tekivex-ui 2.5.10 → 2.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/TkxForm-1KDzoniV.cjs +12 -0
  2. package/dist/TkxForm-9-W3Nl6m.js +314 -0
  3. package/dist/charts.cjs +1 -1
  4. package/dist/charts.js +543 -507
  5. package/dist/chunk-Bmb41Sf3.cjs +1 -0
  6. package/dist/headless.cjs +1 -1
  7. package/dist/headless.js +428 -447
  8. package/dist/hooks-6pRsPOyG.js +58 -0
  9. package/dist/hooks-mivgRljH.cjs +1 -0
  10. package/dist/i18n.cjs +1 -1
  11. package/dist/i18n.js +728 -752
  12. package/dist/index.cjs +46 -23
  13. package/dist/index.d.ts +6 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +16103 -16237
  16. package/dist/quantum.cjs +14 -16
  17. package/dist/quantum.js +2473 -2279
  18. package/dist/realtime.cjs +4 -10
  19. package/dist/realtime.js +804 -958
  20. package/dist/src/components/TkxAIChatBubble.d.ts +24 -0
  21. package/dist/src/components/TkxAIChatBubble.d.ts.map +1 -0
  22. package/dist/src/components/TkxAIConfidenceBar.d.ts +17 -0
  23. package/dist/src/components/TkxAIConfidenceBar.d.ts.map +1 -0
  24. package/dist/src/components/TkxAIThinking.d.ts +17 -0
  25. package/dist/src/components/TkxAIThinking.d.ts.map +1 -0
  26. package/dist/src/components/TkxClock.d.ts.map +1 -1
  27. package/dist/src/components/TkxForm.d.ts.map +1 -1
  28. package/dist/src/components/TkxLiveFeed.d.ts +1 -1
  29. package/dist/src/components/TkxLiveLog.d.ts +1 -1
  30. package/dist/src/components/TkxRealTimeChart.d.ts +1 -1
  31. package/dist/src/components/TkxTooltip.d.ts.map +1 -1
  32. package/dist/src/components/TkxTypography.d.ts +5 -5
  33. package/dist/src/components/TkxTypography.d.ts.map +1 -1
  34. package/dist/src/components/index.d.ts +3 -0
  35. package/dist/src/components/index.d.ts.map +1 -1
  36. package/dist/tekivex-ui.css +2 -0
  37. package/dist/themes-BbJanqiC.js +498 -0
  38. package/dist/themes-CMq2vWXj.cjs +2 -0
  39. package/dist/tkx-0oAwZqgL.cjs +4 -0
  40. package/dist/tkx-DQkvHdE5.js +1172 -0
  41. package/package.json +16 -16
  42. package/src/components/TkxAIChatBubble.tsx +209 -0
  43. package/src/components/TkxAIConfidenceBar.tsx +131 -0
  44. package/src/components/TkxAIThinking.tsx +191 -0
  45. package/src/components/TkxClock.tsx +2 -2
  46. package/src/components/TkxForm.tsx +4 -2
  47. package/src/components/TkxTooltip.tsx +7 -5
  48. package/src/components/TkxTypography.tsx +2 -2
  49. package/src/components/index.ts +5 -0
  50. package/dist/TkxForm-2tGLCPH6.js +0 -326
  51. package/dist/TkxForm-C2VqR2wC.cjs +0 -12
  52. package/dist/index-BgHMZe4Z.js +0 -66
  53. package/dist/index-Bt5y50Qa.cjs +0 -1
  54. package/dist/index-DnqXtpwV.cjs +0 -2
  55. package/dist/index-iUUHRxqJ.js +0 -515
  56. package/dist/security-C-ZPGoyG.js +0 -97
  57. package/dist/security-Uf0mjv8o.cjs +0 -1
  58. package/dist/style.css +0 -1
  59. package/dist/tkx-BtHzWKTl.js +0 -1112
  60. package/dist/tkx-C7GvVUE9.cjs +0 -4
