@photon-ai/pho-ui 2.15.0 → 2.17.0

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 (97) hide show
  1. package/dist/chunks/IconArrowsMinimize-BfPUGuCB.js +75 -0
  2. package/dist/chunks/IconArrowsMinimize-BfPUGuCB.js.map +1 -0
  3. package/dist/chunks/IconChevronUp-CrpWSgIl.js +11 -0
  4. package/dist/chunks/IconChevronUp-CrpWSgIl.js.map +1 -0
  5. package/dist/chunks/{bar-chart-BJfr3eyd.js → bar-chart-DIALC2_z.js} +2 -2
  6. package/dist/chunks/bar-chart-DIALC2_z.js.map +1 -0
  7. package/dist/chunks/basic-page-CogcwGx3.js +1749 -0
  8. package/dist/chunks/basic-page-CogcwGx3.js.map +1 -0
  9. package/dist/chunks/card-DhDwtSi9.js +56 -0
  10. package/dist/chunks/card-DhDwtSi9.js.map +1 -0
  11. package/dist/chunks/code-block-BuDIo8Q0.js +197 -0
  12. package/dist/chunks/code-block-BuDIo8Q0.js.map +1 -0
  13. package/dist/chunks/collapsible-if7ncPbI.js +28 -0
  14. package/dist/chunks/collapsible-if7ncPbI.js.map +1 -0
  15. package/dist/chunks/{command-Ck8IAgV7.js → command-CTYrSz9a.js} +2 -2
  16. package/dist/chunks/{command-Ck8IAgV7.js.map → command-CTYrSz9a.js.map} +1 -1
  17. package/dist/chunks/data-table-DcwCgXJU.js +293 -0
  18. package/dist/chunks/data-table-DcwCgXJU.js.map +1 -0
  19. package/dist/chunks/date-range-picker-DwFDUNRL.js +88 -0
  20. package/dist/chunks/date-range-picker-DwFDUNRL.js.map +1 -0
  21. package/dist/chunks/{dialog-BxKACOj5.js → dialog-BwfUFn6B.js} +2 -2
  22. package/dist/chunks/{dialog-BxKACOj5.js.map → dialog-BwfUFn6B.js.map} +1 -1
  23. package/dist/chunks/{filter-bar-Cjjq38xo.js → filter-bar-BsvdXwzc.js} +2 -2
  24. package/dist/chunks/{filter-bar-Cjjq38xo.js.map → filter-bar-BsvdXwzc.js.map} +1 -1
  25. package/dist/chunks/ghost-search-BvBFa9su.js +25 -0
  26. package/dist/chunks/ghost-search-BvBFa9su.js.map +1 -0
  27. package/dist/chunks/{line-chart-CUR3AxrR.js → line-chart-VuMYKzW3.js} +2 -2
  28. package/dist/chunks/{line-chart-CUR3AxrR.js.map → line-chart-VuMYKzW3.js.map} +1 -1
  29. package/dist/chunks/{log-list-0AXnjFrk.js → log-list-BERiO4UJ.js} +2 -2
  30. package/dist/chunks/{log-list-0AXnjFrk.js.map → log-list-BERiO4UJ.js.map} +1 -1
  31. package/dist/chunks/scroll-area-Zik8t1Mk.js +168 -0
  32. package/dist/chunks/scroll-area-Zik8t1Mk.js.map +1 -0
  33. package/dist/chunks/sidebar-DRPe5CAh.js +306 -0
  34. package/dist/chunks/sidebar-DRPe5CAh.js.map +1 -0
  35. package/dist/chunks/{toast-iSf6NuAS.js → toast-72Wwlzg9.js} +2 -2
  36. package/dist/chunks/{toast-iSf6NuAS.js.map → toast-72Wwlzg9.js.map} +1 -1
  37. package/dist/chunks/trace-Ba1RMBfk.js +1645 -0
  38. package/dist/chunks/trace-Ba1RMBfk.js.map +1 -0
  39. package/dist/chunks/use-measure-C-i54AC6.js +629 -0
  40. package/dist/chunks/use-measure-C-i54AC6.js.map +1 -0
  41. package/dist/components/bar-chart.js +1 -1
  42. package/dist/components/card.js +1 -1
  43. package/dist/components/code-block.js +1 -1
  44. package/dist/components/collapsible.js +2 -25
  45. package/dist/components/command.js +1 -1
  46. package/dist/components/data-table.js +9 -8
  47. package/dist/components/date-range-picker.js +10 -0
  48. package/dist/components/dialog.js +1 -1
  49. package/dist/components/filter-bar.js +1 -1
  50. package/dist/components/line-chart.js +1 -1
  51. package/dist/components/log-list.js +1 -1
  52. package/dist/components/scroll-area.js +1 -1
  53. package/dist/components/toast.js +1 -1
  54. package/dist/components/trace.js +41 -6
  55. package/dist/index.js +166 -121
  56. package/dist/primitives.js +2 -2
  57. package/dist/sections/basic-page.js +5 -5
  58. package/dist/sections/sidebar.js +9 -6
  59. package/dist/src/components/card/card.d.ts +5 -1
  60. package/dist/src/components/chart/scale.d.ts +6 -1
  61. package/dist/src/components/code-block/code-block.d.ts +24 -5
  62. package/dist/src/components/code-block/index.d.ts +1 -1
  63. package/dist/src/components/data-table/data-table.d.ts +54 -13
  64. package/dist/src/components/date-range-picker/date-range-picker.d.ts +31 -0
  65. package/dist/src/components/date-range-picker/index.d.ts +1 -0
  66. package/dist/src/components/scroll-area/scroll-area.d.ts +9 -1
  67. package/dist/src/components/trace/decorations.d.ts +32 -0
  68. package/dist/src/components/trace/index.d.ts +5 -2
  69. package/dist/src/components/trace/layout.d.ts +57 -29
  70. package/dist/src/components/trace/span-primitive.d.ts +168 -0
  71. package/dist/src/components/trace/span-tree.d.ts +148 -0
  72. package/dist/src/components/trace/trace.d.ts +98 -16
  73. package/dist/src/index.d.ts +1 -0
  74. package/dist/src/sections/basic-page/basic-page.d.ts +139 -29
  75. package/dist/src/sections/basic-page/index.d.ts +1 -1
  76. package/dist/src/sections/sidebar/index.d.ts +1 -1
  77. package/dist/src/sections/sidebar/sidebar.d.ts +72 -0
  78. package/dist/src/utils/ghost-search.d.ts +11 -0
  79. package/package.json +5 -1
  80. package/dist/chunks/bar-chart-BJfr3eyd.js.map +0 -1
  81. package/dist/chunks/basic-page-CVZT_zaH.js +0 -1611
  82. package/dist/chunks/basic-page-CVZT_zaH.js.map +0 -1
  83. package/dist/chunks/card-DSW3Uhag.js +0 -56
  84. package/dist/chunks/card-DSW3Uhag.js.map +0 -1
  85. package/dist/chunks/code-block-CdozzaHM.js +0 -139
  86. package/dist/chunks/code-block-CdozzaHM.js.map +0 -1
  87. package/dist/chunks/data-table-CHLJfGkS.js +0 -279
  88. package/dist/chunks/data-table-CHLJfGkS.js.map +0 -1
  89. package/dist/chunks/scroll-area-BO-9PMM7.js +0 -167
  90. package/dist/chunks/scroll-area-BO-9PMM7.js.map +0 -1
  91. package/dist/chunks/sidebar-DVzZsCts.js +0 -223
  92. package/dist/chunks/sidebar-DVzZsCts.js.map +0 -1
  93. package/dist/chunks/trace-CbH0IohX.js +0 -314
  94. package/dist/chunks/trace-CbH0IohX.js.map +0 -1
  95. package/dist/chunks/use-measure-CMVgLouO.js +0 -616
  96. package/dist/chunks/use-measure-CMVgLouO.js.map +0 -1
  97. package/dist/components/collapsible.js.map +0 -1
