@cccsaurora/clue-ui 1.2.4 → 1.2.5-dev.298

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 (188) hide show
  1. package/ActionForm-D6gYuFRR.js +5970 -0
  2. package/AnnotationDetails-Zx4pjBiN.js +175 -0
  3. package/AnnotationPreview-Dmz7taAU.js +188 -0
  4. package/ClueEnrichContext-CJEJxrgs.js +541 -0
  5. package/FlexOne-BSYAhhtG.js +9 -0
  6. package/_MapCache-WmuDdwuH.js +222 -0
  7. package/_Uint8Array-B7JqpgFX.js +128 -0
  8. package/_baseAssignValue-CGTuELqU.js +25 -0
  9. package/_baseClone-CkNrTyhm.js +283 -0
  10. package/_baseExtremum-kob8QXyt.js +18 -0
  11. package/_baseFlatten-jIR_sN_-.js +92 -0
  12. package/_baseGet-Bx3A4Qfp.js +108 -0
  13. package/_baseIsEqual-C5OTWzTk.js +208 -0
  14. package/_baseIteratee-avi7MX2o.js +126 -0
  15. package/_baseSlice-GAv_YFTT.js +20 -0
  16. package/_baseSum-D0WC1dN0.js +13 -0
  17. package/_baseUniq-BI9GIHMF.js +115 -0
  18. package/_commonjsHelpers-DWwsNxpa.js +8 -0
  19. package/_createAggregator-QD8MzKwe.js +63 -0
  20. package/_getPrototype-CU0j_POw.js +5 -0
  21. package/_getTag-Ckxxfr88.js +126 -0
  22. package/_isIterateeCall-Ds3sw2SF.js +17 -0
  23. package/_setToArray-CaPKQhcz.js +33 -0
  24. package/cloneDeep-DJrLSw8W.js +8 -0
  25. package/components/AnnotationBody.js +49 -35
  26. package/components/AnnotationDetailPopover.js +36 -30
  27. package/components/AnnotationDetails.js +7 -7
  28. package/components/AnnotationEntry.js +35 -35
  29. package/components/AnnotationPreview.js +5 -5
  30. package/components/ClassificationChip.js +44 -23
  31. package/components/CountBadge.js +31 -26
  32. package/components/EnrichedCard.js +110 -97
  33. package/components/EnrichedChip.js +130 -105
  34. package/components/EnrichedTypography.js +133 -107
  35. package/components/ErrorBoundary.js +28 -24
  36. package/components/RetryFailedEnrichments.js +10 -9
  37. package/components/SourcePicker.js +57 -49
  38. package/components/actions/ActionForm.js +4 -4
  39. package/components/actions/ExecutePopover.js +75 -59
  40. package/components/actions/ResultModal.js +4 -4
  41. package/components/actions/form/schemaAdapter.js +39 -23
  42. package/components/actions/formats/FileResult.js +86 -59
  43. package/components/actions/formats/index.js +21 -10
  44. package/components/display/graph/ExpandMoreButton.js +10 -10
  45. package/components/display/graph/elements/NodeCard.js +111 -91
  46. package/components/display/graph/elements/NodeTag.js +15 -13
  47. package/components/display/graph/index.js +261 -202
  48. package/components/display/graph/visualizations/Leaf.js +88 -69
  49. package/components/display/graph/visualizations/cloud/index.js +98 -81
  50. package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
  51. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  53. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  54. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  55. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  56. package/components/display/graph/visualizations/icons/index.js +14 -13
  57. package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
  58. package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
  59. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  60. package/components/display/graph/visualizations/tree/index.js +408 -306
  61. package/components/display/icons/Iconified.js +27 -12
  62. package/components/display/json/index.js +4 -4
  63. package/components/display/markdown/index.js +8678 -5770
  64. package/components/enrichment/EnrichPopover.js +54 -46
  65. package/components/fetchers/Fetcher.js +158 -119
  66. package/components/fetchers/PreviewModal.js +20 -17
  67. package/components/fetchers/StatusChip.js +21 -17
  68. package/components/group/Entry.js +13 -11
  69. package/components/group/Group.js +13 -10
  70. package/components/group/GroupControl.js +76 -65
  71. package/components/stats/QueryStatus.js +43 -33
  72. package/countBy-c6S3dvSW.js +14 -0
  73. package/data/event.js +6 -4
  74. package/database/index.js +2 -2
  75. package/debounce-bV0h5FC5.js +92 -0
  76. package/get-DSsNkRQs.js +8 -0
  77. package/groupBy-xqz-n0Vd.js +14 -0
  78. package/hooks/ClueActionContext.d.ts +10 -2
  79. package/hooks/ClueActionContext.js +6 -6
  80. package/hooks/ClueComponentContext.js +29 -23
  81. package/hooks/ClueConfigProvider.js +14 -12
  82. package/hooks/ClueDatabaseContext.js +19 -13
  83. package/hooks/ClueEnrichContext.js +8 -8
  84. package/hooks/ClueFetcherContext.js +83 -56
  85. package/hooks/ClueGroupContext.js +17 -14
  86. package/hooks/CluePopupContext.js +5 -5
  87. package/hooks/ClueProvider.js +12 -10
  88. package/hooks/selectors.js +7 -7
  89. package/hooks/useActionResult.d.ts +1 -0
  90. package/hooks/useActionResult.js +3 -3
  91. package/hooks/useAnnotations.js +47 -31
  92. package/hooks/useClue.js +6 -4
  93. package/hooks/useClueActions.js +3 -3
  94. package/hooks/useClueConfig.js +6 -4
  95. package/hooks/useClueTypeConfig.js +3 -3
  96. package/hooks/useComparator.js +722 -435
  97. package/hooks/useErrors.js +22 -18
  98. package/hooks/useFetcherResult.d.ts +1 -0
  99. package/hooks/useFetcherResult.js +33 -24
  100. package/hooks/useMyHighlights.js +66 -36
  101. package/hooks/useMyLocalStorage.js +66 -37
  102. package/iconify-CXMreGTg.js +1782 -0
  103. package/icons/Action.js +66 -49
  104. package/icons/Assessment.js +85 -69
  105. package/icons/Context.js +77 -63
  106. package/icons/Opinion.js +76 -60
  107. package/icons/iconMap.js +2 -2
  108. package/identity-CPGTqrE4.js +6 -0
  109. package/index-AMfoEg_6.js +696 -0
  110. package/index-B6C2a_Lg.js +1172 -0
  111. package/index-C12gPw2W.js +17698 -0
  112. package/index-DCKkHTvx.js +15750 -0
  113. package/index-JcKyZeoY.js +465 -0
  114. package/isNil-CIubwp4T.js +6 -0
  115. package/isObject-FTY-5JQX.js +7 -0
  116. package/isObjectLike-OAgjjZye.js +48 -0
  117. package/isSymbol-Xd2FsJyp.js +8 -0
  118. package/last-CUCl67Im.js +7 -0
  119. package/main.js +60 -60
  120. package/maxBy-IKHzFrCS.js +8 -0
  121. package/package.json +1 -1
  122. package/sortBy-DfSj8IoJ.js +96 -0
  123. package/sumBy-D-hb_NY-.js +8 -0
  124. package/text/Frequency.js +42 -23
  125. package/toFinite-Bc55msYj.js +16 -0
  126. package/toNumber-DPxy1FBy.js +39 -0
  127. package/types/RunningActionData.d.ts +1 -0
  128. package/types/WithActionData.d.ts +1 -0
  129. package/useClueTypeConfig-Z1LFp01b.js +3289 -0
  130. package/utils/chain.js +92 -65
  131. package/utils/classificationParser.js +519 -256
  132. package/utils/constants.js +35 -10
  133. package/utils/graph.js +72 -45
  134. package/utils/hashUtil.js +7 -7
  135. package/utils/line.js +131 -81
  136. package/utils/loggerUtil.js +5 -3
  137. package/utils/sessionStorage.js +41 -27
  138. package/utils/time.js +423 -423
  139. package/utils/utils.js +9 -9
  140. package/utils/window.js +21 -10
  141. package/utils-HmNPuoDB.js +199 -0
  142. package/ActionForm-CwsfB99X.js +0 -4458
  143. package/AnnotationDetails-Bw2JdtTL.js +0 -160
  144. package/AnnotationPreview-BO7rVnOP.js +0 -140
  145. package/ClueEnrichContext-KqRuuWNS.js +0 -418
  146. package/FlexOne-BXWFOd1T.js +0 -6
  147. package/_MapCache-BiTi0iqu.js +0 -180
  148. package/_Uint8Array-BQNOM9Rr.js +0 -101
  149. package/_baseAssignValue-CNMLQZco.js +0 -20
  150. package/_baseClone-BnT-6pyM.js +0 -207
  151. package/_baseExtremum-Ca2EHgy2.js +0 -16
  152. package/_baseFlatten-Bfr_Molw.js +0 -72
  153. package/_baseGet-DSZygzyq.js +0 -79
  154. package/_baseIsEqual-VgvaAFZG.js +0 -147
  155. package/_baseIteratee-Dbfsw5z8.js +0 -95
  156. package/_baseSlice-M5RKzt1A.js +0 -10
  157. package/_baseSum-wEbgNeUs.js +0 -10
  158. package/_baseUniq-BJcj69PL.js +0 -79
  159. package/_commonjsHelpers-DaMA6jEr.js +0 -8
  160. package/_createAggregator-k3TuAnxT.js +0 -53
  161. package/_getPrototype-Cr1Mk7BC.js +0 -5
  162. package/_getTag-CK2Sffaq.js +0 -90
  163. package/_isIterateeCall-DkJP7Rbx.js +0 -13
  164. package/_setToArray-C7yMOeww.js +0 -29
  165. package/cloneDeep-CF8TtLHr.js +0 -8
  166. package/countBy-CdYegFSu.js +0 -8
  167. package/debounce-DryYcbJ4.js +0 -56
  168. package/get-CH7kz5Ix.js +0 -8
  169. package/groupBy-br8xmD2R.js +0 -8
  170. package/iconify-BBckr5AQ.js +0 -1263
  171. package/identity-ByMq8VxU.js +0 -6
  172. package/index-BHAe_V9n.js +0 -12768
  173. package/index-BK-zfYhR.js +0 -358
  174. package/index-CA5CUNZO.js +0 -975
  175. package/index-Dj5C04IX.js +0 -568
  176. package/index-p5_wX7q1.js +0 -11729
  177. package/isNil-CjWwlQS3.js +0 -6
  178. package/isObject-B53jY8Qg.js +0 -7
  179. package/isObjectLike-BatpeCIi.js +0 -29
  180. package/isSymbol-C3_SC0Qp.js +0 -8
  181. package/last-7CdUxN0r.js +0 -7
  182. package/maxBy-Bc0dYHcO.js +0 -8
  183. package/sortBy-DY2JBf9n.js +0 -75
  184. package/sumBy-DuMASLPd.js +0 -8
  185. package/toFinite-BMy6GObD.js +0 -14
  186. package/toNumber-YVhnnJv4.js +0 -31
  187. package/useClueTypeConfig-Ct9Ygter.js +0 -2292
  188. package/utils-DmwSUrum.js +0 -129