package/dist/realtime.js CHANGED
@@ -1,958 +1,804 @@
1
- import { useRef as D, useState as W, useMemo as Q, useEffect as B, useCallback as K, createElement as n } from "react";
2
- import { u as ee } from "./index-iUUHRxqJ.js";
3
- import { s as L } from "./security-C-ZPGoyG.js";
4
- const _ = 64, ue = 5;
5
- let fe = !1;
6
- function Ie() {
7
- if (fe || typeof document > "u") return;
8
- fe = !0;
9
- const e = document.createElement("style");
10
- e.id = "tkx-live-feed-styles", e.textContent = `
11
- @keyframes tkx-feed-slide-in {
12
- from { transform: translateY(-20px); opacity: 0; }
13
- to { transform: translateY(0); opacity: 1; }
14
- }
15
- .tkx-feed-item-new {
16
- animation: tkx-feed-slide-in 0.25s ease-out both;
17
- }
18
- `.trim(), document.head.appendChild(e);
19
- }
20
- function Le(e) {
21
- const t = Date.now() - e;
22
- return t < 1e4 ? "just now" : t < 6e4 ? `${Math.floor(t / 1e3)}s ago` : t < 36e5 ? `${Math.floor(t / 6e4)}m ago` : t < 864e5 ? `${Math.floor(t / 36e5)}h ago` : `${Math.floor(t / 864e5)}d ago`;
23
- }
24
- function Re(e, t) {
25
- switch (e) {
26
- case "info":
27
- return t.info;
28
- case "success":
29
- return t.success;
30
- case "warning":
31
- return t.warning;
32
- case "error":
33
- return t.danger;
34
- default:
35
- return t.border;
36
- }
37
- }
38
- function ze(e) {
39
- return e ? e.split(" ").map((t) => t[0] ?? "").slice(0, 2).join("").toUpperCase() : "?";
40
- }
41
- function Ee({ item: e, isNew: t, showTimestamps: o, onItemClick: r, renderItem: a, theme: s, style: f }) {
42
- const u = Re(e.type, s);
43
- if (a)
44
- return n("div", { style: f, className: t ? "tkx-feed-item-new" : void 0 }, a(e));
45
- const h = {
46
- ...f,
47
- display: "flex",
48
- alignItems: "center",
49
- gap: 10,
50
- padding: "0 12px",
51
- borderLeft: `3px solid ${u}`,
52
- cursor: r ? "pointer" : "default",
53
- boxSizing: "border-box",
54
- height: _,
55
- background: s.surface,
56
- transition: "background 0.15s"
57
- };
58
- return n(
59
- "div",
60
- {
61
- style: h,
62
- className: t ? "tkx-feed-item-new" : void 0,
63
- onClick: r ? () => r(e) : void 0,
64
- role: r ? "button" : void 0,
65
- tabIndex: r ? 0 : void 0,
66
- onKeyDown: r ? (l) => {
67
- (l.key === "Enter" || l.key === " ") && r(e);
68
- } : void 0
69
- },
70
- // Avatar
71
- n(
72
- "div",
73
- {
74
- style: {
75
- width: 36,
76
- height: 36,
77
- borderRadius: "50%",
78
- background: u,
79
- display: "flex",
80
- alignItems: "center",
81
- justifyContent: "center",
82
- fontSize: 13,
83
- fontWeight: 700,
84
- color: s.bg,
85
- flexShrink: 0,
86
- overflow: "hidden"
87
- }
88
- },
89
- e.avatar ? n("img", { src: e.avatar, alt: e.author ?? "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : ze(e.author)
90
- ),
91
- // Body
92
- n(
93
- "div",
94
- { style: { flex: 1, minWidth: 0 } },
95
- n(
96
- "div",
97
- { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 } },
98
- e.author && n("span", { style: { fontWeight: 600, fontSize: 13, color: s.text } }, L(e.author)),
99
- e.meta && n("span", { style: { fontSize: 11, color: s.textMuted, background: s.surfaceAlt, borderRadius: 4, padding: "1px 5px" } }, L(e.meta))
100
- ),
101
- n(
102
- "div",
103
- { style: { fontSize: 13, color: s.text, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } },
104
- L(e.content)
105
- )
106
- ),
107
- // Timestamp
108
- o && n(
109
- "div",
110
- { style: { fontSize: 11, color: s.textMuted, flexShrink: 0 } },
111
- Le(e.timestamp)
112
- )
113
- );
114
- }
115
- function Je({
116
- items: e,
117
- maxItems: t = 100,
118
- height: o = 400,
119
- autoScroll: r = !0,
120
- showTimestamps: a = !0,
121
- onItemClick: s,
122
- emptyMessage: f = "No activity yet.",
123
- pauseOnHover: u = !0,
124
- renderItem: h
125
- }) {
126
- const l = ee();
127
- Ie();
128
- const y = D(null), [v, k] = W(0), [b, x] = W(!1), [C, N] = W(/* @__PURE__ */ new Set()), V = D([]), R = Q(
129
- () => e.slice(-t),
130
- [e, t]
131
- ), $ = typeof o == "number" ? o : 400, w = R.length * _;
132
- B(() => {
133
- const I = new Set(V.current.map((E) => E.id)), S = R.filter((E) => !I.has(E.id)).map((E) => E.id);
134
- if (S.length > 0) {
135
- N((j) => {
136
- const F = new Set(j);
137
- return S.forEach((A) => F.add(A)), F;
138
- });
139
- const E = window.setTimeout(() => {
140
- N((j) => {
141
- const F = new Set(j);
142
- return S.forEach((A) => F.delete(A)), F;
143
- });
144
- }, 400);
145
- return () => clearTimeout(E);
146
- }
147
- }, [R]), B(() => {
148
- V.current = R;
149
- }, [R]);
150
- const P = r && !(u && b);
151
- B(() => {
152
- if (!P || !y.current) return;
153
- const I = y.current;
154
- (I.scrollHeight - I.scrollTop - I.clientHeight < _ * 3 || R.length <= 5) && (I.scrollTop = I.scrollHeight);
155
- }, [R.length, P]);
156
- const Y = K(() => {
157
- y.current && k(y.current.scrollTop);
158
- }, []), H = Math.max(0, Math.floor(v / _) - ue), g = Math.min(
159
- R.length - 1,
160
- Math.ceil((v + $) / _) + ue
161
- ), T = {
162
- position: "relative",
163
- overflow: "auto",
164
- height: typeof o == "number" ? `${o}px` : o,
165
- background: l.bg,
166
- border: `1px solid ${l.border}`,
167
- borderRadius: 8,
168
- boxSizing: "border-box"
169
- }, G = {
170
- position: "relative",
171
- height: w,
172
- minHeight: "100%"
173
- };
174
- if (R.length === 0)
175
- return n(
176
- "div",
177
- { style: { ...T, display: "flex", alignItems: "center", justifyContent: "center" } },
178
- n("span", { style: { color: l.textMuted, fontSize: 14 } }, L(f))
179
- );
180
- const z = [];
181
- for (let I = H; I <= g; I++) {
182
- const S = R[I];
183
- S && z.push(
184
- n(Ee, {
185
- key: S.id,
186
- item: S,
187
- isNew: C.has(S.id),
188
- showTimestamps: a,
189
- onItemClick: s,
190
- renderItem: h,
191
- theme: l,
192
- style: {
193
- position: "absolute",
194
- top: I * _,
195
- left: 0,
196
- right: 0
197
- }
198
- })
199
- );
200
- }
201
- return n(
202
- "div",
203
- {
204
- ref: y,
205
- style: T,
206
- onScroll: Y,
207
- onMouseEnter: u ? () => x(!0) : void 0,
208
- onMouseLeave: u ? () => x(!1) : void 0,
209
- "aria-label": "Live feed",
210
- role: "feed"
211
- },
212
- n("div", { style: G }, ...z)
213
- );
214
- }
215
- let pe = !1;
216
- function Ne() {
217
- if (pe || typeof document > "u") return;
218
- pe = !0;
219
- const e = document.createElement("style");
220
- e.id = "tkx-live-metrics-styles", e.textContent = `
221
- @keyframes tkx-metric-pulse {
222
- 0% { opacity: 1; }
223
- 40% { opacity: 0.4; }
224
- 100% { opacity: 1; }
225
- }
226
- @keyframes tkx-metric-shimmer {
227
- 0% { background-position: -200% 0; }
228
- 100% { background-position: 200% 0; }
229
- }
230
- .tkx-metric-shimmer {
231
- animation: tkx-metric-shimmer 0.6s ease-in-out;
232
- }
233
- @media (prefers-reduced-motion: reduce) {
234
- .tkx-metric-shimmer { animation: none; }
235
- .tkx-metric-pulse { animation: none; }
236
- }
237
- `.trim(), document.head.appendChild(e);
238
- }
239
- function ge(e, t) {
240
- if (typeof e == "string") return e;
241
- const o = e >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : e >= 1e3 ? `${(e / 1e3).toFixed(1)}k` : String(Number.isInteger(e) ? e : e.toFixed(2));
242
- return t ? `${o}${t}` : o;
243
- }
244
- function We(e, t) {
245
- switch (e) {
246
- case "warning":
247
- return t.warning;
248
- case "critical":
249
- return t.danger;
250
- default:
251
- return t.primary;
252
- }
253
- }
254
- function Ce() {
255
- const [e, t] = W(
256
- () => typeof window < "u" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : !1
257
- );
258
- return B(() => {
259
- if (typeof window > "u") return;
260
- const o = window.matchMedia("(prefers-reduced-motion: reduce)"), r = (a) => t(a.matches);
261
- return o.addEventListener("change", r), () => o.removeEventListener("change", r);
262
- }, []), e;
263
- }
264
- function He(e, t, o) {
265
- const [r, a] = W(e), s = D(e), f = D(null), u = D(null), h = Ce();
266
- return B(() => {
267
- if (!o || h) {
268
- a(e), s.current = e;
269
- return;
270
- }
271
- const l = s.current;
272
- if (l === e) return;
273
- f.current = null;
274
- const y = (v) => {
275
- f.current === null && (f.current = v);
276
- const k = v - f.current, b = Math.min(k / t, 1), x = 1 - Math.pow(1 - b, 3);
277
- a(l + (e - l) * x), b < 1 ? u.current = requestAnimationFrame(y) : s.current = e;
278
- };
279
- return u.current = requestAnimationFrame(y), () => {
280
- u.current !== null && cancelAnimationFrame(u.current);
281
- };
282
- }, [e, t, o, h]), r;
283
- }
284
- function Fe({ data: e, color: t }) {
285
- if (e.length < 2) return null;
286
- const o = 80, r = 24, a = Math.min(...e), f = Math.max(...e) - a || 1, u = e.map((h, l) => {
287
- const y = l / (e.length - 1) * o, v = r - (h - a) / f * (r - 2) - 1;
288
- return `${y.toFixed(1)},${v.toFixed(1)}`;
289
- });
290
- return n(
291
- "svg",
292
- { width: o, height: r, viewBox: `0 0 ${o} ${r}`, "aria-hidden": "true" },
293
- n("polyline", {
294
- points: u.join(" "),
295
- fill: "none",
296
- stroke: t,
297
- strokeWidth: 1.5,
298
- strokeLinejoin: "round",
299
- strokeLinecap: "round"
300
- })
301
- );
302
- }
303
- function Ae({ trend: e, theme: t }) {
304
- return e === "up" ? n("span", { style: { color: t.success, fontSize: 14, fontWeight: 700 } }, "▲") : e === "down" ? n("span", { style: { color: t.danger, fontSize: 14, fontWeight: 700 } }, "▼") : n("span", { style: { color: t.textMuted, fontSize: 14 } }, "→");
305
- }
306
- function De({ metric: e, animate: t, onMetricClick: o, theme: r }) {
307
- const a = e.color ?? We(e.status, r), s = typeof e.value == "number" ? e.value : NaN, f = He(isNaN(s) ? 0 : s, 600, t && !isNaN(s)), [u, h] = W(!1), l = D(e.value);
308
- B(() => {
309
- if (l.current !== e.value) {
310
- l.current = e.value, h(!0);
311
- const x = window.setTimeout(() => h(!1), 700);
312
- return () => clearTimeout(x);
313
- }
314
- }, [e.value]);
315
- const y = e.previousValue !== void 0 && e.previousValue !== s, v = {
316
- background: r.surface,
317
- border: `1px solid ${r.border}`,
318
- borderLeft: `4px solid ${a}`,
319
- borderRadius: 8,
320
- padding: "14px 16px",
321
- cursor: o ? "pointer" : "default",
322
- position: "relative",
323
- overflow: "hidden",
324
- boxSizing: "border-box"
325
- }, k = u ? {
326
- position: "absolute",
327
- inset: 0,
328
- background: `linear-gradient(90deg, transparent 0%, ${a}22 50%, transparent 100%)`,
329
- backgroundSize: "200% 100%",
330
- animation: "tkx-metric-shimmer 0.6s ease-in-out",
331
- pointerEvents: "none"
332
- } : {}, b = isNaN(s) ? L(String(e.value)) : ge(f, e.unit);
333
- return n(
334
- "div",
335
- {
336
- style: v,
337
- className: u ? "tkx-metric-shimmer" : void 0,
338
- onClick: o ? () => o(e) : void 0,
339
- role: o ? "button" : void 0,
340
- tabIndex: o ? 0 : void 0
341
- },
342
- // Shimmer overlay
343
- u && n("div", { style: k }),
344
- // Label
345
- n("div", { style: { fontSize: 12, color: r.textMuted, marginBottom: 6, fontWeight: 500, letterSpacing: "0.03em" } }, L(e.label)),
346
- // Value row
347
- n(
348
- "div",
349
- { style: { display: "flex", alignItems: "flex-end", gap: 6, marginBottom: 6 } },
350
- n("span", { style: { fontSize: 28, fontWeight: 700, color: r.text, lineHeight: 1 } }, b),
351
- e.unit && isNaN(s) && n("span", { style: { fontSize: 14, color: r.textMuted, marginBottom: 2 } }, L(e.unit))
352
- ),
353
- // Trend row
354
- (e.trend || e.trendValue) && n(
355
- "div",
356
- { style: { display: "flex", alignItems: "center", gap: 4, marginBottom: e.sparkline ? 8 : 0 } },
357
- e.trend && n(Ae, { trend: e.trend, theme: r }),
358
- e.trendValue && n("span", { style: { fontSize: 12, color: r.textMuted } }, L(e.trendValue))
359
- ),
360
- // Previous value
361
- y && n(
362
- "div",
363
- { style: { fontSize: 11, color: r.textMuted, marginTop: 2 } },
364
- `was ${ge(e.previousValue)}`
365
- ),
366
- // Sparkline
367
- e.sparkline && e.sparkline.length >= 2 && n(
368
- "div",
369
- { style: { marginTop: 8 } },
370
- n(Fe, { data: e.sparkline, color: a })
371
- )
372
- );
373
- }
374
- function Ze({
375
- metrics: e,
376
- columns: t = 3,
377
- animate: o = !0,
378
- onMetricClick: r
379
- }) {
380
- const a = ee();
381
- Ne();
382
- const s = {
383
- display: "grid",
384
- gridTemplateColumns: `repeat(${t}, minmax(0, 1fr))`,
385
- gap: 16
386
- };
387
- return n(
388
- "div",
389
- { style: s },
390
- ...e.map(
391
- (f) => n(De, {
392
- key: f.id,
393
- metric: f,
394
- animate: o,
395
- onMetricClick: r,
396
- theme: a
397
- })
398
- )
399
- );
400
- }
401
- function xe(e) {
402
- const t = new Date(e), o = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), a = String(t.getSeconds()).padStart(2, "0");
403
- return `${o}:${r}:${a}`;
404
- }
405
- function he(e) {
406
- return Math.abs(e) >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(1)}k` : Number.isInteger(e) ? String(e) : e.toFixed(2);
407
- }
408
- function Qe({
409
- data: e,
410
- maxPoints: t = 60,
411
- height: o = 200,
412
- width: r = "100%",
413
- color: a,
414
- fill: s = !0,
415
- showGrid: f = !0,
416
- showLabels: u = !0,
417
- showTooltip: h = !0,
418
- label: l,
419
- unit: y,
420
- animate: v = !0,
421
- yMin: k,
422
- yMax: b
423
- }) {
424
- const x = ee(), C = a ?? x.primary, N = D(null), [V, R] = W(600), [$, w] = W(null), [P, Y] = W(0), H = D(e.length);
425
- B(() => {
426
- if (!N.current) return;
427
- const i = new ResizeObserver((m) => {
428
- const O = m[0];
429
- O && R(O.contentRect.width);
430
- });
431
- return i.observe(N.current), R(N.current.offsetWidth), () => i.disconnect();
432
- }, []);
433
- const g = Q(
434
- () => e.slice(-t),
435
- [e, t]
436
- );
437
- B(() => {
438
- g.length > H.current && Y((i) => i + 1), H.current = g.length;
439
- }, [g.length]);
440
- const T = u ? 48 : 12, G = 12, z = l ? 28 : 12, I = 28, S = Math.max(V - T - G, 1), E = Math.max(o - z - I, 1), j = g.length ? Math.min(...g.map((i) => i.value)) : 0, F = g.length ? Math.max(...g.map((i) => i.value)) : 1, A = F - j || 1, d = k !== void 0 ? k : j - A * 0.1, p = (b !== void 0 ? b : F + A * 0.1) - d || 1;
441
- function M(i) {
442
- return g.length < 2 ? S / 2 : i / (g.length - 1) * S;
443
- }
444
- function q(i) {
445
- return E - (i - d) / p * E;
446
- }
447
- const X = g.length >= 2 ? g.map((i, m) => `${m === 0 ? "M" : "L"}${M(m).toFixed(2)},${q(i.value).toFixed(2)}`).join(" ") : "", ae = X ? `${X} L${M(g.length - 1).toFixed(2)},${E} L${M(0).toFixed(2)},${E} Z` : "", te = 4, ne = [];
448
- for (let i = 0; i <= te; i++)
449
- ne.push(i);
450
- const be = ne.map((i) => {
451
- const m = d + i / te * p;
452
- return { y: q(m), text: he(m) };
453
- }), oe = Math.min(4, g.length), Se = oe > 0 ? Array.from(
454
- { length: oe },
455
- (i, m) => Math.round(m / Math.max(oe - 1, 1) * (g.length - 1))
456
- ) : [], ke = K(
457
- (i) => {
458
- if (!h || g.length === 0) return;
459
- const m = i.currentTarget.getBoundingClientRect(), O = i.clientX - m.left - T;
460
- let U = 0, le = 1 / 0;
461
- g.forEach((Ue, ce) => {
462
- const de = Math.abs(M(ce) - O);
463
- de < le && (le = de, U = ce);
464
- });
465
- const se = g[U];
466
- if (!se) return;
467
- const $e = M(U) + T, Te = q(se.value) + z;
468
- w({ x: $e, y: Te, point: se });
469
- },
470
- [g, h, T, z]
471
- ), we = K(() => w(null), []), re = V, J = o, ie = `tkx-chart-clip-${P}`, Me = {
472
- position: "relative",
473
- width: typeof r == "number" ? `${r}px` : r,
474
- background: x.surface,
475
- border: `1px solid ${x.border}`,
476
- borderRadius: 8,
477
- overflow: "hidden",
478
- boxSizing: "border-box"
479
- };
480
- return n(
481
- "div",
482
- { ref: N, style: Me },
483
- n(
484
- "svg",
485
- {
486
- width: re,
487
- height: J,
488
- viewBox: `0 0 ${re} ${J}`,
489
- onMouseMove: ke,
490
- onMouseLeave: we,
491
- style: { display: "block", userSelect: "none" },
492
- "aria-label": l ? L(l) : "Real-time chart"
493
- },
494
- // Defs: clip for animation
495
- v && g.length >= 2 && n(
496
- "defs",
497
- null,
498
- n(
499
- "clipPath",
500
- { id: ie },
501
- n(
502
- "rect",
503
- {
504
- x: 0,
505
- y: 0,
506
- width: S,
507
- height: J
508
- },
509
- n("animate", {
510
- attributeName: "width",
511
- from: Math.max(0, S - S / Math.max(g.length - 1, 1)),
512
- to: S,
513
- dur: "0.3s",
514
- fill: "freeze"
515
- })
516
- )
517
- )
518
- ),
519
- // Chart title
520
- l && n(
521
- "text",
522
- {
523
- x: T,
524
- y: 18,
525
- fill: x.textMuted,
526
- fontSize: 12,
527
- fontWeight: 500
528
- },
529
- L(l)
530
- ),
531
- // Grid lines
532
- f && ne.map((i) => {
533
- const m = q(d + i / te * p) + z;
534
- return n("line", {
535
- key: `grid-${i}`,
536
- x1: T,
537
- y1: m,
538
- x2: T + S,
539
- y2: m,
540
- stroke: x.border,
541
- strokeWidth: 1,
542
- strokeDasharray: "4 4"
543
- });
544
- }),
545
- // Y axis labels
546
- u && be.map((i, m) => n(
547
- "text",
548
- {
549
- key: `yl-${m}`,
550
- x: T - 4,
551
- y: i.y + z + 4,
552
- fill: x.textMuted,
553
- fontSize: 10,
554
- textAnchor: "end"
555
- },
556
- i.text
557
- )),
558
- // Y axis unit
559
- y && n(
560
- "text",
561
- { x: 4, y: z + 10, fill: x.textMuted, fontSize: 9 },
562
- L(y)
563
- ),
564
- // Area fill
565
- s && ae && n("path", {
566
- d: ae,
567
- fill: `${C}22`,
568
- clipPath: v ? `url(#${ie})` : void 0,
569
- transform: `translate(${T}, ${z})`
570
- }),
571
- // Data line
572
- X && n("path", {
573
- d: X,
574
- fill: "none",
575
- stroke: C,
576
- strokeWidth: 2,
577
- strokeLinejoin: "round",
578
- strokeLinecap: "round",
579
- clipPath: v ? `url(#${ie})` : void 0,
580
- transform: `translate(${T}, ${z})`
581
- }),
582
- // X axis labels
583
- Se.map((i) => {
584
- const m = g[i];
585
- return m ? n(
586
- "text",
587
- {
588
- key: `xl-${i}`,
589
- x: T + M(i),
590
- y: J - 8,
591
- fill: x.textMuted,
592
- fontSize: 9,
593
- textAnchor: "middle"
594
- },
595
- xe(m.timestamp)
596
- ) : null;
597
- }),
598
- // Tooltip vertical line
599
- $ && n("line", {
600
- x1: $.x,
601
- y1: z,
602
- x2: $.x,
603
- y2: z + E,
604
- stroke: C,
605
- strokeWidth: 1,
606
- strokeDasharray: "3 3",
607
- opacity: 0.6
608
- }),
609
- // Tooltip dot
610
- $ && n("circle", {
611
- cx: $.x,
612
- cy: $.y,
613
- r: 4,
614
- fill: C,
615
- stroke: x.surface,
616
- strokeWidth: 2
617
- }),
618
- // Tooltip box
619
- $ && (() => {
620
- const i = Math.min($.x + 8, re - 100), m = Math.max($.y - 36, 4), O = `${he($.point.value)}${y || ""}`, U = xe($.point.timestamp);
621
- return n(
622
- "g",
623
- null,
624
- n("rect", {
625
- x: i - 4,
626
- y: m - 2,
627
- width: 90,
628
- height: 34,
629
- rx: 4,
630
- fill: x.surfaceAlt,
631
- stroke: x.border,
632
- strokeWidth: 1
633
- }),
634
- n("text", { x: i, y: m + 11, fill: x.text, fontSize: 12, fontWeight: 700 }, O),
635
- n("text", { x: i, y: m + 26, fill: x.textMuted, fontSize: 10 }, U)
636
- );
637
- })()
638
- )
639
- );
640
- }
641
- const Z = 28, me = 8, ye = {
642
- debug: 0,
643
- info: 1,
644
- warn: 2,
645
- error: 3,
646
- fatal: 4
647
- };
648
- let ve = !1;
649
- function je() {
650
- if (ve || typeof document > "u") return;
651
- ve = !0;
652
- const e = document.createElement("style");
653
- e.id = "tkx-live-log-styles", e.textContent = `
654
- .tkx-log-row:hover { filter: brightness(1.12); }
655
- .tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }
656
- `.trim(), document.head.appendChild(e);
657
- }
658
- function Be(e) {
659
- const t = new Date(e), o = String(t.getHours()).padStart(2, "0"), r = String(t.getMinutes()).padStart(2, "0"), a = String(t.getSeconds()).padStart(2, "0"), s = String(t.getMilliseconds()).padStart(3, "0");
660
- return `${o}:${r}:${a}.${s}`;
661
- }
662
- function Ve(e, t) {
663
- switch (e) {
664
- case "debug":
665
- return t.textMuted;
666
- case "info":
667
- return t.info;
668
- case "warn":
669
- return t.warning;
670
- case "error":
671
- return t.danger;
672
- case "fatal":
673
- return t.danger;
674
- default:
675
- return t.textMuted;
676
- }
677
- }
678
- function Oe(e, t) {
679
- return e === "fatal" ? `${t.danger}22` : "transparent";
680
- }
681
- function Pe(e) {
682
- return `[${e.toUpperCase().padEnd(5)}]`;
683
- }
684
- function Ye(e, t) {
685
- if (!t) return [e];
686
- const o = L(e), r = L(t);
687
- if (!r) return [o];
688
- try {
689
- const a = new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi");
690
- return o.split(a).map(
691
- (f, u) => a.test(f) ? n("mark", { key: u, className: "tkx-log-highlight" }, f) : f
692
- );
693
- } catch {
694
- return [o];
695
- }
696
- }
697
- function _e({
698
- entry: e,
699
- showLevel: t,
700
- showTimestamp: o,
701
- showSource: r,
702
- searchQuery: a,
703
- monospace: s,
704
- isExpanded: f,
705
- onToggle: u,
706
- onEntryClick: h,
707
- theme: l,
708
- style: y
709
- }) {
710
- const v = Ve(e.level, l), k = Oe(e.level, l), b = e.metadata && Object.keys(e.metadata).length > 0, x = {
711
- ...y,
712
- display: "flex",
713
- alignItems: "center",
714
- gap: 6,
715
- padding: "0 10px",
716
- fontSize: 12,
717
- fontFamily: s ? '"JetBrains Mono", "Fira Mono", Consolas, monospace' : "inherit",
718
- cursor: b || h ? "pointer" : "default",
719
- background: k,
720
- boxSizing: "border-box",
721
- height: Z,
722
- overflow: "hidden",
723
- whiteSpace: "nowrap",
724
- borderBottom: `1px solid ${l.border}22`
725
- };
726
- return n(
727
- "div",
728
- {
729
- style: x,
730
- className: "tkx-log-row",
731
- onClick: () => {
732
- b && u(), h && h(e);
733
- },
734
- role: b ? "button" : void 0,
735
- tabIndex: b ? 0 : void 0,
736
- onKeyDown: b ? (N) => {
737
- (N.key === "Enter" || N.key === " ") && u();
738
- } : void 0,
739
- "aria-expanded": b ? f : void 0
740
- },
741
- // Timestamp
742
- o && n(
743
- "span",
744
- { style: { color: l.textMuted, flexShrink: 0, minWidth: 84 } },
745
- Be(e.timestamp)
746
- ),
747
- // Level badge
748
- t && n(
749
- "span",
750
- {
751
- style: {
752
- color: v,
753
- flexShrink: 0,
754
- fontWeight: e.level === "fatal" ? 700 : 500,
755
- minWidth: 56
756
- }
757
- },
758
- Pe(e.level)
759
- ),
760
- // Source badge
761
- r && e.source && n(
762
- "span",
763
- {
764
- style: {
765
- background: l.surfaceAlt,
766
- border: `1px solid ${l.border}`,
767
- borderRadius: 10,
768
- padding: "0 5px",
769
- fontSize: 10,
770
- color: l.textMuted,
771
- flexShrink: 0,
772
- maxWidth: 80,
773
- overflow: "hidden",
774
- textOverflow: "ellipsis"
775
- }
776
- },
777
- L(e.source)
778
- ),
779
- // Message
780
- n(
781
- "span",
782
- { style: { flex: 1, color: l.text, overflow: "hidden", textOverflow: "ellipsis" } },
783
- ...Ye(e.message, a)
784
- ),
785
- // Expand indicator
786
- b && n(
787
- "span",
788
- { style: { color: l.textMuted, fontSize: 10, flexShrink: 0 } },
789
- f ? "▲" : "▼"
790
- )
791
- );
792
- }
793
- function Ge({ metadata: e, theme: t, style: o }) {
794
- const r = {
795
- ...o,
796
- background: t.surfaceAlt,
797
- borderBottom: `1px solid ${t.border}`,
798
- padding: "6px 10px 6px 56px",
799
- display: "flex",
800
- flexWrap: "wrap",
801
- gap: 6,
802
- boxSizing: "border-box"
803
- };
804
- return n(
805
- "div",
806
- { style: r },
807
- ...Object.entries(e).map(
808
- ([a, s]) => n(
809
- "span",
810
- {
811
- key: a,
812
- style: {
813
- fontSize: 11,
814
- fontFamily: "monospace",
815
- color: t.textMuted,
816
- background: t.surface,
817
- border: `1px solid ${t.border}`,
818
- borderRadius: 4,
819
- padding: "1px 6px"
820
- }
821
- },
822
- n("span", { style: { color: t.info } }, `${L(a)}: `),
823
- L(String(s))
824
- )
825
- )
826
- );
827
- }
828
- function et({
829
- entries: e,
830
- maxEntries: t = 500,
831
- height: o = 400,
832
- autoScroll: r = !0,
833
- showLevel: a = !0,
834
- showTimestamp: s = !0,
835
- showSource: f = !0,
836
- filterLevel: u,
837
- searchQuery: h = "",
838
- monospace: l = !0,
839
- onEntryClick: y
840
- }) {
841
- const v = ee();
842
- je();
843
- const k = D(null), [b, x] = W(0), [C, N] = W(/* @__PURE__ */ new Set()), [V, R] = W(!1), $ = D(e.length), w = Q(() => {
844
- let d = e.slice(-t);
845
- if (u !== void 0) {
846
- const c = ye[u];
847
- d = d.filter((p) => ye[p.level] >= c);
848
- }
849
- if (h) {
850
- const c = h.toLowerCase();
851
- d = d.filter(
852
- (p) => p.message.toLowerCase().includes(c) || (p.source ?? "").toLowerCase().includes(c)
853
- );
854
- }
855
- return d;
856
- }, [e, t, u, h]), P = typeof o == "number" ? o : 400, Y = 40, H = Q(() => {
857
- const d = [];
858
- let c = 0;
859
- for (const p of w)
860
- d.push(c), c += Z + (C.has(p.id) ? Y : 0);
861
- return d.push(c), d;
862
- }, [w, C]), g = H[H.length - 1] ?? 0;
863
- B(() => {
864
- !r || V || w.length !== $.current && ($.current = w.length, k.current && (k.current.scrollTop = k.current.scrollHeight));
865
- }, [w.length, r, V]);
866
- const T = K(() => {
867
- if (!k.current) return;
868
- const d = k.current, c = d.scrollHeight - d.scrollTop - d.clientHeight < Z * 2;
869
- R(!c), x(d.scrollTop);
870
- }, []), G = K((d) => {
871
- N((c) => {
872
- const p = new Set(c);
873
- return p.has(d) ? p.delete(d) : p.add(d), p;
874
- });
875
- }, []);
876
- function z(d) {
877
- let c = 0, p = w.length - 1;
878
- for (; c < p; ) {
879
- const M = c + p >> 1;
880
- (H[M + 1] ?? 0) <= d ? c = M + 1 : p = M;
881
- }
882
- return Math.max(0, c - me);
883
- }
884
- function I(d) {
885
- let c = 0, p = w.length - 1;
886
- for (; c < p; ) {
887
- const M = c + p + 1 >> 1;
888
- (H[M] ?? 0) >= d + P ? p = M - 1 : c = M;
889
- }
890
- return Math.min(w.length - 1, c + me);
891
- }
892
- const S = w.length > 0 ? z(b) : 0, E = w.length > 0 ? I(b) : -1, j = {
893
- position: "relative",
894
- overflow: "auto",
895
- height: typeof o == "number" ? `${o}px` : o,
896
- background: v.bg,
897
- border: `1px solid ${v.border}`,
898
- borderRadius: 8,
899
- boxSizing: "border-box"
900
- }, F = {
901
- position: "relative",
902
- height: g,
903
- minHeight: "100%"
904
- };
905
- if (w.length === 0)
906
- return n(
907
- "div",
908
- { style: { ...j, display: "flex", alignItems: "center", justifyContent: "center" } },
909
- n("span", { style: { color: v.textMuted, fontSize: 13, fontFamily: "monospace" } }, "No log entries.")
910
- );
911
- const A = [];
912
- for (let d = S; d <= E; d++) {
913
- const c = w[d];
914
- if (!c) continue;
915
- const p = H[d] ?? 0, M = C.has(c.id);
916
- A.push(
917
- n(_e, {
918
- key: c.id,
919
- entry: c,
920
- showLevel: a,
921
- showTimestamp: s,
922
- showSource: f,
923
- searchQuery: h,
924
- monospace: l,
925
- isExpanded: M,
926
- onToggle: () => G(c.id),
927
- onEntryClick: y,
928
- theme: v,
929
- style: { position: "absolute", top: p, left: 0, right: 0 }
930
- })
931
- ), M && c.metadata && Object.keys(c.metadata).length > 0 && A.push(
932
- n(Ge, {
933
- key: `${c.id}-meta`,
934
- metadata: c.metadata,
935
- theme: v,
936
- style: { position: "absolute", top: p + Z, left: 0, right: 0, height: Y }
937
- })
938
- );
939
- }
940
- return n(
941
- "div",
942
- {
943
- ref: k,
944
- style: j,
945
- onScroll: T,
946
- role: "log",
947
- "aria-live": "polite",
948
- "aria-label": "Log viewer"
949
- },
950
- n("div", { style: F }, ...A)
951
- );
952
- }
953
- export {
954
- Je as TkxLiveFeed,
955
- et as TkxLiveLog,
956
- Ze as TkxLiveMetrics,
957
- Qe as TkxRealTimeChart
958
- };
1
+ import { f as e } from "./themes-BbJanqiC.js";
2
+ import { m as t } from "./tkx-DQkvHdE5.js";
3
+ import { createElement as n, useCallback as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
4
+ //#region src/components/TkxLiveFeed.tsx
5
+ var c = 64, l = 5, u = !1;
6
+ function d() {
7
+ if (u || typeof document > "u") return;
8
+ u = !0;
9
+ let e = document.createElement("style");
10
+ e.id = "tkx-live-feed-styles", e.textContent = "@keyframes tkx-feed-slide-in {\n from { transform: translateY(-20px); opacity: 0; }\n to { transform: translateY(0); opacity: 1; }\n}\n.tkx-feed-item-new {\n animation: tkx-feed-slide-in 0.25s ease-out both;\n}", document.head.appendChild(e);
11
+ }
12
+ function f(e) {
13
+ let t = Date.now() - e;
14
+ return t < 1e4 ? "just now" : t < 6e4 ? `${Math.floor(t / 1e3)}s ago` : t < 36e5 ? `${Math.floor(t / 6e4)}m ago` : t < 864e5 ? `${Math.floor(t / 36e5)}h ago` : `${Math.floor(t / 864e5)}d ago`;
15
+ }
16
+ function p(e, t) {
17
+ switch (e) {
18
+ case "info": return t.info;
19
+ case "success": return t.success;
20
+ case "warning": return t.warning;
21
+ case "error": return t.danger;
22
+ default: return t.border;
23
+ }
24
+ }
25
+ function m(e) {
26
+ return e ? e.split(" ").map((e) => e[0] ?? "").slice(0, 2).join("").toUpperCase() : "?";
27
+ }
28
+ function h({ item: e, isNew: r, showTimestamps: i, onItemClick: a, renderItem: o, theme: s, style: l }) {
29
+ let u = p(e.type, s);
30
+ return o ? n("div", {
31
+ style: l,
32
+ className: r ? "tkx-feed-item-new" : void 0
33
+ }, o(e)) : n("div", {
34
+ style: {
35
+ ...l,
36
+ display: "flex",
37
+ alignItems: "center",
38
+ gap: 10,
39
+ padding: "0 12px",
40
+ borderLeft: `3px solid ${u}`,
41
+ cursor: a ? "pointer" : "default",
42
+ boxSizing: "border-box",
43
+ height: c,
44
+ background: s.surface,
45
+ transition: "background 0.15s"
46
+ },
47
+ className: r ? "tkx-feed-item-new" : void 0,
48
+ onClick: a ? () => a(e) : void 0,
49
+ role: a ? "button" : void 0,
50
+ tabIndex: a ? 0 : void 0,
51
+ onKeyDown: a ? (t) => {
52
+ (t.key === "Enter" || t.key === " ") && a(e);
53
+ } : void 0
54
+ }, n("div", { style: {
55
+ width: 36,
56
+ height: 36,
57
+ borderRadius: "50%",
58
+ background: u,
59
+ display: "flex",
60
+ alignItems: "center",
61
+ justifyContent: "center",
62
+ fontSize: 13,
63
+ fontWeight: 700,
64
+ color: s.bg,
65
+ flexShrink: 0,
66
+ overflow: "hidden"
67
+ } }, e.avatar ? n("img", {
68
+ src: e.avatar,
69
+ alt: e.author ?? "",
70
+ style: {
71
+ width: "100%",
72
+ height: "100%",
73
+ objectFit: "cover"
74
+ }
75
+ }) : m(e.author)), n("div", { style: {
76
+ flex: 1,
77
+ minWidth: 0
78
+ } }, n("div", { style: {
79
+ display: "flex",
80
+ alignItems: "center",
81
+ gap: 6,
82
+ marginBottom: 2
83
+ } }, e.author && n("span", { style: {
84
+ fontWeight: 600,
85
+ fontSize: 13,
86
+ color: s.text
87
+ } }, t(e.author)), e.meta && n("span", { style: {
88
+ fontSize: 11,
89
+ color: s.textMuted,
90
+ background: s.surfaceAlt,
91
+ borderRadius: 4,
92
+ padding: "1px 5px"
93
+ } }, t(e.meta))), n("div", { style: {
94
+ fontSize: 13,
95
+ color: s.text,
96
+ overflow: "hidden",
97
+ textOverflow: "ellipsis",
98
+ whiteSpace: "nowrap"
99
+ } }, t(e.content))), i && n("div", { style: {
100
+ fontSize: 11,
101
+ color: s.textMuted,
102
+ flexShrink: 0
103
+ } }, f(e.timestamp)));
104
+ }
105
+ function g({ items: u, maxItems: f = 100, height: p = 400, autoScroll: m = !0, showTimestamps: g = !0, onItemClick: _, emptyMessage: v = "No activity yet.", pauseOnHover: y = !0, renderItem: b }) {
106
+ let x = e();
107
+ d();
108
+ let S = o(null), [C, w] = s(0), [T, E] = s(!1), [D, O] = s(/* @__PURE__ */ new Set()), k = o([]), A = a(() => u.slice(-f), [u, f]), j = typeof p == "number" ? p : 400, M = A.length * c;
109
+ i(() => {
110
+ let e = new Set(k.current.map((e) => e.id)), t = A.filter((t) => !e.has(t.id)).map((e) => e.id);
111
+ if (t.length > 0) {
112
+ O((e) => {
113
+ let n = new Set(e);
114
+ return t.forEach((e) => n.add(e)), n;
115
+ });
116
+ let e = window.setTimeout(() => {
117
+ O((e) => {
118
+ let n = new Set(e);
119
+ return t.forEach((e) => n.delete(e)), n;
120
+ });
121
+ }, 400);
122
+ return () => clearTimeout(e);
123
+ }
124
+ }, [A]), i(() => {
125
+ k.current = A;
126
+ }, [A]);
127
+ let N = m && !(y && T);
128
+ i(() => {
129
+ if (!N || !S.current) return;
130
+ let e = S.current;
131
+ (e.scrollHeight - e.scrollTop - e.clientHeight < c * 3 || A.length <= 5) && (e.scrollTop = e.scrollHeight);
132
+ }, [A.length, N]);
133
+ let P = r(() => {
134
+ S.current && w(S.current.scrollTop);
135
+ }, []), F = Math.max(0, Math.floor(C / c) - l), I = Math.min(A.length - 1, Math.ceil((C + j) / c) + l), L = {
136
+ position: "relative",
137
+ overflow: "auto",
138
+ height: typeof p == "number" ? `${p}px` : p,
139
+ background: x.bg,
140
+ border: `1px solid ${x.border}`,
141
+ borderRadius: 8,
142
+ boxSizing: "border-box"
143
+ }, R = {
144
+ position: "relative",
145
+ height: M,
146
+ minHeight: "100%"
147
+ };
148
+ if (A.length === 0) return n("div", { style: {
149
+ ...L,
150
+ display: "flex",
151
+ alignItems: "center",
152
+ justifyContent: "center"
153
+ } }, n("span", { style: {
154
+ color: x.textMuted,
155
+ fontSize: 14
156
+ } }, t(v)));
157
+ let z = [];
158
+ for (let e = F; e <= I; e++) {
159
+ let t = A[e];
160
+ t && z.push(n(h, {
161
+ key: t.id,
162
+ item: t,
163
+ isNew: D.has(t.id),
164
+ showTimestamps: g,
165
+ onItemClick: _,
166
+ renderItem: b,
167
+ theme: x,
168
+ style: {
169
+ position: "absolute",
170
+ top: e * c,
171
+ left: 0,
172
+ right: 0
173
+ }
174
+ }));
175
+ }
176
+ return n("div", {
177
+ ref: S,
178
+ style: L,
179
+ onScroll: P,
180
+ onMouseEnter: y ? () => E(!0) : void 0,
181
+ onMouseLeave: y ? () => E(!1) : void 0,
182
+ "aria-label": "Live feed",
183
+ role: "feed"
184
+ }, n("div", { style: R }, ...z));
185
+ }
186
+ //#endregion
187
+ //#region src/components/TkxLiveMetrics.tsx
188
+ var _ = !1;
189
+ function v() {
190
+ if (_ || typeof document > "u") return;
191
+ _ = !0;
192
+ let e = document.createElement("style");
193
+ e.id = "tkx-live-metrics-styles", e.textContent = "@keyframes tkx-metric-pulse {\n 0% { opacity: 1; }\n 40% { opacity: 0.4; }\n 100% { opacity: 1; }\n}\n@keyframes tkx-metric-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n}\n.tkx-metric-shimmer {\n animation: tkx-metric-shimmer 0.6s ease-in-out;\n}\n@media (prefers-reduced-motion: reduce) {\n .tkx-metric-shimmer { animation: none; }\n .tkx-metric-pulse { animation: none; }\n}", document.head.appendChild(e);
194
+ }
195
+ function y(e, t) {
196
+ if (typeof e == "string") return e;
197
+ let n = e >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : e >= 1e3 ? `${(e / 1e3).toFixed(1)}k` : String(Number.isInteger(e) ? e : e.toFixed(2));
198
+ return t ? `${n}${t}` : n;
199
+ }
200
+ function b(e, t) {
201
+ switch (e) {
202
+ case "warning": return t.warning;
203
+ case "critical": return t.danger;
204
+ default: return t.primary;
205
+ }
206
+ }
207
+ function x() {
208
+ let [e, t] = s(() => typeof window < "u" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : !1);
209
+ return i(() => {
210
+ if (typeof window > "u") return;
211
+ let e = window.matchMedia("(prefers-reduced-motion: reduce)"), n = (e) => t(e.matches);
212
+ return e.addEventListener("change", n), () => e.removeEventListener("change", n);
213
+ }, []), e;
214
+ }
215
+ function S(e, t, n) {
216
+ let [r, a] = s(e), c = o(e), l = o(null), u = o(null), d = x();
217
+ return i(() => {
218
+ if (!n || d) {
219
+ a(e), c.current = e;
220
+ return;
221
+ }
222
+ let r = c.current;
223
+ if (r === e) return;
224
+ l.current = null;
225
+ let i = (n) => {
226
+ l.current === null && (l.current = n);
227
+ let o = n - l.current, s = Math.min(o / t, 1), d = 1 - (1 - s) ** 3;
228
+ a(r + (e - r) * d), s < 1 ? u.current = requestAnimationFrame(i) : c.current = e;
229
+ };
230
+ return u.current = requestAnimationFrame(i), () => {
231
+ u.current !== null && cancelAnimationFrame(u.current);
232
+ };
233
+ }, [
234
+ e,
235
+ t,
236
+ n,
237
+ d
238
+ ]), r;
239
+ }
240
+ function C({ data: e, color: t }) {
241
+ if (e.length < 2) return null;
242
+ let r = Math.min(...e), i = Math.max(...e) - r || 1;
243
+ return n("svg", {
244
+ width: 80,
245
+ height: 24,
246
+ viewBox: "0 0 80 24",
247
+ "aria-hidden": "true"
248
+ }, n("polyline", {
249
+ points: e.map((t, n) => {
250
+ let a = n / (e.length - 1) * 80, o = 24 - (t - r) / i * 22 - 1;
251
+ return `${a.toFixed(1)},${o.toFixed(1)}`;
252
+ }).join(" "),
253
+ fill: "none",
254
+ stroke: t,
255
+ strokeWidth: 1.5,
256
+ strokeLinejoin: "round",
257
+ strokeLinecap: "round"
258
+ }));
259
+ }
260
+ function w({ trend: e, theme: t }) {
261
+ return e === "up" ? n("span", { style: {
262
+ color: t.success,
263
+ fontSize: 14,
264
+ fontWeight: 700
265
+ } }, "▲") : e === "down" ? n("span", { style: {
266
+ color: t.danger,
267
+ fontSize: 14,
268
+ fontWeight: 700
269
+ } }, "▼") : n("span", { style: {
270
+ color: t.textMuted,
271
+ fontSize: 14
272
+ } }, "→");
273
+ }
274
+ function T({ metric: e, animate: r, onMetricClick: a, theme: c }) {
275
+ let l = e.color ?? b(e.status, c), u = typeof e.value == "number" ? e.value : NaN, d = S(isNaN(u) ? 0 : u, 600, r && !isNaN(u)), [f, p] = s(!1), m = o(e.value);
276
+ i(() => {
277
+ if (m.current !== e.value) {
278
+ m.current = e.value, p(!0);
279
+ let t = window.setTimeout(() => p(!1), 700);
280
+ return () => clearTimeout(t);
281
+ }
282
+ }, [e.value]);
283
+ let h = e.previousValue !== void 0 && e.previousValue !== u, g = {
284
+ background: c.surface,
285
+ border: `1px solid ${c.border}`,
286
+ borderLeft: `4px solid ${l}`,
287
+ borderRadius: 8,
288
+ padding: "14px 16px",
289
+ cursor: a ? "pointer" : "default",
290
+ position: "relative",
291
+ overflow: "hidden",
292
+ boxSizing: "border-box"
293
+ }, _ = f ? {
294
+ position: "absolute",
295
+ inset: 0,
296
+ background: `linear-gradient(90deg, transparent 0%, ${l}22 50%, transparent 100%)`,
297
+ backgroundSize: "200% 100%",
298
+ animation: "tkx-metric-shimmer 0.6s ease-in-out",
299
+ pointerEvents: "none"
300
+ } : {}, v = isNaN(u) ? t(String(e.value)) : y(d, e.unit);
301
+ return n("div", {
302
+ style: g,
303
+ className: f ? "tkx-metric-shimmer" : void 0,
304
+ onClick: a ? () => a(e) : void 0,
305
+ role: a ? "button" : void 0,
306
+ tabIndex: a ? 0 : void 0
307
+ }, f && n("div", { style: _ }), n("div", { style: {
308
+ fontSize: 12,
309
+ color: c.textMuted,
310
+ marginBottom: 6,
311
+ fontWeight: 500,
312
+ letterSpacing: "0.03em"
313
+ } }, t(e.label)), n("div", { style: {
314
+ display: "flex",
315
+ alignItems: "flex-end",
316
+ gap: 6,
317
+ marginBottom: 6
318
+ } }, n("span", { style: {
319
+ fontSize: 28,
320
+ fontWeight: 700,
321
+ color: c.text,
322
+ lineHeight: 1
323
+ } }, v), e.unit && isNaN(u) && n("span", { style: {
324
+ fontSize: 14,
325
+ color: c.textMuted,
326
+ marginBottom: 2
327
+ } }, t(e.unit))), (e.trend || e.trendValue) && n("div", { style: {
328
+ display: "flex",
329
+ alignItems: "center",
330
+ gap: 4,
331
+ marginBottom: e.sparkline ? 8 : 0
332
+ } }, e.trend && n(w, {
333
+ trend: e.trend,
334
+ theme: c
335
+ }), e.trendValue && n("span", { style: {
336
+ fontSize: 12,
337
+ color: c.textMuted
338
+ } }, t(e.trendValue))), h && n("div", { style: {
339
+ fontSize: 11,
340
+ color: c.textMuted,
341
+ marginTop: 2
342
+ } }, `was ${y(e.previousValue)}`), e.sparkline && e.sparkline.length >= 2 && n("div", { style: { marginTop: 8 } }, n(C, {
343
+ data: e.sparkline,
344
+ color: l
345
+ })));
346
+ }
347
+ function E({ metrics: t, columns: r = 3, animate: i = !0, onMetricClick: a }) {
348
+ let o = e();
349
+ return v(), n("div", { style: {
350
+ display: "grid",
351
+ gridTemplateColumns: `repeat(${r}, minmax(0, 1fr))`,
352
+ gap: 16
353
+ } }, ...t.map((e) => n(T, {
354
+ key: e.id,
355
+ metric: e,
356
+ animate: i,
357
+ onMetricClick: a,
358
+ theme: o
359
+ })));
360
+ }
361
+ //#endregion
362
+ //#region src/components/TkxRealTimeChart.tsx
363
+ function D(e) {
364
+ let t = new Date(e);
365
+ return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}:${String(t.getSeconds()).padStart(2, "0")}`;
366
+ }
367
+ function O(e) {
368
+ return Math.abs(e) >= 1e6 ? `${(e / 1e6).toFixed(1)}M` : Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(1)}k` : Number.isInteger(e) ? String(e) : e.toFixed(2);
369
+ }
370
+ function k({ data: c, maxPoints: l = 60, height: u = 200, width: d = "100%", color: f, fill: p = !0, showGrid: m = !0, showLabels: h = !0, showTooltip: g = !0, label: _, unit: v, animate: y = !0, yMin: b, yMax: x }) {
371
+ let S = e(), C = f ?? S.primary, w = o(null), [T, E] = s(600), [k, A] = s(null), [j, M] = s(0), N = o(c.length);
372
+ i(() => {
373
+ if (!w.current) return;
374
+ let e = new ResizeObserver((e) => {
375
+ let t = e[0];
376
+ t && E(t.contentRect.width);
377
+ });
378
+ return e.observe(w.current), E(w.current.offsetWidth), () => e.disconnect();
379
+ }, []);
380
+ let P = a(() => c.slice(-l), [c, l]);
381
+ i(() => {
382
+ P.length > N.current && M((e) => e + 1), N.current = P.length;
383
+ }, [P.length]);
384
+ let F = h ? 48 : 12, I = _ ? 28 : 12, L = Math.max(T - F - 12, 1), R = Math.max(u - I - 28, 1), z = P.length ? Math.min(...P.map((e) => e.value)) : 0, B = P.length ? Math.max(...P.map((e) => e.value)) : 1, V = B - z || 1, H = b === void 0 ? z - V * .1 : b, U = (x === void 0 ? B + V * .1 : x) - H || 1;
385
+ function W(e) {
386
+ return P.length < 2 ? L / 2 : e / (P.length - 1) * L;
387
+ }
388
+ function G(e) {
389
+ return R - (e - H) / U * R;
390
+ }
391
+ let K = P.length >= 2 ? P.map((e, t) => `${t === 0 ? "M" : "L"}${W(t).toFixed(2)},${G(e.value).toFixed(2)}`).join(" ") : "", q = K ? `${K} L${W(P.length - 1).toFixed(2)},${R} L${W(0).toFixed(2)},${R} Z` : "", J = [];
392
+ for (let e = 0; e <= 4; e++) J.push(e);
393
+ let Y = J.map((e) => {
394
+ let t = H + e / 4 * U;
395
+ return {
396
+ y: G(t),
397
+ text: O(t)
398
+ };
399
+ }), X = Math.min(4, P.length), ee = X > 0 ? Array.from({ length: X }, (e, t) => Math.round(t / Math.max(X - 1, 1) * (P.length - 1))) : [], te = r((e) => {
400
+ if (!g || P.length === 0) return;
401
+ let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left - F, r = 0, i = Infinity;
402
+ P.forEach((e, t) => {
403
+ let a = Math.abs(W(t) - n);
404
+ a < i && (i = a, r = t);
405
+ });
406
+ let a = P[r];
407
+ a && A({
408
+ x: W(r) + F,
409
+ y: G(a.value) + I,
410
+ point: a
411
+ });
412
+ }, [
413
+ P,
414
+ g,
415
+ F,
416
+ I
417
+ ]), ne = r(() => A(null), []), Z = T, Q = u, $ = `tkx-chart-clip-${j}`;
418
+ return n("div", {
419
+ ref: w,
420
+ style: {
421
+ position: "relative",
422
+ width: typeof d == "number" ? `${d}px` : d,
423
+ background: S.surface,
424
+ border: `1px solid ${S.border}`,
425
+ borderRadius: 8,
426
+ overflow: "hidden",
427
+ boxSizing: "border-box"
428
+ }
429
+ }, n("svg", {
430
+ width: Z,
431
+ height: Q,
432
+ viewBox: `0 0 ${Z} ${Q}`,
433
+ onMouseMove: te,
434
+ onMouseLeave: ne,
435
+ style: {
436
+ display: "block",
437
+ userSelect: "none"
438
+ },
439
+ "aria-label": _ ? t(_) : "Real-time chart"
440
+ }, y && P.length >= 2 && n("defs", null, n("clipPath", { id: $ }, n("rect", {
441
+ x: 0,
442
+ y: 0,
443
+ width: L,
444
+ height: Q
445
+ }, n("animate", {
446
+ attributeName: "width",
447
+ from: Math.max(0, L - L / Math.max(P.length - 1, 1)),
448
+ to: L,
449
+ dur: "0.3s",
450
+ fill: "freeze"
451
+ })))), _ && n("text", {
452
+ x: F,
453
+ y: 18,
454
+ fill: S.textMuted,
455
+ fontSize: 12,
456
+ fontWeight: 500
457
+ }, t(_)), m && J.map((e) => {
458
+ let t = G(H + e / 4 * U) + I;
459
+ return n("line", {
460
+ key: `grid-${e}`,
461
+ x1: F,
462
+ y1: t,
463
+ x2: F + L,
464
+ y2: t,
465
+ stroke: S.border,
466
+ strokeWidth: 1,
467
+ strokeDasharray: "4 4"
468
+ });
469
+ }), h && Y.map((e, t) => n("text", {
470
+ key: `yl-${t}`,
471
+ x: F - 4,
472
+ y: e.y + I + 4,
473
+ fill: S.textMuted,
474
+ fontSize: 10,
475
+ textAnchor: "end"
476
+ }, e.text)), v && n("text", {
477
+ x: 4,
478
+ y: I + 10,
479
+ fill: S.textMuted,
480
+ fontSize: 9
481
+ }, t(v)), p && q && n("path", {
482
+ d: q,
483
+ fill: `${C}22`,
484
+ clipPath: y ? `url(#${$})` : void 0,
485
+ transform: `translate(${F}, ${I})`
486
+ }), K && n("path", {
487
+ d: K,
488
+ fill: "none",
489
+ stroke: C,
490
+ strokeWidth: 2,
491
+ strokeLinejoin: "round",
492
+ strokeLinecap: "round",
493
+ clipPath: y ? `url(#${$})` : void 0,
494
+ transform: `translate(${F}, ${I})`
495
+ }), ee.map((e) => {
496
+ let t = P[e];
497
+ return t ? n("text", {
498
+ key: `xl-${e}`,
499
+ x: F + W(e),
500
+ y: Q - 8,
501
+ fill: S.textMuted,
502
+ fontSize: 9,
503
+ textAnchor: "middle"
504
+ }, D(t.timestamp)) : null;
505
+ }), k && n("line", {
506
+ x1: k.x,
507
+ y1: I,
508
+ x2: k.x,
509
+ y2: I + R,
510
+ stroke: C,
511
+ strokeWidth: 1,
512
+ strokeDasharray: "3 3",
513
+ opacity: .6
514
+ }), k && n("circle", {
515
+ cx: k.x,
516
+ cy: k.y,
517
+ r: 4,
518
+ fill: C,
519
+ stroke: S.surface,
520
+ strokeWidth: 2
521
+ }), k && (() => {
522
+ let e = Math.min(k.x + 8, Z - 100), t = Math.max(k.y - 36, 4), r = `${O(k.point.value)}${v || ""}`, i = D(k.point.timestamp);
523
+ return n("g", null, n("rect", {
524
+ x: e - 4,
525
+ y: t - 2,
526
+ width: 90,
527
+ height: 34,
528
+ rx: 4,
529
+ fill: S.surfaceAlt,
530
+ stroke: S.border,
531
+ strokeWidth: 1
532
+ }), n("text", {
533
+ x: e,
534
+ y: t + 11,
535
+ fill: S.text,
536
+ fontSize: 12,
537
+ fontWeight: 700
538
+ }, r), n("text", {
539
+ x: e,
540
+ y: t + 26,
541
+ fill: S.textMuted,
542
+ fontSize: 10
543
+ }, i));
544
+ })()));
545
+ }
546
+ //#endregion
547
+ //#region src/components/TkxLiveLog.tsx
548
+ var A = 28, j = 8, M = {
549
+ debug: 0,
550
+ info: 1,
551
+ warn: 2,
552
+ error: 3,
553
+ fatal: 4
554
+ }, N = !1;
555
+ function P() {
556
+ if (N || typeof document > "u") return;
557
+ N = !0;
558
+ let e = document.createElement("style");
559
+ e.id = "tkx-live-log-styles", e.textContent = ".tkx-log-row:hover { filter: brightness(1.12); }\n.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }", document.head.appendChild(e);
560
+ }
561
+ function F(e) {
562
+ let t = new Date(e);
563
+ return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}:${String(t.getSeconds()).padStart(2, "0")}.${String(t.getMilliseconds()).padStart(3, "0")}`;
564
+ }
565
+ function I(e, t) {
566
+ switch (e) {
567
+ case "debug": return t.textMuted;
568
+ case "info": return t.info;
569
+ case "warn": return t.warning;
570
+ case "error": return t.danger;
571
+ case "fatal": return t.danger;
572
+ default: return t.textMuted;
573
+ }
574
+ }
575
+ function L(e, t) {
576
+ return e === "fatal" ? `${t.danger}22` : "transparent";
577
+ }
578
+ function R(e) {
579
+ return `[${e.toUpperCase().padEnd(5)}]`;
580
+ }
581
+ function z(e, r) {
582
+ if (!r) return [e];
583
+ let i = t(e), a = t(r);
584
+ if (!a) return [i];
585
+ try {
586
+ let e = RegExp(`(${a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi");
587
+ return i.split(e).map((t, r) => e.test(t) ? n("mark", {
588
+ key: r,
589
+ className: "tkx-log-highlight"
590
+ }, t) : t);
591
+ } catch {
592
+ return [i];
593
+ }
594
+ }
595
+ function B({ entry: e, showLevel: r, showTimestamp: i, showSource: a, searchQuery: o, monospace: s, isExpanded: c, onToggle: l, onEntryClick: u, theme: d, style: f }) {
596
+ let p = I(e.level, d), m = L(e.level, d), h = e.metadata && Object.keys(e.metadata).length > 0;
597
+ return n("div", {
598
+ style: {
599
+ ...f,
600
+ display: "flex",
601
+ alignItems: "center",
602
+ gap: 6,
603
+ padding: "0 10px",
604
+ fontSize: 12,
605
+ fontFamily: s ? "\"JetBrains Mono\", \"Fira Mono\", Consolas, monospace" : "inherit",
606
+ cursor: h || u ? "pointer" : "default",
607
+ background: m,
608
+ boxSizing: "border-box",
609
+ height: A,
610
+ overflow: "hidden",
611
+ whiteSpace: "nowrap",
612
+ borderBottom: `1px solid ${d.border}22`
613
+ },
614
+ className: "tkx-log-row",
615
+ onClick: () => {
616
+ h && l(), u && u(e);
617
+ },
618
+ role: h ? "button" : void 0,
619
+ tabIndex: h ? 0 : void 0,
620
+ onKeyDown: h ? (e) => {
621
+ (e.key === "Enter" || e.key === " ") && l();
622
+ } : void 0,
623
+ "aria-expanded": h ? c : void 0
624
+ }, i && n("span", { style: {
625
+ color: d.textMuted,
626
+ flexShrink: 0,
627
+ minWidth: 84
628
+ } }, F(e.timestamp)), r && n("span", { style: {
629
+ color: p,
630
+ flexShrink: 0,
631
+ fontWeight: e.level === "fatal" ? 700 : 500,
632
+ minWidth: 56
633
+ } }, R(e.level)), a && e.source && n("span", { style: {
634
+ background: d.surfaceAlt,
635
+ border: `1px solid ${d.border}`,
636
+ borderRadius: 10,
637
+ padding: "0 5px",
638
+ fontSize: 10,
639
+ color: d.textMuted,
640
+ flexShrink: 0,
641
+ maxWidth: 80,
642
+ overflow: "hidden",
643
+ textOverflow: "ellipsis"
644
+ } }, t(e.source)), n("span", { style: {
645
+ flex: 1,
646
+ color: d.text,
647
+ overflow: "hidden",
648
+ textOverflow: "ellipsis"
649
+ } }, ...z(e.message, o)), h && n("span", { style: {
650
+ color: d.textMuted,
651
+ fontSize: 10,
652
+ flexShrink: 0
653
+ } }, c ? "" : "▼"));
654
+ }
655
+ function V({ metadata: e, theme: r, style: i }) {
656
+ return n("div", { style: {
657
+ ...i,
658
+ background: r.surfaceAlt,
659
+ borderBottom: `1px solid ${r.border}`,
660
+ padding: "6px 10px 6px 56px",
661
+ display: "flex",
662
+ flexWrap: "wrap",
663
+ gap: 6,
664
+ boxSizing: "border-box"
665
+ } }, ...Object.entries(e).map(([e, i]) => n("span", {
666
+ key: e,
667
+ style: {
668
+ fontSize: 11,
669
+ fontFamily: "monospace",
670
+ color: r.textMuted,
671
+ background: r.surface,
672
+ border: `1px solid ${r.border}`,
673
+ borderRadius: 4,
674
+ padding: "1px 6px"
675
+ }
676
+ }, n("span", { style: { color: r.info } }, `${t(e)}: `), t(String(i)))));
677
+ }
678
+ function H({ entries: t, maxEntries: c = 500, height: l = 400, autoScroll: u = !0, showLevel: d = !0, showTimestamp: f = !0, showSource: p = !0, filterLevel: m, searchQuery: h = "", monospace: g = !0, onEntryClick: _ }) {
679
+ let v = e();
680
+ P();
681
+ let y = o(null), [b, x] = s(0), [S, C] = s(/* @__PURE__ */ new Set()), [w, T] = s(!1), E = o(t.length), D = a(() => {
682
+ let e = t.slice(-c);
683
+ if (m !== void 0) {
684
+ let t = M[m];
685
+ e = e.filter((e) => M[e.level] >= t);
686
+ }
687
+ if (h) {
688
+ let t = h.toLowerCase();
689
+ e = e.filter((e) => e.message.toLowerCase().includes(t) || (e.source ?? "").toLowerCase().includes(t));
690
+ }
691
+ return e;
692
+ }, [
693
+ t,
694
+ c,
695
+ m,
696
+ h
697
+ ]), O = typeof l == "number" ? l : 400, k = a(() => {
698
+ let e = [], t = 0;
699
+ for (let n of D) e.push(t), t += A + (S.has(n.id) ? 40 : 0);
700
+ return e.push(t), e;
701
+ }, [D, S]), N = k[k.length - 1] ?? 0;
702
+ i(() => {
703
+ !u || w || D.length !== E.current && (E.current = D.length, y.current && (y.current.scrollTop = y.current.scrollHeight));
704
+ }, [
705
+ D.length,
706
+ u,
707
+ w
708
+ ]);
709
+ let F = r(() => {
710
+ if (!y.current) return;
711
+ let e = y.current;
712
+ T(!(e.scrollHeight - e.scrollTop - e.clientHeight < A * 2)), x(e.scrollTop);
713
+ }, []), I = r((e) => {
714
+ C((t) => {
715
+ let n = new Set(t);
716
+ return n.has(e) ? n.delete(e) : n.add(e), n;
717
+ });
718
+ }, []);
719
+ function L(e) {
720
+ let t = 0, n = D.length - 1;
721
+ for (; t < n;) {
722
+ let r = t + n >> 1;
723
+ (k[r + 1] ?? 0) <= e ? t = r + 1 : n = r;
724
+ }
725
+ return Math.max(0, t - j);
726
+ }
727
+ function R(e) {
728
+ let t = 0, n = D.length - 1;
729
+ for (; t < n;) {
730
+ let r = t + n + 1 >> 1;
731
+ (k[r] ?? 0) >= e + O ? n = r - 1 : t = r;
732
+ }
733
+ return Math.min(D.length - 1, t + j);
734
+ }
735
+ let z = D.length > 0 ? L(b) : 0, H = D.length > 0 ? R(b) : -1, U = {
736
+ position: "relative",
737
+ overflow: "auto",
738
+ height: typeof l == "number" ? `${l}px` : l,
739
+ background: v.bg,
740
+ border: `1px solid ${v.border}`,
741
+ borderRadius: 8,
742
+ boxSizing: "border-box"
743
+ }, W = {
744
+ position: "relative",
745
+ height: N,
746
+ minHeight: "100%"
747
+ };
748
+ if (D.length === 0) return n("div", { style: {
749
+ ...U,
750
+ display: "flex",
751
+ alignItems: "center",
752
+ justifyContent: "center"
753
+ } }, n("span", { style: {
754
+ color: v.textMuted,
755
+ fontSize: 13,
756
+ fontFamily: "monospace"
757
+ } }, "No log entries."));
758
+ let G = [];
759
+ for (let e = z; e <= H; e++) {
760
+ let t = D[e];
761
+ if (!t) continue;
762
+ let r = k[e] ?? 0, i = S.has(t.id);
763
+ G.push(n(B, {
764
+ key: t.id,
765
+ entry: t,
766
+ showLevel: d,
767
+ showTimestamp: f,
768
+ showSource: p,
769
+ searchQuery: h,
770
+ monospace: g,
771
+ isExpanded: i,
772
+ onToggle: () => I(t.id),
773
+ onEntryClick: _,
774
+ theme: v,
775
+ style: {
776
+ position: "absolute",
777
+ top: r,
778
+ left: 0,
779
+ right: 0
780
+ }
781
+ })), i && t.metadata && Object.keys(t.metadata).length > 0 && G.push(n(V, {
782
+ key: `${t.id}-meta`,
783
+ metadata: t.metadata,
784
+ theme: v,
785
+ style: {
786
+ position: "absolute",
787
+ top: r + A,
788
+ left: 0,
789
+ right: 0,
790
+ height: 40
791
+ }
792
+ }));
793
+ }
794
+ return n("div", {
795
+ ref: y,
796
+ style: U,
797
+ onScroll: F,
798
+ role: "log",
799
+ "aria-live": "polite",
800
+ "aria-label": "Log viewer"
801
+ }, n("div", { style: W }, ...G));
802
+ }
803
+ //#endregion
804
+ export { g as TkxLiveFeed, H as TkxLiveLog, E as TkxLiveMetrics, k as TkxRealTimeChart };