@cccsaurora/clue-ui 1.3.0 → 1.4.0-dev.426

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 (224) hide show
  1. package/ActionForm-CqKcnDWC.js +6099 -0
  2. package/AnnotationDetails-BlPd3T8k.js +176 -0
  3. package/AnnotationPreview-Bl447SKT.js +188 -0
  4. package/ClueEnrichContext-B3YrTCaJ.js +567 -0
  5. package/FlexOne-BSYAhhtG.js +9 -0
  6. package/_MapCache-kuEY_iOH.js +220 -0
  7. package/_Set-BrSMTlHn.js +6 -0
  8. package/_Uint8Array-OPpgYQj7.js +123 -0
  9. package/_arrayIncludes-BNqL-9ZP.js +31 -0
  10. package/_arrayPush-CBkQqaE_.js +10 -0
  11. package/_baseAssignValue-CNUVPOBW.js +16 -0
  12. package/_baseClone-9FaRd1R2.js +287 -0
  13. package/_baseExtremum-wOGT4Dgw.js +18 -0
  14. package/_baseFlatten-Co6QHDlG.js +92 -0
  15. package/_baseGet-Cmp6FztG.js +109 -0
  16. package/_baseGetTag-Hj-0NTYF.js +44 -0
  17. package/_baseIsEqual-1CpU47TZ.js +211 -0
  18. package/_baseIteratee-BN7Vbe5g.js +126 -0
  19. package/_baseRest-BZ_hQ9PC.js +8 -0
  20. package/_baseSlice-GAv_YFTT.js +20 -0
  21. package/_baseSum-D0WC1dN0.js +13 -0
  22. package/_baseUniq-BnvS3JHL.js +63 -0
  23. package/_cacheHas-_aF2y2Xv.js +25 -0
  24. package/_commonjsHelpers-CUmg6egw.js +6 -0
  25. package/_createAggregator-BUZrP_is.js +63 -0
  26. package/_defineProperty-DolZLKmv.js +12 -0
  27. package/_getPrototype-Bb4gm-5m.js +5 -0
  28. package/_getTag-CML_cXiN.js +105 -0
  29. package/_isIterateeCall-B1IFEqVv.js +17 -0
  30. package/_setToArray-CqyqC8ib.js +10 -0
  31. package/cloneDeep-l3UkXG5M.js +8 -0
  32. package/components/AnnotationBody.js +49 -35
  33. package/components/AnnotationDetailPopover.js +36 -30
  34. package/components/AnnotationDetails.js +7 -7
  35. package/components/AnnotationEntry.js +35 -35
  36. package/components/AnnotationPreview.js +5 -5
  37. package/components/ClassificationChip.js +44 -23
  38. package/components/CountBadge.js +31 -26
  39. package/components/EnrichedCard.js +110 -97
  40. package/components/EnrichedChip.js +130 -105
  41. package/components/EnrichedTypography.js +133 -107
  42. package/components/ErrorBoundary.js +28 -24
  43. package/components/RetryFailedEnrichments.js +10 -9
  44. package/components/SourcePicker.js +57 -49
  45. package/components/actions/ActionForm.js +4 -4
  46. package/components/actions/ExecutePopover.js +75 -59
  47. package/components/actions/ResultModal.js +4 -4
  48. package/components/actions/form/schemaAdapter.js +39 -23
  49. package/components/actions/formats/FileResult.js +86 -59
  50. package/components/actions/formats/index.js +29 -25
  51. package/components/display/graph/ExpandMoreButton.js +10 -10
  52. package/components/display/graph/elements/NodeCard.js +111 -91
  53. package/components/display/graph/elements/NodeTag.js +15 -13
  54. package/components/display/graph/index.js +261 -202
  55. package/components/display/graph/visualizations/Leaf.js +89 -70
  56. package/components/display/graph/visualizations/cloud/index.js +98 -81
  57. package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
  58. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  59. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  60. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  61. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  62. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  63. package/components/display/graph/visualizations/icons/index.js +14 -13
  64. package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
  65. package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
  66. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  67. package/components/display/graph/visualizations/tree/index.js +408 -306
  68. package/components/display/icons/Iconified.js +27 -12
  69. package/components/display/json/index.js +4 -4
  70. package/components/display/markdown/index.js +8678 -5770
  71. package/components/enrichment/EnrichPopover.js +54 -46
  72. package/components/fetchers/Fetcher.js +166 -123
  73. package/components/fetchers/FetcherResultView.js +31 -27
  74. package/components/fetchers/PreviewModal.js +17 -16
  75. package/components/fetchers/StatusChip.js +21 -17
  76. package/components/group/Entry.js +13 -11
  77. package/components/group/Group.js +13 -10
  78. package/components/group/GroupControl.js +76 -65
  79. package/components/stats/QueryStatus.js +45 -32
  80. package/countBy-Bqcp3VCs.js +14 -0
  81. package/data/event.js +6 -4
  82. package/database/globals.js +2 -2
  83. package/database/index.js +3 -3
  84. package/database/replication.js +4 -4
  85. package/get-CdMThM8x.js +8 -0
  86. package/groupBy-BVV07EGQ.js +14 -0
  87. package/hooks/ClueActionContext.js +6 -6
  88. package/hooks/ClueComponentContext.js +29 -23
  89. package/hooks/ClueConfigProvider.js +14 -12
  90. package/hooks/ClueDatabaseContext.js +35 -23
  91. package/hooks/ClueEnrichContext.js +11 -11
  92. package/hooks/ClueFetcherContext.js +83 -56
  93. package/hooks/ClueGroupContext.js +17 -14
  94. package/hooks/CluePopupContext.js +5 -5
  95. package/hooks/ClueProvider.js +13 -11
  96. package/hooks/ClueUIPluginContext.js +49 -35
  97. package/hooks/selectors.js +7 -7
  98. package/hooks/useActionResult.js +3 -3
  99. package/hooks/useAnnotations.js +48 -32
  100. package/hooks/useClue.js +6 -4
  101. package/hooks/useClueActions.js +3 -3
  102. package/hooks/useClueConfig.js +6 -4
  103. package/hooks/useClueTypeConfig.js +49 -24
  104. package/hooks/useClueUIPlugins.js +8 -7
  105. package/hooks/useComparator.js +722 -435
  106. package/hooks/useErrors.js +22 -18
  107. package/hooks/useFetcherResult.js +33 -24
  108. package/hooks/useMyHighlights.js +66 -36
  109. package/hooks/useMyLocalStorage.js +66 -37
  110. package/iconify-DJxl6dC-.js +1789 -0
  111. package/icons/Action.js +66 -49
  112. package/icons/Assessment.js +85 -69
  113. package/icons/Context.js +77 -63
  114. package/icons/Opinion.js +76 -60
  115. package/icons/iconMap.js +2 -2
  116. package/identity-CPGTqrE4.js +6 -0
  117. package/index-CAvu7vwt.js +1172 -0
  118. package/index-CVUD9o3t.js +15768 -0
  119. package/index-DUEubgWN.js +464 -0
  120. package/index-Dj1N4IQP.js +9314 -0
  121. package/index-DpJxD74E.js +3272 -0
  122. package/index-_gpzM2Px.js +702 -0
  123. package/isArguments-CuYlEuhP.js +27 -0
  124. package/isArray-RJPfgWqI.js +4 -0
  125. package/isEmpty-BE656RUK.js +30 -0
  126. package/isNil-CIubwp4T.js +6 -0
  127. package/isObject-FTY-5JQX.js +7 -0
  128. package/isObjectLike-CeENW9FN.js +6 -0
  129. package/isSymbol-D_H4HPZQ.js +9 -0
  130. package/last-CUCl67Im.js +7 -0
  131. package/main.js +62 -62
  132. package/maxBy-BjjQmX5t.js +8 -0
  133. package/package.json +1 -1
  134. package/plugins/ClueUIPlugin.js +163 -96
  135. package/plugins/file/index.js +15 -15
  136. package/plugins/graph/index.js +29 -26
  137. package/plugins/image/index.js +28 -24
  138. package/plugins/json/index.js +21 -21
  139. package/plugins/markdown/index.js +18 -18
  140. package/plugins/registry.js +6 -6
  141. package/plugins/store.js +4 -4
  142. package/plugins/test/index.js +17 -17
  143. package/plugins/utils.js +13 -12
  144. package/replication--gLEZw8a.js +11777 -0
  145. package/sessionStorage-B68y-wnE.js +140 -0
  146. package/sortBy-B8JVsLQY.js +95 -0
  147. package/store-B9sjQbcS.js +2163 -0
  148. package/sumBy-D-HCzM2i.js +8 -0
  149. package/text/Frequency.js +42 -23
  150. package/toFinite-meZTg4Su.js +16 -0
  151. package/toNumber-B5JaA1vX.js +39 -0
  152. package/uniq-CahZPAwp.js +7 -0
  153. package/utils/chain.js +92 -65
  154. package/utils/classificationParser.js +519 -256
  155. package/utils/constants.js +37 -11
  156. package/utils/graph.js +72 -45
  157. package/utils/hashUtil.js +7 -7
  158. package/utils/line.js +131 -81
  159. package/utils/loggerUtil.js +5 -3
  160. package/utils/sessionStorage.js +7 -7
  161. package/utils/time.js +447 -427
  162. package/utils/utils.js +10 -10
  163. package/utils/window.js +21 -10
  164. package/utils-CEySTPtg.js +224 -0
  165. package/ActionForm-CHOSKfvu.js +0 -4403
  166. package/AnnotationDetails-Bqq6Ymmg.js +0 -160
  167. package/AnnotationPreview-CqXmC-j8.js +0 -140
  168. package/ClueEnrichContext-DL6aGe1k.js +0 -432
  169. package/FlexOne-BXWFOd1T.js +0 -6
  170. package/_MapCache-DRK-s2eK.js +0 -179
  171. package/_Set-DrS_bbSV.js +0 -6
  172. package/_Uint8Array-D9R2N9Lp.js +0 -98
  173. package/_arrayIncludes-Dcl_29E6.js +0 -25
  174. package/_arrayPush-DBJIuK2V.js +0 -8
  175. package/_baseAssignValue-Bx1cxHj5.js +0 -12
  176. package/_baseClone-DRhywkxm.js +0 -211
  177. package/_baseExtremum-DodEaEyF.js +0 -16
  178. package/_baseFlatten-CD9NgrYE.js +0 -72
  179. package/_baseGet-bVwDaGrA.js +0 -80
  180. package/_baseGetTag-CxDaTem-.js +0 -25
  181. package/_baseIsEqual-C-FKsm1J.js +0 -150
  182. package/_baseIteratee-D0FhC5bC.js +0 -95
  183. package/_baseRest-D_eW2E0d.js +0 -8
  184. package/_baseSlice-M5RKzt1A.js +0 -10
  185. package/_baseSum-wEbgNeUs.js +0 -10
  186. package/_baseUniq-D3N8igOm.js +0 -41
  187. package/_cacheHas-Wgl-hw34.js +0 -22
  188. package/_commonjsHelpers-C6fGbg64.js +0 -6
  189. package/_createAggregator-BVj8IAuF.js +0 -53
  190. package/_defineProperty-BZU4WKA3.js +0 -11
  191. package/_getPrototype-BGBCg-aX.js +0 -5
  192. package/_getTag-B7R9qBo7.js +0 -73
  193. package/_isIterateeCall-Dm0VTAYy.js +0 -13
  194. package/_setToArray-Ck4YZu0Z.js +0 -9
  195. package/cloneDeep-fV59zwUf.js +0 -8
  196. package/countBy-B3rNuG4T.js +0 -8
  197. package/get-Bil3mzRD.js +0 -8
  198. package/groupBy-CrJC7sGa.js +0 -8
  199. package/iconify-Ptb5dTKy.js +0 -1270
  200. package/identity-ByMq8VxU.js +0 -6
  201. package/index-BH-gBhtO.js +0 -2282
  202. package/index-BM9Sve5T.js +0 -571
  203. package/index-Cj4d5cGz.js +0 -357
  204. package/index-Dh2PP9h8.js +0 -11747
  205. package/index-DoFpWPHo.js +0 -975
  206. package/index-DzVIklWY.js +0 -6464
  207. package/isArguments-BWcXOE6a.js +0 -24
  208. package/isArray-WzO_os3q.js +0 -4
  209. package/isEmpty-DKxrY-_M.js +0 -22
  210. package/isNil-CjWwlQS3.js +0 -6
  211. package/isObject-B53jY8Qg.js +0 -7
  212. package/isObjectLike-CYbdrIBr.js +0 -6
  213. package/isSymbol-DE1Kcy2M.js +0 -9
  214. package/last-7CdUxN0r.js +0 -7
  215. package/maxBy-BOWDkL_D.js +0 -8
  216. package/replication-WkKbPdwG.js +0 -8453
  217. package/sessionStorage-DFMae61b.js +0 -90
  218. package/sortBy-BHe812lF.js +0 -74
  219. package/store-DClHBq7r.js +0 -1169
  220. package/sumBy-B7f_bP_k.js +0 -8
  221. package/toFinite-CBrE65MP.js +0 -14
  222. package/toNumber-CxmWey0f.js +0 -31
  223. package/uniq-B4UZ671_.js +0 -7
  224. package/utils-SpTOhPYl.js +0 -147
