@elevasis/ui 1.7.4 → 1.7.5

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.
@@ -0,0 +1,1590 @@
1
+ import { getTimeRangeLabel, getTimeRangeDates, useErrorTrends, formatBucketTime } from './chunk-6HZAMY6T.js';
2
+ import { ResourceStatusColors } from './chunk-YZ6GTZXL.js';
3
+ import { getResourceIcon } from './chunk-LFYO3MDC.js';
4
+ import { getErrorInfo, getErrorTitle } from './chunk-4VGWQ5AN.js';
5
+ import { useAuthContext } from './chunk-7PLEQFHO.js';
6
+ import { useRouterContext } from './chunk-Q7DJKLEN.js';
7
+ import { useMemo, useState, useEffect, useCallback } from 'react';
8
+ import { useComputedColorScheme, Group, Text, Box, Stack, Center, Title, Button, Loader, Badge, Collapse, ScrollArea, Card, Skeleton, Select, Alert, Code, ThemeIcon, Paper, Grid, NumberFormatter, Space, Tooltip as Tooltip$1, SimpleGrid, SegmentedControl } from '@mantine/core';
9
+ import { ResponsiveContainer, AreaChart, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine as ReferenceLine$1, Area, PieChart, Pie, Cell } from 'recharts';
10
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
11
+ import { IconMinus, IconTrendingUp, IconTrendingDown, IconChevronUp, IconChevronDown, IconAlertCircle, IconClock, IconInfoCircle, IconChevronRight, IconDownload, IconChartLine, IconApps, IconPlayerPlay, IconChartBar, IconAlertTriangle, IconRocket } from '@tabler/icons-react';
12
+ import Markdown from 'react-markdown';
13
+ import { Prism } from 'react-syntax-highlighter';
14
+ import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
15
+
16
+ var THEME_DERIVED = {
17
+ grid: "var(--color-border)",
18
+ gridLine: "var(--color-border)",
19
+ tickText: "var(--mantine-color-dimmed)",
20
+ tooltipBg: "var(--glass-background)",
21
+ tooltipBorder: "var(--color-border)",
22
+ tooltipText: "var(--mantine-color-dimmed)",
23
+ dotStroke: "var(--mantine-color-body)"
24
+ };
25
+ var DARK = {
26
+ cyan: "#00e5ff",
27
+ cyanDim: "#00b8d4",
28
+ blue: "#448aff",
29
+ green: "#00ff88",
30
+ greenDim: "#00c853",
31
+ red: "#ff1744",
32
+ redDim: "#d50000",
33
+ yellow: "#ffab00",
34
+ magenta: "#ff4081",
35
+ ...THEME_DERIVED,
36
+ cardGlow: "0 0 30px rgba(0, 229, 255, 0.06)"
37
+ };
38
+ var LIGHT = {
39
+ cyan: "#0091ea",
40
+ cyanDim: "#0277bd",
41
+ blue: "#4d8af0",
42
+ green: "#00a854",
43
+ greenDim: "#00873e",
44
+ red: "#d32f2f",
45
+ redDim: "#b71c1c",
46
+ yellow: "#f9a825",
47
+ magenta: "#c51162",
48
+ ...THEME_DERIVED,
49
+ cardGlow: "0 0 20px rgba(0, 145, 234, 0.06)"
50
+ };
51
+ function useCyberColors() {
52
+ const scheme = useComputedColorScheme("dark");
53
+ return useMemo(() => scheme === "dark" ? DARK : LIGHT, [scheme]);
54
+ }
55
+ function getSeriesColor(key, colors) {
56
+ switch (key) {
57
+ case "Success Rate":
58
+ return colors.cyan;
59
+ case "Executions":
60
+ return colors.blue;
61
+ case "Success Count":
62
+ return colors.green;
63
+ case "Error Count":
64
+ return colors.red;
65
+ default:
66
+ return colors.cyan;
67
+ }
68
+ }
69
+ var ReferenceLine = ReferenceLine$1;
70
+ function CyberDefs({ colors }) {
71
+ const gradients = [
72
+ { id: "gradCyan", color: colors.cyan, opacity: 0.35 },
73
+ { id: "gradBlue", color: colors.blue, opacity: 0.3 },
74
+ { id: "gradGreen", color: colors.green, opacity: 0.3 },
75
+ { id: "gradRed", color: colors.red, opacity: 0.3 },
76
+ { id: "gradYellow", color: colors.yellow, opacity: 0.3 }
77
+ ];
78
+ const filters = [
79
+ { id: "glowCyan", std: 3 },
80
+ { id: "glowBlue", std: 3 },
81
+ { id: "glowGreen", std: 2.5 },
82
+ { id: "glowRed", std: 2.5 },
83
+ { id: "glowYellow", std: 2.5 }
84
+ ];
85
+ return /* @__PURE__ */ jsxs("defs", { children: [
86
+ gradients.map((g) => /* @__PURE__ */ jsxs("linearGradient", { id: g.id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
87
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: g.color, stopOpacity: g.opacity }),
88
+ /* @__PURE__ */ jsx("stop", { offset: "60%", stopColor: g.color, stopOpacity: g.opacity * 0.2 }),
89
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: g.color, stopOpacity: 0 })
90
+ ] }, g.id)),
91
+ filters.map((f) => /* @__PURE__ */ jsxs("filter", { id: f.id, x: "-20%", y: "-20%", width: "140%", height: "140%", children: [
92
+ /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: f.std, result: "blur" }),
93
+ /* @__PURE__ */ jsxs("feMerge", { children: [
94
+ /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
95
+ /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
96
+ ] })
97
+ ] }, f.id)),
98
+ /* @__PURE__ */ jsxs("filter", { id: "dotGlow", x: "-50%", y: "-50%", width: "200%", height: "200%", children: [
99
+ /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "4", result: "blur" }),
100
+ /* @__PURE__ */ jsxs("feMerge", { children: [
101
+ /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
102
+ /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
103
+ /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
104
+ ] })
105
+ ] }),
106
+ /* @__PURE__ */ jsxs("filter", { id: "pulseGlow", x: "-30%", y: "-30%", width: "160%", height: "160%", children: [
107
+ /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "5", result: "blur" }),
108
+ /* @__PURE__ */ jsxs("feMerge", { children: [
109
+ /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
110
+ /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
111
+ /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
112
+ ] })
113
+ ] })
114
+ ] });
115
+ }
116
+ function PulseDefs({ series, colors, isLight }) {
117
+ return /* @__PURE__ */ jsx("defs", { children: series.map((s, i) => {
118
+ const color = colors[s.color ?? "cyan"];
119
+ const dur = "6s";
120
+ const delay = "0s";
121
+ const keyTimes = "0;0.3;1";
122
+ const keySplines = "0.33 0 0.67 1;0 0 1 1";
123
+ const animateProps = {
124
+ dur,
125
+ keyTimes,
126
+ keySplines,
127
+ repeatCount: "indefinite",
128
+ calcMode: "spline",
129
+ begin: delay
130
+ };
131
+ return /* @__PURE__ */ jsxs("linearGradient", { id: `pulse-${i}`, x1: "0", y1: "0", x2: "1", y2: "0", children: [
132
+ /* @__PURE__ */ jsx("stop", { offset: "0", stopColor: color, stopOpacity: 0, children: /* @__PURE__ */ jsx("animate", { attributeName: "offset", values: "-0.15;1.0;1.0", ...animateProps }) }),
133
+ /* @__PURE__ */ jsx("stop", { offset: "0", stopColor: isLight ? "white" : color, stopOpacity: isLight ? 0.6 : 0.9, children: /* @__PURE__ */ jsx("animate", { attributeName: "offset", values: "-0.075;1.075;1.075", ...animateProps }) }),
134
+ /* @__PURE__ */ jsx("stop", { offset: "0", stopColor: color, stopOpacity: 0, children: /* @__PURE__ */ jsx("animate", { attributeName: "offset", values: "0;1.15;1.15", ...animateProps }) })
135
+ ] }, i);
136
+ }) });
137
+ }
138
+ function CyberActiveDot({
139
+ cx,
140
+ cy,
141
+ color,
142
+ dotStroke
143
+ }) {
144
+ if (cx == null || cy == null) return null;
145
+ return /* @__PURE__ */ jsxs("g", { filter: "url(#dotGlow)", children: [
146
+ /* @__PURE__ */ jsxs("circle", { cx, cy, r: 6, fill: "none", stroke: color, strokeWidth: 2, opacity: 0.5, children: [
147
+ /* @__PURE__ */ jsx("animate", { attributeName: "r", from: "4", to: "10", dur: "1.2s", repeatCount: "indefinite" }),
148
+ /* @__PURE__ */ jsx("animate", { attributeName: "opacity", from: "0.6", to: "0", dur: "1.2s", repeatCount: "indefinite" })
149
+ ] }),
150
+ /* @__PURE__ */ jsx("circle", { cx, cy, r: 4, fill: color, stroke: dotStroke, strokeWidth: 2 })
151
+ ] });
152
+ }
153
+ function CyberTooltipContent({
154
+ active,
155
+ payload,
156
+ label,
157
+ colors,
158
+ labelFormatter,
159
+ valueFormatter
160
+ }) {
161
+ if (!active || !payload?.length) return null;
162
+ const filtered = payload.filter((entry) => !entry.name?.startsWith("_pulse_"));
163
+ if (!filtered.length) return null;
164
+ const displayLabel = label && labelFormatter ? labelFormatter(label) : label;
165
+ return /* @__PURE__ */ jsxs(
166
+ "div",
167
+ {
168
+ style: {
169
+ background: colors.tooltipBg,
170
+ border: `1px solid ${colors.tooltipBorder}`,
171
+ borderRadius: 8,
172
+ padding: "10px 14px",
173
+ backdropFilter: "var(--glass-blur)",
174
+ WebkitBackdropFilter: "var(--glass-blur)",
175
+ boxShadow: "var(--standard-box-shadow)",
176
+ fontFamily: "var(--mantine-font-family-monospace, monospace)",
177
+ minWidth: 160
178
+ },
179
+ children: [
180
+ /* @__PURE__ */ jsx(
181
+ "div",
182
+ {
183
+ style: {
184
+ fontSize: 11,
185
+ color: colors.tickText,
186
+ marginBottom: 8,
187
+ letterSpacing: "0.05em",
188
+ textTransform: "uppercase",
189
+ borderBottom: `1px solid ${colors.tooltipBorder}`,
190
+ paddingBottom: 6
191
+ },
192
+ children: displayLabel
193
+ }
194
+ ),
195
+ filtered.map((entry) => {
196
+ const color = entry.color || getSeriesColor(entry.dataKey, colors);
197
+ return /* @__PURE__ */ jsxs(
198
+ "div",
199
+ {
200
+ style: {
201
+ display: "flex",
202
+ justifyContent: "space-between",
203
+ alignItems: "center",
204
+ gap: 16,
205
+ padding: "3px 0",
206
+ fontSize: 12
207
+ },
208
+ children: [
209
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
210
+ /* @__PURE__ */ jsx(
211
+ "div",
212
+ {
213
+ style: {
214
+ width: 8,
215
+ height: 8,
216
+ borderRadius: "50%",
217
+ backgroundColor: color,
218
+ boxShadow: `0 0 6px ${color}`
219
+ }
220
+ }
221
+ ),
222
+ /* @__PURE__ */ jsx("span", { style: { color: colors.tooltipText }, children: entry.name ?? entry.dataKey })
223
+ ] }),
224
+ /* @__PURE__ */ jsx("span", { style: { color, fontWeight: 600, fontVariantNumeric: "tabular-nums" }, children: entry.value != null && valueFormatter ? valueFormatter(entry.value) : String(entry.value) })
225
+ ]
226
+ },
227
+ entry.dataKey
228
+ );
229
+ })
230
+ ]
231
+ }
232
+ );
233
+ }
234
+ function CyberLegendItem({ color, label }) {
235
+ return /* @__PURE__ */ jsxs(Group, { gap: 8, children: [
236
+ /* @__PURE__ */ jsx(
237
+ "div",
238
+ {
239
+ style: {
240
+ width: 10,
241
+ height: 10,
242
+ borderRadius: "50%",
243
+ backgroundColor: color,
244
+ boxShadow: `0 0 8px ${color}, 0 0 16px ${color}40`
245
+ }
246
+ }
247
+ ),
248
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", style: { letterSpacing: "0.03em" }, children: label })
249
+ ] });
250
+ }
251
+ var COLOR_MAP = {
252
+ cyan: { gradient: "url(#gradCyan)", filter: "url(#glowCyan)", key: "cyan" },
253
+ blue: { gradient: "url(#gradBlue)", filter: "url(#glowBlue)", key: "blue" },
254
+ green: { gradient: "url(#gradGreen)", filter: "url(#glowGreen)", key: "green" },
255
+ red: { gradient: "url(#gradRed)", filter: "url(#glowRed)", key: "red" },
256
+ yellow: { gradient: "url(#gradYellow)", filter: "url(#glowYellow)", key: "yellow" }
257
+ };
258
+ function CyberAreaChart({
259
+ data,
260
+ series,
261
+ xDataKey = "time",
262
+ height = 300,
263
+ yAxisLabel,
264
+ yDomain,
265
+ yTickFormatter,
266
+ showGrid = true,
267
+ showZeroBaseline = true,
268
+ baselineColor,
269
+ lineOnly = false,
270
+ margin = { top: 8, right: 20, left: 0, bottom: 0 },
271
+ xTickFormatter,
272
+ tooltipFormatter
273
+ }) {
274
+ const isLight = useComputedColorScheme("dark") === "light";
275
+ const colors = useCyberColors();
276
+ const [ready, setReady] = useState(false);
277
+ useEffect(() => {
278
+ const frame = requestAnimationFrame(() => setReady(true));
279
+ return () => cancelAnimationFrame(frame);
280
+ }, []);
281
+ const allZero = useMemo(() => {
282
+ if (!showZeroBaseline || !data.length) return false;
283
+ return data.every((row) => series.every((s) => row[s.dataKey] === 0));
284
+ }, [data, series, showZeroBaseline]);
285
+ if (!ready || !data.length) return /* @__PURE__ */ jsx(Box, { style: { height } });
286
+ const gridProps = {
287
+ stroke: colors.gridLine,
288
+ strokeDasharray: "3 6",
289
+ strokeOpacity: 1
290
+ };
291
+ const xAxisConfig = {
292
+ stroke: "none",
293
+ tick: {
294
+ fill: colors.tickText,
295
+ fontSize: 11,
296
+ fontFamily: "var(--mantine-font-family-monospace, monospace)"
297
+ },
298
+ tickLine: false,
299
+ axisLine: { stroke: colors.grid, strokeWidth: 1 }
300
+ };
301
+ const yTickStyle = {
302
+ fill: colors.tickText,
303
+ fontSize: 11,
304
+ fontFamily: "var(--mantine-font-family-monospace, monospace)"
305
+ };
306
+ return /* @__PURE__ */ jsx(Box, { style: { width: "100%", height }, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(AreaChart, { data, margin, children: [
307
+ /* @__PURE__ */ jsx(CyberDefs, { colors }),
308
+ /* @__PURE__ */ jsx(PulseDefs, { series, colors, isLight }),
309
+ showGrid && /* @__PURE__ */ jsx(CartesianGrid, { ...gridProps }),
310
+ /* @__PURE__ */ jsx(XAxis, { dataKey: xDataKey, ...xAxisConfig, tickFormatter: xTickFormatter }),
311
+ /* @__PURE__ */ jsx(
312
+ YAxis,
313
+ {
314
+ domain: yDomain ?? [0, (max) => Math.max(max, 1)],
315
+ allowDecimals: false,
316
+ stroke: "none",
317
+ tick: yTickStyle,
318
+ tickFormatter: yTickFormatter,
319
+ tickLine: false,
320
+ axisLine: { stroke: colors.grid, strokeWidth: 1 },
321
+ label: yAxisLabel ? {
322
+ value: yAxisLabel,
323
+ angle: -90,
324
+ position: "insideLeft",
325
+ offset: 0,
326
+ style: { fill: colors.tickText, fontSize: 11 }
327
+ } : void 0
328
+ }
329
+ ),
330
+ /* @__PURE__ */ jsx(
331
+ Tooltip,
332
+ {
333
+ content: /* @__PURE__ */ jsx(CyberTooltipContent, { colors, labelFormatter: xTickFormatter, valueFormatter: tooltipFormatter }),
334
+ cursor: { stroke: colors.cyan, strokeOpacity: 0.2 }
335
+ }
336
+ ),
337
+ allZero && (() => {
338
+ const bColor = colors[baselineColor ?? series[0]?.color ?? "cyan"];
339
+ return /* @__PURE__ */ jsx(
340
+ ReferenceLine,
341
+ {
342
+ y: 0,
343
+ stroke: bColor,
344
+ strokeWidth: 2,
345
+ style: {
346
+ filter: `drop-shadow(0 0 4px ${bColor}) drop-shadow(0 0 8px ${bColor})`
347
+ }
348
+ }
349
+ );
350
+ })(),
351
+ series.map((s) => {
352
+ const cm = COLOR_MAP[s.color ?? "cyan"];
353
+ const strokeColor = colors[cm.key];
354
+ return /* @__PURE__ */ jsx(
355
+ Area,
356
+ {
357
+ type: "monotone",
358
+ dataKey: s.dataKey,
359
+ name: s.name ?? s.dataKey,
360
+ stroke: strokeColor,
361
+ strokeWidth: lineOnly ? 3 : 2,
362
+ fill: lineOnly ? "transparent" : cm.gradient,
363
+ filter: cm.filter,
364
+ dot: false,
365
+ activeDot: /* @__PURE__ */ jsx(CyberActiveDot, { color: strokeColor, dotStroke: colors.dotStroke }),
366
+ animationBegin: 100,
367
+ animationDuration: s.animationDuration ?? 1200,
368
+ animationEasing: "ease-out"
369
+ },
370
+ s.dataKey
371
+ );
372
+ }),
373
+ series.map((s, i) => /* @__PURE__ */ jsx(
374
+ Area,
375
+ {
376
+ type: "monotone",
377
+ dataKey: s.dataKey,
378
+ name: `_pulse_${s.dataKey}`,
379
+ stroke: `url(#pulse-${i})`,
380
+ strokeWidth: 3,
381
+ fill: "none",
382
+ filter: "url(#pulseGlow)",
383
+ dot: false,
384
+ activeDot: false,
385
+ tooltipType: "none",
386
+ isAnimationActive: false,
387
+ style: { pointerEvents: "none" }
388
+ },
389
+ `pulse-${s.dataKey}`
390
+ ))
391
+ ] }) }) });
392
+ }
393
+ function CyberDonutTooltip({
394
+ active,
395
+ payload,
396
+ colors
397
+ }) {
398
+ if (!active || !payload?.length) return null;
399
+ const entry = payload[0];
400
+ if (!entry) return null;
401
+ const color = entry.payload?.color ?? colors.cyan;
402
+ return /* @__PURE__ */ jsxs(
403
+ "div",
404
+ {
405
+ style: {
406
+ background: colors.tooltipBg,
407
+ border: `1px solid ${colors.tooltipBorder}`,
408
+ borderRadius: 8,
409
+ padding: "8px 12px",
410
+ backdropFilter: "var(--glass-blur)",
411
+ WebkitBackdropFilter: "var(--glass-blur)",
412
+ boxShadow: "var(--standard-box-shadow)",
413
+ fontFamily: "var(--mantine-font-family-monospace, monospace)",
414
+ display: "flex",
415
+ alignItems: "center",
416
+ gap: 10
417
+ },
418
+ children: [
419
+ /* @__PURE__ */ jsx(
420
+ "div",
421
+ {
422
+ style: {
423
+ width: 8,
424
+ height: 8,
425
+ borderRadius: "50%",
426
+ backgroundColor: color,
427
+ boxShadow: `0 0 6px ${color}`
428
+ }
429
+ }
430
+ ),
431
+ /* @__PURE__ */ jsx("span", { style: { color: colors.tooltipText, fontSize: 12 }, children: entry.name }),
432
+ /* @__PURE__ */ jsx("span", { style: { color, fontWeight: 600, fontSize: 12, fontVariantNumeric: "tabular-nums" }, children: entry.value })
433
+ ]
434
+ }
435
+ );
436
+ }
437
+ function CyberDonut({
438
+ title,
439
+ segments,
440
+ centerValue,
441
+ centerLabel,
442
+ centerValueColor = "var(--mantine-color-text)",
443
+ glowId,
444
+ colors,
445
+ size = 120,
446
+ innerRadius = 36,
447
+ outerRadius = 52,
448
+ isLoading,
449
+ showLegend = true
450
+ }) {
451
+ const filtered = segments.filter((s) => s.value > 0);
452
+ const isEmpty = filtered.length === 0;
453
+ const pieData = isEmpty ? [{ name: "Empty", value: 1, color: "var(--color-border)" }] : filtered;
454
+ return /* @__PURE__ */ jsxs(Stack, { gap: 6, align: "center", children: [
455
+ title && /* @__PURE__ */ jsx(Text, { size: "xs", fw: 600, c: "dimmed", style: { letterSpacing: "0.03em", textTransform: "uppercase" }, children: title }),
456
+ /* @__PURE__ */ jsxs(Box, { style: { width: size, height: size, position: "relative" }, children: [
457
+ /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(PieChart, { children: [
458
+ !isEmpty && /* @__PURE__ */ jsx("defs", { children: filtered.map((_, i) => /* @__PURE__ */ jsxs("filter", { id: `${glowId}-${i}`, x: "-20%", y: "-20%", width: "140%", height: "140%", children: [
459
+ /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "2", result: "blur" }),
460
+ /* @__PURE__ */ jsxs("feMerge", { children: [
461
+ /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
462
+ /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
463
+ ] })
464
+ ] }, i)) }),
465
+ /* @__PURE__ */ jsx(
466
+ Pie,
467
+ {
468
+ data: pieData,
469
+ cx: "50%",
470
+ cy: "50%",
471
+ innerRadius,
472
+ outerRadius,
473
+ paddingAngle: isEmpty ? 0 : 3,
474
+ dataKey: "value",
475
+ stroke: "none",
476
+ animationBegin: 100,
477
+ animationDuration: 1e3,
478
+ animationEasing: "ease-out",
479
+ isAnimationActive: !isEmpty,
480
+ children: pieData.map((entry, i) => /* @__PURE__ */ jsx(
481
+ Cell,
482
+ {
483
+ fill: entry.color,
484
+ style: {
485
+ filter: isEmpty ? void 0 : `url(#${glowId}-${i})`,
486
+ fillOpacity: isEmpty ? 0.3 : 0.9
487
+ }
488
+ },
489
+ entry.name
490
+ ))
491
+ }
492
+ ),
493
+ !isEmpty && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CyberDonutTooltip, { colors }) })
494
+ ] }) }),
495
+ /* @__PURE__ */ jsxs(
496
+ "div",
497
+ {
498
+ style: {
499
+ position: "absolute",
500
+ top: "50%",
501
+ left: "50%",
502
+ transform: "translate(-50%, -50%)",
503
+ textAlign: "center",
504
+ pointerEvents: "none"
505
+ },
506
+ children: [
507
+ /* @__PURE__ */ jsx(
508
+ "div",
509
+ {
510
+ style: {
511
+ fontSize: 18,
512
+ fontWeight: 700,
513
+ fontFamily: "var(--mantine-font-family-monospace, monospace)",
514
+ color: centerValueColor,
515
+ lineHeight: 1
516
+ },
517
+ children: isLoading ? "-" : centerValue
518
+ }
519
+ ),
520
+ /* @__PURE__ */ jsx(
521
+ "div",
522
+ {
523
+ style: {
524
+ fontSize: 8,
525
+ color: "var(--mantine-color-dimmed)",
526
+ letterSpacing: "0.05em",
527
+ textTransform: "uppercase",
528
+ marginTop: 2
529
+ },
530
+ children: centerLabel
531
+ }
532
+ )
533
+ ]
534
+ }
535
+ )
536
+ ] }),
537
+ showLegend && /* @__PURE__ */ jsx(Stack, { gap: 4, style: { width: "100%" }, children: segments.map((seg) => /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", px: "xs", children: [
538
+ /* @__PURE__ */ jsx(CyberLegendItem, { color: seg.color, label: seg.name }),
539
+ /* @__PURE__ */ jsx(
540
+ Text,
541
+ {
542
+ size: "xs",
543
+ fw: 600,
544
+ style: {
545
+ fontFamily: "var(--mantine-font-family-monospace, monospace)",
546
+ fontVariantNumeric: "tabular-nums"
547
+ },
548
+ children: isLoading ? "-" : seg.value
549
+ }
550
+ )
551
+ ] }, seg.name)) })
552
+ ] });
553
+ }
554
+ function EmptyState({ icon: Icon, title, description, action, py = "xl" }) {
555
+ return /* @__PURE__ */ jsx(Center, { py, children: /* @__PURE__ */ jsxs(Stack, { align: "center", gap: "xs", children: [
556
+ /* @__PURE__ */ jsx(Icon, { size: 48, style: { opacity: 0.5 } }),
557
+ /* @__PURE__ */ jsx(Title, { order: 4, children: title }),
558
+ description && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", ta: "center", children: description }),
559
+ action && /* @__PURE__ */ jsx(Button, { variant: "light", onClick: action.onClick, leftSection: action.icon, mt: "sm", children: action.label })
560
+ ] }) });
561
+ }
562
+ function TabCountBadge({ count, isLoading }) {
563
+ return /* @__PURE__ */ jsx(Box, { miw: 20, h: 20, style: { display: "flex", alignItems: "center", justifyContent: "center" }, children: isLoading ? /* @__PURE__ */ jsx(Loader, { size: 12 }) : /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", circle: count < 10, children: count }) });
564
+ }
565
+ function TrendIndicator({ current, previous, inverse }) {
566
+ const change = previous === 0 ? 0 : (current - previous) / previous * 100;
567
+ const isPositive = inverse ? change < 0 : change > 0;
568
+ const isFlat = Math.abs(change) < 0.1;
569
+ const color = isFlat ? "gray" : isPositive ? "green" : "red";
570
+ const Icon = isFlat ? IconMinus : change > 0 ? IconTrendingUp : IconTrendingDown;
571
+ return /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
572
+ /* @__PURE__ */ jsx(Icon, { size: 12 }),
573
+ /* @__PURE__ */ jsx(Badge, { size: "sm", color, variant: "light", children: isFlat ? "No change" : `${isPositive ? "+" : ""}${Math.abs(change).toFixed(1)}%` })
574
+ ] });
575
+ }
576
+ function CollapsibleSection({
577
+ title,
578
+ count,
579
+ countLabel,
580
+ children,
581
+ emptyMessage,
582
+ defaultExpanded = true,
583
+ maxHeight = 300
584
+ }) {
585
+ const [expanded, setExpanded] = useState(defaultExpanded);
586
+ const isEmpty = count === 0;
587
+ return /* @__PURE__ */ jsxs(
588
+ "div",
589
+ {
590
+ style: {
591
+ borderRadius: "8px",
592
+ padding: "8px",
593
+ border: "1px solid var(--color-border)",
594
+ boxShadow: "var(--standard-box-shadow)"
595
+ },
596
+ children: [
597
+ /* @__PURE__ */ jsxs(
598
+ Group,
599
+ {
600
+ gap: "xs",
601
+ mb: expanded ? "xs" : 0,
602
+ justify: "space-between",
603
+ align: "center",
604
+ style: { cursor: "pointer" },
605
+ onClick: () => setExpanded(!expanded),
606
+ children: [
607
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "center", style: { flex: 1 }, children: [
608
+ typeof title === "string" ? /* @__PURE__ */ jsx(
609
+ Text,
610
+ {
611
+ fw: 600,
612
+ size: "sm",
613
+ c: "var(--color-text)",
614
+ style: { fontFamily: "var(--elevasis-font-family-subtitle)" },
615
+ children: title
616
+ }
617
+ ) : title,
618
+ count !== void 0 && countLabel && /* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "light", color: "gray", children: [
619
+ count,
620
+ " ",
621
+ count === 1 ? countLabel.replace(/s$/, "") : countLabel
622
+ ] })
623
+ ] }),
624
+ expanded ? /* @__PURE__ */ jsx(IconChevronUp, { size: 16 }) : /* @__PURE__ */ jsx(IconChevronDown, { size: 16 })
625
+ ]
626
+ }
627
+ ),
628
+ /* @__PURE__ */ jsx(Collapse, { in: expanded, children: isEmpty && emptyMessage ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: emptyMessage }) : /* @__PURE__ */ jsx(ScrollArea, { h: maxHeight, type: "scroll", offsetScrollbars: true, children }) })
629
+ ]
630
+ }
631
+ );
632
+ }
633
+ var PageTitleCaption = ({ title, caption, rightSection }) => {
634
+ const renderCaption = () => {
635
+ if (!caption) return null;
636
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Text, { c: "dimmed", style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: caption }) });
637
+ };
638
+ const titleContent = /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
639
+ /* @__PURE__ */ jsx(Title, { order: 1, children: title }),
640
+ /* @__PURE__ */ jsx(Space, { h: "4" }),
641
+ renderCaption()
642
+ ] });
643
+ if (!rightSection) {
644
+ return titleContent;
645
+ }
646
+ return /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "end", children: [
647
+ titleContent,
648
+ rightSection
649
+ ] });
650
+ };
651
+ function StatsCardSkeleton({ chartHeight = 120, withChart = true, statCount = 3 }) {
652
+ return /* @__PURE__ */ jsxs(Card, { withBorder: true, children: [
653
+ /* @__PURE__ */ jsx(Skeleton, { height: 24, width: 150, mb: "md" }),
654
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "xl", children: [
655
+ /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 100 }),
656
+ statCount >= 2 && /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 100 }),
657
+ /* @__PURE__ */ jsx(Skeleton, { height: 40, circle: true })
658
+ ] }),
659
+ withChart && /* @__PURE__ */ jsx(Skeleton, { height: chartHeight })
660
+ ] });
661
+ }
662
+ function ListSkeleton({ rows = 3, rowHeight = 50 }) {
663
+ return /* @__PURE__ */ jsx(Stack, { gap: "xs", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { height: rowHeight }, i)) });
664
+ }
665
+ function DetailCardSkeleton({ rows = 3 }) {
666
+ return /* @__PURE__ */ jsxs(Card, { withBorder: true, children: [
667
+ /* @__PURE__ */ jsx(Skeleton, { height: 24, width: 150, mb: "md" }),
668
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "lg", children: [
669
+ /* @__PURE__ */ jsx(Skeleton, { height: 80, width: 100 }),
670
+ /* @__PURE__ */ jsx(Skeleton, { height: 80, width: 100 }),
671
+ /* @__PURE__ */ jsx(Skeleton, { height: 40, circle: true })
672
+ ] }),
673
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { height: 60 }, i)) })
674
+ ] });
675
+ }
676
+ function CustomSelector({
677
+ value,
678
+ onChange,
679
+ data,
680
+ leftSection,
681
+ placeholder,
682
+ w,
683
+ withCheckIcon = false,
684
+ disabled
685
+ }) {
686
+ return /* @__PURE__ */ jsx(
687
+ Select,
688
+ {
689
+ value,
690
+ onChange,
691
+ data,
692
+ leftSection,
693
+ placeholder,
694
+ w,
695
+ size: "xs",
696
+ variant: "unstyled",
697
+ withCheckIcon,
698
+ disabled,
699
+ styles: {
700
+ wrapper: {
701
+ border: "1px solid var(--color-border)",
702
+ borderRadius: "var(--mantine-radius-default)",
703
+ backgroundColor: "var(--color-surface)",
704
+ transition: "border-color 150ms ease, background-color 150ms ease",
705
+ "&:hover": {
706
+ borderColor: "var(--color-border-hover, var(--mantine-color-dark-3))"
707
+ }
708
+ },
709
+ input: {
710
+ fontSize: "var(--mantine-font-size-xs)",
711
+ fontWeight: 500,
712
+ height: "30px",
713
+ minHeight: "30px",
714
+ paddingLeft: leftSection ? "30px" : void 0,
715
+ borderRadius: "var(--mantine-radius-default)",
716
+ cursor: "pointer"
717
+ },
718
+ section: {
719
+ color: "var(--color-text-subtle)"
720
+ },
721
+ dropdown: {
722
+ border: "1px solid var(--color-border)",
723
+ backgroundColor: "var(--color-surface)",
724
+ boxShadow: "var(--card-shadow)"
725
+ },
726
+ option: {
727
+ fontSize: "var(--mantine-font-size-xs)"
728
+ }
729
+ }
730
+ }
731
+ );
732
+ }
733
+ function APIErrorAlert({
734
+ error,
735
+ title,
736
+ showRequestId = true,
737
+ icon = /* @__PURE__ */ jsx(IconAlertCircle, {}),
738
+ color = "red"
739
+ }) {
740
+ const { message, code, requestId, retryAfter } = getErrorInfo(error);
741
+ const alertTitle = title || getErrorTitle(code);
742
+ return /* @__PURE__ */ jsxs(Alert, { icon, title: alertTitle, color, variant: "light", children: [
743
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: message }),
744
+ retryAfter && /* @__PURE__ */ jsxs(Text, { size: "sm", mt: "xs", children: [
745
+ "Please wait ",
746
+ retryAfter,
747
+ " seconds before retrying."
748
+ ] }),
749
+ showRequestId && requestId && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", mt: "xs", children: [
750
+ "Request ID: ",
751
+ /* @__PURE__ */ jsx(Code, { children: requestId })
752
+ ] })
753
+ ] });
754
+ }
755
+
756
+ // src/components/display/StatCard.module.css.js
757
+ var StatCard_module_css_default = { "heroCard": "heroCard", "iconRing": "iconRing", "iconRingSm": "iconRingSm", "heroValue": "heroValue", "heroValueSm": "heroValueSm", "heroLabel": "heroLabel", "heroLabelSm": "heroLabelSm" };
758
+ function StatCard(props) {
759
+ if (props.variant === "hero") {
760
+ return /* @__PURE__ */ jsx(HeroStatCard, { ...props });
761
+ }
762
+ const { label, value, icon: IconComponent, color } = props;
763
+ return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
764
+ /* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color, children: /* @__PURE__ */ jsx(IconComponent, { size: 18 }) }),
765
+ /* @__PURE__ */ jsxs("div", { children: [
766
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: label }),
767
+ /* @__PURE__ */ jsx(Text, { size: "lg", fw: 600, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: value })
768
+ ] })
769
+ ] }) });
770
+ }
771
+ function HeroStatCard({
772
+ icon: IconComponent,
773
+ value,
774
+ label,
775
+ valueColor,
776
+ isLoading,
777
+ size = "sm",
778
+ children
779
+ }) {
780
+ const sm = size === "sm";
781
+ const iconSize = sm ? 36 : 46;
782
+ if (isLoading) {
783
+ return /* @__PURE__ */ jsx(Paper, { p: sm ? "md" : "lg", className: StatCard_module_css_default.heroCard, children: /* @__PURE__ */ jsxs(Group, { gap: sm ? "sm" : "md", wrap: "nowrap", children: [
784
+ /* @__PURE__ */ jsx(Skeleton, { circle: true, height: iconSize }),
785
+ /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
786
+ /* @__PURE__ */ jsx(Skeleton, { height: sm ? 24 : 32, width: 60 }),
787
+ /* @__PURE__ */ jsx(Skeleton, { height: 12, width: 80 })
788
+ ] })
789
+ ] }) });
790
+ }
791
+ return /* @__PURE__ */ jsx(Paper, { p: sm ? "md" : "lg", className: StatCard_module_css_default.heroCard, children: /* @__PURE__ */ jsxs(Group, { gap: sm ? "sm" : "md", wrap: "nowrap", children: [
792
+ /* @__PURE__ */ jsx("div", { className: sm ? StatCard_module_css_default.iconRingSm : StatCard_module_css_default.iconRing, children: /* @__PURE__ */ jsx(IconComponent, { size: sm ? 18 : 22 }) }),
793
+ /* @__PURE__ */ jsxs(Stack, { gap: 2, style: { flex: children ? 1 : void 0 }, children: [
794
+ /* @__PURE__ */ jsx(
795
+ "span",
796
+ {
797
+ className: sm ? StatCard_module_css_default.heroValueSm : StatCard_module_css_default.heroValue,
798
+ style: valueColor ? { color: valueColor } : void 0,
799
+ children: value
800
+ }
801
+ ),
802
+ children ? /* @__PURE__ */ jsxs(Group, { gap: "sm", wrap: "nowrap", style: { flex: 1 }, children: [
803
+ /* @__PURE__ */ jsx("span", { className: sm ? StatCard_module_css_default.heroLabelSm : StatCard_module_css_default.heroLabel, children: label }),
804
+ /* @__PURE__ */ jsx("div", { style: { flex: 1 }, children })
805
+ ] }) : /* @__PURE__ */ jsx("span", { className: sm ? StatCard_module_css_default.heroLabelSm : StatCard_module_css_default.heroLabel, children: label })
806
+ ] })
807
+ ] }) });
808
+ }
809
+ function StatCardSkeleton() {
810
+ return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsx(Skeleton, { height: 60 }) });
811
+ }
812
+ var customCodeTheme = Object.fromEntries(
813
+ Object.entries(oneDark).map(([key, value]) => [
814
+ key,
815
+ typeof value === "object" && value !== null ? { ...value, background: "none", backgroundColor: "none" } : value
816
+ ])
817
+ );
818
+ var defaultComponents = {
819
+ h1: ({ children }) => /* @__PURE__ */ jsx(Title, { order: 3, c: "var(--color-primary)", mb: "xs", mt: "md", children }),
820
+ h2: ({ children }) => /* @__PURE__ */ jsx(Title, { order: 4, c: "var(--color-primary)", mb: "xs", mt: "sm", children }),
821
+ ul: ({ children }) => /* @__PURE__ */ jsx("ul", { style: { margin: "0.5rem 0", paddingLeft: "1.5rem" }, children }),
822
+ ol: ({ children }) => /* @__PURE__ */ jsx("ol", { style: { margin: "0.5rem 0", paddingLeft: "1.5rem" }, children }),
823
+ li: ({ children }) => /* @__PURE__ */ jsx("li", { style: { marginBottom: "0.25rem", fontSize: "var(--mantine-font-size-sm)" }, children }),
824
+ code: ({ className, children, ...props }) => {
825
+ const match = /language-(\w+)/.exec(className || "");
826
+ const codeString = String(children).replace(/\n$/, "");
827
+ if (match) {
828
+ return /* @__PURE__ */ jsx(
829
+ Prism,
830
+ {
831
+ style: customCodeTheme,
832
+ language: match[1],
833
+ PreTag: "div",
834
+ customStyle: {
835
+ margin: "0.5rem 0",
836
+ borderRadius: "var(--mantine-radius-default)",
837
+ fontSize: "0.8rem"
838
+ },
839
+ children: codeString
840
+ }
841
+ );
842
+ }
843
+ return /* @__PURE__ */ jsx(Code, { ...props, children });
844
+ },
845
+ pre: ({ children }) => /* @__PURE__ */ jsx(Fragment, { children }),
846
+ blockquote: ({ children }) => /* @__PURE__ */ jsx(Box, { pl: "sm", my: "xs", style: { borderLeft: "2px solid var(--color-border)" }, children }),
847
+ p: ({ children }) => /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, children }),
848
+ strong: ({ children }) => /* @__PURE__ */ jsx(Text, { component: "span", fw: 700, children }),
849
+ em: ({ children }) => /* @__PURE__ */ jsx(Text, { component: "span", fs: "italic", children })
850
+ };
851
+ function StyledMarkdown({ children, components, className, style }) {
852
+ const mergedComponents = components ? { ...defaultComponents, ...components } : defaultComponents;
853
+ return /* @__PURE__ */ jsx("div", { className, style, children: /* @__PURE__ */ jsx(Markdown, { components: mergedComponents, children }) });
854
+ }
855
+ var jsonTheme = Object.fromEntries(
856
+ Object.entries(oneDark).map(([key, value]) => [
857
+ key,
858
+ typeof value === "object" && value !== null ? { ...value, background: "none", backgroundColor: "none" } : value
859
+ ])
860
+ );
861
+ function JsonViewer({ data, maxHeight, fontSize = "0.8rem" }) {
862
+ const jsonString = typeof data === "string" ? data : JSON.stringify(data, null, 2);
863
+ return /* @__PURE__ */ jsx(
864
+ Prism,
865
+ {
866
+ language: "json",
867
+ style: jsonTheme,
868
+ customStyle: {
869
+ margin: 0,
870
+ fontSize,
871
+ maxHeight,
872
+ overflow: maxHeight ? "auto" : void 0,
873
+ overflowX: "auto"
874
+ },
875
+ children: jsonString
876
+ }
877
+ );
878
+ }
879
+ var subtleMarkdownComponents = {
880
+ p: ({ children }) => /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, c: "var(--color-text-subtle)", style: { whiteSpace: "pre-wrap" }, children })
881
+ };
882
+ var subtleMarkdownWrapperStyle = {
883
+ display: "flex",
884
+ flexDirection: "column",
885
+ gap: 8
886
+ };
887
+ function ContextViewer({ data }) {
888
+ return /* @__PURE__ */ jsx(ContextNode, { data, depth: 0 });
889
+ }
890
+ function ContextNode({ data, depth }) {
891
+ if (data === null || data === void 0) {
892
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "No context provided" });
893
+ }
894
+ if (typeof data === "string") {
895
+ return /* @__PURE__ */ jsx(StyledMarkdown, { components: subtleMarkdownComponents, style: subtleMarkdownWrapperStyle, children: data });
896
+ }
897
+ if (typeof data === "number" || typeof data === "boolean") {
898
+ return /* @__PURE__ */ jsx(Text, { size: "sm", children: String(data) });
899
+ }
900
+ if (Array.isArray(data)) {
901
+ return /* @__PURE__ */ jsx(ArrayView, { items: data, depth });
902
+ }
903
+ if (typeof data === "object") {
904
+ return /* @__PURE__ */ jsx(ObjectView, { data, depth });
905
+ }
906
+ return /* @__PURE__ */ jsx(Text, { size: "sm", children: String(data) });
907
+ }
908
+ function formatLabel(key) {
909
+ return key.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
910
+ }
911
+ function hasMarkdown(value) {
912
+ return /(\*\*.+\*\*|^#{1,6}\s|^\s*[-*]\s|\[.+\]\(.+\)|^\|.+\|$|^>\s|```)/.test(value);
913
+ }
914
+ function NestedSection({ title, children }) {
915
+ const [expanded, setExpanded] = useState(true);
916
+ return /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
917
+ /* @__PURE__ */ jsxs(Group, { gap: 4, style: { cursor: "pointer", userSelect: "none" }, onClick: () => setExpanded((v) => !v), children: [
918
+ /* @__PURE__ */ jsx(
919
+ IconChevronRight,
920
+ {
921
+ size: 14,
922
+ color: "var(--color-primary)",
923
+ style: {
924
+ transition: "transform 150ms ease",
925
+ transform: expanded ? "rotate(90deg)" : "rotate(0deg)",
926
+ flexShrink: 0
927
+ }
928
+ }
929
+ ),
930
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: title })
931
+ ] }),
932
+ expanded && /* @__PURE__ */ jsx(Box, { pl: "sm", style: { borderLeft: "2px solid var(--color-border)" }, children })
933
+ ] });
934
+ }
935
+ function PrimitiveValue({ value }) {
936
+ if (value === null || value === void 0) {
937
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "\u2014" });
938
+ }
939
+ if (typeof value === "boolean") {
940
+ return /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, children: value ? "Yes" : "No" });
941
+ }
942
+ if (typeof value === "number") {
943
+ return /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, children: value.toLocaleString() });
944
+ }
945
+ const str = String(value);
946
+ if (hasMarkdown(str)) {
947
+ return /* @__PURE__ */ jsx(StyledMarkdown, { components: subtleMarkdownComponents, children: str });
948
+ }
949
+ return /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, c: "var(--color-text-subtle)", style: { whiteSpace: "pre-wrap" }, children: str });
950
+ }
951
+ function ArrayView({ items, depth }) {
952
+ if (items.length === 0) {
953
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "Empty list" });
954
+ }
955
+ const allPrimitive = items.every((item) => typeof item !== "object" || item === null);
956
+ if (allPrimitive) {
957
+ return /* @__PURE__ */ jsx(Stack, { gap: 2, children: items.map((item, i) => /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "flex-start", children: [
958
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { userSelect: "none" }, children: "\u2022" }),
959
+ /* @__PURE__ */ jsx(PrimitiveValue, { value: item })
960
+ ] }, i)) });
961
+ }
962
+ return /* @__PURE__ */ jsx(Stack, { gap: "sm", children: items.map((item, i) => /* @__PURE__ */ jsx(Paper, { p: "sm", style: { border: "1px solid var(--color-border)" }, children: /* @__PURE__ */ jsx(ContextNode, { data: item, depth: depth + 1 }) }, i)) });
963
+ }
964
+ function ObjectView({ data, depth }) {
965
+ const entries = Object.entries(data);
966
+ if (entries.length === 0) {
967
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "Empty" });
968
+ }
969
+ const simpleEntries = [];
970
+ const complexEntries = [];
971
+ for (const [key, value] of entries) {
972
+ if (value === null || value === void 0 || typeof value === "boolean" || typeof value === "number") {
973
+ simpleEntries.push([key, value]);
974
+ } else if (typeof value === "string") {
975
+ if (hasMarkdown(value) || value.length > 120) {
976
+ complexEntries.push([key, value]);
977
+ } else {
978
+ simpleEntries.push([key, value]);
979
+ }
980
+ } else {
981
+ complexEntries.push([key, value]);
982
+ }
983
+ }
984
+ return /* @__PURE__ */ jsxs(Stack, { gap: 10, children: [
985
+ simpleEntries.length > 0 && /* @__PURE__ */ jsx(Stack, { gap: 6, children: simpleEntries.map(([key, value]) => /* @__PURE__ */ jsxs(Group, { gap: "sm", align: "flex-start", wrap: "nowrap", children: [
986
+ /* @__PURE__ */ jsx(
987
+ Text,
988
+ {
989
+ size: "sm",
990
+ style: { minWidth: 140, flexShrink: 0, fontFamily: "var(--mantine-font-family-headings)" },
991
+ children: formatLabel(key)
992
+ }
993
+ ),
994
+ /* @__PURE__ */ jsx(PrimitiveValue, { value })
995
+ ] }, key)) }),
996
+ complexEntries.map(([key, value]) => /* @__PURE__ */ jsx(NestedSection, { title: formatLabel(key), children: /* @__PURE__ */ jsx(ContextNode, { data: value, depth: depth + 1 }) }, key))
997
+ ] });
998
+ }
999
+ var TIME_RANGE_OPTIONS = [
1000
+ { value: "1h", label: "Last 1 hour" },
1001
+ { value: "24h", label: "Last 24 hours" },
1002
+ { value: "7d", label: "Last 7 days" },
1003
+ { value: "30d", label: "Last 30 days" }
1004
+ ];
1005
+ function TimeRangeSelector({ value, onChange, width = 180 }) {
1006
+ return /* @__PURE__ */ jsx(
1007
+ CustomSelector,
1008
+ {
1009
+ value,
1010
+ onChange: (newValue) => newValue && onChange(newValue),
1011
+ data: TIME_RANGE_OPTIONS,
1012
+ leftSection: /* @__PURE__ */ jsx(IconClock, { size: 16, color: "var(--color-text-subtle)" }),
1013
+ w: width,
1014
+ withCheckIcon: true
1015
+ }
1016
+ );
1017
+ }
1018
+ function PageNotFound() {
1019
+ const { currentPath, navigate } = useRouterContext();
1020
+ const { user, isLoading } = useAuthContext();
1021
+ const isAuthPage = currentPath === "/login" || currentPath === "/auth-redirect";
1022
+ const shouldShowSidebar = user && !isLoading && !isAuthPage;
1023
+ const height = shouldShowSidebar ? "100%" : "100vh";
1024
+ return /* @__PURE__ */ jsx(Center, { h: height, bg: "var(--color-background)", children: /* @__PURE__ */ jsxs(Stack, { align: "center", justify: "center", children: [
1025
+ /* @__PURE__ */ jsx(IconInfoCircle, { size: 60, color: "var(--color-text-subtle)" }),
1026
+ /* @__PURE__ */ jsx(Title, { order: 1, children: "Page Not Found" }),
1027
+ /* @__PURE__ */ jsx(Text, { c: "dimmed", size: "lg", children: "The page you are looking for does not exist." }),
1028
+ /* @__PURE__ */ jsx(Group, { justify: "center", children: /* @__PURE__ */ jsx(Button, { size: "md", onClick: () => navigate("/"), children: "Go Home" }) })
1029
+ ] }) });
1030
+ }
1031
+ function ResourceCard({
1032
+ resource,
1033
+ onClick,
1034
+ layout = "stack",
1035
+ rightSection,
1036
+ topSection,
1037
+ lastRunLabel,
1038
+ style,
1039
+ ...rest
1040
+ }) {
1041
+ const Icon = getResourceIcon(resource.type);
1042
+ if (!Icon) {
1043
+ return /* @__PURE__ */ jsx(Card, { shadow: "sm", withBorder: true, children: /* @__PURE__ */ jsxs(Text, { children: [
1044
+ "Invalid resource type: ",
1045
+ resource.type
1046
+ ] }) });
1047
+ }
1048
+ const cardStyle = {
1049
+ cursor: "pointer",
1050
+ ...layout === "grid" || layout === "card" ? { transition: "box-shadow var(--duration-fast) var(--easing)" } : {},
1051
+ ...style
1052
+ };
1053
+ const iconSize = layout === "grid" ? 28 : 20;
1054
+ const details = /* @__PURE__ */ jsxs(Group, { gap: "sm", wrap: "nowrap", children: [
1055
+ /* @__PURE__ */ jsx(Icon, { size: iconSize, color: "var(--color-primary)" }),
1056
+ /* @__PURE__ */ jsxs(Stack, { gap: 4, style: { flex: 1, minWidth: 0 }, children: [
1057
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "center", children: [
1058
+ /* @__PURE__ */ jsx(
1059
+ Text,
1060
+ {
1061
+ fw: 600,
1062
+ size: "sm",
1063
+ style: { fontFamily: "var(--elevasis-font-family-subtitle)" },
1064
+ ...layout === "stack" ? { lineClamp: 1 } : { truncate: true },
1065
+ children: resource.name
1066
+ }
1067
+ ),
1068
+ /* @__PURE__ */ jsx(Badge, { variant: "light", size: layout === "grid" ? "xs" : "sm", children: resource.type })
1069
+ ] }),
1070
+ resource.description && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", ...layout === "stack" ? { lineClamp: 1 } : { truncate: true }, children: resource.description }),
1071
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
1072
+ resource.version && /* @__PURE__ */ jsxs(Badge, { variant: "outline", size: "xs", children: [
1073
+ "v",
1074
+ resource.version
1075
+ ] }),
1076
+ /* @__PURE__ */ jsx(Badge, { color: ResourceStatusColors[resource.status], variant: "outline", size: layout === "grid" ? "xs" : "sm", children: resource.status.toUpperCase() })
1077
+ ] }),
1078
+ lastRunLabel && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: lastRunLabel }),
1079
+ /* @__PURE__ */ jsx(Text, { size: layout === "grid" ? "sm" : "xs", c: "dimmed", ff: "monospace", children: resource.resourceId })
1080
+ ] })
1081
+ ] });
1082
+ if (layout === "card") {
1083
+ return /* @__PURE__ */ jsx(
1084
+ Card,
1085
+ {
1086
+ withBorder: true,
1087
+ padding: 0,
1088
+ style: cardStyle,
1089
+ onClick: () => onClick(resource),
1090
+ "data-resource-id": rest["data-resource-id"],
1091
+ children: /* @__PURE__ */ jsxs(Stack, { gap: 8, p: "sm", pb: "xs", children: [
1092
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", justify: "space-between", children: [
1093
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", style: { minWidth: 0 }, children: [
1094
+ /* @__PURE__ */ jsx(Icon, { size: 20, color: "var(--color-primary)", style: { flexShrink: 0 } }),
1095
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "md", style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, truncate: true, children: resource.name })
1096
+ ] }),
1097
+ /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", style: { flexShrink: 0 }, children: [
1098
+ resource.version && /* @__PURE__ */ jsxs(Badge, { variant: "light", size: "sm", children: [
1099
+ "v",
1100
+ resource.version
1101
+ ] }),
1102
+ /* @__PURE__ */ jsx(Badge, { color: ResourceStatusColors[resource.status], variant: "light", size: "sm", children: resource.status.toUpperCase() })
1103
+ ] })
1104
+ ] }),
1105
+ resource.description && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", truncate: true, children: resource.description }),
1106
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", wrap: "nowrap", children: [
1107
+ rightSection || /* @__PURE__ */ jsx("span", {}),
1108
+ lastRunLabel && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap" }, children: lastRunLabel })
1109
+ ] }),
1110
+ topSection
1111
+ ] })
1112
+ }
1113
+ );
1114
+ }
1115
+ if (layout === "row") {
1116
+ const [hovered, setHovered] = useState(false);
1117
+ return /* @__PURE__ */ jsx(
1118
+ Card,
1119
+ {
1120
+ padding: 0,
1121
+ style: {
1122
+ cursor: "pointer",
1123
+ border: "1px solid var(--color-border)",
1124
+ transition: "background 150ms ease",
1125
+ background: hovered ? "var(--active-background)" : "var(--glass-background)",
1126
+ ...style
1127
+ },
1128
+ onClick: () => onClick(resource),
1129
+ onMouseEnter: () => setHovered(true),
1130
+ onMouseLeave: () => setHovered(false),
1131
+ "data-resource-id": rest["data-resource-id"],
1132
+ children: /* @__PURE__ */ jsxs(
1133
+ "div",
1134
+ {
1135
+ style: {
1136
+ display: "grid",
1137
+ gridTemplateColumns: "18px 200px 120px 1fr 180px 140px 14px",
1138
+ alignItems: "center",
1139
+ gap: "var(--mantine-spacing-sm)"
1140
+ },
1141
+ children: [
1142
+ /* @__PURE__ */ jsx(Icon, { size: 18, color: "var(--color-primary)" }),
1143
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "md", truncate: true, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: resource.name }),
1144
+ /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", children: [
1145
+ resource.version && /* @__PURE__ */ jsxs(Badge, { variant: "light", size: "sm", children: [
1146
+ "v",
1147
+ resource.version
1148
+ ] }),
1149
+ /* @__PURE__ */ jsx(Badge, { color: ResourceStatusColors[resource.status], variant: "light", size: "sm", children: resource.status.toUpperCase() })
1150
+ ] }),
1151
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", truncate: true, style: { minWidth: 0 }, children: resource.description || "" }),
1152
+ /* @__PURE__ */ jsx("div", { style: { whiteSpace: "nowrap" }, children: rightSection }),
1153
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap", textAlign: "right" }, children: lastRunLabel || "" }),
1154
+ /* @__PURE__ */ jsx(
1155
+ IconChevronRight,
1156
+ {
1157
+ size: 14,
1158
+ style: {
1159
+ opacity: hovered ? 0.7 : 0,
1160
+ transition: "opacity 150ms ease"
1161
+ }
1162
+ }
1163
+ )
1164
+ ]
1165
+ }
1166
+ )
1167
+ }
1168
+ );
1169
+ }
1170
+ if (layout === "grid") {
1171
+ return /* @__PURE__ */ jsx(
1172
+ Card,
1173
+ {
1174
+ withBorder: true,
1175
+ padding: "sm",
1176
+ style: cardStyle,
1177
+ onClick: () => onClick(resource),
1178
+ "data-resource-id": rest["data-resource-id"],
1179
+ children: /* @__PURE__ */ jsxs(Grid, { gutter: "sm", align: "center", children: [
1180
+ /* @__PURE__ */ jsx(Grid.Col, { span: 8, children: details }),
1181
+ rightSection && /* @__PURE__ */ jsx(Grid.Col, { span: 4, children: /* @__PURE__ */ jsx(Group, { justify: "flex-end", gap: "md", wrap: "nowrap", children: rightSection }) })
1182
+ ] })
1183
+ }
1184
+ );
1185
+ }
1186
+ return /* @__PURE__ */ jsx(
1187
+ Card,
1188
+ {
1189
+ shadow: "sm",
1190
+ withBorder: true,
1191
+ style: cardStyle,
1192
+ onClick: () => onClick(resource),
1193
+ "data-resource-id": rest["data-resource-id"],
1194
+ children: /* @__PURE__ */ jsx(Stack, { children: details })
1195
+ }
1196
+ );
1197
+ }
1198
+
1199
+ // src/components/display/ResourceCardAdapters.ts
1200
+ function catalogItemToResourceDefinition(item) {
1201
+ return {
1202
+ resourceId: item.resourceId,
1203
+ name: item.resourceName,
1204
+ description: item.description || "",
1205
+ version: item.version,
1206
+ type: item.resourceType,
1207
+ status: item.status
1208
+ };
1209
+ }
1210
+ function CardHeader({ icon, title, subtitle, rightSection }) {
1211
+ return /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "md", children: [
1212
+ subtitle ? /* @__PURE__ */ jsxs("div", { children: [
1213
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
1214
+ icon,
1215
+ /* @__PURE__ */ jsx(Title, { order: 3, children: title })
1216
+ ] }),
1217
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", mt: 2, children: subtitle })
1218
+ ] }) : /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
1219
+ icon,
1220
+ /* @__PURE__ */ jsx(Title, { order: 3, children: title })
1221
+ ] }),
1222
+ rightSection
1223
+ ] });
1224
+ }
1225
+ var GRANULARITY_MAP = {
1226
+ "1h": "hour",
1227
+ "24h": "hour",
1228
+ "7d": "day",
1229
+ "30d": "day"
1230
+ };
1231
+ var BUCKET_CONFIG = {
1232
+ "1h": { size: 5 * 60 * 1e3, count: 12 },
1233
+ "24h": { size: 60 * 60 * 1e3, count: 24 },
1234
+ "7d": { size: 24 * 60 * 60 * 1e3, count: 7 },
1235
+ "30d": { size: 24 * 60 * 60 * 1e3, count: 30 }
1236
+ };
1237
+ function groupTimestampsByTime(timestamps, timeRange) {
1238
+ const { size: bucketSize, count: bucketCount } = BUCKET_CONFIG[timeRange];
1239
+ const granularity = GRANULARITY_MAP[timeRange];
1240
+ const now = /* @__PURE__ */ new Date();
1241
+ const buckets = /* @__PURE__ */ new Map();
1242
+ for (let i = bucketCount - 1; i >= 0; i--) {
1243
+ const bucketTime = new Date(now.getTime() - i * bucketSize);
1244
+ const label = formatBucketTime(bucketTime.toISOString(), granularity);
1245
+ buckets.set(label, 0);
1246
+ }
1247
+ timestamps.forEach((occurredAt) => {
1248
+ const timeDiff = now.getTime() - occurredAt.getTime();
1249
+ const bucketIndex = Math.floor(timeDiff / bucketSize);
1250
+ if (bucketIndex >= 0 && bucketIndex < bucketCount) {
1251
+ const bucketTime = new Date(now.getTime() - bucketIndex * bucketSize);
1252
+ const label = formatBucketTime(bucketTime.toISOString(), granularity);
1253
+ buckets.set(label, (buckets.get(label) || 0) + 1);
1254
+ }
1255
+ });
1256
+ return Array.from(buckets.entries()).map(([time, count]) => ({
1257
+ time,
1258
+ "Activity Count": count
1259
+ }));
1260
+ }
1261
+ function ActivityTrendChart({ timestamps, total, isLoading, timeRange }) {
1262
+ const chartData = useMemo(() => {
1263
+ return groupTimestampsByTime(timestamps, timeRange);
1264
+ }, [timestamps, timeRange]);
1265
+ if (isLoading) {
1266
+ return /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) });
1267
+ }
1268
+ return /* @__PURE__ */ jsxs(Card, { withBorder: true, children: [
1269
+ /* @__PURE__ */ jsx(CardHeader, { title: "Activity Trend", subtitle: `${total} activities in ${getTimeRangeLabel(timeRange)}` }),
1270
+ /* @__PURE__ */ jsx(
1271
+ CyberAreaChart,
1272
+ {
1273
+ data: chartData,
1274
+ series: [{ dataKey: "Activity Count", color: "blue" }],
1275
+ height: 200,
1276
+ yAxisLabel: "Count",
1277
+ yDomain: [0, "auto"]
1278
+ }
1279
+ )
1280
+ ] });
1281
+ }
1282
+ function formatDollar(value) {
1283
+ return `$${value.toFixed(2)}`;
1284
+ }
1285
+ function CostTrendChart({ data, summaryData, isLoading, error }) {
1286
+ const todayCost = summaryData?.current.totalCostUsd ?? 0;
1287
+ const previousCost = summaryData?.previous.totalCostUsd ?? 0;
1288
+ const mtdCost = summaryData?.mtd.totalCostUsd ?? 0;
1289
+ const projectedMonthlyCost = summaryData?.projection.monthlyCostUsd ?? 0;
1290
+ const confidence = summaryData?.projection.confidence ?? "low";
1291
+ const budget = 1500;
1292
+ const budgetStatus = projectedMonthlyCost <= budget ? "green" : projectedMonthlyCost <= budget * 1.1 ? "yellow" : "red";
1293
+ const budgetLabel = projectedMonthlyCost <= budget ? "On Budget" : projectedMonthlyCost <= budget * 1.1 ? "Warning" : "Over Budget";
1294
+ const chartData = data?.trendData.map((point) => {
1295
+ const date = new Date(point.time);
1296
+ const timeLabel = data.granularity === "hour" ? date.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" }) : date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
1297
+ return {
1298
+ time: timeLabel,
1299
+ "Total Cost": point.totalCostUsd
1300
+ };
1301
+ }) ?? [];
1302
+ const handleExport = () => {
1303
+ if (!data) return;
1304
+ const csvContent = [
1305
+ ["Time", "Total Cost ($)", "Executions", "Avg Cost/Execution ($)"],
1306
+ ...data.trendData.map((d) => [
1307
+ d.time,
1308
+ d.totalCostUsd.toFixed(4),
1309
+ d.executionCount,
1310
+ d.avgCostPerExecution.toFixed(4)
1311
+ ])
1312
+ ].map((row) => row.join(",")).join("\n");
1313
+ const blob = new Blob([csvContent], { type: "text/csv" });
1314
+ const url = URL.createObjectURL(blob);
1315
+ const link = document.createElement("a");
1316
+ link.href = url;
1317
+ link.download = `cost-trends-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
1318
+ link.click();
1319
+ URL.revokeObjectURL(url);
1320
+ };
1321
+ if (error) {
1322
+ return /* @__PURE__ */ jsx(APIErrorAlert, { error, title: "Failed to load cost trends" });
1323
+ }
1324
+ if (isLoading) {
1325
+ return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) });
1326
+ }
1327
+ const granularityLabel = data?.granularity === "hour" ? "Hourly" : "Daily";
1328
+ return /* @__PURE__ */ jsxs(Card, { withBorder: true, children: [
1329
+ /* @__PURE__ */ jsx(
1330
+ CardHeader,
1331
+ {
1332
+ title: `Cost Trend (${granularityLabel})`,
1333
+ rightSection: /* @__PURE__ */ jsx(Button, { variant: "subtle", size: "xs", leftSection: /* @__PURE__ */ jsx(IconDownload, { size: 14 }), onClick: handleExport, children: "Export CSV" })
1334
+ }
1335
+ ),
1336
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", mb: "md", children: [
1337
+ /* @__PURE__ */ jsxs(Group, { gap: "lg", children: [
1338
+ /* @__PURE__ */ jsxs(Group, { gap: 6, align: "baseline", children: [
1339
+ /* @__PURE__ */ jsx(Text, { size: "xl", fw: 700, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: todayCost, decimalScale: 2 }) }),
1340
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "period" }),
1341
+ /* @__PURE__ */ jsx(TrendIndicator, { current: todayCost, previous: previousCost, inverse: true })
1342
+ ] }),
1343
+ /* @__PURE__ */ jsxs(Group, { gap: 6, align: "baseline", children: [
1344
+ /* @__PURE__ */ jsx(Text, { size: "xl", fw: 700, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: mtdCost, thousandSeparator: true, decimalScale: 2 }) }),
1345
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "MTD" })
1346
+ ] })
1347
+ ] }),
1348
+ /* @__PURE__ */ jsx(Badge, { size: "md", variant: "dot", color: budgetStatus, children: budgetLabel })
1349
+ ] }),
1350
+ chartData.length > 0 ? /* @__PURE__ */ jsx(
1351
+ CyberAreaChart,
1352
+ {
1353
+ data: chartData,
1354
+ series: [{ dataKey: "Total Cost", color: "blue", name: "Total Cost" }],
1355
+ height: 200,
1356
+ yDomain: [0, (max) => Math.max(max * 1.1, 0.01)],
1357
+ yTickFormatter: formatDollar,
1358
+ tooltipFormatter: formatDollar,
1359
+ baselineColor: "blue"
1360
+ }
1361
+ ) : /* @__PURE__ */ jsx(EmptyState, { icon: IconChartLine, title: "No cost data available for this time period" }),
1362
+ /* @__PURE__ */ jsx(Space, { h: "lg" }),
1363
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
1364
+ /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
1365
+ /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
1366
+ "Projected monthly:",
1367
+ " ",
1368
+ /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: projectedMonthlyCost, thousandSeparator: true, decimalScale: 2 })
1369
+ ] }),
1370
+ /* @__PURE__ */ jsx(Tooltip$1, { label: `Projection confidence: ${confidence}`, children: /* @__PURE__ */ jsx(IconInfoCircle, { size: 12, color: "var(--color-text-subtle)" }) })
1371
+ ] }),
1372
+ /* @__PURE__ */ jsxs(
1373
+ Text,
1374
+ {
1375
+ size: "xs",
1376
+ fw: 600,
1377
+ c: projectedMonthlyCost > budget ? "red" : "dimmed",
1378
+ style: { fontFamily: "var(--mantine-font-family-headings)" },
1379
+ children: [
1380
+ "Budget: ",
1381
+ /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: budget, thousandSeparator: true, decimalScale: 2 })
1382
+ ]
1383
+ }
1384
+ )
1385
+ ] })
1386
+ ] });
1387
+ }
1388
+ var EM_DASH = "\u2014";
1389
+ function getSuccessRateColor(rate) {
1390
+ if (rate >= 95) return "var(--mantine-color-teal-6)";
1391
+ if (rate >= 80) return "var(--mantine-color-yellow-6)";
1392
+ return "var(--mantine-color-red-6)";
1393
+ }
1394
+ function getErrorCountColor(count) {
1395
+ if (count === 0) return "var(--mantine-color-teal-6)";
1396
+ if (count <= 5) return "var(--mantine-color-yellow-6)";
1397
+ return "var(--mantine-color-red-6)";
1398
+ }
1399
+ function HeroStatsRow({
1400
+ resourcesData,
1401
+ resourcesLoading,
1402
+ dashboardData,
1403
+ dashboardLoading,
1404
+ unresolvedErrorCount,
1405
+ errorsLoading
1406
+ }) {
1407
+ const health = dashboardData?.executionHealth;
1408
+ const resourceCount = resourcesData?.total ?? null;
1409
+ const totalExecutions = health?.totalExecutions ?? null;
1410
+ const successRate = totalExecutions ? health?.successRate ?? null : null;
1411
+ return /* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 2, sm: 5 }, children: [
1412
+ /* @__PURE__ */ jsx(
1413
+ StatCard,
1414
+ {
1415
+ variant: "hero",
1416
+ icon: IconApps,
1417
+ value: resourceCount ?? EM_DASH,
1418
+ label: "Resources",
1419
+ isLoading: resourcesLoading
1420
+ }
1421
+ ),
1422
+ /* @__PURE__ */ jsx(
1423
+ StatCard,
1424
+ {
1425
+ variant: "hero",
1426
+ icon: IconPlayerPlay,
1427
+ value: totalExecutions ?? EM_DASH,
1428
+ label: "Executions",
1429
+ isLoading: dashboardLoading
1430
+ }
1431
+ ),
1432
+ /* @__PURE__ */ jsx(
1433
+ StatCard,
1434
+ {
1435
+ variant: "hero",
1436
+ icon: IconChartBar,
1437
+ value: successRate != null ? `${Math.round(successRate)}%` : EM_DASH,
1438
+ label: "Success Rate",
1439
+ valueColor: successRate != null ? getSuccessRateColor(successRate) : void 0,
1440
+ isLoading: dashboardLoading
1441
+ }
1442
+ ),
1443
+ /* @__PURE__ */ jsx(
1444
+ StatCard,
1445
+ {
1446
+ variant: "hero",
1447
+ icon: IconAlertTriangle,
1448
+ value: unresolvedErrorCount ?? EM_DASH,
1449
+ label: "Errors",
1450
+ valueColor: unresolvedErrorCount != null ? getErrorCountColor(unresolvedErrorCount) : void 0,
1451
+ isLoading: errorsLoading
1452
+ }
1453
+ ),
1454
+ /* @__PURE__ */ jsx(
1455
+ StatCard,
1456
+ {
1457
+ variant: "hero",
1458
+ icon: IconRocket,
1459
+ value: dashboardData?.activeDeploymentVersion ?? EM_DASH,
1460
+ label: "Deployment Version",
1461
+ isLoading: dashboardLoading
1462
+ }
1463
+ )
1464
+ ] });
1465
+ }
1466
+ function getGranularityFromTimeRange(timeRange) {
1467
+ return ["1h", "24h"].includes(timeRange) ? "hour" : "day";
1468
+ }
1469
+ function formatPeakPeriod(peakPeriod, granularity) {
1470
+ if (!peakPeriod) return "N/A";
1471
+ const date = new Date(peakPeriod);
1472
+ if (granularity === "hour") {
1473
+ return date.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", hour12: true });
1474
+ } else {
1475
+ return date.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" });
1476
+ }
1477
+ }
1478
+ function CombinedTrendChart({
1479
+ healthData,
1480
+ errorData: _errorData,
1481
+ isLoading,
1482
+ error,
1483
+ timeRange,
1484
+ navigationAction
1485
+ }) {
1486
+ const [activeTab, setActiveTab] = useState("success");
1487
+ const colors = useCyberColors();
1488
+ const { startDate: start, endDate: end } = useMemo(() => getTimeRangeDates(timeRange), [timeRange]);
1489
+ const granularity = getGranularityFromTimeRange(timeRange);
1490
+ const { data: errorTrends } = useErrorTrends({
1491
+ startDate: start,
1492
+ endDate: end,
1493
+ granularity
1494
+ });
1495
+ const xTickFormatter = useCallback((value) => formatBucketTime(value, granularity), [granularity]);
1496
+ if (error) {
1497
+ return /* @__PURE__ */ jsx(APIErrorAlert, { error, title: "Failed to load trend data" });
1498
+ }
1499
+ if (isLoading) {
1500
+ return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) });
1501
+ }
1502
+ const errorTrendsMap = new Map(errorTrends?.map((trend) => [trend.time, trend.errorCount]) || []);
1503
+ const successErrorData = healthData?.trendData.length ? healthData.trendData.map((d) => {
1504
+ const errorCount = errorTrendsMap.get(d.time) || 0;
1505
+ return {
1506
+ time: d.time,
1507
+ "Success Count": d.successCount,
1508
+ "Error Count": errorCount
1509
+ };
1510
+ }) : [];
1511
+ const throughputData = healthData?.trendData.length ? healthData.trendData.map((d) => ({
1512
+ time: d.time,
1513
+ Executions: d.executionCount
1514
+ })) : [];
1515
+ const totalExecutions = healthData?.totalExecutions ?? 0;
1516
+ const peakPeriod = healthData?.peakPeriod ?? "";
1517
+ const dataGranularity = healthData?.granularity ?? granularity;
1518
+ if (!successErrorData.length) {
1519
+ return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { h: 300, children: /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, {}), color: "gray", variant: "light", children: "No trend data available for the selected time range" }) }) });
1520
+ }
1521
+ return /* @__PURE__ */ jsxs(Card, { withBorder: true, children: [
1522
+ /* @__PURE__ */ jsx(
1523
+ CardHeader,
1524
+ {
1525
+ title: "Execution Trends",
1526
+ subtitle: `${getTimeRangeLabel(timeRange)} - ${dataGranularity === "hour" ? "Hourly" : "Daily"} data`,
1527
+ rightSection: /* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
1528
+ /* @__PURE__ */ jsx(
1529
+ SegmentedControl,
1530
+ {
1531
+ value: activeTab ?? "success",
1532
+ onChange: setActiveTab,
1533
+ size: "xs",
1534
+ data: [
1535
+ { label: "Success & Errors", value: "success" },
1536
+ { label: "Throughput", value: "throughput" }
1537
+ ]
1538
+ }
1539
+ ),
1540
+ navigationAction
1541
+ ] })
1542
+ }
1543
+ ),
1544
+ activeTab === "success" && /* @__PURE__ */ jsxs(Box, { style: { height: 280 }, children: [
1545
+ /* @__PURE__ */ jsxs(Group, { gap: "lg", justify: "center", mb: "xs", h: 24, align: "center", children: [
1546
+ /* @__PURE__ */ jsx(CyberLegendItem, { color: colors.green, label: "Success Count" }),
1547
+ /* @__PURE__ */ jsx(CyberLegendItem, { color: colors.red, label: "Error Count" })
1548
+ ] }),
1549
+ /* @__PURE__ */ jsx(
1550
+ CyberAreaChart,
1551
+ {
1552
+ data: successErrorData,
1553
+ series: [
1554
+ { dataKey: "Error Count", color: "red" },
1555
+ { dataKey: "Success Count", color: "green", animationDuration: 1400 }
1556
+ ],
1557
+ height: 250,
1558
+ yAxisLabel: "Count",
1559
+ baselineColor: "green",
1560
+ xTickFormatter
1561
+ }
1562
+ )
1563
+ ] }),
1564
+ activeTab === "throughput" && /* @__PURE__ */ jsxs(Box, { style: { height: 280 }, children: [
1565
+ /* @__PURE__ */ jsxs(Group, { gap: "lg", justify: "center", mb: "xs", h: 24, align: "center", children: [
1566
+ /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
1567
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { color: colors.blue, fontVariantNumeric: "tabular-nums" }, children: totalExecutions.toLocaleString() }),
1568
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "executions" })
1569
+ ] }),
1570
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "|" }),
1571
+ /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
1572
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "peak" }),
1573
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { color: colors.blue, fontVariantNumeric: "tabular-nums" }, children: formatPeakPeriod(peakPeriod, dataGranularity) })
1574
+ ] }),
1575
+ /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "dot", color: "green", children: "Normal" })
1576
+ ] }),
1577
+ /* @__PURE__ */ jsx(
1578
+ CyberAreaChart,
1579
+ {
1580
+ data: throughputData,
1581
+ series: [{ dataKey: "Executions", color: "blue" }],
1582
+ height: 250,
1583
+ xTickFormatter
1584
+ }
1585
+ )
1586
+ ] })
1587
+ ] });
1588
+ }
1589
+
1590
+ export { APIErrorAlert, ActivityTrendChart, CardHeader, CollapsibleSection, CombinedTrendChart, ContextViewer, CostTrendChart, CustomSelector, CyberAreaChart, CyberDonut, CyberDonutTooltip, CyberLegendItem, DetailCardSkeleton, EmptyState, HeroStatsRow, JsonViewer, ListSkeleton, PageNotFound, PageTitleCaption, ResourceCard, StatCard, StatCardSkeleton, StatsCardSkeleton, StyledMarkdown, TabCountBadge, TimeRangeSelector, TrendIndicator, catalogItemToResourceDefinition, getSeriesColor, useCyberColors };