@localstack/appinspector-ui 1.0.220 → 1.0.222

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.
package/dist/index.cjs CHANGED
@@ -2425,8 +2425,8 @@ __export(index_exports, {
2425
2425
  module.exports = __toCommonJS(index_exports);
2426
2426
 
2427
2427
  // src/pages/spans-list-page.tsx
2428
- var import_material29 = require("@mui/material");
2429
- var import_react70 = require("react");
2428
+ var import_material30 = require("@mui/material");
2429
+ var import_react71 = require("react");
2430
2430
 
2431
2431
  // src/api/errors.ts
2432
2432
  var AppInspectorDisabledError = class extends Error {
@@ -2552,6 +2552,21 @@ var WATERFALL_AXIS_LABEL_TEST_ID = "waterfall-axis-label";
2552
2552
  var WATERFALL_TREE_VIEW_BUTTON_TEST_ID = "waterfall-tree-view-button";
2553
2553
  var WATERFALL_LIST_VIEW_BUTTON_TEST_ID = "waterfall-list-view-button";
2554
2554
  var WATERFALL_ROW_OFFSET_TEST_ID = "waterfall-row-offset";
2555
+ var TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID = "trace-sidebar-sequence-button";
2556
+ var SEQUENCE_DIAGRAM_TEST_ID = "sequence-diagram";
2557
+ var SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID = "sequence-diagram-participant";
2558
+ var SEQUENCE_DIAGRAM_MESSAGE_TEST_ID = "sequence-diagram-message";
2559
+ var SEQUENCE_DIAGRAM_RETURN_TEST_ID = "sequence-diagram-return";
2560
+ var SEQUENCE_DIAGRAM_ARROW_TEST_ID = "sequence-diagram-arrow";
2561
+ var SEQUENCE_DIAGRAM_SEGMENT_TEST_ID = "sequence-diagram-segment";
2562
+ var SEQUENCE_DIAGRAM_HOVER_CARD_TEST_ID = "sequence-diagram-hover-card";
2563
+ var SEQUENCE_DIAGRAM_TOGGLE_TEST_ID = "sequence-diagram-toggle";
2564
+ var SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID = "sequence-diagram-zoom-in-button";
2565
+ var SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID = "sequence-diagram-zoom-out-button";
2566
+ var SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID = "sequence-diagram-zoom-reset-button";
2567
+ var SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID = "sequence-diagram-zoom-fit-button";
2568
+ var SEQUENCE_DIAGRAM_MINIMAP_TEST_ID = "sequence-diagram-minimap";
2569
+ var SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID = "sequence-diagram-minimap-toggle";
2555
2570
 
2556
2571
  // src/utils/emulator-version.ts
2557
2572
  var import_semver = __toESM(require_semver2(), 1);
@@ -7157,12 +7172,12 @@ var isColorString = (type, testProp) => (v) => {
7157
7172
  var splitColor = (aName, bName, cName) => (v) => {
7158
7173
  if (!isString(v))
7159
7174
  return v;
7160
- const [a3, b3, c3, alpha8] = v.match(floatRegex);
7175
+ const [a3, b3, c3, alpha9] = v.match(floatRegex);
7161
7176
  return {
7162
7177
  [aName]: parseFloat(a3),
7163
7178
  [bName]: parseFloat(b3),
7164
7179
  [cName]: parseFloat(c3),
7165
- alpha: alpha8 !== void 0 ? parseFloat(alpha8) : 1
7180
+ alpha: alpha9 !== void 0 ? parseFloat(alpha9) : 1
7166
7181
  };
7167
7182
  };
7168
7183
 
@@ -8276,7 +8291,7 @@ function hueToRgb(p, q, t) {
8276
8291
  return p + (q - p) * (2 / 3 - t) * 6;
8277
8292
  return p;
8278
8293
  }
8279
- function hslaToRgba({ hue, saturation, lightness, alpha: alpha8 }) {
8294
+ function hslaToRgba({ hue, saturation, lightness, alpha: alpha9 }) {
8280
8295
  hue /= 360;
8281
8296
  saturation /= 100;
8282
8297
  lightness /= 100;
@@ -8296,7 +8311,7 @@ function hslaToRgba({ hue, saturation, lightness, alpha: alpha8 }) {
8296
8311
  red: Math.round(red * 255),
8297
8312
  green: Math.round(green * 255),
8298
8313
  blue: Math.round(blue * 255),
8299
- alpha: alpha8
8314
+ alpha: alpha9
8300
8315
  };
8301
8316
  }
8302
8317
 
@@ -13147,10 +13162,10 @@ var getOperationLabel = (span) => {
13147
13162
 
13148
13163
  // src/components/operation-name.tsx
13149
13164
  var import_jsx_runtime4 = require("react/jsx-runtime");
13150
- var OperationName = ({ span }) => {
13165
+ var OperationName = ({ span, tooltip = true }) => {
13151
13166
  const label = getOperationLabel(span);
13152
- if (label === span.operation_name) {
13153
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { title: label, children: label });
13167
+ if (label === span.operation_name || !tooltip) {
13168
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { title: tooltip ? label : void 0, children: label });
13154
13169
  }
13155
13170
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
13156
13171
  import_material2.Tooltip,
@@ -16962,10 +16977,10 @@ var getTraceBounds = (spans) => {
16962
16977
  };
16963
16978
 
16964
16979
  // src/components/trace-panel/trace-sidebar.tsx
16965
- var import_icons_material15 = require("@mui/icons-material");
16966
- var import_material27 = require("@mui/material");
16967
- var import_react63 = require("@xyflow/react");
16968
- var React125 = __toESM(require("react"), 1);
16980
+ var import_icons_material16 = require("@mui/icons-material");
16981
+ var import_material28 = require("@mui/material");
16982
+ var import_react64 = require("@xyflow/react");
16983
+ var React127 = __toESM(require("react"), 1);
16969
16984
 
16970
16985
  // src/components/event-details/event-details.tsx
16971
16986
  var import_icons_material11 = require("@mui/icons-material");
@@ -16974,7 +16989,7 @@ var import_react53 = require("react");
16974
16989
 
16975
16990
  // src/dev-settings.tsx
16976
16991
  var React122 = __toESM(require("react"), 1);
16977
- var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", succeededIconColor: "green", waterfallLayout: "tree" };
16992
+ var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", sequenceBlocks: "detached", sequenceClickTargets: "arrows-and-segments", sequenceHoverCard: "on", succeededIconColor: "green", waterfallLayout: "tree" };
16978
16993
  var DevSettingsContext = React122.createContext(DEFAULT_DEV_SETTINGS);
16979
16994
  var useDevSettings = () => React122.useContext(DevSettingsContext);
16980
16995
 
@@ -31760,8 +31775,8 @@ var OPTIONAL_TABS = ["logs", "permissions", "response"];
31760
31775
  var getOptionalTabs = (span, eventGroups) => ({
31761
31776
  logs: checkIsLambdaInvoke(span) && typeof span.attributes?.["localstack.request_id"] === "string",
31762
31777
  permissions: span.iam_errors_suppressed === true || eventGroups.permissions !== void 0,
31763
- // A failed call has no response; its error is at the top of Details.
31764
- response: span.attributes?.["localstack.aws.service.response_suppressed"] === true || tryParseJson(span.attributes?.["localstack.aws.service.response"]) !== void 0
31778
+ // A failed call shows its error here, even with no response payload.
31779
+ response: getSpanIssues(span).error || span.attributes?.["localstack.aws.service.response_suppressed"] === true || tryParseJson(span.attributes?.["localstack.aws.service.response"]) !== void 0
31765
31780
  });
31766
31781
  var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { children: [
31767
31782
  /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Typography, { sx: { fontWeight: 600 }, variant: "caption", children: label }),
@@ -31771,14 +31786,19 @@ var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PUR
31771
31786
  ] })
31772
31787
  ] });
31773
31788
  var EmptyTab = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Typography, { color: "text.secondary", variant: "body2", children });
31774
- var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
31789
+ var EventDetails = ({ onClose, onOperationShown, requestedTab, selectedEvent }) => {
31775
31790
  const eventGroups = (0, import_react53.useMemo)(
31776
31791
  () => getEventGroupsByType(selectedEvent?.events ?? []),
31777
31792
  [selectedEvent?.events]
31778
31793
  );
31779
31794
  const { headingPills } = useDevSettings();
31780
31795
  const [parseNestedJson, setParseNestedJson] = (0, import_react53.useState)(true);
31781
- const [tab, setTab] = (0, import_react53.useState)("details");
31796
+ const [tab, setTab] = (0, import_react53.useState)(requestedTab?.view ?? "details");
31797
+ const [appliedRequest, setAppliedRequest] = (0, import_react53.useState)(requestedTab);
31798
+ if (requestedTab !== appliedRequest) {
31799
+ setAppliedRequest(requestedTab);
31800
+ if (requestedTab) setTab(requestedTab.view);
31801
+ }
31782
31802
  const optionalTabs = selectedEvent ? getOptionalTabs(selectedEvent, eventGroups) : void 0;
31783
31803
  const activeTab = optionalTabs && OPTIONAL_TABS.some((optional) => optional === tab && !optionalTabs[optional]) ? "details" : tab;
31784
31804
  const onOperationShownRef = (0, import_react53.useRef)(onOperationShown);
@@ -31895,9 +31915,9 @@ var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
31895
31915
  value: activeTab,
31896
31916
  variant: "scrollable",
31897
31917
  children: [
31898
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_DETAILS_TEST_ID, icon: showError ? /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_icons_material11.Cancel, { color: "error", sx: { fontSize: 16 } }) : void 0, iconPosition: "end", label: "Details", value: "details" }),
31918
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_DETAILS_TEST_ID, label: "Details", value: "details" }),
31899
31919
  /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_REQUEST_TEST_ID, label: "Payload", value: "payload" }),
31900
- showResponse && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_RESPONSE_TEST_ID, label: "Response", value: "response" }),
31920
+ showResponse && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_RESPONSE_TEST_ID, icon: showError ? /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_icons_material11.Cancel, { color: "error", sx: { fontSize: 16 } }) : void 0, iconPosition: "end", label: "Response", value: "response" }),
31901
31921
  showPermissions && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_PERMISSIONS_TEST_ID, icon: permissionsIcon, iconPosition: "end", label: "Permissions", value: "permissions" }),
31902
31922
  showLogs && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_LOGS_TEST_ID, label: "Logs", value: "logs" }),
31903
31923
  /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Tab, { "data-testid": DETAIL_TAB_ADVANCED_TEST_ID, label: "Advanced", value: "advanced" })
@@ -31906,35 +31926,6 @@ var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
31906
31926
  ),
31907
31927
  /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { sx: { p: 2 }, children: [
31908
31928
  activeTab === "details" && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { spacing: 2, children: [
31909
- showError && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { spacing: 2, sx: ERROR_BOX_SX, children: [
31910
- /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { spacing: 1, children: [
31911
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Type", children: errorType }),
31912
- errorMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Message", children: errorMessages.join(" \xB7 ") }),
31913
- functionError && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { sx: { display: "grid", gap: 2, gridTemplateColumns: "1.3fr 1fr" }, children: [
31914
- functionError.requestId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Request ID", children: functionError.requestId }),
31915
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Function Error", testId: EVENT_DETAILS_FUNCTION_ERROR_TEST_ID, children: functionError.functionError })
31916
- ] })
31917
- ] }),
31918
- functionError?.stackTrace !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { children: [
31919
- /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { alignItems: "center", direction: "row", sx: { "&:hover .copy-btn": { opacity: 1 } }, children: [
31920
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Typography, { sx: { fontWeight: 600 }, variant: "caption", children: "Stack Trace" }),
31921
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(CopyButton, { value: functionError.stackTrace })
31922
- ] }),
31923
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
31924
- import_material21.Box,
31925
- {
31926
- component: "pre",
31927
- "data-testid": EVENT_DETAILS_STACK_TRACE_TEST_ID,
31928
- sx: { backgroundColor: "background.default", borderRadius: 1, fontFamily: "monospace", fontSize: 12, m: 0, overflow: "auto", p: 1 },
31929
- children: functionError.stackTrace
31930
- }
31931
- )
31932
- ] }),
31933
- exceptionPayload !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { children: [
31934
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Typography, { sx: { fontWeight: 600, mb: 0.5 }, variant: "caption", children: "Exception" }),
31935
- /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PayloadViewer, { testId: EVENT_DETAILS_EXCEPTION_PAYLOAD_TEST_ID, value: exceptionPayload })
31936
- ] })
31937
- ] }),
31938
31929
  /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { "data-testid": EVENT_DETAILS_SECTION_BASIC_INFORMATION_TEST_ID, spacing: 1, children: [
31939
31930
  /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { sx: { display: "grid", gap: 2, gridTemplateColumns: "1.3fr 1fr" }, children: [
31940
31931
  /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { copy: getServiceDisplayName(selectedEvent.service_name), label: "Service", testId: EVENT_DETAILS_SERVICE_NAME_TEST_ID, children: getServiceDisplayName(selectedEvent.service_name) }),
@@ -31974,9 +31965,40 @@ var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
31974
31965
  rawDataSwitch,
31975
31966
  /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PayloadViewer, { testId: EVENT_DETAILS_REQUEST_PAYLOAD, value: requestPayload })
31976
31967
  ] })),
31977
- activeTab === "response" && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_jsx_runtime145.Fragment, { children: [
31978
- rawDataSwitch,
31979
- isResponseSuppressed ? /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Alert, { severity: "warning", children: "Response payload is available \u2014 upgrade your license to view" }) : /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PayloadViewer, { testId: EVENT_DETAILS_RESPONSE_PAYLOAD_TEST_ID, value: responsePayload })
31968
+ activeTab === "response" && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { spacing: 2, children: [
31969
+ showError && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { spacing: 2, sx: ERROR_BOX_SX, children: [
31970
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { spacing: 1, children: [
31971
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Type", children: errorType }),
31972
+ errorMessages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Message", children: errorMessages.join(" \xB7 ") }),
31973
+ functionError && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { sx: { display: "grid", gap: 2, gridTemplateColumns: "1.3fr 1fr" }, children: [
31974
+ functionError.requestId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Request ID", children: functionError.requestId }),
31975
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Field, { label: "Function Error", testId: EVENT_DETAILS_FUNCTION_ERROR_TEST_ID, children: functionError.functionError })
31976
+ ] })
31977
+ ] }),
31978
+ functionError?.stackTrace !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { children: [
31979
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Stack, { alignItems: "center", direction: "row", sx: { "&:hover .copy-btn": { opacity: 1 } }, children: [
31980
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Typography, { sx: { fontWeight: 600 }, variant: "caption", children: "Stack Trace" }),
31981
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(CopyButton, { value: functionError.stackTrace })
31982
+ ] }),
31983
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(
31984
+ import_material21.Box,
31985
+ {
31986
+ component: "pre",
31987
+ "data-testid": EVENT_DETAILS_STACK_TRACE_TEST_ID,
31988
+ sx: { backgroundColor: "background.default", borderRadius: 1, fontFamily: "monospace", fontSize: 12, m: 0, overflow: "auto", p: 1 },
31989
+ children: functionError.stackTrace
31990
+ }
31991
+ )
31992
+ ] }),
31993
+ exceptionPayload !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { children: [
31994
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Typography, { sx: { fontWeight: 600, mb: 0.5 }, variant: "caption", children: "Exception" }),
31995
+ /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PayloadViewer, { testId: EVENT_DETAILS_EXCEPTION_PAYLOAD_TEST_ID, value: exceptionPayload })
31996
+ ] })
31997
+ ] }),
31998
+ (isResponseSuppressed || responsePayload !== void 0) && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_material21.Box, { children: [
31999
+ rawDataSwitch,
32000
+ isResponseSuppressed ? /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Alert, { severity: "warning", children: "Response payload is available \u2014 upgrade your license to view" }) : /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PayloadViewer, { testId: EVENT_DETAILS_RESPONSE_PAYLOAD_TEST_ID, value: responsePayload })
32001
+ ] })
31980
32002
  ] }),
31981
32003
  activeTab === "permissions" && /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_jsx_runtime145.Fragment, { children: [
31982
32004
  selectedEvent.iam_errors_suppressed && /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_material21.Alert, { "data-testid": EVENT_DETAILS_IAM_ERRORS_SUPPRESSED_TEST_ID, severity: "warning", sx: { mb: 1 }, children: "IAM errors are suppressed \u2014 upgrade your license to view" }),
@@ -32525,6 +32547,36 @@ var TraceGraph = ({
32525
32547
  ] });
32526
32548
  };
32527
32549
 
