@cccsaurora/clue-ui 1.2.1-patch.256 → 1.3.0-dev.255

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 (181) hide show
  1. package/ActionForm-C0aE9HUv.js +5941 -0
  2. package/AnnotationDetails-CEou0vCc.js +175 -0
  3. package/AnnotationPreview-CLMVD6Ec.js +188 -0
  4. package/ClueEnrichContext-BkD9ZwM9.js +541 -0
  5. package/FlexOne-BSYAhhtG.js +9 -0
  6. package/_MapCache-WmuDdwuH.js +222 -0
  7. package/_Uint8Array-DdG4KLKn.js +128 -0
  8. package/_baseAssignValue-CGTuELqU.js +25 -0
  9. package/_baseClone-BpWiBnMp.js +283 -0
  10. package/_baseExtremum-BY663UjY.js +33 -0
  11. package/_baseFlatten-B69cDsaV.js +92 -0
  12. package/_baseGet-Bx3A4Qfp.js +108 -0
  13. package/_baseIsEqual-B4IufFlL.js +208 -0
  14. package/_baseIteratee-7AQvAy1o.js +126 -0
  15. package/_baseSlice-GAv_YFTT.js +20 -0
  16. package/_baseSum-D0WC1dN0.js +13 -0
  17. package/_baseUniq-B8fK6hI-.js +115 -0
  18. package/_commonjsHelpers-DWwsNxpa.js +8 -0
  19. package/_createAggregator-CwGPThny.js +63 -0
  20. package/_getPrototype-CblfEidB.js +5 -0
  21. package/_getTag-jwz4XLoZ.js +126 -0
  22. package/_setToArray-CaPKQhcz.js +33 -0
  23. package/cloneDeep-DmUylbkM.js +8 -0
  24. package/components/AnnotationBody.js +49 -35
  25. package/components/AnnotationDetailPopover.js +36 -30
  26. package/components/AnnotationDetails.js +7 -7
  27. package/components/AnnotationEntry.js +35 -35
  28. package/components/AnnotationPreview.js +5 -5
  29. package/components/ClassificationChip.js +44 -23
  30. package/components/CountBadge.js +31 -26
  31. package/components/EnrichedCard.js +110 -97
  32. package/components/EnrichedChip.js +130 -105
  33. package/components/EnrichedTypography.js +133 -107
  34. package/components/ErrorBoundary.js +28 -24
  35. package/components/RetryFailedEnrichments.js +10 -9
  36. package/components/SourcePicker.js +57 -49
  37. package/components/actions/ActionForm.js +4 -4
  38. package/components/actions/ExecutePopover.js +75 -59
  39. package/components/actions/ResultModal.js +4 -4
  40. package/components/actions/form/schemaAdapter.js +39 -23
  41. package/components/actions/formats/FileResult.js +86 -59
  42. package/components/actions/formats/index.js +21 -10
  43. package/components/display/graph/ExpandMoreButton.js +10 -10
  44. package/components/display/graph/elements/NodeCard.js +111 -91
  45. package/components/display/graph/elements/NodeTag.js +15 -13
  46. package/components/display/graph/index.js +261 -202
  47. package/components/display/graph/visualizations/Leaf.js +88 -69
  48. package/components/display/graph/visualizations/cloud/index.js +98 -81
  49. package/components/display/graph/visualizations/icons/BaseIcon.js +26 -21
  50. package/components/display/graph/visualizations/icons/BugIcon.js +12 -12
  51. package/components/display/graph/visualizations/icons/HostIcon.js +12 -12
  52. package/components/display/graph/visualizations/icons/NetworkIcon.js +12 -12
  53. package/components/display/graph/visualizations/icons/ProcessIcon.js +12 -12
  54. package/components/display/graph/visualizations/icons/TargetIcon.js +13 -13
  55. package/components/display/graph/visualizations/icons/index.js +14 -13
  56. package/components/display/graph/visualizations/panels/NodePanel.js +10 -8
  57. package/components/display/graph/visualizations/tree/BundleLine.js +108 -81
  58. package/components/display/graph/visualizations/tree/Triangle.js +13 -13
  59. package/components/display/graph/visualizations/tree/index.js +407 -306
  60. package/components/display/icons/Iconified.js +27 -12
  61. package/components/display/json/index.js +4 -4
  62. package/components/display/markdown/index.js +8678 -5770
  63. package/components/enrichment/EnrichPopover.js +54 -46
  64. package/components/fetchers/Fetcher.js +155 -117
  65. package/components/fetchers/PreviewModal.js +20 -17
  66. package/components/fetchers/StatusChip.js +21 -17
  67. package/components/group/Entry.js +13 -11
  68. package/components/group/Group.js +13 -10
  69. package/components/group/GroupControl.js +76 -65
  70. package/components/stats/QueryStatus.js +43 -33
  71. package/countBy-DqlU5OwT.js +14 -0
  72. package/data/event.js +6 -4
  73. package/database/index.js +2 -2
  74. package/debounce-bV0h5FC5.js +92 -0
  75. package/get-DSsNkRQs.js +8 -0
  76. package/groupBy-ChDRT7uy.js +14 -0
  77. package/hooks/ClueActionContext.js +6 -6
  78. package/hooks/ClueComponentContext.js +29 -23
  79. package/hooks/ClueConfigProvider.js +14 -12
  80. package/hooks/ClueDatabaseContext.js +19 -13
  81. package/hooks/ClueEnrichContext.js +8 -8
  82. package/hooks/ClueFetcherContext.js +83 -56
  83. package/hooks/ClueGroupContext.js +17 -14
  84. package/hooks/CluePopupContext.js +5 -5
  85. package/hooks/ClueProvider.js +12 -10
  86. package/hooks/selectors.js +7 -7
  87. package/hooks/useActionResult.js +2 -2
  88. package/hooks/useAnnotations.js +47 -31
  89. package/hooks/useClue.js +6 -4
  90. package/hooks/useClueActions.js +3 -3
  91. package/hooks/useClueConfig.js +6 -4
  92. package/hooks/useClueTypeConfig.js +3 -3
  93. package/hooks/useComparator.js +722 -435
  94. package/hooks/useErrors.js +22 -18
  95. package/hooks/useFetcherResult.js +33 -24
  96. package/hooks/useMyHighlights.js +66 -36
  97. package/hooks/useMyLocalStorage.js +66 -37
  98. package/iconify-CXMreGTg.js +1782 -0
  99. package/icons/Action.js +66 -49
  100. package/icons/Assessment.js +84 -69
  101. package/icons/Context.js +77 -63
  102. package/icons/Opinion.js +78 -60
  103. package/icons/iconMap.js +2 -2
  104. package/identity-CPGTqrE4.js +6 -0
  105. package/index-AMfoEg_6.js +696 -0
  106. package/index-B6C2a_Lg.js +1172 -0
  107. package/index-C12gPw2W.js +17698 -0
  108. package/index-DCKkHTvx.js +15750 -0
  109. package/index-UkW8Sur3.js +465 -0
  110. package/isNil-CIubwp4T.js +6 -0
  111. package/isObject-FTY-5JQX.js +7 -0
  112. package/isObjectLike-OAgjjZye.js +48 -0
  113. package/isSymbol-Xd2FsJyp.js +8 -0
  114. package/last-CUCl67Im.js +7 -0
  115. package/main.js +60 -60
  116. package/package.json +1 -1
  117. package/sortBy-C7mGPI_D.js +100 -0
  118. package/sumBy-CGALjmwQ.js +8 -0
  119. package/text/Frequency.js +42 -23
  120. package/toFinite-Bc55msYj.js +16 -0
  121. package/toNumber-DPxy1FBy.js +39 -0
  122. package/useClueTypeConfig-D2tf4-NM.js +3289 -0
  123. package/utils/chain.js +91 -65
  124. package/utils/classificationParser.js +519 -256
  125. package/utils/constants.js +35 -10
  126. package/utils/graph.js +72 -45
  127. package/utils/hashUtil.js +7 -7
  128. package/utils/line.js +131 -81
  129. package/utils/loggerUtil.js +5 -3
  130. package/utils/sessionStorage.js +41 -27
  131. package/utils/time.js +423 -423
  132. package/utils/utils.js +9 -9
  133. package/utils/window.js +21 -10
  134. package/utils-71DpzFrA.js +199 -0
  135. package/ActionForm-DlOXqMUx.js +0 -4460
  136. package/AnnotationDetails-Bk-p0F6h.js +0 -160
  137. package/AnnotationPreview-jzZvkCxJ.js +0 -140
  138. package/ClueEnrichContext-KqRuuWNS.js +0 -418
  139. package/FlexOne-BXWFOd1T.js +0 -6
  140. package/_MapCache-BiTi0iqu.js +0 -180
  141. package/_Uint8Array-BQNOM9Rr.js +0 -101
  142. package/_baseAssignValue-CNMLQZco.js +0 -20
  143. package/_baseClone-BnT-6pyM.js +0 -207
  144. package/_baseExtremum-Ca2EHgy2.js +0 -16
  145. package/_baseFlatten-Bfr_Molw.js +0 -72
  146. package/_baseGet-DSZygzyq.js +0 -79
  147. package/_baseIsEqual-VgvaAFZG.js +0 -147
  148. package/_baseIteratee-Dbfsw5z8.js +0 -95
  149. package/_baseSlice-M5RKzt1A.js +0 -10
  150. package/_baseSum-wEbgNeUs.js +0 -10
  151. package/_baseUniq-BJcj69PL.js +0 -79
  152. package/_commonjsHelpers-DaMA6jEr.js +0 -8
  153. package/_createAggregator-k3TuAnxT.js +0 -53
  154. package/_getPrototype-Cr1Mk7BC.js +0 -5
  155. package/_getTag-CK2Sffaq.js +0 -90
  156. package/_isIterateeCall-DkJP7Rbx.js +0 -13
  157. package/_setToArray-C7yMOeww.js +0 -29
  158. package/cloneDeep-CF8TtLHr.js +0 -8
  159. package/countBy-CdYegFSu.js +0 -8
  160. package/debounce-DryYcbJ4.js +0 -56
  161. package/get-CH7kz5Ix.js +0 -8
  162. package/groupBy-br8xmD2R.js +0 -8
  163. package/iconify-BBckr5AQ.js +0 -1263
  164. package/identity-ByMq8VxU.js +0 -6
  165. package/index-BHAe_V9n.js +0 -12768
  166. package/index-BK-zfYhR.js +0 -358
  167. package/index-CA5CUNZO.js +0 -975
  168. package/index-Dj5C04IX.js +0 -568
  169. package/index-p5_wX7q1.js +0 -11729
  170. package/isNil-CjWwlQS3.js +0 -6
  171. package/isObject-B53jY8Qg.js +0 -7
  172. package/isObjectLike-BatpeCIi.js +0 -29
  173. package/isSymbol-C3_SC0Qp.js +0 -8
  174. package/last-7CdUxN0r.js +0 -7
  175. package/maxBy-Bc0dYHcO.js +0 -8
  176. package/sortBy-DY2JBf9n.js +0 -75
  177. package/sumBy-DuMASLPd.js +0 -8
  178. package/toFinite-BMy6GObD.js +0 -14
  179. package/toNumber-YVhnnJv4.js +0 -31
  180. package/useClueTypeConfig-Ct9Ygter.js +0 -2292
  181. package/utils-DmwSUrum.js +0 -129
