@cccsaurora/clue-ui 1.4.1 → 1.4.2-dev.453

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 (225) hide show
  1. package/ActionForm-CbLz66Rk.js +6099 -0
  2. package/AnnotationDetails-CdNvyJl7.js +176 -0
  3. package/AnnotationPreview-C6a3qRFG.js +188 -0
  4. package/ClueEnrichContext-0eVIgvZp.js +594 -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 +39 -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 +46 -24
  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.d.ts +4 -0
  91. package/hooks/ClueDatabaseContext.js +36 -23
  92. package/hooks/ClueEnrichContext.js +11 -11
  93. package/hooks/ClueFetcherContext.js +83 -56
  94. package/hooks/ClueGroupContext.js +17 -14
  95. package/hooks/CluePopupContext.js +5 -5
  96. package/hooks/ClueProvider.js +13 -11
  97. package/hooks/ClueUIPluginContext.js +50 -36
  98. package/hooks/selectors.js +7 -7
  99. package/hooks/useActionResult.js +3 -3
  100. package/hooks/useAnnotations.js +48 -32
  101. package/hooks/useClue.js +6 -4
  102. package/hooks/useClueActions.js +3 -3
  103. package/hooks/useClueConfig.js +6 -4
  104. package/hooks/useClueTypeConfig.js +49 -24
  105. package/hooks/useClueUIPlugins.js +8 -7
  106. package/hooks/useComparator.js +722 -435
  107. package/hooks/useErrors.js +22 -18
  108. package/hooks/useFetcherResult.js +33 -24
  109. package/hooks/useMyHighlights.js +66 -36
  110. package/hooks/useMyLocalStorage.js +66 -37
  111. package/iconify-DJxl6dC-.js +1789 -0
  112. package/icons/Action.js +66 -49
  113. package/icons/Assessment.js +85 -69
  114. package/icons/Context.js +77 -63
  115. package/icons/Opinion.js +76 -60
  116. package/icons/iconMap.js +2 -2
  117. package/identity-CPGTqrE4.js +6 -0
  118. package/index-CDrC9oSE.js +1172 -0
  119. package/index-CVUD9o3t.js +15768 -0
  120. package/index-DUEubgWN.js +464 -0
  121. package/index-DpJxD74E.js +3272 -0
  122. package/index-IKI1G5v-.js +9314 -0
  123. package/index-_gpzM2Px.js +702 -0
  124. package/isArguments-CuYlEuhP.js +27 -0
  125. package/isArray-RJPfgWqI.js +4 -0
  126. package/isEmpty-BE656RUK.js +30 -0
  127. package/isNil-CIubwp4T.js +6 -0
  128. package/isObject-FTY-5JQX.js +7 -0
  129. package/isObjectLike-CeENW9FN.js +6 -0
  130. package/isSymbol-D_H4HPZQ.js +9 -0
  131. package/last-CUCl67Im.js +7 -0
  132. package/main.js +62 -62
  133. package/maxBy-BjjQmX5t.js +8 -0
  134. package/package.json +22 -22
  135. package/plugins/ClueUIPlugin.js +163 -96
  136. package/plugins/file/index.js +15 -15
  137. package/plugins/graph/index.js +29 -26
  138. package/plugins/image/index.js +28 -24
  139. package/plugins/json/index.js +21 -21
  140. package/plugins/markdown/index.js +18 -18
  141. package/plugins/registry.js +6 -6
  142. package/plugins/store.js +4 -4
  143. package/plugins/test/index.js +17 -17
  144. package/plugins/utils.js +13 -12
  145. package/replication-kdsH0l7f.js +11779 -0
  146. package/sessionStorage-B68y-wnE.js +140 -0
  147. package/sortBy-B8JVsLQY.js +95 -0
  148. package/store-DHP48fQB.js +2165 -0
  149. package/sumBy-D-HCzM2i.js +8 -0
  150. package/text/Frequency.js +42 -23
  151. package/toFinite-meZTg4Su.js +16 -0
  152. package/toNumber-B5JaA1vX.js +39 -0
  153. package/uniq-CahZPAwp.js +7 -0
  154. package/utils/chain.js +92 -65
  155. package/utils/classificationParser.js +519 -256
  156. package/utils/constants.js +37 -11
  157. package/utils/graph.js +72 -45
  158. package/utils/hashUtil.js +7 -7
  159. package/utils/line.js +131 -81
  160. package/utils/loggerUtil.js +5 -3
  161. package/utils/sessionStorage.js +7 -7
  162. package/utils/time.js +447 -427
  163. package/utils/utils.js +10 -10
  164. package/utils/window.js +21 -10
  165. package/utils-CEySTPtg.js +224 -0
  166. package/ActionForm-DjyNwVzM.js +0 -4403
  167. package/AnnotationDetails-BvPv3_pR.js +0 -160
  168. package/AnnotationPreview-C0JN_lr0.js +0 -140
  169. package/ClueEnrichContext-CNbh-qiy.js +0 -452
  170. package/FlexOne-BXWFOd1T.js +0 -6
  171. package/_MapCache-DRK-s2eK.js +0 -179
  172. package/_Set-DrS_bbSV.js +0 -6
  173. package/_Uint8Array-D9R2N9Lp.js +0 -98
  174. package/_arrayIncludes-Dcl_29E6.js +0 -25
  175. package/_arrayPush-DBJIuK2V.js +0 -8
  176. package/_baseAssignValue-Bx1cxHj5.js +0 -12
  177. package/_baseClone-DRhywkxm.js +0 -211
  178. package/_baseExtremum-DodEaEyF.js +0 -16
  179. package/_baseFlatten-CD9NgrYE.js +0 -72
  180. package/_baseGet-bVwDaGrA.js +0 -80
  181. package/_baseGetTag-CxDaTem-.js +0 -25
  182. package/_baseIsEqual-C-FKsm1J.js +0 -150
  183. package/_baseIteratee-D0FhC5bC.js +0 -95
  184. package/_baseRest-D_eW2E0d.js +0 -8
  185. package/_baseSlice-M5RKzt1A.js +0 -10
  186. package/_baseSum-wEbgNeUs.js +0 -10
  187. package/_baseUniq-D3N8igOm.js +0 -41
  188. package/_cacheHas-Wgl-hw34.js +0 -22
  189. package/_commonjsHelpers-C6fGbg64.js +0 -6
  190. package/_createAggregator-BVj8IAuF.js +0 -53
  191. package/_defineProperty-BZU4WKA3.js +0 -11
  192. package/_getPrototype-BGBCg-aX.js +0 -5
  193. package/_getTag-B7R9qBo7.js +0 -73
  194. package/_isIterateeCall-Dm0VTAYy.js +0 -13
  195. package/_setToArray-Ck4YZu0Z.js +0 -9
  196. package/cloneDeep-fV59zwUf.js +0 -8
  197. package/countBy-B3rNuG4T.js +0 -8
  198. package/get-Bil3mzRD.js +0 -8
  199. package/groupBy-CrJC7sGa.js +0 -8
  200. package/iconify-Ptb5dTKy.js +0 -1270
  201. package/identity-ByMq8VxU.js +0 -6
  202. package/index-BH-gBhtO.js +0 -2282
  203. package/index-BM9Sve5T.js +0 -571
  204. package/index-Cj4d5cGz.js +0 -357
  205. package/index-D3Dwn-8x.js +0 -6464
  206. package/index-Dh2PP9h8.js +0 -11747
  207. package/index-DoFpWPHo.js +0 -975
  208. package/isArguments-BWcXOE6a.js +0 -24
  209. package/isArray-WzO_os3q.js +0 -4
  210. package/isEmpty-DKxrY-_M.js +0 -22
  211. package/isNil-CjWwlQS3.js +0 -6
  212. package/isObject-B53jY8Qg.js +0 -7
  213. package/isObjectLike-CYbdrIBr.js +0 -6
  214. package/isSymbol-DE1Kcy2M.js +0 -9
  215. package/last-7CdUxN0r.js +0 -7
  216. package/maxBy-BOWDkL_D.js +0 -8
  217. package/replication-WkKbPdwG.js +0 -8453
  218. package/sessionStorage-DFMae61b.js +0 -90
  219. package/sortBy-BHe812lF.js +0 -74
  220. package/store-D4aFUWxi.js +0 -1169
  221. package/sumBy-B7f_bP_k.js +0 -8
  222. package/toFinite-CBrE65MP.js +0 -14
  223. package/toNumber-CxmWey0f.js +0 -31
  224. package/uniq-B4UZ671_.js +0 -7
  225. package/utils-SpTOhPYl.js +0 -147