@@ -1,41 +1,55 @@
1
- import { jsxs as it, jsx as L, Fragment as At } from "react/jsx-runtime";
2
- import { useTheme as Bt, colors as wt, Box as Ft } from "@mui/material";
3
- import It from "../../../../../hooks/useComparator.js";
4
- import Wt from "../../../../../hooks/useMyHighlights.js";
5
- import { useMyLocalStorageItem as Ot } from "../../../../../hooks/useMyLocalStorage.js";
6
- import { StorageKey as Pt, BUNDLE_SEPARATOR as Ht } from "../../../../../utils/constants.js";
7
- import { c as Xt } from "../../../../../cloneDeep-CF8TtLHr.js";
8
- import { g as Tt } from "../../../../../get-CH7kz5Ix.js";
9
- import { i as Yt } from "../../../../../isNil-CjWwlQS3.js";
10
- import { b as $t, a as jt } from "../../../../../_baseExtremum-Ca2EHgy2.js";
11
- import { i as Nt } from "../../../../../identity-ByMq8VxU.js";
12
- import { i as Ut } from "../../../../../_isIterateeCall-DkJP7Rbx.js";
13
- import { t as et } from "../../../../../toFinite-BMy6GObD.js";
14
- import { b as Gt } from "../../../../../_baseSum-wEbgNeUs.js";
15
- import { memo as Vt, useMemo as S } from "react";
16
- import qt from "../../elements/NodeCard.js";
17
- import zt from "../icons/index.js";
18
- import Jt from "../Leaf.js";
19
- import Qt from "./BundleLine.js";
20
- function kt(c) {
21
- return c && c.length ? $t(c, Nt, jt) : void 0;
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useTheme, colors, Box } from "@mui/material";
3
+ import useComparator from "../../../../../hooks/useComparator.js";
4
+ import useMyHighlights from "../../../../../hooks/useMyHighlights.js";
5
+ import { useMyLocalStorageItem } from "../../../../../hooks/useMyLocalStorage.js";
6
+ import { StorageKey, BUNDLE_SEPARATOR } from "../../../../../utils/constants.js";
7
+ import { c as cloneDeep } from "../../../../../cloneDeep-DJrLSw8W.js";
8
+ import { g as get } from "../../../../../get-DSsNkRQs.js";
9
+ import { i as isNil } from "../../../../../isNil-CIubwp4T.js";
10
+ import { b as baseExtremum, a as baseGt } from "../../../../../_baseExtremum-kob8QXyt.js";
11
+ import { i as identity } from "../../../../../identity-CPGTqrE4.js";
12
+ import { i as isIterateeCall } from "../../../../../_isIterateeCall-Ds3sw2SF.js";
13
+ import { t as toFinite } from "../../../../../toFinite-Bc55msYj.js";
14
+ import { b as baseSum } from "../../../../../_baseSum-D0WC1dN0.js";
15
+ import { memo, useMemo } from "react";
16
+ import NodeCard from "../../elements/NodeCard.js";
17
+ import getIcon from "../icons/index.js";
18
+ import Leaf from "../Leaf.js";
19
+ import BundleLine from "./BundleLine.js";
20
+ function max(array) {
21
+ return array && array.length ? baseExtremum(array, identity, baseGt) : void 0;
22
22
  }
