@cccsaurora/clue-ui 1.0.1 → 1.1.0-dev.10

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 (185) hide show
  1. package/ActionForm-D4ryHO0M.js +436 -0
  2. package/AnnotationDetails-YAPoqw3R.js +175 -0
  3. package/AnnotationPreview-DiQDjt9s.js +188 -0
  4. package/ClueEnrichContext-DIn6g8tw.js +522 -0
  5. package/FlexOne-BSYAhhtG.js +9 -0
  6. package/_Map-kgDsDYxq.js +64 -0
  7. package/_MapCache-DabaaWfq.js +161 -0
  8. package/_Uint8Array-BlVVH1tp.js +129 -0
  9. package/_baseAssignValue-CNbcU6Nb.js +25 -0
  10. package/_baseClone-D3a8Pa4T.js +284 -0
  11. package/_baseExtremum-B1o1zHjR.js +33 -0
  12. package/_baseFlatten-D4huXoEI.js +92 -0
  13. package/_baseGet-BSK_nnoz.js +109 -0
  14. package/_baseIsEqual-B5xLoweL.js +238 -0
  15. package/_baseIteratee-p6Nj07-n.js +126 -0
  16. package/_baseSlice-GAv_YFTT.js +20 -0
  17. package/_baseSum-D0WC1dN0.js +13 -0
  18. package/_baseUniq-CpupKWcL.js +89 -0
  19. package/_commonjsHelpers-CUmg6egw.js +6 -0
  20. package/_createAggregator-BpVy5xMi.js +63 -0
  21. package/_getPrototype-D1LAdQKO.js +5 -0
  22. package/_getTag-D3ToyefI.js +126 -0
  23. package/api/lookup/enrich.d.ts +3 -3
  24. package/cloneDeep-CjP5k9zW.js +8 -0
  25. package/components/AnnotationBody.js +49 -34
  26. package/components/AnnotationDetailPopover.js +36 -30
  27. package/components/AnnotationDetails.js +21 -155
  28. package/components/AnnotationEntry.js +50 -52
  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 +104 -92
  33. package/components/EnrichedChip.js +134 -109
  34. package/components/EnrichedTypography.js +136 -110
  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 +64 -50
  40. package/components/actions/ResultModal.js +37 -34
  41. package/components/actions/form/schemaAdapter.js +39 -20
  42. package/components/display/graph/ExpandMoreButton.js +10 -10
  43. package/components/display/graph/elements/NodeCard.js +92 -76
  44. package/components/display/graph/elements/NodeTag.js +15 -13
  45. package/components/display/graph/index.js +258 -200
  46. package/components/display/graph/visualizations/Leaf.js +88 -69
  47. package/components/display/graph/visualizations/cloud/index.js +98 -81
  48. package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
  49. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  50. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  51. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  53. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  54. package/components/display/graph/visualizations/icons/index.js +14 -13
  55. package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
  56. package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
  57. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  58. package/components/display/graph/visualizations/tree/index.js +407 -305
  59. package/components/display/icons/Iconified.js +27 -12
  60. package/components/display/json/index.js +4 -4
  61. package/components/display/markdown/DynamicTabs.js +22 -17
  62. package/components/display/markdown/index.js +8527 -5670
  63. package/components/display/markdown/markdownPlugins/tabs.js +1 -1
  64. package/components/enrichment/EnrichPopover.js +55 -47
  65. package/components/fetchers/Fetcher.js +123 -95
  66. package/components/fetchers/PreviewModal.js +20 -17
  67. package/components/fetchers/StatusChip.js +22 -18
  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 +37 -28
  72. package/countBy-C69WslUA.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-D3C3lEU3.js +8 -0
  77. package/groupBy-DC2oOuBN.js +14 -0
  78. package/hooks/ClueActionContext.d.ts +1 -1
  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 +74 -46
  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 +22 -11
  89. package/hooks/useAnnotations.js +45 -33
  90. package/hooks/useClue.js +6 -4
  91. package/hooks/useClueActions.js +3 -3
  92. package/hooks/useClueConfig.js +5 -5
  93. package/hooks/useClueTypeConfig.d.ts +2 -1
  94. package/hooks/useClueTypeConfig.js +3 -3
  95. package/hooks/useComparator.js +722 -435
  96. package/hooks/useErrors.js +22 -18
  97. package/hooks/useMyHighlights.js +66 -36
  98. package/hooks/useMyLocalStorage.js +63 -43
  99. package/iconify-CXMreGTg.js +1782 -0
  100. package/icons/Action.js +66 -49
  101. package/icons/Assessment.js +84 -68
  102. package/icons/Context.js +75 -61
  103. package/icons/Opinion.js +77 -65
  104. package/icons/iconMap.js +2 -2
  105. package/identity-CPGTqrE4.js +6 -0
  106. package/index-BDVjGvMI.js +696 -0
  107. package/index-BHPT3qoB.js +1172 -0
  108. package/index-BMxyILVD.js +465 -0
  109. package/index-BbPn6-Mw.js +15750 -0
  110. package/index-Dz1kF2MU.js +17654 -0
  111. package/isEmpty-BQkZubqU.js +29 -0
  112. package/isNil-CIubwp4T.js +6 -0
  113. package/isObject-FTY-5JQX.js +7 -0
  114. package/isObjectLike-OAgjjZye.js +48 -0
  115. package/isSymbol-Xd2FsJyp.js +8 -0
  116. package/last-CUCl67Im.js +7 -0
  117. package/main.d.ts +0 -1
  118. package/main.js +58 -68
  119. package/package.json +1 -1
  120. package/sortBy-B-UKp4GT.js +100 -0
  121. package/sumBy-MYkDPHZL.js +8 -0
  122. package/tabs-xGuUGsJd.js +254 -0
  123. package/text/Frequency.js +42 -23
  124. package/toFinite-Bc55msYj.js +16 -0
  125. package/toNumber-DPxy1FBy.js +39 -0
  126. package/useClueTypeConfig-CH-nGq6a.js +3184 -0
  127. package/utils/chain.js +91 -64
  128. package/utils/classificationParser.d.ts +8 -8
  129. package/utils/classificationParser.js +517 -267
  130. package/utils/constants.js +35 -10
  131. package/utils/graph.js +72 -45
  132. package/utils/hashUtil.js +7 -7
  133. package/utils/line.js +131 -81
  134. package/utils/loggerUtil.js +5 -3
  135. package/utils/sessionStorage.js +41 -29
  136. package/utils/utils.js +9 -9
  137. package/utils/window.js +21 -10
  138. package/utils-Dr4wbKBZ.js +4182 -0
  139. package/ActionForm-WIj7BfD5.js +0 -340
  140. package/AnnotationPreview-DWRDhxUB.js +0 -140
  141. package/ClueEnrichContext-CbJVBm4w.js +0 -397
  142. package/FlexOne-BXWFOd1T.js +0 -6
  143. package/_Map-DXNg_Z-q.js +0 -54
  144. package/_MapCache-Cu25RRDU.js +0 -129
  145. package/_Uint8Array-DlJCtTvG.js +0 -102
  146. package/_baseAssignValue-CUmzp727.js +0 -20
  147. package/_baseClone-BlMmRXeX.js +0 -208
  148. package/_baseExtremum-P_0akmCi.js +0 -27
  149. package/_baseFlatten-CN7vDNEQ.js +0 -72
  150. package/_baseGet-Dgf6_xCm.js +0 -80
  151. package/_baseIsEqual-Cpjtfb3Q.js +0 -173
  152. package/_baseIteratee-CP1bocOX.js +0 -95
  153. package/_baseSlice-M5RKzt1A.js +0 -10
  154. package/_baseSum-wEbgNeUs.js +0 -10
  155. package/_baseUniq-tMFmk80M.js +0 -61
  156. package/_commonjsHelpers-C6fGbg64.js +0 -6
  157. package/_createAggregator-B4Cav8ZM.js +0 -53
  158. package/_getPrototype-CHAFQYL_.js +0 -5
  159. package/_getTag-BV_UoLYG.js +0 -90
  160. package/cloneDeep-BPVpFBzJ.js +0 -8
  161. package/countBy-DOutsa_w.js +0 -8
  162. package/debounce-DryYcbJ4.js +0 -56
  163. package/get-Bow1vKwx.js +0 -8
  164. package/groupBy-BheQYl6f.js +0 -8
  165. package/iconify-BBckr5AQ.js +0 -1263
  166. package/identity-ByMq8VxU.js +0 -6
  167. package/index-4YFAh_sa.js +0 -358
  168. package/index-E7g8cRyW.js +0 -568
  169. package/index-HuYhutsd.js +0 -975
  170. package/index-WvFmjbxF.js +0 -12734
  171. package/index-p5_wX7q1.js +0 -11729
  172. package/isEmpty-g47Qir2A.js +0 -21
  173. package/isNil-CjWwlQS3.js +0 -6
  174. package/isObject-B53jY8Qg.js +0 -7
  175. package/isObjectLike-BatpeCIi.js +0 -29
  176. package/isSymbol-C3_SC0Qp.js +0 -8
  177. package/isUndefined-DiNCDKoz.js +0 -10
  178. package/last-7CdUxN0r.js +0 -7
  179. package/sortBy-ITdmD17L.js +0 -79
  180. package/sumBy-DxJUU2E8.js +0 -8
  181. package/tabs-CgADNA57.js +0 -195
  182. package/toFinite-BMy6GObD.js +0 -14
  183. package/toNumber-YVhnnJv4.js +0 -31
  184. package/useClueTypeConfig-BQ33EiyB.js +0 -2273
  185. package/utils-C_RX5uMP.js +0 -2704