@@ -1,197 +1,256 @@
1
- import { jsx as i, jsxs as l, Fragment as ke } from "react/jsx-runtime";
2
- import { useMemo as m, useRef as te, useState as u, useEffect as z, useCallback as f, createElement as Ce } from "react";
3
- import { useTheme as we, lighten as oe, darken as ne, Stack as x, Card as T, Typography as he, Autocomplete as ze, TextField as Se, FormControl as Ee, InputLabel as Ie, Select as Oe, MenuItem as Ne, alpha as ie, IconButton as Me, Collapse as Pe } from "@mui/material";
4
- import { p as Fe } from "../../../index-Cj4d5cGz.js";
5
- import { z as Re, i as P, s as p, t as Te, p as re } from "../../../index-Dh2PP9h8.js";
6
- import { ClueComponentContext as ge } from "../../../hooks/ClueComponentContext.js";
7
- import Le from "../../../hooks/useComparator.js";
8
- import { useMyLocalStorageItem as g } from "../../../hooks/useMyLocalStorage.js";
9
- import { StorageKey as L } from "../../../utils/constants.js";
10
- import { g as Ae } from "../../../get-Bil3mzRD.js";
11
- import { a as Be } from "../../../index-BM9Sve5T.js";
12
- import { cssImportant as k } from "../../../utils/graph.js";
13
- import ae from "../icons/Iconified.js";
14
- import $e from "./ExpandMoreButton.js";
15
- import je from "./visualizations/cloud/index.js";
16
- import He from "./visualizations/panels/NodePanel.js";
17
- import _e from "./visualizations/tree/index.js";
18
- const rt = ({ graph: t, sx: se = {} }) => {
19
- var Y, Z, U, q, J;
20
- const { t: C } = Be(ge, (e) => e.i18next), o = we(), S = m(() => o.palette.mode === "dark", [o]), { runComparator: A } = Le(), a = te(), le = te(), [F] = g(L.SHOW_MOUSE_POS, !1), [w] = g(L.SHOW_COORDINATES, !1), [E] = g(L.PANEL_LOCATION, "vertical"), [ce, de] = u(["0", "0"]), [me, ue] = u(["0", "0"]), [I, B] = u(!1), $ = m(() => ((t == null ? void 0 : t.data) ?? []).flat(2).map((e) => e.id), [t == null ? void 0 : t.data]), v = m(() => Re().scaleExtent([0.1, 6]), []), [s, O] = u(P), [N, pe] = u(""), [h, j] = u([]), [M, H] = u(
21
- ((Z = (Y = t == null ? void 0 : t.metadata.display) == null ? void 0 : Y.visualization) == null ? void 0 : Z.type) ?? "tree"
22
- ), [fe, R] = u(!1);
23
- z(() => {
24
- B(h.length > 0);
25
- }, [h]);
26
- const b = m(
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useState, useEffect, useCallback, createElement } from "react";
3
+ import { useTheme, lighten, darken, Stack, Card, Typography, Autocomplete, TextField, FormControl, InputLabel, Select, MenuItem, alpha, IconButton, Collapse } from "@mui/material";
4
+ import { p as parseEvent } from "../../../index-DUEubgWN.js";
5
+ import { z as zoom, i as identity, s as select, t as transform, p as pointer } from "../../../index-CVUD9o3t.js";
6
+ import { ClueComponentContext } from "../../../hooks/ClueComponentContext.js";
7
+ import useComparator from "../../../hooks/useComparator.js";
8
+ import { useMyLocalStorageItem } from "../../../hooks/useMyLocalStorage.js";
9
+ import { StorageKey } from "../../../utils/constants.js";
10
+ import { g as get } from "../../../get-CdMThM8x.js";
11
+ import { a as useContextSelector } from "../../../index-_gpzM2Px.js";
12
+ import { cssImportant } from "../../../utils/graph.js";
13
+ import Iconified from "../icons/Iconified.js";
14
+ import ExpandMoreButton from "./ExpandMoreButton.js";
15
+ import Cloud from "./visualizations/cloud/index.js";
16
+ import NodePanel from "./visualizations/panels/NodePanel.js";
17
+ import Tree from "./visualizations/tree/index.js";
18
+ const Graph = ({ graph, sx = {} }) => {
19
+ var _a, _b, _c, _d, _e;
20
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
21
+ const theme = useTheme();
22
+ const isDark = useMemo(() => theme.palette.mode === "dark", [theme]);
23
+ const { runComparator } = useComparator();
24
+ const svgRef = useRef();
25
+ const pointRef = useRef();
26
+ const [showMousePos] = useMyLocalStorageItem(StorageKey.SHOW_MOUSE_POS, false);
27
+ const [showCoordinates] = useMyLocalStorageItem(StorageKey.SHOW_COORDINATES, false);
28
+ const [panelLocation] = useMyLocalStorageItem(StorageKey.PANEL_LOCATION, "vertical");
29
+ const [relativeMousePos, setRelativeMousePos] = useState(["0", "0"]);
30
+ const [absoluteMousePos, setAbsoluteMousePos] = useState(["0", "0"]);
31
+ const [showPanel, setShowPanel] = useState(false);
32
+ const nodeIds = useMemo(() => ((graph == null ? void 0 : graph.data) ?? []).flat(2).map((node) => node.id), [graph == null ? void 0 : graph.data]);
33
+ const zoom$1 = useMemo(() => zoom().scaleExtent([0.1, 6]), []);
34
+ const [currentZoom, setCurrentZoom] = useState(identity);
35
+ const [nodeId, setNodeId] = useState("");
36
+ const [selectedNodeIds, setSelectedNodeIds] = useState([]);
37
+ const [viz, setViz] = useState(
38
+ ((_b = (_a = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a.visualization) == null ? void 0 : _b.type) ?? "tree"
39
+ );
40
+ const [hasError, setHasError] = useState(false);
41
+ useEffect(() => {
42
+ setShowPanel(selectedNodeIds.length > 0);
43
+ }, [selectedNodeIds]);
44
+ const labelKeys = useMemo(
27
45
  () => {
28
- var e, n;
29
- return (n = (e = t == null ? void 0 : t.metadata.display) == null ? void 0 : e.displayField) == null ? void 0 : n.filter((r) => (r.zoom ?? Number.MAX_SAFE_INTEGER) > s.k);
46
+ var _a2, _b2;
47
+ return (_b2 = (_a2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a2.displayField) == null ? void 0 : _b2.filter((entry) => (entry.zoom ?? Number.MAX_SAFE_INTEGER) > currentZoom.k);
30
48
  },
31
- [(U = t == null ? void 0 : t.metadata.display) == null ? void 0 : U.displayField, s.k]
32
- ), xe = f((e) => {
33
- pe(e);
34
- }, []), _ = f((e) => {
35
- const n = e === "view" ? e : `node-${e ?? "will\\%never\\$ever\\*exist"}`;
36
- return p(`#${n}`);
37
- }, []), G = f(() => {
38
- if (!N) {
39
- R(!0);
49
+ [(_c = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _c.displayField, currentZoom.k]
50
+ );
51
+ const onNodeChange = useCallback((node) => {
52
+ setNodeId(node);
53
+ }, []);
54
+ const checkForNode = useCallback((_nodeId) => {
55
+ const selector = _nodeId === "view" ? _nodeId : `node-${_nodeId ?? "will\\%never\\$ever\\*exist"}`;
56
+ return select(`#${selector}`);
57
+ }, []);
58
+ const selectNode = useCallback(() => {
59
+ if (!nodeId) {
60
+ setHasError(true);
40
61
  return;
41
62
  }
42
- const e = _(N.replace(/[^A-Za-z0-9]*/g, ""));
43
- if (e.empty()) {
44
- R(!0);
63
+ const nodeToGet = checkForNode(nodeId.replace(/[^A-Za-z0-9]*/g, ""));
64
+ if (nodeToGet.empty()) {
65
+ setHasError(true);
45
66
  return;
46
67
  }
47
- R(!1), j([N]);
48
- const n = a.current.getBoundingClientRect(), r = p(a.current), d = e.node().getBBox();
49
- r.transition().duration(500).call(
50
- v.transform,
51
- P.translate(n.width / 2, n.height / 2).scale(4).translate(-d.x, -d.y)
68
+ setHasError(false);
69
+ setSelectedNodeIds([nodeId]);
70
+ const clientRect = svgRef.current.getBoundingClientRect();
71
+ const svg = select(svgRef.current);
72
+ const box = nodeToGet.node().getBBox();
73
+ svg.transition().duration(500).call(
74
+ zoom$1.transform,
75
+ identity.translate(clientRect.width / 2, clientRect.height / 2).scale(4).translate(-box.x, -box.y)
52
76
  );
53
- }, [_, N, v.transform]), ve = f(
54
- (e) => {
55
- const n = Fe(e);
56
- n.isCtrl && n.isEnter && G();
77
+ }, [checkForNode, nodeId, zoom$1.transform]);
78
+ const onKeyPress = useCallback(
79
+ (event) => {
80
+ const parsedEvent = parseEvent(event);
81
+ if (parsedEvent.isCtrl && parsedEvent.isEnter) {
82
+ selectNode();
83
+ }
57
84
  },
58
- [G]
59
- ), be = f((e) => ((t == null ? void 0 : t.data) ?? []).flat().find((n) => n.id === e), [t == null ? void 0 : t.data]), W = f(
60
- (e = !1) => {
61
- if (!t)
85
+ [selectNode]
86
+ );
87
+ const findNode = useCallback((id) => ((graph == null ? void 0 : graph.data) ?? []).flat().find((n) => n.id === id), [graph == null ? void 0 : graph.data]);
88
+ const resetZoom = useCallback(
89
+ (instant = false) => {
90
+ if (!graph) {
62
91
  return;
63
- const n = p(a.current).select("#view").node().getBBox(), r = a.current.getBoundingClientRect(), d = Math.min(r.width / (n.width + 25), (r.height - 96) / n.height);
64
- let y = p(a.current);
65
- e || (y = y.transition().duration(500)), y.call(
66
- v.transform,
67
- P.translate(r.width / 2, (r.height + 96) / 2).scale(d).translate(-n.width / 2, -n.height / 2 - 10)
92
+ }
93
+ const box = select(svgRef.current).select("#view").node().getBBox();
94
+ const clientRect = svgRef.current.getBoundingClientRect();
95
+ const zoomLevel = Math.min(clientRect.width / (box.width + 25), (clientRect.height - 96) / box.height);
96
+ let selection = select(svgRef.current);
97
+ if (!instant) {
98
+ selection = selection.transition().duration(500);
99
+ }
100
+ selection.call(
101
+ zoom$1.transform,
102
+ identity.translate(clientRect.width / 2, (clientRect.height + 96) / 2).scale(zoomLevel).translate(-box.width / 2, -box.height / 2 - 10)
68
103
  );
69
104
  },
70
- [v.transform, t]
71
- ), D = f((e) => j(e), []);
72
- z(() => {
73
- t && (le.current = a.current.createSVGPoint(), p(a.current).call(
74
- v.on("zoom", (e) => {
75
- O == null || O(e.transform), p(a.current).select("#view").attr("transform", e.transform);
105
+ [zoom$1.transform, graph]
106
+ );
107
+ const onNodeSelectionChanged = useCallback((_nodeIds) => setSelectedNodeIds(_nodeIds), []);
108
+ useEffect(() => {
109
+ if (!graph) {
110
+ return;
111
+ }
112
+ pointRef.current = svgRef.current.createSVGPoint();
113
+ select(svgRef.current).call(
114
+ zoom$1.on("zoom", (event) => {
115
+ setCurrentZoom == null ? void 0 : setCurrentZoom(event.transform);
116
+ select(svgRef.current).select("#view").attr("transform", event.transform);
76
117
  })
77
- ));
78
- }, [O, v, M, t]), z(() => {
79
- F && p(a.current).on("mousemove", (e) => {
80
- const n = Te(p(a.current).select("#view").node());
81
- ue(n.invert(re(e)).map((r) => r.toFixed(0))), de(re(e).map((r) => r.toFixed(0)));
82
- });
83
- }, [F, t]), z(() => {
84
- W();
85
- }, [M, t == null ? void 0 : t.data]), z(() => {
86
- var e, n, r, d;
87
- (n = (e = t == null ? void 0 : t.metadata.display) == null ? void 0 : e.visualization) != null && n.type && H((d = (r = t == null ? void 0 : t.metadata.display) == null ? void 0 : r.visualization) == null ? void 0 : d.type);
88
- }, [(J = (q = t == null ? void 0 : t.metadata.display) == null ? void 0 : q.visualization) == null ? void 0 : J.type]);
89
- const V = m(
118
+ );
119
+ }, [setCurrentZoom, zoom$1, viz, graph]);
120
+ useEffect(() => {
121
+ if (showMousePos) {
122
+ select(svgRef.current).on("mousemove", (event) => {
123
+ const _zoom = transform(select(svgRef.current).select("#view").node());
124
+ setAbsoluteMousePos(_zoom.invert(pointer(event)).map((n) => n.toFixed(0)));
125
+ setRelativeMousePos(pointer(event).map((n) => n.toFixed(0)));
126
+ });
127
+ }
128
+ }, [showMousePos, graph]);
129
+ useEffect(() => {
130
+ resetZoom();
131
+ }, [viz, graph == null ? void 0 : graph.data]);
132
+ useEffect(() => {
133
+ var _a2, _b2, _c2, _d2;
134
+ if ((_b2 = (_a2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a2.visualization) == null ? void 0 : _b2.type) {
135
+ setViz((_d2 = (_c2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _c2.visualization) == null ? void 0 : _d2.type);
136
+ }
137
+ }, [(_e = (_d = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _d.visualization) == null ? void 0 : _e.type]);
138
+ const treeOptions = useMemo(
90
139
  () => ({
91
- textColor: o.palette.text.primary,
92
- backgroundColor: o.palette.background.paper,
140
+ textColor: theme.palette.text.primary,
141
+ backgroundColor: theme.palette.background.paper,
93
142
  nodeColor: {
94
- border: (S ? oe : ne)(o.palette.background.paper, 0.3),
143
+ border: (isDark ? lighten : darken)(theme.palette.background.paper, 0.3),
95
144
  center: "white"
96
145
  }
97
146
  }),
98
- [S, o.palette.background.paper, o.palette.text.primary]
99
- ), K = m(
147
+ [isDark, theme.palette.background.paper, theme.palette.text.primary]
148
+ );
149
+ const cloudOptions = useMemo(
100
150
  () => ({
101
- textColor: o.palette.text.primary,
102
- backgroundColor: o.palette.background.paper,
151
+ textColor: theme.palette.text.primary,
152
+ backgroundColor: theme.palette.background.paper,
103
153
  nodeColor: {
104
- border: (S ? oe : ne)(o.palette.background.paper, 0.3),
154
+ border: (isDark ? lighten : darken)(theme.palette.background.paper, 0.3),
105
155
  center: "white"
106
156
  }
107
157
  }),
108
- [S, o.palette.background.paper, o.palette.text.primary]
109
- ), X = m(
158
+ [isDark, theme.palette.background.paper, theme.palette.text.primary]
159
+ );
160
+ const visualizations = useMemo(
110
161
  () => ({
111
- tree: () => /* @__PURE__ */ i(
112
- _e,
162
+ tree: () => /* @__PURE__ */ jsx(
163
+ Tree,
113
164
  {
114
- svgRef: a,
115
- graph: t,
116
- labelKeys: b,
117
- onNodeSelectionChanged: D,
118
- zoom: s,
119
- options: V
165
+ svgRef,
166
+ graph,
167
+ labelKeys,
168
+ onNodeSelectionChanged,
169
+ zoom: currentZoom,
170
+ options: treeOptions
120
171
  }
121
172
  ),
122
- cloud: () => /* @__PURE__ */ i(je, { svgRef: a, graph: t, options: K })
173
+ cloud: () => /* @__PURE__ */ jsx(Cloud, { svgRef, graph, options: cloudOptions })
123
174
  }),
124
- [K, s, t, b, D, V]
125
- ), ye = m(() => $.flatMap((e) => {
126
- var y, Q;
127
- const n = (((y = t == null ? void 0 : t.data) == null ? void 0 : y.flat()) ?? []).find((c) => c.id === e);
128
- return n ? (((Q = b == null ? void 0 : b.filter((c) => A(c, n)).pop()) == null ? void 0 : Q.label) ?? "id").split(",").map((c) => {
129
- var ee;
130
- return (ee = Ae(n, c)) == null ? void 0 : ee.toString();
131
- }).filter((c) => !!c).map((c) => ({ id: e, value: c.trim() })) : { id: e, value: e };
132
- }), [t == null ? void 0 : t.data, b, $, A]);
133
- return /* @__PURE__ */ l(
134
- x,
175
+ [cloudOptions, currentZoom, graph, labelKeys, onNodeSelectionChanged, treeOptions]
176
+ );
177
+ const suggestions = useMemo(() => {
178
+ return nodeIds.flatMap((id) => {
179
+ var _a2, _b2;
180
+ const node = (((_a2 = graph == null ? void 0 : graph.data) == null ? void 0 : _a2.flat()) ?? []).find((_node) => _node.id === id);
181
+ if (!node) {
182
+ return { id, value: id };
183
+ }
184
+ const key = ((_b2 = labelKeys == null ? void 0 : labelKeys.filter((comparator) => runComparator(comparator, node)).pop()) == null ? void 0 : _b2.label) ?? "id";
185
+ const value = key.split(",").map((_key) => {
186
+ var _a3;
187
+ return (_a3 = get(node, _key)) == null ? void 0 : _a3.toString();
188
+ }).filter((val) => !!val).map((_value) => ({ id, value: _value.trim() }));
189
+ return value;
190
+ });
191
+ }, [graph == null ? void 0 : graph.data, labelKeys, nodeIds, runComparator]);
192
+ return /* @__PURE__ */ jsxs(
193
+ Stack,
135
194
  {
136
- direction: E === "vertical" ? "row" : "column",
195
+ direction: panelLocation === "vertical" ? "row" : "column",
137
196
  spacing: 1,
138
197
  overflow: "hidden",
139
198
  height: "100%",
140
199
  width: "100%",
141
- sx: se,
200
+ sx,
142
201
  children: [
143
- /* @__PURE__ */ i(x, { direction: "column", spacing: 1, sx: { position: "relative", flex: 1 }, children: /* @__PURE__ */ l(
144
- T,
202
+ /* @__PURE__ */ jsx(Stack, { direction: "column", spacing: 1, sx: { position: "relative", flex: 1 }, children: /* @__PURE__ */ jsxs(
203
+ Card,
145
204
  {
146
205
  variant: "outlined",
147
206
  sx: {
148
207
  flex: 1,
149
208
  position: "relative",
150
- maxHeight: `calc(100vh - 64px - ${o.spacing(1)})`,
209
+ maxHeight: `calc(100vh - 64px - ${theme.spacing(1)})`,
151
210
  "& #viz": {
152
- maxHeight: `calc(100vh - 64px - ${o.spacing(1)})`,
211
+ maxHeight: `calc(100vh - 64px - ${theme.spacing(1)})`,
153
212
  width: "100%",
154
213
  height: "100%",
155
- backgroundColor: o.palette.background.paper
214
+ backgroundColor: theme.palette.background.paper
156
215
  },
157
216
  "& .path": {
158
- transition: o.transitions.create(["opacity"], {
159
- duration: o.transitions.duration.short
217
+ transition: theme.transitions.create(["opacity"], {
218
+ duration: theme.transitions.duration.short
160
219
  }),
161
220
  transform: "translateY(-10px)"
162
221
  },
163
222
  "& .node": {
164
223
  cursor: "pointer",
165
224
  "& > path, & > text, & > polygon, & circle": {
166
- transition: o.transitions.create(["stroke", "fill", "fill-opacity", "stroke-opacity"], {
167
- duration: o.transitions.duration.short
225
+ transition: theme.transitions.create(["stroke", "fill", "fill-opacity", "stroke-opacity"], {
226
+ duration: theme.transitions.duration.short
168
227
  })
169
228
  },
170
229
  "&.hover > .center": {
171
- stroke: k(o.palette.primary.main)
230
+ stroke: cssImportant(theme.palette.primary.main)
172
231
  },
173
232
  "&.hover > .border": {
174
- stroke: k(o.palette.primary.dark)
233
+ stroke: cssImportant(theme.palette.primary.dark)
175
234
  },
176
235
  "&.selected > .center": {
177
- stroke: k(o.palette.success.main)
236
+ stroke: cssImportant(theme.palette.success.main)
178
237
  },
179
238
  "&.selected > .border": {
180
- stroke: k(o.palette.success.dark)
239
+ stroke: cssImportant(theme.palette.success.dark)
181
240
  },
182
241
  "&.selected.hover > .center": {
183
- stroke: k(o.palette.primary.main)
242
+ stroke: cssImportant(theme.palette.primary.main)
184
243
  },
185
244
  "&.selected.hover > .border": {
186
- stroke: k(o.palette.primary.dark)
245
+ stroke: cssImportant(theme.palette.primary.dark)
187
246
  }
188
247
  }
189
248
  },
190
249
  children: [
191
- t ? X[M]() : /* @__PURE__ */ l(ke, { children: [
192
- /* @__PURE__ */ i("svg", { id: "viz", ref: a, children: /* @__PURE__ */ i("g", { id: "view" }) }),
193
- /* @__PURE__ */ i(
194
- he,
250
+ graph ? visualizations[viz]() : /* @__PURE__ */ jsxs(Fragment, { children: [
251
+ /* @__PURE__ */ jsx("svg", { id: "viz", ref: svgRef, children: /* @__PURE__ */ jsx("g", { id: "view" }) }),
252
+ /* @__PURE__ */ jsx(
253
+ Typography,
195
254
  {
196
255
  variant: "h1",
197
256
  color: "text.secondary",
@@ -202,23 +261,23 @@ const rt = ({ graph: t, sx: se = {} }) => {
202
261
  opacity: 0.3,
203
262
  transform: "translateX(-50%) translateY(-50%)"
204
263
  },
205
- children: C("graph.no.dataset")
264
+ children: t("graph.no.dataset")
206
265
  }
207
266
  )
208
267
  ] }),
209
- /* @__PURE__ */ i(
210
- x,
268
+ /* @__PURE__ */ jsx(
269
+ Stack,
211
270
  {
212
271
  direction: "column",
213
272
  spacing: 1,
214
273
  sx: {
215
274
  position: "absolute",
216
- top: o.spacing(1),
217
- left: o.spacing(1),
218
- right: o.spacing(1)
275
+ top: theme.spacing(1),
276
+ left: theme.spacing(1),
277
+ right: theme.spacing(1)
219
278
  },
220
- children: /* @__PURE__ */ l(
221
- x,
279
+ children: /* @__PURE__ */ jsxs(
280
+ Stack,
222
281
  {
223
282
  direction: "row",
224
283
  spacing: 1,
@@ -226,55 +285,55 @@ const rt = ({ graph: t, sx: se = {} }) => {
226
285
  "& > div:first-of-type": {
227
286
  flex: 1,
228
287
  maxWidth: "775px",
229
- backgroundColor: ie(o.palette.background.paper, 0.8)
288
+ backgroundColor: alpha(theme.palette.background.paper, 0.8)
230
289
  }
231
290
  },
232
291
  children: [
233
- /* @__PURE__ */ i(
234
- ze,
292
+ /* @__PURE__ */ jsx(
293
+ Autocomplete,
235
294
  {
236
- disablePortal: !0,
237
- onChange: (e, n) => xe(n.id),
238
- onKeyDown: ve,
239
- options: ye,
295
+ disablePortal: true,
296
+ onChange: (__, value) => onNodeChange(value.id),
297
+ onKeyDown: onKeyPress,
298
+ options: suggestions,
240
299
  sx: { width: "400px" },
241
- getOptionLabel: (e) => e.value,
242
- filterOptions: (e, n) => e.filter((r) => r.value.toLowerCase().includes(n.inputValue)),
243
- renderOption: (e, n) => /* @__PURE__ */ Ce("li", { ...e, key: n.id + n.value }, n.value),
244
- renderInput: (e) => /* @__PURE__ */ i(Se, { ...e, error: fe, label: C("graph.node.input.label") })
300
+ getOptionLabel: (option) => option.value,
301
+ filterOptions: (options, state) => options.filter((opt) => opt.value.toLowerCase().includes(state.inputValue)),
302
+ renderOption: (props, option) => /* @__PURE__ */ createElement("li", { ...props, key: option.id + option.value }, option.value),
303
+ renderInput: (params) => /* @__PURE__ */ jsx(TextField, { ...params, error: hasError, label: t("graph.node.input.label") })
245
304
  }
246
305
  ),
247
- /* @__PURE__ */ l(Ee, { sx: { minWidth: "150px", backgroundColor: ie(o.palette.background.paper, 0.8) }, children: [
248
- /* @__PURE__ */ i(Ie, { id: "viz-label", children: C("graph.visualization") }),
249
- /* @__PURE__ */ i(
250
- Oe,
306
+ /* @__PURE__ */ jsxs(FormControl, { sx: { minWidth: "150px", backgroundColor: alpha(theme.palette.background.paper, 0.8) }, children: [
307
+ /* @__PURE__ */ jsx(InputLabel, { id: "viz-label", children: t("graph.visualization") }),
308
+ /* @__PURE__ */ jsx(
309
+ Select,
251
310
  {
252
- label: C("graph.visualization"),
311
+ label: t("graph.visualization"),
253
312
  labelId: "viz-label",
254
- value: M,
255
- onChange: (e) => H(e.target.value),
313
+ value: viz,
314
+ onChange: (event) => setViz(event.target.value),
256
315
  sx: { textTransform: "capitalize" },
257
- children: Object.keys(X).map((e) => /* @__PURE__ */ i(Ne, { value: e, sx: { textTransform: "capitalize" }, children: e }, e))
316
+ children: Object.keys(visualizations).map((_viz) => /* @__PURE__ */ jsx(MenuItem, { value: _viz, sx: { textTransform: "capitalize" }, children: _viz }, _viz))
258
317
  }
259
318
  )
260
319
  ] }),
261
- /* @__PURE__ */ i(
262
- $e,
320
+ /* @__PURE__ */ jsx(
321
+ ExpandMoreButton,
263
322
  {
264
- disabled: h.length < 1,
265
- expand: I,
266
- onClick: () => B(!I),
267
- "aria-expanded": I,
268
- "aria-label": C("graph.show.more"),
323
+ disabled: selectedNodeIds.length < 1,
324
+ expand: showPanel,
325
+ onClick: () => setShowPanel(!showPanel),
326
+ "aria-expanded": showPanel,
327
+ "aria-label": t("graph.show.more"),
269
328
  size: "small",
270
329
  sx: {
271
330
  marginLeft: "auto !important",
272
331
  alignSelf: "center"
273
332
  },
274
- children: /* @__PURE__ */ i(
275
- ae,
333
+ children: /* @__PURE__ */ jsx(
334
+ Iconified,
276
335
  {
277
- icon: E === "vertical" ? "ic:baseline-chevron-left" : "ic:baseline-expand-more",
336
+ icon: panelLocation === "vertical" ? "ic:baseline-chevron-left" : "ic:baseline-expand-more",
278
337
  fontSize: "medium"
279
338
  }
280
339
  )
@@ -285,64 +344,64 @@ const rt = ({ graph: t, sx: se = {} }) => {
285
344
  )
286
345
  }
287
346
  ),
288
- /* @__PURE__ */ i(
289
- T,
347
+ /* @__PURE__ */ jsx(
348
+ Card,
290
349
  {
291
- variant: w ? "elevation" : "outlined",
292
- elevation: w ? 4 : 0,
350
+ variant: showCoordinates ? "elevation" : "outlined",
351
+ elevation: showCoordinates ? 4 : 0,
293
352
  sx: {
294
353
  position: "absolute",
295
- bottom: o.spacing(0.5),
296
- right: o.spacing(0.5),
354
+ bottom: theme.spacing(0.5),
355
+ right: theme.spacing(0.5),
297
356
  px: 1,
298
357
  py: 0.5,
299
358
  border: "none !important"
300
359
  },
301
- children: /* @__PURE__ */ l(x, { direction: "row", spacing: 0.5, alignItems: "center", children: [
302
- w && /* @__PURE__ */ l("span", { children: [
303
- s.x.toFixed(0),
360
+ children: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", children: [
361
+ showCoordinates && /* @__PURE__ */ jsxs("span", { children: [
362
+ currentZoom.x.toFixed(0),
304
363
  ", ",
305
- s.y.toFixed(0),
364
+ currentZoom.y.toFixed(0),
306
365
  " (",
307
- s.k.toFixed(2),
366
+ currentZoom.k.toFixed(2),
308
367
  "x",
309
368
  ")"
310
369
  ] }),
311
- /* @__PURE__ */ i(
312
- Me,
370
+ /* @__PURE__ */ jsx(
371
+ IconButton,
313
372
  {
314
- size: w ? "small" : "medium",
315
- onClick: () => W(),
316
- disabled: s.k === P.k && s.x === 0 && s.y === 0,
317
- children: /* @__PURE__ */ i(ae, { icon: "ic:baseline-refresh", fontSize: w ? "small" : "medium" })
373
+ size: showCoordinates ? "small" : "medium",
374
+ onClick: () => resetZoom(),
375
+ disabled: currentZoom.k === identity.k && currentZoom.x === 0 && currentZoom.y === 0,
376
+ children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-refresh", fontSize: showCoordinates ? "small" : "medium" })
318
377
  }
319
378
  )
320
379
  ] })
321
380
  }
322
381
  ),
323
- F && /* @__PURE__ */ i(
324
- T,
382
+ showMousePos && /* @__PURE__ */ jsx(
383
+ Card,
325
384
  {
326
385
  variant: "elevation",
327
386
  elevation: 4,
328
387
  sx: {
329
388
  position: "absolute",
330
- bottom: o.spacing(0.5),
331
- left: o.spacing(0.5),
389
+ bottom: theme.spacing(0.5),
390
+ left: theme.spacing(0.5),
332
391
  px: 1,
333
392
  py: 0.5
334
393
  },
335
- children: /* @__PURE__ */ i("code", { children: /* @__PURE__ */ l(x, { direction: "row", spacing: 1, children: [
336
- /* @__PURE__ */ l("span", { children: [
394
+ children: /* @__PURE__ */ jsx("code", { children: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
395
+ /* @__PURE__ */ jsxs("span", { children: [
337
396
  "(",
338
397
  "abs: ",
339
- me.join(", "),
398
+ absoluteMousePos.join(", "),
340
399
  ")"
341
400
  ] }),
342
- /* @__PURE__ */ l("span", { children: [
401
+ /* @__PURE__ */ jsxs("span", { children: [
343
402
  "(",
344
403
  "rel: ",
345
- ce.join(", "),
404
+ relativeMousePos.join(", "),
346
405
  ")"
347
406
  ] })
348
407
  ] }) })
@@ -351,21 +410,21 @@ const rt = ({ graph: t, sx: se = {} }) => {
351
410
  ]
352
411
  }
353
412
  ) }),
354
- /* @__PURE__ */ i(
355
- Pe,
413
+ /* @__PURE__ */ jsx(
414
+ Collapse,
356
415
  {
357
- in: I && h.length > 0,
358
- orientation: E === "vertical" ? "horizontal" : "vertical",
359
- appear: !0,
360
- unmountOnExit: !0,
361
- children: /* @__PURE__ */ i(
362
- x,
416
+ in: showPanel && selectedNodeIds.length > 0,
417
+ orientation: panelLocation === "vertical" ? "horizontal" : "vertical",
418
+ appear: true,
419
+ unmountOnExit: true,
420
+ children: /* @__PURE__ */ jsx(
421
+ Stack,
363
422
  {
364
423
  direction: "column",
365
424
  spacing: 1,
366
- sx: E === "vertical" ? { width: "450px", height: "100%" } : { width: "100%", height: "300px" },
425
+ sx: panelLocation === "vertical" ? { width: "450px", height: "100%" } : { width: "100%", height: "300px" },
367
426
  pb: 1,
368
- children: /* @__PURE__ */ i(He, { selectedNodeIds: h, findNode: be })
427
+ children: /* @__PURE__ */ jsx(NodePanel, { selectedNodeIds, findNode })
369
428
  }
370
429
  )
371
430
  }
@@ -375,5 +434,5 @@ const rt = ({ graph: t, sx: se = {} }) => {
375
434
  );
376
435
  };
377
436
  export {
378
- rt as default
437
+ Graph as default
379
438
  };