@@ -1,79 +1,87 @@
1
- import { jsxs as y, Fragment as C, jsx as e } from "react/jsx-runtime";
2
- import { useTheme as k, Tooltip as S, IconButton as E, CircularProgress as d, Button as z, Popover as I, Paper as j, Stack as c, Box as P, Typography as B, Divider as O } from "@mui/material";
3
- import { e as T, f as p, c as w } from "../../ActionForm-DjyNwVzM.js";
4
- import { useState as m, useRef as M, useCallback as D, useEffect as F } from "react";
5
- import g from "../display/icons/Iconified.js";
6
- const H = ({ show: t = !1, size: b = "small", selector: n }) => {
7
- const { t: s } = T((i) => i.i18next), h = k(), a = p((i) => i.availableSources), u = p((i) => i.enrich), [x, o] = m(t), [r, f] = m(!1), l = M(null), v = D(
8
- async (i) => {
9
- f(!0);
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
+ import { useTheme, Tooltip, IconButton, CircularProgress, Button, Popover, Paper, Stack, Box, Typography, Divider } from "@mui/material";
3
+ import { e as useClueComponentSelector, f as useClueEnrichSelector, c as capitalize } from "../../ActionForm-CbLz66Rk.js";
4
+ import { useState, useRef, useCallback, useEffect } from "react";
5
+ import Iconified from "../display/icons/Iconified.js";
6
+ const EnrichPopover = ({ show = false, size = "small", selector }) => {
7
+ const { t } = useClueComponentSelector((ctx) => ctx.i18next);
8
+ const theme = useTheme();
9
+ const availableSources = useClueEnrichSelector((ctx) => ctx.availableSources);
10
+ const _enrich = useClueEnrichSelector((ctx) => ctx.enrich);
11
+ const [showEnrichMenu, setShowEnrichMenu] = useState(show);
12
+ const [loading, setLoading] = useState(false);
13
+ const enrichEl = useRef(null);
14
+ const enrich = useCallback(
15
+ async (_source) => {
16
+ setLoading(true);
10
17
  try {
11
- await u(n.type, n.value, {
12
- classification: n.classification,
18
+ await _enrich(selector.type, selector.value, {
19
+ classification: selector.classification,
13
20
  timeout: 30,
14
- force: !0,
15
- noCache: !0,
16
- sources: [i],
17
- append: !0
21
+ force: true,
22
+ noCache: true,
23
+ sources: [_source],
24
+ append: true
18
25
  });
19
26
  } finally {
20
- f(!1);
27
+ setLoading(false);
21
28
  }
22
29
  },
23
- [u, n.classification, n.type, n.value]
30
+ [_enrich, selector.classification, selector.type, selector.value]
24
31
  );
25
- return F(() => {
26
- o(t);
27
- }, [t]), /* @__PURE__ */ y(C, { children: [
28
- b === "small" ? /* @__PURE__ */ e(S, { ref: l, title: s("enrich"), children: /* @__PURE__ */ e("span", { style: { alignSelf: "center" }, children: /* @__PURE__ */ e(
29
- E,
32
+ useEffect(() => {
33
+ setShowEnrichMenu(show);
34
+ }, [show]);
35
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
36
+ size === "small" ? /* @__PURE__ */ jsx(Tooltip, { ref: enrichEl, title: t("enrich"), children: /* @__PURE__ */ jsx("span", { style: { alignSelf: "center" }, children: /* @__PURE__ */ jsx(
37
+ IconButton,
30
38
  {
31
- onClick: () => o(!0),
32
- disabled: Object.keys(a).length < 1 || r,
39
+ onClick: () => setShowEnrichMenu(true),
40
+ disabled: Object.keys(availableSources).length < 1 || loading,
33
41
  color: "info",
34
- children: r ? /* @__PURE__ */ e(d, { color: "info", size: "24px" }) : /* @__PURE__ */ e(g, { icon: "ic:baseline-auto-fix-high" })
42
+ children: loading ? /* @__PURE__ */ jsx(CircularProgress, { color: "info", size: "24px" }) : /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-auto-fix-high" })
35
43
  }
36
- ) }) }) : /* @__PURE__ */ e(
37
- z,
44
+ ) }) }) : /* @__PURE__ */ jsx(
45
+ Button,
38
46
  {
39
- ref: l,
47
+ ref: enrichEl,
40
48
  variant: "outlined",
41
49
  color: "info",
42
- disabled: Object.keys(a).length < 1 || r,
43
- startIcon: r ? /* @__PURE__ */ e(d, { color: "info", size: "20px" }) : /* @__PURE__ */ e(g, { icon: "ic:baseline-auto-fix-high" }),
50
+ disabled: Object.keys(availableSources).length < 1 || loading,
51
+ startIcon: loading ? /* @__PURE__ */ jsx(CircularProgress, { color: "info", size: "20px" }) : /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-auto-fix-high" }),
44
52
  sx: { alignSelf: "stretch" },
45
- onClick: () => o(!0),
46
- children: s("enrich")
53
+ onClick: () => setShowEnrichMenu(true),
54
+ children: t("enrich")
47
55
  }
48
56
  ),
49
- /* @__PURE__ */ e(
50
- I,
57
+ /* @__PURE__ */ jsx(
58
+ Popover,
51
59
  {
52
60
  sx: { zIndex: 2e3 },
53
- open: x,
54
- disablePortal: !0,
55
- onClose: () => o(!1),
56
- anchorEl: l.current,
61
+ open: showEnrichMenu,
62
+ disablePortal: true,
63
+ onClose: () => setShowEnrichMenu(false),
64
+ anchorEl: enrichEl.current,
57
65
  anchorOrigin: { horizontal: "left", vertical: "bottom" },
58
- children: /* @__PURE__ */ e(j, { onClick: () => o(!1), children: /* @__PURE__ */ e(c, { divider: /* @__PURE__ */ e(O, { flexItem: !0, orientation: "horizontal" }), children: a.map((i) => /* @__PURE__ */ e(
59
- P,
66
+ children: /* @__PURE__ */ jsx(Paper, { onClick: () => setShowEnrichMenu(false), children: /* @__PURE__ */ jsx(Stack, { divider: /* @__PURE__ */ jsx(Divider, { flexItem: true, orientation: "horizontal" }), children: availableSources.map((_source) => /* @__PURE__ */ jsx(
67
+ Box,
60
68
  {
61
69
  sx: {
62
70
  px: 3,
63
71
  py: 1,
64
72
  cursor: "pointer",
65
- transition: h.transitions.create("background-color"),
66
- "&:hover": { backgroundColor: h.palette.background.default }
73
+ transition: theme.transitions.create("background-color"),
74
+ "&:hover": { backgroundColor: theme.palette.background.default }
67
75
  },
68
- onClick: () => v(i),
69
- children: /* @__PURE__ */ e(c, { children: /* @__PURE__ */ e(c, { direction: "row", spacing: 1, alignItems: "center", children: /* @__PURE__ */ e(B, { variant: "body1", children: i.split("-").map(w).join(" ") }) }) })
76
+ onClick: () => enrich(_source),
77
+ children: /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(Stack, { direction: "row", spacing: 1, alignItems: "center", children: /* @__PURE__ */ jsx(Typography, { variant: "body1", children: _source.split("-").map(capitalize).join(" ") }) }) })
70
78
  },
71
- i
79
+ _source
72
80
  )) }) })
73
81
  }
74
82
  )
75
83
  ] });
76
84
  };
77
85
  export {
78
- H as default
86
+ EnrichPopover as default
79
87
  };
@@ -1,106 +1,148 @@
1
- import { jsx as t, jsxs as l } from "react/jsx-runtime";
2
- import { I as J } from "../../iconify-Ptb5dTKy.js";
3
- import { useTheme as K, Skeleton as W, Chip as Q, Tooltip as D, Stack as s, Typography as U, LinearProgress as X, Paper as Y, IconButton as Z } from "@mui/material";
4
- import { F as E } from "../../FlexOne-BXWFOd1T.js";
5
- import S from "../display/icons/Iconified.js";
6
- import { ClueComponentContext as $ } from "../../hooks/ClueComponentContext.js";
7
- import { g as f } from "../../ActionForm-DjyNwVzM.js";
8
- import p, { useState as b, useRef as k, useMemo as N, useEffect as O, memo as P } from "react";
9
- import { a as ee } from "../../index-BM9Sve5T.js";
10
- import { FetcherResultView as te } from "./FetcherResultView.js";
11
- import ie from "./PreviewModal.js";
12
- import ne from "./StatusChip.js";
13
- const re = p.memo(
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { I as Icon } from "../../iconify-DJxl6dC-.js";
3
+ import { useTheme, Skeleton, Chip, Tooltip, Stack, Typography, LinearProgress, Paper, IconButton } from "@mui/material";
4
+ import { F as FlexOne } from "../../FlexOne-BSYAhhtG.js";
5
+ import Iconified from "../display/icons/Iconified.js";
6
+ import { ClueComponentContext } from "../../hooks/ClueComponentContext.js";
7
+ import { g as useClueFetcherSelector } from "../../ActionForm-CbLz66Rk.js";
8
+ import React__default, { useState, useRef, useMemo, useEffect, memo } from "react";
9
+ import { a as useContextSelector } from "../../index-_gpzM2Px.js";
10
+ import { FetcherResultView } from "./FetcherResultView.js";
11
+ import PreviewModal from "./PreviewModal.js";
12
+ import StatusChip from "./StatusChip.js";
13
+ const Fetcher = React__default.memo(
14
14
  ({
15
- type: h,
16
- value: x,
17
- classification: g,
18
- fetcherId: n,
15
+ type,
16
+ value,
17
+ classification,
18
+ fetcherId,
19
19
  slotProps: {
20
- paper: o = {},
21
- preview: q = {},
22
- stack: a = {},
23
- image: v = {},
24
- chip: R = {},
25
- skeleton: r = {}
20
+ paper: paperProps = {},
21
+ preview: previewProps = {},
22
+ stack: stackProps = {},
23
+ image: imageProps = {},
24
+ chip: chipProps = {},
25
+ skeleton: skeletonProps = {}
26
26
  } = {}
27
27
  }) => {
28
- var M, j, B, L;
29
- const c = K(), w = f((i) => i.fetchers), F = f((i) => i.fetchSelector), A = f((i) => i.getFetcherStatus), G = f((i) => i.fetchCompleted), { t: u } = ee($, (i) => i == null ? void 0 : i.i18next), [e, m] = b(null), [H, _] = b(!0), [I, z] = b(!1), y = k(null), C = N(() => e == null ? void 0 : e.task_id, [e == null ? void 0 : e.task_id]);
30
- O(() => {
31
- if ((e == null ? void 0 : e.outcome) !== "pending" || !C) return;
32
- let i = !1;
33
- const V = async () => {
34
- const d = await A(n, C);
35
- if (!d)
36
- m({ outcome: "failure", done: !0, error: "Missing result", link: "" });
37
- else if (d.outcome === "success" || d.outcome === "failure")
38
- m({ ...d, done: !0 });
39
- else {
40
- if (i) return;
41
- m({ ...d }), y.current = setTimeout(V, 2e3);
28
+ var _a, _b, _c, _d;
29
+ const theme = useTheme();
30
+ const fetchers = useClueFetcherSelector((ctx) => ctx.fetchers);
31
+ const fetchSelector = useClueFetcherSelector((ctx) => ctx.fetchSelector);
32
+ const getFetcherStatus = useClueFetcherSelector((ctx) => ctx.getFetcherStatus);
33
+ const fetchCompleted = useClueFetcherSelector((ctx) => ctx.fetchCompleted);
34
+ const { t } = useContextSelector(ClueComponentContext, (ctx) => ctx == null ? void 0 : ctx.i18next);
35
+ const [result, setResult] = useState(null);
36
+ const [loading, setLoading] = useState(true);
37
+ const [showPreview, setShowPreview] = useState(false);
38
+ const timeoutRef = useRef(null);
39
+ const taskId = useMemo(() => result == null ? void 0 : result.task_id, [result == null ? void 0 : result.task_id]);
40
+ useEffect(() => {
41
+ if ((result == null ? void 0 : result.outcome) !== "pending" || !taskId) return;
42
+ let cancelled = false;
43
+ const poll = async () => {
44
+ const res = await getFetcherStatus(fetcherId, taskId);
45
+ if (!res) {
46
+ setResult({ outcome: "failure", done: true, error: "Missing result", link: "" });
47
+ } else if (res.outcome === "success" || res.outcome === "failure") {
48
+ setResult({ ...res, done: true });
49
+ } else {
50
+ if (cancelled) return;
51
+ setResult({ ...res });
52
+ timeoutRef.current = setTimeout(poll, 2e3);
42
53
  }
43
54
  };
44
- return V(), () => {
45
- i = !0, y.current && clearTimeout(y.current);
55
+ poll();
56
+ return () => {
57
+ cancelled = true;
58
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
46
59
  };
47
- }, [n, A, e == null ? void 0 : e.outcome, C]), O(() => {
60
+ }, [fetcherId, getFetcherStatus, result == null ? void 0 : result.outcome, taskId]);
61
+ useEffect(() => {
48
62
  (async () => {
49
63
  try {
50
- _(!0), m(await F(n, { type: h, value: x, classification: g }));
64
+ setLoading(true);
65
+ setResult(await fetchSelector(fetcherId, { type, value, classification }));
51
66
  } catch {
52
- m({ outcome: "failure", done: !0, error: u("error.unexpected") });
67
+ setResult({ outcome: "failure", done: true, error: t("error.unexpected") });
53
68
  } finally {
54
- _(!1);
69
+ setLoading(false);
55
70
  }
56
71
  })();
57
- }, [g, F, n, u, h, x]);
58
- const T = N(() => (e == null ? void 0 : e.outcome) === "success" && e.format === "image" ? { ...v, onClick: () => z(!0) } : { result: e }, [v, e]);
59
- if (G)
60
- if (n)
61
- if (n.includes(".")) {
62
- if (!(n in w))
63
- return console.warn("Fetcher ID does not correspond to a registered fetcher. Component will not render."), null;
64
- } else return console.warn(
72
+ }, [classification, fetchSelector, fetcherId, t, type, value]);
73
+ const resultAdditionalProps = useMemo(() => {
74
+ if ((result == null ? void 0 : result.outcome) === "success" && result.format === "image") {
75
+ return { ...imageProps, onClick: () => setShowPreview(true) };
76
+ }
77
+ return { result };
78
+ }, [imageProps, result]);
79
+ if (fetchCompleted) {
80
+ if (!fetcherId) {
81
+ console.warn("Missing fetcher Id. Component will not render.");
82
+ return null;
83
+ } else if (!fetcherId.includes(".")) {
84
+ console.warn(
65
85
  "Invalid fetcher id. Must be in the format '<plugin_id>.<fetcher_id>'. Component will not render."
66
- ), null;
67
- else return console.warn("Missing fetcher Id. Component will not render."), null;
68
- else
69
- return null;
70
- return H ? ((M = w[n]) == null ? void 0 : M.format) === "status" ? /* @__PURE__ */ t(
71
- W,
72
- {
73
- variant: "rounded",
74
- height: "32px",
75
- width: "150px",
76
- ...r,
77
- sx: [
78
- { borderRadius: "16px" },
79
- ...Array.isArray(r == null ? void 0 : r.sx) ? r == null ? void 0 : r.sx : [r == null ? void 0 : r.sx]
80
- ]
86
+ );
87
+ return null;
88
+ } else if (!(fetcherId in fetchers)) {
89
+ console.warn("Fetcher ID does not correspond to a registered fetcher. Component will not render.");
90
+ return null;
81
91
  }
82
- ) : /* @__PURE__ */ t(W, { variant: "rounded", height: "325px", width: "300px", ...r }) : e ? e.outcome === "failure" && w[n].format === "status" ? /* @__PURE__ */ t(
83
- Q,
84
- {
85
- icon: /* @__PURE__ */ t(D, { title: e.error, children: /* @__PURE__ */ t(J, { icon: "mdi:information-outline", fontSize: "1.25rem" }) }),
86
- label: u("error"),
87
- color: "error",
88
- ...R
92
+ } else {
93
+ return null;
94
+ }
95
+ if (loading) {
96
+ if (((_a = fetchers[fetcherId]) == null ? void 0 : _a.format) === "status") {
97
+ return /* @__PURE__ */ jsx(
98
+ Skeleton,
99
+ {
100
+ variant: "rounded",
101
+ height: "32px",
102
+ width: "150px",
103
+ ...skeletonProps,
104
+ sx: [
105
+ { borderRadius: "16px" },
106
+ ...Array.isArray(skeletonProps == null ? void 0 : skeletonProps.sx) ? skeletonProps == null ? void 0 : skeletonProps.sx : [skeletonProps == null ? void 0 : skeletonProps.sx]
107
+ ]
108
+ }
109
+ );
110
+ } else {
111
+ return /* @__PURE__ */ jsx(Skeleton, { variant: "rounded", height: "325px", width: "300px", ...skeletonProps });
89
112
  }
90
- ) : e.outcome === "pending" ? /* @__PURE__ */ l(s, { flex: 1, sx: { pt: 2, alignItems: "center" }, spacing: 1, children: [
91
- ((j = e.data) == null ? void 0 : j.summary) && /* @__PURE__ */ t(U, { variant: "caption", children: e.data.summary }),
92
- /* @__PURE__ */ t(
93
- X,
113
+ }
114
+ if (!result) return null;
115
+ if (result.outcome === "failure" && fetchers[fetcherId].format === "status") {
116
+ return /* @__PURE__ */ jsx(
117
+ Chip,
94
118
  {
95
- variant: (B = e.data) != null && B.progress ? "determinate" : "indeterminate",
96
- value: ((L = e.data) == null ? void 0 : L.progress) * 100,
97
- sx: { maxWidth: 500, width: "100%", borderRadius: c.shape.borderRadius }
119
+ icon: /* @__PURE__ */ jsx(Tooltip, { title: result.error, children: /* @__PURE__ */ jsx(Icon, { icon: "mdi:information-outline", fontSize: "1.25rem" }) }),
120
+ label: t("error"),
121
+ color: "error",
122
+ ...chipProps
98
123
  }
99
- )
100
- ] }) : e.format === "status" ? /* @__PURE__ */ t(ne, { data: e.data, ...R }) : /* @__PURE__ */ t(
101
- Y,
124
+ );
125
+ }
126
+ if (result.outcome === "pending") {
127
+ return /* @__PURE__ */ jsxs(Stack, { flex: 1, sx: { pt: 2, alignItems: "center" }, spacing: 1, children: [
128
+ ((_b = result.data) == null ? void 0 : _b.summary) && /* @__PURE__ */ jsx(Typography, { variant: "caption", children: result.data.summary }),
129
+ /* @__PURE__ */ jsx(
130
+ LinearProgress,
131
+ {
132
+ variant: ((_c = result.data) == null ? void 0 : _c.progress) ? "determinate" : "indeterminate",
133
+ value: ((_d = result.data) == null ? void 0 : _d.progress) * 100,
134
+ sx: { maxWidth: 500, width: "100%", borderRadius: theme.shape.borderRadius }
135
+ }
136
+ )
137
+ ] });
138
+ }
139
+ if (result.format === "status") {
140
+ return /* @__PURE__ */ jsx(StatusChip, { data: result.data, ...chipProps });
141
+ }
142
+ return /* @__PURE__ */ jsx(
143
+ Paper,
102
144
  {
103
- ...o,
145
+ ...paperProps,
104
146
  sx: [
105
147
  {
106
148
  p: 1,
@@ -109,16 +151,16 @@ const re = p.memo(
109
151
  width: "100%",
110
152
  minWidth: "300px"
111
153
  },
112
- ...Array.isArray(o == null ? void 0 : o.sx) ? o == null ? void 0 : o.sx : [o == null ? void 0 : o.sx]
154
+ ...Array.isArray(paperProps == null ? void 0 : paperProps.sx) ? paperProps == null ? void 0 : paperProps.sx : [paperProps == null ? void 0 : paperProps.sx]
113
155
  ],
114
- children: /* @__PURE__ */ l(
115
- s,
156
+ children: /* @__PURE__ */ jsxs(
157
+ Stack,
116
158
  {
117
159
  sx: {
118
160
  "& > img": {
119
161
  borderRadius: "3px",
120
162
  cursor: "zoom-in",
121
- transition: c.transitions.create("border-color", { duration: c.transitions.duration.shortest }),
163
+ transition: theme.transitions.create("border-color", { duration: theme.transitions.duration.shortest }),
122
164
  border: "3px solid transparent",
123
165
  "&:hover": {
124
166
  borderColor: "primary.main"
@@ -126,71 +168,72 @@ const re = p.memo(
126
168
  }
127
169
  },
128
170
  children: [
129
- e.outcome === "failure" && /* @__PURE__ */ t("code", { style: { color: c.palette.error.main }, children: /* @__PURE__ */ t("pre", { style: { marginTop: 0, marginBottom: 0 }, children: e.error }) }),
130
- /* @__PURE__ */ t(te, { result: e, fetcherId: n, ...T }),
131
- /* @__PURE__ */ t(E, {}),
132
- /* @__PURE__ */ l(
133
- s,
171
+ result.outcome === "failure" && /* @__PURE__ */ jsx("code", { style: { color: theme.palette.error.main }, children: /* @__PURE__ */ jsx("pre", { style: { marginTop: 0, marginBottom: 0 }, children: result.error }) }),
172
+ /* @__PURE__ */ jsx(FetcherResultView, { result, fetcherId, ...resultAdditionalProps }),
173
+ /* @__PURE__ */ jsx(FlexOne, {}),
174
+ /* @__PURE__ */ jsxs(
175
+ Stack,
134
176
  {
135
177
  direction: "row",
136
178
  spacing: 1,
137
- ...a,
179
+ ...stackProps,
138
180
  sx: [
139
181
  {
140
- py: c.spacing(0.5),
182
+ py: theme.spacing(0.5),
141
183
  display: "flex",
142
184
  alignItems: "center"
143
185
  },
144
- ...Array.isArray(a == null ? void 0 : a.sx) ? a == null ? void 0 : a.sx : [a == null ? void 0 : a.sx]
186
+ ...Array.isArray(stackProps == null ? void 0 : stackProps.sx) ? stackProps == null ? void 0 : stackProps.sx : [stackProps == null ? void 0 : stackProps.sx]
145
187
  ],
146
188
  children: [
147
- /* @__PURE__ */ t(S, { icon: "ic:baseline-landscape", color: "primary", fontSize: "small" }),
148
- /* @__PURE__ */ t(
149
- D,
189
+ /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-landscape", color: "primary", fontSize: "small" }),
190
+ /* @__PURE__ */ jsx(
191
+ Tooltip,
150
192
  {
151
- title: /* @__PURE__ */ l(s, { spacing: 0.5, children: [
152
- /* @__PURE__ */ l("span", { children: [
153
- u("type"),
193
+ title: /* @__PURE__ */ jsxs(Stack, { spacing: 0.5, children: [
194
+ /* @__PURE__ */ jsxs("span", { children: [
195
+ t("type"),
154
196
  ": ",
155
- h
197
+ type
156
198
  ] }),
157
- /* @__PURE__ */ l("span", { children: [
158
- u("value"),
199
+ /* @__PURE__ */ jsxs("span", { children: [
200
+ t("value"),
159
201
  ": ",
160
- x
202
+ value
161
203
  ] }),
162
- /* @__PURE__ */ l("span", { children: [
163
- u("classification"),
204
+ /* @__PURE__ */ jsxs("span", { children: [
205
+ t("classification"),
164
206
  ": ",
165
- g ?? "N/A"
207
+ classification ?? "N/A"
166
208
  ] })
167
209
  ] }),
168
- children: /* @__PURE__ */ t(S, { icon: "ic:outline-info", fontSize: "small" })
210
+ children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:outline-info", fontSize: "small" })
169
211
  }
170
212
  ),
171
- /* @__PURE__ */ t(E, {}),
172
- e.link && /* @__PURE__ */ t(Z, { size: "small", component: "a", href: e.link, children: /* @__PURE__ */ t(S, { icon: "ic:baseline-open-in-new", fontSize: "small" }) })
213
+ /* @__PURE__ */ jsx(FlexOne, {}),
214
+ result.link && /* @__PURE__ */ jsx(IconButton, { size: "small", component: "a", href: result.link, children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-open-in-new", fontSize: "small" }) })
173
215
  ]
174
216
  }
175
217
  ),
176
- /* @__PURE__ */ t(
177
- ie,
218
+ /* @__PURE__ */ jsx(
219
+ PreviewModal,
178
220
  {
179
- ...q,
180
- fetcherId: n,
181
- slotProps: { fetcherResultView: T },
182
- open: I,
183
- result: e,
184
- onClose: () => z(!1)
221
+ ...previewProps,
222
+ fetcherId,
223
+ slotProps: { fetcherResultView: resultAdditionalProps },
224
+ open: showPreview,
225
+ result,
226
+ onClose: () => setShowPreview(false)
185
227
  }
186
228
  )
187
229
  ]
188
230
  }
189
231
  )
190
232
  }
191
- ) : null;
233
+ );
192
234
  }
193
- ), we = P(re);
235
+ );
236
+ const Fetcher_default = memo(Fetcher);
194
237
  export {
195
- we as default
238
+ Fetcher_default as default
196
239
  };
@@ -1,37 +1,41 @@
1
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
2
- import { Stack as c } from "@mui/material";
3
- import { J as m } from "../../index-Cj4d5cGz.js";
4
- import f from "../display/markdown/index.js";
5
- import { u as p, c as g } from "../../store-D4aFUWxi.js";
6
- import { useTranslation as h } from "react-i18next";
7
- import u from "../ErrorBoundary.js";
8
- const y = ({
9
- pluginName: l,
10
- result: o,
11
- fetcherId: t,
12
- ...d
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Stack } from "@mui/material";
3
+ import { J as JSONViewer } from "../../index-DUEubgWN.js";
4
+ import Markdown from "../display/markdown/index.js";
5
+ import { u as usePluginStore, c as clueUIPluginStore } from "../../store-DHP48fQB.js";
6
+ import { useTranslation } from "react-i18next";
7
+ import ErrorBoundary from "../ErrorBoundary.js";
8
+ const FetcherResultView = ({
9
+ pluginName,
10
+ result,
11
+ fetcherId,
12
+ ...props
13
13
  }) => {
14
- const s = p(), { t: e } = h(), n = l ?? g.getPlugin(o.format ?? "undefined", "fetcher", void 0, t);
15
- if (n)
14
+ const pluginStore = usePluginStore();
15
+ const { t } = useTranslation();
16
+ const availablePlugin = pluginName ?? clueUIPluginStore.getPlugin(result.format ?? "undefined", "fetcher", void 0, fetcherId);
17
+ if (availablePlugin) {
16
18
  try {
17
- const a = s.executeFunction(`${n}.fetcherResult`, {
18
- result: o,
19
- fetcherId: t,
20
- ...d
19
+ const component = pluginStore.executeFunction(`${availablePlugin}.fetcherResult`, {
20
+ result,
21
+ fetcherId,
22
+ ...props
21
23
  });
22
- if (a !== void 0)
23
- return /* @__PURE__ */ r(u, { children: a });
24
+ if (component !== void 0) {
25
+ return /* @__PURE__ */ jsx(ErrorBoundary, { children: component });
26
+ }
24
27
  } catch {
25
- return /* @__PURE__ */ r(u, { children: /* @__PURE__ */ i(c, { sx: { overflowY: "auto" }, children: [
26
- /* @__PURE__ */ r(f, { md: e("format.render.error", { format: o.format }) }),
27
- /* @__PURE__ */ r(m, { data: o, collapse: !0, forceCompact: !0 })
28
+ return /* @__PURE__ */ jsx(ErrorBoundary, { children: /* @__PURE__ */ jsxs(Stack, { sx: { overflowY: "auto" }, children: [
29
+ /* @__PURE__ */ jsx(Markdown, { md: t("format.render.error", { format: result.format }) }),
30
+ /* @__PURE__ */ jsx(JSONViewer, { data: result, collapse: true, forceCompact: true })
28
31
  ] }) });
29
32
  }
30
- return /* @__PURE__ */ i(c, { sx: { overflowY: "auto" }, children: [
31
- /* @__PURE__ */ r(f, { md: e("format.not.recognized", { format: o.format }) }),
32
- /* @__PURE__ */ r(m, { data: o, collapse: !0, forceCompact: !0 })
33
+ }
34
+ return /* @__PURE__ */ jsxs(Stack, { sx: { overflowY: "auto" }, children: [
35
+ /* @__PURE__ */ jsx(Markdown, { md: t("format.not.recognized", { format: result.format }) }),
36
+ /* @__PURE__ */ jsx(JSONViewer, { data: result, collapse: true, forceCompact: true })
33
37
  ] });
34
38
  };
35
39
  export {
36
- y as FetcherResultView
40
+ FetcherResultView
37
41
  };
@@ -1,24 +1,25 @@
1
- import { jsx as l } from "react/jsx-runtime";
2
- import { Modal as c, Paper as d } from "@mui/material";
3
- import { memo as u } from "react";
4
- import { FetcherResultView as s } from "./FetcherResultView.js";
5
- const w = ({ result: a, slotProps: e = {}, fetcherId: m, onClose: n, open: f = !1, ...i }) => {
6
- const { fetcherResultView: t, ...x } = e;
7
- return /* @__PURE__ */ l(
8
- c,
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Modal, Paper } from "@mui/material";
3
+ import { memo } from "react";
4
+ import { FetcherResultView } from "./FetcherResultView.js";
5
+ const PreviewModal = ({ result, slotProps = {}, fetcherId, onClose, open = false, ...otherProps }) => {
6
+ const { fetcherResultView, ...modalSlotProps } = slotProps;
7
+ return /* @__PURE__ */ jsx(
8
+ Modal,
9
9
  {
10
- open: f,
10
+ open,
11
11
  sx: [
12
12
  { display: "flex", alignItems: "center", justifyContent: "center" },
13
- ...Array.isArray(i == null ? void 0 : i.sx) ? i == null ? void 0 : i.sx : [i == null ? void 0 : i.sx]
13
+ ...Array.isArray(otherProps == null ? void 0 : otherProps.sx) ? otherProps == null ? void 0 : otherProps.sx : [otherProps == null ? void 0 : otherProps.sx]
14
14
  ],
15
- onClose: n,
16
- slotProps: x,
17
- ...i,
18
- children: /* @__PURE__ */ l(d, { sx: { maxHeight: "90%", maxWidth: "90%", p: 2, overflow: "auto" }, children: /* @__PURE__ */ l(s, { ...t ?? {}, result: a, fetcherId: m }) })
15
+ onClose,
16
+ slotProps: modalSlotProps,
17
+ ...otherProps,
18
+ children: /* @__PURE__ */ jsx(Paper, { sx: { maxHeight: "90%", maxWidth: "90%", p: 2, overflow: "auto" }, children: /* @__PURE__ */ jsx(FetcherResultView, { ...fetcherResultView ?? {}, result, fetcherId }) })
19
19
  }
20
20
  );
21
- }, j = u(w);
21
+ };
22
+ const PreviewModal$1 = memo(PreviewModal);
22
23
  export {
23
- j as default
24
+ PreviewModal$1 as default
24
25
  };