32550
+ // src/hooks/use-content-width.ts
32551
+ var React124 = __toESM(require("react"), 1);
32552
+ var contentWidth = (element) => {
32553
+ const style = getComputedStyle(element);
32554
+ const edges = ["borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight"];
32555
+ return edges.reduce((width, edge) => width - (Number.parseFloat(style[edge]) || 0), element.getBoundingClientRect().width);
32556
+ };
32557
+ var useContentWidth = (elementRef, parent = false) => {
32558
+ const [width, setWidth] = React124.useState(0);
32559
+ React124.useLayoutEffect(() => {
32560
+ const element = parent ? elementRef.current?.parentElement : elementRef.current;
32561
+ if (!element) return;
32562
+ setWidth(contentWidth(element));
32563
+ let frame2 = 0;
32564
+ const observer = new ResizeObserver(([entry]) => {
32565
+ if (!entry) return;
32566
+ cancelAnimationFrame(frame2);
32567
+ frame2 = requestAnimationFrame(() => {
32568
+ setWidth(entry.contentRect.width);
32569
+ });
32570
+ });
32571
+ observer.observe(element);
32572
+ return () => {
32573
+ cancelAnimationFrame(frame2);
32574
+ observer.disconnect();
32575
+ };
32576
+ }, [elementRef, parent]);
32577
+ return width;
32578
+ };
32579
+
32528
32580
  // src/hooks/use-local-storage.tsx
32529
32581
  var import_react62 = require("react");
32530
32582
  function useLocalStorage(key, initialValue) {
@@ -32570,11 +32622,118 @@ function useLocalStorage(key, initialValue) {
32570
32622
  return [storedValue, setValue];
32571
32623
  }
32572
32624
 
32625
+ // src/components/trace-panel/sequence-diagram.tsx
32626
+ var import_react63 = require("@emotion/react");
32627
+ var import_icons_material15 = require("@mui/icons-material");
32628
+ var import_material27 = require("@mui/material");
32629
+ var import_styles5 = require("@mui/material/styles");
32630
+ var React126 = __toESM(require("react"), 1);
32631
+
32632
+ // src/components/trace-panel/sequence-layout.ts
32633
+ var CALLER_KEY = "";
32634
+ var resourceOf = (span) => {
32635
+ const resource = shortResourceName(span.resource_name, span.arn);
32636
+ return resource === "*" ? "" : resource;
32637
+ };
32638
+ var participantOf = (span, mode, callers) => {
32639
+ const resource = mode === "resource" || mode === "caller" && callers.has(`${span.service_name}/${resourceOf(span)}`) ? resourceOf(span) : "";
32640
+ return { key: `${span.service_name}/${resource}`, label: resource, resource, service: span.service_name };
32641
+ };
32642
+ var countDescendants = (node) => node.children.reduce((sum2, child) => sum2 + 1 + countDescendants(child), 0);
32643
+ var layoutSequence = (spans, mode, folded) => {
32644
+ const tree = buildTraceTree(spans);
32645
+ const visible = [];
32646
+ const visit = (nodes2, parent) => {
32647
+ for (const node of nodes2) {
32648
+ visible.push({ node, parent });
32649
+ if (!folded.has(node.span.span_id)) visit(node.children, node.span);
32650
+ }
32651
+ };
32652
+ visit(tree.roots);
32653
+ visible.sort((left, right) => compareNano(left.node.span.start_time_unix_nano, right.node.span.start_time_unix_nano));
32654
+ const callers = new Set(spans.filter((span) => tree.parentOf.has(span.span_id)).flatMap((span) => {
32655
+ const parent = spans.find((candidate) => candidate.span_id === tree.parentOf.get(span.span_id));
32656
+ return parent ? [`${parent.service_name}/${resourceOf(parent)}`] : [];
32657
+ }));
32658
+ const participants = [{ key: CALLER_KEY, label: "", resource: "", service: "" }];
32659
+ const indexOf = /* @__PURE__ */ new Map([[CALLER_KEY, 0]]);
32660
+ const place = (participant) => {
32661
+ const known = indexOf.get(participant.key);
32662
+ if (known !== void 0) return known;
32663
+ participants.push(participant);
32664
+ indexOf.set(participant.key, participants.length - 1);
32665
+ return participants.length - 1;
32666
+ };
32667
+ const rowOf = /* @__PURE__ */ new Map();
32668
+ const parentRows = [];
32669
+ const messages = [];
32670
+ for (const [row, { node, parent }] of visible.entries()) {
32671
+ const { span } = node;
32672
+ const issues = getSpanIssues(span);
32673
+ const from = parent ? place(participantOf(parent, mode, callers)) : 0;
32674
+ const hasChildren = node.children.length > 0;
32675
+ parentRows.push(parent ? rowOf.get(parent.span_id) : void 0);
32676
+ messages.push({
32677
+ async: parent !== void 0 && span.parent_span_id !== parent.span_id,
32678
+ depth: 0,
32679
+ descendantCount: countDescendants(node),
32680
+ endRow: row,
32681
+ error: issues.error,
32682
+ folded: hasChildren && folded.has(span.span_id),
32683
+ from,
32684
+ fromDepth: 0,
32685
+ resource: resourceOf(span),
32686
+ returnLevel: 0,
32687
+ span,
32688
+ to: place(participantOf(span, mode, callers)),
32689
+ warning: issues.warning
32690
+ });
32691
+ rowOf.set(span.span_id, row);
32692
+ }
32693
+ for (let row = messages.length - 1; row >= 0; row--) {
32694
+ const message = messages[row];
32695
+ const parent = messages[parentRows[row] ?? -1];
32696
+ if (message && parent && !message.async) parent.endRow = Math.max(parent.endRow, message.endRow);
32697
+ }
32698
+ const endings = messages.map(() => 0);
32699
+ for (const message of messages.toReversed()) {
32700
+ message.returnLevel = endings[message.endRow] ?? 0;
32701
+ endings[message.endRow] = message.returnLevel + 1;
32702
+ }
32703
+ for (const [row, message] of messages.entries()) {
32704
+ message.depth = messages.slice(0, row).filter((earlier) => earlier.to === message.to && earlier.endRow >= row).length;
32705
+ message.fromDepth = messages[parentRows[row] ?? -1]?.depth ?? 0;
32706
+ }
32707
+ const prefix = sharedPrefix(participants.map((participant) => participant.resource));
32708
+ const strip2 = (name) => name.startsWith(prefix) ? name.slice(prefix.length) : name;
32709
+ return {
32710
+ endings,
32711
+ messages: messages.map((message) => ({ ...message, resource: strip2(message.resource) })),
32712
+ participants: participants.map((participant) => ({ ...participant, label: strip2(participant.resource) }))
32713
+ };
32714
+ };
32715
+ var sharedPrefix = (names2) => {
32716
+ const counts = /* @__PURE__ */ new Map();
32717
+ for (const name of new Set(names2)) {
32718
+ for (let index = 0; index < name.length - 1; index++) {
32719
+ if ("-_/.".includes(name.charAt(index))) {
32720
+ const prefix = name.slice(0, index + 1);
32721
+ counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
32722
+ }
32723
+ }
32724
+ }
32725
+ let best = "";
32726
+ for (const [prefix, count2] of counts) {
32727
+ if (count2 >= 2 && count2 * prefix.length > (counts.get(best) ?? 0) * best.length) best = prefix;
32728
+ }
32729
+ return best;
32730
+ };
32731
+
32573
32732
  // src/components/trace-panel/waterfall.tsx
32574
32733
  var import_icons_material14 = require("@mui/icons-material");
32575
32734
  var import_material26 = require("@mui/material");
32576
32735
  var import_styles4 = require("@mui/material/styles");
32577
- var React124 = __toESM(require("react"), 1);
32736
+ var React125 = __toESM(require("react"), 1);
32578
32737
 
32579
32738
  // src/components/trace-panel/axis-ticks.ts
32580
32739
  var getAxisTicks = (durationMs, maxIntervals) => {
@@ -32666,25 +32825,10 @@ var Line = ({ height, left, top = 0, width = 1 }) => /* @__PURE__ */ (0, import_
32666
32825
  );
32667
32826
  var AXIS_HEIGHT = 22;
32668
32827
  var TRACK_INSET = 1.5;
32669
- var useWidth = (elementRef) => {
32670
- const [width, setWidth] = React124.useState(0);
32671
- React124.useLayoutEffect(() => {
32672
- const element = elementRef.current;
32673
- if (!element) return;
32674
- const observer = new ResizeObserver(([entry]) => {
32675
- if (entry) setWidth(entry.contentRect.width);
32676
- });
32677
- observer.observe(element);
32678
- return () => {
32679
- observer.disconnect();
32680
- };
32681
- }, [elementRef]);
32682
- return width;
32683
- };
32684
32828
  var LABEL_TRANSFORMS = { center: "translateX(-50%)", end: "translateX(-100%)", start: void 0 };
32685
32829
  var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
32686
- const trackRef = React124.useRef(null);
32687
- const width = useWidth(trackRef);
32830
+ const trackRef = React125.useRef(null);
32831
+ const width = useContentWidth(trackRef);
32688
32832
  const { labels: labels2, marks } = layoutAxis(durationMs, width);
32689
32833
  return /* @__PURE__ */ (0, import_jsx_runtime150.jsxs)(
32690
32834
  import_material26.Box,
@@ -32752,15 +32896,15 @@ var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
32752
32896
  );
32753
32897
  };
32754
32898
  var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32755
- const [collapsed, setCollapsed] = React124.useState(() => /* @__PURE__ */ new Set());
32756
- const containerRef = React124.useRef(null);
32757
- const tree = React124.useMemo(() => buildTraceTree(spans), [spans]);
32758
- const bounds = React124.useMemo(() => getTraceBounds(spans), [spans]);
32899
+ const [collapsed, setCollapsed] = React125.useState(() => /* @__PURE__ */ new Set());
32900
+ const containerRef = React125.useRef(null);
32901
+ const tree = React125.useMemo(() => buildTraceTree(spans), [spans]);
32902
+ const bounds = React125.useMemo(() => getTraceBounds(spans), [spans]);
32759
32903
  const { waterfallLayout } = useDevSettings();
32760
- const [toggledFlat, setToggledFlat] = React124.useState(false);
32904
+ const [toggledFlat, setToggledFlat] = React125.useState(false);
32761
32905
  const flat = waterfallLayout === "list" || waterfallLayout === "toggle" && toggledFlat;
32762
- const rows = React124.useMemo(() => flat ? flattenAll(tree.roots) : flatten(tree.roots, collapsed), [tree, collapsed, flat]);
32763
- const [revealed, setRevealed] = React124.useState();
32906
+ const rows = React125.useMemo(() => flat ? flattenAll(tree.roots) : flatten(tree.roots, collapsed), [tree, collapsed, flat]);
32907
+ const [revealed, setRevealed] = React125.useState();
32764
32908
  if (selectedSpanId !== revealed) {
32765
32909
  setRevealed(selectedSpanId);
32766
32910
  const ancestors = /* @__PURE__ */ new Set();
@@ -32769,7 +32913,7 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32769
32913
  setCollapsed((current) => new Set([...current].filter((id2) => !ancestors.has(id2))));
32770
32914
  }
32771
32915
  }
32772
- React124.useEffect(() => {
32916
+ React125.useEffect(() => {
32773
32917
  if (selectedSpanId === void 0) return;
32774
32918
  containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest" });
32775
32919
  }, [selectedSpanId]);
@@ -32944,8 +33088,661 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32944
33088
  ] });
32945
33089
  };
32946
33090
 
32947
- // src/components/trace-panel/trace-sidebar.tsx
33091
+ // src/components/trace-panel/sequence-diagram.tsx
32948
33092
  var import_jsx_runtime151 = require("react/jsx-runtime");
