@mechane-ai/elements 0.62.0 → 0.64.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 (82) hide show
  1. package/dist/ai.js +7 -7
  2. package/dist/{article-DBRkXW1r.js → article-BopqPz1K.js} +6 -6
  3. package/dist/article.js +1 -1
  4. package/dist/catalog.json +1 -1
  5. package/dist/{categorical-values-Bq5dMg0i.js → categorical-values-8LA9KXhi.js} +1 -1
  6. package/dist/charts/cartesian.js +1 -1
  7. package/dist/charts/comparison.js +1 -1
  8. package/dist/charts/distribution.js +1 -1
  9. package/dist/charts/figure.js +12 -12
  10. package/dist/charts/graph.js +1 -1
  11. package/dist/charts/hierarchy.js +1 -1
  12. package/dist/charts/image.js +1 -1
  13. package/dist/charts/matrix.js +1 -1
  14. package/dist/charts/plot.js +3 -3
  15. package/dist/charts/relationship.js +1 -1
  16. package/dist/charts/text.js +1 -1
  17. package/dist/charts/timeline.js +2 -2
  18. package/dist/charts/trend.js +1 -1
  19. package/dist/charts.js +2 -2
  20. package/dist/{code-block-C_Ze7QLO.js → code-block-BjQUIvvw.js} +1 -1
  21. package/dist/collections.js +1 -1
  22. package/dist/{commands-BWwMKUdd.js → commands-BI9rWGpb.js} +2 -2
  23. package/dist/content/code.js +1 -1
  24. package/dist/content/diff.js +3 -3
  25. package/dist/content/link.js +1 -1
  26. package/dist/content/markdown.js +1 -1
  27. package/dist/content/tree.js +2 -2
  28. package/dist/{content-link-BSR0a887.js → content-link-C3RAJ2kP.js} +1 -1
  29. package/dist/content.js +1 -1
  30. package/dist/{dates-DNb7_KSp.js → dates-D1v_jiva.js} +2 -2
  31. package/dist/{dumbbell-plot-DWybxZAH.js → dumbbell-plot-QGjFMk0X.js} +3 -3
  32. package/dist/{embedding-map-B5JjgyGR.js → embedding-map-D_RNxsCD.js} +6 -6
  33. package/dist/feedback.js +1 -1
  34. package/dist/{figure-frame-zyCmHlgX.js → figure-frame-CF3298LZ.js} +3 -3
  35. package/dist/forms/dates.js +1 -1
  36. package/dist/{forms-C5vXBA_C.js → forms-DlKhXUlc.js} +1 -1
  37. package/dist/forms.js +2 -2
  38. package/dist/{image-grid-Cgkz2fsU.js → image-grid-BXsgVBnB.js} +3 -3
  39. package/dist/index.js +1 -1
  40. package/dist/kits/evaluation.js +4 -4
  41. package/dist/kits/interpretability.js +11 -11
  42. package/dist/kits/operations.js +6 -6
  43. package/dist/kits/research.js +8 -8
  44. package/dist/kits/training.js +5 -5
  45. package/dist/layout.js +1 -1
  46. package/dist/lesson.js +3 -3
  47. package/dist/{markdown-BkFwgQzJ.js → markdown-B92daSMP.js} +2 -2
  48. package/dist/mdx.js +6 -6
  49. package/dist/navigation/commands.js +1 -1
  50. package/dist/{navigation-Bqouujdr.js → navigation-D3vnWiVv.js} +1 -1
  51. package/dist/navigation.js +3 -3
  52. package/dist/packages/charts/src/timeline/trace-timeline.d.ts +1 -1
  53. package/dist/packages/collections/src/data-table-styles.d.ts +4 -0
  54. package/dist/packages/collections/src/data-table-text.d.ts +3 -1
  55. package/dist/{param-BLGHbZoi.js → param-DfOYi9wL.js} +1 -1
  56. package/dist/{pierre-diff-TAaZTeg-.js → pierre-diff-DP_TXXIt.js} +1 -1
  57. package/dist/{plot-layout-JgEcW4fY.js → plot-layout-BfXmAi71.js} +3 -3
  58. package/dist/{plot-surface-CAAzoXJh.js → plot-surface-UQgDiTVe.js} +1 -1
  59. package/dist/{reference-lines-BGE13uMG.js → reference-lines-BRHB78Wb.js} +1 -1
  60. package/dist/{scene-GBAHedGg.js → scene-DlVQupfw.js} +6 -6
  61. package/dist/scene.js +1 -1
  62. package/dist/{slope-chart-Bh7fntOb.js → slope-chart-CjXcvoRJ.js} +4 -4
  63. package/dist/{src-KTMBylbq.js → src-BI1xQE7D.js} +1 -1
  64. package/dist/{src-k0l1Y4Xl.js → src-BYmv3_AL.js} +9 -12
  65. package/dist/{src-D_BL6n5Q.js → src-BYnmQkDq.js} +2 -2
  66. package/dist/{src-CoRsRnHQ.js → src-BdQGb362.js} +4 -4
  67. package/dist/{src-DxZdE_P5.js → src-DPcnDU5H.js} +1 -1
  68. package/dist/{src-Ddx3fHei.js → src-DojhQZKX.js} +3 -3
  69. package/dist/{src-XMHLpSe9.js → src-P19zz_aO.js} +15 -10
  70. package/dist/styles2.css +103 -26
  71. package/dist/{time-series-_wZflmIb.js → time-series-Dg3DZRGx.js} +8 -8
  72. package/dist/timeline-C2IVroD3.js +923 -0
  73. package/dist/{token-heatmap-Chnea1Iv.js → token-heatmap-CZtIPU60.js} +3 -3
  74. package/dist/{token-predictions-DQEd5sj7.js → token-predictions-BJ5L-Lrm.js} +3 -3
  75. package/dist/{transport-CagqVWwW.js → transport-D9e0H2we.js} +4 -4
  76. package/dist/{tree-diagram-CL8RI9gT.js → tree-diagram-DRAJiqjW.js} +4 -4
  77. package/dist/{treemap-C3zmI4of.js → treemap-BdELCV7E.js} +4 -4
  78. package/dist/{use-tween-C2VZtQjV.js → use-tween-COV8bEYL.js} +1 -1
  79. package/dist/{violin-plot-CgpyGuSe.js → violin-plot-DuxqWnuD.js} +3 -3
  80. package/dist/{waterfall-S8CLEUib.js → waterfall-D4ewGb4u.js} +175 -176
  81. package/package.json +1 -1
  82. package/dist/timeline-DsNPo_57.js +0 -869