@@ -0,0 +1,1645 @@
1
+ "use client";
2
+ import { t as L } from "./cn-ChIgwEl3.js";
3
+ import { t as U } from "./createReactComponent-BqCmnqfX.js";
4
+ import { t as Ie } from "./IconChevronDown-CZilB71T.js";
5
+ import { t as Xe } from "./IconChevronRight-CzoJnYNI.js";
6
+ import { t as Te } from "./IconChevronUp-CrpWSgIl.js";
7
+ import { t as ve } from "./collapsible-if7ncPbI.js";
8
+ import { t as He } from "./ghost-search-BvBFa9su.js";
9
+ import { r as Je } from "./badge-DlLJPLeZ.js";
10
+ import { createContext as ue, useCallback as O, useContext as pe, useEffect as ae, useId as Ze, useMemo as D, useRef as he, useState as Q } from "react";
11
+ import { Fragment as Ye, jsx as l, jsxs as x } from "react/jsx-runtime";
12
+ import { useRender as q } from "@base-ui/react/use-render";
13
+ var Qe = [
14
+ ["path", {
15
+ d: "M5 12l14 0",
16
+ key: "svg-0"
17
+ }],
18
+ ["path", {
19
+ d: "M15 16l4 -4",
20
+ key: "svg-1"
21
+ }],
22
+ ["path", {
23
+ d: "M15 8l4 4",
24
+ key: "svg-2"
25
+ }]
26
+ ], qe = U("outline", "arrow-narrow-right", "ArrowNarrowRight", Qe), et = [["path", {
27
+ d: "M7 10h14l-4 -4",
28
+ key: "svg-0"
29
+ }], ["path", {
30
+ d: "M17 14h-14l4 4",
31
+ key: "svg-1"
32
+ }]], tt = U("outline", "arrows-exchange", "ArrowsExchange", et), nt = [["path", {
33
+ d: "M7 7l5 5l5 -5",
34
+ key: "svg-0"
35
+ }], ["path", {
36
+ d: "M7 13l5 5l5 -5",
37
+ key: "svg-1"
38
+ }]], at = U("outline", "chevrons-down", "ChevronsDown", nt), rt = [["path", {
39
+ d: "M7 11l5 -5l5 5",
40
+ key: "svg-0"
41
+ }], ["path", {
42
+ d: "M7 17l5 -5l5 5",
43
+ key: "svg-1"
44
+ }]], st = U("outline", "chevrons-up", "ChevronsUp", rt), ot = [
45
+ ["path", {
46
+ d: "M4 6a8 3 0 1 0 16 0a8 3 0 1 0 -16 0",
47
+ key: "svg-0"
48
+ }],
49
+ ["path", {
50
+ d: "M4 6v6a8 3 0 0 0 16 0v-6",
51
+ key: "svg-1"
52
+ }],
53
+ ["path", {
54
+ d: "M4 12v6a8 3 0 0 0 16 0v-6",
55
+ key: "svg-2"
56
+ }]
57
+ ], it = U("outline", "database", "Database", ot), lt = [
58
+ ["path", {
59
+ d: "M14 3v4a1 1 0 0 0 1 1h4",
60
+ key: "svg-0"
61
+ }],
62
+ ["path", {
63
+ d: "M12 21h-5a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v4.5",
64
+ key: "svg-1"
65
+ }],
66
+ ["path", {
67
+ d: "M14 17.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0",
68
+ key: "svg-2"
69
+ }],
70
+ ["path", {
71
+ d: "M18.5 19.5l2.5 2.5",
72
+ key: "svg-3"
73
+ }]
74
+ ], ct = U("outline", "file-search", "FileSearch", lt), dt = [
75
+ ["path", {
76
+ d: "M8 9h8",
77
+ key: "svg-0"
78
+ }],
79
+ ["path", {
80
+ d: "M8 13h6",
81
+ key: "svg-1"
82
+ }],
83
+ ["path", {
84
+ d: "M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1 -3 3h-5l-5 3v-3h-2a3 3 0 0 1 -3 -3v-8a3 3 0 0 1 3 -3h12",
85
+ key: "svg-2"
86
+ }]
87
+ ], ut = U("outline", "message", "Message", dt), pt = [
88
+ ["path", {
89
+ d: "M6 6a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2l0 -4",
90
+ key: "svg-0"
91
+ }],
92
+ ["path", {
93
+ d: "M12 2v2",
94
+ key: "svg-1"
95
+ }],
96
+ ["path", {
97
+ d: "M9 12v9",
98
+ key: "svg-2"
99
+ }],
100
+ ["path", {
101
+ d: "M15 12v9",
102
+ key: "svg-3"
103
+ }],
104
+ ["path", {
105
+ d: "M5 16l4 -2",
106
+ key: "svg-4"
107
+ }],
108
+ ["path", {
109
+ d: "M15 14l4 2",
110
+ key: "svg-5"
111
+ }],
112
+ ["path", {
113
+ d: "M9 18h6",
114
+ key: "svg-6"
115
+ }],
116
+ ["path", {
117
+ d: "M10 8v.01",
118
+ key: "svg-7"
119
+ }],
120
+ ["path", {
121
+ d: "M14 8v.01",
122
+ key: "svg-8"
123
+ }]
124
+ ], ht = U("outline", "robot", "Robot", pt), mt = [["path", {
125
+ d: "M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6",
126
+ key: "svg-0"
127
+ }]], ge = U("outline", "sparkles", "Sparkles", mt), ft = [["path", {
128
+ d: "M7 10h3v-3l-3.5 -3.5a6 6 0 0 1 8 8l6 6a2 2 0 0 1 -3 3l-6 -6a6 6 0 0 1 -8 -8l3.5 3.5",
129
+ key: "svg-0"
130
+ }]], vt = U("outline", "tool", "Tool", ft), gt = [
131
+ ["path", {
132
+ d: "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",
133
+ key: "svg-0"
134
+ }],
135
+ ["path", {
136
+ d: "M3.6 9h16.8",
137
+ key: "svg-1"
138
+ }],
139
+ ["path", {
140
+ d: "M3.6 15h16.8",
141
+ key: "svg-2"
142
+ }],
143
+ ["path", {
144
+ d: "M11.5 3a17 17 0 0 0 0 18",
145
+ key: "svg-3"
146
+ }],
147
+ ["path", {
148
+ d: "M12.5 3a17 17 0 0 1 0 18",
149
+ key: "svg-4"
150
+ }]
151
+ ], bt = U("outline", "world", "World", gt), be = [0, 1], ce = 1e-3, X = (e) => typeof e == "number" && Number.isFinite(e);
152
+ function xt(e) {
153
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
154
+ for (const r of e.values()) r.parentSpanId != null && e.has(r.parentSpanId) ? t.set(r.id, r.parentSpanId) : (t.set(r.id, null), r.parentSpanId != null && n.add(r.id));
155
+ const a = /* @__PURE__ */ new Set();
156
+ for (const r of e.keys()) {
157
+ if (a.has(r)) continue;
158
+ const o = [], i = /* @__PURE__ */ new Set();
159
+ let s = r;
160
+ for (; s !== null && !a.has(s); ) {
161
+ if (i.has(s)) {
162
+ t.set(s, null), n.add(s);
163
+ break;
164
+ }
165
+ o.push(s), i.add(s), s = t.get(s) ?? null;
166
+ }
167
+ for (const c of o) a.add(c);
168
+ }
169
+ return {
170
+ parents: t,
171
+ orphans: n
172
+ };
173
+ }
174
+ function _e(e) {
175
+ const t = new Map(e.map((p) => [p.id, p])), { parents: n, orphans: a } = xt(t), r = /* @__PURE__ */ new Map();
176
+ for (const p of t.values()) {
177
+ const S = n.get(p.id) ?? null, w = r.get(S) ?? [];
178
+ w.push(p), r.set(S, w);
179
+ }
180
+ let o = 1 / 0;
181
+ for (const p of t.values()) X(p.startedAt) && p.startedAt < o && (o = p.startedAt);
182
+ o === 1 / 0 && (o = 0);
183
+ const i = (p, S) => {
184
+ let w = !1, d = p.startedAt;
185
+ X(d) || (d = S ?? o, w = !0);
186
+ let m = p.endedAt;
187
+ m != null && (!X(m) || m < d) && (m = d, w = !0);
188
+ const A = X(p.latencyMs) && p.latencyMs >= 0 ? p.latencyMs : null;
189
+ return {
190
+ startedAt: d,
191
+ endedAt: m,
192
+ latencyMs: A,
193
+ repaired: w
194
+ };
195
+ }, s = [], c = /* @__PURE__ */ new Map();
196
+ let u = 0;
197
+ const g = (p, S, w) => {
198
+ const d = i(p, w), m = r.get(p.id) ?? [], A = {
199
+ ...p,
200
+ parentSpanId: n.get(p.id) ?? null,
201
+ startedAt: d.startedAt,
202
+ endedAt: d.endedAt,
203
+ latencyMs: d.latencyMs,
204
+ depth: S,
205
+ hasChildren: m.length > 0,
206
+ isCollapsed: !1,
207
+ descendants: 0,
208
+ descendantErrors: 0,
209
+ orphan: a.has(p.id),
210
+ repaired: d.repaired,
211
+ serverChildId: null
212
+ };
213
+ d.repaired && (u += 1), s.push(A), c.set(A.id, A);
214
+ const b = m.map((E) => ({
215
+ kid: E,
216
+ start: X(E.startedAt) ? E.startedAt : d.startedAt
217
+ }));
218
+ b.sort((E, N) => E.start - N.start);
219
+ let $ = 0, _ = 0;
220
+ for (const { kid: E } of b) {
221
+ const N = g(E, S + 1, d.startedAt);
222
+ $ += 1 + N.descendants, _ += (N.status === "failed" ? 1 : 0) + N.descendantErrors, A.kind === "client" && A.serverChildId == null && N.kind === "server" && (A.serverChildId = N.id);
223
+ }
224
+ return A.descendants = $, A.descendantErrors = _, A;
225
+ }, h = (r.get(null) ?? []).map((p) => ({
226
+ root: p,
227
+ start: X(p.startedAt) ? p.startedAt : o
228
+ }));
229
+ h.sort((p, S) => p.start - S.start);
230
+ for (const { root: p } of h) g(p, 0, null);
231
+ return {
232
+ spans: s,
233
+ byId: c,
234
+ orphans: a.size,
235
+ repaired: u
236
+ };
237
+ }
238
+ function Ee(e, t) {
239
+ const n = [];
240
+ let a = null;
241
+ for (const r of e.spans) {
242
+ if (a != null) {
243
+ if (r.depth > a) continue;
244
+ a = null;
245
+ }
246
+ t.has(r.id) ? (n.push({
247
+ ...r,
248
+ isCollapsed: !0
249
+ }), r.hasChildren && (a = r.depth)) : n.push(r);
250
+ }
251
+ return n;
252
+ }
253
+ function Kn(e, t = /* @__PURE__ */ new Set()) {
254
+ return Ee(_e(e), t);
255
+ }
256
+ function yt(e, t) {
257
+ const n = [];
258
+ let a = e.get(t)?.parentSpanId ?? null;
259
+ for (; a != null && !n.includes(a); )
260
+ n.push(a), a = e.get(a)?.parentSpanId ?? null;
261
+ return n;
262
+ }
263
+ function wt(e) {
264
+ return e.filter((t) => t.hasChildren).map((t) => t.id);
265
+ }
266
+ function Nt(e, t) {
267
+ return e.filter((n) => n.hasChildren).every((n) => t.has(n.id));
268
+ }
269
+ function kt(e, t) {
270
+ const n = new Set(t);
271
+ let a;
272
+ for (const r of e) a && r.depth <= a.depth ? (n.add(a.id), a = r.hasChildren && !n.has(r.id) ? r : void 0) : r.hasChildren && !n.has(r.id) && (a = r);
273
+ return a && n.add(a.id), Array.from(n);
274
+ }
275
+ function Mt(e, t) {
276
+ const n = new Set(t);
277
+ let a = -1, r = !0;
278
+ for (const o of e)
279
+ o.depth <= a && (r = !0), r && n.has(o.id) && (n.delete(o.id), r = !1, a = o.depth);
280
+ return Array.from(n);
281
+ }
282
+ function At(e, t) {
283
+ let n = 1 / 0, a = -1 / 0;
284
+ for (const r of e) {
285
+ if (!X(r.startedAt)) continue;
286
+ r.startedAt < n && (n = r.startedAt);
287
+ const o = X(r.endedAt) ? r.endedAt : t ?? r.startedAt;
288
+ o > a && (a = o);
289
+ }
290
+ return n === 1 / 0 ? {
291
+ min: 0,
292
+ max: 0
293
+ } : {
294
+ min: n,
295
+ max: Math.max(a, n)
296
+ };
297
+ }
298
+ var ie = (e) => Math.min(1, Math.max(0, e));
299
+ function oe(e) {
300
+ let [t, n] = e;
301
+ if (X(t) || (t = 0), X(n) || (n = 1), n < t && ([t, n] = [n, t]), t = ie(t), n = ie(n), n - t < 1e-3) {
302
+ const a = (t + n) / 2;
303
+ t = ie(a - ce / 2), n = ie(t + ce), t = n - ce;
304
+ }
305
+ return [t, n];
306
+ }
307
+ function St(e, t) {
308
+ const n = e.max - e.min;
309
+ return {
310
+ min: e.min + t[0] * n,
311
+ max: e.min + t[1] * n
312
+ };
313
+ }
314
+ function Ct(e, t, n = 0.5) {
315
+ const [a, r] = e, o = r - a, i = Math.min(1, Math.max(ce, o * t));
316
+ let s = a + n * o - n * i;
317
+ return s = Math.min(Math.max(s, 0), 1 - i), oe([s, s + i]);
318
+ }
319
+ function It(e, t) {
320
+ const [n, a] = e, r = a - n;
321
+ let o = n + t * r;
322
+ return o = Math.min(Math.max(o, 0), 1 - r), oe([o, o + r]);
323
+ }
324
+ function xe(e, t) {
325
+ return e[0] + t * (e[1] - e[0]);
326
+ }
327
+ function Tt(e) {
328
+ return e[0] <= 0 && e[1] >= 1;
329
+ }
330
+ function _t({ startedAt: e, endedAt: t, timeRange: n, now: a }) {
331
+ const r = Math.max(1, n.max - n.min), o = t ?? a ?? n.max, i = (e - n.min) / r * 100, s = (o - n.min) / r * 100, c = Math.min(100, Math.max(0, i)), u = Math.min(100, Math.max(c, s));
332
+ return {
333
+ leftPercent: c,
334
+ endPercent: u,
335
+ widthPercent: u - c,
336
+ durationMs: Math.max(0, o - e),
337
+ effectiveEnd: o,
338
+ clippedStart: i < 0 && s > 0,
339
+ clippedEnd: s > 100 && i < 100
340
+ };
341
+ }
342
+ function Et(e) {
343
+ if (e == null) return "";
344
+ if (typeof e == "object") try {
345
+ return JSON.stringify(e);
346
+ } catch {
347
+ return String(e);
348
+ }
349
+ return String(e);
350
+ }
351
+ function $t(e, t) {
352
+ if (e == null || e.trim() === "") return null;
353
+ const n = [], a = [];
354
+ for (const s of e.match(/[^\s"]+|"([^"]*)"/g) ?? []) {
355
+ const c = s.replace(/^"(.*)"$/, "$1").toLowerCase();
356
+ c && (c.startsWith("-") && c.length > 1 ? a.push(c.slice(1)) : n.push(c));
357
+ }
358
+ if (n.length === 0) return /* @__PURE__ */ new Set();
359
+ const r = (s) => {
360
+ const c = s.toLowerCase();
361
+ return n.some((u) => c.includes(u));
362
+ }, o = (s) => {
363
+ const c = s.toLowerCase();
364
+ return a.some((u) => c.includes(u));
365
+ }, i = /* @__PURE__ */ new Set();
366
+ for (const s of t) {
367
+ if (r(s.name) || s.service != null && r(s.service) || s.type !== "" && r(s.type) || s.kind != null && r(s.kind) || n.some((u) => u === s.id.toLowerCase())) {
368
+ i.add(s.id);
369
+ continue;
370
+ }
371
+ const c = s.attributes;
372
+ if (c != null)
373
+ for (const u of Object.keys(c)) {
374
+ if (o(u)) continue;
375
+ const g = Et(c[u]);
376
+ if (g !== "" && (r(u) || r(g) || r(`${u}=${g}`))) {
377
+ i.add(s.id);
378
+ break;
379
+ }
380
+ }
381
+ }
382
+ return i;
383
+ }
384
+ var $e = ue(null), Pe = ue(null), Re = ue(null);
385
+ function H() {
386
+ const e = pe($e);
387
+ if (e == null) throw new Error("SpanPrimitive parts render inside SpanPrimitive.Provider.");
388
+ return e;
389
+ }
390
+ function ee() {
391
+ const e = pe(Pe);
392
+ if (e == null) throw new Error("SpanPrimitive parts render inside SpanPrimitive.Children.");
393
+ return e;
394
+ }
395
+ var ye = [];
396
+ function Pt({ spans: e, defaultCollapsed: t, collapsed: n, onCollapsedChange: a, now: r, query: o = "", keepFoldsOnMatch: i = !1, defaultView: s, view: c, onViewChange: u, children: g }) {
397
+ const h = D(() => _e(e), [e]), [p, S] = Q(() => t ?? ye), w = n ?? p, d = D(() => new Set(w), [w]), m = O((I) => {
398
+ const T = Array.from(new Set(I));
399
+ n == null && S(T), a?.(T);
400
+ }, [n, a]), A = O((I) => {
401
+ const T = new Set(d);
402
+ T.has(I) ? T.delete(I) : T.add(I), m(Array.from(T));
403
+ }, [d, m]), { spans: b, byId: $ } = h, _ = O(() => m(ye), [m]), E = O(() => m(wt(b)), [b, m]), N = O(() => m(Mt(b, d)), [
404
+ b,
405
+ d,
406
+ m
407
+ ]), v = O(() => m(kt(b, d)), [
408
+ b,
409
+ d,
410
+ m
411
+ ]), y = !Nt(b, d), P = b.some((I) => I.hasChildren && d.has(I.id)), M = D(() => $t(o, b), [o, b]);
412
+ ae(() => {
413
+ if (i || M == null || M.size === 0) return;
414
+ const I = /* @__PURE__ */ new Set();
415
+ for (const T of M) for (const ne of yt($, T)) d.has(ne) && I.add(ne);
416
+ I.size !== 0 && m(w.filter((T) => !I.has(T)));
417
+ }, [
418
+ M,
419
+ i,
420
+ $,
421
+ d,
422
+ w,
423
+ m
424
+ ]);
425
+ const J = D(() => Ee(h, d), [h, d]), z = D(() => At(b, r), [b, r]), [W, F] = Q(() => oe(s ?? be)), C = D(() => oe(c ?? W), [c, W]), k = O((I) => {
426
+ const T = oe(I);
427
+ c == null && F(T), u?.(T);
428
+ }, [c, u]), B = O((I, T) => k(Ct(C, I, T)), [C, k]), te = O((I) => k(It(C, I)), [C, k]), R = O(() => k(be), [k]), V = D(() => St(z, C), [z, C]), G = D(() => ({
429
+ spans: J,
430
+ all: b,
431
+ byId: $,
432
+ orphans: h.orphans,
433
+ repaired: h.repaired,
434
+ range: z,
435
+ view: C,
436
+ viewRange: V,
437
+ zoomed: !Tt(C),
438
+ now: r,
439
+ collapsed: d,
440
+ toggle: A,
441
+ setCollapsed: m,
442
+ expandAll: _,
443
+ collapseAll: E,
444
+ expandOne: N,
445
+ collapseOne: v,
446
+ canExpand: P,
447
+ canCollapse: y,
448
+ query: o,
449
+ matches: M,
450
+ setView: k,
451
+ zoom: B,
452
+ pan: te,
453
+ resetView: R
454
+ }), [
455
+ J,
456
+ b,
457
+ $,
458
+ h.orphans,
459
+ h.repaired,
460
+ z,
461
+ C,
462
+ V,
463
+ r,
464
+ d,
465
+ A,
466
+ m,
467
+ _,
468
+ E,
469
+ N,
470
+ v,
471
+ P,
472
+ y,
473
+ o,
474
+ M,
475
+ k,
476
+ B,
477
+ te,
478
+ R
479
+ ]);
480
+ return /* @__PURE__ */ l($e.Provider, {
481
+ value: G,
482
+ children: g
483
+ });
484
+ }
485
+ function Rt({ children: e }) {
486
+ const { spans: t } = H();
487
+ return t.map((n) => /* @__PURE__ */ l(Pe.Provider, {
488
+ value: n,
489
+ children: e(n)
490
+ }, n.id));
491
+ }
492
+ function Dt({ render: e, ref: t, ...n }) {
493
+ const a = ee(), { matches: r } = H();
494
+ return q({
495
+ render: e,
496
+ ref: t,
497
+ defaultTagName: "div",
498
+ props: {
499
+ ...n,
500
+ "data-span-id": a.id,
501
+ "data-span-status": a.status,
502
+ "data-span-type": a.type,
503
+ "data-span-depth": a.depth,
504
+ "data-span-kind": a.kind,
505
+ "data-collapsed": a.isCollapsed ? "" : void 0,
506
+ "data-match": r?.has(a.id) ? "" : void 0,
507
+ "data-orphan": a.orphan ? "" : void 0
508
+ }
509
+ });
510
+ }
511
+ function Lt({ render: e, ref: t, baseIndent: n = 8, indentPerLevel: a = 12, style: r, ...o }) {
512
+ const i = ee();
513
+ return q({
514
+ render: e,
515
+ ref: t,
516
+ defaultTagName: "div",
517
+ props: {
518
+ ...o,
519
+ style: {
520
+ ...r,
521
+ paddingLeft: n + i.depth * a
522
+ },
523
+ "data-span-depth": i.depth
524
+ }
525
+ });
526
+ }
527
+ function Ot({ render: e, ref: t, onClick: n, ...a }) {
528
+ const r = ee(), { toggle: o } = H();
529
+ return q({
530
+ render: e,
531
+ ref: t,
532
+ enabled: r.hasChildren,
533
+ defaultTagName: "button",
534
+ props: {
535
+ type: "button",
536
+ ...a,
537
+ "data-collapsed": r.isCollapsed ? "" : void 0,
538
+ onClick: (i) => {
539
+ i.stopPropagation(), o(r.id), n?.(i);
540
+ }
541
+ }
542
+ });
543
+ }
544
+ function zt({ render: e, ref: t, ...n }) {
545
+ const a = ee();
546
+ return q({
547
+ render: e,
548
+ ref: t,
549
+ defaultTagName: "span",
550
+ props: {
551
+ ...n,
552
+ "data-span-status": a.status,
553
+ "data-descendant-errors": a.isCollapsed && a.descendantErrors > 0 ? a.descendantErrors : void 0
554
+ }
555
+ });
556
+ }
557
+ function Ft({ render: e, ref: t, children: n, ...a }) {
558
+ const r = ee();
559
+ return q({
560
+ render: e,
561
+ ref: t,
562
+ defaultTagName: "span",
563
+ props: {
564
+ ...a,
565
+ "data-span-type": r.type,
566
+ children: n ?? r.type
567
+ }
568
+ });
569
+ }
570
+ function Kt({ render: e, ref: t, children: n, ...a }) {
571
+ const r = ee();
572
+ return q({
573
+ render: e,
574
+ ref: t,
575
+ defaultTagName: "span",
576
+ props: {
577
+ ...a,
578
+ children: n ?? r.name
579
+ }
580
+ });
581
+ }
582
+ function Wt({ render: e, ref: t, timeRange: n, paddingEnd: a = 0, style: r, ...o }) {
583
+ const i = H(), s = D(() => {
584
+ const h = n ?? i.viewRange, p = Math.max(1, h.max - h.min);
585
+ return {
586
+ min: h.min,
587
+ max: h.max + p * Math.max(0, a)
588
+ };
589
+ }, [
590
+ n,
591
+ i.viewRange,
592
+ a
593
+ ]), c = Math.max(1, s.max - s.min), u = {
594
+ ...r,
595
+ "--span-timeline-min-ms": s.min,
596
+ "--span-timeline-max-ms": s.max,
597
+ "--span-timeline-range-ms": c
598
+ }, g = q({
599
+ render: e,
600
+ ref: t,
601
+ defaultTagName: "div",
602
+ props: {
603
+ ...o,
604
+ style: u,
605
+ "data-span-timeline": ""
606
+ }
607
+ });
608
+ return /* @__PURE__ */ l(Re.Provider, {
609
+ value: s,
610
+ children: g
611
+ });
612
+ }
613
+ function Vt({ render: e, ref: t, now: n, timeRange: a, style: r, ...o }) {
614
+ const i = ee(), s = H(), c = pe(Re), u = _t({
615
+ startedAt: i.startedAt,
616
+ endedAt: i.endedAt,
617
+ timeRange: a ?? c ?? s.viewRange,
618
+ now: n ?? s.now
619
+ }), g = {
620
+ ...r,
621
+ position: "absolute",
622
+ insetInlineStart: "var(--span-timeline-left)",
623
+ inlineSize: "max(var(--span-timeline-width), var(--span-timeline-min-width, 0px))",
624
+ "--span-timeline-left": `${u.leftPercent}%`,
625
+ "--span-timeline-end": `${u.endPercent}%`,
626
+ "--span-timeline-width": `${u.widthPercent}%`,
627
+ "--span-timeline-duration-ms": u.durationMs
628
+ };
629
+ return q({
630
+ render: e,
631
+ ref: t,
632
+ defaultTagName: "div",
633
+ props: {
634
+ ...o,
635
+ style: g,
636
+ "data-span-status": i.status,
637
+ "data-span-type": i.type,
638
+ "data-span-running": i.endedAt === null ? "" : void 0,
639
+ "data-clipped-start": u.clippedStart ? "" : void 0,
640
+ "data-clipped-end": u.clippedEnd ? "" : void 0
641
+ }
642
+ });
643
+ }
644
+ var Z = {
645
+ Provider: Pt,
646
+ Children: Rt,
647
+ Root: Dt,
648
+ Indent: Lt,
649
+ CollapseToggle: Ot,
650
+ StatusIndicator: zt,
651
+ TypeBadge: Ft,
652
+ Name: Kt,
653
+ Timeline: Wt,
654
+ TimelineBar: Vt
655
+ }, jt = (e) => {
656
+ const t = Number(e.trim());
657
+ return t >= 500 && t < 600;
658
+ }, De = [
659
+ {
660
+ namespace: "db",
661
+ icon: it,
662
+ pills: [{
663
+ label: "db.system",
664
+ keys: ["db.system.name", "db.system"]
665
+ }]
666
+ },
667
+ {
668
+ namespace: "http",
669
+ icon: bt,
670
+ pills: [{
671
+ label: "http.status_code",
672
+ keys: ["http.response.status_code", "http.status_code"],
673
+ error: jt
674
+ }, {
675
+ label: "http.method",
676
+ keys: ["http.request.method", "http.method"]
677
+ }]
678
+ },
679
+ {
680
+ namespace: "messaging",
681
+ icon: ut
682
+ },
683
+ {
684
+ namespace: "rpc",
685
+ icon: tt,
686
+ pills: [{
687
+ label: "rpc.system",
688
+ keys: ["rpc.system.name", "rpc.system"]
689
+ }]
690
+ },
691
+ {
692
+ namespace: "gen_ai",
693
+ pills: [{
694
+ label: "gen_ai.request.model",
695
+ keys: ["gen_ai.request.model"]
696
+ }]
697
+ }
698
+ ], Bt = {
699
+ agent: {
700
+ icon: ht,
701
+ label: "Agent"
702
+ },
703
+ llm: {
704
+ icon: ge,
705
+ label: "LLM call"
706
+ },
707
+ tool: {
708
+ icon: vt,
709
+ label: "Tool call"
710
+ },
711
+ retrieval: {
712
+ icon: ct,
713
+ label: "Retrieval"
714
+ },
715
+ generic: {
716
+ icon: ge,
717
+ label: "GenAI span"
718
+ }
719
+ }, Ut = {
720
+ chat: "llm",
721
+ text_completion: "llm",
722
+ generate_content: "llm",
723
+ execute_tool: "tool",
724
+ invoke_agent: "agent",
725
+ create_agent: "agent",
726
+ embeddings: "retrieval",
727
+ retrieve: "retrieval"
728
+ };
729
+ function Gt(e) {
730
+ if (e == null) return "";
731
+ if (e instanceof Uint8Array) return JSON.stringify(Array.from(e));
732
+ if (typeof e == "object") try {
733
+ return JSON.stringify(e);
734
+ } catch {
735
+ return "[unserializable]";
736
+ }
737
+ return String(e).trim();
738
+ }
739
+ function me(e, t) {
740
+ if (e == null) return null;
741
+ for (const n of t) {
742
+ if (!(n in e)) continue;
743
+ const a = Gt(e[n]);
744
+ if (a !== "") return a;
745
+ }
746
+ return null;
747
+ }
748
+ function Xt(e) {
749
+ if (e == null) return null;
750
+ const t = me(e, ["gen_ai.operation.name"]);
751
+ return t != null ? Ut[t.toLowerCase()] ?? "generic" : Object.keys(e).some((n) => n.startsWith("gen_ai.")) ? "generic" : null;
752
+ }
753
+ function Ht(e) {
754
+ const t = Xt(e);
755
+ if (t != null) return Bt[t];
756
+ if (e == null) return null;
757
+ const n = /* @__PURE__ */ new Set();
758
+ for (const a of Object.keys(e)) {
759
+ const r = a.indexOf(".");
760
+ r > 0 && n.add(a.slice(0, r));
761
+ }
762
+ for (const a of De) if (a.icon && n.has(a.namespace)) return { icon: a.icon };
763
+ return null;
764
+ }
765
+ function Jt(e) {
766
+ const t = [];
767
+ if (e == null) return t;
768
+ for (const n of De) for (const a of n.pills ?? []) {
769
+ const r = me(e, a.keys);
770
+ if (r == null) continue;
771
+ const o = {
772
+ label: a.label,
773
+ value: r
774
+ };
775
+ a.error?.(r) && (o.error = !0), t.push(o);
776
+ }
777
+ return t;
778
+ }
779
+ function Zt(e) {
780
+ return me(e, ["peer.service", "server.address"]);
781
+ }
782
+ function Yt(e) {
783
+ return e.map((t) => {
784
+ const n = t.endedAt ?? null, a = {
785
+ id: t.id,
786
+ parentSpanId: t.parentSpanId ?? null,
787
+ name: t.name,
788
+ type: t.type ?? "",
789
+ status: t.status ?? (n == null ? "running" : "completed"),
790
+ startedAt: t.startedAt,
791
+ endedAt: n,
792
+ latencyMs: t.latencyMs ?? (n == null ? null : Math.max(0, n - t.startedAt))
793
+ };
794
+ return t.kind != null && (a.kind = t.kind), t.service != null && (a.service = t.service), t.attributes != null && (a.attributes = t.attributes), a;
795
+ });
796
+ }
797
+ function Qt(e, t) {
798
+ return e.latencyMs != null ? Math.max(0, e.latencyMs) : e.endedAt != null ? Math.max(0, e.endedAt - e.startedAt) : t != null ? Math.max(0, t - e.startedAt) : null;
799
+ }
800
+ var we = (e) => Math.min(1, Math.max(0, e));
801
+ function Ne(e, t, n) {
802
+ const a = Math.max(1, t.max - t.min), r = e.endedAt ?? n ?? t.max, o = we((e.startedAt - t.min) / a);
803
+ return {
804
+ left: o,
805
+ width: we(Math.max(o, (r - t.min) / a)) - o
806
+ };
807
+ }
808
+ function qt(e, t = 6) {
809
+ if (e <= 0) return 1;
810
+ const n = e / t, a = 10 ** Math.floor(Math.log10(n));
811
+ for (const r of [
812
+ 1,
813
+ 2,
814
+ 5,
815
+ 10
816
+ ]) if (r * a >= n) return r * a;
817
+ return 10 * a;
818
+ }
819
+ function en(e, t) {
820
+ const n = t - e;
821
+ if (!(n > 0)) return [{
822
+ at: 0,
823
+ ms: e
824
+ }];
825
+ const a = qt(n), r = [], o = Math.ceil(e / a - 1e-9) * a;
826
+ for (let i = o; i <= t + 1e-9; i += a) {
827
+ const s = Number(i.toFixed(6));
828
+ r.push({
829
+ at: (s - e) / n,
830
+ ms: s
831
+ });
832
+ }
833
+ return r;
834
+ }
835
+ function re(e) {
836
+ if (!Number.isFinite(e)) return "";
837
+ const t = Math.abs(e);
838
+ return t < 10 ? `${e.toFixed(2)} ms` : t < 100 ? `${e.toFixed(1)} ms` : t < 1e3 ? `${Math.round(e)} ms` : t < 6e4 ? `${(e / 1e3).toFixed(2)} s` : `${(e / 6e4).toFixed(1)} min`;
839
+ }
840
+ function Le(e) {
841
+ return e === 0 ? "0" : e >= 1e3 ? `${Number((e / 1e3).toFixed(2))} s` : `${Number(e.toFixed(2))} ms`;
842
+ }
843
+ var tn = 7, le = 4, nn = 4;
844
+ function an(e, t) {
845
+ if (e.length === 0 || t <= 0) return [];
846
+ const n = e[e.length - 1], a = [];
847
+ for (const r of e) {
848
+ const o = Le(r.ms), i = Math.max(o.length * tn, 8), s = r === n, c = r.at * t, u = s ? c - le - i : c + le, g = s ? c - le : c + le + i, h = a[a.length - 1];
849
+ if (h && u < h.right + nn) {
850
+ if (!s) continue;
851
+ a.pop();
852
+ }
853
+ a.push({
854
+ ms: r.ms,
855
+ right: g
856
+ });
857
+ }
858
+ return a.map((r) => r.ms);
859
+ }
860
+ function Y(e) {
861
+ return `${Number((e * 100).toFixed(4))}%`;
862
+ }
863
+ var Oe = "rounded-base border border-pho-secondary bg-pho-primary overflow-hidden", ze = "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)]", rn = "absolute inset-y-0 left-3 right-3", Fe = 12, Ke = 16, sn = 26;
864
+ function on(e) {
865
+ return `${Fe + e * Ke + sn}px`;
866
+ }
867
+ var ln = 250, ke = 0.8, Me = 0.5, cn = 0.1, dn = 0.3, un = 5e-3, pn = {
868
+ completed: "bg-pho-inverse/25",
869
+ failed: "bg-pho-error-ink",
870
+ running: "bg-pho-inverse/15 motion-safe:animate-pulse",
871
+ skipped: "border-pho-secondary border border-dashed bg-transparent"
872
+ }, Ae = {
873
+ completed: "bg-pho-inverse",
874
+ failed: "bg-pho-error-ink",
875
+ running: "bg-pho-inverse/40",
876
+ skipped: "border-pho-secondary border bg-transparent"
877
+ }, hn = "border-pho-error-ink border bg-transparent", mn = {
878
+ completed: null,
879
+ failed: "Failed.",
880
+ running: "Running.",
881
+ skipped: "Skipped."
882
+ }, se = "text-pho-secondary outline-pho-brand hover:bg-pho-ghost-hover hover:text-pho-secondary-hover flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm transition-colors duration-100 ease-linear focus-visible:outline-2 disabled:pointer-events-none disabled:opacity-40", Se = (e) => ({ backgroundImage: `linear-gradient(to ${e === "left" ? "right" : "left"}, color-mix(in srgb, var(--background-color-pho-inverse) 18%, transparent), transparent)` }), de = (e, t, n = `${t}s`) => `${e} ${e === 1 ? t : n}`;
883
+ function We({ className: e, clippedStart: t, clippedEnd: n, children: a }) {
884
+ return /* @__PURE__ */ x("div", {
885
+ className: L("border-pho-secondary relative border-l", e),
886
+ children: [
887
+ /* @__PURE__ */ l("div", {
888
+ "data-trace-track": "",
889
+ className: rn,
890
+ children: a
891
+ }),
892
+ t ? /* @__PURE__ */ l("span", {
893
+ "aria-hidden": !0,
894
+ "data-trace-clipped": "start",
895
+ className: "pointer-events-none absolute inset-y-0 left-0 w-2",
896
+ style: Se("left")
897
+ }) : null,
898
+ n ? /* @__PURE__ */ l("span", {
899
+ "aria-hidden": !0,
900
+ "data-trace-clipped": "end",
901
+ className: "pointer-events-none absolute inset-y-0 right-0 w-2",
902
+ style: Se("right")
903
+ }) : null
904
+ ]
905
+ });
906
+ }
907
+ function fn(e, t) {
908
+ return t > 0.5 ? "inside" : e + t > 0.8 ? "before" : "after";
909
+ }
910
+ function vn(e) {
911
+ if (!(e instanceof HTMLElement)) return !1;
912
+ const t = e.tagName;
913
+ return t === "INPUT" || t === "TEXTAREA" || t === "SELECT" || e.isContentEditable;
914
+ }
915
+ var Ve = ue(null);
916
+ function je() {
917
+ const e = pe(Ve);
918
+ if (e == null) throw new Error("Trace rows render inside Trace.Waterfall only.");
919
+ return e;
920
+ }
921
+ function gn() {
922
+ const e = je(), t = ee(), { viewRange: n, now: a, byId: r, matches: o } = H(), { id: i, name: s, type: c, status: u, depth: g, isCollapsed: h, hasChildren: p } = t, S = e.spans.get(i), w = e.selectedId != null && e.selectedId === i, d = w && S != null ? e.renderSpanDetail?.(S) ?? null : null, m = e.renderSpanDetail != null ? `${e.idBase}-span-${i}` : void 0, A = e.onSelect ? () => e.onSelect?.(w ? null : i) : void 0, { left: b, width: $ } = Ne(t, n, a), _ = t.endedAt ?? a ?? n.max, E = t.startedAt < n.min && _ > n.min, N = _ > n.max && t.startedAt < n.max, v = fn(b, $), y = b > 1 - (b + $) ? "before" : "after", P = Qt(t, a), M = P == null ? null : re(P), J = [
923
+ t.service,
924
+ s,
925
+ M
926
+ ].filter(Boolean).join(" · "), z = [t.service, c].filter(Boolean).join(", "), W = h ? t.descendants : 0, F = h ? t.descendantErrors : 0, C = mn[u], k = u === "failed", B = Ht(t.attributes), te = Jt(t.attributes), R = h && t.kind === "client" && t.serverChildId != null ? r.get(t.serverChildId) : void 0, V = R != null ? R.service ?? R.name : !p && (t.kind === "client" || t.kind === "producer") ? Zt(t.attributes) : null, G = R ? Ne(R, n, a) : null, I = o?.has(i) ?? !1, T = e.activeMatchId === i, ne = (K) => K === "after" ? { left: `calc(${Y(b + $)} + 0.375rem)` } : { right: `calc(${Y(1 - b)} + 0.375rem)` };
927
+ return /* @__PURE__ */ x("li", {
928
+ className: "m-0",
929
+ style: { "--trace-indent": on(g) },
930
+ children: [/* @__PURE__ */ x(Z.Root, {
931
+ "data-trace-row": "",
932
+ "data-selected": w || void 0,
933
+ "data-active-match": T || void 0,
934
+ className: L(ze, "group/row relative min-h-9 items-center transition-colors", "has-[[data-trace-select]:focus-visible]:outline-pho-brand has-[[data-trace-select]:focus-visible]:outline-2 has-[[data-trace-select]:focus-visible]:-outline-offset-2", A != null && "hover:bg-pho-primary-hover", I && "bg-pho-brand-secondary", T && "ring-pho-brand ring-1 ring-inset", w && "bg-pho-primary-hover"),
935
+ children: [/* @__PURE__ */ x(Z.Indent, {
936
+ baseIndent: Fe,
937
+ indentPerLevel: Ke,
938
+ className: "flex min-w-0 items-center gap-1.5 py-1.5 pr-3",
939
+ children: [
940
+ p ? /* @__PURE__ */ l(Z.CollapseToggle, {
941
+ "aria-expanded": !h,
942
+ "aria-label": `${h ? "Expand" : "Collapse"} ${s}`,
943
+ className: "text-pho-secondary outline-pho-brand hover:bg-pho-ghost-hover hover:text-pho-secondary-hover relative z-10 flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm transition-[color,background-color,transform] duration-100 ease-linear focus-visible:outline-2",
944
+ children: /* @__PURE__ */ l(Xe, {
945
+ "aria-hidden": !0,
946
+ className: L("size-4 transition-transform duration-150 ease-out", !h && "rotate-90")
947
+ })
948
+ }) : /* @__PURE__ */ l("span", {
949
+ "aria-hidden": !0,
950
+ className: "size-5 shrink-0"
951
+ }),
952
+ /* @__PURE__ */ l(Z.StatusIndicator, {
953
+ "aria-hidden": !0,
954
+ className: L("size-1.5 shrink-0 rounded-full", k ? Ae.failed : F > 0 ? hn : Ae[u])
955
+ }),
956
+ B ? /* @__PURE__ */ l(B.icon, {
957
+ "data-trace-icon": "",
958
+ role: B.label ? "img" : void 0,
959
+ "aria-label": B.label,
960
+ "aria-hidden": B.label ? void 0 : !0,
961
+ className: "text-pho-description size-3.5 shrink-0"
962
+ }) : null,
963
+ /* @__PURE__ */ x(bn, {
964
+ selected: w,
965
+ expanded: e.renderSpanDetail != null ? d != null : void 0,
966
+ controls: d != null ? m : void 0,
967
+ onSelect: A,
968
+ children: [
969
+ /* @__PURE__ */ l(Z.Name, { className: "text-pho-primary truncate text-base" }),
970
+ V ? /* @__PURE__ */ x("span", {
971
+ "data-trace-callee": "",
972
+ className: "text-pho-description flex shrink-0 items-center gap-0.5 text-xs",
973
+ children: [
974
+ /* @__PURE__ */ l(qe, {
975
+ "aria-hidden": !0,
976
+ className: "size-3"
977
+ }),
978
+ /* @__PURE__ */ l("span", {
979
+ className: "sr-only",
980
+ children: "calls "
981
+ }),
982
+ V
983
+ ]
984
+ }) : null,
985
+ z ? /* @__PURE__ */ l("span", {
986
+ className: "text-pho-description shrink-[3] truncate text-xs",
987
+ children: z
988
+ }) : null,
989
+ te.map((K) => /* @__PURE__ */ l(Je, {
990
+ size: "xs",
991
+ contrast: "low",
992
+ color: K.error ? "error" : "gray",
993
+ title: `${K.label}: ${K.value}`,
994
+ "aria-label": `${K.label}: ${K.value}`,
995
+ "data-trace-pill": K.label,
996
+ "data-error": K.error || void 0,
997
+ className: "max-w-32 shrink-0 truncate",
998
+ children: K.value
999
+ }, K.label)),
1000
+ W > 0 ? /* @__PURE__ */ x("span", {
1001
+ className: "text-pho-description shrink-0 text-xs tabular-nums",
1002
+ children: [
1003
+ "(",
1004
+ W,
1005
+ F > 0 ? `, ${de(F, "error")}` : "",
1006
+ ")"
1007
+ ]
1008
+ }) : null,
1009
+ C ? /* @__PURE__ */ l("span", {
1010
+ className: "sr-only",
1011
+ children: C
1012
+ }) : null,
1013
+ F > 0 ? /* @__PURE__ */ x("span", {
1014
+ className: "sr-only",
1015
+ children: [de(F, "error"), " hidden."]
1016
+ }) : null
1017
+ ]
1018
+ })
1019
+ ]
1020
+ }), /* @__PURE__ */ x(We, {
1021
+ className: "h-9",
1022
+ clippedStart: E,
1023
+ clippedEnd: N,
1024
+ children: [
1025
+ /* @__PURE__ */ l(Z.TimelineBar, {
1026
+ "aria-hidden": !0,
1027
+ "data-trace-bar": "",
1028
+ className: L("top-1/2 h-4 -translate-y-1/2 rounded-sm", pn[u]),
1029
+ style: { "--span-timeline-min-width": "2px" },
1030
+ children: v === "inside" && M ? /* @__PURE__ */ l("span", {
1031
+ "data-trace-label": "short",
1032
+ className: L("absolute inset-y-0 right-1.5 flex items-center text-xs whitespace-nowrap tabular-nums group-hover/row:hidden", k ? "text-pho-on-brand" : "text-pho-primary"),
1033
+ children: M
1034
+ }) : null
1035
+ }),
1036
+ R && G ? /* @__PURE__ */ l("span", {
1037
+ "aria-hidden": !0,
1038
+ "data-trace-rpc": "",
1039
+ className: "bg-pho-inverse/45 absolute top-1/2 h-2 -translate-y-1/2 rounded-sm",
1040
+ style: {
1041
+ left: Y(G.left),
1042
+ width: Y(G.width),
1043
+ minWidth: "2px"
1044
+ }
1045
+ }) : null,
1046
+ v !== "inside" && M ? /* @__PURE__ */ l("span", {
1047
+ "aria-hidden": !0,
1048
+ "data-trace-label": "short",
1049
+ className: "text-pho-description absolute top-1/2 -translate-y-1/2 text-xs whitespace-nowrap tabular-nums group-hover/row:hidden",
1050
+ style: ne(v),
1051
+ children: M
1052
+ }) : null,
1053
+ M ? /* @__PURE__ */ l("span", {
1054
+ "aria-hidden": !0,
1055
+ "data-trace-label": "long",
1056
+ className: "text-pho-primary absolute top-1/2 hidden -translate-y-1/2 text-xs whitespace-nowrap tabular-nums group-hover/row:block",
1057
+ style: ne(y),
1058
+ children: J
1059
+ }) : null,
1060
+ M ? /* @__PURE__ */ l("span", {
1061
+ className: "sr-only",
1062
+ children: M
1063
+ }) : null
1064
+ ]
1065
+ })]
1066
+ }), d != null ? /* @__PURE__ */ l(ve.Root, {
1067
+ open: !0,
1068
+ children: /* @__PURE__ */ l(ve.Panel, {
1069
+ className: "motion-reduce:transition-none",
1070
+ children: /* @__PURE__ */ l("section", {
1071
+ id: m,
1072
+ "data-trace-detail": "",
1073
+ className: "border-pho-secondary bg-pho-page border-t py-3 pr-3",
1074
+ style: { paddingLeft: "var(--trace-indent)" },
1075
+ children: d
1076
+ })
1077
+ })
1078
+ }) : null]
1079
+ });
1080
+ }
1081
+ function bn({ selected: e, expanded: t, controls: n, onSelect: a, children: r }) {
1082
+ const o = "flex min-w-0 flex-1 items-baseline gap-2 text-left";
1083
+ return a == null ? /* @__PURE__ */ l("span", {
1084
+ className: o,
1085
+ children: r
1086
+ }) : /* @__PURE__ */ l("button", {
1087
+ type: "button",
1088
+ "data-trace-select": "",
1089
+ "aria-current": e ? "true" : void 0,
1090
+ "aria-expanded": t,
1091
+ "aria-controls": n,
1092
+ onClick: a,
1093
+ className: L(o, "cursor-pointer outline-none after:absolute after:inset-0 after:content-['']"),
1094
+ children: r
1095
+ });
1096
+ }
1097
+ function xn(e) {
1098
+ const [t, n] = Q(void 0);
1099
+ return ae(() => {
1100
+ if (!e) return;
1101
+ n(Date.now());
1102
+ const a = setInterval(() => n(Date.now()), ln);
1103
+ return () => clearInterval(a);
1104
+ }, [e]), e ? t : void 0;
1105
+ }
1106
+ function yn({ spans: e, now: t, selectedId: n, onSelect: a, renderSpanDetail: r, defaultCollapsed: o, collapsed: i, onCollapsedChange: s, foldControls: c = !0, search: u, query: g, onQueryChange: h, defaultView: p, view: S, onViewChange: w, shortcuts: d = "focus", title: m, summary: A, startedAt: b, footer: $, className: _, ...E }) {
1107
+ const N = D(() => Yt(e), [e]), v = D(() => new Map(e.map((C) => [C.id, C])), [e]), y = xn(N.some((C) => C.endedAt == null) && t === void 0), P = t ?? y, [M, J] = Q(""), z = g ?? M, W = O((C) => {
1108
+ g == null && J(C), h?.(C);
1109
+ }, [g, h]), F = D(() => N.filter((C) => C.status === "failed").length, [N]);
1110
+ return /* @__PURE__ */ l(Z.Provider, {
1111
+ spans: N,
1112
+ now: P,
1113
+ defaultCollapsed: o,
1114
+ collapsed: i,
1115
+ onCollapsedChange: s,
1116
+ query: z,
1117
+ defaultView: p,
1118
+ view: S,
1119
+ onViewChange: w,
1120
+ children: /* @__PURE__ */ l(wn, {
1121
+ sources: v,
1122
+ spanCount: N.length,
1123
+ errorCount: F,
1124
+ selectedId: n,
1125
+ onSelect: a,
1126
+ renderSpanDetail: r,
1127
+ foldControls: c,
1128
+ search: u,
1129
+ query: z,
1130
+ setQuery: W,
1131
+ shortcuts: d,
1132
+ title: m,
1133
+ summary: A,
1134
+ startedAt: b,
1135
+ footer: $,
1136
+ className: _,
1137
+ ...E
1138
+ })
1139
+ });
1140
+ }
1141
+ function wn({ sources: e, spanCount: t, errorCount: n, selectedId: a, onSelect: r, renderSpanDetail: o, foldControls: i, search: s, query: c, setQuery: u, shortcuts: g, title: h, summary: p, startedAt: S, footer: w, className: d, ref: m, ...A }) {
1142
+ const { all: b, matches: $, zoomed: _, zoom: E, pan: N, resetView: v, expandAll: y, collapseAll: P, expandOne: M, collapseOne: J } = H(), z = Ze(), W = he(null), F = he(null), C = O((f) => {
1143
+ W.current = f, typeof m == "function" ? m(f) : m != null && (m.current = f);
1144
+ }, [m]), k = D(() => $ == null ? [] : b.filter((f) => $.has(f.id)).map((f) => f.id), [b, $]), [B, te] = Q(0);
1145
+ ae(() => te(0), [c]);
1146
+ const R = k.length > 0 ? k[B % k.length] ?? null : null, V = O((f) => {
1147
+ k.length !== 0 && te((j) => (j + f + k.length) % k.length);
1148
+ }, [k.length]);
1149
+ ae(() => {
1150
+ if (R == null) return;
1151
+ const f = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(R) : R.replace(/"/g, '\\"');
1152
+ W.current?.querySelector(`[data-trace-row][data-span-id="${f}"]`)?.scrollIntoView?.({ block: "nearest" });
1153
+ }, [R]);
1154
+ const G = c !== "", I = a != null && r != null;
1155
+ ae(() => {
1156
+ if (!G && !_ && !I || g === !1) return;
1157
+ const f = (j) => {
1158
+ j.key === "Escape" && (g === "focus" && !(j.target instanceof Node && W.current?.contains(j.target)) || (j.preventDefault(), j.stopPropagation(), G ? u("") : _ ? v() : r?.(null)));
1159
+ };
1160
+ return document.addEventListener("keydown", f, !0), () => document.removeEventListener("keydown", f, !0);
1161
+ }, [
1162
+ G,
1163
+ _,
1164
+ I,
1165
+ g,
1166
+ u,
1167
+ v,
1168
+ r
1169
+ ]);
1170
+ const T = O((f) => {
1171
+ if (f.metaKey || f.ctrlKey || f.altKey || vn(f.target)) return !1;
1172
+ switch (f.key) {
1173
+ case "[":
1174
+ return y(), !0;
1175
+ case "]":
1176
+ return P(), !0;
1177
+ case "o":
1178
+ return M(), !0;
1179
+ case "p":
1180
+ return J(), !0;
1181
+ case "ArrowUp":
1182
+ return E(f.shiftKey ? Me : ke), !0;
1183
+ case "ArrowDown":
1184
+ return _ ? (E(f.shiftKey ? 1 / Me : 1 / ke), !0) : !1;
1185
+ case "ArrowLeft":
1186
+ return _ ? (N(f.shiftKey ? -0.3 : -0.1), !0) : !1;
1187
+ case "ArrowRight":
1188
+ return _ ? (N(f.shiftKey ? dn : cn), !0) : !1;
1189
+ case "/":
1190
+ return F.current == null ? !1 : (F.current.focus(), !0);
1191
+ case "f":
1192
+ return k.length === 0 ? !1 : (V(1), !0);
1193
+ case "b":
1194
+ return k.length === 0 ? !1 : (V(-1), !0);
1195
+ default:
1196
+ return !1;
1197
+ }
1198
+ }, [
1199
+ y,
1200
+ P,
1201
+ M,
1202
+ J,
1203
+ E,
1204
+ N,
1205
+ _,
1206
+ k.length,
1207
+ V
1208
+ ]);
1209
+ ae(() => {
1210
+ if (g === !1) return;
1211
+ const f = (j) => {
1212
+ g === "focus" && !(j.target instanceof Node && W.current?.contains(j.target)) || T(j) && j.preventDefault();
1213
+ };
1214
+ return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
1215
+ }, [g, T]);
1216
+ const ne = D(() => ({
1217
+ spans: e,
1218
+ selectedId: a,
1219
+ onSelect: r,
1220
+ renderSpanDetail: o,
1221
+ idBase: z,
1222
+ spanCount: t,
1223
+ errorCount: n,
1224
+ startedAt: S,
1225
+ activeMatchId: R
1226
+ }), [
1227
+ e,
1228
+ a,
1229
+ r,
1230
+ o,
1231
+ z,
1232
+ t,
1233
+ n,
1234
+ S,
1235
+ R
1236
+ ]), K = b.some((f) => f.hasChildren), Ue = s === !0 || typeof s == "string", fe = typeof s == "string" ? s : "Search spans", Ge = w === void 0 ? t > 0 ? /* @__PURE__ */ l(Be, {}) : null : w;
1237
+ return /* @__PURE__ */ l(Ve.Provider, {
1238
+ value: ne,
1239
+ children: /* @__PURE__ */ x("section", {
1240
+ ref: C,
1241
+ "data-trace": "",
1242
+ "data-zoomed": _ || void 0,
1243
+ "aria-label": typeof h == "string" ? h : "Trace",
1244
+ tabIndex: g === "focus" ? -1 : void 0,
1245
+ className: L(Oe, "min-w-0 outline-none", d),
1246
+ ...A,
1247
+ children: [
1248
+ Ue ? /* @__PURE__ */ x("div", {
1249
+ "data-trace-toolbar": "",
1250
+ className: "border-pho-secondary flex min-h-10 items-center gap-3 border-b px-3",
1251
+ children: [/* @__PURE__ */ l(He, {
1252
+ ref: F,
1253
+ value: c,
1254
+ onChange: u,
1255
+ placeholder: fe,
1256
+ "aria-label": fe,
1257
+ onKeyDown: (f) => {
1258
+ f.key === "Enter" ? (f.preventDefault(), V(f.shiftKey ? -1 : 1)) : f.key === "Escape" && c !== "" && (f.preventDefault(), u(""));
1259
+ }
1260
+ }), G ? /* @__PURE__ */ x(Ye, { children: [/* @__PURE__ */ l("span", {
1261
+ "data-trace-match-count": "",
1262
+ "aria-live": "polite",
1263
+ className: "text-pho-description shrink-0 text-xs tabular-nums",
1264
+ children: k.length === 0 ? "No matches" : `${B % k.length + 1} of ${k.length}`
1265
+ }), /* @__PURE__ */ x("span", {
1266
+ className: "flex shrink-0 items-center",
1267
+ children: [/* @__PURE__ */ l("button", {
1268
+ type: "button",
1269
+ "aria-label": "Previous match",
1270
+ title: "Previous match (b)",
1271
+ disabled: k.length === 0,
1272
+ onClick: () => V(-1),
1273
+ className: se,
1274
+ children: /* @__PURE__ */ l(Te, {
1275
+ "aria-hidden": !0,
1276
+ className: "size-4"
1277
+ })
1278
+ }), /* @__PURE__ */ l("button", {
1279
+ type: "button",
1280
+ "aria-label": "Next match",
1281
+ title: "Next match (f)",
1282
+ disabled: k.length === 0,
1283
+ onClick: () => V(1),
1284
+ className: se,
1285
+ children: /* @__PURE__ */ l(Ie, {
1286
+ "aria-hidden": !0,
1287
+ className: "size-4"
1288
+ })
1289
+ })]
1290
+ })] }) : null]
1291
+ }) : null,
1292
+ /* @__PURE__ */ x("div", {
1293
+ "data-trace-axis": "",
1294
+ className: L(ze, "border-pho-secondary h-10 border-b"),
1295
+ children: [/* @__PURE__ */ x("div", {
1296
+ className: "flex h-10 min-w-0 items-center gap-2 px-3",
1297
+ children: [
1298
+ h != null ? /* @__PURE__ */ l("div", {
1299
+ className: "text-pho-secondary min-w-0 truncate text-xs font-medium",
1300
+ children: h
1301
+ }) : null,
1302
+ p != null ? /* @__PURE__ */ l("div", {
1303
+ className: "text-pho-description shrink-0 text-xs tabular-nums",
1304
+ children: p
1305
+ }) : null,
1306
+ i && K ? /* @__PURE__ */ l(Nn, {}) : null
1307
+ ]
1308
+ }), /* @__PURE__ */ l(kn, {})]
1309
+ }),
1310
+ /* @__PURE__ */ l(Z.Timeline, {
1311
+ render: /* @__PURE__ */ l("ol", {
1312
+ "aria-label": typeof h == "string" ? h : "Spans",
1313
+ className: "m-0 list-none p-0"
1314
+ }),
1315
+ children: /* @__PURE__ */ l(Z.Children, { children: () => /* @__PURE__ */ l(gn, {}) })
1316
+ }),
1317
+ Ge
1318
+ ]
1319
+ })
1320
+ });
1321
+ }
1322
+ function Nn() {
1323
+ const { canExpand: e, canCollapse: t, expandAll: n, collapseAll: a, expandOne: r, collapseOne: o } = H();
1324
+ return /* @__PURE__ */ x("fieldset", {
1325
+ "data-trace-fold-controls": "",
1326
+ className: "m-0 ml-auto flex min-w-0 shrink-0 items-center border-0 p-0",
1327
+ children: [
1328
+ /* @__PURE__ */ l("legend", {
1329
+ className: "sr-only",
1330
+ children: "Fold"
1331
+ }),
1332
+ /* @__PURE__ */ l("button", {
1333
+ type: "button",
1334
+ "aria-label": "Expand one level",
1335
+ title: "Expand one level (o)",
1336
+ disabled: !e,
1337
+ onClick: r,
1338
+ className: se,
1339
+ children: /* @__PURE__ */ l(Ie, {
1340
+ "aria-hidden": !0,
1341
+ className: "size-4"
1342
+ })
1343
+ }),
1344
+ /* @__PURE__ */ l("button", {
1345
+ type: "button",
1346
+ "aria-label": "Collapse one level",
1347
+ title: "Collapse one level (p)",
1348
+ disabled: !t,
1349
+ onClick: o,
1350
+ className: se,
1351
+ children: /* @__PURE__ */ l(Te, {
1352
+ "aria-hidden": !0,
1353
+ className: "size-4"
1354
+ })
1355
+ }),
1356
+ /* @__PURE__ */ l("button", {
1357
+ type: "button",
1358
+ "aria-label": "Expand all",
1359
+ title: "Expand all ([)",
1360
+ disabled: !e,
1361
+ onClick: n,
1362
+ className: se,
1363
+ children: /* @__PURE__ */ l(at, {
1364
+ "aria-hidden": !0,
1365
+ className: "size-4"
1366
+ })
1367
+ }),
1368
+ /* @__PURE__ */ l("button", {
1369
+ type: "button",
1370
+ "aria-label": "Collapse all",
1371
+ title: "Collapse all (])",
1372
+ disabled: !t,
1373
+ onClick: a,
1374
+ className: se,
1375
+ children: /* @__PURE__ */ l(st, {
1376
+ "aria-hidden": !0,
1377
+ className: "size-4"
1378
+ })
1379
+ })
1380
+ ]
1381
+ });
1382
+ }
1383
+ function kn() {
1384
+ const { range: e, view: t, viewRange: n, setView: a, resetView: r } = H(), o = n.min - e.min, i = n.max - e.min, s = D(() => en(o, i), [o, i]), [c, u] = Q(280), g = he(null);
1385
+ ae(() => {
1386
+ const v = g.current;
1387
+ if (v == null) return;
1388
+ const y = () => {
1389
+ const M = v.clientWidth;
1390
+ M > 0 && u(M);
1391
+ };
1392
+ y();
1393
+ const P = new ResizeObserver(y);
1394
+ return P.observe(v), () => P.disconnect();
1395
+ }, []);
1396
+ const h = new Set(an(s, c)), p = s[s.length - 1], [S, w] = Q(null), [d, m] = Q(null), A = (v) => {
1397
+ const y = v.currentTarget.getBoundingClientRect();
1398
+ return y.width <= 0 ? 0 : Math.min(1, Math.max(0, (v.clientX - y.left) / y.width));
1399
+ }, b = (v) => {
1400
+ if (v.button !== 0) return;
1401
+ v.currentTarget.setPointerCapture?.(v.pointerId);
1402
+ const y = A(v);
1403
+ m({
1404
+ from: y,
1405
+ to: y
1406
+ });
1407
+ }, $ = (v) => {
1408
+ const y = A(v);
1409
+ d && m({
1410
+ from: d.from,
1411
+ to: y
1412
+ }), w(y);
1413
+ }, _ = (v) => {
1414
+ if (!d) return;
1415
+ const y = A(v);
1416
+ m(null);
1417
+ const [P, M] = d.from < y ? [d.from, y] : [y, d.from];
1418
+ M - P < un || a([xe(t, P), xe(t, M)]);
1419
+ }, E = () => {
1420
+ w(null), m(null);
1421
+ }, N = d == null ? null : d.from < d.to ? {
1422
+ left: d.from,
1423
+ width: d.to - d.from
1424
+ } : {
1425
+ left: d.to,
1426
+ width: d.from - d.to
1427
+ };
1428
+ return /* @__PURE__ */ l(We, {
1429
+ className: "h-10",
1430
+ children: /* @__PURE__ */ x("div", {
1431
+ ref: g,
1432
+ "aria-hidden": !0,
1433
+ role: "presentation",
1434
+ "data-trace-axis-track": "",
1435
+ title: "Drag to zoom, double-click to reset",
1436
+ className: "absolute inset-0 cursor-crosshair touch-none select-none",
1437
+ onPointerDown: b,
1438
+ onPointerMove: $,
1439
+ onPointerUp: _,
1440
+ onPointerCancel: E,
1441
+ onPointerLeave: E,
1442
+ onDoubleClick: r,
1443
+ children: [
1444
+ s.map((v) => {
1445
+ const y = v === p;
1446
+ return /* @__PURE__ */ x("span", {
1447
+ "data-trace-tick": "",
1448
+ "data-labeled": h.has(v.ms) || void 0,
1449
+ className: "text-pho-description absolute inset-y-0 text-xs tabular-nums",
1450
+ style: { left: Y(v.at) },
1451
+ children: [/* @__PURE__ */ l("span", { className: "bg-pho-secondary absolute bottom-0 left-0 h-1.5 w-px" }), h.has(v.ms) ? /* @__PURE__ */ l("span", {
1452
+ className: L("absolute inset-y-0 flex items-center whitespace-nowrap", y ? "right-1" : "left-1"),
1453
+ children: Le(v.ms)
1454
+ }) : null]
1455
+ }, v.ms);
1456
+ }),
1457
+ S != null && N == null ? /* @__PURE__ */ l("span", {
1458
+ "data-trace-cursor": "",
1459
+ className: "bg-pho-inverse/40 pointer-events-none absolute inset-y-0 w-px",
1460
+ style: { left: Y(S) },
1461
+ children: /* @__PURE__ */ l("span", {
1462
+ className: L("bg-pho-primary text-pho-secondary absolute top-1 rounded-sm px-1 text-[10px] whitespace-nowrap tabular-nums", S > 0.8 ? "right-1" : "left-1"),
1463
+ children: re(o + S * (i - o))
1464
+ })
1465
+ }) : null,
1466
+ N ? /* @__PURE__ */ l("span", {
1467
+ "data-trace-selection": "",
1468
+ className: "bg-pho-inverse/10 pointer-events-none absolute inset-y-0",
1469
+ style: {
1470
+ left: Y(N.left),
1471
+ width: Y(N.width)
1472
+ }
1473
+ }) : null
1474
+ ]
1475
+ })
1476
+ });
1477
+ }
1478
+ function Mn(e) {
1479
+ const t = new Date(e);
1480
+ if (!Number.isFinite(e) || Number.isNaN(t.getTime())) return "";
1481
+ const n = (a, r = 2) => String(a).padStart(r, "0");
1482
+ return `Started ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}.${n(t.getMilliseconds(), 3)}`;
1483
+ }
1484
+ function An({ spanCount: e, errorCount: t, orphanCount: n = 0, durationMs: a, window: r, startedAt: o }) {
1485
+ const i = [de(e, "span")];
1486
+ if (t > 0 && i.push(de(t, "error")), n > 0 && i.push(`${n} missing ${n === 1 ? "parent" : "parents"}`), i.push(r ? `${re(r.startMs)} – ${re(r.endMs)} of ${re(a)}` : `${re(a)} total`), o != null) {
1487
+ const s = Mn(o);
1488
+ s && i.push(s);
1489
+ }
1490
+ return i;
1491
+ }
1492
+ function Be({ startedAt: e, className: t, ...n }) {
1493
+ const { spanCount: a, errorCount: r, startedAt: o } = je(), { range: i, viewRange: s, zoomed: c, orphans: u, resetView: g } = H(), h = An({
1494
+ spanCount: a,
1495
+ errorCount: r,
1496
+ orphanCount: u,
1497
+ durationMs: i.max - i.min,
1498
+ window: c ? {
1499
+ startMs: s.min - i.min,
1500
+ endMs: s.max - i.min
1501
+ } : null,
1502
+ startedAt: e ?? o
1503
+ });
1504
+ return /* @__PURE__ */ x("div", {
1505
+ "data-trace-footer": "",
1506
+ className: L("border-pho-secondary text-pho-description flex h-10 items-center justify-between gap-3 border-t px-3 text-xs", t),
1507
+ ...n,
1508
+ children: [/* @__PURE__ */ x("ul", {
1509
+ className: "flex min-w-0 items-center gap-3",
1510
+ children: [/* @__PURE__ */ l(Ce, {
1511
+ className: "bg-pho-inverse/25",
1512
+ label: "Span"
1513
+ }), /* @__PURE__ */ l(Ce, {
1514
+ className: "bg-pho-error-ink",
1515
+ label: "Error"
1516
+ })]
1517
+ }), /* @__PURE__ */ x("div", {
1518
+ className: "flex min-w-0 items-center gap-3",
1519
+ children: [/* @__PURE__ */ l("ul", {
1520
+ className: "flex min-w-0 items-center gap-3 tabular-nums",
1521
+ children: h.map((p) => /* @__PURE__ */ l("li", {
1522
+ className: "shrink-0 last:min-w-0 last:truncate",
1523
+ children: p
1524
+ }, p))
1525
+ }), c ? /* @__PURE__ */ l("button", {
1526
+ type: "button",
1527
+ "data-trace-reset-zoom": "",
1528
+ onClick: g,
1529
+ title: "Reset zoom (Esc)",
1530
+ className: "text-pho-secondary hover:text-pho-primary outline-pho-brand shrink-0 cursor-pointer rounded-sm underline-offset-2 hover:underline focus-visible:outline-2",
1531
+ children: "Reset zoom"
1532
+ }) : null]
1533
+ })]
1534
+ });
1535
+ }
1536
+ function Ce({ className: e, label: t }) {
1537
+ return /* @__PURE__ */ x("li", {
1538
+ className: "flex items-center gap-1.5",
1539
+ children: [/* @__PURE__ */ l("span", {
1540
+ "aria-hidden": !0,
1541
+ className: L("size-2.5 shrink-0 rounded-sm", e)
1542
+ }), t]
1543
+ });
1544
+ }
1545
+ var Sn = {
1546
+ debug: "text-pho-description",
1547
+ info: "text-pho-secondary",
1548
+ warn: "text-pho-warning",
1549
+ error: "text-pho-error"
1550
+ };
1551
+ function Cn({ logs: e, spans: t, title: n = "Logs", className: a, ...r }) {
1552
+ const o = D(() => new Map((t ?? []).map((i) => [i.id, i.name])), [t]);
1553
+ return e == null || e.length === 0 ? null : /* @__PURE__ */ x("section", {
1554
+ "data-trace-logs": "",
1555
+ className: L(Oe, "min-w-0", a),
1556
+ ...r,
1557
+ children: [/* @__PURE__ */ x("div", {
1558
+ className: "border-pho-secondary flex min-h-10 items-center justify-between gap-3 border-b px-3",
1559
+ children: [/* @__PURE__ */ l("div", {
1560
+ className: "text-pho-secondary min-w-0 truncate text-xs font-medium",
1561
+ children: n
1562
+ }), /* @__PURE__ */ x("div", {
1563
+ className: "text-pho-description shrink-0 text-xs tabular-nums",
1564
+ children: [
1565
+ e.length,
1566
+ " ",
1567
+ e.length === 1 ? "line" : "lines"
1568
+ ]
1569
+ })]
1570
+ }), /* @__PURE__ */ l("ol", {
1571
+ className: "divide-pho-secondary m-0 list-none divide-y p-0 font-mono text-xs",
1572
+ children: e.map((i, s) => {
1573
+ const c = i.level ?? "info", u = i.spanId ? o.get(i.spanId) : void 0;
1574
+ return /* @__PURE__ */ x("li", {
1575
+ className: "grid grid-cols-[5rem_3.5rem_minmax(0,1fr)] items-baseline gap-3 px-3 py-1.5",
1576
+ children: [
1577
+ /* @__PURE__ */ x("span", {
1578
+ className: "text-pho-description tabular-nums",
1579
+ children: ["+", re(i.offsetMs)]
1580
+ }),
1581
+ /* @__PURE__ */ l("span", {
1582
+ className: L("truncate", Sn[c]),
1583
+ children: c.charAt(0).toUpperCase() + c.slice(1)
1584
+ }),
1585
+ /* @__PURE__ */ x("span", {
1586
+ className: "text-pho-primary [overflow-wrap:anywhere] whitespace-pre-wrap",
1587
+ children: [i.message, u ? /* @__PURE__ */ x("span", {
1588
+ className: "text-pho-description",
1589
+ children: [" ", u]
1590
+ }) : null]
1591
+ })
1592
+ ]
1593
+ }, i.id ?? s);
1594
+ })
1595
+ })]
1596
+ });
1597
+ }
1598
+ var In = Object.assign(yn, { Footer: Be }), Wn = {
1599
+ Waterfall: In,
1600
+ Logs: Cn
1601
+ };
1602
+ export {
1603
+ _e as A,
1604
+ Ct as B,
1605
+ ce as C,
1606
+ oe as D,
1607
+ Kn as E,
1608
+ _t as F,
1609
+ At as I,
1610
+ xe as L,
1611
+ $t as M,
1612
+ Tt as N,
1613
+ wt as O,
1614
+ It as P,
1615
+ St as R,
1616
+ be as S,
1617
+ yt as T,
1618
+ Ht as _,
1619
+ Ne as a,
1620
+ ee as b,
1621
+ an as c,
1622
+ Qt as d,
1623
+ Bt as f,
1624
+ Zt as g,
1625
+ Xt as h,
1626
+ en as i,
1627
+ Mt as j,
1628
+ kt as k,
1629
+ qt as l,
1630
+ Gt as m,
1631
+ An as n,
1632
+ re as o,
1633
+ me as p,
1634
+ on as r,
1635
+ Le as s,
1636
+ Wn as t,
1637
+ Yt as u,
1638
+ Jt as v,
1639
+ Nt as w,
1640
+ H as x,
1641
+ Z as y,
1642
+ Ee as z
1643
+ };
1644
+
1645
+ //# sourceMappingURL=trace-Ba1RMBfk.js.map