33093
+ var COLUMN_WIDTH = 136;
33094
+ var HEADER_HEIGHT = 52;
33095
+ var LABEL_TOP = 1;
33096
+ var LABEL_HEIGHT = 18;
33097
+ var ARROW_Y = 24;
33098
+ var ARROW_HEAD = 5;
33099
+ var SELF_LOOP = 22;
33100
+ var BLOCK_WIDTH = 8;
33101
+ var BLOCK_OFFSET = BLOCK_WIDTH + 6;
33102
+ var BLOCK_OVERLAP_OFFSET = BLOCK_WIDTH * 3 / 4;
33103
+ var HATCH_MARGIN = 4;
33104
+ var BLOCK_OVERHANG = 4;
33105
+ var BLOCK_MIN_HEIGHT = 24;
33106
+ var BLOCK_TAIL = BLOCK_MIN_HEIGHT - BLOCK_OVERHANG;
33107
+ var BLOCK_RADIUS = 2;
33108
+ var RETURN_GAP = 10;
33109
+ var ROW_GAP = 8;
33110
+ var rowHeight = (endings) => ARROW_Y + (endings === 0 ? 0 : BLOCK_TAIL + (endings - 1) * RETURN_GAP) + ROW_GAP;
33111
+ var SLIDE_MS = 200;
33112
+ var SLIDE = `${String(SLIDE_MS)}ms cubic-bezier(0.4, 0, 0.2, 1)`;
33113
+ var SLIDE_TRANSITION = `transform ${SLIDE}, height ${SLIDE}`;
33114
+ var RETURN_HIT_HEIGHT = 9;
33115
+ var ARROW_HIT_HEIGHT = 15;
33116
+ var BLOCK_HIT_MARGIN = 3;
33117
+ var enter = import_react63.keyframes`from { opacity: 0 }`;
33118
+ var ENTER_ANIMATION = `${enter} ${SLIDE}`;
33119
+ var slideTo = (y, entering = false) => ({
33120
+ animation: entering ? ENTER_ANIMATION : void 0,
33121
+ transform: `translateY(${String(y)}px)`,
33122
+ transition: SLIDE_TRANSITION
33123
+ });
33124
+ var blockRect = (height) => ({ height, style: { height, transition: SLIDE_TRANSITION }, y: 0 });
33125
+ var hatchId = (color2) => `sequence-hatch-${color2.replace("#", "")}`;
33126
+ var lifelineX = (index) => index * COLUMN_WIDTH + COLUMN_WIDTH / 2;
33127
+ var blockX = (index, depth, offset) => lifelineX(index) + depth * offset;
33128
+ var Arrow = ({ blockOffset, blockWidth, color: color2, entering, message, top }) => {
33129
+ const y = ARROW_Y;
33130
+ const dash = message.async ? "4 3" : void 0;
33131
+ const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
33132
+ const fromX = blockX(message.from, message.fromDepth, blockOffset);
33133
+ const toX = blockX(message.to, message.depth, blockOffset);
33134
+ if (message.from === message.to) {
33135
+ const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
33136
+ const endX2 = toX + blockWidth / 2;
33137
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { stroke: color2, style: slideTo(top, entering), children: [
33138
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("path", { d: `M${String(fromX + fromHalf)} ${String(y - 6)}H${String(loopX)}v8H${String(endX2 + ARROW_HEAD)}`, fill: "none", strokeDasharray: dash }),
33139
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("path", { d: `M${String(endX2)} ${String(y + 2)}l${String(ARROW_HEAD)} -3v6z`, fill: color2 })
33140
+ ] });
33141
+ }
33142
+ const direction = toX > fromX ? 1 : -1;
33143
+ const startX = fromX + direction * fromHalf;
33144
+ const endX = toX - direction * blockWidth / 2;
33145
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { stroke: color2, style: slideTo(top, entering), children: [
33146
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("line", { strokeDasharray: dash, x1: startX, x2: endX - direction * ARROW_HEAD, y1: y, y2: y }),
33147
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("path", { d: `M${String(endX)} ${String(y)}l${String(-direction * ARROW_HEAD)} -3v6z`, fill: color2 })
33148
+ ] });
33149
+ };
33150
+ var arrowHitBox = (message, blockWidth, blockOffset, height) => {
33151
+ const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
33152
+ const fromX = blockX(message.from, message.fromDepth, blockOffset);
33153
+ const toX = blockX(message.to, message.depth, blockOffset);
33154
+ if (message.from === message.to) {
33155
+ const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
33156
+ const left = Math.min(fromX + fromHalf, toX + blockWidth / 2);
33157
+ return { height, left, top: ARROW_Y - 2 - height / 2, width: loopX - left };
33158
+ }
33159
+ const direction = toX > fromX ? 1 : -1;
33160
+ const startX = fromX + direction * fromHalf;
33161
+ const endX = toX - direction * blockWidth / 2;
33162
+ return { height, left: Math.min(startX, endX), top: ARROW_Y - height / 2, width: Math.abs(endX - startX) };
33163
+ };
33164
+ var hasReturn = (message) => !message.async && message.from !== message.to;
33165
+ var ReturnArrow = ({ blockOffset, blockWidth, color: color2, entering, message, y: lineY }) => {
33166
+ const y = 0;
33167
+ const fromX = blockX(message.to, message.depth, blockOffset);
33168
+ const toX = blockX(message.from, message.fromDepth, blockOffset);
33169
+ const direction = toX > fromX ? 1 : -1;
33170
+ const startX = fromX + direction * blockWidth / 2;
33171
+ const endX = toX - direction * (message.from === 0 ? 0 : blockWidth / 2);
33172
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { stroke: color2, style: slideTo(lineY, entering), children: [
33173
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("line", { strokeDasharray: "3 3", x1: startX, x2: endX, y1: y, y2: y }),
33174
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("path", { d: `M${String(endX - direction * ARROW_HEAD)} ${String(y - 3)}L${String(endX)} ${String(y)}L${String(endX - direction * ARROW_HEAD)} ${String(y + 3)}`, fill: "none" })
33175
+ ] });
33176
+ };
33177
+ var MIN_ZOOM = 0.25;
33178
+ var MAX_ZOOM = 1;
33179
+ var ZOOM_STEP = 1.25;
33180
+ var WHEEL_ZOOM_SPEED = 0.01;
33181
+ var MINIMAP_WIDTH = 168;
33182
+ var MINIMAP_MAX_HEIGHT = 160;
33183
+ var MINIMAP_MAX_VIEW_SHARE = 1 / 3;
33184
+ var WIDGET_MARGIN = 16;
33185
+ var BOTTOM_ROOM = 44 + WIDGET_MARGIN + 16;
33186
+ var MINIMAP_OPEN_STORAGE_KEY = "appinspector-sequence-minimap-open";
33187
+ var bodyIds = 0;
33188
+ var useBodyId = () => {
33189
+ const [id2] = React126.useState(() => `sequence-body-${String(++bodyIds)}`);
33190
+ return id2;
33191
+ };
33192
+ var clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
33193
+ var useZoom = (scrollRef, areaRef, widgetRef, enabled) => {
33194
+ const [zoom, setZoom] = React126.useState(1);
33195
+ const zoomRef = React126.useRef(zoom);
33196
+ const anchorRef = React126.useRef();
33197
+ const zoomTo = React126.useCallback((next, x, y) => {
33198
+ const element = scrollRef.current;
33199
+ const clamped = clampZoom(next);
33200
+ if (!element || clamped === zoomRef.current) return;
33201
+ anchorRef.current = { ratio: clamped / zoomRef.current, x: x ?? element.clientWidth / 2, y: y ?? element.clientHeight / 2 };
33202
+ zoomRef.current = clamped;
33203
+ setZoom(clamped);
33204
+ }, [scrollRef]);
33205
+ React126.useLayoutEffect(() => {
33206
+ const element = scrollRef.current;
33207
+ const anchor = anchorRef.current;
33208
+ if (!element || !anchor) return;
33209
+ element.scrollLeft = (element.scrollLeft + anchor.x) * anchor.ratio - anchor.x;
33210
+ element.scrollTop = (element.scrollTop + anchor.y) * anchor.ratio - anchor.y;
33211
+ anchorRef.current = void 0;
33212
+ }, [scrollRef, zoom]);
33213
+ React126.useEffect(() => {
33214
+ const element = scrollRef.current;
33215
+ const area = areaRef.current;
33216
+ if (!element || !area || !enabled) return;
33217
+ const pointer = (event) => {
33218
+ if (event.target instanceof Node && widgetRef.current?.contains(event.target)) return [];
33219
+ const bounds = element.getBoundingClientRect();
33220
+ return [event.clientX - bounds.left, event.clientY - bounds.top];
33221
+ };
33222
+ const handleWheel = (event) => {
33223
+ if (!event.ctrlKey && !event.metaKey) return;
33224
+ event.preventDefault();
33225
+ zoomTo(zoomRef.current * Math.exp(-event.deltaY * WHEEL_ZOOM_SPEED), ...pointer(event));
33226
+ };
33227
+ let gestureStart = 1;
33228
+ const handleGestureStart = (event) => {
33229
+ event.preventDefault();
33230
+ gestureStart = zoomRef.current;
33231
+ };
33232
+ const handleGestureChange = (event) => {
33233
+ event.preventDefault();
33234
+ const { scale: scale2 } = event;
33235
+ zoomTo(gestureStart * scale2, ...pointer(event));
33236
+ };
33237
+ area.addEventListener("wheel", handleWheel, { passive: false });
33238
+ area.addEventListener("gesturestart", handleGestureStart);
33239
+ area.addEventListener("gesturechange", handleGestureChange);
33240
+ return () => {
33241
+ area.removeEventListener("wheel", handleWheel);
33242
+ area.removeEventListener("gesturestart", handleGestureStart);
33243
+ area.removeEventListener("gesturechange", handleGestureChange);
33244
+ };
33245
+ }, [scrollRef, areaRef, widgetRef, enabled, zoomTo]);
33246
+ return { zoom, zoomTo };
33247
+ };
33248
+ var lifelineName = (participant) => participant.service === "" ? "Caller" : [getServiceDisplayName(participant.service), participant.label].filter(Boolean).join(" ");
33249
+ var hoverDirection = (hover) => {
33250
+ if (hover.kind === "segment") return `Active on ${hover.to}`;
33251
+ const kind = hover.kind === "response" ? "Response" : hover.message.async ? "Async request" : "Request";
33252
+ return `${kind} \xB7 ${hover.from} \u2192 ${hover.to}`;
33253
+ };
33254
+ var ArrowHoverCard = ({ hover }) => {
33255
+ const { span } = hover.message;
33256
+ const duration = span.end_time_unix_nano === null ? void 0 : formatDuration(Number(BigInt(span.end_time_unix_nano) - BigInt(span.start_time_unix_nano)) / 1e6);
33257
+ const issue = span.errors?.find((item) => item.level === "error")?.message ?? (hover.message.error ? span.status_message ?? void 0 : void 0) ?? span.errors?.find((item) => item.level === "warning")?.message;
33258
+ const anchor = { getBoundingClientRect: () => new DOMRect(hover.x, hover.y, 0, 0) };
33259
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Popper, { anchorEl: anchor, "data-testid": SEQUENCE_DIAGRAM_HOVER_CARD_TEST_ID, modifiers: [{ name: "offset", options: { offset: [12, 16] } }], open: true, placement: "bottom-start", sx: { pointerEvents: "none", zIndex: "tooltip" }, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Paper, { elevation: 6, sx: { display: "flex", flexDirection: "column", gap: 0.75, maxWidth: 360, px: 1.5, py: 1 }, children: [
33260
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationIdentity, { arn: span.arn, density: "stacked", iconSize: 24, operation: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationName, { span, tooltip: false }), resourceName: span.resource_name, service: span.service_name }),
33261
+ getOperationLabel(span) !== span.operation_name && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", sx: { fontSize: 12 }, children: `Action: ${span.operation_name}` }),
33262
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", sx: { fontSize: 12 }, children: [hoverDirection(hover), duration].filter(Boolean).join(" \xB7 ") }),
33263
+ issue !== void 0 && issue !== "" && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: hover.message.error ? "error" : "warning.main", sx: { fontSize: 12 }, children: issue })
33264
+ ] }) });
33265
+ };
33266
+ var SequenceDiagram = ({ onSelectSpan, participantMode = "caller", selectedSpanId, spans }) => {
33267
+ const theme = (0, import_styles5.useTheme)();
33268
+ const [folded, setFolded] = React126.useState(() => /* @__PURE__ */ new Set());
33269
+ const containerRef = React126.useRef(null);
33270
+ const scrollRef = React126.useRef(null);
33271
+ const areaRef = React126.useRef(null);
33272
+ const widgetRef = React126.useRef(null);
33273
+ const { zoom, zoomTo } = useZoom(scrollRef, areaRef, widgetRef, spans.length > 0);
33274
+ const bodyId = useBodyId();
33275
+ const [minimapOpen, setMinimapOpen] = useLocalStorage(MINIMAP_OPEN_STORAGE_KEY, true);
33276
+ const [scrollView, setScrollView] = React126.useState({ height: 0, left: 0, scrollbarHeight: 0, scrollbarWidth: 0, top: 0, width: 0 });
33277
+ const measureView = React126.useCallback(() => {
33278
+ const element = scrollRef.current;
33279
+ if (element) setScrollView({
33280
+ height: element.clientHeight,
33281
+ left: element.scrollLeft,
33282
+ // Classic scrollbars take room; overlay ones (macOS by default) measure 0.
33283
+ scrollbarHeight: element.offsetHeight - element.clientHeight,
33284
+ scrollbarWidth: element.offsetWidth - element.clientWidth,
33285
+ top: element.scrollTop,
33286
+ width: element.clientWidth
33287
+ });
33288
+ }, []);
33289
+ React126.useLayoutEffect(() => {
33290
+ const element = scrollRef.current;
33291
+ if (!element) return;
33292
+ measureView();
33293
+ let frame2 = 0;
33294
+ const observer = new ResizeObserver(() => {
33295
+ cancelAnimationFrame(frame2);
33296
+ frame2 = requestAnimationFrame(measureView);
33297
+ });
33298
+ observer.observe(element);
33299
+ return () => {
33300
+ cancelAnimationFrame(frame2);
33301
+ observer.disconnect();
33302
+ };
33303
+ }, [measureView, zoom, spans.length]);
33304
+ const { sequenceBlocks, sequenceClickTargets, sequenceHoverCard } = useDevSettings();
33305
+ const arrowTargets = sequenceClickTargets === "arrows-and-segments";
33306
+ const returnHitHeight = arrowTargets ? ARROW_HIT_HEIGHT : RETURN_HIT_HEIGHT;
33307
+ const hoverCard = sequenceHoverCard === "on";
33308
+ const [hover, setHover] = React126.useState();
33309
+ const blocks = sequenceBlocks === "detached" || sequenceBlocks === "overlapped";
33310
+ const hatched = sequenceBlocks === "detached";
33311
+ const blockOffset = sequenceBlocks === "overlapped" ? BLOCK_OVERLAP_OFFSET : BLOCK_OFFSET;
33312
+ const merged = sequenceBlocks === "merged";
33313
+ const blockWidth = sequenceBlocks === "off" ? 0 : BLOCK_WIDTH;
33314
+ const segmentTargets = (arrowTargets || hoverCard) && blockWidth > 0;
33315
+ const { endings, messages, participants } = React126.useMemo(() => {
33316
+ const layout = layoutSequence(spans, participantMode, folded);
33317
+ return blocks ? layout : { ...layout, messages: layout.messages.map((message) => ({ ...message, depth: 0, fromDepth: 0 })) };
33318
+ }, [spans, participantMode, folded, blocks]);
33319
+ const pickedHereRef = React126.useRef();
33320
+ const select = React126.useCallback((spanId, view2) => {
33321
+ pickedHereRef.current = spanId;
33322
+ onSelectSpan(spanId, view2);
33323
+ }, [onSelectSpan]);
33324
+ React126.useEffect(() => {
33325
+ if (selectedSpanId === void 0 || selectedSpanId === pickedHereRef.current) return;
33326
+ containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest", inline: "nearest" });
33327
+ }, [selectedSpanId]);
33328
+ const [folding, setFolding] = React126.useState(false);
33329
+ const foldingTimerRef = React126.useRef();
33330
+ React126.useEffect(() => () => {
33331
+ clearTimeout(foldingTimerRef.current);
33332
+ }, []);
33333
+ const setFold = React126.useCallback((spanId, fold) => {
33334
+ setFolding(true);
33335
+ clearTimeout(foldingTimerRef.current);
33336
+ foldingTimerRef.current = setTimeout(() => {
33337
+ setFolding(false);
33338
+ }, SLIDE_MS + 100);
33339
+ setFolded((previous) => {
33340
+ const next = new Set(previous);
33341
+ if (fold) next.add(spanId);
33342
+ else next.delete(spanId);
33343
+ return next;
33344
+ });
33345
+ }, []);
33346
+ const handleKeyDown = React126.useCallback((event, message) => {
33347
+ if (event.target !== event.currentTarget) return;
33348
+ const spanId = message.span.span_id;
33349
+ if (event.key === "Enter" || event.key === " ") {
33350
+ event.preventDefault();
33351
+ select(spanId, "details");
33352
+ } else if (event.key === "ArrowRight" && message.folded) setFold(spanId, false);
33353
+ else if (event.key === "ArrowLeft" && message.descendantCount > 0 && !message.folded) setFold(spanId, true);
33354
+ }, [select, setFold]);
33355
+ const [shown, setShown] = React126.useState(() => ({ messages, revealed: /* @__PURE__ */ new Set() }));
33356
+ if (shown.messages !== messages) {
33357
+ const previous = new Set(shown.messages.map((message) => message.span.span_id));
33358
+ const continued = messages.some((message) => previous.has(message.span.span_id));
33359
+ setShown({ messages, revealed: new Set(continued ? messages.filter((message) => !previous.has(message.span.span_id)).map((message) => message.span.span_id) : []) });
33360
+ }
33361
+ const isEntering = React126.useCallback((spanId) => shown.revealed.has(spanId), [shown]);
33362
+ const geometry = React126.useMemo(() => {
33363
+ const participant2 = (index) => participants[index] ?? { key: "", label: "", resource: "", service: "" };
33364
+ const width2 = participants.length * COLUMN_WIDTH;
33365
+ const rowHeights2 = endings.map((count2) => rowHeight(count2));
33366
+ const rowTops = rowHeights2.map((_height, row) => rowHeights2.slice(0, row).reduce((sum2, height) => sum2 + height, 0));
33367
+ const bodyHeight2 = rowHeights2.reduce((sum2, height) => sum2 + height, 0);
33368
+ const top2 = (row) => rowTops[row] ?? 0;
33369
+ const activeDepth2 = (lifeline, row) => Math.max(0, ...messages.slice(0, row + 1).filter((message) => message.to === lifeline && message.endRow >= row).map((message) => message.depth));
33370
+ const endY2 = (message) => top2(message.endRow) + ARROW_Y + BLOCK_TAIL + message.returnLevel * RETURN_GAP;
33371
+ const rowOf = new Map(messages.map((message, index) => [message.span.span_id, index]));
33372
+ const blockY2 = (message) => top2(rowOf.get(message.span.span_id) ?? 0) + ARROW_Y - BLOCK_OVERHANG;
33373
+ const mergedBlocks2 = [];
33374
+ if (merged) {
33375
+ for (const message of messages.toSorted((left, right) => left.to - right.to || blockY2(left) - blockY2(right))) {
33376
+ const last = mergedBlocks2.at(-1);
33377
+ if (last?.members[0]?.to === message.to && blockY2(message) <= last.bottom) {
33378
+ last.bottom = Math.max(last.bottom, endY2(message));
33379
+ last.members.push(message);
33380
+ } else mergedBlocks2.push({ bottom: endY2(message), members: [message], top: blockY2(message) });
33381
+ }
33382
+ }
33383
+ return { activeDepth: activeDepth2, blockY: blockY2, bodyHeight: bodyHeight2, endY: endY2, mergedBlocks: mergedBlocks2, participant: participant2, rowHeights: rowHeights2, top: top2, width: width2 };
33384
+ }, [endings, merged, messages, participants]);
33385
+ const { activeDepth, blockY, bodyHeight, endY, mergedBlocks, participant, rowHeights, top, width } = geometry;
33386
+ const hoveredMessage = hover && messages.find((message) => message.span.span_id === hover.message.span.span_id);
33387
+ const arrowHoverProps = React126.useCallback((message, kind) => {
33388
+ if (!hoverCard) return {};
33389
+ const [from, to] = kind === "response" ? [message.to, message.from] : [message.from, message.to];
33390
+ return {
33391
+ onMouseLeave: () => {
33392
+ setHover(void 0);
33393
+ },
33394
+ onMouseMove: (event) => {
33395
+ setHover({ from: lifelineName(participant(from)), kind, message, to: lifelineName(participant(to)), x: event.clientX, y: event.clientY });
33396
+ }
33397
+ };
33398
+ }, [hoverCard, participant]);
33399
+ const drawing = React126.useMemo(() => /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_jsx_runtime151.Fragment, { children: [
33400
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { sx: { "&:has(> :hover) > :not(:hover)": { opacity: 0.4 }, "& > *": { transition: "opacity 150ms" }, "backgroundColor": "background.paper", "borderBottom": 1, "borderColor": "divider", "display": "flex", "height": HEADER_HEIGHT, "position": "sticky", "top": 0, "zIndex": 3 }, children: participants.map((participant2) => (
33401
+ // A subtle box per lifeline, its identity as in every other view: icon, service, resource below.
33402
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33403
+ import_material27.Box,
33404
+ {
33405
+ "data-testid": SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID,
33406
+ sx: {
33407
+ // As in Flow: a hovered box grows to show its whole name, over its neighbours, without moving them.
33408
+ "&:hover": { "& > *": { width: "max-content" }, "zIndex": 1 },
33409
+ "alignItems": "center",
33410
+ "display": "flex",
33411
+ "flex": "none",
33412
+ "justifyContent": "flex-start",
33413
+ "position": "relative",
33414
+ "px": "4px",
33415
+ "width": COLUMN_WIDTH
33416
+ },
33417
+ title: [participant2.service, participant2.resource].filter(Boolean).join(" \xB7 ") || "Caller",
33418
+ children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33419
+ import_material27.Box,
33420
+ {
33421
+ sx: { alignItems: "center", background: `linear-gradient(${theme.palette.action.hover}, ${theme.palette.action.hover}), ${theme.palette.background.paper}`, border: 1, borderColor: "divider", borderRadius: 1, display: "flex", flex: "none", height: HEADER_HEIGHT - 12, justifyContent: participant2.service === "" ? "center" : "flex-start", minWidth: "100%", px: "6px", width: "100%" },
33422
+ children: participant2.service === "" ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", component: "span", sx: { fontSize: 12 }, children: "Caller" }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationIdentity, { density: "stacked", iconSize: 24, resourceName: participant2.label, service: participant2.service })
33423
+ }
33424
+ )
33425
+ },
33426
+ participant2.key
33427
+ )
33428
+ )) }),
33429
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { sx: { backgroundColor: "background.paper", height: bodyHeight, position: "relative" }, children: [
33430
+ messages.map((message, index) => {
33431
+ const { span } = message;
33432
+ const selected = span.span_id === selectedSpanId;
33433
+ const self2 = message.from === message.to;
33434
+ const lane = Math.min(message.from, message.to);
33435
+ const labelLeft = self2 ? blockX(message.to, Math.max(message.depth, message.fromDepth), blockOffset) + BLOCK_WIDTH / 2 + SELF_LOOP + 4 : blockX(lane, activeDepth(lane, index), blockOffset) + BLOCK_WIDTH / 2 + 4;
33436
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
33437
+ import_material27.Box,
33438
+ {
33439
+ "aria-selected": selected,
33440
+ "data-span-id": span.span_id,
33441
+ "data-testid": SEQUENCE_DIAGRAM_MESSAGE_TEST_ID,
33442
+ onClick: arrowTargets ? void 0 : () => {
33443
+ select(span.span_id, "details");
33444
+ },
33445
+ onKeyDown: (event) => {
33446
+ handleKeyDown(event, message);
33447
+ },
33448
+ role: "listitem",
33449
+ sx: {
33450
+ "&:focus-visible": { boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}` },
33451
+ "&:hover": arrowTargets ? void 0 : { "--row-tint": selected ? (0, import_styles5.alpha)(theme.palette.primary.main, 0.16) : (0, import_styles5.alpha)(theme.palette.text.primary, 0.04) },
33452
+ // Opaque, so a label repeating it hides the lifelines behind it.
33453
+ "--row-bg": `linear-gradient(var(--row-tint), var(--row-tint)), ${theme.palette.background.paper}`,
33454
+ "--row-tint": selected ? (0, import_styles5.alpha)(theme.palette.primary.main, 0.12) : "transparent",
33455
+ "animation": isEntering(span.span_id) ? ENTER_ANIMATION : void 0,
33456
+ // Only the tint: the drawing shows through the row, under its label.
33457
+ "background": "var(--row-tint)",
33458
+ "cursor": arrowTargets ? void 0 : "pointer",
33459
+ "height": rowHeights[index],
33460
+ "left": 0,
33461
+ "outline": 0,
33462
+ "position": "absolute",
33463
+ "right": 0,
33464
+ "scrollMarginTop": HEADER_HEIGHT,
33465
+ "top": 0,
33466
+ "transform": `translateY(${String(top(index))}px)`,
33467
+ // Only the transform: a height transition would re-lay out every row on every frame.
33468
+ "transition": `transform ${SLIDE}`,
33469
+ // The transform makes the row a stacking context: over the drawing, so its label covers the blocks and lines it crosses.
33470
+ "zIndex": 1
33471
+ },
33472
+ tabIndex: 0,
33473
+ children: [
33474
+ (arrowTargets || hoverCard) && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33475
+ import_material27.Box,
33476
+ {
33477
+ "data-testid": SEQUENCE_DIAGRAM_ARROW_TEST_ID,
33478
+ onClick: arrowTargets ? () => {
33479
+ select(span.span_id, "payload");
33480
+ } : void 0,
33481
+ ...arrowHoverProps(message, "request"),
33482
+ sx: { "&:hover": arrowTargets ? { backgroundColor: (0, import_styles5.alpha)(theme.palette.primary.main, selected ? 0.16 : 0.12) } : void 0, "borderRadius": "4px", "cursor": "pointer", "position": "absolute", ...arrowHitBox(message, blockWidth, blockOffset, ARROW_HIT_HEIGHT) }
33483
+ }
33484
+ ),
33485
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
33486
+ import_material27.Box,
33487
+ {
33488
+ onClick: arrowTargets ? () => {
33489
+ select(span.span_id, "details");
33490
+ } : void 0,
33491
+ ...arrowHoverProps(message, "request"),
33492
+ sx: {
33493
+ alignItems: "center",
33494
+ background: "var(--row-bg)",
33495
+ cursor: arrowTargets ? "pointer" : void 0,
33496
+ display: "flex",
33497
+ gap: "3px",
33498
+ height: LABEL_HEIGHT,
33499
+ left: labelLeft,
33500
+ maxWidth: width - labelLeft - 4,
33501
+ position: "absolute",
33502
+ px: "2px",
33503
+ top: LABEL_TOP,
33504
+ zIndex: 2
33505
+ },
33506
+ children: [
33507
+ message.descendantCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33508
+ import_material27.ButtonBase,
33509
+ {
33510
+ "aria-label": message.folded ? "Expand" : "Collapse",
33511
+ "data-testid": SEQUENCE_DIAGRAM_TOGGLE_TEST_ID,
33512
+ onClick: (event) => {
33513
+ event.stopPropagation();
33514
+ setFold(span.span_id, !message.folded);
33515
+ },
33516
+ sx: { "&:hover": { backgroundColor: (0, import_styles5.alpha)(theme.palette.text.primary, 0.12) }, "borderRadius": "3px", "color": "text.secondary", "flex": "none", "height": 14, "width": 14 },
33517
+ tabIndex: -1,
33518
+ children: message.folded ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowRight, { sx: { fontSize: 16 } }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowDown, { sx: { fontSize: 16 } })
33519
+ }
33520
+ ),
33521
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: message.error ? "error" : "text.primary", component: "span", noWrap: true, sx: { flex: "none", fontSize: "inherit", fontWeight: 600 }, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationName, { span, tooltip: !hoverCard }) }),
33522
+ participant(message.to).resource === "" && message.resource !== "" && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", component: "span", noWrap: true, sx: { ...RESOURCE_CODE_SX, fontSize: 11, minWidth: 0 }, title: hoverCard ? void 0 : message.resource, children: message.resource }),
33523
+ message.error && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.Cancel, { sx: { color: "error.main", flex: "none", fontSize: 13 } }),
33524
+ message.warning && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.GppMaybe, { sx: { color: "warning.main", flex: "none", fontSize: 13 } }),
33525
+ message.folded && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", component: "span", sx: { flex: "none", fontSize: 11 }, children: `+${String(message.descendantCount)}` })
33526
+ ]
33527
+ }
33528
+ )
33529
+ ]
33530
+ },
33531
+ span.span_id
33532
+ );
33533
+ }),
33534
+ messages.filter((message) => hasReturn(message)).map((message) => {
33535
+ const fromX = blockX(message.to, message.depth, blockOffset);
33536
+ const toX = blockX(message.from, message.fromDepth, blockOffset);
33537
+ const selected = message.span.span_id === selectedSpanId;
33538
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33539
+ import_material27.Box,
33540
+ {
33541
+ "aria-hidden": "true",
33542
+ "aria-selected": selected,
33543
+ "data-span-id": message.span.span_id,
33544
+ "data-testid": SEQUENCE_DIAGRAM_RETURN_TEST_ID,
33545
+ onClick: () => {
33546
+ select(message.span.span_id, "response");
33547
+ },
33548
+ ...arrowHoverProps(message, "response"),
33549
+ sx: {
33550
+ // The selected call's tint, as on its row, so its reply reads as part of it.
33551
+ "&:hover": { backgroundColor: (0, import_styles5.alpha)(theme.palette.primary.main, selected ? 0.16 : 0.12) },
33552
+ "backgroundColor": selected ? (0, import_styles5.alpha)(theme.palette.primary.main, 0.12) : void 0,
33553
+ "borderRadius": "4px",
33554
+ "cursor": "pointer",
33555
+ "height": returnHitHeight,
33556
+ "left": Math.min(fromX, toX),
33557
+ "position": "absolute",
33558
+ "top": 0,
33559
+ "width": Math.abs(toX - fromX),
33560
+ "zIndex": 2,
33561
+ ...slideTo(endY(message) - returnHitHeight / 2, isEntering(message.span.span_id))
33562
+ },
33563
+ title: hoverCard ? void 0 : `${getOperationLabel(message.span)}: response`
33564
+ },
33565
+ message.span.span_id
33566
+ );
33567
+ }),
33568
+ segmentTargets && messages.map((message) => {
33569
+ const selected = message.span.span_id === selectedSpanId;
33570
+ const boxY = blockY(message);
33571
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33572
+ import_material27.Box,
33573
+ {
33574
+ "aria-hidden": "true",
33575
+ "data-span-id": message.span.span_id,
33576
+ "data-testid": SEQUENCE_DIAGRAM_SEGMENT_TEST_ID,
33577
+ onClick: () => {
33578
+ select(message.span.span_id, "details");
33579
+ },
33580
+ ...arrowHoverProps(message, "segment"),
33581
+ sx: {
33582
+ "&:hover": { backgroundColor: (0, import_styles5.alpha)(theme.palette.primary.main, selected ? 0.16 : 0.12) },
33583
+ "borderRadius": "4px",
33584
+ "cursor": "pointer",
33585
+ "height": endY(message) - boxY,
33586
+ "left": blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 - BLOCK_HIT_MARGIN,
33587
+ "position": "absolute",
33588
+ "top": 0,
33589
+ "width": BLOCK_WIDTH + 2 * BLOCK_HIT_MARGIN,
33590
+ "zIndex": 2,
33591
+ // Its height follows a fold too: the slide's transition covers both.
33592
+ ...slideTo(boxY, isEntering(message.span.span_id))
33593
+ },
33594
+ title: hoverCard ? void 0 : getOperationLabel(message.span)
33595
+ },
33596
+ message.span.span_id
33597
+ );
33598
+ }),
33599
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("svg", { "aria-hidden": "true", height: bodyHeight, style: { left: 0, overflow: "visible", pointerEvents: "none", position: "absolute", top: 0, zIndex: 0 }, width, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { id: bodyId, children: [
33600
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("defs", { children: [...new Set(messages.map((message) => getServiceColor(message.span.service_name)))].map((color2) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("pattern", { height: 4, id: hatchId(color2), patternTransform: "rotate(45)", patternUnits: "userSpaceOnUse", width: 4, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(color2, 0.35), height: 4, width: 2 }) }, color2)) }),
33601
+ participants.map((participant2, index) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("line", { stroke: blockWidth > 0 ? theme.palette.text.disabled : theme.palette.divider, strokeDasharray: blockWidth > 0 ? "2 3" : void 0, x1: lifelineX(index), x2: lifelineX(index), y1: 0, y2: bodyHeight }, participant2.key)),
33602
+ blocks && messages.map((message, index) => {
33603
+ const serviceColor = getServiceColor(message.span.service_name);
33604
+ const selected = message.span.span_id === selectedSpanId;
33605
+ const boxY = top(index) + ARROW_Y - BLOCK_OVERHANG;
33606
+ const boxHeight = endY(message) - boxY;
33607
+ const box = { ...blockRect(boxHeight), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x: blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 };
33608
+ const hatch = (earlier) => ({
33609
+ ...blockRect(boxHeight + 2 * HATCH_MARGIN),
33610
+ // A pixel wider on each side, over the outer block's border: the hatch has none.
33611
+ width: BLOCK_WIDTH + 2,
33612
+ x: blockX(earlier.to, earlier.depth, blockOffset) - BLOCK_WIDTH / 2 - 1
33613
+ });
33614
+ const outer = hatched ? messages.slice(0, index).filter((earlier) => earlier.to === message.to && earlier.endRow >= index && earlier.depth < message.depth) : [];
33615
+ return (
33616
+ // Paper first, so the tint over it stays opaque to the lifeline.
33617
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { style: slideTo(boxY, isEntering(message.span.span_id)), children: [
33618
+ outer.map((earlier) => /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { transform: `translate(0 ${String(-HATCH_MARGIN)})`, children: [
33619
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: theme.palette.background.paper, ...hatch(earlier) }),
33620
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: `url(#${hatchId(getServiceColor(earlier.span.service_name))})`, rx: BLOCK_RADIUS, ...hatch(earlier) })
33621
+ ] }, earlier.span.span_id)),
33622
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { ...box, fill: theme.palette.background.paper }),
33623
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33624
+ "rect",
33625
+ {
33626
+ ...box,
33627
+ fill: (0, import_styles5.alpha)(serviceColor, selected ? 0.5 : 0.2),
33628
+ stroke: message.error ? theme.palette.error.main : serviceColor,
33629
+ strokeWidth: selected ? 1.5 : 1
33630
+ }
33631
+ )
33632
+ ] }, message.span.span_id)
33633
+ );
33634
+ }),
33635
+ merged && mergedBlocks.map(({ bottom, members, top: blockTop }) => {
33636
+ const [firstMember] = members;
33637
+ if (!firstMember) return;
33638
+ const serviceColor = getServiceColor(firstMember.span.service_name);
33639
+ const x = lifelineX(firstMember.to) - BLOCK_WIDTH / 2;
33640
+ const range = (member2) => ({ ...blockRect(endY(member2) - blockY(member2)), transform: `translate(0 ${String(blockY(member2) - blockTop)})`, width: BLOCK_WIDTH, x });
33641
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("g", { style: slideTo(blockTop), children: [
33642
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: theme.palette.background.paper, ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x }),
33643
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(serviceColor, 0.2), ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, stroke: serviceColor, width: BLOCK_WIDTH, x }),
33644
+ members.filter((member2) => member2.span.span_id === selectedSpanId).map((member2) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(serviceColor, 0.35), rx: BLOCK_RADIUS, ...range(member2) }, member2.span.span_id)),
33645
+ members.filter((member2) => member2.error).map((member2) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: "none", rx: BLOCK_RADIUS, stroke: theme.palette.error.main, ...range(member2) }, member2.span.span_id))
33646
+ ] }, firstMember.span.span_id);
33647
+ }),
33648
+ messages.filter((message) => hasReturn(message)).map((message) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(ReturnArrow, { blockOffset, blockWidth, color: message.error ? theme.palette.error.main : theme.palette.text.secondary, entering: isEntering(message.span.span_id), message, y: endY(message) }, message.span.span_id)),
33649
+ messages.map((message, index) => /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33650
+ Arrow,
33651
+ {
33652
+ blockOffset,
33653
+ blockWidth,
33654
+ color: message.error ? theme.palette.error.main : theme.palette.text.secondary,
33655
+ entering: isEntering(message.span.span_id),
33656
+ message,
33657
+ top: top(index)
33658
+ },
33659
+ message.span.span_id
33660
+ ))
33661
+ ] }) })
33662
+ ] })
33663
+ ] }), [activeDepth, arrowHoverProps, arrowTargets, blockOffset, blockWidth, blockY, blocks, bodyHeight, bodyId, endY, handleKeyDown, hatched, hoverCard, isEntering, merged, mergedBlocks, messages, participant, participants, returnHitHeight, rowHeights, segmentTargets, select, selectedSpanId, setFold, theme, top, width]);
33664
+ if (spans.length === 0) {
33665
+ return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", sx: { p: 2 }, variant: "body2", children: "No operations in this trace." });
33666
+ }
33667
+ const view = { height: scrollView.height / zoom - HEADER_HEIGHT, width: scrollView.width / zoom, x: scrollView.left / zoom, y: scrollView.top / zoom };
33668
+ const minimapScale = Math.min((MINIMAP_WIDTH - 16) / width, Math.min(MINIMAP_MAX_HEIGHT, scrollView.height * MINIMAP_MAX_VIEW_SHARE) / bodyHeight);
33669
+ const minimap = scrollView.width > 0 && (view.width < width || view.height < bodyHeight) ? { scale: minimapScale, view } : void 0;
33670
+ const panTo = (event) => {
33671
+ const element = scrollRef.current;
33672
+ if (!element) return;
33673
+ const bounds = event.currentTarget.querySelector("svg")?.getBoundingClientRect();
33674
+ if (!bounds) return;
33675
+ element.scrollLeft = ((event.clientX - bounds.left) / minimapScale - view.width / 2) * zoom;
33676
+ element.scrollTop = ((event.clientY - bounds.top) / minimapScale - view.height / 2) * zoom;
33677
+ };
33678
+ const fitWidth = () => {
33679
+ const viewWidth = scrollRef.current?.clientWidth;
33680
+ if (viewWidth) zoomTo(viewWidth / width, 0, 0);
33681
+ };
33682
+ return (
33683
+ // The diagram scrolls in a box of its own, so the zoom controls stay put over it.
33684
+ // Its own stacking context: the header's and the widget's z-indexes order them within the
33685
+ // diagram only, never over the sidebar's resize handles.
33686
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { ref: areaRef, sx: { flex: 1, height: "100%", isolation: "isolate", minHeight: 0, position: "relative" }, children: [
33687
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { onScroll: measureView, ref: scrollRef, sx: { inset: 0, overflow: "auto", position: "absolute" }, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { "aria-label": "Sequence diagram", "data-folding": folding || void 0, "data-testid": SEQUENCE_DIAGRAM_TEST_ID, ref: containerRef, role: "list", style: { zoom }, sx: { "&:not([data-folding]) *": { transition: "none !important" }, "@media (prefers-reduced-motion: reduce)": { "& *": { animation: "none !important", transition: "none !important" } }, "fontSize": 12, "minWidth": "100%", "position": "relative", width }, children: [
33688
+ drawing,
33689
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { sx: { height: BOTTOM_ROOM / zoom } })
33690
+ ] }) }),
33691
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Paper, { elevation: 2, ref: widgetRef, sx: { bottom: WIDGET_MARGIN + scrollView.scrollbarHeight, overflow: "hidden", p: 0, position: "absolute", right: WIDGET_MARGIN + scrollView.scrollbarWidth, width: MINIMAP_WIDTH, zIndex: 4 }, children: [
33692
+ minimap && // A thin bar with only a chevron: down folds the minimap away, up brings it back.
33693
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33694
+ import_material27.ButtonBase,
33695
+ {
33696
+ "aria-expanded": minimapOpen,
33697
+ "aria-label": minimapOpen ? "Hide the overview" : "Show the overview",
33698
+ "data-testid": SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID,
33699
+ onClick: () => {
33700
+ setMinimapOpen(!minimapOpen);
33701
+ },
33702
+ sx: { "&:hover": { color: "text.primary" }, "borderBottom": 1, "borderColor": "divider", "color": "text.secondary", "height": 14, "width": "100%" },
33703
+ children: minimapOpen ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowDown, { sx: { fontSize: 16 } }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.KeyboardArrowUp, { sx: { fontSize: 16 } })
33704
+ }
33705
+ ),
33706
+ minimap && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Collapse, { in: minimapOpen, unmountOnExit: true, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33707
+ import_material27.Box,
33708
+ {
33709
+ "aria-label": "Minimap",
33710
+ "data-testid": SEQUENCE_DIAGRAM_MINIMAP_TEST_ID,
33711
+ onPointerDown: (event) => {
33712
+ event.currentTarget.setPointerCapture(event.pointerId);
33713
+ panTo(event);
33714
+ },
33715
+ onPointerMove: (event) => {
33716
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) panTo(event);
33717
+ },
33718
+ role: "navigation",
33719
+ sx: { backgroundColor: "action.hover", borderBottom: 1, borderColor: "divider", cursor: "pointer", display: "flex", justifyContent: "center", lineHeight: 0, p: 1, touchAction: "none" },
33720
+ children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("svg", { height: bodyHeight * minimap.scale, style: { backgroundColor: theme.palette.background.paper }, viewBox: `0 0 ${String(width)} ${String(bodyHeight)}`, width: width * minimap.scale, children: [
33721
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("use", { href: `#${bodyId}` }),
33722
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("rect", { fill: (0, import_styles5.alpha)(theme.palette.primary.main, 0.08), height: minimap.view.height, stroke: theme.palette.primary.main, strokeWidth: 1.5 / minimap.scale, width: minimap.view.width, x: minimap.view.x, y: minimap.view.y })
33723
+ ] })
33724
+ }
33725
+ ) }),
33726
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { sx: { alignItems: "center", display: "flex", justifyContent: "space-between", px: "2px" }, children: [
33727
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Zoom out (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": "Zoom out", "data-testid": SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID, disabled: zoom <= MIN_ZOOM, onClick: () => {
33728
+ zoomTo(zoom / ZOOM_STEP);
33729
+ }, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.ZoomOut, { fontSize: "small" }) }) }),
33730
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Reset zoom", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.ButtonBase, { "data-testid": SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID, onClick: () => {
33731
+ zoomTo(1);
33732
+ }, sx: { borderRadius: 1, fontSize: 12, fontVariantNumeric: "tabular-nums", minWidth: 40, py: "2px" }, children: `${String(Math.round(zoom * 100))}%` }) }),
33733
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Zoom in (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": "Zoom in", "data-testid": SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID, disabled: zoom >= MAX_ZOOM, onClick: () => {
33734
+ zoomTo(zoom * ZOOM_STEP);
33735
+ }, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.ZoomIn, { fontSize: "small" }) }) }),
33736
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Tooltip, { title: "Fit the width", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": "Fit the width", "data-testid": SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID, onClick: fitWidth, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.FitScreen, { fontSize: "small" }) }) })
33737
+ ] })
33738
+ ] }),
33739
+ hoverCard && hoveredMessage && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(ArrowHoverCard, { hover: { ...hover, message: hoveredMessage } })
33740
+ ] })
33741
+ );
33742
+ };
33743
+
33744
+ // src/components/trace-panel/trace-sidebar.tsx
33745
+ var import_jsx_runtime152 = require("react/jsx-runtime");
32949
33746
  var DEFAULT_WIDTH_SHARE = 0.75;