@@ -1,869 +0,0 @@
1
- import { A as e, E as t, M as n, S as r, h as i, j as a, l as o, s } from "./plot-layout-JgEcW4fY.js";
2
- import { E as c, c as l, m as u, t as d, y as f } from "./src-k0l1Y4Xl.js";
3
- import { t as p } from "./chart-tones-ei3BC2AL.js";
4
- import { t as m } from "./chart-cursor-1mFd48Jc.js";
5
- import { i as h, l as g, n as ee, r as te, t as ne } from "./figure-frame-zyCmHlgX.js";
6
- import { i as re } from "./chart-link-AE_xuxiP.js";
7
- import { t as ie } from "./chart-range-Du1gDxCY.js";
8
- import { n as ae } from "./plot-width-D3hTycYX.js";
9
- import { r as oe } from "./figure-format-B8kRZMlo.js";
10
- import { a as se } from "./tone-scope-DKiSw-JR.js";
11
- import { t as ce } from "./plot-axes-D5S9BnBa.js";
12
- import { r as le } from "./plot-marks-DgCtcd3L.js";
13
- import { n as ue, r as de, t as fe } from "./plot-surface-CAAzoXJh.js";
14
- import { r as pe } from "./scale-C2xgZyZN.js";
15
- import * as _ from "@stylexjs/stylex";
16
- import { useId as me, useRef as he, useState as ge } from "react";
17
- import { stackSpans as v } from "@ui-sdk/core";
18
- import { Fragment as _e, jsx as y, jsxs as b } from "react/jsx-runtime";
19
- import { X as ve } from "lucide-react";
20
- // packages/charts/src/timeline/trace-timeline-layout.ts
21
- var x = {
22
- lanes: 24,
23
- spans: 2e3
24
- }, S = .5, C = .005, ye = .7, w = .2, be = .15, T = 4, E = 48, D = .5, O = 14, xe = 6, Se = 8, Ce = 6, we = 28, Te = 1, Ee = 6, k = 4, A = 3;
25
- function De({ lanes: e, spans: t, domain: r }) {
26
- let [i, a] = r;
27
- if (!Number.isFinite(i) || !Number.isFinite(a) || a < i) return "The trace domain must have finite, ordered endpoints.";
28
- if (e.length === 0) return "A trace timeline needs at least one lane.";
29
- if (e.length > x.lanes) return `This chart draws at most ${x.lanes} lanes.`;
30
- if (t.length > x.spans) return `This chart draws at most ${x.spans} spans.`;
31
- if (!n(e)) return "Trace lanes must have unique identifiers.";
32
- if (!n(t)) return "Trace spans must have unique identifiers.";
33
- let o = new Set(e.map((e) => e.id));
34
- for (let e of t) {
35
- if (!o.has(e.laneId)) return `Span "${e.id}" references an unknown lane "${e.laneId}".`;
36
- if (!Number.isFinite(e.start) || !Number.isFinite(e.end) || e.end < e.start) return `Span "${e.id}" must have finite, ordered endpoints.`;
37
- }
38
- }
39
- function Oe(e, t) {
40
- let [n, r] = t, i = Math.max(r - n, 0);
41
- if (i === 0) return [n, r];
42
- let a = i * C, o = Math.max(n, Math.min(r, e[0])), s = Math.max(n, Math.min(r, e[1]));
43
- if (s < o && ([o, s] = [s, o]), s - o < a) {
44
- let e = (o + s) * S;
45
- o = Math.max(n, e - a * S), s = Math.min(r, o + a), o = Math.max(n, s - a);
46
- }
47
- return [o, s];
48
- }
49
- function ke({ visible: e, domain: t, factor: n, anchorRatio: r = S }) {
50
- let [i, a] = t, o = e[1] - e[0], s = a - i;
51
- if (s <= 0 || !Number.isFinite(n) || n <= 0) return t;
52
- let c = Math.min(s, Math.max(s * C, o * n)), l = e[0] + o * r - c * r, u = l + c;
53
- return l < i && (l = i, u = Math.min(a, i + c)), u > a && (u = a, l = Math.max(i, a - c)), [l, u];
54
- }
55
- function j({ visible: e, domain: t, direction: n, anchorRatio: r = S }) {
56
- return ke({
57
- visible: e,
58
- domain: t,
59
- factor: n === "in" ? ye : 1 / ye,
60
- anchorRatio: r
61
- });
62
- }
63
- function Ae({ visible: e, domain: t, direction: n }) {
64
- return je({
65
- visible: e,
66
- domain: t,
67
- delta: (e[1] - e[0]) * w * (n === "left" ? -1 : 1)
68
- });
69
- }
70
- function je({ visible: e, domain: t, delta: n }) {
71
- let [r, i] = t, a = e[1] - e[0], o = e[0] + n, s = o + a;
72
- return o < r && (o = r, s = Math.min(i, r + a)), s > i && (s = i, o = Math.max(r, i - a)), [o, s];
73
- }
74
- function Me(e, t) {
75
- let [n, r] = t, i = r - n, a = Math.max(e.end - e.start, i * C) * be;
76
- return Oe([e.start - a, e.end + a], t);
77
- }
78
- var Ne = 32;
79
- function M(e, t) {
80
- let n = t.get(e)?.parentId;
81
- return Array.from({ length: Ne }, () => {
82
- if (n === void 0) return null;
83
- let e = n;
84
- return n = t.get(e)?.parentId, e;
85
- }).filter((e) => e !== null);
86
- }
87
- function Pe(e, t, n) {
88
- if (e == null) return;
89
- let r = new Map(t.map((e) => [e.id, e])), i = r.get(e);
90
- if (i === void 0) return;
91
- let a = M(i.id, r), o = i.relatedIds ?? [], s = (n ?? []).flatMap((e) => e.fromSpanId === i.id ? [e.toSpanId] : e.toSpanId === i.id ? [e.fromSpanId] : []), c = t.filter((e) => e.relatedIds?.includes(i.id) === !0 || M(e.id, r).includes(i.id)).map((e) => e.id);
92
- return /* @__PURE__ */ new Set([
93
- i.id,
94
- ...a,
95
- ...o,
96
- ...s,
97
- ...c
98
- ]);
99
- }
100
- function Fe({ from: e, to: t }) {
101
- let n = Math.abs(e.y - t.y) < 1, r = t.x1 - e.x2, i = 18 * S;
102
- if (r >= (n ? xe : O)) {
103
- let n = e.x2, r = e.y, i = t.x1 - Te, a = t.y, o = Math.min(E, Math.max(T, (i - n) * D));
104
- return {
105
- sx: n,
106
- sy: r,
107
- c1x: n + o,
108
- c1y: r,
109
- c2x: i - o,
110
- c2y: a,
111
- ex: i,
112
- ey: a
113
- };
114
- }
115
- if (n) {
116
- let n = e.x2, r = e.y - i, a = t.x1, o = t.y - i - Te, s = r - Se;
117
- return {
118
- sx: n,
119
- sy: r,
120
- c1x: n,
121
- c1y: s,
122
- c2x: a,
123
- c2y: s,
124
- ex: a,
125
- ey: o
126
- };
127
- }
128
- let a = t.y > e.y ? 1 : -1, o = Math.max(0, t.x2 - t.x1), s = t.x1 + Math.min(Ee, o * S), c = t.y - a * 10, l = Math.max(e.x1, Math.min(e.x2, s)), u = e.y + a * i, d = Math.min(we, Math.max(Ce, Math.abs(c - u) * S));
129
- return {
130
- sx: l,
131
- sy: u,
132
- c1x: l,
133
- c1y: u + a * d,
134
- c2x: s,
135
- c2y: c - a * d,
136
- ex: s,
137
- ey: c
138
- };
139
- }
140
- function Ie({ from: e, to: t }) {
141
- let { sx: n, sy: r, c1x: i, c1y: a, c2x: o, c2y: s, ex: c, ey: l } = Fe({
142
- from: e,
143
- to: t
144
- }), u = c - o, d = l - s, f = Math.hypot(u, d), p = f > 0 ? u / f : 1, m = f > 0 ? d / f : 0, h = c - p * k, g = l - m * k, ee = h - m * A, te = g + p * A, ne = h + m * A, re = g - p * A;
145
- return {
146
- path: `M ${n} ${r} C ${i} ${a}, ${o} ${s}, ${c} ${l}`,
147
- arrowPath: `M ${ee} ${te} L ${c} ${l} L ${ne} ${re}`
148
- };
149
- }
150
- function Le({ lane: e, spans: t, minExtent: n }) {
151
- let r = t.filter((t) => t.laneId === e.id).map((t) => ({
152
- id: t.id,
153
- track: e.id,
154
- start: t.start,
155
- end: Math.max(t.end, t.start + n)
156
- })), i = [...v(r).entries()].map(([e, t]) => [e, t.lane]), a = Math.max(0, ...i.map(([, e]) => e));
157
- return {
158
- entries: i,
159
- rowCount: r.length === 0 ? 1 : a + 1
160
- };
161
- }
162
- function Re({ lanes: e, spans: t, minExtent: n }) {
163
- let r = e.map((e) => Le({
164
- lane: e,
165
- spans: t,
166
- minExtent: n
167
- }));
168
- return {
169
- rowBySpanId: new Map(r.flatMap((e) => e.entries)),
170
- rowCountByLane: r.map((e) => e.rowCount)
171
- };
172
- }
173
- // packages/charts/src/timeline/trace-timeline.tsx
174
- var N = 42, ze = 4, Be = 6, P = .5, Ve = 4, He = 10, Ue = 96, We = 3, Ge = 200, Ke = 80, qe = .004, Je = 4, F = 2, Ye = 180, Xe = 280, I = 8, L = 64, Ze = 28, Qe = 2, R = {
175
- k1xSpc: "x1rg5ohu",
176
- kzqmXN: "xci0xqf",
177
- kZKoxP: "x1hagigm",
178
- kaIpWk: "x1cum3z5",
179
- kmuXW: "x2lah0s",
180
- $$css: !0
181
- }, z = {
182
- kVYP8I: "x1vx5rtw",
183
- $$css: !0
184
- }, B = {
185
- swatch: (e) => [
186
- R,
187
- {
188
- kWkggS: e == null ? e : "xl8spv7",
189
- $$css: !0
190
- },
191
- { "--x-backgroundColor": e ?? void 0 }
192
- ],
193
- minimapBox: {
194
- kVAEAm: "x1n2onr6",
195
- kB7OPa: "x9f619",
196
- kMzoRj: "xmkeg23",
197
- ksu8eU: "x1y0btm7",
198
- kVAM5u: "x1ey3b81",
199
- kaIpWk: "x1ok0vyi",
200
- kWkggS: "x1r7kqkb",
201
- kVQacm: "xb3r6kr",
202
- $$css: !0
203
- },
204
- minimapFrame: (e, t) => [{
205
- keTefX: e == null ? e : "x4lel18",
206
- kzqmXN: t == null ? t : "x5lhr3w",
207
- $$css: !0
208
- }, {
209
- "--x-marginInlineStart": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
210
- "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
211
- }],
212
- minimapBar: (e) => [
213
- z,
214
- {
215
- kDwRjp: e == null ? e : "x19zyb68",
216
- $$css: !0
217
- },
218
- { "--x-fill": e ?? void 0 }
219
- ],
220
- separator: {
221
- kfzvcC: "x47corl",
222
- $$css: !0
223
- },
224
- linkGroup: {
225
- kSiTet: "x1iy03kw",
226
- kfzvcC: "x47corl",
227
- $$css: !0
228
- },
229
- linkGroupReceded: {
230
- kSiTet: "xvpkmg4",
231
- $$css: !0
232
- },
233
- scrubPill: {
234
- kVAEAm: "x10l6tqk",
235
- k3aq6I: "xuuh30",
236
- kfzvcC: "x47corl",
237
- kY2c9j: "xhmu9ja",
238
- kg3NbH: "x14w6jbu",
239
- kaIpWk: "x1ok0vyi",
240
- kWkggS: "x1pt885t",
241
- kMwMTN: "x1ymx3u3",
242
- kMv6JI: "x1hz01jw",
243
- kGuDYH: "xy8obcc",
244
- kLWn49: "xas2l8k",
245
- kcqcaj: "xss6m8b",
246
- khDVqt: "xuxw1ft",
247
- $$css: !0
248
- },
249
- scrubPillPos: (e, t) => [{
250
- kbCHJM: e == null ? e : "xgq9j65",
251
- k87sOh: t == null ? t : "xjbys53",
252
- $$css: !0
253
- }, {
254
- "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
255
- "--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t)
256
- }],
257
- hoverCard: {
258
- kVAEAm: "x10l6tqk",
259
- kB7OPa: "x9f619",
260
- kfzvcC: "x47corl",
261
- kY2c9j: "xhmu9ja",
262
- k1xSpc: "xrvj5dj",
263
- kOIVth: "xfko13i",
264
- k8WAf4: "x1hmw7ec",
265
- kg3NbH: "x5g2kb4",
266
- kMzoRj: "xmkeg23",
267
- ksu8eU: "x1y0btm7",
268
- kVAM5u: "x1ey3b81",
269
- kaIpWk: "x1ok0vyi",
270
- kWkggS: "xpvm0e4",
271
- kGVxlE: "x1ghndwu",
272
- kMwMTN: "xbixft",
273
- kMv6JI: "x1hz01jw",
274
- kGuDYH: "xy8obcc",
275
- kLWn49: "xas2l8k",
276
- $$css: !0
277
- },
278
- hoverCardAbove: (e, t, n) => [{
279
- kbCHJM: e == null ? e : "xgq9j65",
280
- kzqmXN: t == null ? t : "x5lhr3w",
281
- krVfgx: n == null ? n : "x1nqzi6q",
282
- $$css: !0
283
- }, {
284
- "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
285
- "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
286
- "--x-bottom": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n)
287
- }],
288
- hoverCardBelow: (e, t, n) => [{
289
- kbCHJM: e == null ? e : "xgq9j65",
290
- kzqmXN: t == null ? t : "x5lhr3w",
291
- k87sOh: n == null ? n : "xjbys53",
292
- $$css: !0
293
- }, {
294
- "--x-left": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(e),
295
- "--x-width": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(t),
296
- "--x-top": ((e) => typeof e == "number" ? e + "px" : e ?? void 0)(n)
297
- }]
298
- };
299
- function $e({ mark: e, box: t, linkLabel: n }) {
300
- let r = Math.min(Xe, Math.max(Ye, t.innerWidth)), i = (e.x1 + e.x2) * P - r * P, a = Math.max(t.left, Math.min(Math.max(t.left, t.right - r), i)), o = e.y - 18 * P, s = e.y + 18 * P, c = o >= L, l = Math.min(t.right, t.left + Ze), u = Math.max(l, t.right - Ze), d = Math.max(l, Math.min(u, e.x1)), f = n ?? e.laneLabel, m = e.span.detail !== void 0 && e.span.detail !== "" && e.span.detail !== e.span.label;
301
- return /* @__PURE__ */ b(_e, { children: [/* @__PURE__ */ b("div", {
302
- "aria-hidden": !0,
303
- ..._.props(B.hoverCard, c ? B.hoverCardAbove(a, r, t.height - o + I) : B.hoverCardBelow(a, r, s + I)),
304
- children: [
305
- /* @__PURE__ */ b("div", {
306
- className: "x78zum5 x6s0dn4 x1qughib x1hnptsi xeuugli",
307
- children: [/* @__PURE__ */ b("span", {
308
- className: "x3nfvp2 x6s0dn4 xunmzkg xeuugli x153jb6y xb3r6kr xlyipyv xuxw1ft",
309
- children: [/* @__PURE__ */ y("span", { ..._.props(B.swatch(p[e.tone])) }), /* @__PURE__ */ y("span", { children: f })]
310
- }), /* @__PURE__ */ y("span", {
311
- className: "x153jb6y xss6m8b xuxw1ft x2lah0s",
312
- children: `${e.duration} · +${e.offset}`
313
- })]
314
- }),
315
- /* @__PURE__ */ y("span", {
316
- className: "xbixft xk4h15q xb3r6kr xlyipyv xuxw1ft",
317
- children: e.span.label
318
- }),
319
- m && /* @__PURE__ */ y("span", {
320
- className: "x153jb6y xb3r6kr xlyipyv xuxw1ft",
321
- children: e.span.detail
322
- })
323
- ]
324
- }), /* @__PURE__ */ y("span", {
325
- "aria-hidden": !0,
326
- ..._.props(B.scrubPill, B.scrubPillPos(d, t.bottom + Qe)),
327
- children: `+${e.offset}`
328
- })] });
329
- }
330
- function et({ lanes: n, spans: v, links: _e, domain: x, categories: S, visibleRange: C, onVisibleRangeChange: ye, onClearSelection: w, offsetFormat: be, selected: T, onSelectedChange: E, highlightedIds: D, onActivateSpan: O, spanActions: xe, isMinimapVisible: Se = !0, xTitle: Ce = "Elapsed", ...we }) {
331
- let { emptyLabel: Te = "No spans were recorded.", actions: Ee, ...k } = we, { title: A, locale: Ne } = k, M = de("regular"), Fe = me(), Le = se(), Ye = re(), [Xe, I] = ge(x), [L, Ze] = ge(null), [Qe, R] = ge(!1), z = he(null);
332
- if (k.status === "loading") return /* @__PURE__ */ y(h, {
333
- ...k,
334
- height: "regular"
335
- });
336
- let et = De({
337
- lanes: n,
338
- spans: v,
339
- domain: x
340
- });
341
- if (et !== void 0) return /* @__PURE__ */ y(te, {
342
- ...k,
343
- message: et
344
- });
345
- let V = Oe(C ?? Xe, x), H = Math.max(x[1] - x[0], 0), U = Math.max(V[1] - V[0], 0), W = H > 0 && U < H * .999;
346
- function G(e) {
347
- let t = Oe(e, x);
348
- C === void 0 && I(t), ye?.(t);
349
- }
350
- let tt = new Map((S ?? []).map((e) => [e.id, e])), nt = /* @__PURE__ */ new Map();
351
- for (let e of v) e.category !== void 0 && nt.set(e.category, (nt.get(e.category) ?? 0) + 1);
352
- let K = o({
353
- width: M.width,
354
- valueLabels: n.map((e) => e.label),
355
- hasXTitle: !0,
356
- hasYTitle: !1
357
- }), rt = Math.max(1, M.width - K.left - K.right), { rowBySpanId: it, rowCountByLane: at } = Re({
358
- lanes: n,
359
- spans: v,
360
- minExtent: U > 0 ? U / rt * 6 : 0
361
- }), ot = 0;
362
- for (let e of at) ot += e;
363
- let st = K.top + ot * 26 + n.length * 6 * 2 + K.bottom, q = s({
364
- width: M.width,
365
- height: st,
366
- margins: K
367
- }), ct = pe({
368
- domain: V,
369
- range: [q.left, q.right]
370
- }), J = Math.max(1, q.innerWidth), lt = pe({
371
- domain: x,
372
- range: [0, J]
373
- }), Y = [], ut = q.top;
374
- for (let [e, t] of n.entries()) {
375
- let n = at[e] ?? 1, r = n * 26 + 12;
376
- Y.push({
377
- lane: t,
378
- index: e,
379
- rowCount: n,
380
- start: ut,
381
- end: ut + r
382
- }), ut += r;
383
- }
384
- let dt = new Map(Y.map((e) => [e.lane.id, e])), ft = Y.map((e) => ({
385
- key: e.lane.id,
386
- position: (e.start + e.end) * P,
387
- label: e.lane.label
388
- }));
389
- function X(e) {
390
- return oe({
391
- value: e,
392
- locale: Ne,
393
- format: be
394
- });
395
- }
396
- let pt = Math.max(We, Math.floor(q.innerWidth / Ue)), mt = i(V, pt), ht = (mt.length > 0 ? mt : [V[0]]).map((e) => ({
397
- key: String(e),
398
- position: ct.position(e),
399
- label: X(e - x[0])
400
- })), gt = D !== void 0 && D.length > 0 ? new Set(D) : null, _t = Pe(T, v, _e), Z = gt ?? _t ?? null;
401
- function vt(e, t) {
402
- if (e.tone !== void 0) return e.tone;
403
- let r = e.category === void 0 ? void 0 : tt.get(e.category);
404
- return r === void 0 ? Le({
405
- id: e.laneId,
406
- tone: n[t]?.tone,
407
- index: t
408
- }) : r.tone;
409
- }
410
- let Q = v.map((e, t) => ({
411
- span: e,
412
- index: t
413
- })).toSorted((e, t) => e.span.start === t.span.start ? e.index - t.index : e.span.start - t.span.start).map((e) => e.span).map((e, t) => {
414
- let n = dt.get(e.laneId), r = n?.index ?? 0, i = it.get(e.id) ?? 0, a = (n?.start ?? q.top) + 6 + (i + P) * 26, o = ct.position(e.start), s = Math.max(o + 4, ct.position(e.end)), c = Math.max(q.left, o), l = Math.min(q.right, s), u = s >= q.left - 4 && o <= q.right + 4, d = vt(e, r), f = X(e.end - e.start), p = X(e.start - x[0]), m = L === null || e.category === L, h = Z === null || Z.has(e.id), g = m && h;
415
- return {
416
- span: e,
417
- rank: t,
418
- laneIndex: r,
419
- laneLabel: n?.lane.label ?? e.laneId,
420
- rawX1: o,
421
- rawX2: s,
422
- x1: c,
423
- x2: l,
424
- y: a,
425
- isVisible: u,
426
- tone: d,
427
- duration: f,
428
- offset: p,
429
- isEmphasized: g
430
- };
431
- }), yt = new Map(Q.map((e) => [e.span.id, e])), bt = Q.map(({ span: e, laneLabel: t, duration: n, offset: r }) => ({
432
- id: e.id,
433
- label: [
434
- t,
435
- e.label,
436
- n,
437
- `at +${r}`,
438
- e.badge,
439
- e.detail
440
- ].filter((e) => e !== void 0 && e !== "").join(" · ")
441
- })), $ = Q.find((e) => e.span.id === T), xt = 1 / (n.length * 2 + 1);
442
- function St(e) {
443
- let t = e.x / e.width * q.width, n = e.y / e.height * q.height, r, i = Infinity;
444
- for (let e of Q) {
445
- let a = t >= e.x1 - Ve && t <= e.x2 + Ve, o = Math.abs(n - e.y) <= 26 * P;
446
- if (e.isVisible && a && o) {
447
- let a = Math.max(e.x1, Math.min(e.x2, t)), o = Math.hypot(t - a, n - e.y);
448
- o <= i && (i = o, r = e.span.id);
449
- }
450
- }
451
- return r;
452
- }
453
- function Ct(e) {
454
- if (H <= 0) return;
455
- let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = Math.max(0, Math.min(1, (n - q.left) / Math.max(1, q.innerWidth)));
456
- if (e.ctrlKey || e.metaKey || e.shiftKey) {
457
- e.preventDefault();
458
- let t = Math.max(-80, Math.min(Ke, e.deltaY)), n = Math.exp(t * qe);
459
- G(ke({
460
- visible: V,
461
- domain: x,
462
- factor: n,
463
- anchorRatio: r
464
- }));
465
- } else if (W && Math.abs(e.deltaX) > Math.abs(e.deltaY)) {
466
- e.preventDefault();
467
- let t = e.deltaX / Math.max(1, q.innerWidth) * U;
468
- G(je({
469
- visible: V,
470
- domain: x,
471
- delta: t
472
- }));
473
- }
474
- }
475
- function wt(e) {
476
- if (e.button !== 0 || e.pointerType === "touch") return;
477
- let t = e.currentTarget.getBoundingClientRect();
478
- St({
479
- x: e.clientX - t.left,
480
- y: e.clientY - t.top,
481
- width: t.width,
482
- height: t.height
483
- }) === void 0 ? (z.current = {
484
- clientX: e.clientX,
485
- clientY: e.clientY,
486
- range: W ? V : null,
487
- hasDragged: !1
488
- }, W && (R(!0), e.currentTarget.setPointerCapture(e.pointerId))) : z.current = null;
489
- }
490
- function Tt(e) {
491
- let t = z.current;
492
- if (t === null) return;
493
- let n = e.clientX - t.clientX, r = e.clientY - t.clientY;
494
- if (!t.hasDragged && Math.hypot(n, r) > Je && (z.current = {
495
- ...t,
496
- hasDragged: !0
497
- }), t.range === null) return;
498
- let i = t.range[1] - t.range[0], a = -(n / Math.max(1, q.innerWidth)) * i;
499
- G(je({
500
- visible: t.range,
501
- domain: x,
502
- delta: a
503
- }));
504
- }
505
- function Et() {
506
- let e = z.current;
507
- z.current = null, R(!1), e !== null && !e.hasDragged && T != null && w?.();
508
- }
509
- function Dt() {
510
- z.current = null, R(!1);
511
- }
512
- function Ot(e) {
513
- switch (e.key) {
514
- case "+":
515
- case "=":
516
- e.preventDefault(), G(j({
517
- visible: V,
518
- domain: x,
519
- direction: "in"
520
- }));
521
- break;
522
- case "-":
523
- e.preventDefault(), G(j({
524
- visible: V,
525
- domain: x,
526
- direction: "out"
527
- }));
528
- break;
529
- case "0":
530
- e.preventDefault(), G(x);
531
- break;
532
- case "[":
533
- W && (e.preventDefault(), G(Ae({
534
- visible: V,
535
- domain: x,
536
- direction: "left"
537
- })));
538
- break;
539
- case "]":
540
- W && (e.preventDefault(), G(Ae({
541
- visible: V,
542
- domain: x,
543
- direction: "right"
544
- })));
545
- break;
546
- case "Escape":
547
- T != null && w !== void 0 && (e.preventDefault(), w());
548
- break;
549
- case "Enter": $ !== void 0 && O !== void 0 && (e.preventDefault(), O($.span));
550
- }
551
- }
552
- let kt = `${X(V[0] - x[0])} – ${X(V[1] - x[0])}`, At = /* @__PURE__ */ b(u, { children: [
553
- /* @__PURE__ */ y("span", {
554
- className: "xy8obcc x153jb6y xss6m8b xuxw1ft",
555
- children: kt
556
- }),
557
- /* @__PURE__ */ y(c, {
558
- variant: "outline",
559
- onClick: () => G(j({
560
- visible: V,
561
- domain: x,
562
- direction: "out"
563
- })),
564
- disabled: !W,
565
- "aria-label": "Zoom out",
566
- children: "−"
567
- }),
568
- /* @__PURE__ */ y(c, {
569
- variant: "outline",
570
- onClick: () => G(j({
571
- visible: V,
572
- domain: x,
573
- direction: "in"
574
- })),
575
- disabled: H <= 0,
576
- "aria-label": "Zoom in",
577
- children: "+"
578
- }),
579
- $ !== void 0 && /* @__PURE__ */ y(c, {
580
- variant: "outline",
581
- onClick: () => G(Me($.span, x)),
582
- "aria-label": "Zoom to selected span",
583
- children: "Fit span"
584
- }),
585
- W && /* @__PURE__ */ y(c, {
586
- variant: "ghost",
587
- onClick: () => G(x),
588
- "aria-label": "Reset zoom",
589
- children: "Reset"
590
- }),
591
- Ee
592
- ] }), jt = $ !== void 0 && xe !== void 0 ? xe($.span) : [], Mt = S ?? [], Nt = Mt.length > 0, Pt = O !== void 0 && jt.length === 0, Ft = $ === void 0 ? null : /* @__PURE__ */ b("div", {
593
- role: "region",
594
- "aria-label": "Selected span actions",
595
- className: "x78zum5 x1a02dak x6s0dn4 x1qughib x1hnptsi xn9t2bk x1doqdfy xmkeg23 x1y0btm7 x1ey3b81 x1ok0vyi x1r7kqkb xeuugli",
596
- children: [/* @__PURE__ */ b("div", {
597
- className: "x78zum5 x1a02dak x6s0dn4 x1hnptsi xeuugli xk30mkq",
598
- children: [
599
- /* @__PURE__ */ y("span", { ..._.props(B.swatch(p[$.tone])) }),
600
- /* @__PURE__ */ y("span", {
601
- title: $.span.label,
602
- className: "xb3r6kr xlyipyv xuxw1ft xyq1l15",
603
- children: /* @__PURE__ */ y(l, { children: $.span.label })
604
- }),
605
- /* @__PURE__ */ y("span", {
606
- className: "xy8obcc x153jb6y xss6m8b xuxw1ft",
607
- children: `${$.duration} (+${$.offset})`
608
- }),
609
- $.span.badge !== void 0 && /* @__PURE__ */ y(d, { children: $.span.badge }),
610
- $.span.detail !== void 0 && /* @__PURE__ */ y("span", {
611
- title: $.span.detail,
612
- className: "xy8obcc x153jb6y xb3r6kr xlyipyv xuxw1ft xxc7z9f",
613
- children: $.span.detail
614
- })
615
- ]
616
- }), /* @__PURE__ */ b(u, { children: [
617
- jt.map((e) => e.href === void 0 ? /* @__PURE__ */ y(c, {
618
- variant: "outline",
619
- onClick: e.onSelect,
620
- children: e.label
621
- }, e.id) : /* @__PURE__ */ y("a", {
622
- href: e.href,
623
- target: e.isExternal === !0 ? "_blank" : void 0,
624
- rel: e.isExternal === !0 ? "noreferrer" : void 0,
625
- className: "x3nfvp2 x6s0dn4 xunmzkg x1fgtraw x5g2kb4 x1ok0vyi xmkeg23 x1y0btm7 x1ey3b81 xpvm0e4 xbixft x1hz01jw xy8obcc x1hl2dhg x1ypdohk x1mkwuse",
626
- children: e.label
627
- }, e.id)),
628
- Pt && /* @__PURE__ */ y(c, {
629
- variant: "solid",
630
- onClick: () => O($.span),
631
- children: "Inspect span"
632
- }),
633
- w !== void 0 && /* @__PURE__ */ b(c, {
634
- variant: "ghost",
635
- density: "compact",
636
- onClick: w,
637
- "aria-label": "Clear selection",
638
- children: [/* @__PURE__ */ y(ve, {
639
- size: 14,
640
- "aria-hidden": !0
641
- }), "Clear"]
642
- })
643
- ] })]
644
- }), It = H > 0 ? H / Ge : 1;
645
- return /* @__PURE__ */ y(t, {
646
- ...Ye,
647
- items: bt,
648
- place: (e) => {
649
- let t = Q.find((t) => t.span.id === e), n = t?.rank ?? 0, r = (t?.laneIndex ?? 0) * xt;
650
- return t === void 0 ? void 0 : {
651
- left: n,
652
- right: n,
653
- top: r,
654
- bottom: r
655
- };
656
- },
657
- locate: St,
658
- selected: T ?? null,
659
- onSelect: E === void 0 && w === void 0 ? void 0 : (e, t) => {
660
- let n = t.event instanceof MouseEvent && t.event.detail >= 2;
661
- e === T && !n && w !== void 0 ? w() : E?.(e, t);
662
- },
663
- render: (t, { inspected: i, cursor: o }) => {
664
- let s = Q.find((e) => e.span.id === o), c = i === null ? void 0 : yt.get(i), l = c !== void 0 && c.isVisible;
665
- return /* @__PURE__ */ y(ee, {
666
- ...k,
667
- actions: At,
668
- figure: t,
669
- footer: v.length === 0 ? void 0 : /* @__PURE__ */ y(r, {
670
- id: Fe,
671
- children: e(bt, i)
672
- }),
673
- children: v.length === 0 ? /* @__PURE__ */ y(ne, { children: Te }) : /* @__PURE__ */ b("div", {
674
- className: "xrvj5dj xunmzkg xeuugli",
675
- children: [
676
- Nt && /* @__PURE__ */ y(f, {
677
- label: "Filter by span category",
678
- allLabel: "All",
679
- value: L,
680
- onValueChange: Ze,
681
- options: Mt.map((e) => ({
682
- id: e.id,
683
- label: e.label,
684
- color: p[e.tone],
685
- count: nt.get(e.id) ?? 0
686
- }))
687
- }),
688
- Se && H > 0 && /* @__PURE__ */ y("div", {
689
- ..._.props(B.minimapBox, B.minimapFrame(q.left, J)),
690
- children: /* @__PURE__ */ y(ie, {
691
- value: W ? V : null,
692
- onValueChange: (e) => G(e ?? x),
693
- min: x[0],
694
- max: x[1],
695
- step: It,
696
- describe: (e) => `${X(e[0] - x[0])} to ${X(e[1] - x[0])}`,
697
- label: `${A} zoom minimap`,
698
- left: 0,
699
- width: J,
700
- height: N,
701
- children: /* @__PURE__ */ y("svg", {
702
- "aria-hidden": !0,
703
- width: J,
704
- height: N,
705
- viewBox: `0 0 ${J} ${N}`,
706
- className: "x1lliihq xh8yej3 x5kalc8 x87ps6o",
707
- children: Q.map((e) => {
708
- let t = lt.position(e.span.start), r = Math.max(t + 2, lt.position(e.span.end)), i = Be + (n.length > 1 ? e.laneIndex / (n.length - 1) : P) * 26;
709
- return /* @__PURE__ */ y("rect", {
710
- x: t,
711
- y: i,
712
- width: Math.max(2, r - t),
713
- height: ze,
714
- rx: F,
715
- ..._.props(B.minimapBar(p[e.tone]))
716
- }, `mini-${e.span.id}`);
717
- })
718
- })
719
- })
720
- }),
721
- /* @__PURE__ */ y("div", {
722
- onWheel: Ct,
723
- onPointerDown: wt,
724
- onPointerMove: Tt,
725
- onPointerUp: Et,
726
- onPointerCancel: Dt,
727
- onKeyDown: Ot,
728
- onDoubleClick: () => {
729
- $ !== void 0 && O !== void 0 && O($.span);
730
- },
731
- ...{
732
- 0: { className: "x1n2onr6 xeuugli x1t137rt" },
733
- 2: { className: "x1n2onr6 xeuugli x1t137rt x1jm3nie" },
734
- 1: { className: "x1n2onr6 xeuugli x1t137rt xi9pz9s x87ps6o" },
735
- 3: { className: "x1n2onr6 xeuugli x1t137rt xi9pz9s x87ps6o" }
736
- }[!!W << 1 | !!Qe],
737
- children: /* @__PURE__ */ b(ue, {
738
- plotRef: M.ref,
739
- box: q,
740
- label: a({
741
- title: A,
742
- marks: "spans",
743
- isSelectable: E !== void 0
744
- }),
745
- readoutId: Fe,
746
- overlay: l ? /* @__PURE__ */ y($e, {
747
- mark: c,
748
- box: q
749
- }) : void 0,
750
- children: [
751
- Y.map((e, t) => t % 2 == 1 ? /* @__PURE__ */ y("rect", {
752
- x: q.left,
753
- y: e.start,
754
- width: q.innerWidth,
755
- height: e.end - e.start,
756
- className: "x2wnxhi x6b6j1m x47corl"
757
- }, `band-${e.lane.id}`) : null),
758
- /* @__PURE__ */ y(ce, {
759
- box: q,
760
- xTicks: ht,
761
- yTicks: ft,
762
- xTitle: Ce,
763
- grid: "x"
764
- }),
765
- Y.slice(1).map((e) => /* @__PURE__ */ y("line", {
766
- x1: q.left,
767
- x2: q.right,
768
- y1: e.start,
769
- y2: e.start,
770
- ..._.props(ae.grid, B.separator)
771
- }, e.lane.id)),
772
- /* @__PURE__ */ b(fe, {
773
- box: q,
774
- children: [
775
- Y.map((e) => Array.from({ length: e.rowCount }, (t, n) => /* @__PURE__ */ y("rect", {
776
- x: q.left,
777
- y: e.start + 6 + n * 26 + 8 * P,
778
- width: q.innerWidth,
779
- height: 18,
780
- rx: F,
781
- className: "xzmcrz1 xbd1tli x47corl"
782
- }, `track-${e.lane.id}-${n}`))),
783
- Q.map((e) => {
784
- if (!e.isVisible) return null;
785
- let t = Math.max(4, e.x2 - e.x1);
786
- return /* @__PURE__ */ y(le, {
787
- mark: e.span.id,
788
- x: e.x1,
789
- y: e.y - 18 * P,
790
- width: t,
791
- height: 18,
792
- rx: F,
793
- tone: e.tone,
794
- emphasis: e.isEmphasized ? "normal" : "receded",
795
- isInspected: i === e.span.id,
796
- isSelected: T === e.span.id
797
- }, e.span.id);
798
- }),
799
- (_e ?? []).map((e) => {
800
- let t = yt.get(e.fromSpanId), n = yt.get(e.toSpanId);
801
- if (t === void 0 || n === void 0) return null;
802
- let r = Math.min(t.rawX1, n.rawX1);
803
- if (Math.max(t.rawX2, n.rawX2) < q.left - 4 || r > q.right + 4) return null;
804
- let i = Ie({
805
- from: {
806
- x1: t.rawX1,
807
- x2: t.rawX2,
808
- y: t.y
809
- },
810
- to: {
811
- x1: n.rawX1,
812
- x2: n.rawX2,
813
- y: n.y
814
- }
815
- }), a = p[e.tone ?? "positive"], o = Z === null ? t.isEmphasized || n.isEmphasized : Z.has(e.fromSpanId) || Z.has(e.toSpanId);
816
- return /* @__PURE__ */ b("g", {
817
- ..._.props(ae.emphasis, B.linkGroup, !o && B.linkGroupReceded),
818
- children: [
819
- e.label !== void 0 && e.label.length > 0 && /* @__PURE__ */ y("title", { children: e.label }),
820
- /* @__PURE__ */ y("path", {
821
- d: i.path,
822
- stroke: a,
823
- className: "xbh8q5q xhr4kjn x1owpc8m x1f6yumg x13efnbd"
824
- }),
825
- /* @__PURE__ */ y("path", {
826
- d: i.arrowPath,
827
- stroke: a,
828
- className: "xbh8q5q xhr4kjn x1owpc8m x1f6yumg x13efnbd"
829
- })
830
- ]
831
- }, e.id);
832
- })
833
- ]
834
- }),
835
- l && /* @__PURE__ */ y("line", {
836
- x1: c.x1,
837
- x2: c.x1,
838
- y1: q.top,
839
- y2: q.bottom,
840
- className: "xhq4mlf x17ub4bw xnpr05h x47corl x13efnbd"
841
- }),
842
- s !== void 0 && s.isVisible && /* @__PURE__ */ y(m, {
843
- x: (s.x1 + s.x2) * P,
844
- top: q.top,
845
- bottom: q.bottom,
846
- width: He
847
- })
848
- ]
849
- })
850
- }),
851
- Ft,
852
- /* @__PURE__ */ y(g, {
853
- label: `${A} spans`,
854
- columns: [{
855
- id: "span",
856
- label: "Span"
857
- }],
858
- rows: bt.map((e) => ({
859
- id: e.id,
860
- values: [e.label]
861
- }))
862
- })
863
- ]
864
- })
865
- });
866
- }
867
- });
868
- }
869
- export { x as n, et as t };