@@ -1,104 +1,120 @@
1
- import { jsxs as s, Fragment as j, jsx as e } from "react/jsx-runtime";
2
- import { I as O } from "../../iconify-BBckr5AQ.js";
3
- import { useTheme as w, Tooltip as S, IconButton as z, CircularProgress as E, Button as D, Popover as M, Paper as B, Stack as l, Typography as I, Box as T, Divider as F } from "@mui/material";
4
- import h from "../display/icons/Iconified.js";
5
- import { ClueComponentContext as R } from "../../hooks/ClueComponentContext.js";
6
- import { a } from "../../ActionForm-DlOXqMUx.js";
7
- import W from "../../hooks/useClueConfig.js";
8
- import { isAccessible as q } from "../../utils/classificationParser.js";
9
- import { useState as G, useRef as H, useMemo as J, useEffect as P } from "react";
10
- import { u as K } from "../../index-Dj5C04IX.js";
11
- import L from "../ClassificationChip.js";
12
- const ie = ({ show: u = !1, size: _ = "small", selectors: i, multiples: x = !1 }) => {
13
- const { t: p } = K(R, (o) => o.i18next), g = w(), C = a((o) => o.availableActions), b = a((o) => o.refreshActions), y = a((o) => o.executeAction), f = a((o) => o.loading), { config: k } = W(), [m, r] = G(u), d = H(null), v = J(
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { I as Icon } from "../../iconify-CXMreGTg.js";
3
+ import { useTheme, Tooltip, IconButton, CircularProgress, Button, Popover, Paper, Stack, Typography, Box, Divider } from "@mui/material";
4
+ import Iconified from "../display/icons/Iconified.js";
5
+ import { ClueComponentContext } from "../../hooks/ClueComponentContext.js";
6
+ import { a as useClueActionsSelector } from "../../ActionForm-C0aE9HUv.js";
7
+ import useClueConfig from "../../hooks/useClueConfig.js";
8
+ import { isAccessible } from "../../utils/classificationParser.js";
9
+ import { useState, useRef, useMemo, useEffect } from "react";
10
+ import { u as useContextSelector } from "../../index-AMfoEg_6.js";
11
+ import ClassificationChip from "../ClassificationChip.js";
12
+ const ExecutePopover = ({ show = false, size = "small", selectors, multiples = false }) => {
13
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx.i18next);
14
+ const theme = useTheme();
15
+ const availableActions = useClueActionsSelector((ctx) => ctx.availableActions);
16
+ const refreshActions = useClueActionsSelector((ctx) => ctx.refreshActions);
17
+ const executeAction = useClueActionsSelector((ctx) => ctx.executeAction);
18
+ const loading = useClueActionsSelector((ctx) => ctx.loading);
19
+ const { config } = useClueConfig();
20
+ const [showExecuteMenu, setShowExecuteMenu] = useState(show);
21
+ const executeEl = useRef(null);
22
+ const actions = useMemo(
14
23
  () => Object.fromEntries(
15
- Object.entries(C).filter(
16
- ([o, t]) => {
17
- var n;
18
- return (!((n = t.supported_types) != null && n.length) || i.every((c) => t.supported_types.includes(c == null ? void 0 : c.type))) && (!x || t.accept_multiple || i.length === 1) && i.every((c) => q(t.classification, c.classification, k.c12nDef));
24
+ Object.entries(availableActions).filter(
25
+ ([__, action]) => {
26
+ var _a;
27
+ return (!((_a = action.supported_types) == null ? void 0 : _a.length) || selectors.every((value) => action.supported_types.includes(value == null ? void 0 : value.type))) && (!multiples || action.accept_multiple || selectors.length === 1) && selectors.every((value) => isAccessible(action.classification, value.classification, config.c12nDef));
19
28
  }
20
29
  )
21
30
  ),
22
- [C, k.c12nDef, x, i]
23
- ), A = Object.keys(v).length < 1 || f || i.length < 1;
24
- return P(() => {
25
- r(u);
26
- }, [u]), P(() => {
27
- m && b();
28
- }, [b, m]), /* @__PURE__ */ s(j, { children: [
29
- _ === "small" ? /* @__PURE__ */ e(S, { ref: d, title: p("actions.execute"), children: /* @__PURE__ */ e("span", { style: { alignSelf: "center" }, children: /* @__PURE__ */ e(z, { onClick: () => r(!0), disabled: A, color: "success", children: f ? /* @__PURE__ */ e(E, { color: "success", size: "24px" }) : /* @__PURE__ */ e(h, { icon: "ic:outline-play-arrow" }) }) }) }) : /* @__PURE__ */ e(
30
- D,
31
+ [availableActions, config.c12nDef, multiples, selectors]
32
+ );
33
+ const actionDisabled = Object.keys(actions).length < 1 || loading || selectors.length < 1;
34
+ useEffect(() => {
35
+ setShowExecuteMenu(show);
36
+ }, [show]);
37
+ useEffect(() => {
38
+ if (showExecuteMenu) {
39
+ refreshActions();
40
+ }
41
+ }, [refreshActions, showExecuteMenu]);
42
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
43
+ size === "small" ? /* @__PURE__ */ jsx(Tooltip, { ref: executeEl, title: t("actions.execute"), children: /* @__PURE__ */ jsx("span", { style: { alignSelf: "center" }, children: /* @__PURE__ */ jsx(IconButton, { onClick: () => setShowExecuteMenu(true), disabled: actionDisabled, color: "success", children: loading ? /* @__PURE__ */ jsx(CircularProgress, { color: "success", size: "24px" }) : /* @__PURE__ */ jsx(Iconified, { icon: "ic:outline-play-arrow" }) }) }) }) : /* @__PURE__ */ jsx(
44
+ Button,
31
45
  {
32
- ref: d,
46
+ ref: executeEl,
33
47
  variant: "outlined",
34
48
  color: "success",
35
- disabled: A,
36
- startIcon: f ? /* @__PURE__ */ e(E, { color: "success", size: "20px" }) : /* @__PURE__ */ e(h, { icon: "ic:outline-play-arrow" }),
49
+ disabled: actionDisabled,
50
+ startIcon: loading ? /* @__PURE__ */ jsx(CircularProgress, { color: "success", size: "20px" }) : /* @__PURE__ */ jsx(Iconified, { icon: "ic:outline-play-arrow" }),
37
51
  sx: { alignSelf: "stretch" },
38
- onClick: () => r(!0),
39
- children: p("actions.execute")
52
+ onClick: () => setShowExecuteMenu(true),
53
+ children: t("actions.execute")
40
54
  }
41
55
  ),
42
- /* @__PURE__ */ e(
43
- M,
56
+ /* @__PURE__ */ jsx(
57
+ Popover,
44
58
  {
45
59
  sx: { zIndex: 2e3 },
46
- open: m,
47
- disablePortal: !0,
48
- onClose: () => r(!1),
49
- anchorEl: d.current,
60
+ open: showExecuteMenu,
61
+ disablePortal: true,
62
+ onClose: () => setShowExecuteMenu(false),
63
+ anchorEl: executeEl.current,
50
64
  anchorOrigin: { horizontal: "left", vertical: "bottom" },
51
- children: /* @__PURE__ */ e(B, { onClick: () => r(!1), children: /* @__PURE__ */ e(l, { divider: /* @__PURE__ */ e(F, { flexItem: !0, orientation: "horizontal" }), children: Object.entries(v).map(([o, t]) => /* @__PURE__ */ s(
52
- l,
65
+ children: /* @__PURE__ */ jsx(Paper, { onClick: () => setShowExecuteMenu(false), children: /* @__PURE__ */ jsx(Stack, { divider: /* @__PURE__ */ jsx(Divider, { flexItem: true, orientation: "horizontal" }), children: Object.entries(actions).map(([actionId, action]) => /* @__PURE__ */ jsxs(
66
+ Stack,
53
67
  {
54
68
  sx: {
55
69
  pl: 3,
56
70
  pr: 2,
57
71
  py: 1,
58
72
  cursor: "pointer",
59
- transition: g.transitions.create("background-color"),
60
- "&:hover": { backgroundColor: g.palette.background.default }
73
+ transition: theme.transitions.create("background-color"),
74
+ "&:hover": { backgroundColor: theme.palette.background.default }
61
75
  },
62
- onClick: (n) => {
63
- n.isPropagationStopped() || y(o, i);
76
+ onClick: (ev) => {
77
+ if (!ev.isPropagationStopped()) {
78
+ executeAction(actionId, selectors);
79
+ }
64
80
  },
65
81
  direction: "row",
66
82
  spacing: 1,
67
83
  alignItems: "center",
68
84
  children: [
69
- /* @__PURE__ */ s(l, { flex: 1, children: [
70
- /* @__PURE__ */ s(l, { direction: "row", spacing: 1, alignItems: "center", children: [
71
- t.action_icon && /* @__PURE__ */ e(O, { icon: t.action_icon }),
72
- /* @__PURE__ */ e(I, { variant: "body1", children: t.name }),
73
- /* @__PURE__ */ e(L, { size: "small", classification: t.classification })
85
+ /* @__PURE__ */ jsxs(Stack, { flex: 1, children: [
86
+ /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
87
+ action.action_icon && /* @__PURE__ */ jsx(Icon, { icon: action.action_icon }),
88
+ /* @__PURE__ */ jsx(Typography, { variant: "body1", children: action.name }),
89
+ /* @__PURE__ */ jsx(ClassificationChip, { size: "small", classification: action.classification })
74
90
  ] }),
75
- t.summary && /* @__PURE__ */ e(I, { variant: "caption", color: "text.secondary", maxWidth: "300px", children: t.summary })
91
+ action.summary && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", maxWidth: "300px", children: action.summary })
76
92
  ] }),
77
- /* @__PURE__ */ e(
78
- T,
93
+ /* @__PURE__ */ jsx(
94
+ Box,
79
95
  {
80
96
  sx: { pl: 1 },
81
- onClick: (n) => {
82
- n.stopPropagation();
97
+ onClick: (ev) => {
98
+ ev.stopPropagation();
83
99
  },
84
- children: /* @__PURE__ */ e(S, { title: p("actions.execute.menu"), children: /* @__PURE__ */ e(
85
- z,
100
+ children: /* @__PURE__ */ jsx(Tooltip, { title: t("actions.execute.menu"), children: /* @__PURE__ */ jsx(
101
+ IconButton,
86
102
  {
87
103
  size: "small",
88
- onClick: () => y(o, i, null, { forceMenu: !0 }),
89
- children: /* @__PURE__ */ e(h, { icon: "ic:baseline-settings" })
104
+ onClick: () => executeAction(actionId, selectors, null, { forceMenu: true }),
105
+ children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-settings" })
90
106
  }
91
107
  ) })
92
108
  }
93
109
  )
94
110
  ]
95
111
  },
96
- o
112
+ actionId
97
113
  )) }) })
98
114
  }
99
115
  )
100
116
  ] });
101
117
  };
102
118
  export {
103
- ie as default
119
+ ExecutePopover as default
104
120
  };
@@ -1,13 +1,13 @@
1
1
  import "react/jsx-runtime";
2
- import "../../iconify-BBckr5AQ.js";
2
+ import "../../iconify-CXMreGTg.js";
3
3
  import "@mui/material";
4
4
  import "../../hooks/ClueComponentContext.js";
5
- import { R as s } from "../../ActionForm-DlOXqMUx.js";
5
+ import { R } from "../../ActionForm-C0aE9HUv.js";
6
6
  import "react";
7
- import "../../index-Dj5C04IX.js";
7
+ import "../../index-AMfoEg_6.js";
8
8
  import "../ClassificationChip.js";
9
9
  import "../ErrorBoundary.js";
10
10
  import "./formats/index.js";
11
11
  export {
12
- s as default
12
+ R as default
13
13
  };
@@ -1,32 +1,48 @@
1
- import { c as y } from "../../../cloneDeep-CF8TtLHr.js";
2
- import { g as s } from "../../../get-CH7kz5Ix.js";
3
- const u = (i) => {
4
- const r = [], l = y(i), n = {
5
- ...l,
1
+ import { c as cloneDeep } from "../../../cloneDeep-DmUylbkM.js";
2
+ import { g as get } from "../../../get-DSsNkRQs.js";
3
+ const adaptSchema = (_schema) => {
4
+ const requiredFields = [];
5
+ const schema = cloneDeep(_schema);
6
+ const newSchema = {
7
+ ...schema,
6
8
  properties: Object.fromEntries(
7
- Object.entries(l.properties ?? {}).filter(([t]) => !["raw_data", "selector", "selectors", "context"].includes(t)).map(([t, e]) => {
8
- var a, o;
9
- if (r.push(t), typeof e == "boolean")
10
- return [t, e];
11
- if (((a = e.anyOf) == null ? void 0 : a.length) === 2) {
12
- if (typeof e.anyOf[1] == "boolean")
13
- return [t, e];
14
- e.anyOf[1].type === "null" && typeof e.anyOf[0] != "boolean" && (e.anyOf[0].enum && (e.enum = e.anyOf[0].enum), e.type = [...Array.isArray(e.anyOf[0].type) ? e.anyOf[0].type : [e.anyOf[0].type], "null"], delete e.anyOf, r.pop());
9
+ Object.entries(schema.properties ?? {}).filter(([name]) => !["raw_data", "selector", "selectors", "context"].includes(name)).map(([name, def]) => {
10
+ var _a, _b;
11
+ requiredFields.push(name);
12
+ if (typeof def === "boolean") {
13
+ return [name, def];
15
14
  }
16
- if (((o = e.allOf) == null ? void 0 : o.length) > 0 && typeof e.allOf[0] != "boolean" && e.allOf[0].$ref) {
17
- const p = {
18
- ...e,
19
- ...s(l, e.allOf[0].$ref.replace("#/", "").replaceAll("/", ".")),
20
- title: e.title
21
- };
22
- return delete p.allOf, [t, p];
15
+ if (((_a = def.anyOf) == null ? void 0 : _a.length) === 2) {
16
+ if (typeof def.anyOf[1] === "boolean") {
17
+ return [name, def];
18
+ }
19
+ if (def.anyOf[1].type === "null" && typeof def.anyOf[0] !== "boolean") {
20
+ if (def.anyOf[0].enum) {
21
+ def.enum = def.anyOf[0].enum;
22
+ }
23
+ def.type = [...Array.isArray(def.anyOf[0].type) ? def.anyOf[0].type : [def.anyOf[0].type], "null"];
24
+ delete def.anyOf;
25
+ requiredFields.pop();
26
+ }
23
27
  }
24
- return [t, e];
28
+ if (((_b = def.allOf) == null ? void 0 : _b.length) > 0) {
29
+ if (typeof def.allOf[0] !== "boolean" && def.allOf[0].$ref) {
30
+ const newDef = {
31
+ ...def,
32
+ ...get(schema, def.allOf[0].$ref.replace("#/", "").replaceAll("/", ".")),
33
+ title: def.title
34
+ };
35
+ delete newDef.allOf;
36
+ return [name, newDef];
37
+ }
38
+ }
39
+ return [name, def];
25
40
  })
26
41
  )
27
42
  };
28
- return n.required = r, n;
43
+ newSchema.required = requiredFields;
44
+ return newSchema;
29
45
  };
30
46
  export {
31
- u as adaptSchema
47
+ adaptSchema
32
48
  };
@@ -1,85 +1,112 @@
1
- import { jsxs as c, jsx as n } from "react/jsx-runtime";
2
- import { Stack as v, Typography as u, Divider as A, Table as C, TableBody as S, TableRow as d, TableCell as l, Button as k } from "@mui/material";
3
- import M from "../../display/icons/Iconified.js";
4
- import { ClueComponentContext as R } from "../../../hooks/ClueComponentContext.js";
5
- import { useState as T, useMemo as U, useEffect as _ } from "react";
6
- import { u as j } from "../../../index-Dj5C04IX.js";
7
- const b = (t) => {
8
- const e = atob(t), o = new Uint8Array(new ArrayBuffer(e.length));
9
- for (let a = 0; a < e.length; a++)
10
- o[a] = e.charCodeAt(a);
11
- return o;
12
- }, H = (t) => {
13
- if (t === 0)
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Stack, Typography, Divider, Table, TableBody, TableRow, TableCell, Button } from "@mui/material";
3
+ import Iconified from "../../display/icons/Iconified.js";
4
+ import { ClueComponentContext } from "../../../hooks/ClueComponentContext.js";
5
+ import { useState, useMemo, useEffect } from "react";
6
+ import { u as useContextSelector } from "../../../index-AMfoEg_6.js";
7
+ const decodeBase64ToBytes = (base64Data) => {
8
+ const byteCharacters = atob(base64Data);
9
+ const byteArray = new Uint8Array(new ArrayBuffer(byteCharacters.length));
10
+ for (let i = 0; i < byteCharacters.length; i++) {
11
+ byteArray[i] = byteCharacters.charCodeAt(i);
12
+ }
13
+ return byteArray;
14
+ };
15
+ const formatBytes = (bytes) => {
16
+ if (bytes === 0) {
14
17
  return "0 B";
15
- const e = ["B", "KB", "MB", "GB"], o = Math.min(Math.floor(Math.log(t) / Math.log(1024)), e.length - 1);
16
- return `${(t / 1024 ** o).toFixed(o === 0 ? 0 : 2)} ${e[o]}`;
17
- }, F = (t) => {
18
- const e = b(t.data), o = new Blob([e], { type: t.mime_type || "application/octet-stream" }), a = URL.createObjectURL(o), i = document.createElement("a");
19
- i.href = a, i.download = t.file_name || "result.txt", document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(a);
20
- }, D = ({ result: t }) => {
21
- var h, f, m, p, y;
22
- const { t: e } = j(R, (r) => r == null ? void 0 : r.i18next), [o, a] = T(""), i = ((h = t.action) == null ? void 0 : h.name) ?? e("actions.result.file.unknown"), s = U(() => {
23
- var r;
24
- if (!((r = t.output) != null && r.data))
18
+ }
19
+ const units = ["B", "KB", "MB", "GB"];
20
+ const unitIndex = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
21
+ const value = bytes / 1024 ** unitIndex;
22
+ return `${value.toFixed(unitIndex === 0 ? 0 : 2)} ${units[unitIndex]}`;
23
+ };
24
+ const saveFileFromServer = (output) => {
25
+ const byteArray = decodeBase64ToBytes(output.data);
26
+ const blob = new Blob([byteArray], { type: output.mime_type || "application/octet-stream" });
27
+ const url = URL.createObjectURL(blob);
28
+ const link = document.createElement("a");
29
+ link.href = url;
30
+ link.download = output.file_name || "result.txt";
31
+ document.body.appendChild(link);
32
+ link.click();
33
+ document.body.removeChild(link);
34
+ URL.revokeObjectURL(url);
35
+ };
36
+ const FileResult = ({ result }) => {
37
+ var _a, _b, _c, _d, _e;
38
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx == null ? void 0 : ctx.i18next);
39
+ const [sha256Hash, setSha256Hash] = useState("");
40
+ const actionName = ((_a = result.action) == null ? void 0 : _a.name) ?? t("actions.result.file.unknown");
41
+ const outputBytes = useMemo(() => {
42
+ var _a2;
43
+ if (!((_a2 = result.output) == null ? void 0 : _a2.data)) {
25
44
  return null;
45
+ }
26
46
  try {
27
- return b(t.output.data);
47
+ return decodeBase64ToBytes(result.output.data);
28
48
  } catch {
29
49
  return null;
30
50
  }
31
- }, [(f = t.output) == null ? void 0 : f.data]);
32
- return _(() => {
33
- let r = !1;
34
- const g = async () => {
35
- if (!s || typeof crypto > "u" || !crypto.subtle) {
36
- a("N/A");
51
+ }, [(_b = result.output) == null ? void 0 : _b.data]);
52
+ useEffect(() => {
53
+ let cancelled = false;
54
+ const generateHash = async () => {
55
+ if (!outputBytes || typeof crypto === "undefined" || !crypto.subtle) {
56
+ setSha256Hash("N/A");
37
57
  return;
38
58
  }
39
- const w = await crypto.subtle.digest("SHA-256", s), x = Array.from(new Uint8Array(w)).map((B) => B.toString(16).padStart(2, "0")).join("");
40
- r || a(x);
59
+ const digest = await crypto.subtle.digest("SHA-256", outputBytes);
60
+ const digestArray = Array.from(new Uint8Array(digest));
61
+ const digestHex = digestArray.map((value) => value.toString(16).padStart(2, "0")).join("");
62
+ if (!cancelled) {
63
+ setSha256Hash(digestHex);
64
+ }
41
65
  };
42
- return a(""), g(), () => {
43
- r = !0;
66
+ setSha256Hash("");
67
+ generateHash();
68
+ return () => {
69
+ cancelled = true;
44
70
  };
45
- }, [s]), /* @__PURE__ */ c(v, { sx: { overflowY: "auto" }, spacing: 3, children: [
46
- /* @__PURE__ */ n(u, { variant: "h5", children: e("actions.result.file.title", { actionName: i }) }),
47
- /* @__PURE__ */ n(u, { children: e("actions.result.file.description", { actionName: i }) }),
48
- /* @__PURE__ */ n(A, { flexItem: !0 }),
49
- /* @__PURE__ */ n(u, { variant: "h6", children: e("actions.result.file.stats.title") }),
50
- s && /* @__PURE__ */ n(C, { sx: { maxWidth: 900 }, children: /* @__PURE__ */ c(S, { children: [
51
- /* @__PURE__ */ c(d, { children: [
52
- /* @__PURE__ */ n(l, { sx: { width: "35%" }, children: e("actions.result.file.stats.label.decoded_size") }),
53
- /* @__PURE__ */ n(l, { children: H(s.length) || "n/a" })
71
+ }, [outputBytes]);
72
+ return /* @__PURE__ */ jsxs(Stack, { sx: { overflowY: "auto" }, spacing: 3, children: [
73
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", children: t("actions.result.file.title", { actionName }) }),
74
+ /* @__PURE__ */ jsx(Typography, { children: t("actions.result.file.description", { actionName }) }),
75
+ /* @__PURE__ */ jsx(Divider, { flexItem: true }),
76
+ /* @__PURE__ */ jsx(Typography, { variant: "h6", children: t("actions.result.file.stats.title") }),
77
+ outputBytes && /* @__PURE__ */ jsx(Table, { sx: { maxWidth: 900 }, children: /* @__PURE__ */ jsxs(TableBody, { children: [
78
+ /* @__PURE__ */ jsxs(TableRow, { children: [
79
+ /* @__PURE__ */ jsx(TableCell, { sx: { width: "35%" }, children: t("actions.result.file.stats.label.decoded_size") }),
80
+ /* @__PURE__ */ jsx(TableCell, { children: formatBytes(outputBytes.length) || "n/a" })
54
81
  ] }),
55
- /* @__PURE__ */ c(d, { children: [
56
- /* @__PURE__ */ n(l, { sx: { width: "35%" }, children: e("actions.result.file.stats.label.decoded_bytes") }),
57
- /* @__PURE__ */ n(l, { children: s.length || "n/a" })
82
+ /* @__PURE__ */ jsxs(TableRow, { children: [
83
+ /* @__PURE__ */ jsx(TableCell, { sx: { width: "35%" }, children: t("actions.result.file.stats.label.decoded_bytes") }),
84
+ /* @__PURE__ */ jsx(TableCell, { children: outputBytes.length || "n/a" })
58
85
  ] }),
59
- /* @__PURE__ */ c(d, { children: [
60
- /* @__PURE__ */ n(l, { sx: { width: "35%" }, children: e("actions.result.file.stats.label.base64_length") }),
61
- /* @__PURE__ */ n(l, { children: ((m = t.output) == null ? void 0 : m.data.length) ?? "n/a" })
86
+ /* @__PURE__ */ jsxs(TableRow, { children: [
87
+ /* @__PURE__ */ jsx(TableCell, { sx: { width: "35%" }, children: t("actions.result.file.stats.label.base64_length") }),
88
+ /* @__PURE__ */ jsx(TableCell, { children: ((_c = result.output) == null ? void 0 : _c.data.length) ?? "n/a" })
62
89
  ] }),
63
- /* @__PURE__ */ c(d, { children: [
64
- /* @__PURE__ */ n(l, { sx: { width: "35%" }, children: e("actions.result.file.stats.label.sha256") }),
65
- /* @__PURE__ */ n(l, { children: /* @__PURE__ */ n("code", { children: o || e("actions.result.file.stats.calculating") }) })
90
+ /* @__PURE__ */ jsxs(TableRow, { children: [
91
+ /* @__PURE__ */ jsx(TableCell, { sx: { width: "35%" }, children: t("actions.result.file.stats.label.sha256") }),
92
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("code", { children: sha256Hash || t("actions.result.file.stats.calculating") }) })
66
93
  ] })
67
94
  ] }) }),
68
- /* @__PURE__ */ n(
69
- k,
95
+ /* @__PURE__ */ jsx(
96
+ Button,
70
97
  {
71
- startIcon: /* @__PURE__ */ n(M, { icon: "ic:baseline-download" }),
98
+ startIcon: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-download" }),
72
99
  variant: "outlined",
73
100
  sx: { alignSelf: "center" },
74
- disabled: !((p = t.output) != null && p.data),
75
- onClick: () => t.output && F(t.output),
101
+ disabled: !((_d = result.output) == null ? void 0 : _d.data),
102
+ onClick: () => result.output && saveFileFromServer(result.output),
76
103
  name: "download",
77
104
  role: "button",
78
- children: e("download", { file: ((y = t.output) == null ? void 0 : y.file_name) ?? "result.txt" })
105
+ children: t("download", { file: ((_e = result.output) == null ? void 0 : _e.file_name) ?? "result.txt" })
79
106
  }
80
107
  )
81
108
  ] });
82
109
  };
83
110
  export {
84
- D as default
111
+ FileResult as default
85
112
  };
@@ -1,12 +1,23 @@
1
- import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
- import { Stack as f } from "@mui/material";
3
- import { J as t } from "../../../index-BK-zfYhR.js";
4
- import a from "../../display/markdown/index.js";
5
- import i from "./FileResult.js";
6
- const u = ({ result: o }) => o.format === "markdown" ? /* @__PURE__ */ r(a, { md: o.output }) : o.format === "json" ? /* @__PURE__ */ r(t, { data: o.output, collapse: !0, forceCompact: !0 }) : o.format === "file" ? /* @__PURE__ */ r(i, { result: o }) : /* @__PURE__ */ m(f, { sx: { overflowY: "auto" }, children: [
7
- /* @__PURE__ */ r(a, { md: "`" + o.format + "` is not recognized as a format in this application." }),
8
- /* @__PURE__ */ r(t, { data: o, collapse: !0, forceCompact: !0 })
9
- ] });
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Stack } from "@mui/material";
3
+ import { J as JSONViewer } from "../../../index-UkW8Sur3.js";
4
+ import Markdown from "../../display/markdown/index.js";
5
+ import FileResult from "./FileResult.js";
6
+ const Result = ({ result }) => {
7
+ if (result.format === "markdown") {
8
+ return /* @__PURE__ */ jsx(Markdown, { md: result.output });
9
+ }
10
+ if (result.format === "json") {
11
+ return /* @__PURE__ */ jsx(JSONViewer, { data: result.output, collapse: true, forceCompact: true });
12
+ }
13
+ if (result.format === "file") {
14
+ return /* @__PURE__ */ jsx(FileResult, { result });
15
+ }
16
+ return /* @__PURE__ */ jsxs(Stack, { sx: { overflowY: "auto" }, children: [
17
+ /* @__PURE__ */ jsx(Markdown, { md: "`" + result.format + "` is not recognized as a format in this application." }),
18
+ /* @__PURE__ */ jsx(JSONViewer, { data: result, collapse: true, forceCompact: true })
19
+ ] });
20
+ };
10
21
  export {
11
- u as default
22
+ Result as default
12
23
  };
@@ -1,18 +1,18 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { IconButton as a } from "@mui/material";
3
- const m = (t) => {
4
- const { expand: o, ...r } = t;
5
- return /* @__PURE__ */ e(
6
- a,
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { IconButton } from "@mui/material";
3
+ const ExpandMoreButton = (props) => {
4
+ const { expand, ...other } = props;
5
+ return /* @__PURE__ */ jsx(
6
+ IconButton,
7
7
  {
8
- ...r,
8
+ ...other,
9
9
  sx: {
10
- transform: o ? "rotate(180deg)" : "rotate(0deg)",
11
- transition: (n) => n.transitions.create("transform")
10
+ transform: !expand ? "rotate(0deg)" : "rotate(180deg)",
11
+ transition: (theme) => theme.transitions.create("transform")
12
12
  }
13
13
  }
14
14
  );
15
15
  };
16
16
  export {
17
- m as default
17
+ ExpandMoreButton as default
18
18
  };