32950
33747
  var MAX_WIDTH_SHARE = 0.8;
32951
33748
  var SNAP_WIDTH_SHARE = (MAX_WIDTH_SHARE + 1) / 2;
@@ -32966,22 +33763,16 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
32966
33763
  const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
32967
33764
  const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
32968
33765
  const [storedView, setView] = useLocalStorage(VIEW_STORAGE_KEY, "map");
32969
- const view = storedView === "waterfall" ? "waterfall" : "map";
32970
- const sidebarRef = React125.useRef(null);
32971
- const traceViewRef = React125.useRef(null);
33766
+ const view = storedView === "waterfall" || storedView === "sequence" ? storedView : "map";
33767
+ const sidebarRef = React127.useRef(null);
33768
+ const traceViewRef = React127.useRef(null);
32972
33769
  const width = maximized ? 1 : storedWidth;
32973
- const [parentWidth, setParentWidth] = React125.useState(0);
32974
- React125.useLayoutEffect(() => {
32975
- const parent = sidebarRef.current?.parentElement;
32976
- if (!parent) return;
32977
- const observer = new ResizeObserver(([entry]) => {
32978
- if (entry) setParentWidth(entry.contentRect.width);
32979
- });
32980
- observer.observe(parent);
32981
- return () => {
32982
- observer.disconnect();
32983
- };
32984
- }, []);
33770
+ const [requestedTab, setRequestedTab] = React127.useState();
33771
+ const selectFromSequence = React127.useCallback((spanId, view2) => {
33772
+ onSelectSpan(spanId);
33773
+ setRequestedTab({ view: view2 });
33774
+ }, [onSelectSpan]);
33775
+ const parentWidth = useContentWidth(sidebarRef, true);
32985
33776
  const minWidth = parentWidth === 0 ? 0 : Math.min(1, MIN_WIDTH / parentWidth);