@@ -0,0 +1,436 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { materialRenderers, materialCells } from "@jsonforms/material-renderers";
3
+ import { JsonForms } from "@jsonforms/react";
4
+ import { Stack, Typography, IconButton, Modal, Paper, Box, Button, Divider, CircularProgress, Collapse } from "@mui/material";
5
+ import Iconified from "./components/display/icons/Iconified.js";
6
+ import { J as JSONViewer } from "./index-BMxyILVD.js";
7
+ import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
8
+ import { c as createContext, u as useContextSelector, a as useContext } from "./index-BDVjGvMI.js";
9
+ import { A as Ajv } from "./index-Dz1kF2MU.js";
10
+ import { a as api } from "./useClueTypeConfig-CH-nGq6a.js";
11
+ import { d as toString } from "./_baseGet-BSK_nnoz.js";
12
+ import { b as baseSlice } from "./_baseSlice-GAv_YFTT.js";
13
+ import { i as isEqual } from "./utils-Dr4wbKBZ.js";
14
+ import { useState, useCallback, useEffect, useMemo, memo } from "react";
15
+ import ErrorBoundary from "./components/ErrorBoundary.js";
16
+ import { adaptSchema } from "./components/actions/form/schemaAdapter.js";
17
+ import ResultModal from "./components/actions/ResultModal.js";
18
+ import { SNACKBAR_EVENT_ID } from "./data/event.js";
19
+ import { safeDispatchEvent } from "./utils/window.js";
20
+ import useClue from "./hooks/useClue.js";
21
+ function castSlice(array, start, end) {
22
+ var length = array.length;
23
+ end = end === void 0 ? length : end;
24
+ return !start && end >= length ? array : baseSlice(array, start, end);
25
+ }
26
+ var rsAstralRange$1 = "\\ud800-\\udfff", rsComboMarksRange$1 = "\\u0300-\\u036f", reComboHalfMarksRange$1 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$1 = "\\u20d0-\\u20ff", rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1, rsVarRange$1 = "\\ufe0e\\ufe0f";
27
+ var rsZWJ$1 = "\\u200d";
28
+ var reHasUnicode = RegExp("[" + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + "]");
29
+ function hasUnicode(string) {
30
+ return reHasUnicode.test(string);
31
+ }
32
+ function asciiToArray(string) {
33
+ return string.split("");
34
+ }
35
+ var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f";
36
+ var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d";
37
+ var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
38
+ var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
39
+ function unicodeToArray(string) {
40
+ return string.match(reUnicode) || [];
41
+ }
42
+ function stringToArray(string) {
43
+ return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
44
+ }
45
+ function createCaseFirst(methodName) {
46
+ return function(string) {
47
+ string = toString(string);
48
+ var strSymbols = hasUnicode(string) ? stringToArray(string) : void 0;
49
+ var chr = strSymbols ? strSymbols[0] : string.charAt(0);
50
+ var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
51
+ return chr[methodName]() + trailing;
52
+ };
53
+ }
54
+ var upperFirst = createCaseFirst("toUpperCase");
55
+ function capitalize(string) {
56
+ return upperFirst(toString(string).toLowerCase());
57
+ }
58
+ const AJV = new Ajv({ removeAdditional: true, coerceTypes: true, strict: false });
59
+ const ClueActionContext = createContext(null);
60
+ const ClueActionProvider = ({
61
+ baseURL,
62
+ children,
63
+ classification: defaultClassification,
64
+ getToken,
65
+ onNetworkCall
66
+ }) => {
67
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
68
+ const { ready } = useClue();
69
+ const [runningActionData, setRunningActionData] = useState(null);
70
+ const [actionResults, setActionResults] = useState({});
71
+ const [showResultModal, setShowResultModal] = useState(false);
72
+ const [lastResult, setLastResult] = useState(null);
73
+ const [loading, setLoading] = useState(false);
74
+ const [availableActions, setAvailableActions] = useState({});
75
+ const refreshActions = useCallback(async () => {
76
+ if (!ready) {
77
+ return;
78
+ }
79
+ const headers = {};
80
+ const token = getToken == null ? void 0 : getToken();
81
+ if (token) {
82
+ headers.Authorization = `Bearer ${token}`;
83
+ }
84
+ let requestConfig = { baseURL, headers };
85
+ if (onNetworkCall) {
86
+ requestConfig = onNetworkCall(requestConfig);
87
+ }
88
+ const _actions = await api.actions.get(requestConfig);
89
+ if (_actions) {
90
+ setAvailableActions(_actions);
91
+ }
92
+ return _actions;
93
+ }, [baseURL, getToken, onNetworkCall, ready]);
94
+ useEffect(() => {
95
+ refreshActions();
96
+ }, [baseURL, ready]);
97
+ const getHashKey = useCallback(
98
+ (type, value, classification) => JSON.stringify({ type, value, classification: classification ?? defaultClassification }),
99
+ [defaultClassification]
100
+ );
101
+ const executeAction = useCallback(
102
+ async (actionId, selectors, params, options) => {
103
+ const { forceMenu, onComplete, skipMenu, timeout } = {
104
+ forceMenu: false,
105
+ skipMenu: false,
106
+ onComplete: null,
107
+ timeout: null,
108
+ ...options
109
+ };
110
+ const headers = {};
111
+ const token = getToken == null ? void 0 : getToken();
112
+ if (token) {
113
+ headers.Authorization = `Bearer ${token}`;
114
+ }
115
+ if (!Object.keys(availableActions).includes(actionId)) {
116
+ throw new Error("Invalid action id");
117
+ }
118
+ const stringifiedSelectors = selectors.map(
119
+ (selector) => selector.type === "telemetry" ? { ...selector, value: JSON.stringify(selector.value) } : selector
120
+ );
121
+ const actionToRun = availableActions[actionId];
122
+ const validator = AJV.compile(actionToRun.params);
123
+ const validatedParams = { selectors: stringifiedSelectors, ...params };
124
+ setLoading(true);
125
+ if (!validator(validatedParams) || forceMenu) {
126
+ if (skipMenu && !forceMenu) {
127
+ console.error(`Form is not valid (${validator.errors.length} errors)`);
128
+ throw new Error("Form is not completed");
129
+ }
130
+ if ((runningActionData == null ? void 0 : runningActionData.id) === actionId) {
131
+ console.error(`Form is not valid (${validator.errors.length} errors)`);
132
+ safeDispatchEvent(
133
+ new CustomEvent(SNACKBAR_EVENT_ID, {
134
+ detail: {
135
+ message: t("action.error.validation"),
136
+ level: "error"
137
+ }
138
+ })
139
+ );
140
+ }
141
+ setRunningActionData({
142
+ id: actionId,
143
+ action: actionToRun,
144
+ selectors,
145
+ params: validatedParams ?? {},
146
+ onComplete,
147
+ timeout
148
+ });
149
+ return;
150
+ }
151
+ try {
152
+ let requestConfig = { baseURL, headers };
153
+ if (onNetworkCall) {
154
+ requestConfig = onNetworkCall(requestConfig);
155
+ }
156
+ const actionResult = await api.actions.post(
157
+ actionId,
158
+ stringifiedSelectors,
159
+ validatedParams ?? {},
160
+ { timeout },
161
+ requestConfig
162
+ );
163
+ const actionResultWithData = { ...actionResult, actionId, action: actionToRun };
164
+ onComplete == null ? void 0 : onComplete(actionResultWithData);
165
+ setActionResults((_results) => {
166
+ const keys = selectors.map((value) => getHashKey(value.type, value.value, value.classification));
167
+ return {
168
+ ..._results,
169
+ ...keys.reduce(
170
+ (acc, key) => ({
171
+ ...acc,
172
+ [key]: [..._results[key] ?? [], actionResultWithData]
173
+ }),
174
+ {}
175
+ )
176
+ };
177
+ });
178
+ safeDispatchEvent(
179
+ new CustomEvent(SNACKBAR_EVENT_ID, {
180
+ detail: {
181
+ message: /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, width: "100%", children: [
182
+ /* @__PURE__ */ jsx(Typography, { children: actionResult.summary }),
183
+ actionResult.link && /* @__PURE__ */ jsx(IconButton, { component: "a", href: actionResult.link, size: "small", target: "_blank", children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-open-in-new", fontSize: "small" }) })
184
+ ] }),
185
+ timeout: actionResult.link ? null : 5e3,
186
+ level: actionResult.outcome === "success" ? "success" : "error",
187
+ options: {
188
+ style: {
189
+ minWidth: 0
190
+ },
191
+ SnackbarProps: {
192
+ style: {
193
+ minWidth: 0
194
+ }
195
+ }
196
+ }
197
+ }
198
+ })
199
+ );
200
+ if (actionResult.outcome === "success") {
201
+ setRunningActionData(null);
202
+ }
203
+ if (actionResult.format) {
204
+ setLastResult({ ...actionResult, actionId, action: actionToRun });
205
+ if (actionResult.format !== "pivot") {
206
+ setShowResultModal(true);
207
+ } else {
208
+ window.open(actionResult.output, "_blank", "noreferrer");
209
+ }
210
+ }
211
+ } catch (e) {
212
+ safeDispatchEvent(
213
+ new CustomEvent(SNACKBAR_EVENT_ID, {
214
+ detail: {
215
+ message: e.toString(),
216
+ level: "error"
217
+ }
218
+ })
219
+ );
220
+ } finally {
221
+ setLoading(false);
222
+ }
223
+ },
224
+ [availableActions, baseURL, getHashKey, getToken, onNetworkCall, runningActionData == null ? void 0 : runningActionData.id, t]
225
+ );
226
+ const cancelAction = useCallback(() => {
227
+ setRunningActionData(null);
228
+ setLoading(false);
229
+ }, []);
230
+ const getActionResults = useCallback(
231
+ (type, value, classification) => actionResults[getHashKey(type, value, classification)] ?? [],
232
+ [actionResults, getHashKey]
233
+ );
234
+ const context = useMemo(
235
+ () => ({
236
+ availableActions,
237
+ executeAction,
238
+ cancelAction,
239
+ getActionResults,
240
+ loading,
241
+ refreshActions
242
+ }),
243
+ [availableActions, cancelAction, executeAction, getActionResults, loading, refreshActions]
244
+ );
245
+ return /* @__PURE__ */ jsxs(ClueActionContext.Provider, { value: context, children: [
246
+ children,
247
+ /* @__PURE__ */ jsxs(ErrorBoundary, { children: [
248
+ runningActionData && /* @__PURE__ */ jsx(ActionForm$1, { runningActionData }),
249
+ /* @__PURE__ */ jsx(
250
+ ResultModal,
251
+ {
252
+ show: showResultModal && !!lastResult,
253
+ result: lastResult,
254
+ onClose: () => setShowResultModal(false)
255
+ }
256
+ )
257
+ ] })
258
+ ] });
259
+ };
260
+ const useClueActions = () => {
261
+ return useContext(ClueActionContext);
262
+ };
263
+ const WRAPPED_RENDERERS = materialRenderers.map((value) => ({
264
+ ...value,
265
+ renderer: ({ ...props }) => /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(value.renderer, { ...props }) })
266
+ }));
267
+ const ActionForm = ({ runningActionData }) => {
268
+ const { executeAction, cancelAction } = useClueActions();
269
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
270
+ const [loading, setLoading] = useState(false);
271
+ const [errors, setErrors] = useState(null);
272
+ const [formData, setFormData] = useState(runningActionData == null ? void 0 : runningActionData.params);
273
+ const [showFormDataJson, setShowFormDataJson] = useState(false);
274
+ const formSchema = useMemo(
275
+ () => (runningActionData == null ? void 0 : runningActionData.action) ? { ...adaptSchema(runningActionData.action.params), ...runningActionData.action.extra_schema ?? {} } : null,
276
+ [runningActionData == null ? void 0 : runningActionData.action]
277
+ );
278
+ const uiSchema = useMemo(
279
+ () => ({
280
+ type: "VerticalLayout",
281
+ elements: Object.entries((formSchema == null ? void 0 : formSchema.properties) ?? {}).sort(([a_key, a_ent], [b_key, b_ent]) => {
282
+ if (!!a_ent.order || !!b_ent.order) {
283
+ return a_ent.order - b_ent.order;
284
+ } else {
285
+ return +(formSchema == null ? void 0 : formSchema.required.includes(a_key)) - +(formSchema == null ? void 0 : formSchema.required.includes(b_key));
286
+ }
287
+ }).map(([key, value]) => ({
288
+ type: "Control",
289
+ scope: `#/properties/${key}`,
290
+ options: {
291
+ autocomplete: !!value.enum,
292
+ showUnfocusedDescription: true,
293
+ ...value.options
294
+ },
295
+ rule: value.rule
296
+ }))
297
+ }),
298
+ [formSchema == null ? void 0 : formSchema.properties, formSchema == null ? void 0 : formSchema.required]
299
+ );
300
+ const execute = useCallback(async () => {
301
+ try {
302
+ setLoading(true);
303
+ const options = {};
304
+ if (runningActionData == null ? void 0 : runningActionData.onComplete) {
305
+ options.onComplete = runningActionData == null ? void 0 : runningActionData.onComplete;
306
+ }
307
+ if (runningActionData == null ? void 0 : runningActionData.timeout) {
308
+ options.timeout = runningActionData == null ? void 0 : runningActionData.timeout;
309
+ }
310
+ await executeAction(runningActionData == null ? void 0 : runningActionData.id, runningActionData == null ? void 0 : runningActionData.selectors, formData, options);
311
+ } catch (e) {
312
+ console.error(e);
313
+ } finally {
314
+ setLoading(false);
315
+ }
316
+ }, [
317
+ executeAction,
318
+ runningActionData == null ? void 0 : runningActionData.id,
319
+ runningActionData == null ? void 0 : runningActionData.selectors,
320
+ runningActionData == null ? void 0 : runningActionData.onComplete,
321
+ runningActionData == null ? void 0 : runningActionData.timeout,
322
+ formData
323
+ ]);
324
+ if (!(runningActionData == null ? void 0 : runningActionData.action)) {
325
+ return;
326
+ }
327
+ try {
328
+ return /* @__PURE__ */ jsx(Modal, { open: true, sx: { display: "flex", alignItems: "center", justifyContent: "center" }, onClose: cancelAction, children: /* @__PURE__ */ jsx(
329
+ Paper,
330
+ {
331
+ sx: { maxHeight: "80%", maxWidth: "80%", height: "100%", px: 2, pt: 2, minWidth: "750px", overflow: "auto" },
332
+ children: /* @__PURE__ */ jsxs(
333
+ Stack,
334
+ {
335
+ spacing: 1,
336
+ height: "100%",
337
+ sx: {
338
+ ".MuiFormHelperText-root": {
339
+ marginLeft: "0 !important",
340
+ "&:last-of-type": { mb: 3 }
341
+ }
342
+ },
343
+ children: [
344
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
345
+ /* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 1, children: [
346
+ /* @__PURE__ */ jsxs(Typography, { variant: "h5", children: [
347
+ t("actions.executing"),
348
+ " ",
349
+ runningActionData == null ? void 0 : runningActionData.action.id.replace(/_/g, " ").split(" ").map(capitalize).join(" ")
350
+ ] }),
351
+ (runningActionData == null ? void 0 : runningActionData.action.summary) && /* @__PURE__ */ jsx(Typography, { variant: "body1", color: "text.secondary", sx: { pb: 1.5 }, children: runningActionData == null ? void 0 : runningActionData.action.summary })
352
+ ] }),
353
+ /* @__PURE__ */ jsx(Box, { flex: 1 }),
354
+ /* @__PURE__ */ jsx(Box, { alignContent: "end", children: /* @__PURE__ */ jsx(
355
+ Button,
356
+ {
357
+ variant: "outlined",
358
+ onClick: () => setShowFormDataJson((prev) => !prev),
359
+ startIcon: /* @__PURE__ */ jsx(
360
+ Box,
361
+ {
362
+ component: "span",
363
+ sx: (theme) => ({
364
+ transition: theme.transitions.create("transform"),
365
+ transform: showFormDataJson ? "rotate(180deg)" : "rotate(0deg)"
366
+ }),
367
+ children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-keyboard-double-arrow-right" })
368
+ }
369
+ ),
370
+ children: !showFormDataJson ? t("actions.json.show") : t("actions.json.hide")
371
+ }
372
+ ) })
373
+ ] }),
374
+ /* @__PURE__ */ jsx(Divider, { orientation: "horizontal", variant: "middle" }),
375
+ /* @__PURE__ */ jsx(Box, { pt: 1.5 }),
376
+ /* @__PURE__ */ jsxs(Stack, { flexGrow: 1, direction: "row", spacing: 1, children: [
377
+ /* @__PURE__ */ jsxs(Stack, { direction: "column", flexGrow: 1, children: [
378
+ /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsx(
379
+ JsonForms,
380
+ {
381
+ schema: formSchema,
382
+ uischema: uiSchema,
383
+ renderers: WRAPPED_RENDERERS,
384
+ cells: materialCells,
385
+ data: formData,
386
+ onChange: ({ data, errors: _errors }) => {
387
+ if (!isEqual(data, formData)) {
388
+ setFormData(data);
389
+ }
390
+ setErrors(_errors);
391
+ },
392
+ config: {}
393
+ }
394
+ ) }),
395
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, pb: 1, children: [
396
+ /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
397
+ /* @__PURE__ */ jsx(Button, { color: "error", variant: "outlined", onClick: cancelAction, children: t("cancel") }),
398
+ /* @__PURE__ */ jsx(
399
+ Button,
400
+ {
401
+ color: "success",
402
+ variant: "outlined",
403
+ disabled: loading || (errors == null ? void 0 : errors.length) > 0,
404
+ onClick: execute,
405
+ endIcon: loading && /* @__PURE__ */ jsx(CircularProgress, { color: "inherit", size: 18 }),
406
+ children: t("actions.execute")
407
+ }
408
+ )
409
+ ] })
410
+ ] }),
411
+ /* @__PURE__ */ jsx(Collapse, { orientation: "horizontal", in: showFormDataJson, unmountOnExit: true, mountOnEnter: true, children: /* @__PURE__ */ jsxs(Stack, { direction: "row", height: "100%", spacing: 1, children: [
412
+ /* @__PURE__ */ jsx(Divider, { orientation: "vertical" }),
413
+ /* @__PURE__ */ jsxs(Stack, { children: [
414
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", children: t("action.data") }),
415
+ /* @__PURE__ */ jsx(Box, { width: 600, height: "100%", children: /* @__PURE__ */ jsx(JSONViewer, { data: formData, slotProps: { stack: { height: "100%" }, json: { name: false } } }) })
416
+ ] })
417
+ ] }) })
418
+ ] })
419
+ ]
420
+ }
421
+ )
422
+ }
423
+ ) });
424
+ } catch (e) {
425
+ console.warn(e);
426
+ return null;
427
+ }
428
+ };
429
+ const ActionForm$1 = memo(ActionForm);
430
+ export {
431
+ ActionForm$1 as A,
432
+ ClueActionProvider as C,
433
+ ClueActionContext as a,
434
+ capitalize as c,
435
+ useClueActions as u
436
+ };
@@ -0,0 +1,175 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { I as Icon } from "./iconify-CXMreGTg.js";
3
+ import { useTheme, Stack, Typography, Tooltip, Box, IconButton, CircularProgress, Chip, Accordion, AccordionSummary, AccordionDetails, Divider } from "@mui/material";
4
+ import Iconified from "./components/display/icons/Iconified.js";
5
+ import { SNACKBAR_EVENT_ID } from "./data/event.js";
6
+ import { ClueComponentContext } from "./hooks/ClueComponentContext.js";
7
+ import { useClueEnrichSelector } from "./hooks/selectors.js";
8
+ import useAnnotations from "./hooks/useAnnotations.js";
9
+ import useErrors from "./hooks/useErrors.js";
10
+ import { ICON_MAP } from "./icons/iconMap.js";
11
+ import { safeDispatchEvent } from "./utils/window.js";
12
+ import { g as groupBy } from "./groupBy-DC2oOuBN.js";
13
+ import { u as uniq } from "./ClueEnrichContext-DIn6g8tw.js";
14
+ import { memo, useState, useMemo, useCallback, useEffect } from "react";
15
+ import { u as useContextSelector } from "./index-BDVjGvMI.js";
16
+ import ExecutePopover from "./components/actions/ExecutePopover.js";
17
+ import AnnotationEntry from "./components/AnnotationEntry.js";
18
+ import ClassificationChip from "./components/ClassificationChip.js";
19
+ import EnrichPopover from "./components/enrichment/EnrichPopover.js";
20
+ function isNull(value) {
21
+ return value === null;
22
+ }
23
+ const AnnotationDetails = ({ enrichRequest, setReady, updatePosition }) => {
24
+ const theme = useTheme();
25
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
26
+ const [filter, setFilter] = useState("all");
27
+ const enrich = useClueEnrichSelector((state) => state.enrich);
28
+ const [annotations, loading] = useAnnotations(
29
+ enrichRequest == null ? void 0 : enrichRequest.type,
30
+ enrichRequest == null ? void 0 : enrichRequest.value,
31
+ enrichRequest == null ? void 0 : enrichRequest.classification,
32
+ { skipEnrichment: true }
33
+ );
34
+ const errors = useErrors(enrichRequest == null ? void 0 : enrichRequest.value);
35
+ const options = useMemo(
36
+ () => ["all", ...uniq((annotations ?? []).map((annotation) => annotation.type))],
37
+ [annotations]
38
+ );
39
+ const annotationsByType = useMemo(() => groupBy(annotations ?? [], "type"), [annotations]);
40
+ const forceEnrich = useCallback(async () => {
41
+ await enrich(enrichRequest.type, enrichRequest.value, {
42
+ classification: enrichRequest.classification,
43
+ timeout: 15,
44
+ force: true
45
+ });
46
+ }, [enrichRequest, enrich]);
47
+ useEffect(() => {
48
+ if (!setReady) {
49
+ return;
50
+ }
51
+ setReady(enrichRequest && !isNull(annotations));
52
+ updatePosition == null ? void 0 : updatePosition();
53
+ }, [annotations, enrichRequest, setReady, updatePosition]);
54
+ return enrichRequest && !isNull(annotations) && /* @__PURE__ */ jsxs(Stack, { direction: "column", sx: { p: 1, width: "100%" }, spacing: 1, children: [
55
+ /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
56
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
57
+ /* @__PURE__ */ jsxs(Stack, { children: [
58
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
59
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", fontWeight: "bold", children: "Clue" }),
60
+ enrichRequest.classification && /* @__PURE__ */ jsx(ClassificationChip, { size: "small", classification: enrichRequest.classification })
61
+ ] }),
62
+ /* @__PURE__ */ jsxs(Typography, { variant: "caption", color: "text.secondary", children: [
63
+ enrichRequest.type.toLocaleUpperCase(),
64
+ " ",
65
+ t("enrichment")
66
+ ] })
67
+ ] }),
68
+ /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
69
+ /* @__PURE__ */ jsx(Tooltip, { title: t("refresh"), children: /* @__PURE__ */ jsx(Box, { sx: { alignSelf: "center", m: -1 }, children: /* @__PURE__ */ jsx(IconButton, { onClick: () => forceEnrich(), disabled: loading, children: loading ? /* @__PURE__ */ jsx(CircularProgress, { variant: "indeterminate", size: 20 }) : /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-replay", fontSize: "small" }) }) }) }),
70
+ /* @__PURE__ */ jsx(Tooltip, { title: t("clipboard"), children: /* @__PURE__ */ jsx(
71
+ IconButton,
72
+ {
73
+ sx: { alignSelf: "center", m: -1 },
74
+ onClick: () => {
75
+ navigator.clipboard.writeText(enrichRequest.value);
76
+ safeDispatchEvent(
77
+ new CustomEvent(SNACKBAR_EVENT_ID, {
78
+ detail: {
79
+ message: `${enrichRequest.value} ${t("clipboard.success")}`,
80
+ level: "success"
81
+ }
82
+ })
83
+ );
84
+ },
85
+ children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:outline-assignment", fontSize: "small" })
86
+ }
87
+ ) }),
88
+ /* @__PURE__ */ jsx(EnrichPopover, { selector: enrichRequest }),
89
+ /* @__PURE__ */ jsx(ExecutePopover, { selectors: [enrichRequest] })
90
+ ] }),
91
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.5, children: [
92
+ options.map((opt, id) => /* @__PURE__ */ jsx(
93
+ Chip,
94
+ {
95
+ size: "small",
96
+ variant: opt === filter ? "filled" : "outlined",
97
+ icon: ICON_MAP[opt] && /* @__PURE__ */ jsx(Icon, { icon: ICON_MAP[opt] }),
98
+ label: /* @__PURE__ */ jsxs(Typography, { variant: "caption", textTransform: "capitalize", children: [
99
+ opt,
100
+ ":",
101
+ " ",
102
+ opt === "all" ? annotations.length : annotations.filter((annotation) => annotation.type === opt).length
103
+ ] }),
104
+ onClick: () => setFilter(opt)
105
+ },
106
+ id
107
+ )),
108
+ (errors == null ? void 0 : errors.length) > 0 && /* @__PURE__ */ jsx(
109
+ Tooltip,
110
+ {
111
+ title: /* @__PURE__ */ jsx("div", { onClick: (e) => e.stopPropagation(), children: errors.map((err, err_id) => /* @__PURE__ */ jsxs("div", { children: [
112
+ /* @__PURE__ */ jsx("span", { style: { textTransform: "capitalize" }, children: err.source.replace(/-/g, " ") }),
113
+ ":",
114
+ " ",
115
+ err.message
116
+ ] }, err_id)) }),
117
+ children: /* @__PURE__ */ jsx(
118
+ Chip,
119
+ {
120
+ size: "small",
121
+ variant: "outlined",
122
+ icon: /* @__PURE__ */ jsx(Icon, { icon: "material-symbols:timer-outline", color: theme.palette.error.main }),
123
+ label: /* @__PURE__ */ jsxs(Typography, { variant: "caption", textTransform: "capitalize", children: [
124
+ t("annotation.failed"),
125
+ ": ",
126
+ errors.length
127
+ ] }),
128
+ onClick: forceEnrich
129
+ }
130
+ )
131
+ }
132
+ )
133
+ ] })
134
+ ] }),
135
+ /* @__PURE__ */ jsx(Box, {}),
136
+ Object.keys(annotationsByType).filter((type) => !filter || filter === "all" || type === filter).map((type, id) => /* @__PURE__ */ jsxs(
137
+ Accordion,
138
+ {
139
+ defaultExpanded: true,
140
+ sx: {
141
+ marginTop: `${theme.spacing(1)} !important`,
142
+ marginBottom: "0 !important",
143
+ "&:before": { height: 0 }
144
+ },
145
+ children: [
146
+ filter === "all" && /* @__PURE__ */ jsx(
147
+ AccordionSummary,
148
+ {
149
+ expandIcon: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-arrow-drop-down" }),
150
+ sx: {
151
+ minHeight: "initial !important",
152
+ mt: 0.5,
153
+ mb: 0,
154
+ px: 1,
155
+ "& .MuiAccordionSummary-content": { my: 0.5, mx: 0 },
156
+ "& .MuiAccordionSummary-content.Mui-expanded": { my: 0.5, mx: 0 }
157
+ },
158
+ children: /* @__PURE__ */ jsx(Typography, { variant: "body1", textTransform: "capitalize", children: type }, type)
159
+ }
160
+ ),
161
+ /* @__PURE__ */ jsxs(AccordionDetails, { sx: { px: 1 }, children: [
162
+ filter === "all" && /* @__PURE__ */ jsx(Divider, { orientation: "horizontal", sx: { mb: 1 } }),
163
+ /* @__PURE__ */ jsx(Stack, { spacing: 1, divider: /* @__PURE__ */ jsx(Divider, { orientation: "horizontal", flexItem: true }), children: annotationsByType[type].map((annotation, ann_id) => /* @__PURE__ */ jsx(AnnotationEntry, { annotation }, ann_id)) })
164
+ ] })
165
+ ]
166
+ },
167
+ id
168
+ ))
169
+ ] });
170
+ };
171
+ const AnnotationDetails$1 = memo(AnnotationDetails);
172
+ export {
173
+ AnnotationDetails$1 as A,
174
+ isNull as i
175
+ };