23
- var Zt = Math.ceil, Kt = Math.max;
24
- function ti(c, n, r, h) {
25
- for (var d = -1, _ = Kt(Zt((n - c) / (r || 1)), 0), v = Array(_); _--; )
26
- v[++d] = c, c += r;
27
- return v;
23
+ var nativeCeil = Math.ceil, nativeMax = Math.max;
24
+ function baseRange(start, end, step, fromRight) {
25
+ var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result = Array(length);
26
+ while (length--) {
27
+ result[++index] = start;
28
+ start += step;
29
+ }
30
+ return result;
28
31
  }
29
- function ii(c) {
30
- return function(n, r, h) {
31
- return h && typeof h != "number" && Ut(n, r, h) && (r = h = void 0), n = et(n), r === void 0 ? (r = n, n = 0) : r = et(r), h = h === void 0 ? n < r ? 1 : -1 : et(h), ti(n, r, h);
32
+ function createRange(fromRight) {
33
+ return function(start, end, step) {
34
+ if (step && typeof step != "number" && isIterateeCall(start, end, step)) {
35
+ end = step = void 0;
36
+ }
37
+ start = toFinite(start);
38
+ if (end === void 0) {
39
+ end = start;
40
+ start = 0;
41
+ } else {
42
+ end = toFinite(end);
43
+ }
44
+ step = step === void 0 ? start < end ? 1 : -1 : toFinite(step);
45
+ return baseRange(start, end, step);
32
46
  };
33
47
  }
34
- var ei = ii();
35
- function ni(c) {
36
- return c && c.length ? Gt(c, Nt) : 0;
48
+ var range = createRange();
49
+ function sum(array) {
50
+ return array && array.length ? baseSum(array, identity) : 0;
37
51
  }
38
- const nt = {
52
+ const DEFAULT_OPTIONS = {
39
53
  textColor: "white",
40
54
  nodeColor: {
41
55
  border: "grey",
@@ -50,335 +64,423 @@ const nt = {
50
64
  linePaddingX: 10,
51
65
  linePaddingY: 10,
52
66
  lineWidth: 3,
53
- enableEntryPadding: !0,
54
- truncateLabels: !0,
55
- enableTimestamps: !0,
67
+ enableEntryPadding: true,
68
+ truncateLabels: true,
69
+ enableTimestamps: true,
56
70
  iconOrientation: "vertical",
57
71
  lineDirection: "horizontal",
58
72
  rowStep: null,
59
73
  // We'll make this dynamic
60
- belowPrevious: !1
74
+ belowPrevious: false
61
75
  };
62
- nt.rowStep = nt.ySpacing * 2;
63
- const ai = ({ svgRef: c, graph: n, labelKeys: r, onNodeSelectionChanged: h, zoom: d, options: _ = {} }) => {
64
- var gt, xt, vt;
65
- const v = S(
76
+ DEFAULT_OPTIONS.rowStep = DEFAULT_OPTIONS.ySpacing * 2;
77
+ const Tree = ({ svgRef, graph, labelKeys, onNodeSelectionChanged, zoom, options = {} }) => {
78
+ var _a, _b, _c;
79
+ const combinedOptions = useMemo(
66
80
  () => {
67
- var i, o;
81
+ var _a2, _b2;
68
82
  return {
69
- ...nt,
70
- ..._,
71
- ...((o = (i = n == null ? void 0 : n.metadata.display) == null ? void 0 : i.visualization) == null ? void 0 : o.config) ?? {}
83
+ ...DEFAULT_OPTIONS,
84
+ ...options,
85
+ ...((_b2 = (_a2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a2.visualization) == null ? void 0 : _b2.config) ?? {}
72
86
  };
73
87
  },
74
- [(xt = (gt = n == null ? void 0 : n.metadata.display) == null ? void 0 : gt.visualization) == null ? void 0 : xt.config, _]
75
- ), {
76
- xSpacing: at,
77
- ySpacing: ot,
78
- linePaddingX: rt,
79
- linePaddingY: st
80
- } = v, { runComparators: lt, runComparator: W } = It(), { onNodeHoveredChanged: A, onNodeClicked: ct, nodeOpacities: H, highlightedPath: dt, highlightedNodes: ft, hoveredNode: pt } = Wt(n, (i) => h(i)), u = Bt(), ut = S(() => u.palette.mode === "dark", [u]), [X] = Ot(Pt.SHOW_CARDS, !1), [mt] = Ot(Pt.CARD_CUTOFF, 2.5), Y = S(() => d.k > mt && X, [mt, X, d.k]), w = S(
81
- () => n.data.map(
82
- (i, o) => i.map((l) => ({
83
- ...l,
84
- parents: l == null ? void 0 : l.edges,
85
- level: o
88
+ [(_b = (_a = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a.visualization) == null ? void 0 : _b.config, options]
89
+ );
90
+ const {
91
+ xSpacing: baseXSpacing,
92
+ ySpacing: baseYSpacing,
93
+ linePaddingX: baseLinePaddingX,
94
+ linePaddingY: baseLinePaddingY
95
+ } = combinedOptions;
96
+ const { runComparators, runComparator } = useComparator();
97
+ const { onNodeHoveredChanged, onNodeClicked, nodeOpacities, highlightedPath, highlightedNodes, hoveredNode } = useMyHighlights(graph, (nodeIds) => onNodeSelectionChanged(nodeIds));
98
+ const theme = useTheme();
99
+ const isDark = useMemo(() => theme.palette.mode === "dark", [theme]);
100
+ const [showCardsSettings] = useMyLocalStorageItem(StorageKey.SHOW_CARDS, false);
101
+ const [cardCutoff] = useMyLocalStorageItem(StorageKey.CARD_CUTOFF, 2.5);
102
+ const showCards = useMemo(() => zoom.k > cardCutoff && showCardsSettings, [cardCutoff, showCardsSettings, zoom.k]);
103
+ const levels = useMemo(
104
+ () => graph.data.map(
105
+ (level, levelIndex) => level.map((node) => ({
106
+ ...node,
107
+ parents: node == null ? void 0 : node.edges,
108
+ level: levelIndex
86
109
  }))
87
110
  ),
88
- [n.data]
89
- ), C = S(() => w.flat(), [w]), [$, j, ht, M] = S(() => {
90
- const i = [
91
- [at, rt],
92
- [ot, st]
111
+ [graph.data]
112
+ );
113
+ const flatNodes = useMemo(() => levels.flat(), [levels]);
114
+ const [xSpacing, linePaddingX, ySpacing, linePaddingY] = useMemo(() => {
115
+ const baseValues = [
116
+ [baseXSpacing, baseLinePaddingX],
117
+ [baseYSpacing, baseLinePaddingY]
93
118
  ];
94
- return d.k > 1 && X ? i.flatMap(
95
- (o, l) => o.map((s) => s * Math.pow(2.5 - l * 1.25, Math.min(d.k, 2.5) - 1))
96
- ) : i.flat();
97
- }, [rt, st, at, ot, X, d.k]);
98
- let B;
99
- if (!n || !c.current)
100
- B = [
119
+ if (zoom.k > 1 && showCardsSettings) {
120
+ return baseValues.flatMap(
121
+ (arr, index) => arr.map((_v) => _v * Math.pow(2.5 - index * 1.25, Math.min(zoom.k, 2.5) - 1))
122
+ );
123
+ } else {
124
+ return baseValues.flat();
125
+ }
126
+ }, [baseLinePaddingX, baseLinePaddingY, baseXSpacing, baseYSpacing, showCardsSettings, zoom.k]);
127
+ let portBounds;
128
+ if (!graph || !svgRef.current) {
129
+ portBounds = [
101
130
  [0, 0],
102
131
  [0, 0]
103
132
  ];
104
- else {
105
- const i = c.current.getBoundingClientRect();
106
- B = [d.invert([0, 0]), d.invert([i.width, i.height])];
133
+ } else {
134
+ const data = svgRef.current.getBoundingClientRect();
135
+ portBounds = [zoom.invert([0, 0]), zoom.invert([data.width, data.height])];
107
136
  }
108
- const U = S(() => {
109
- const i = {};
110
- return C.forEach((o) => {
111
- if (!o.parents)
137
+ const bundles = useMemo(() => {
138
+ const bundlesDict = {};
139
+ flatNodes.forEach((node) => {
140
+ if (!node.parents) {
112
141
  return;
113
- const l = o.parents.join(Ht);
114
- i[l] ? i[l].destinations.push(o) : i[l] = {
115
- id: l,
116
- sources: o.parents.map((s) => C.find((E) => E.id === s)),
117
- destinations: [o]
118
- };
119
- }), Object.values(i);
120
- }, [C]), G = S(() => {
142
+ }
143
+ const bundleId = node.parents.join(BUNDLE_SEPARATOR);
144
+ if (bundlesDict[bundleId]) {
145
+ bundlesDict[bundleId].destinations.push(node);
146
+ } else {
147
+ bundlesDict[bundleId] = {
148
+ id: bundleId,
149
+ sources: node.parents.map((parent) => flatNodes.find((_node) => _node.id === parent)),
150
+ destinations: [node]
151
+ };
152
+ }
153
+ });
154
+ return Object.values(bundlesDict);
155
+ }, [flatNodes]);
156
+ const layoutData = useMemo(() => {
121
157
  const {
122
- letterSize: i,
123
- letterWidth: o,
124
- enableEntryPadding: l,
125
- truncateLabels: s,
126
- rowStep: E,
127
- belowPrevious: F
128
- } = v;
129
- let V = 0, O = 0;
130
- const P = {}, T = {}, R = {}, k = {}, D = {};
131
- return w.forEach((e, a) => {
132
- let b = 0;
133
- e.forEach((f) => {
134
- var q;
135
- const g = r == null ? void 0 : r.filter((t) => W(t, f)), m = (q = g == null ? void 0 : g.pop()) == null ? void 0 : q.label, p = (m == null ? void 0 : m.split(",").map((t) => Tt(f, t)).filter((t) => !!t)) ?? [];
136
- p.length < 1 && f.id.split(`
137
- `).forEach((t) => p.push(t));
138
- const I = p.length * i;
139
- O += I, P[f.id] = [+V, +O, -M], O += ht, l && (b = Math.max(b, kt((p == null ? void 0 : p.map((t) => t.toString().length)) ?? [f.id.length])));
140
- }), V += $ + (s ? Math.min(b, 44) : b) * o, F ? O += E : O = (a + 1) * E;
141
- }), U.forEach((e) => {
142
- e.sources.forEach((a) => {
143
- D[a.id] || (D[a.id] = /* @__PURE__ */ new Set()), D[a.id].add(e.id);
144
- }), e.destinations.forEach((a) => {
145
- Yt(T[a.level]) && (T[a.level] = /* @__PURE__ */ new Set()), k[a.id] || (k[a.id] = /* @__PURE__ */ new Set()), T[a.level].add(e.id), k[a.id].add(e.id);
158
+ letterSize,
159
+ letterWidth,
160
+ enableEntryPadding,
161
+ truncateLabels,
162
+ rowStep,
163
+ belowPrevious
164
+ } = combinedOptions;
165
+ let currentX = 0;
166
+ let currentY = 0;
167
+ const nodeLocations = {};
168
+ const linesByLevel = {};
169
+ const paddingByLevel = {};
170
+ const inputs = {};
171
+ const outputs = {};
172
+ levels.forEach((level, levelIndex) => {
173
+ let longestLabel = 0;
174
+ level.forEach((node) => {
175
+ var _a2;
176
+ const validKeys = labelKeys == null ? void 0 : labelKeys.filter((_comparator) => runComparator(_comparator, node));
177
+ const labelKey = (_a2 = validKeys == null ? void 0 : validKeys.pop()) == null ? void 0 : _a2.label;
178
+ const labelRows = (labelKey == null ? void 0 : labelKey.split(",").map((key) => get(node, key)).filter((val) => !!val)) ?? [];
179
+ if (labelRows.length < 1) {
180
+ node.id.split("\n").forEach((line) => labelRows.push(line));
181
+ }
182
+ const labelHeight = labelRows.length * letterSize;
183
+ currentY += labelHeight;
184
+ nodeLocations[node.id] = [+currentX, +currentY, -linePaddingY];
185
+ currentY += ySpacing;
186
+ if (enableEntryPadding) {
187
+ longestLabel = Math.max(longestLabel, max((labelRows == null ? void 0 : labelRows.map((row) => row.toString().length)) ?? [node.id.length]));
188
+ }
146
189
  });
147
- }), Object.entries(T).forEach(([e, a]) => R[e] = a.size), w.forEach((e, a) => {
148
- const f = ei(a + 1).map((m) => R[m] ?? 0), g = ni(f) * j;
149
- e.forEach((m) => {
150
- P[m.id][0] += g;
190
+ currentX += xSpacing + (!truncateLabels ? longestLabel : Math.min(longestLabel, 44)) * letterWidth;
191
+ if (!belowPrevious) {
192
+ currentY = (levelIndex + 1) * rowStep;
193
+ } else {
194
+ currentY += rowStep;
195
+ }
196
+ });
197
+ bundles.forEach((bundle) => {
198
+ bundle.sources.forEach((source) => {
199
+ if (!outputs[source.id]) {
200
+ outputs[source.id] = /* @__PURE__ */ new Set();
201
+ }
202
+ outputs[source.id].add(bundle.id);
151
203
  });
152
- }), C.forEach((e) => {
153
- var f, g, m;
154
- let a = kt([((f = k[e.id]) == null ? void 0 : f.size) - 1, ((g = D[e.id]) == null ? void 0 : g.size) - 1, 0]) * M;
155
- (m = k[e.id]) != null && m.has(e.id) && (a += M), P[e.id][2] = a;
156
- const b = w[e.level].findIndex((p) => p.id === e.id);
157
- w[e.level].filter((p, I) => b < I).forEach((p) => {
158
- P[p.id][1] += a;
204
+ bundle.destinations.forEach((dest) => {
205
+ if (isNil(linesByLevel[dest.level])) {
206
+ linesByLevel[dest.level] = /* @__PURE__ */ new Set();
207
+ }
208
+ if (!inputs[dest.id]) {
209
+ inputs[dest.id] = /* @__PURE__ */ new Set();
210
+ }
211
+ linesByLevel[dest.level].add(bundle.id);
212
+ inputs[dest.id].add(bundle.id);
159
213
  });
160
- }), {
161
- nodeLocations: P,
162
- linesByLevel: T,
163
- paddingByLevel: R
214
+ });
215
+ Object.entries(linesByLevel).forEach(([level, lines]) => paddingByLevel[level] = lines.size);
216
+ levels.forEach((level, levelIndex) => {
217
+ const indexesSoFar = range(levelIndex + 1);
218
+ const paddingArray = indexesSoFar.map((_levelIndex) => paddingByLevel[_levelIndex] ?? 0);
219
+ const totalPadding = sum(paddingArray) * linePaddingX;
220
+ level.forEach((node) => {
221
+ nodeLocations[node.id][0] += totalPadding;
222
+ });
223
+ });
224
+ flatNodes.forEach((node) => {
225
+ var _a2, _b2, _c2;
226
+ let maxHeight = max([((_a2 = inputs[node.id]) == null ? void 0 : _a2.size) - 1, ((_b2 = outputs[node.id]) == null ? void 0 : _b2.size) - 1, 0]) * linePaddingY;
227
+ if ((_c2 = inputs[node.id]) == null ? void 0 : _c2.has(node.id)) {
228
+ maxHeight += linePaddingY;
229
+ }
230
+ nodeLocations[node.id][2] = maxHeight;
231
+ const levelIndex = levels[node.level].findIndex((_node) => _node.id === node.id);
232
+ levels[node.level].filter((__, index) => levelIndex < index).forEach((_node) => {
233
+ nodeLocations[_node.id][1] += maxHeight;
234
+ });
235
+ });
236
+ return {
237
+ nodeLocations,
238
+ linesByLevel,
239
+ paddingByLevel
164
240
  };
165
241
  }, [
166
- U,
167
- v,
168
- C,
169
- r,
170
- w,
171
- j,
172
- M,
173
- W,
174
- $,
175
- ht
176
- ]), [Mt, Rt, Dt] = S(() => {
242
+ bundles,
243
+ combinedOptions,
244
+ flatNodes,
245
+ labelKeys,
246
+ levels,
247
+ linePaddingX,
248
+ linePaddingY,
249
+ runComparator,
250
+ xSpacing,
251
+ ySpacing
252
+ ]);
253
+ const [timestamps, bundleElements, nodes] = useMemo(() => {
177
254
  const {
178
- textColor: i,
179
- letterSize: o,
180
- letterWidth: l,
181
- nodeRadius: s,
182
- nodeColor: E,
183
- maxArcRadius: F,
184
- lineWidth: V,
185
- truncateLabels: O,
186
- enableTimestamps: P,
187
- belowPrevious: T,
188
- iconOrientation: R,
189
- lineDirection: k,
190
- colorTheme: D
191
- } = v, { nodeLocations: e, linesByLevel: a, paddingByLevel: b } = G, f = [], g = [];
192
- C.forEach((t) => {
193
- var St, Ct, bt, Et;
194
- const [yt, z, Z] = e[t.id], K = ((St = r == null ? void 0 : r.filter((y) => W(y, t)).pop()) == null ? void 0 : St.label) ?? "id";
195
- let J = K == null ? void 0 : K.split(",").map((y) => {
196
- let x = Tt(t, y);
197
- return x && O && x.length > 44 && (x = x.replace(/^(.{32}).+$/, "$1 (TRUNCATED)")), x;
198
- }).filter((y) => !!y).join(`
199
- `);
200
- if (J || (t.id.length > 44 ? J = t.id.replace(/^(.{32}).+$/, "$1 (TRUNCATED)") : J = t.id), T && P && (t.timestamp || t.annotation) && g.push(
201
- /* @__PURE__ */ it(
202
- "g",
203
- {
204
- style: {
205
- cursor: "default",
206
- fontFamily: '"Lucida Console", monospace',
207
- fontSize: o * 0.75 + "px"
208
- },
209
- children: [
210
- /* @__PURE__ */ L(
211
- "text",
212
- {
213
- x: B[0][0] + $,
214
- y: z + (Z + s) / 2,
215
- fill: u.palette.getContrastText(u.palette.background.paper),
216
- style: {
217
- fillOpacity: H(t.id) / 2,
218
- transition: u.transitions.create(["fill-opacity"], {
219
- duration: u.transitions.duration.short
220
- })
221
- },
222
- children: t.timestamp
223
- }
224
- ),
225
- t.annotation && t.annotation.split(`
226
- `).map((y, x) => {
227
- var Q;
228
- return /* @__PURE__ */ L(
255
+ textColor,
256
+ letterSize,
257
+ letterWidth,
258
+ nodeRadius,
259
+ nodeColor,
260
+ maxArcRadius,
261
+ lineWidth,
262
+ truncateLabels,
263
+ enableTimestamps,
264
+ belowPrevious,
265
+ iconOrientation,
266
+ lineDirection,
267
+ colorTheme
268
+ } = combinedOptions;
269
+ const { nodeLocations, linesByLevel, paddingByLevel } = layoutData;
270
+ const _nodes = [];
271
+ const _timestamps = [];
272
+ flatNodes.forEach((node) => {
273
+ var _a2, _b2, _c2, _d;
274
+ const [x, y, _height] = nodeLocations[node.id];
275
+ const labelKey = ((_a2 = labelKeys == null ? void 0 : labelKeys.filter((_comparator) => runComparator(_comparator, node)).pop()) == null ? void 0 : _a2.label) ?? "id";
276
+ let label = labelKey == null ? void 0 : labelKey.split(",").map((key) => {
277
+ let labelSection = get(node, key);
278
+ if (labelSection && truncateLabels && labelSection.length > 44) {
279
+ labelSection = labelSection.replace(/^(.{32}).+$/, "$1 (TRUNCATED)");
280
+ }
281
+ return labelSection;
282
+ }).filter((section) => !!section).join("\n");
283
+ if (!label) {
284
+ if (node.id.length > 44) {
285
+ label = node.id.replace(/^(.{32}).+$/, "$1 (TRUNCATED)");
286
+ } else {
287
+ label = node.id;
288
+ }
289
+ }
290
+ if (belowPrevious && enableTimestamps && (node.timestamp || node.annotation)) {
291
+ _timestamps.push(
292
+ /* @__PURE__ */ jsxs(
293
+ "g",
294
+ {
295
+ style: {
296
+ cursor: "default",
297
+ fontFamily: '"Lucida Console", monospace',
298
+ fontSize: letterSize * 0.75 + "px"
299
+ },
300
+ children: [
301
+ /* @__PURE__ */ jsx(
229
302
  "text",
230
303
  {
231
- x: B[0][0] + (((Q = t.timestamp) == null ? void 0 : Q.length) ?? 0) * l,
232
- y: z + (Z + s) / 2 + x * o,
233
- fill: ut ? wt.orange[300] : wt.blue[900],
304
+ x: portBounds[0][0] + xSpacing,
305
+ y: y + (_height + nodeRadius) / 2,
306
+ fill: theme.palette.getContrastText(theme.palette.background.paper),
234
307
  style: {
235
- fillOpacity: H(t.id),
236
- transition: u.transitions.create(["fill-opacity"], {
237
- duration: u.transitions.duration.short
308
+ fillOpacity: nodeOpacities(node.id) / 2,
309
+ transition: theme.transitions.create(["fill-opacity"], {
310
+ duration: theme.transitions.duration.short
238
311
  })
239
312
  },
240
- children: y
241
- },
242
- y
243
- );
244
- })
245
- ]
246
- },
247
- t.id + "-timestamp"
248
- )
249
- ), !Y) {
250
- const y = lt(
251
- (bt = (Ct = n.metadata.display) == null ? void 0 : Ct.styles) == null ? void 0 : bt.filter((N) => N.type === "node"),
252
- t
253
- ), x = H(t.id), Q = (Et = t.icons) == null ? void 0 : Et.map((N) => [N, zt(N)]).filter(([N, tt]) => !!tt).map(([N, tt], Lt) => /* @__PURE__ */ L(
254
- tt,
313
+ children: node.timestamp
314
+ }
315
+ ),
316
+ node.annotation && node.annotation.split("\n").map((line, index) => {
317
+ var _a3;
318
+ return /* @__PURE__ */ jsx(
319
+ "text",
320
+ {
321
+ x: portBounds[0][0] + (((_a3 = node.timestamp) == null ? void 0 : _a3.length) ?? 0) * letterWidth,
322
+ y: y + (_height + nodeRadius) / 2 + index * letterSize,
323
+ fill: isDark ? colors.orange[300] : colors.blue[900],
324
+ style: {
325
+ fillOpacity: nodeOpacities(node.id),
326
+ transition: theme.transitions.create(["fill-opacity"], {
327
+ duration: theme.transitions.duration.short
328
+ })
329
+ },
330
+ children: line
331
+ },
332
+ line
333
+ );
334
+ })
335
+ ]
336
+ },
337
+ node.id + "-timestamp"
338
+ )
339
+ );
340
+ }
341
+ if (!showCards) {
342
+ const style = runComparators(
343
+ (_c2 = (_b2 = graph.metadata.display) == null ? void 0 : _b2.styles) == null ? void 0 : _c2.filter((comparator) => comparator.type === "node"),
344
+ node
345
+ );
346
+ const nodeOpacity = nodeOpacities(node.id);
347
+ const icons = (_d = node.icons) == null ? void 0 : _d.map((icon) => [icon, getIcon(icon)]).filter(([__, icon]) => !!icon).map(([icon, Icon], index) => /* @__PURE__ */ jsx(
348
+ Icon,
255
349
  {
256
- x: yt - s * 3 * (R === "horizontal" ? Lt + 1 : 0),
257
- y: z - s * 3 * (R === "vertical" ? Lt + 1 : 0),
258
- size: o * 1.5,
350
+ x: x - nodeRadius * 3 * (iconOrientation === "horizontal" ? index + 1 : 0),
351
+ y: y - nodeRadius * 3 * (iconOrientation === "vertical" ? index + 1 : 0),
352
+ size: letterSize * 1.5,
259
353
  style: {
260
- fillOpacity: x
354
+ fillOpacity: nodeOpacity
261
355
  },
262
356
  circleStyle: {
263
- fillOpacity: x
357
+ fillOpacity: nodeOpacity
264
358
  }
265
359
  },
266
- N
360
+ icon
267
361
  ));
268
- f.push(
269
- /* @__PURE__ */ L(
270
- Jt,
362
+ _nodes.push(
363
+ /* @__PURE__ */ jsx(
364
+ Leaf,
271
365
  {
272
- alwaysShowText: !0,
273
- nodeId: t.id,
274
- label: J,
275
- height: Z,
276
- x: yt,
277
- y: z,
278
- style: y,
279
- nodeRadius: s,
280
- nodeColor: E,
281
- nodeOpacity: x,
282
- letterSize: o,
283
- letterWidth: l,
284
- textColor: i,
285
- selected: ft.has(t.id),
286
- onHoverChanged: A,
287
- onClick: ct,
288
- children: Q
366
+ alwaysShowText: true,
367
+ nodeId: node.id,
368
+ label,
369
+ height: _height,
370
+ x,
371
+ y,
372
+ style,
373
+ nodeRadius,
374
+ nodeColor,
375
+ nodeOpacity,
376
+ letterSize,
377
+ letterWidth,
378
+ textColor,
379
+ selected: highlightedNodes.has(node.id),
380
+ onHoverChanged: onNodeHoveredChanged,
381
+ onClick: onNodeClicked,
382
+ children: icons
289
383
  },
290
- t.id
384
+ node.id
291
385
  )
292
386
  );
293
387
  }
294
388
  });
295
- const m = Xt(e), p = {}, I = {}, q = U.map((t) => /* @__PURE__ */ L(
296
- Qt,
297
- {
298
- lineDirection: k,
299
- linesByLevel: a,
300
- paddingByLevel: b,
301
- nodeLocations: m,
302
- outputsByNode: p,
303
- inputsByNode: I,
304
- bundle: t,
305
- maxArcRadius: F,
306
- lineWidth: V,
307
- linePaddingX: j,
308
- linePaddingY: M,
309
- highlightedPath: dt,
310
- colorTheme: D
311
- },
312
- t.id
313
- ));
314
- return [g, q, f];
389
+ const readonlyNodeLocations = cloneDeep(nodeLocations);
390
+ const outputsByNode = {};
391
+ const inputsByNode = {};
392
+ const _bundleElements = bundles.map((bundle) => {
393
+ return /* @__PURE__ */ jsx(
394
+ BundleLine,
395
+ {
396
+ lineDirection,
397
+ linesByLevel,
398
+ paddingByLevel,
399
+ nodeLocations: readonlyNodeLocations,
400
+ outputsByNode,
401
+ inputsByNode,
402
+ bundle,
403
+ maxArcRadius,
404
+ lineWidth,
405
+ linePaddingX,
406
+ linePaddingY,
407
+ highlightedPath,
408
+ colorTheme
409
+ },
410
+ bundle.id
411
+ );
412
+ });
413
+ return [_timestamps, _bundleElements, _nodes];
315
414
  }, [
316
- U,
317
- v,
318
- (vt = n.metadata.display) == null ? void 0 : vt.styles,
319
- C,
320
- ft,
321
- dt,
322
- ut,
323
- r,
324
- G,
325
- j,
326
- M,
327
- H,
328
- ct,
329
- A,
330
- B,
331
- W,
332
- lt,
333
- Y,
334
- u.palette,
335
- u.transitions,
336
- $
337
- ]), _t = S(() => {
338
- const { nodeRadius: i, lineWidth: o } = v, { nodeLocations: l } = G;
339
- return C.filter((s) => Y || pt === s.id).map((s) => {
340
- const [E, F] = l[s.id];
341
- return /* @__PURE__ */ L(
342
- Ft,
415
+ bundles,
416
+ combinedOptions,
417
+ (_c = graph.metadata.display) == null ? void 0 : _c.styles,
418
+ flatNodes,
419
+ highlightedNodes,
420
+ highlightedPath,
421
+ isDark,
422
+ labelKeys,
423
+ layoutData,
424
+ linePaddingX,
425
+ linePaddingY,
426
+ nodeOpacities,
427
+ onNodeClicked,
428
+ onNodeHoveredChanged,
429
+ portBounds,
430
+ runComparator,
431
+ runComparators,
432
+ showCards,
433
+ theme.palette,
434
+ theme.transitions,
435
+ xSpacing
436
+ ]);
437
+ const cards = useMemo(() => {
438
+ const { nodeRadius, lineWidth } = combinedOptions;
439
+ const { nodeLocations } = layoutData;
440
+ return flatNodes.filter((node) => showCards || hoveredNode === node.id).map((node) => {
441
+ const [x, y] = nodeLocations[node.id];
442
+ return /* @__PURE__ */ jsx(
443
+ Box,
343
444
  {
344
- onMouseOver: () => A(s.id, !0),
345
- onMouseLeave: () => setTimeout(() => A(s.id, !1), 100),
445
+ onMouseOver: () => onNodeHoveredChanged(node.id, true),
446
+ onMouseLeave: () => setTimeout(() => onNodeHoveredChanged(node.id, false), 100),
346
447
  sx: {
347
448
  position: "absolute",
348
- left: d.k * E + d.x,
349
- top: d.k * F + d.y,
350
- transform: `translateX(-${i * 2}px) translateY(${o}px)`,
351
- backgroundColor: u.palette.background.paper,
449
+ left: zoom.k * x + zoom.x,
450
+ top: zoom.k * y + zoom.y,
451
+ transform: `translateX(-${nodeRadius * 2}px) translateY(${lineWidth}px)`,
452
+ backgroundColor: theme.palette.background.paper,
352
453
  maxWidth: "450px",
353
454
  maxHeight: "500px",
354
455
  overflow: "auto"
355
456
  },
356
- children: /* @__PURE__ */ L(qt, { node: s })
457
+ children: /* @__PURE__ */ jsx(NodeCard, { node })
357
458
  },
358
- s.id
459
+ node.id
359
460
  );
360
461
  });
361
462
  }, [
362
- v,
363
- C,
364
- pt,
365
- G,
366
- A,
367
- Y,
368
- u.palette.background.paper,
369
- d.k,
370
- d.x,
371
- d.y
463
+ combinedOptions,
464
+ flatNodes,
465
+ hoveredNode,
466
+ layoutData,
467
+ onNodeHoveredChanged,
468
+ showCards,
469
+ theme.palette.background.paper,
470
+ zoom.k,
471
+ zoom.x,
472
+ zoom.y
372
473
  ]);
373
- return /* @__PURE__ */ it(At, { children: [
374
- /* @__PURE__ */ L("svg", { id: "viz", ref: c, children: /* @__PURE__ */ it("g", { id: "view", children: [
375
- Mt,
376
- Rt,
377
- Dt
474
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
475
+ /* @__PURE__ */ jsx("svg", { id: "viz", ref: svgRef, children: /* @__PURE__ */ jsxs("g", { id: "view", children: [
476
+ timestamps,
477
+ bundleElements,
478
+ nodes
378
479
  ] }) }),
379
- _t
480
+ cards
380
481
  ] });
381
- }, Li = Vt(ai);
482
+ };
483
+ const Tree$1 = memo(Tree);
382
484
  export {
383
- Li as default
485
+ Tree$1 as default
384
486
  };