32986
33777
  const resize = (share) => {
32987
33778
  const snap = share > SNAP_WIDTH_SHARE;
@@ -33020,7 +33811,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33020
33811
  event.preventDefault();
33021
33812
  setStoredSplit(clampSplit(storedSplit + delta));
33022
33813
  };
33023
- const { root: root2, selectedSpan, stats } = React125.useMemo(() => {
33814
+ const { root: root2, selectedSpan, stats } = React127.useMemo(() => {
33024
33815
  const tree = buildTraceTree(spans);
33025
33816
  const issues = spans.map((span) => getSpanIssues(span));
33026
33817
  return {
@@ -33034,7 +33825,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33034
33825
  };
33035
33826
  }, [spans, selectedSpanId]);
33036
33827
  const rootSpanId = root2?.span_id;
33037
- React125.useEffect(() => {
33828
+ React127.useEffect(() => {
33038
33829
  if (!onRequestRendered || rootSpanId === void 0) return;
33039
33830
  let frame2 = requestAnimationFrame(() => {
33040
33831
  frame2 = requestAnimationFrame(() => {
@@ -33045,8 +33836,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33045
33836
  cancelAnimationFrame(frame2);
33046
33837
  };
33047
33838
  }, [onRequestRendered, rootSpanId, view]);
33048
- return /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
33049
- import_material27.Box,
33839
+ return /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
33840
+ import_material28.Box,
33050
33841
  {
33051
33842
  "data-testid": TRACE_SIDEBAR_TEST_ID,
33052
33843
  ref: sidebarRef,
@@ -33068,8 +33859,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33068
33859
  width: `${String(width * 100)}%`
33069
33860
  },
33070
33861
  children: [
33071
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33072
- import_material27.Box,
33862
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
33863
+ import_material28.Box,
33073
33864
  {
33074
33865
  "aria-label": "Resize the sidebar",
33075
33866
  "aria-orientation": "vertical",
@@ -33097,14 +33888,14 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33097
33888
  tabIndex: 0
33098
33889
  }
33099
33890
  ),
33100
- /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_material27.Box, { "aria-label": "Request", component: "header", sx: { alignItems: "center", borderBottom: 1, borderColor: "divider", display: "flex", gap: 1.5, px: 2, py: 1.25 }, children: [
33101
- root2 === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { sx: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33891
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(import_material28.Box, { "aria-label": "Request", component: "header", sx: { alignItems: "center", borderBottom: 1, borderColor: "divider", display: "flex", gap: 1.5, px: 2, py: 1.25 }, children: [
33892
+ root2 === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
33102
33893
  OperationIdentity,
33103
33894
  {
33104
33895
  arn: root2.arn,
33105
33896
  density: "heading",
33106
33897
  label: "Request",
33107
- operation: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(OperationName, { span: root2 }),
33898
+ operation: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(OperationName, { span: root2 }),
33108
33899
  resourceName: root2.resource_name,
33109
33900
  service: root2.service_name,
33110
33901
  sx: { flex: 1 },
@@ -33118,8 +33909,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33118
33909
  ].join(" \xB7 ")
33119
33910
  }
33120
33911
  ),
33121
- /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
33122
- import_material27.ToggleButtonGroup,
33912
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
33913
+ import_material28.ToggleButtonGroup,
33123
33914
  {
33124
33915
  "aria-label": "Trace view",
33125
33916
  exclusive: true,
@@ -33131,28 +33922,33 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33131
33922
  size: "small",
33132
33923
  value: view,
33133
33924
  children: [
33134
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.ToggleButton, { "data-testid": TRACE_SIDEBAR_MAP_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "map", children: "Flow" }),
33135
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.ToggleButton, { "data-testid": TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "waterfall", children: "Operations" })
33925
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.ToggleButton, { "data-testid": TRACE_SIDEBAR_MAP_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "map", children: "Flow" }),
33926
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.ToggleButton, { "data-testid": TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "waterfall", children: "Operations" }),
33927
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.ToggleButton, { "data-testid": TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "sequence", children: "Sequence" })
33136
33928
  ]
33137
33929
  }
33138
33930
  ),
33139
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
33931
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.IconButton, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
33140
33932
  setMaximized(!maximized);
33141
- }, size: "small", children: maximized ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.OpenInFull, { fontSize: "small" }) }),
33142
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.IconButton, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_icons_material15.Close, {}) })
33933
+ }, size: "small", children: maximized ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_icons_material16.CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_icons_material16.OpenInFull, { fontSize: "small" }) }),
33934
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.IconButton, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_icons_material16.Close, {}) })
33143
33935
  ] }),
33144
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { ref: traceViewRef, sx: { borderBottom: 1, borderColor: "divider", display: "flex", flex: `0 0 ${String(storedSplit * 100)}%`, flexDirection: "column", minHeight: 0, overflow: "auto", position: "relative" }, children: view === "waterfall" ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { sx: { height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_react63.ReactFlowProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33145
- TraceGraph,
33146
- {
33147
- hideMiniMap: true,
33148
- initialFocusEventId: selectedSpanId,
33149
- onEventSelect: onSelectSpan,
33150
- onRefresh: noop,
33151
- spans: { data: spans, error: void 0, loading: false }
33152
- }
33153
- ) }) }) }),
33154
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { sx: { flexShrink: 0, position: "relative" }, children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
33155
- import_material27.Box,
33936
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(import_material28.Box, { ref: traceViewRef, sx: { borderBottom: 1, borderColor: "divider", display: "flex", flex: `0 0 ${String(storedSplit * 100)}%`, flexDirection: "column", minHeight: 0, overflow: "auto", position: "relative" }, children: [
33937
+ view === "waterfall" && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }),
33938
+ view === "sequence" && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(SequenceDiagram, { onSelectSpan: selectFromSequence, selectedSpanId, spans }),
33939
+ view === "map" && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { height: "100%" }, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_react64.ReactFlowProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
33940
+ TraceGraph,
33941
+ {
33942
+ hideMiniMap: true,
33943
+ initialFocusEventId: selectedSpanId,
33944
+ onEventSelect: onSelectSpan,
33945
+ onRefresh: noop,
33946
+ spans: { data: spans, error: void 0, loading: false }
33947
+ }
33948
+ ) }) })
33949
+ ] }),
33950
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { flexShrink: 0, position: "relative" }, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
33951
+ import_material28.Box,
33156
33952
  {
33157
33953
  "aria-label": "Resize the operation details",
33158
33954
  "aria-orientation": "horizontal",
@@ -33180,18 +33976,18 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33180
33976
  tabIndex: 0
33181
33977
  }
33182
33978
  ) }),
33183
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Box, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(EventDetails, { onOperationShown, selectedEvent: selectedSpan }) : /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(import_material27.Typography, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
33979
+ /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(EventDetails, { onOperationShown, requestedTab, selectedEvent: selectedSpan }) : /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Typography, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
33184
33980
  ]
33185
33981
  }
33186
33982
  );
33187
33983
  };
33188
33984
 
33189
33985
  // src/components/worker-error-message/worker-error-message.tsx
33190
- var import_icons_material16 = require("@mui/icons-material");
33191
- var import_material28 = require("@mui/material");
33192
- var import_jsx_runtime152 = require("react/jsx-runtime");
33193
- var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
33194
- import_material28.Box,
33986
+ var import_icons_material17 = require("@mui/icons-material");
33987
+ var import_material29 = require("@mui/material");
33988
+ var import_jsx_runtime153 = require("react/jsx-runtime");
33989
+ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
33990
+ import_material29.Box,
33195
33991
  {
33196
33992
  sx: {
33197
33993
  alignItems: "center",
@@ -33201,18 +33997,18 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0, import_jsx_
33201
33997
  justifyContent: "center",
33202
33998
  p: 4
33203
33999
  },
33204
- children: /* @__PURE__ */ (0, import_jsx_runtime152.jsxs)(
33205
- import_material28.Alert,
34000
+ children: /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
34001
+ import_material29.Alert,
33206
34002
  {
33207
- icon: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_icons_material16.ErrorOutline, { fontSize: "large" }),
34003
+ icon: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_icons_material17.ErrorOutline, { fontSize: "large" }),
33208
34004
  severity: "error",
33209
34005
  sx: { maxWidth: 600, width: "100%" },
33210
34006
  children: [
33211
- /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.AlertTitle, { sx: { fontWeight: "bold" }, children: "Unable to Start Span Filtering" }),
33212
- /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Typography, { sx: { mb: 2 }, variant: "body2", children: "App Inspector couldn't start the background worker that filters and sorts operations. This is usually caused by a Content-Security-Policy blocking Web Workers in this environment." }),
33213
- /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Typography, { sx: { fontFamily: "monospace", mb: 2 }, variant: "caption", children: error.message }),
33214
- onRetry && /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(import_material28.Box, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ (0, import_jsx_runtime152.jsx)(
33215
- import_material28.Button,
34007
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.AlertTitle, { sx: { fontWeight: "bold" }, children: "Unable to Start Span Filtering" }),
34008
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.Typography, { sx: { mb: 2 }, variant: "body2", children: "App Inspector couldn't start the background worker that filters and sorts operations. This is usually caused by a Content-Security-Policy blocking Web Workers in this environment." }),
34009
+ /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.Typography, { sx: { fontFamily: "monospace", mb: 2 }, variant: "caption", children: error.message }),
34010
+ onRetry && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(import_material29.Box, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
34011
+ import_material29.Button,
33216
34012
  {
33217
34013
  "aria-label": "Retry starting the spans filter worker",
33218
34014
  onClick: onRetry,
@@ -33227,7 +34023,7 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ (0, import_jsx_
33227
34023
  );
33228
34024
 
33229
34025
  // src/hooks/use-filter-used-analytics.ts
33230
- var import_react64 = require("react");
34026
+ var import_react65 = require("react");
33231
34027
  var FILTER_KEYS = {
33232
34028
  consumer: "service",
33233
34029
  producer: "producer",
@@ -33254,11 +34050,11 @@ var EMPTY_SEARCH = searchPart(parseQuery(""));
33254
34050
  var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, searching }) => {
33255
34051
  const api = useAppInspectorApi();
33256
34052
  const { deploymentContainer } = useAppInspector();
33257
- const previousQueryRef = (0, import_react64.useRef)(query2);
33258
- const pendingRef = (0, import_react64.useRef)();
33259
- const changeCountRef = (0, import_react64.useRef)(0);
33260
- const [settledChange, setSettledChange] = (0, import_react64.useState)(0);
33261
- (0, import_react64.useEffect)(() => {
34053
+ const previousQueryRef = (0, import_react65.useRef)(query2);
34054
+ const pendingRef = (0, import_react65.useRef)();
34055
+ const changeCountRef = (0, import_react65.useRef)(0);
34056
+ const [settledChange, setSettledChange] = (0, import_react65.useState)(0);
34057
+ (0, import_react65.useEffect)(() => {
33262
34058
  const previous = parseQuery(previousQueryRef.current);
33263
34059
  const next = parseQuery(query2);
33264
34060
  previousQueryRef.current = query2;
@@ -33281,7 +34077,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
33281
34077
  clearTimeout(timer);
33282
34078
  };
33283
34079
  }, [query2]);
33284
- (0, import_react64.useEffect)(() => {
34080
+ (0, import_react65.useEffect)(() => {
33285
34081
  const pending = pendingRef.current;
33286
34082
  if (pending === void 0 || filteredCount === void 0) {
33287
34083
  return;
@@ -33327,7 +34123,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
33327
34123
  };
33328
34124
 
33329
34125
  // src/hooks/use-operation-open-analytics.ts
33330
- var import_react65 = require("react");
34126
+ var import_react66 = require("react");
33331
34127
 
33332
34128
  // src/utils/request-id.ts
33333
34129
  var getRequestId = (spans) => {
@@ -33347,8 +34143,8 @@ var getRequestId = (spans) => {
33347
34143
  var useOperationOpenAnalytics = ({ open, shown, spans }) => {
33348
34144
  const api = useAppInspectorApi();
33349
34145
  const { deploymentContainer } = useAppInspector();
33350
- const shownKeyRef = (0, import_react65.useRef)();
33351
- (0, import_react65.useEffect)(() => {
34146
+ const shownKeyRef = (0, import_react66.useRef)();
34147
+ (0, import_react66.useEffect)(() => {
33352
34148
  const shownKey = open && shown ? `${shown.span.span_id}
33353
34149
  ${shown.view}` : void 0;
33354
34150
  const previousKey = shownKeyRef.current;
@@ -33374,12 +34170,12 @@ ${shown.view}` : void 0;
33374
34170
  };
33375
34171
 
33376
34172
  // src/hooks/use-request-open-analytics.ts
33377
- var import_react66 = require("react");
34173
+ var import_react67 = require("react");
33378
34174
  var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
33379
34175
  const api = useAppInspectorApi();
33380
34176
  const { deploymentContainer } = useAppInspector();
33381
- const firedForRef = (0, import_react66.useRef)();
33382
- (0, import_react66.useEffect)(() => {
34177
+ const firedForRef = (0, import_react67.useRef)();
34178
+ (0, import_react67.useEffect)(() => {
33383
34179
  if (loadStartedAt === void 0 || firedForRef.current === loadStartedAt) {
33384
34180
  return;
33385
34181
  }
@@ -33410,7 +34206,7 @@ var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
33410
34206
  };
33411
34207
 
33412
34208
  // src/hooks/use-spans.ts
33413
- var import_react69 = require("react");
34209
+ var import_react70 = require("react");
33414
34210
  var import_react_dom2 = require("react-dom");
33415
34211
 
33416
34212
  // src/utils/pagination-buffer.ts
@@ -33665,7 +34461,7 @@ var toSpanFilterProjection = (span) => ({
33665
34461
  });
33666
34462
 
33667
34463
  // src/hooks/use-spans-compute.ts
33668
- var import_react67 = require("react");
34464
+ var import_react68 = require("react");
33669
34465
 
33670
34466
  // inline-worker:/home/runner/work/localstack-appinspector-ui/localstack-appinspector-ui/src/workers/spans-worker.worker.ts
33671
34467
  var source = '(() => {\n // src/utils/query.ts\n var EXTERNAL_PRODUCER = "external";\n var QUERY_KEYS = ["service", "producer", "status", "op", "resource", "client", "region", "account", "dur", "trace"];\n var isQueryKey = (value) => QUERY_KEYS.includes(value);\n var TOKEN_PATTERN = /(?:[^\\s"]+|"[^"]*"?)+/g;\n var unquote = (value) => value.replaceAll(\'"\', "");\n var isExclusion = (token) => token.length > 1 && token.startsWith("-");\n var splitTerm = (token) => {\n const unquoted = unquote(isExclusion(token) ? token.slice(1) : token);\n const separator = unquoted.indexOf(":");\n if (separator <= 0) {\n return void 0;\n }\n const key = unquoted.slice(0, separator).toLowerCase();\n const value = unquoted.slice(separator + 1);\n return isQueryKey(key) && value !== "" ? [key, value] : void 0;\n };\n var parseQuery = (query) => {\n const parsed = { excludedTerms: {}, excludedWords: [], terms: {}, words: [] };\n for (const token of query.match(TOKEN_PATTERN) ?? []) {\n const excluded = isExclusion(token);\n const term = splitTerm(token);\n if (term) {\n const [key, value] = term;\n ((excluded ? parsed.excludedTerms : parsed.terms)[key] ??= []).push(value);\n } else {\n const word = unquote(excluded ? token.slice(1) : token).toLowerCase();\n if (word !== "") {\n (excluded ? parsed.excludedWords : parsed.words).push(word);\n }\n }\n }\n return parsed;\n };\n var hasExclusions = (parsed) => parsed.excludedWords.length > 0 || Object.keys(parsed.excludedTerms).length > 0;\n var isQueryEmpty = (parsed) => parsed.words.length === 0 && Object.keys(parsed.terms).length === 0 && !hasExclusions(parsed);\n var UNIT_TO_MS = { m: 6e4, ms: 1, s: 1e3, us: 1e-3 };\n var parseDuration = (value) => {\n const match = /^(>=|<=|>|<|=)?\\s*(\\d+(?:\\.\\d+)?)\\s*(us|ms|s|m)?$/i.exec(value.trim());\n if (!match) {\n return void 0;\n }\n const [, operator = ">=", amount = "0", unit = "ms"] = match;\n const threshold = Number(amount) * (UNIT_TO_MS[unit.toLowerCase()] ?? 1);\n switch (operator) {\n case "<": {\n return (durationMs) => durationMs < threshold;\n }\n case "<=": {\n return (durationMs) => durationMs <= threshold;\n }\n case "=": {\n return (durationMs) => Math.round(durationMs) === Math.round(threshold);\n }\n case ">": {\n return (durationMs) => durationMs > threshold;\n }\n default: {\n return (durationMs) => durationMs >= threshold;\n }\n }\n };\n var includesIgnoreCase = (haystack, needle) => haystack.toLowerCase().includes(needle.toLowerCase());\n var matchesTerm = (span, key, value) => {\n switch (key) {\n case "account": {\n return span.accountId === value;\n }\n case "client": {\n return span.triggerKind === value.toLowerCase();\n }\n case "dur": {\n const predicate = parseDuration(value);\n return predicate !== void 0 && span.durationMs !== void 0 && predicate(span.durationMs);\n }\n case "op": {\n return includesIgnoreCase(span.operationName, value);\n }\n case "producer": {\n return span.producer.toLowerCase() === value.toLowerCase();\n }\n case "region": {\n return span.region.toLowerCase() === value.toLowerCase();\n }\n case "resource": {\n return includesIgnoreCase(span.resourceName, value) || includesIgnoreCase(span.arn, value);\n }\n case "service": {\n return span.serviceName.toLowerCase() === value.toLowerCase();\n }\n case "status": {\n const status = value.toLowerCase();\n if (status === "error") return span.error;\n if (status === "warning" || status === "warn") return span.warning;\n if (status === "ok") return !span.error && !span.warning;\n return span.statusMessage?.includes(value) ?? false;\n }\n case "trace": {\n return span.traceId.startsWith(value.toLowerCase());\n }\n }\n };\n var matchesExclusion = (span, parsed) => Object.entries(parsed.excludedTerms).some(([key, values]) => values.some((value) => matchesTerm(span, key, value))) || parsed.excludedWords.some((word) => span.haystack.includes(word));\n var matchesQuery = (span, parsed, textMatches) => {\n if (matchesExclusion(span, parsed)) {\n return false;\n }\n for (const [key, values] of Object.entries(parsed.terms)) {\n if (!values.some((value) => matchesTerm(span, key, value))) {\n return false;\n }\n }\n if (parsed.words.length > 0 && !textMatches?.has(span.spanId)) {\n return parsed.words.every((word) => span.haystack.includes(word));\n }\n return true;\n };\n\n // src/utils/iam-utils.ts\n function determinePermissionStatus(payload) {\n if (payload.explicit_deny_count && payload.explicit_deny_count > 0) {\n return "explicitly_denied";\n }\n if (payload.is_allowed) {\n return "explicitly_allowed";\n }\n return "implicitly_denied";\n }\n function parseIAMEvent(payloadString) {\n try {\n const payload = JSON.parse(payloadString);\n const permission = determinePermissionStatus(payload);\n const actions = [];\n const resources = [];\n if (payload.explicit_allows) {\n for (const allow of payload.explicit_allows) {\n if (!actions.includes(allow.action)) actions.push(allow.action);\n if (!resources.includes(allow.resource)) resources.push(allow.resource);\n }\n }\n if (payload.explicit_denies) {\n for (const deny of payload.explicit_denies) {\n if (!actions.includes(deny.action)) actions.push(deny.action);\n if (!resources.includes(deny.resource)) resources.push(deny.resource);\n }\n }\n if (payload.implicit_denies) {\n for (const deny of payload.implicit_denies) {\n if (!actions.includes(deny.action)) actions.push(deny.action);\n if (!resources.includes(deny.resource)) resources.push(deny.resource);\n }\n }\n return {\n details: {\n actions,\n explicitAllows: payload.explicit_allow_count,\n explicitDenies: payload.explicit_deny_count,\n implicitDenies: payload.implicit_deny_count,\n resources\n },\n enforcement: payload.enforcement,\n operation: payload.operation,\n permission,\n principal: payload.principal_arn,\n service: payload.service\n };\n } catch (error) {\n console.error("Error parsing IAM event payload:", error);\n return void 0;\n }\n }\n var getIamEvents = (span) => span.events.flatMap((event) => {\n const payload = event.attributes?.payload;\n if (!event.event_type?.toLowerCase().includes("iam") || typeof payload !== "string") return [];\n return parseIAMEvent(payload) ?? [];\n });\n var getIamEnforcement = (span, events = getIamEvents(span)) => {\n const enforcements = new Set(events.map((event) => event.enforcement).filter(Boolean));\n if (enforcements.size > 0) {\n if (enforcements.has("deny")) return "deny";\n if (enforcements.has("allow_with_warning")) return "allow_with_warning";\n return void 0;\n }\n return getIamEnforcementFromOperationStatus(span);\n };\n var getIamEnforcementFromOperationStatus = (span) => {\n const status = span.operation_status;\n if (status === "iam_explicit_deny" || status === "iam_implicit_deny") return "deny";\n if (status === "iam_explicit_warn" || status === "iam_implicit_warn") return "allow_with_warning";\n return void 0;\n };\n\n // src/utils/span-issues.ts\n var firstText = (...values) => values.find((value) => !!value) ?? void 0;\n var getExceptionCode = (span) => {\n const raw = span.attributes?.["localstack.aws.service.exception"];\n if (typeof raw !== "string") return void 0;\n try {\n const exception = JSON.parse(raw);\n const code = exception.code ?? exception.Code;\n return typeof code === "string" ? code : void 0;\n } catch {\n return void 0;\n }\n };\n var OTEL_STATUS_ERROR = 2;\n var getIamOutcome = (span) => {\n const iamEvents = getIamEvents(span);\n const enforcement = getIamEnforcement(span, iamEvents);\n const iamDenied = enforcement === "deny";\n const denials = iamEvents.flatMap((event) => {\n if (event.permission === "explicitly_denied") return ["explicit"];\n if (event.permission === "implicitly_denied") return ["implicit"];\n return [];\n });\n return {\n denials,\n iamDenied,\n iamWarned: enforcement === "allow_with_warning",\n unenforcedDenial: !iamDenied && (denials.length > 0 || span.attributes?.["localstack.has_iam_deny_event"] === true)\n };\n };\n var getSpanIssues = (span) => {\n const status = span.operation_status;\n const { denials, iamDenied, iamWarned, unenforcedDenial } = getIamOutcome(span);\n const errorMessages = (span.errors ?? []).filter((item) => item.level === "error");\n const warningMessages = (span.errors ?? []).filter((item) => item.level === "warning");\n const error = status === "error" || iamDenied || span.status_code === OTEL_STATUS_ERROR || errorMessages.length > 0;\n const warning = iamWarned || warningMessages.length > 0 || unenforcedDenial;\n const denialCount = unenforcedDenial ? Math.max(1, denials.length) : 0;\n return {\n error,\n errorType: error ? firstText(span.status_message, errorMessages[0]?.message, getExceptionCode(span)) ?? (iamDenied ? "AccessDenied" : "Error") : void 0,\n warning,\n warningCount: warning ? Math.max(1, warningMessages.length + denialCount) : 0,\n warningType: warning ? firstText(warningMessages[0]?.message) ?? (unenforcedDenial ? `IAM ${denials[0] ?? "implicit"} deny` : iamWarned ? "IAM permission warning" : "Warning") : void 0\n };\n };\n\n // src/utils/span-parents.ts\n var resolveParents = (spans) => {\n const byId = new Map(spans.map((span) => [span.span_id, span]));\n const parentOf = /* @__PURE__ */ new Map();\n for (const span of spans) {\n const parent = span.parent_span_id === null ? void 0 : byId.get(span.parent_span_id);\n if (parent && parent.span_id !== span.span_id && parent.trace_id === span.trace_id) {\n parentOf.set(span.span_id, parent.span_id);\n }\n }\n const causes = /* @__PURE__ */ new Map();\n const addCause = (spanId, causeId) => {\n const list = causes.get(spanId);\n if (list) list.push(causeId);\n else causes.set(spanId, [causeId]);\n };\n for (const span of spans) {\n for (const causeId of span.outgoing_link_span_ids ?? []) addCause(span.span_id, causeId);\n for (const effectId of span.incoming_link_span_ids ?? []) addCause(effectId, span.span_id);\n }\n const isAncestorOrSelf = (candidateId, spanId) => {\n let current = spanId;\n for (let hops = 0; current !== void 0 && hops <= spans.length; hops++) {\n if (current === candidateId) return true;\n current = parentOf.get(current);\n }\n return false;\n };\n for (const span of spans) {\n if (parentOf.has(span.span_id)) continue;\n const cause = causes.get(span.span_id)?.find((causeId) => byId.has(causeId) && !isAncestorOrSelf(span.span_id, causeId));\n if (cause !== void 0) parentOf.set(span.span_id, cause);\n }\n return parentOf;\n };\n\n // src/utils/trigger.ts\n var getTriggerKind = (span) => span.isInternal ? "internal" : "client";\n\n // src/workers/spans-reducer.ts\n var nanosToMilliseconds = (start, end) => {\n if (!end) return void 0;\n return Number(BigInt(end) - BigInt(start)) / 1e6;\n };\n var toCorpusEntry = (projection, arrivedAt) => {\n const issues = getSpanIssues(projection);\n return {\n accountId: projection.account_id,\n arn: projection.arn,\n arrivedAt,\n durationMs: nanosToMilliseconds(projection.start_time_unix_nano, projection.end_time_unix_nano),\n error: issues.error,\n haystack: [\n projection.service_name,\n projection.operation_name,\n projection.operation_label,\n projection.resource_name,\n projection.arn,\n projection.status_message,\n projection.region,\n projection.account_id,\n projection.trace_id,\n projection.span_id,\n ...(projection.errors ?? []).map((error) => error.message)\n ].filter(Boolean).join("\\n").toLowerCase(),\n issues,\n operationName: projection.operation_name,\n parents: projection,\n producer: projection.parent_service_name ?? EXTERNAL_PRODUCER,\n region: projection.region,\n resourceName: projection.resource_name,\n serviceName: projection.service_name,\n spanId: projection.span_id,\n startTime: projection.start_time_unix_nano,\n statusMessage: projection.status_message,\n traceId: projection.trace_id,\n triggerKind: getTriggerKind({ isInternal: projection.is_internal }),\n warning: issues.warning\n };\n };\n var compareByStartTime = (left, right) => {\n if (left.startTime.length !== right.startTime.length) {\n return left.startTime.length - right.startTime.length;\n }\n return left.startTime.localeCompare(right.startTime, "en");\n };\n var countFacet = (requests, value, rootSpanId) => {\n const set = requests.get(value);\n if (set) set.add(rootSpanId);\n else requests.set(value, /* @__PURE__ */ new Set([rootSpanId]));\n };\n var toFacetValues = (requests) => [...requests].map(([value, set]) => ({ count: set.size, value })).toSorted((left, right) => left.value.localeCompare(right.value));\n var createSpansReducer = ({ now = Date.now, orphanGraceMs = 0 } = {}) => {\n const corpus = /* @__PURE__ */ new Map();\n let parsedQuery = parseQuery("");\n let textMatches;\n let nextReveal;\n const computeResult = () => {\n const sorted = [...corpus.values()].toSorted(compareByStartTime);\n const queryActive = !isQueryEmpty(parsedQuery);\n const parentOf = resolveParents(sorted.map((entry) => entry.parents));\n const time = now();\n nextReveal = void 0;\n const waiting = /* @__PURE__ */ new Map();\n const isOrphanWaiting = (root) => {\n if (root.parents.parent_span_id === null && (root.parents.outgoing_link_span_ids?.length ?? 0) === 0) return false;\n const revealAt = root.arrivedAt + orphanGraceMs;\n if (time >= revealAt) return false;\n nextReveal = Math.min(nextReveal ?? revealAt, revealAt);\n return true;\n };\n const isWaiting = (entry) => {\n const chain = [];\n let current = entry;\n let result = false;\n while (current) {\n const known = waiting.get(current.spanId);\n if (known !== void 0) {\n result = known;\n break;\n }\n chain.push(current);\n const parent = corpus.get(parentOf.get(current.spanId) ?? "");\n if (!parent) result = isOrphanWaiting(current);\n current = parent;\n }\n for (const item of chain) waiting.set(item.spanId, result);\n return result;\n };\n const entries = orphanGraceMs > 0 ? sorted.filter((entry) => !isWaiting(entry)) : sorted;\n const children = /* @__PURE__ */ new Map();\n const topLevel = [];\n for (const entry of entries) {\n const parentId = parentOf.get(entry.spanId);\n if (parentId === void 0) {\n topLevel.push(entry);\n continue;\n }\n const siblings = children.get(parentId);\n if (siblings) siblings.push(entry);\n else children.set(parentId, [entry]);\n }\n const rows = {};\n const visit = (root) => {\n const stack = [{ entry: root, expanded: false }];\n while (stack.length > 0) {\n const frame = stack.at(-1);\n const kids = children.get(frame.entry.spanId) ?? [];\n if (!frame.expanded) {\n frame.expanded = true;\n for (const kid of kids) {\n if (!(kid.spanId in rows)) stack.push({ entry: kid, expanded: false });\n }\n continue;\n }\n stack.pop();\n const matches = !queryActive || matchesQuery(frame.entry, parsedQuery, textMatches);\n const row = {\n ...frame.entry.issues,\n downstream: { count: 0, errors: 0, warnings: 0 },\n matches,\n parentServiceName: corpus.get(parentOf.get(frame.entry.spanId) ?? "")?.serviceName,\n rootSpanId: root.spanId,\n treeMatches: matches ? 1 : 0,\n treeSize: 1\n };\n for (const kid of kids) {\n const kidRow = rows[kid.spanId];\n if (!kidRow) continue;\n row.downstream.count += kidRow.downstream.count + 1;\n row.downstream.errors += kidRow.downstream.errors + (kidRow.error ? 1 : 0);\n row.downstream.warnings += kidRow.downstream.warnings + (kidRow.warning ? 1 : 0);\n row.treeMatches += kidRow.treeMatches;\n row.treeSize += kidRow.treeSize;\n }\n rows[frame.entry.spanId] = row;\n }\n return rows[root.spanId]?.treeMatches ?? 0;\n };\n const topLevelIds = [];\n for (const entry of topLevel) {\n if (visit(entry) > 0) {\n topLevelIds.push(entry.spanId);\n }\n }\n const allIds = [];\n let excludedCount = 0;\n const excluding = hasExclusions(parsedQuery);\n const producers = /* @__PURE__ */ new Map();\n const services = /* @__PURE__ */ new Map();\n const regions = /* @__PURE__ */ new Map();\n const accounts = /* @__PURE__ */ new Map();\n const clients = /* @__PURE__ */ new Map();\n const issues = /* @__PURE__ */ new Map();\n for (const entry of entries) {\n const row = rows[entry.spanId];\n if (!row) continue;\n if (row.matches) allIds.push(entry.spanId);\n if (excluding && matchesExclusion(entry, parsedQuery)) excludedCount++;\n countFacet(producers, entry.producer, row.rootSpanId);\n countFacet(services, entry.serviceName, row.rootSpanId);\n countFacet(regions, entry.region, row.rootSpanId);\n countFacet(accounts, entry.accountId, row.rootSpanId);\n countFacet(clients, entry.triggerKind, row.rootSpanId);\n if (entry.error) countFacet(issues, "error", row.rootSpanId);\n if (entry.warning) countFacet(issues, "warning", row.rootSpanId);\n if (!entry.error && !entry.warning) countFacet(issues, "ok", row.rootSpanId);\n }\n return {\n allIds: allIds.toReversed(),\n excludedCount,\n facets: {\n account: toFacetValues(accounts),\n client: toFacetValues(clients),\n issues: ["error", "warning", "ok"].map((value) => ({ count: issues.get(value)?.size ?? 0, value })),\n producer: toFacetValues(producers),\n region: toFacetValues(regions),\n service: toFacetValues(services)\n },\n queryActive,\n rows,\n topLevelIds: topLevelIds.toReversed(),\n totalCount: topLevel.length\n };\n };\n return {\n addPage: (_direction, projections) => {\n for (const projection of projections) {\n corpus.set(projection.span_id, toCorpusEntry(projection, corpus.get(projection.span_id)?.arrivedAt ?? now()));\n }\n return computeResult();\n },\n clear: () => {\n corpus.clear();\n return computeResult();\n },\n nextReveal: () => nextReveal,\n refresh: computeResult,\n setQuery: (query, matches) => {\n parsedQuery = parseQuery(query);\n textMatches = matches ? new Set(matches) : void 0;\n return computeResult();\n }\n };\n };\n\n // src/workers/spans-worker.worker.ts\n var context = globalThis;\n var reducer = createSpansReducer({ orphanGraceMs: 3e3 });\n var revealTimer;\n var post = (result, seq) => {\n context.postMessage({ result, seq });\n clearTimeout(revealTimer);\n const revealAt = reducer.nextReveal();\n if (revealAt !== void 0) {\n revealTimer = setTimeout(() => {\n post(reducer.refresh(), seq);\n }, Math.max(0, revealAt - Date.now()));\n }\n };\n context.addEventListener("message", (event) => {\n const request = event.data;\n let result;\n switch (request.op) {\n case "addPage": {\n result = reducer.addPage(request.direction, request.projections);\n break;\n }\n case "clear": {\n result = reducer.clear();\n break;\n }\n case "setQuery": {\n result = reducer.setQuery(request.query, request.textMatches);\n break;\n }\n }\n post(result, request.seq);\n });\n})();\n';
@@ -33690,15 +34486,15 @@ var EMPTY_RESULT = {
33690
34486
  };
33691
34487
  var useSpansCompute = () => {
33692
34488
  const { spansWorkerUrl } = useAppInspector();
33693
- const [computeState, setComputeState] = (0, import_react67.useState)({ loaded: false, result: EMPTY_RESULT, resultVersion: 0 });
34489
+ const [computeState, setComputeState] = (0, import_react68.useState)({ loaded: false, result: EMPTY_RESULT, resultVersion: 0 });
33694
34490
  const { loaded, result, resultVersion } = computeState;
33695
- const [workerError, setWorkerError] = (0, import_react67.useState)();
33696
- const [retryCount, setRetryCount] = (0, import_react67.useState)(0);
33697
- const workerRef = (0, import_react67.useRef)();
33698
- const seqRef = (0, import_react67.useRef)(0);
33699
- const lastAppliedRef = (0, import_react67.useRef)(0);
33700
- const firstPageSeqRef = (0, import_react67.useRef)();
33701
- (0, import_react67.useEffect)(() => {
34491
+ const [workerError, setWorkerError] = (0, import_react68.useState)();
34492
+ const [retryCount, setRetryCount] = (0, import_react68.useState)(0);
34493
+ const workerRef = (0, import_react68.useRef)();
34494
+ const seqRef = (0, import_react68.useRef)(0);
34495
+ const lastAppliedRef = (0, import_react68.useRef)(0);
34496
+ const firstPageSeqRef = (0, import_react68.useRef)();
34497
+ (0, import_react68.useEffect)(() => {
33702
34498
  try {
33703
34499
  const worker = spansWorkerUrl ? new Worker(spansWorkerUrl) : createInlineWorker();
33704
34500
  worker.addEventListener("message", (event) => {
@@ -33725,26 +34521,26 @@ var useSpansCompute = () => {
33725
34521
  return;
33726
34522
  }
33727
34523
  }, [retryCount, spansWorkerUrl]);
33728
- const retryWorker = (0, import_react67.useCallback)(() => {
34524
+ const retryWorker = (0, import_react68.useCallback)(() => {
33729
34525
  setWorkerError(void 0);
33730
34526
  setRetryCount((count2) => count2 + 1);
33731
34527
  }, []);
33732
- const addPage = (0, import_react67.useCallback)((direction, projections) => {
34528
+ const addPage = (0, import_react68.useCallback)((direction, projections) => {
33733
34529
  const seq = ++seqRef.current;
33734
34530
  firstPageSeqRef.current ??= seq;
33735
34531
  workerRef.current?.postMessage({ direction, op: "addPage", projections, seq });
33736
34532
  }, []);
33737
- const setQuery = (0, import_react67.useCallback)((query2, textMatches) => {
34533
+ const setQuery = (0, import_react68.useCallback)((query2, textMatches) => {
33738
34534
  workerRef.current?.postMessage({ op: "setQuery", query: query2, seq: ++seqRef.current, textMatches });
33739
34535
  }, []);
33740
- const clear = (0, import_react67.useCallback)(() => {
34536
+ const clear = (0, import_react68.useCallback)(() => {
33741
34537
  workerRef.current?.postMessage({ op: "clear", seq: ++seqRef.current });
33742
34538
  }, []);
33743
34539
  return { addPage, clear, loaded, result, resultVersion, retryWorker, setQuery, workerError };
33744
34540
  };
33745
34541
 
33746
34542
  // src/hooks/use-spans-ws.tsx
33747
- var import_react68 = require("react");
34543
+ var import_react69 = require("react");
33748
34544
  var wsLogger = createScopedLogger("WS");
33749
34545
  var isLegacySpanFields = (value) => {
33750
34546
  return typeof value.span_id === "string" && typeof value.trace_id === "string" && typeof value.timestamp === "string";
@@ -33776,22 +34572,22 @@ var parseSpansWebSocketMessage = (raw) => {
33776
34572
  };
33777
34573
  function useSpansWebSocket(options) {
33778
34574
  const { enabled, onClose, onMessage, onOpen } = options;
33779
- const onMessageRef = (0, import_react68.useRef)(onMessage);
33780
- const onOpenRef = (0, import_react68.useRef)(onOpen);
33781
- const onCloseRef = (0, import_react68.useRef)(onClose);
33782
- (0, import_react68.useEffect)(() => {
34575
+ const onMessageRef = (0, import_react69.useRef)(onMessage);
34576
+ const onOpenRef = (0, import_react69.useRef)(onOpen);
34577
+ const onCloseRef = (0, import_react69.useRef)(onClose);
34578
+ (0, import_react69.useEffect)(() => {
33783
34579
  onMessageRef.current = onMessage;
33784
34580
  }, [onMessage]);
33785
- (0, import_react68.useEffect)(() => {
34581
+ (0, import_react69.useEffect)(() => {
33786
34582
  onOpenRef.current = onOpen;
33787
34583
  }, [onOpen]);
33788
- (0, import_react68.useEffect)(() => {
34584
+ (0, import_react69.useEffect)(() => {
33789
34585
  onCloseRef.current = onClose;
33790
34586
  }, [onClose]);
33791
- const [connected, setConnected] = (0, import_react68.useState)(false);
33792
- const wsRef = (0, import_react68.useRef)(void 0);
34587
+ const [connected, setConnected] = (0, import_react69.useState)(false);
34588
+ const wsRef = (0, import_react69.useRef)(void 0);
33793
34589
  const { localstackEndpoint } = useAppInspector();
33794
- const connect = (0, import_react68.useCallback)(() => {
34590
+ const connect = (0, import_react69.useCallback)(() => {
33795
34591
  if (wsRef.current !== void 0) return;
33796
34592
  const url = new URL(getAppInspectorApiUrl(localstackEndpoint, API_ENDPOINTS.WEBSOCKET_SPANS));
33797
34593
  url.protocol = globalThis.location.protocol === "https:" ? "wss" : "ws";
@@ -33832,7 +34628,7 @@ function useSpansWebSocket(options) {
33832
34628
  }
33833
34629
  });
33834
34630
  }, [localstackEndpoint]);
33835
- (0, import_react68.useEffect)(() => {
34631
+ (0, import_react69.useEffect)(() => {
33836
34632
  if (!enabled) {
33837
34633
  if (wsRef.current !== void 0) {
33838
34634
  wsRef.current.close();
@@ -33875,42 +34671,42 @@ var useSpans = () => {
33875
34671
  const api = useAppInspectorApi();
33876
34672
  const { onWsClose, onWsOpen, status, wsEnabled } = useAppInspectorStatus();
33877
34673
  const { addPage, clear: clearCompute, loaded: spansLoaded, result: computeResult, resultVersion, retryWorker, setQuery: setComputeQuery, workerError } = useSpansCompute();
33878
- const spanMapRef = (0, import_react69.useRef)(/* @__PURE__ */ new Map());
33879
- const newSpanIdsRef = (0, import_react69.useRef)(/* @__PURE__ */ new Set());
33880
- const caughtUpRef = (0, import_react69.useRef)(false);
33881
- const [fetchError, setFetchError] = (0, import_react69.useState)();
33882
- const [fetchingForward, setFetchingForward] = (0, import_react69.useState)(false);
33883
- const [fetchingBackward, setFetchingBackward] = (0, import_react69.useState)(false);
33884
- const [query2, setQueryState] = (0, import_react69.useState)("");
33885
- const [searching, setSearching] = (0, import_react69.useState)(false);
33886
- const paginationBufferRef = (0, import_react69.useRef)();
33887
- const [totalCount, setTotalCount] = (0, import_react69.useState)();
33888
- const [licenseLimit, setLicenseLimit] = (0, import_react69.useState)();
33889
- const [systemLimit, setSystemLimit] = (0, import_react69.useState)();
33890
- const [errorCount, setErrorCount] = (0, import_react69.useState)();
33891
- const [warningCount, setWarningCount] = (0, import_react69.useState)();
33892
- const [hasMoreBackward, setHasMoreBackward] = (0, import_react69.useState)();
33893
- const [hasMoreForward, setHasMoreForward] = (0, import_react69.useState)();
33894
- const fetchForward = (0, import_react69.useCallback)(() => {
34674
+ const spanMapRef = (0, import_react70.useRef)(/* @__PURE__ */ new Map());
34675
+ const newSpanIdsRef = (0, import_react70.useRef)(/* @__PURE__ */ new Set());
34676
+ const caughtUpRef = (0, import_react70.useRef)(false);
34677
+ const [fetchError, setFetchError] = (0, import_react70.useState)();
34678
+ const [fetchingForward, setFetchingForward] = (0, import_react70.useState)(false);
34679
+ const [fetchingBackward, setFetchingBackward] = (0, import_react70.useState)(false);
34680
+ const [query2, setQueryState] = (0, import_react70.useState)("");
34681
+ const [searching, setSearching] = (0, import_react70.useState)(false);
34682
+ const paginationBufferRef = (0, import_react70.useRef)();
34683
+ const [totalCount, setTotalCount] = (0, import_react70.useState)();
34684
+ const [licenseLimit, setLicenseLimit] = (0, import_react70.useState)();
34685
+ const [systemLimit, setSystemLimit] = (0, import_react70.useState)();
34686
+ const [errorCount, setErrorCount] = (0, import_react70.useState)();
34687
+ const [warningCount, setWarningCount] = (0, import_react70.useState)();
34688
+ const [hasMoreBackward, setHasMoreBackward] = (0, import_react70.useState)();
34689
+ const [hasMoreForward, setHasMoreForward] = (0, import_react70.useState)();
34690
+ const fetchForward = (0, import_react70.useCallback)(() => {
33895
34691
  void paginationBufferRef.current?.fetchForward();
33896
34692
  }, []);
33897
- const fetchBackward = (0, import_react69.useCallback)(() => {
34693
+ const fetchBackward = (0, import_react70.useCallback)(() => {
33898
34694
  void paginationBufferRef.current?.fetchBackward();
33899
34695
  }, []);
33900
- const resetCorpus = (0, import_react69.useCallback)(() => {
34696
+ const resetCorpus = (0, import_react70.useCallback)(() => {
33901
34697
  spanMapRef.current.clear();
33902
34698
  newSpanIdsRef.current.clear();
33903
34699
  caughtUpRef.current = false;
33904
34700
  clearCompute();
33905
34701
  }, [clearCompute]);
33906
- const [epoch, setEpoch] = (0, import_react69.useState)();
33907
- const onEpochSeen = (0, import_react69.useCallback)((observedEpoch) => {
34702
+ const [epoch, setEpoch] = (0, import_react70.useState)();
34703
+ const onEpochSeen = (0, import_react70.useCallback)((observedEpoch) => {
33908
34704
  if (observedEpoch === null || observedEpoch === void 0) {
33909
34705
  return;
33910
34706
  }
33911
34707
  setEpoch(observedEpoch);
33912
34708
  }, []);
33913
- const clearCache = (0, import_react69.useCallback)(() => {
34709
+ const clearCache = (0, import_react70.useCallback)(() => {
33914
34710
  paginationBufferRef.current?.clear();
33915
34711
  resetCorpus();
33916
34712
  setTotalCount(void 0);
@@ -33918,9 +34714,9 @@ var useSpans = () => {
33918
34714
  setWarningCount(void 0);
33919
34715
  void paginationBufferRef.current?.fetchForward();
33920
34716
  }, [resetCorpus]);
33921
- const hasFetchedWithoutEpochRef = (0, import_react69.useRef)(false);
33922
- const previousEpochRef = (0, import_react69.useRef)();
33923
- (0, import_react69.useEffect)(() => {
34717
+ const hasFetchedWithoutEpochRef = (0, import_react70.useRef)(false);
34718
+ const previousEpochRef = (0, import_react70.useRef)();
34719
+ (0, import_react70.useEffect)(() => {
33924
34720
  if (epoch === void 0) {
33925
34721
  return;
33926
34722
  }
@@ -33933,11 +34729,11 @@ var useSpans = () => {
33933
34729
  }, [epoch, clearCache]);
33934
34730
  const searchSupported = emulatorSupportsSearch(status?.localstackVersion);
33935
34731
  const freeText = parseQuery(query2).words.join(" ");
33936
- const setQuery = (0, import_react69.useCallback)((next) => {
34732
+ const setQuery = (0, import_react70.useCallback)((next) => {
33937
34733
  setQueryState(next);
33938
34734
  setComputeQuery(next);
33939
34735
  }, [setComputeQuery]);
33940
- (0, import_react69.useEffect)(() => {
34736
+ (0, import_react70.useEffect)(() => {
33941
34737
  if (!searchSupported || freeText === "") {
33942
34738
  return;
33943
34739
  }
@@ -33958,7 +34754,7 @@ var useSpans = () => {
33958
34754
  setSearching(false);
33959
34755
  };
33960
34756
  }, [api, freeText, query2, searchSupported, setComputeQuery]);
33961
- (0, import_react69.useEffect)(() => {
34757
+ (0, import_react70.useEffect)(() => {
33962
34758
  const buffer = createPaginationBuffer({
33963
34759
  async fetchPage(token, signal) {
33964
34760
  const requestPage = async (paginationToken) => {
@@ -34029,8 +34825,8 @@ var useSpans = () => {
34029
34825
  paginationBufferRef.current = buffer;
34030
34826
  void buffer.fetchForward();
34031
34827
  }, [api, addPage, onEpochSeen, resetCorpus]);
34032
- const [clearingSpans, setClearingSpans] = (0, import_react69.useState)(false);
34033
- const clearSpans = (0, import_react69.useCallback)(async () => {
34828
+ const [clearingSpans, setClearingSpans] = (0, import_react70.useState)(false);
34829
+ const clearSpans = (0, import_react70.useCallback)(async () => {
34034
34830
  if (clearingSpans) {
34035
34831
  return;
34036
34832
  }
@@ -34048,17 +34844,17 @@ var useSpans = () => {
34048
34844
  setClearingSpans(false);
34049
34845
  }
34050
34846
  }, [clearingSpans, api, resetCorpus]);
34051
- (0, import_react69.useEffect)(() => {
34847
+ (0, import_react70.useEffect)(() => {
34052
34848
  if (hasMoreForward === true && !fetchingForward) {
34053
34849
  void paginationBufferRef.current?.fetchForward();
34054
34850
  }
34055
34851
  }, [hasMoreForward, fetchingForward]);
34056
- (0, import_react69.useEffect)(() => {
34852
+ (0, import_react70.useEffect)(() => {
34057
34853
  if (hasMoreBackward === true && !fetchingBackward && !fetchingForward) {
34058
34854
  void paginationBufferRef.current?.fetchBackward();
34059
34855
  }
34060
34856
  }, [hasMoreBackward, fetchingBackward, fetchingForward]);
34061
- const [previousStatusEpoch, setPreviousStatusEpoch] = (0, import_react69.useState)();
34857
+ const [previousStatusEpoch, setPreviousStatusEpoch] = (0, import_react70.useState)();
34062
34858
  if (status !== void 0 && status.epoch !== previousStatusEpoch) {
34063
34859
  setPreviousStatusEpoch(status.epoch);
34064
34860
  onEpochSeen(status.epoch);
@@ -34083,10 +34879,10 @@ var useSpans = () => {
34083
34879
  fetchForward();
34084
34880
  }
34085
34881
  });
34086
- const clearFetchError = (0, import_react69.useCallback)(() => {
34882
+ const clearFetchError = (0, import_react70.useCallback)(() => {
34087
34883
  setFetchError(void 0);
34088
34884
  }, []);
34089
- const getSpan = (0, import_react69.useCallback)((spanId) => spanMapRef.current.get(spanId), []);
34885
+ const getSpan = (0, import_react70.useCallback)((spanId) => spanMapRef.current.get(spanId), []);
34090
34886
  const newSpanIds = newSpanIdsRef.current;
34091
34887
  return {
34092
34888
  clearFetchError,
@@ -34118,7 +34914,8 @@ var useSpans = () => {
34118
34914
  };
34119
34915
 
34120
34916
  // src/pages/spans-list-page.tsx
34121
- var import_jsx_runtime153 = require("react/jsx-runtime");
34917
+ var import_jsx_runtime154 = require("react/jsx-runtime");
34918
+ var ANALYTICS_REQUEST_VIEWS = { map: "flow_graph", sequence: "sequence_graph", waterfall: "operations" };
34122
34919
  var SpansListPage = () => {
34123
34920
  const api = useAppInspectorApi();
34124
34921
  const {
@@ -34151,49 +34948,49 @@ var SpansListPage = () => {
34151
34948
  resultVersion,
34152
34949
  searching
34153
34950
  });
34154
- const clearSpansSync = (0, import_react70.useCallback)(() => {
34951
+ const clearSpansSync = (0, import_react71.useCallback)(() => {
34155
34952
  void clearSpans();
34156
34953
  }, [clearSpans]);
34157
34954
  const localstackVersion = status?.localstackVersion ?? (statusError instanceof AppInspectorNotFoundError ? statusError.localstackVersion : void 0);
34158
34955
  const versionCompatibility = checkEmulatorVersion(localstackVersion);
34159
- const [bannerDismissed, setBannerDismissed] = (0, import_react70.useState)(false);
34956
+ const [bannerDismissed, setBannerDismissed] = (0, import_react71.useState)(false);
34160
34957
  const [order2, setOrder] = useLocalStorage("spans-order", "oldest_first");
34161
- const [selectedSpanId, setSelectedSpanId] = (0, import_react70.useState)();
34162
- const getTreeSpans = (0, import_react70.useCallback)((rootSpanId2) => Object.entries(compute.rows).filter(([, row]) => row.rootSpanId === rootSpanId2).map(([spanId]) => getSpan(spanId)).filter((span) => span !== void 0), [compute.rows, getSpan]);
34163
- const latestRef = (0, import_react70.useRef)({ compute, getTreeSpans });
34164
- (0, import_react70.useEffect)(() => {
34958
+ const [selectedSpanId, setSelectedSpanId] = (0, import_react71.useState)();
34959
+ const getTreeSpans = (0, import_react71.useCallback)((rootSpanId2) => Object.entries(compute.rows).filter(([, row]) => row.rootSpanId === rootSpanId2).map(([spanId]) => getSpan(spanId)).filter((span) => span !== void 0), [compute.rows, getSpan]);
34960
+ const latestRef = (0, import_react71.useRef)({ compute, getTreeSpans });
34961
+ (0, import_react71.useEffect)(() => {
34165
34962
  latestRef.current = { compute, getTreeSpans };
34166
34963
  }, [compute, getTreeSpans]);
34167
- const openedAtRef = (0, import_react70.useRef)();
34168
- const navigateToSpan = (0, import_react70.useCallback)((span) => {
34964
+ const openedAtRef = (0, import_react71.useRef)();
34965
+ const navigateToSpan = (0, import_react71.useCallback)((span) => {
34169
34966
  openedAtRef.current = performance.now();
34170
34967
  const { compute: { queryActive, rows }, getTreeSpans: getSpans } = latestRef.current;
34171
34968
  const rootSpanId2 = rows[span.span_id]?.rootSpanId;
34172
34969
  const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
34173
34970
  setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
34174
34971
  }, []);
34175
- const [shownOperation, setShownOperation] = (0, import_react70.useState)();
34176
- const closeSidebar = (0, import_react70.useCallback)(() => {
34972
+ const [shownOperation, setShownOperation] = (0, import_react71.useState)();
34973
+ const closeSidebar = (0, import_react71.useCallback)(() => {
34177
34974
  setSelectedSpanId(void 0);
34178
34975
  setShownOperation(void 0);
34179
34976
  }, []);
34180
34977
  const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
34181
- const treeSpans = (0, import_react70.useMemo)(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
34182
- const spanMatches = (0, import_react70.useMemo)(
34978
+ const treeSpans = (0, import_react71.useMemo)(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
34979
+ const spanMatches = (0, import_react71.useMemo)(
34183
34980
  () => compute.queryActive ? (spanId) => compute.rows[spanId]?.matches ?? false : void 0,
34184
34981
  [compute]
34185
34982
  );
34186
- const treeSpansRef = (0, import_react70.useRef)(treeSpans);
34187
- (0, import_react70.useEffect)(() => {
34983
+ const treeSpansRef = (0, import_react71.useRef)(treeSpans);
34984
+ (0, import_react71.useEffect)(() => {
34188
34985
  treeSpansRef.current = treeSpans;
34189
34986
  }, [treeSpans]);
34190
- const [renderedRequest, setRenderedRequest] = (0, import_react70.useState)();
34191
- const handleRequestRendered = (0, import_react70.useCallback)((view) => {
34987
+ const [renderedRequest, setRenderedRequest] = (0, import_react71.useState)();
34988
+ const handleRequestRendered = (0, import_react71.useCallback)((view) => {
34192
34989
  const openedAt = openedAtRef.current;
34193
34990
  if (openedAt === void 0) return;
34194
- setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: view === "map" ? "flow_graph" : "operations" });
34991
+ setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: ANALYTICS_REQUEST_VIEWS[view] });
34195
34992
  }, []);
34196
- const handleViewChange = (0, import_react70.useCallback)(() => {
34993
+ const handleViewChange = (0, import_react71.useCallback)(() => {
34197
34994
  openedAtRef.current = performance.now();
34198
34995
  }, []);
34199
34996
  useRequestOpenAnalytics({
@@ -34202,28 +34999,28 @@ var SpansListPage = () => {
34202
34999
  view: renderedRequest?.view ?? "operations"
34203
35000
  });
34204
35001
  const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
34205
- const handleOperationShown = (0, import_react70.useCallback)((spanId, view) => {
35002
+ const handleOperationShown = (0, import_react71.useCallback)((spanId, view) => {
34206
35003
  setShownOperation({ spanId, view });
34207
35004
  }, []);
34208
- const shown = (0, import_react70.useMemo)(() => {
35005
+ const shown = (0, import_react71.useMemo)(() => {
34209
35006
  if (shownOperation === void 0) return;
34210
35007
  const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
34211
35008
  return span && { span, view: shownOperation.view };
34212
35009
  }, [shownOperation, treeSpans]);
34213
35010
  useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
34214
- const handleRetry = (0, import_react70.useCallback)(() => {
35011
+ const handleRetry = (0, import_react71.useCallback)(() => {
34215
35012
  checkStatus();
34216
35013
  fetchForward();
34217
35014
  }, [checkStatus, fetchForward]);
34218
- const handleEnable = (0, import_react70.useCallback)(async () => {
35015
+ const handleEnable = (0, import_react71.useCallback)(async () => {
34219
35016
  await api.setStatus({ status: "ENABLED" });
34220
35017
  clearFetchError();
34221
35018
  checkStatus();
34222
35019
  }, [api, checkStatus, clearFetchError]);
34223
- const isDelayedRefetchRef = (0, import_react70.useRef)(false);
34224
- const delayedRefetchTimerRef = (0, import_react70.useRef)();
34225
- const prevFetchingForwardRef = (0, import_react70.useRef)(false);
34226
- (0, import_react70.useEffect)(() => {
35020
+ const isDelayedRefetchRef = (0, import_react71.useRef)(false);
35021
+ const delayedRefetchTimerRef = (0, import_react71.useRef)();
35022
+ const prevFetchingForwardRef = (0, import_react71.useRef)(false);
35023
+ (0, import_react71.useEffect)(() => {
34227
35024
  const wasFetching = prevFetchingForwardRef.current;
34228
35025
  prevFetchingForwardRef.current = fetchingForward;
34229
35026
  if (wasFetching && !fetchingForward) {
@@ -34244,10 +35041,10 @@ var SpansListPage = () => {
34244
35041
  switch (phase) {
34245
35042
  case "CHECKING_STATUS":
34246
35043
  case "CONNECTING_WS": {
34247
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(StatusMessage, { phase });
35044
+ return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(StatusMessage, { phase });
34248
35045
  }
34249
35046
  case "DISABLED": {
34250
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35047
+ return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
34251
35048
  StatusMessage,
34252
35049
  {
34253
35050
  onEnable: handleEnable,
@@ -34256,7 +35053,7 @@ var SpansListPage = () => {
34256
35053
  );
34257
35054
  }
34258
35055
  case "INCOMPATIBLE": {
34259
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35056
+ return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
34260
35057
  StatusMessage,
34261
35058
  {
34262
35059
  localstackVersion,
@@ -34267,12 +35064,12 @@ var SpansListPage = () => {
34267
35064
  }
34268
35065
  case "LIVE": {
34269
35066
  if (workerError) {
34270
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(WorkerErrorMessage, { error: workerError, onRetry: retryWorker });
35067
+ return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(WorkerErrorMessage, { error: workerError, onRetry: retryWorker });
34271
35068
  }
34272
35069
  break;
34273
35070
  }
34274
35071
  case "UNREACHABLE": {
34275
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35072
+ return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
34276
35073
  StatusMessage,
34277
35074
  {
34278
35075
  onRetry: handleRetry,
@@ -34281,9 +35078,9 @@ var SpansListPage = () => {
34281
35078
  );
34282
35079
  }
34283
35080
  }
34284
- return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(import_material29.Paper, { square: true, sx: { ...THEMED_SCROLLBARS, display: "flex", flexDirection: "row", flexGrow: 1, minHeight: 0, overflow: "hidden" }, children: [
34285
- /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(
34286
- import_material29.Box,
35081
+ return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_material30.Paper, { square: true, sx: { ...THEMED_SCROLLBARS, display: "flex", flexDirection: "row", flexGrow: 1, minHeight: 0, overflow: "hidden" }, children: [
35082
+ /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(
35083
+ import_material30.Box,
34287
35084
  {
34288
35085
  "data-testid": SPANS_LIST_PAGE_TEST_ID,
34289
35086
  sx: {
@@ -34296,7 +35093,7 @@ var SpansListPage = () => {
34296
35093
  overflow: "hidden"
34297
35094
  },
34298
35095
  children: [
34299
- /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35096
+ /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
34300
35097
  EmulatorVersionBanner,
34301
35098
  {
34302
35099
  compatibility: bannerDismissed && versionCompatibility === "warning" ? "ok" : versionCompatibility,
@@ -34306,7 +35103,7 @@ var SpansListPage = () => {
34306
35103
  } : void 0
34307
35104
  }
34308
35105
  ),
34309
- /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35106
+ /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
34310
35107
  SpansList,
34311
35108
  {
34312
35109
  clearingSpans,
@@ -34333,7 +35130,7 @@ var SpansListPage = () => {
34333
35130
  ]
34334
35131
  }
34335
35132
  ),
34336
- selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime153.jsx)(
35133
+ selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(
34337
35134
  TraceSidebar,
34338
35135
  {
34339
35136
  onClose: closeSidebar,