@localstack/appinspector-ui 1.0.219 → 1.0.221

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.js CHANGED
@@ -2421,8 +2421,8 @@ var init_event_streams = __esm({
2421
2421
  });
2422
2422
 
2423
2423
  // src/pages/spans-list-page.tsx
2424
- import { Box as Box24, Paper as Paper2 } from "@mui/material";
2425
- import { useCallback as useCallback12, useEffect as useEffect28, useMemo as useMemo13, useRef as useRef24, useState as useState24 } from "react";
2424
+ import { Box as Box25, Paper as Paper3 } from "@mui/material";
2425
+ import { useCallback as useCallback14, useEffect as useEffect29, useMemo as useMemo14, useRef as useRef25, useState as useState26 } from "react";
2426
2426
 
2427
2427
  // src/api/errors.ts
2428
2428
  var AppInspectorDisabledError = class extends Error {
@@ -2548,6 +2548,21 @@ var WATERFALL_AXIS_LABEL_TEST_ID = "waterfall-axis-label";
2548
2548
  var WATERFALL_TREE_VIEW_BUTTON_TEST_ID = "waterfall-tree-view-button";
2549
2549
  var WATERFALL_LIST_VIEW_BUTTON_TEST_ID = "waterfall-list-view-button";
2550
2550
  var WATERFALL_ROW_OFFSET_TEST_ID = "waterfall-row-offset";
2551
+ var TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID = "trace-sidebar-sequence-button";
2552
+ var SEQUENCE_DIAGRAM_TEST_ID = "sequence-diagram";
2553
+ var SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID = "sequence-diagram-participant";
2554
+ var SEQUENCE_DIAGRAM_MESSAGE_TEST_ID = "sequence-diagram-message";
2555
+ var SEQUENCE_DIAGRAM_RETURN_TEST_ID = "sequence-diagram-return";
2556
+ var SEQUENCE_DIAGRAM_ARROW_TEST_ID = "sequence-diagram-arrow";
2557
+ var SEQUENCE_DIAGRAM_SEGMENT_TEST_ID = "sequence-diagram-segment";
2558
+ var SEQUENCE_DIAGRAM_HOVER_CARD_TEST_ID = "sequence-diagram-hover-card";
2559
+ var SEQUENCE_DIAGRAM_TOGGLE_TEST_ID = "sequence-diagram-toggle";
2560
+ var SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID = "sequence-diagram-zoom-in-button";
2561
+ var SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID = "sequence-diagram-zoom-out-button";
2562
+ var SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID = "sequence-diagram-zoom-reset-button";
2563
+ var SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID = "sequence-diagram-zoom-fit-button";
2564
+ var SEQUENCE_DIAGRAM_MINIMAP_TEST_ID = "sequence-diagram-minimap";
2565
+ var SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID = "sequence-diagram-minimap-toggle";
2551
2566
 
2552
2567
  // src/utils/emulator-version.ts
2553
2568
  var import_semver = __toESM(require_semver2(), 1);
@@ -7170,12 +7185,12 @@ var isColorString = (type, testProp) => (v) => {
7170
7185
  var splitColor = (aName, bName, cName) => (v) => {
7171
7186
  if (!isString(v))
7172
7187
  return v;
7173
- const [a3, b3, c3, alpha8] = v.match(floatRegex);
7188
+ const [a3, b3, c3, alpha9] = v.match(floatRegex);
7174
7189
  return {
7175
7190
  [aName]: parseFloat(a3),
7176
7191
  [bName]: parseFloat(b3),
7177
7192
  [cName]: parseFloat(c3),
7178
- alpha: alpha8 !== void 0 ? parseFloat(alpha8) : 1
7193
+ alpha: alpha9 !== void 0 ? parseFloat(alpha9) : 1
7179
7194
  };
7180
7195
  };
7181
7196
 
@@ -8289,7 +8304,7 @@ function hueToRgb(p, q, t) {
8289
8304
  return p + (q - p) * (2 / 3 - t) * 6;
8290
8305
  return p;
8291
8306
  }
8292
- function hslaToRgba({ hue, saturation, lightness, alpha: alpha8 }) {
8307
+ function hslaToRgba({ hue, saturation, lightness, alpha: alpha9 }) {
8293
8308
  hue /= 360;
8294
8309
  saturation /= 100;
8295
8310
  lightness /= 100;
@@ -8309,7 +8324,7 @@ function hslaToRgba({ hue, saturation, lightness, alpha: alpha8 }) {
8309
8324
  red: Math.round(red * 255),
8310
8325
  green: Math.round(green * 255),
8311
8326
  blue: Math.round(blue * 255),
8312
- alpha: alpha8
8327
+ alpha: alpha9
8313
8328
  };
8314
8329
  }
8315
8330
 
@@ -13160,10 +13175,10 @@ var getOperationLabel = (span) => {
13160
13175
 
13161
13176
  // src/components/operation-name.tsx
13162
13177
  import { jsx as jsx4, jsxs } from "react/jsx-runtime";
13163
- var OperationName = ({ span }) => {
13178
+ var OperationName = ({ span, tooltip = true }) => {
13164
13179
  const label = getOperationLabel(span);
13165
- if (label === span.operation_name) {
13166
- return /* @__PURE__ */ jsx4("span", { title: label, children: label });
13180
+ if (label === span.operation_name || !tooltip) {
13181
+ return /* @__PURE__ */ jsx4("span", { title: tooltip ? label : void 0, children: label });
13167
13182
  }
13168
13183
  return /* @__PURE__ */ jsx4(
13169
13184
  Tooltip,
@@ -16989,9 +17004,9 @@ var getTraceBounds = (spans) => {
16989
17004
 
16990
17005
  // src/components/trace-panel/trace-sidebar.tsx
16991
17006
  import { Close as Close4, CloseFullscreen, OpenInFull } from "@mui/icons-material";
16992
- import { Box as Box22, IconButton as IconButton8, ToggleButton as ToggleButton3, ToggleButtonGroup as ToggleButtonGroup3, Typography as Typography15 } from "@mui/material";
17007
+ import { Box as Box23, IconButton as IconButton9, ToggleButton as ToggleButton3, ToggleButtonGroup as ToggleButtonGroup3, Typography as Typography16 } from "@mui/material";
16993
17008
  import { ReactFlowProvider } from "@xyflow/react";
16994
- import * as React125 from "react";
17009
+ import * as React127 from "react";
16995
17010
 
16996
17011
  // src/components/event-details/event-details.tsx
16997
17012
  import { Cancel as Cancel5, Close as Close3, GppBad as GppBad2, GppMaybe as GppMaybe6 } from "@mui/icons-material";
@@ -17000,7 +17015,7 @@ import { useEffect as useEffect17, useMemo as useMemo10, useRef as useRef13, use
17000
17015
 
17001
17016
  // src/dev-settings.tsx
17002
17017
  import * as React122 from "react";
17003
- var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", succeededIconColor: "green", waterfallLayout: "tree" };
17018
+ var DEFAULT_DEV_SETTINGS = { allowedPillWhenSucceeded: "hide", headingPills: "resource-line", sequenceBlocks: "detached", sequenceClickTargets: "arrows-and-segments", sequenceHoverCard: "on", succeededIconColor: "green", waterfallLayout: "tree" };
17004
17019
  var DevSettingsContext = React122.createContext(DEFAULT_DEV_SETTINGS);
17005
17020
  var useDevSettings = () => React122.useContext(DevSettingsContext);
17006
17021
 
@@ -29501,6 +29516,7 @@ var createApiClient = ({ localstackEndpoint }) => {
29501
29516
  method: "POST"
29502
29517
  }
29503
29518
  });
29519
+ analyticsLogger.info(`Sent ${request.event}`, request.payload);
29504
29520
  } catch (error) {
29505
29521
  analyticsLogger.warn("Failed to post analytics event:", { error, event: request.event });
29506
29522
  }
@@ -31796,14 +31812,19 @@ var Field = ({ children, copy, label, testId, testIdOn = "value" }) => /* @__PUR
31796
31812
  ] })
31797
31813
  ] });
31798
31814
  var EmptyTab = ({ children }) => /* @__PURE__ */ jsx145(Typography13, { color: "text.secondary", variant: "body2", children });
31799
- var EventDetails = ({ onClose, onOperationShown, selectedEvent }) => {
31815
+ var EventDetails = ({ onClose, onOperationShown, requestedTab, selectedEvent }) => {
31800
31816
  const eventGroups = useMemo10(
31801
31817
  () => getEventGroupsByType(selectedEvent?.events ?? []),
31802
31818
  [selectedEvent?.events]
31803
31819
  );
31804
31820
  const { headingPills } = useDevSettings();
31805
31821
  const [parseNestedJson, setParseNestedJson] = useState14(true);
31806
- const [tab, setTab] = useState14("details");
31822
+ const [tab, setTab] = useState14(requestedTab?.view ?? "details");
31823
+ const [appliedRequest, setAppliedRequest] = useState14(requestedTab);
31824
+ if (requestedTab !== appliedRequest) {
31825
+ setAppliedRequest(requestedTab);
31826
+ if (requestedTab) setTab(requestedTab.view);
31827
+ }
31807
31828
  const optionalTabs = selectedEvent ? getOptionalTabs(selectedEvent, eventGroups) : void 0;
31808
31829
  const activeTab = optionalTabs && OPTIONAL_TABS.some((optional) => optional === tab && !optionalTabs[optional]) ? "details" : tab;
31809
31830
  const onOperationShownRef = useRef13(onOperationShown);
@@ -32550,10 +32571,40 @@ var TraceGraph = ({
32550
32571
  ] });
32551
32572
  };
32552
32573
 
32574
+ // src/hooks/use-content-width.ts
32575
+ import * as React124 from "react";
32576
+ var contentWidth = (element) => {
32577
+ const style = getComputedStyle(element);
32578
+ const edges = ["borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight"];
32579
+ return edges.reduce((width, edge) => width - (Number.parseFloat(style[edge]) || 0), element.getBoundingClientRect().width);
32580
+ };
32581
+ var useContentWidth = (elementRef, parent = false) => {
32582
+ const [width, setWidth] = React124.useState(0);
32583
+ React124.useLayoutEffect(() => {
32584
+ const element = parent ? elementRef.current?.parentElement : elementRef.current;
32585
+ if (!element) return;
32586
+ setWidth(contentWidth(element));
32587
+ let frame2 = 0;
32588
+ const observer = new ResizeObserver(([entry]) => {
32589
+ if (!entry) return;
32590
+ cancelAnimationFrame(frame2);
32591
+ frame2 = requestAnimationFrame(() => {
32592
+ setWidth(entry.contentRect.width);
32593
+ });
32594
+ });
32595
+ observer.observe(element);
32596
+ return () => {
32597
+ cancelAnimationFrame(frame2);
32598
+ observer.disconnect();
32599
+ };
32600
+ }, [elementRef, parent]);
32601
+ return width;
32602
+ };
32603
+
32553
32604
  // src/hooks/use-local-storage.tsx
32554
- import { useCallback as useCallback8, useEffect as useEffect19, useState as useState17 } from "react";
32605
+ import { useCallback as useCallback8, useEffect as useEffect19, useState as useState18 } from "react";
32555
32606
  function useLocalStorage(key, initialValue) {
32556
- const [storedValue, setStoredValue] = useState17(() => {
32607
+ const [storedValue, setStoredValue] = useState18(() => {
32557
32608
  try {
32558
32609
  const item = globalThis.localStorage.getItem(key);
32559
32610
  return item ? JSON.parse(item) : initialValue;
@@ -32595,11 +32646,118 @@ function useLocalStorage(key, initialValue) {
32595
32646
  return [storedValue, setValue];
32596
32647
  }
32597
32648
 
32649
+ // src/components/trace-panel/sequence-diagram.tsx
32650
+ import { keyframes as keyframes3 } from "@emotion/react";
32651
+ import { Cancel as Cancel8, FitScreen as FitScreen2, GppMaybe as GppMaybe9, KeyboardArrowDown as KeyboardArrowDown3, KeyboardArrowRight as KeyboardArrowRight3, KeyboardArrowUp, ZoomIn, ZoomOut } from "@mui/icons-material";
32652
+ import { Box as Box22, ButtonBase as ButtonBase2, Collapse, IconButton as IconButton8, Paper as Paper2, Popper, Tooltip as Tooltip7, Typography as Typography15 } from "@mui/material";
32653
+ import { alpha as alpha8, useTheme as useTheme7 } from "@mui/material/styles";
32654
+ import * as React126 from "react";
32655
+
32656
+ // src/components/trace-panel/sequence-layout.ts
32657
+ var CALLER_KEY = "";
32658
+ var resourceOf = (span) => {
32659
+ const resource = shortResourceName(span.resource_name, span.arn);
32660
+ return resource === "*" ? "" : resource;
32661
+ };
32662
+ var participantOf = (span, mode, callers) => {
32663
+ const resource = mode === "resource" || mode === "caller" && callers.has(`${span.service_name}/${resourceOf(span)}`) ? resourceOf(span) : "";
32664
+ return { key: `${span.service_name}/${resource}`, label: resource, resource, service: span.service_name };
32665
+ };
32666
+ var countDescendants = (node) => node.children.reduce((sum2, child) => sum2 + 1 + countDescendants(child), 0);
32667
+ var layoutSequence = (spans, mode, folded) => {
32668
+ const tree = buildTraceTree(spans);
32669
+ const visible = [];
32670
+ const visit = (nodes2, parent) => {
32671
+ for (const node of nodes2) {
32672
+ visible.push({ node, parent });
32673
+ if (!folded.has(node.span.span_id)) visit(node.children, node.span);
32674
+ }
32675
+ };
32676
+ visit(tree.roots);
32677
+ visible.sort((left, right) => compareNano(left.node.span.start_time_unix_nano, right.node.span.start_time_unix_nano));
32678
+ const callers = new Set(spans.filter((span) => tree.parentOf.has(span.span_id)).flatMap((span) => {
32679
+ const parent = spans.find((candidate) => candidate.span_id === tree.parentOf.get(span.span_id));
32680
+ return parent ? [`${parent.service_name}/${resourceOf(parent)}`] : [];
32681
+ }));
32682
+ const participants = [{ key: CALLER_KEY, label: "", resource: "", service: "" }];
32683
+ const indexOf = /* @__PURE__ */ new Map([[CALLER_KEY, 0]]);
32684
+ const place = (participant) => {
32685
+ const known = indexOf.get(participant.key);
32686
+ if (known !== void 0) return known;
32687
+ participants.push(participant);
32688
+ indexOf.set(participant.key, participants.length - 1);
32689
+ return participants.length - 1;
32690
+ };
32691
+ const rowOf = /* @__PURE__ */ new Map();
32692
+ const parentRows = [];
32693
+ const messages = [];
32694
+ for (const [row, { node, parent }] of visible.entries()) {
32695
+ const { span } = node;
32696
+ const issues = getSpanIssues(span);
32697
+ const from = parent ? place(participantOf(parent, mode, callers)) : 0;
32698
+ const hasChildren = node.children.length > 0;
32699
+ parentRows.push(parent ? rowOf.get(parent.span_id) : void 0);
32700
+ messages.push({
32701
+ async: parent !== void 0 && span.parent_span_id !== parent.span_id,
32702
+ depth: 0,
32703
+ descendantCount: countDescendants(node),
32704
+ endRow: row,
32705
+ error: issues.error,
32706
+ folded: hasChildren && folded.has(span.span_id),
32707
+ from,
32708
+ fromDepth: 0,
32709
+ resource: resourceOf(span),
32710
+ returnLevel: 0,
32711
+ span,
32712
+ to: place(participantOf(span, mode, callers)),
32713
+ warning: issues.warning
32714
+ });
32715
+ rowOf.set(span.span_id, row);
32716
+ }
32717
+ for (let row = messages.length - 1; row >= 0; row--) {
32718
+ const message = messages[row];
32719
+ const parent = messages[parentRows[row] ?? -1];
32720
+ if (message && parent && !message.async) parent.endRow = Math.max(parent.endRow, message.endRow);
32721
+ }
32722
+ const endings = messages.map(() => 0);
32723
+ for (const message of messages.toReversed()) {
32724
+ message.returnLevel = endings[message.endRow] ?? 0;
32725
+ endings[message.endRow] = message.returnLevel + 1;
32726
+ }
32727
+ for (const [row, message] of messages.entries()) {
32728
+ message.depth = messages.slice(0, row).filter((earlier) => earlier.to === message.to && earlier.endRow >= row).length;
32729
+ message.fromDepth = messages[parentRows[row] ?? -1]?.depth ?? 0;
32730
+ }
32731
+ const prefix = sharedPrefix(participants.map((participant) => participant.resource));
32732
+ const strip2 = (name) => name.startsWith(prefix) ? name.slice(prefix.length) : name;
32733
+ return {
32734
+ endings,
32735
+ messages: messages.map((message) => ({ ...message, resource: strip2(message.resource) })),
32736
+ participants: participants.map((participant) => ({ ...participant, label: strip2(participant.resource) }))
32737
+ };
32738
+ };
32739
+ var sharedPrefix = (names2) => {
32740
+ const counts = /* @__PURE__ */ new Map();
32741
+ for (const name of new Set(names2)) {
32742
+ for (let index = 0; index < name.length - 1; index++) {
32743
+ if ("-_/.".includes(name.charAt(index))) {
32744
+ const prefix = name.slice(0, index + 1);
32745
+ counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
32746
+ }
32747
+ }
32748
+ }
32749
+ let best = "";
32750
+ for (const [prefix, count2] of counts) {
32751
+ if (count2 >= 2 && count2 * prefix.length > (counts.get(best) ?? 0) * best.length) best = prefix;
32752
+ }
32753
+ return best;
32754
+ };
32755
+
32598
32756
  // src/components/trace-panel/waterfall.tsx
32599
32757
  import { AccountTreeOutlined, Cancel as Cancel7, FormatListBulleted, GppMaybe as GppMaybe8, KeyboardArrowDown as KeyboardArrowDown2, KeyboardArrowRight as KeyboardArrowRight2 } from "@mui/icons-material";
32600
32758
  import { Box as Box21, ButtonBase, ToggleButton as ToggleButton2, ToggleButtonGroup as ToggleButtonGroup2, Typography as Typography14 } from "@mui/material";
32601
32759
  import { alpha as alpha7 } from "@mui/material/styles";
32602
- import * as React124 from "react";
32760
+ import * as React125 from "react";
32603
32761
 
32604
32762
  // src/components/trace-panel/axis-ticks.ts
32605
32763
  var getAxisTicks = (durationMs, maxIntervals) => {
@@ -32691,25 +32849,10 @@ var Line = ({ height, left, top = 0, width = 1 }) => /* @__PURE__ */ jsx150(
32691
32849
  );
32692
32850
  var AXIS_HEIGHT = 22;
32693
32851
  var TRACK_INSET = 1.5;
32694
- var useWidth = (elementRef) => {
32695
- const [width, setWidth] = React124.useState(0);
32696
- React124.useLayoutEffect(() => {
32697
- const element = elementRef.current;
32698
- if (!element) return;
32699
- const observer = new ResizeObserver(([entry]) => {
32700
- if (entry) setWidth(entry.contentRect.width);
32701
- });
32702
- observer.observe(element);
32703
- return () => {
32704
- observer.disconnect();
32705
- };
32706
- }, [elementRef]);
32707
- return width;
32708
- };
32709
32852
  var LABEL_TRANSFORMS = { center: "translateX(-50%)", end: "translateX(-100%)", start: void 0 };
32710
32853
  var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
32711
- const trackRef = React124.useRef(null);
32712
- const width = useWidth(trackRef);
32854
+ const trackRef = React125.useRef(null);
32855
+ const width = useContentWidth(trackRef);
32713
32856
  const { labels: labels2, marks } = layoutAxis(durationMs, width);
32714
32857
  return /* @__PURE__ */ jsxs137(
32715
32858
  Box21,
@@ -32777,15 +32920,15 @@ var WaterfallAxis = ({ durationMs, flat, onFlatChange }) => {
32777
32920
  );
32778
32921
  };
32779
32922
  var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32780
- const [collapsed, setCollapsed] = React124.useState(() => /* @__PURE__ */ new Set());
32781
- const containerRef = React124.useRef(null);
32782
- const tree = React124.useMemo(() => buildTraceTree(spans), [spans]);
32783
- const bounds = React124.useMemo(() => getTraceBounds(spans), [spans]);
32923
+ const [collapsed, setCollapsed] = React125.useState(() => /* @__PURE__ */ new Set());
32924
+ const containerRef = React125.useRef(null);
32925
+ const tree = React125.useMemo(() => buildTraceTree(spans), [spans]);
32926
+ const bounds = React125.useMemo(() => getTraceBounds(spans), [spans]);
32784
32927
  const { waterfallLayout } = useDevSettings();
32785
- const [toggledFlat, setToggledFlat] = React124.useState(false);
32928
+ const [toggledFlat, setToggledFlat] = React125.useState(false);
32786
32929
  const flat = waterfallLayout === "list" || waterfallLayout === "toggle" && toggledFlat;
32787
- const rows = React124.useMemo(() => flat ? flattenAll(tree.roots) : flatten(tree.roots, collapsed), [tree, collapsed, flat]);
32788
- const [revealed, setRevealed] = React124.useState();
32930
+ const rows = React125.useMemo(() => flat ? flattenAll(tree.roots) : flatten(tree.roots, collapsed), [tree, collapsed, flat]);
32931
+ const [revealed, setRevealed] = React125.useState();
32789
32932
  if (selectedSpanId !== revealed) {
32790
32933
  setRevealed(selectedSpanId);
32791
32934
  const ancestors = /* @__PURE__ */ new Set();
@@ -32794,7 +32937,7 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32794
32937
  setCollapsed((current) => new Set([...current].filter((id2) => !ancestors.has(id2))));
32795
32938
  }
32796
32939
  }
32797
- React124.useEffect(() => {
32940
+ React125.useEffect(() => {
32798
32941
  if (selectedSpanId === void 0) return;
32799
32942
  containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest" });
32800
32943
  }, [selectedSpanId]);
@@ -32969,8 +33112,661 @@ var Waterfall = ({ onSelectSpan, selectedSpanId, spanMatches, spans }) => {
32969
33112
  ] });
32970
33113
  };
32971
33114
 
33115
+ // src/components/trace-panel/sequence-diagram.tsx
33116
+ import { Fragment as Fragment15, jsx as jsx151, jsxs as jsxs138 } from "react/jsx-runtime";
33117
+ var COLUMN_WIDTH = 136;
33118
+ var HEADER_HEIGHT = 52;
33119
+ var LABEL_TOP = 1;
33120
+ var LABEL_HEIGHT = 18;
33121
+ var ARROW_Y = 24;
33122
+ var ARROW_HEAD = 5;
33123
+ var SELF_LOOP = 22;
33124
+ var BLOCK_WIDTH = 8;
33125
+ var BLOCK_OFFSET = BLOCK_WIDTH + 6;
33126
+ var BLOCK_OVERLAP_OFFSET = BLOCK_WIDTH * 3 / 4;
33127
+ var HATCH_MARGIN = 4;
33128
+ var BLOCK_OVERHANG = 4;
33129
+ var BLOCK_MIN_HEIGHT = 24;
33130
+ var BLOCK_TAIL = BLOCK_MIN_HEIGHT - BLOCK_OVERHANG;
33131
+ var BLOCK_RADIUS = 2;
33132
+ var RETURN_GAP = 10;
33133
+ var ROW_GAP = 8;
33134
+ var rowHeight = (endings) => ARROW_Y + (endings === 0 ? 0 : BLOCK_TAIL + (endings - 1) * RETURN_GAP) + ROW_GAP;
33135
+ var SLIDE_MS = 200;
33136
+ var SLIDE = `${String(SLIDE_MS)}ms cubic-bezier(0.4, 0, 0.2, 1)`;
33137
+ var SLIDE_TRANSITION = `transform ${SLIDE}, height ${SLIDE}`;
33138
+ var RETURN_HIT_HEIGHT = 9;
33139
+ var ARROW_HIT_HEIGHT = 15;
33140
+ var BLOCK_HIT_MARGIN = 3;
33141
+ var enter = keyframes3`from { opacity: 0 }`;
33142
+ var ENTER_ANIMATION = `${enter} ${SLIDE}`;
33143
+ var slideTo = (y, entering = false) => ({
33144
+ animation: entering ? ENTER_ANIMATION : void 0,
33145
+ transform: `translateY(${String(y)}px)`,
33146
+ transition: SLIDE_TRANSITION
33147
+ });
33148
+ var blockRect = (height) => ({ height, style: { height, transition: SLIDE_TRANSITION }, y: 0 });
33149
+ var hatchId = (color2) => `sequence-hatch-${color2.replace("#", "")}`;
33150
+ var lifelineX = (index) => index * COLUMN_WIDTH + COLUMN_WIDTH / 2;
33151
+ var blockX = (index, depth, offset) => lifelineX(index) + depth * offset;
33152
+ var Arrow = ({ blockOffset, blockWidth, color: color2, entering, message, top }) => {
33153
+ const y = ARROW_Y;
33154
+ const dash = message.async ? "4 3" : void 0;
33155
+ const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
33156
+ const fromX = blockX(message.from, message.fromDepth, blockOffset);
33157
+ const toX = blockX(message.to, message.depth, blockOffset);
33158
+ if (message.from === message.to) {
33159
+ const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
33160
+ const endX2 = toX + blockWidth / 2;
33161
+ return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(top, entering), children: [
33162
+ /* @__PURE__ */ jsx151("path", { d: `M${String(fromX + fromHalf)} ${String(y - 6)}H${String(loopX)}v8H${String(endX2 + ARROW_HEAD)}`, fill: "none", strokeDasharray: dash }),
33163
+ /* @__PURE__ */ jsx151("path", { d: `M${String(endX2)} ${String(y + 2)}l${String(ARROW_HEAD)} -3v6z`, fill: color2 })
33164
+ ] });
33165
+ }
33166
+ const direction = toX > fromX ? 1 : -1;
33167
+ const startX = fromX + direction * fromHalf;
33168
+ const endX = toX - direction * blockWidth / 2;
33169
+ return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(top, entering), children: [
33170
+ /* @__PURE__ */ jsx151("line", { strokeDasharray: dash, x1: startX, x2: endX - direction * ARROW_HEAD, y1: y, y2: y }),
33171
+ /* @__PURE__ */ jsx151("path", { d: `M${String(endX)} ${String(y)}l${String(-direction * ARROW_HEAD)} -3v6z`, fill: color2 })
33172
+ ] });
33173
+ };
33174
+ var arrowHitBox = (message, blockWidth, blockOffset, height) => {
33175
+ const fromHalf = message.from === 0 || message.async ? 0 : blockWidth / 2;
33176
+ const fromX = blockX(message.from, message.fromDepth, blockOffset);
33177
+ const toX = blockX(message.to, message.depth, blockOffset);
33178
+ if (message.from === message.to) {
33179
+ const loopX = Math.max(fromX, toX) + blockWidth / 2 + SELF_LOOP;
33180
+ const left = Math.min(fromX + fromHalf, toX + blockWidth / 2);
33181
+ return { height, left, top: ARROW_Y - 2 - height / 2, width: loopX - left };
33182
+ }
33183
+ const direction = toX > fromX ? 1 : -1;
33184
+ const startX = fromX + direction * fromHalf;
33185
+ const endX = toX - direction * blockWidth / 2;
33186
+ return { height, left: Math.min(startX, endX), top: ARROW_Y - height / 2, width: Math.abs(endX - startX) };
33187
+ };
33188
+ var hasReturn = (message) => !message.async && message.from !== message.to;
33189
+ var ReturnArrow = ({ blockOffset, blockWidth, color: color2, entering, message, y: lineY }) => {
33190
+ const y = 0;
33191
+ const fromX = blockX(message.to, message.depth, blockOffset);
33192
+ const toX = blockX(message.from, message.fromDepth, blockOffset);
33193
+ const direction = toX > fromX ? 1 : -1;
33194
+ const startX = fromX + direction * blockWidth / 2;
33195
+ const endX = toX - direction * (message.from === 0 ? 0 : blockWidth / 2);
33196
+ return /* @__PURE__ */ jsxs138("g", { stroke: color2, style: slideTo(lineY, entering), children: [
33197
+ /* @__PURE__ */ jsx151("line", { strokeDasharray: "3 3", x1: startX, x2: endX, y1: y, y2: y }),
33198
+ /* @__PURE__ */ jsx151("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" })
33199
+ ] });
33200
+ };
33201
+ var MIN_ZOOM = 0.25;
33202
+ var MAX_ZOOM = 1;
33203
+ var ZOOM_STEP = 1.25;
33204
+ var WHEEL_ZOOM_SPEED = 0.01;
33205
+ var MINIMAP_WIDTH = 168;
33206
+ var MINIMAP_MAX_HEIGHT = 160;
33207
+ var MINIMAP_MAX_VIEW_SHARE = 1 / 3;
33208
+ var WIDGET_MARGIN = 16;
33209
+ var BOTTOM_ROOM = 44 + WIDGET_MARGIN + 16;
33210
+ var MINIMAP_OPEN_STORAGE_KEY = "appinspector-sequence-minimap-open";
33211
+ var bodyIds = 0;
33212
+ var useBodyId = () => {
33213
+ const [id2] = React126.useState(() => `sequence-body-${String(++bodyIds)}`);
33214
+ return id2;
33215
+ };
33216
+ var clampZoom = (zoom) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, zoom));
33217
+ var useZoom = (scrollRef, areaRef, widgetRef, enabled) => {
33218
+ const [zoom, setZoom] = React126.useState(1);
33219
+ const zoomRef = React126.useRef(zoom);
33220
+ const anchorRef = React126.useRef();
33221
+ const zoomTo = React126.useCallback((next, x, y) => {
33222
+ const element = scrollRef.current;
33223
+ const clamped = clampZoom(next);
33224
+ if (!element || clamped === zoomRef.current) return;
33225
+ anchorRef.current = { ratio: clamped / zoomRef.current, x: x ?? element.clientWidth / 2, y: y ?? element.clientHeight / 2 };
33226
+ zoomRef.current = clamped;
33227
+ setZoom(clamped);
33228
+ }, [scrollRef]);
33229
+ React126.useLayoutEffect(() => {
33230
+ const element = scrollRef.current;
33231
+ const anchor = anchorRef.current;
33232
+ if (!element || !anchor) return;
33233
+ element.scrollLeft = (element.scrollLeft + anchor.x) * anchor.ratio - anchor.x;
33234
+ element.scrollTop = (element.scrollTop + anchor.y) * anchor.ratio - anchor.y;
33235
+ anchorRef.current = void 0;
33236
+ }, [scrollRef, zoom]);
33237
+ React126.useEffect(() => {
33238
+ const element = scrollRef.current;
33239
+ const area = areaRef.current;
33240
+ if (!element || !area || !enabled) return;
33241
+ const pointer = (event) => {
33242
+ if (event.target instanceof Node && widgetRef.current?.contains(event.target)) return [];
33243
+ const bounds = element.getBoundingClientRect();
33244
+ return [event.clientX - bounds.left, event.clientY - bounds.top];
33245
+ };
33246
+ const handleWheel = (event) => {
33247
+ if (!event.ctrlKey && !event.metaKey) return;
33248
+ event.preventDefault();
33249
+ zoomTo(zoomRef.current * Math.exp(-event.deltaY * WHEEL_ZOOM_SPEED), ...pointer(event));
33250
+ };
33251
+ let gestureStart = 1;
33252
+ const handleGestureStart = (event) => {
33253
+ event.preventDefault();
33254
+ gestureStart = zoomRef.current;
33255
+ };
33256
+ const handleGestureChange = (event) => {
33257
+ event.preventDefault();
33258
+ const { scale: scale2 } = event;
33259
+ zoomTo(gestureStart * scale2, ...pointer(event));
33260
+ };
33261
+ area.addEventListener("wheel", handleWheel, { passive: false });
33262
+ area.addEventListener("gesturestart", handleGestureStart);
33263
+ area.addEventListener("gesturechange", handleGestureChange);
33264
+ return () => {
33265
+ area.removeEventListener("wheel", handleWheel);
33266
+ area.removeEventListener("gesturestart", handleGestureStart);
33267
+ area.removeEventListener("gesturechange", handleGestureChange);
33268
+ };
33269
+ }, [scrollRef, areaRef, widgetRef, enabled, zoomTo]);
33270
+ return { zoom, zoomTo };
33271
+ };
33272
+ var lifelineName = (participant) => participant.service === "" ? "Caller" : [getServiceDisplayName(participant.service), participant.label].filter(Boolean).join(" ");
33273
+ var hoverDirection = (hover) => {
33274
+ if (hover.kind === "segment") return `Active on ${hover.to}`;
33275
+ const kind = hover.kind === "response" ? "Response" : hover.message.async ? "Async request" : "Request";
33276
+ return `${kind} \xB7 ${hover.from} \u2192 ${hover.to}`;
33277
+ };
33278
+ var ArrowHoverCard = ({ hover }) => {
33279
+ const { span } = hover.message;
33280
+ 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);
33281
+ 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;
33282
+ const anchor = { getBoundingClientRect: () => new DOMRect(hover.x, hover.y, 0, 0) };
33283
+ return /* @__PURE__ */ jsx151(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__ */ jsxs138(Paper2, { elevation: 6, sx: { display: "flex", flexDirection: "column", gap: 0.75, maxWidth: 360, px: 1.5, py: 1 }, children: [
33284
+ /* @__PURE__ */ jsx151(OperationIdentity, { arn: span.arn, density: "stacked", iconSize: 24, operation: /* @__PURE__ */ jsx151(OperationName, { span, tooltip: false }), resourceName: span.resource_name, service: span.service_name }),
33285
+ getOperationLabel(span) !== span.operation_name && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { fontSize: 12 }, children: `Action: ${span.operation_name}` }),
33286
+ /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { fontSize: 12 }, children: [hoverDirection(hover), duration].filter(Boolean).join(" \xB7 ") }),
33287
+ issue !== void 0 && issue !== "" && /* @__PURE__ */ jsx151(Typography15, { color: hover.message.error ? "error" : "warning.main", sx: { fontSize: 12 }, children: issue })
33288
+ ] }) });
33289
+ };
33290
+ var SequenceDiagram = ({ onSelectSpan, participantMode = "caller", selectedSpanId, spans }) => {
33291
+ const theme = useTheme7();
33292
+ const [folded, setFolded] = React126.useState(() => /* @__PURE__ */ new Set());
33293
+ const containerRef = React126.useRef(null);
33294
+ const scrollRef = React126.useRef(null);
33295
+ const areaRef = React126.useRef(null);
33296
+ const widgetRef = React126.useRef(null);
33297
+ const { zoom, zoomTo } = useZoom(scrollRef, areaRef, widgetRef, spans.length > 0);
33298
+ const bodyId = useBodyId();
33299
+ const [minimapOpen, setMinimapOpen] = useLocalStorage(MINIMAP_OPEN_STORAGE_KEY, true);
33300
+ const [scrollView, setScrollView] = React126.useState({ height: 0, left: 0, scrollbarHeight: 0, scrollbarWidth: 0, top: 0, width: 0 });
33301
+ const measureView = React126.useCallback(() => {
33302
+ const element = scrollRef.current;
33303
+ if (element) setScrollView({
33304
+ height: element.clientHeight,
33305
+ left: element.scrollLeft,
33306
+ // Classic scrollbars take room; overlay ones (macOS by default) measure 0.
33307
+ scrollbarHeight: element.offsetHeight - element.clientHeight,
33308
+ scrollbarWidth: element.offsetWidth - element.clientWidth,
33309
+ top: element.scrollTop,
33310
+ width: element.clientWidth
33311
+ });
33312
+ }, []);
33313
+ React126.useLayoutEffect(() => {
33314
+ const element = scrollRef.current;
33315
+ if (!element) return;
33316
+ measureView();
33317
+ let frame2 = 0;
33318
+ const observer = new ResizeObserver(() => {
33319
+ cancelAnimationFrame(frame2);
33320
+ frame2 = requestAnimationFrame(measureView);
33321
+ });
33322
+ observer.observe(element);
33323
+ return () => {
33324
+ cancelAnimationFrame(frame2);
33325
+ observer.disconnect();
33326
+ };
33327
+ }, [measureView, zoom, spans.length]);
33328
+ const { sequenceBlocks, sequenceClickTargets, sequenceHoverCard } = useDevSettings();
33329
+ const arrowTargets = sequenceClickTargets === "arrows-and-segments";
33330
+ const returnHitHeight = arrowTargets ? ARROW_HIT_HEIGHT : RETURN_HIT_HEIGHT;
33331
+ const hoverCard = sequenceHoverCard === "on";
33332
+ const [hover, setHover] = React126.useState();
33333
+ const blocks = sequenceBlocks === "detached" || sequenceBlocks === "overlapped";
33334
+ const hatched = sequenceBlocks === "detached";
33335
+ const blockOffset = sequenceBlocks === "overlapped" ? BLOCK_OVERLAP_OFFSET : BLOCK_OFFSET;
33336
+ const merged = sequenceBlocks === "merged";
33337
+ const blockWidth = sequenceBlocks === "off" ? 0 : BLOCK_WIDTH;
33338
+ const segmentTargets = (arrowTargets || hoverCard) && blockWidth > 0;
33339
+ const { endings, messages, participants } = React126.useMemo(() => {
33340
+ const layout = layoutSequence(spans, participantMode, folded);
33341
+ return blocks ? layout : { ...layout, messages: layout.messages.map((message) => ({ ...message, depth: 0, fromDepth: 0 })) };
33342
+ }, [spans, participantMode, folded, blocks]);
33343
+ const pickedHereRef = React126.useRef();
33344
+ const select = React126.useCallback((spanId, view2) => {
33345
+ pickedHereRef.current = spanId;
33346
+ onSelectSpan(spanId, view2);
33347
+ }, [onSelectSpan]);
33348
+ React126.useEffect(() => {
33349
+ if (selectedSpanId === void 0 || selectedSpanId === pickedHereRef.current) return;
33350
+ containerRef.current?.querySelector(`[data-span-id="${CSS.escape(selectedSpanId)}"]`)?.scrollIntoView({ block: "nearest", inline: "nearest" });
33351
+ }, [selectedSpanId]);
33352
+ const [folding, setFolding] = React126.useState(false);
33353
+ const foldingTimerRef = React126.useRef();
33354
+ React126.useEffect(() => () => {
33355
+ clearTimeout(foldingTimerRef.current);
33356
+ }, []);
33357
+ const setFold = React126.useCallback((spanId, fold) => {
33358
+ setFolding(true);
33359
+ clearTimeout(foldingTimerRef.current);
33360
+ foldingTimerRef.current = setTimeout(() => {
33361
+ setFolding(false);
33362
+ }, SLIDE_MS + 100);
33363
+ setFolded((previous) => {
33364
+ const next = new Set(previous);
33365
+ if (fold) next.add(spanId);
33366
+ else next.delete(spanId);
33367
+ return next;
33368
+ });
33369
+ }, []);
33370
+ const handleKeyDown = React126.useCallback((event, message) => {
33371
+ if (event.target !== event.currentTarget) return;
33372
+ const spanId = message.span.span_id;
33373
+ if (event.key === "Enter" || event.key === " ") {
33374
+ event.preventDefault();
33375
+ select(spanId, "details");
33376
+ } else if (event.key === "ArrowRight" && message.folded) setFold(spanId, false);
33377
+ else if (event.key === "ArrowLeft" && message.descendantCount > 0 && !message.folded) setFold(spanId, true);
33378
+ }, [select, setFold]);
33379
+ const [shown, setShown] = React126.useState(() => ({ messages, revealed: /* @__PURE__ */ new Set() }));
33380
+ if (shown.messages !== messages) {
33381
+ const previous = new Set(shown.messages.map((message) => message.span.span_id));
33382
+ const continued = messages.some((message) => previous.has(message.span.span_id));
33383
+ setShown({ messages, revealed: new Set(continued ? messages.filter((message) => !previous.has(message.span.span_id)).map((message) => message.span.span_id) : []) });
33384
+ }
33385
+ const isEntering = React126.useCallback((spanId) => shown.revealed.has(spanId), [shown]);
33386
+ const geometry = React126.useMemo(() => {
33387
+ const participant2 = (index) => participants[index] ?? { key: "", label: "", resource: "", service: "" };
33388
+ const width2 = participants.length * COLUMN_WIDTH;
33389
+ const rowHeights2 = endings.map((count2) => rowHeight(count2));
33390
+ const rowTops = rowHeights2.map((_height, row) => rowHeights2.slice(0, row).reduce((sum2, height) => sum2 + height, 0));
33391
+ const bodyHeight2 = rowHeights2.reduce((sum2, height) => sum2 + height, 0);
33392
+ const top2 = (row) => rowTops[row] ?? 0;
33393
+ const activeDepth2 = (lifeline, row) => Math.max(0, ...messages.slice(0, row + 1).filter((message) => message.to === lifeline && message.endRow >= row).map((message) => message.depth));
33394
+ const endY2 = (message) => top2(message.endRow) + ARROW_Y + BLOCK_TAIL + message.returnLevel * RETURN_GAP;
33395
+ const rowOf = new Map(messages.map((message, index) => [message.span.span_id, index]));
33396
+ const blockY2 = (message) => top2(rowOf.get(message.span.span_id) ?? 0) + ARROW_Y - BLOCK_OVERHANG;
33397
+ const mergedBlocks2 = [];
33398
+ if (merged) {
33399
+ for (const message of messages.toSorted((left, right) => left.to - right.to || blockY2(left) - blockY2(right))) {
33400
+ const last = mergedBlocks2.at(-1);
33401
+ if (last?.members[0]?.to === message.to && blockY2(message) <= last.bottom) {
33402
+ last.bottom = Math.max(last.bottom, endY2(message));
33403
+ last.members.push(message);
33404
+ } else mergedBlocks2.push({ bottom: endY2(message), members: [message], top: blockY2(message) });
33405
+ }
33406
+ }
33407
+ return { activeDepth: activeDepth2, blockY: blockY2, bodyHeight: bodyHeight2, endY: endY2, mergedBlocks: mergedBlocks2, participant: participant2, rowHeights: rowHeights2, top: top2, width: width2 };
33408
+ }, [endings, merged, messages, participants]);
33409
+ const { activeDepth, blockY, bodyHeight, endY, mergedBlocks, participant, rowHeights, top, width } = geometry;
33410
+ const hoveredMessage = hover && messages.find((message) => message.span.span_id === hover.message.span.span_id);
33411
+ const arrowHoverProps = React126.useCallback((message, kind) => {
33412
+ if (!hoverCard) return {};
33413
+ const [from, to] = kind === "response" ? [message.to, message.from] : [message.from, message.to];
33414
+ return {
33415
+ onMouseLeave: () => {
33416
+ setHover(void 0);
33417
+ },
33418
+ onMouseMove: (event) => {
33419
+ setHover({ from: lifelineName(participant(from)), kind, message, to: lifelineName(participant(to)), x: event.clientX, y: event.clientY });
33420
+ }
33421
+ };
33422
+ }, [hoverCard, participant]);
33423
+ const drawing = React126.useMemo(() => /* @__PURE__ */ jsxs138(Fragment15, { children: [
33424
+ /* @__PURE__ */ jsx151(Box22, { 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) => (
33425
+ // A subtle box per lifeline, its identity as in every other view: icon, service, resource below.
33426
+ /* @__PURE__ */ jsx151(
33427
+ Box22,
33428
+ {
33429
+ "data-testid": SEQUENCE_DIAGRAM_PARTICIPANT_TEST_ID,
33430
+ sx: {
33431
+ // As in Flow: a hovered box grows to show its whole name, over its neighbours, without moving them.
33432
+ "&:hover": { "& > *": { width: "max-content" }, "zIndex": 1 },
33433
+ "alignItems": "center",
33434
+ "display": "flex",
33435
+ "flex": "none",
33436
+ "justifyContent": "flex-start",
33437
+ "position": "relative",
33438
+ "px": "4px",
33439
+ "width": COLUMN_WIDTH
33440
+ },
33441
+ title: [participant2.service, participant2.resource].filter(Boolean).join(" \xB7 ") || "Caller",
33442
+ children: /* @__PURE__ */ jsx151(
33443
+ Box22,
33444
+ {
33445
+ 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%" },
33446
+ children: participant2.service === "" ? /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", component: "span", sx: { fontSize: 12 }, children: "Caller" }) : /* @__PURE__ */ jsx151(OperationIdentity, { density: "stacked", iconSize: 24, resourceName: participant2.label, service: participant2.service })
33447
+ }
33448
+ )
33449
+ },
33450
+ participant2.key
33451
+ )
33452
+ )) }),
33453
+ /* @__PURE__ */ jsxs138(Box22, { sx: { backgroundColor: "background.paper", height: bodyHeight, position: "relative" }, children: [
33454
+ messages.map((message, index) => {
33455
+ const { span } = message;
33456
+ const selected = span.span_id === selectedSpanId;
33457
+ const self2 = message.from === message.to;
33458
+ const lane = Math.min(message.from, message.to);
33459
+ 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;
33460
+ return /* @__PURE__ */ jsxs138(
33461
+ Box22,
33462
+ {
33463
+ "aria-selected": selected,
33464
+ "data-span-id": span.span_id,
33465
+ "data-testid": SEQUENCE_DIAGRAM_MESSAGE_TEST_ID,
33466
+ onClick: arrowTargets ? void 0 : () => {
33467
+ select(span.span_id, "details");
33468
+ },
33469
+ onKeyDown: (event) => {
33470
+ handleKeyDown(event, message);
33471
+ },
33472
+ role: "listitem",
33473
+ sx: {
33474
+ "&:focus-visible": { boxShadow: `inset 0 0 0 2px ${theme.palette.primary.main}` },
33475
+ "&:hover": arrowTargets ? void 0 : { "--row-tint": selected ? alpha8(theme.palette.primary.main, 0.16) : alpha8(theme.palette.text.primary, 0.04) },
33476
+ // Opaque, so a label repeating it hides the lifelines behind it.
33477
+ "--row-bg": `linear-gradient(var(--row-tint), var(--row-tint)), ${theme.palette.background.paper}`,
33478
+ "--row-tint": selected ? alpha8(theme.palette.primary.main, 0.12) : "transparent",
33479
+ "animation": isEntering(span.span_id) ? ENTER_ANIMATION : void 0,
33480
+ // Only the tint: the drawing shows through the row, under its label.
33481
+ "background": "var(--row-tint)",
33482
+ "cursor": arrowTargets ? void 0 : "pointer",
33483
+ "height": rowHeights[index],
33484
+ "left": 0,
33485
+ "outline": 0,
33486
+ "position": "absolute",
33487
+ "right": 0,
33488
+ "scrollMarginTop": HEADER_HEIGHT,
33489
+ "top": 0,
33490
+ "transform": `translateY(${String(top(index))}px)`,
33491
+ // Only the transform: a height transition would re-lay out every row on every frame.
33492
+ "transition": `transform ${SLIDE}`,
33493
+ // The transform makes the row a stacking context: over the drawing, so its label covers the blocks and lines it crosses.
33494
+ "zIndex": 1
33495
+ },
33496
+ tabIndex: 0,
33497
+ children: [
33498
+ (arrowTargets || hoverCard) && /* @__PURE__ */ jsx151(
33499
+ Box22,
33500
+ {
33501
+ "data-testid": SEQUENCE_DIAGRAM_ARROW_TEST_ID,
33502
+ onClick: arrowTargets ? () => {
33503
+ select(span.span_id, "payload");
33504
+ } : void 0,
33505
+ ...arrowHoverProps(message, "request"),
33506
+ sx: { "&:hover": arrowTargets ? { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) } : void 0, "borderRadius": "4px", "cursor": "pointer", "position": "absolute", ...arrowHitBox(message, blockWidth, blockOffset, ARROW_HIT_HEIGHT) }
33507
+ }
33508
+ ),
33509
+ /* @__PURE__ */ jsxs138(
33510
+ Box22,
33511
+ {
33512
+ onClick: arrowTargets ? () => {
33513
+ select(span.span_id, "details");
33514
+ } : void 0,
33515
+ ...arrowHoverProps(message, "request"),
33516
+ sx: {
33517
+ alignItems: "center",
33518
+ background: "var(--row-bg)",
33519
+ cursor: arrowTargets ? "pointer" : void 0,
33520
+ display: "flex",
33521
+ gap: "3px",
33522
+ height: LABEL_HEIGHT,
33523
+ left: labelLeft,
33524
+ maxWidth: width - labelLeft - 4,
33525
+ position: "absolute",
33526
+ px: "2px",
33527
+ top: LABEL_TOP,
33528
+ zIndex: 2
33529
+ },
33530
+ children: [
33531
+ message.descendantCount > 0 && /* @__PURE__ */ jsx151(
33532
+ ButtonBase2,
33533
+ {
33534
+ "aria-label": message.folded ? "Expand" : "Collapse",
33535
+ "data-testid": SEQUENCE_DIAGRAM_TOGGLE_TEST_ID,
33536
+ onClick: (event) => {
33537
+ event.stopPropagation();
33538
+ setFold(span.span_id, !message.folded);
33539
+ },
33540
+ sx: { "&:hover": { backgroundColor: alpha8(theme.palette.text.primary, 0.12) }, "borderRadius": "3px", "color": "text.secondary", "flex": "none", "height": 14, "width": 14 },
33541
+ tabIndex: -1,
33542
+ children: message.folded ? /* @__PURE__ */ jsx151(KeyboardArrowRight3, { sx: { fontSize: 16 } }) : /* @__PURE__ */ jsx151(KeyboardArrowDown3, { sx: { fontSize: 16 } })
33543
+ }
33544
+ ),
33545
+ /* @__PURE__ */ jsx151(Typography15, { color: message.error ? "error" : "text.primary", component: "span", noWrap: true, sx: { flex: "none", fontSize: "inherit", fontWeight: 600 }, children: /* @__PURE__ */ jsx151(OperationName, { span, tooltip: !hoverCard }) }),
33546
+ participant(message.to).resource === "" && message.resource !== "" && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", component: "span", noWrap: true, sx: { ...RESOURCE_CODE_SX, fontSize: 11, minWidth: 0 }, title: hoverCard ? void 0 : message.resource, children: message.resource }),
33547
+ message.error && /* @__PURE__ */ jsx151(Cancel8, { sx: { color: "error.main", flex: "none", fontSize: 13 } }),
33548
+ message.warning && /* @__PURE__ */ jsx151(GppMaybe9, { sx: { color: "warning.main", flex: "none", fontSize: 13 } }),
33549
+ message.folded && /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", component: "span", sx: { flex: "none", fontSize: 11 }, children: `+${String(message.descendantCount)}` })
33550
+ ]
33551
+ }
33552
+ )
33553
+ ]
33554
+ },
33555
+ span.span_id
33556
+ );
33557
+ }),
33558
+ messages.filter((message) => hasReturn(message)).map((message) => {
33559
+ const fromX = blockX(message.to, message.depth, blockOffset);
33560
+ const toX = blockX(message.from, message.fromDepth, blockOffset);
33561
+ const selected = message.span.span_id === selectedSpanId;
33562
+ return /* @__PURE__ */ jsx151(
33563
+ Box22,
33564
+ {
33565
+ "aria-hidden": "true",
33566
+ "aria-selected": selected,
33567
+ "data-span-id": message.span.span_id,
33568
+ "data-testid": SEQUENCE_DIAGRAM_RETURN_TEST_ID,
33569
+ onClick: () => {
33570
+ select(message.span.span_id, "response");
33571
+ },
33572
+ ...arrowHoverProps(message, "response"),
33573
+ sx: {
33574
+ // The selected call's tint, as on its row, so its reply reads as part of it.
33575
+ "&:hover": { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) },
33576
+ "backgroundColor": selected ? alpha8(theme.palette.primary.main, 0.12) : void 0,
33577
+ "borderRadius": "4px",
33578
+ "cursor": "pointer",
33579
+ "height": returnHitHeight,
33580
+ "left": Math.min(fromX, toX),
33581
+ "position": "absolute",
33582
+ "top": 0,
33583
+ "width": Math.abs(toX - fromX),
33584
+ "zIndex": 2,
33585
+ ...slideTo(endY(message) - returnHitHeight / 2, isEntering(message.span.span_id))
33586
+ },
33587
+ title: hoverCard ? void 0 : `${getOperationLabel(message.span)}: response`
33588
+ },
33589
+ message.span.span_id
33590
+ );
33591
+ }),
33592
+ segmentTargets && messages.map((message) => {
33593
+ const selected = message.span.span_id === selectedSpanId;
33594
+ const boxY = blockY(message);
33595
+ return /* @__PURE__ */ jsx151(
33596
+ Box22,
33597
+ {
33598
+ "aria-hidden": "true",
33599
+ "data-span-id": message.span.span_id,
33600
+ "data-testid": SEQUENCE_DIAGRAM_SEGMENT_TEST_ID,
33601
+ onClick: () => {
33602
+ select(message.span.span_id, "details");
33603
+ },
33604
+ ...arrowHoverProps(message, "segment"),
33605
+ sx: {
33606
+ "&:hover": { backgroundColor: alpha8(theme.palette.primary.main, selected ? 0.16 : 0.12) },
33607
+ "borderRadius": "4px",
33608
+ "cursor": "pointer",
33609
+ "height": endY(message) - boxY,
33610
+ "left": blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 - BLOCK_HIT_MARGIN,
33611
+ "position": "absolute",
33612
+ "top": 0,
33613
+ "width": BLOCK_WIDTH + 2 * BLOCK_HIT_MARGIN,
33614
+ "zIndex": 2,
33615
+ // Its height follows a fold too: the slide's transition covers both.
33616
+ ...slideTo(boxY, isEntering(message.span.span_id))
33617
+ },
33618
+ title: hoverCard ? void 0 : getOperationLabel(message.span)
33619
+ },
33620
+ message.span.span_id
33621
+ );
33622
+ }),
33623
+ /* @__PURE__ */ jsx151("svg", { "aria-hidden": "true", height: bodyHeight, style: { left: 0, overflow: "visible", pointerEvents: "none", position: "absolute", top: 0, zIndex: 0 }, width, children: /* @__PURE__ */ jsxs138("g", { id: bodyId, children: [
33624
+ /* @__PURE__ */ jsx151("defs", { children: [...new Set(messages.map((message) => getServiceColor(message.span.service_name)))].map((color2) => /* @__PURE__ */ jsx151("pattern", { height: 4, id: hatchId(color2), patternTransform: "rotate(45)", patternUnits: "userSpaceOnUse", width: 4, children: /* @__PURE__ */ jsx151("rect", { fill: alpha8(color2, 0.35), height: 4, width: 2 }) }, color2)) }),
33625
+ participants.map((participant2, index) => /* @__PURE__ */ jsx151("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)),
33626
+ blocks && messages.map((message, index) => {
33627
+ const serviceColor = getServiceColor(message.span.service_name);
33628
+ const selected = message.span.span_id === selectedSpanId;
33629
+ const boxY = top(index) + ARROW_Y - BLOCK_OVERHANG;
33630
+ const boxHeight = endY(message) - boxY;
33631
+ const box = { ...blockRect(boxHeight), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x: blockX(message.to, message.depth, blockOffset) - BLOCK_WIDTH / 2 };
33632
+ const hatch = (earlier) => ({
33633
+ ...blockRect(boxHeight + 2 * HATCH_MARGIN),
33634
+ // A pixel wider on each side, over the outer block's border: the hatch has none.
33635
+ width: BLOCK_WIDTH + 2,
33636
+ x: blockX(earlier.to, earlier.depth, blockOffset) - BLOCK_WIDTH / 2 - 1
33637
+ });
33638
+ const outer = hatched ? messages.slice(0, index).filter((earlier) => earlier.to === message.to && earlier.endRow >= index && earlier.depth < message.depth) : [];
33639
+ return (
33640
+ // Paper first, so the tint over it stays opaque to the lifeline.
33641
+ /* @__PURE__ */ jsxs138("g", { style: slideTo(boxY, isEntering(message.span.span_id)), children: [
33642
+ outer.map((earlier) => /* @__PURE__ */ jsxs138("g", { transform: `translate(0 ${String(-HATCH_MARGIN)})`, children: [
33643
+ /* @__PURE__ */ jsx151("rect", { fill: theme.palette.background.paper, ...hatch(earlier) }),
33644
+ /* @__PURE__ */ jsx151("rect", { fill: `url(#${hatchId(getServiceColor(earlier.span.service_name))})`, rx: BLOCK_RADIUS, ...hatch(earlier) })
33645
+ ] }, earlier.span.span_id)),
33646
+ /* @__PURE__ */ jsx151("rect", { ...box, fill: theme.palette.background.paper }),
33647
+ /* @__PURE__ */ jsx151(
33648
+ "rect",
33649
+ {
33650
+ ...box,
33651
+ fill: alpha8(serviceColor, selected ? 0.5 : 0.2),
33652
+ stroke: message.error ? theme.palette.error.main : serviceColor,
33653
+ strokeWidth: selected ? 1.5 : 1
33654
+ }
33655
+ )
33656
+ ] }, message.span.span_id)
33657
+ );
33658
+ }),
33659
+ merged && mergedBlocks.map(({ bottom, members, top: blockTop }) => {
33660
+ const [firstMember] = members;
33661
+ if (!firstMember) return;
33662
+ const serviceColor = getServiceColor(firstMember.span.service_name);
33663
+ const x = lifelineX(firstMember.to) - BLOCK_WIDTH / 2;
33664
+ const range = (member2) => ({ ...blockRect(endY(member2) - blockY(member2)), transform: `translate(0 ${String(blockY(member2) - blockTop)})`, width: BLOCK_WIDTH, x });
33665
+ return /* @__PURE__ */ jsxs138("g", { style: slideTo(blockTop), children: [
33666
+ /* @__PURE__ */ jsx151("rect", { fill: theme.palette.background.paper, ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, width: BLOCK_WIDTH, x }),
33667
+ /* @__PURE__ */ jsx151("rect", { fill: alpha8(serviceColor, 0.2), ...blockRect(bottom - blockTop), rx: BLOCK_RADIUS, stroke: serviceColor, width: BLOCK_WIDTH, x }),
33668
+ members.filter((member2) => member2.span.span_id === selectedSpanId).map((member2) => /* @__PURE__ */ jsx151("rect", { fill: alpha8(serviceColor, 0.35), rx: BLOCK_RADIUS, ...range(member2) }, member2.span.span_id)),
33669
+ members.filter((member2) => member2.error).map((member2) => /* @__PURE__ */ jsx151("rect", { fill: "none", rx: BLOCK_RADIUS, stroke: theme.palette.error.main, ...range(member2) }, member2.span.span_id))
33670
+ ] }, firstMember.span.span_id);
33671
+ }),
33672
+ messages.filter((message) => hasReturn(message)).map((message) => /* @__PURE__ */ jsx151(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)),
33673
+ messages.map((message, index) => /* @__PURE__ */ jsx151(
33674
+ Arrow,
33675
+ {
33676
+ blockOffset,
33677
+ blockWidth,
33678
+ color: message.error ? theme.palette.error.main : theme.palette.text.secondary,
33679
+ entering: isEntering(message.span.span_id),
33680
+ message,
33681
+ top: top(index)
33682
+ },
33683
+ message.span.span_id
33684
+ ))
33685
+ ] }) })
33686
+ ] })
33687
+ ] }), [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]);
33688
+ if (spans.length === 0) {
33689
+ return /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { p: 2 }, variant: "body2", children: "No operations in this trace." });
33690
+ }
33691
+ const view = { height: scrollView.height / zoom - HEADER_HEIGHT, width: scrollView.width / zoom, x: scrollView.left / zoom, y: scrollView.top / zoom };
33692
+ const minimapScale = Math.min((MINIMAP_WIDTH - 16) / width, Math.min(MINIMAP_MAX_HEIGHT, scrollView.height * MINIMAP_MAX_VIEW_SHARE) / bodyHeight);
33693
+ const minimap = scrollView.width > 0 && (view.width < width || view.height < bodyHeight) ? { scale: minimapScale, view } : void 0;
33694
+ const panTo = (event) => {
33695
+ const element = scrollRef.current;
33696
+ if (!element) return;
33697
+ const bounds = event.currentTarget.querySelector("svg")?.getBoundingClientRect();
33698
+ if (!bounds) return;
33699
+ element.scrollLeft = ((event.clientX - bounds.left) / minimapScale - view.width / 2) * zoom;
33700
+ element.scrollTop = ((event.clientY - bounds.top) / minimapScale - view.height / 2) * zoom;
33701
+ };
33702
+ const fitWidth = () => {
33703
+ const viewWidth = scrollRef.current?.clientWidth;
33704
+ if (viewWidth) zoomTo(viewWidth / width, 0, 0);
33705
+ };
33706
+ return (
33707
+ // The diagram scrolls in a box of its own, so the zoom controls stay put over it.
33708
+ // Its own stacking context: the header's and the widget's z-indexes order them within the
33709
+ // diagram only, never over the sidebar's resize handles.
33710
+ /* @__PURE__ */ jsxs138(Box22, { ref: areaRef, sx: { flex: 1, height: "100%", isolation: "isolate", minHeight: 0, position: "relative" }, children: [
33711
+ /* @__PURE__ */ jsx151(Box22, { onScroll: measureView, ref: scrollRef, sx: { inset: 0, overflow: "auto", position: "absolute" }, children: /* @__PURE__ */ jsxs138(Box22, { "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: [
33712
+ drawing,
33713
+ /* @__PURE__ */ jsx151(Box22, { sx: { height: BOTTOM_ROOM / zoom } })
33714
+ ] }) }),
33715
+ /* @__PURE__ */ jsxs138(Paper2, { 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: [
33716
+ minimap && // A thin bar with only a chevron: down folds the minimap away, up brings it back.
33717
+ /* @__PURE__ */ jsx151(
33718
+ ButtonBase2,
33719
+ {
33720
+ "aria-expanded": minimapOpen,
33721
+ "aria-label": minimapOpen ? "Hide the overview" : "Show the overview",
33722
+ "data-testid": SEQUENCE_DIAGRAM_MINIMAP_TOGGLE_TEST_ID,
33723
+ onClick: () => {
33724
+ setMinimapOpen(!minimapOpen);
33725
+ },
33726
+ sx: { "&:hover": { color: "text.primary" }, "borderBottom": 1, "borderColor": "divider", "color": "text.secondary", "height": 14, "width": "100%" },
33727
+ children: minimapOpen ? /* @__PURE__ */ jsx151(KeyboardArrowDown3, { sx: { fontSize: 16 } }) : /* @__PURE__ */ jsx151(KeyboardArrowUp, { sx: { fontSize: 16 } })
33728
+ }
33729
+ ),
33730
+ minimap && /* @__PURE__ */ jsx151(Collapse, { in: minimapOpen, unmountOnExit: true, children: /* @__PURE__ */ jsx151(
33731
+ Box22,
33732
+ {
33733
+ "aria-label": "Minimap",
33734
+ "data-testid": SEQUENCE_DIAGRAM_MINIMAP_TEST_ID,
33735
+ onPointerDown: (event) => {
33736
+ event.currentTarget.setPointerCapture(event.pointerId);
33737
+ panTo(event);
33738
+ },
33739
+ onPointerMove: (event) => {
33740
+ if (event.currentTarget.hasPointerCapture(event.pointerId)) panTo(event);
33741
+ },
33742
+ role: "navigation",
33743
+ sx: { backgroundColor: "action.hover", borderBottom: 1, borderColor: "divider", cursor: "pointer", display: "flex", justifyContent: "center", lineHeight: 0, p: 1, touchAction: "none" },
33744
+ children: /* @__PURE__ */ jsxs138("svg", { height: bodyHeight * minimap.scale, style: { backgroundColor: theme.palette.background.paper }, viewBox: `0 0 ${String(width)} ${String(bodyHeight)}`, width: width * minimap.scale, children: [
33745
+ /* @__PURE__ */ jsx151("use", { href: `#${bodyId}` }),
33746
+ /* @__PURE__ */ jsx151("rect", { fill: alpha8(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 })
33747
+ ] })
33748
+ }
33749
+ ) }),
33750
+ /* @__PURE__ */ jsxs138(Box22, { sx: { alignItems: "center", display: "flex", justifyContent: "space-between", px: "2px" }, children: [
33751
+ /* @__PURE__ */ jsx151(Tooltip7, { title: "Zoom out (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ jsx151(IconButton8, { "aria-label": "Zoom out", "data-testid": SEQUENCE_DIAGRAM_ZOOM_OUT_BUTTON_TEST_ID, disabled: zoom <= MIN_ZOOM, onClick: () => {
33752
+ zoomTo(zoom / ZOOM_STEP);
33753
+ }, size: "small", children: /* @__PURE__ */ jsx151(ZoomOut, { fontSize: "small" }) }) }),
33754
+ /* @__PURE__ */ jsx151(Tooltip7, { title: "Reset zoom", children: /* @__PURE__ */ jsx151(ButtonBase2, { "data-testid": SEQUENCE_DIAGRAM_ZOOM_RESET_BUTTON_TEST_ID, onClick: () => {
33755
+ zoomTo(1);
33756
+ }, sx: { borderRadius: 1, fontSize: 12, fontVariantNumeric: "tabular-nums", minWidth: 40, py: "2px" }, children: `${String(Math.round(zoom * 100))}%` }) }),
33757
+ /* @__PURE__ */ jsx151(Tooltip7, { title: "Zoom in (Ctrl/\u2318 + scroll, or pinch)", children: /* @__PURE__ */ jsx151(IconButton8, { "aria-label": "Zoom in", "data-testid": SEQUENCE_DIAGRAM_ZOOM_IN_BUTTON_TEST_ID, disabled: zoom >= MAX_ZOOM, onClick: () => {
33758
+ zoomTo(zoom * ZOOM_STEP);
33759
+ }, size: "small", children: /* @__PURE__ */ jsx151(ZoomIn, { fontSize: "small" }) }) }),
33760
+ /* @__PURE__ */ jsx151(Tooltip7, { title: "Fit the width", children: /* @__PURE__ */ jsx151(IconButton8, { "aria-label": "Fit the width", "data-testid": SEQUENCE_DIAGRAM_ZOOM_FIT_BUTTON_TEST_ID, onClick: fitWidth, size: "small", children: /* @__PURE__ */ jsx151(FitScreen2, { fontSize: "small" }) }) })
33761
+ ] })
33762
+ ] }),
33763
+ hoverCard && hoveredMessage && /* @__PURE__ */ jsx151(ArrowHoverCard, { hover: { ...hover, message: hoveredMessage } })
33764
+ ] })
33765
+ );
33766
+ };
33767
+
32972
33768
  // src/components/trace-panel/trace-sidebar.tsx
32973
- import { jsx as jsx151, jsxs as jsxs138 } from "react/jsx-runtime";
33769
+ import { jsx as jsx152, jsxs as jsxs139 } from "react/jsx-runtime";
32974
33770
  var DEFAULT_WIDTH_SHARE = 0.75;
32975
33771
  var MAX_WIDTH_SHARE = 0.8;
32976
33772
  var SNAP_WIDTH_SHARE = (MAX_WIDTH_SHARE + 1) / 2;
@@ -32991,22 +33787,16 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
32991
33787
  const [maximized, setMaximized] = useLocalStorage(MAXIMIZED_STORAGE_KEY, false);
32992
33788
  const [storedSplit, setStoredSplit] = useLocalStorage(SPLIT_STORAGE_KEY, DEFAULT_SPLIT);
32993
33789
  const [storedView, setView] = useLocalStorage(VIEW_STORAGE_KEY, "map");
32994
- const view = storedView === "waterfall" ? "waterfall" : "map";
32995
- const sidebarRef = React125.useRef(null);
32996
- const traceViewRef = React125.useRef(null);
33790
+ const view = storedView === "waterfall" || storedView === "sequence" ? storedView : "map";
33791
+ const sidebarRef = React127.useRef(null);
33792
+ const traceViewRef = React127.useRef(null);
32997
33793
  const width = maximized ? 1 : storedWidth;
32998
- const [parentWidth, setParentWidth] = React125.useState(0);
32999
- React125.useLayoutEffect(() => {
33000
- const parent = sidebarRef.current?.parentElement;
33001
- if (!parent) return;
33002
- const observer = new ResizeObserver(([entry]) => {
33003
- if (entry) setParentWidth(entry.contentRect.width);
33004
- });
33005
- observer.observe(parent);
33006
- return () => {
33007
- observer.disconnect();
33008
- };
33009
- }, []);
33794
+ const [requestedTab, setRequestedTab] = React127.useState();
33795
+ const selectFromSequence = React127.useCallback((spanId, view2) => {
33796
+ onSelectSpan(spanId);
33797
+ setRequestedTab({ view: view2 });
33798
+ }, [onSelectSpan]);
33799
+ const parentWidth = useContentWidth(sidebarRef, true);
33010
33800
  const minWidth = parentWidth === 0 ? 0 : Math.min(1, MIN_WIDTH / parentWidth);
33011
33801
  const resize = (share) => {
33012
33802
  const snap = share > SNAP_WIDTH_SHARE;
@@ -33045,7 +33835,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33045
33835
  event.preventDefault();
33046
33836
  setStoredSplit(clampSplit(storedSplit + delta));
33047
33837
  };
33048
- const { root: root2, selectedSpan, stats } = React125.useMemo(() => {
33838
+ const { root: root2, selectedSpan, stats } = React127.useMemo(() => {
33049
33839
  const tree = buildTraceTree(spans);
33050
33840
  const issues = spans.map((span) => getSpanIssues(span));
33051
33841
  return {
@@ -33059,7 +33849,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33059
33849
  };
33060
33850
  }, [spans, selectedSpanId]);
33061
33851
  const rootSpanId = root2?.span_id;
33062
- React125.useEffect(() => {
33852
+ React127.useEffect(() => {
33063
33853
  if (!onRequestRendered || rootSpanId === void 0) return;
33064
33854
  let frame2 = requestAnimationFrame(() => {
33065
33855
  frame2 = requestAnimationFrame(() => {
@@ -33070,8 +33860,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33070
33860
  cancelAnimationFrame(frame2);
33071
33861
  };
33072
33862
  }, [onRequestRendered, rootSpanId, view]);
33073
- return /* @__PURE__ */ jsxs138(
33074
- Box22,
33863
+ return /* @__PURE__ */ jsxs139(
33864
+ Box23,
33075
33865
  {
33076
33866
  "data-testid": TRACE_SIDEBAR_TEST_ID,
33077
33867
  ref: sidebarRef,
@@ -33093,8 +33883,8 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33093
33883
  width: `${String(width * 100)}%`
33094
33884
  },
33095
33885
  children: [
33096
- /* @__PURE__ */ jsx151(
33097
- Box22,
33886
+ /* @__PURE__ */ jsx152(
33887
+ Box23,
33098
33888
  {
33099
33889
  "aria-label": "Resize the sidebar",
33100
33890
  "aria-orientation": "vertical",
@@ -33122,14 +33912,14 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33122
33912
  tabIndex: 0
33123
33913
  }
33124
33914
  ),
33125
- /* @__PURE__ */ jsxs138(Box22, { "aria-label": "Request", component: "header", sx: { alignItems: "center", borderBottom: 1, borderColor: "divider", display: "flex", gap: 1.5, px: 2, py: 1.25 }, children: [
33126
- root2 === void 0 ? /* @__PURE__ */ jsx151(Box22, { sx: { flex: 1 } }) : /* @__PURE__ */ jsx151(
33915
+ /* @__PURE__ */ jsxs139(Box23, { "aria-label": "Request", component: "header", sx: { alignItems: "center", borderBottom: 1, borderColor: "divider", display: "flex", gap: 1.5, px: 2, py: 1.25 }, children: [
33916
+ root2 === void 0 ? /* @__PURE__ */ jsx152(Box23, { sx: { flex: 1 } }) : /* @__PURE__ */ jsx152(
33127
33917
  OperationIdentity,
33128
33918
  {
33129
33919
  arn: root2.arn,
33130
33920
  density: "heading",
33131
33921
  label: "Request",
33132
- operation: /* @__PURE__ */ jsx151(OperationName, { span: root2 }),
33922
+ operation: /* @__PURE__ */ jsx152(OperationName, { span: root2 }),
33133
33923
  resourceName: root2.resource_name,
33134
33924
  service: root2.service_name,
33135
33925
  sx: { flex: 1 },
@@ -33143,7 +33933,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33143
33933
  ].join(" \xB7 ")
33144
33934
  }
33145
33935
  ),
33146
- /* @__PURE__ */ jsxs138(
33936
+ /* @__PURE__ */ jsxs139(
33147
33937
  ToggleButtonGroup3,
33148
33938
  {
33149
33939
  "aria-label": "Trace view",
@@ -33156,28 +33946,33 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33156
33946
  size: "small",
33157
33947
  value: view,
33158
33948
  children: [
33159
- /* @__PURE__ */ jsx151(ToggleButton3, { "data-testid": TRACE_SIDEBAR_MAP_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "map", children: "Flow" }),
33160
- /* @__PURE__ */ jsx151(ToggleButton3, { "data-testid": TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "waterfall", children: "Operations" })
33949
+ /* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_MAP_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "map", children: "Flow" }),
33950
+ /* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_WATERFALL_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "waterfall", children: "Operations" }),
33951
+ /* @__PURE__ */ jsx152(ToggleButton3, { "data-testid": TRACE_SIDEBAR_SEQUENCE_BUTTON_TEST_ID, sx: { px: 1.25, py: 0.25, textTransform: "none" }, value: "sequence", children: "Sequence" })
33161
33952
  ]
33162
33953
  }
33163
33954
  ),
33164
- /* @__PURE__ */ jsx151(IconButton8, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
33955
+ /* @__PURE__ */ jsx152(IconButton9, { "aria-label": maximized ? "Restore" : "Maximize", "aria-pressed": maximized, "data-testid": TRACE_SIDEBAR_MAXIMIZE_BUTTON_TEST_ID, onClick: () => {
33165
33956
  setMaximized(!maximized);
33166
- }, size: "small", children: maximized ? /* @__PURE__ */ jsx151(CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ jsx151(OpenInFull, { fontSize: "small" }) }),
33167
- /* @__PURE__ */ jsx151(IconButton8, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ jsx151(Close4, {}) })
33957
+ }, size: "small", children: maximized ? /* @__PURE__ */ jsx152(CloseFullscreen, { fontSize: "small" }) : /* @__PURE__ */ jsx152(OpenInFull, { fontSize: "small" }) }),
33958
+ /* @__PURE__ */ jsx152(IconButton9, { "aria-label": "Close", "data-testid": EVENT_DETAILS_CLOSE_BUTTON_TEST_ID, onClick: onClose, size: "small", children: /* @__PURE__ */ jsx152(Close4, {}) })
33168
33959
  ] }),
33169
- /* @__PURE__ */ jsx151(Box22, { 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__ */ jsx151(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }) : /* @__PURE__ */ jsx151(Box22, { sx: { height: "100%" }, children: /* @__PURE__ */ jsx151(ReactFlowProvider, { children: /* @__PURE__ */ jsx151(
33170
- TraceGraph,
33171
- {
33172
- hideMiniMap: true,
33173
- initialFocusEventId: selectedSpanId,
33174
- onEventSelect: onSelectSpan,
33175
- onRefresh: noop,
33176
- spans: { data: spans, error: void 0, loading: false }
33177
- }
33178
- ) }) }) }),
33179
- /* @__PURE__ */ jsx151(Box22, { sx: { flexShrink: 0, position: "relative" }, children: /* @__PURE__ */ jsx151(
33180
- Box22,
33960
+ /* @__PURE__ */ jsxs139(Box23, { ref: traceViewRef, sx: { borderBottom: 1, borderColor: "divider", display: "flex", flex: `0 0 ${String(storedSplit * 100)}%`, flexDirection: "column", minHeight: 0, overflow: "auto", position: "relative" }, children: [
33961
+ view === "waterfall" && /* @__PURE__ */ jsx152(Waterfall, { onSelectSpan, selectedSpanId, spanMatches, spans }),
33962
+ view === "sequence" && /* @__PURE__ */ jsx152(SequenceDiagram, { onSelectSpan: selectFromSequence, selectedSpanId, spans }),
33963
+ view === "map" && /* @__PURE__ */ jsx152(Box23, { sx: { height: "100%" }, children: /* @__PURE__ */ jsx152(ReactFlowProvider, { children: /* @__PURE__ */ jsx152(
33964
+ TraceGraph,
33965
+ {
33966
+ hideMiniMap: true,
33967
+ initialFocusEventId: selectedSpanId,
33968
+ onEventSelect: onSelectSpan,
33969
+ onRefresh: noop,
33970
+ spans: { data: spans, error: void 0, loading: false }
33971
+ }
33972
+ ) }) })
33973
+ ] }),
33974
+ /* @__PURE__ */ jsx152(Box23, { sx: { flexShrink: 0, position: "relative" }, children: /* @__PURE__ */ jsx152(
33975
+ Box23,
33181
33976
  {
33182
33977
  "aria-label": "Resize the operation details",
33183
33978
  "aria-orientation": "horizontal",
@@ -33205,7 +34000,7 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33205
34000
  tabIndex: 0
33206
34001
  }
33207
34002
  ) }),
33208
- /* @__PURE__ */ jsx151(Box22, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ jsx151(EventDetails, { onOperationShown, selectedEvent: selectedSpan }) : /* @__PURE__ */ jsx151(Typography15, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
34003
+ /* @__PURE__ */ jsx152(Box23, { sx: { flex: 1, minHeight: 0 }, children: selectedSpan ? /* @__PURE__ */ jsx152(EventDetails, { onOperationShown, requestedTab, selectedEvent: selectedSpan }) : /* @__PURE__ */ jsx152(Typography16, { color: "text.secondary", sx: { p: 3, textAlign: "center" }, variant: "body2", children: "The selected operation is not part of this trace." }) })
33209
34004
  ]
33210
34005
  }
33211
34006
  );
@@ -33213,10 +34008,10 @@ var TraceSidebar = ({ onClose, onOperationShown, onRequestRendered, onSelectSpan
33213
34008
 
33214
34009
  // src/components/worker-error-message/worker-error-message.tsx
33215
34010
  import { ErrorOutline as ErrorOutline2 } from "@mui/icons-material";
33216
- import { Alert as Alert6, AlertTitle as AlertTitle2, Box as Box23, Button as Button7, Typography as Typography16 } from "@mui/material";
33217
- import { jsx as jsx152, jsxs as jsxs139 } from "react/jsx-runtime";
33218
- var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx152(
33219
- Box23,
34011
+ import { Alert as Alert6, AlertTitle as AlertTitle2, Box as Box24, Button as Button7, Typography as Typography17 } from "@mui/material";
34012
+ import { jsx as jsx153, jsxs as jsxs140 } from "react/jsx-runtime";
34013
+ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx153(
34014
+ Box24,
33220
34015
  {
33221
34016
  sx: {
33222
34017
  alignItems: "center",
@@ -33226,17 +34021,17 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx152(
33226
34021
  justifyContent: "center",
33227
34022
  p: 4
33228
34023
  },
33229
- children: /* @__PURE__ */ jsxs139(
34024
+ children: /* @__PURE__ */ jsxs140(
33230
34025
  Alert6,
33231
34026
  {
33232
- icon: /* @__PURE__ */ jsx152(ErrorOutline2, { fontSize: "large" }),
34027
+ icon: /* @__PURE__ */ jsx153(ErrorOutline2, { fontSize: "large" }),
33233
34028
  severity: "error",
33234
34029
  sx: { maxWidth: 600, width: "100%" },
33235
34030
  children: [
33236
- /* @__PURE__ */ jsx152(AlertTitle2, { sx: { fontWeight: "bold" }, children: "Unable to Start Span Filtering" }),
33237
- /* @__PURE__ */ jsx152(Typography16, { 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." }),
33238
- /* @__PURE__ */ jsx152(Typography16, { sx: { fontFamily: "monospace", mb: 2 }, variant: "caption", children: error.message }),
33239
- onRetry && /* @__PURE__ */ jsx152(Box23, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ jsx152(
34031
+ /* @__PURE__ */ jsx153(AlertTitle2, { sx: { fontWeight: "bold" }, children: "Unable to Start Span Filtering" }),
34032
+ /* @__PURE__ */ jsx153(Typography17, { 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." }),
34033
+ /* @__PURE__ */ jsx153(Typography17, { sx: { fontFamily: "monospace", mb: 2 }, variant: "caption", children: error.message }),
34034
+ onRetry && /* @__PURE__ */ jsx153(Box24, { sx: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ jsx153(
33240
34035
  Button7,
33241
34036
  {
33242
34037
  "aria-label": "Retry starting the spans filter worker",
@@ -33252,7 +34047,7 @@ var WorkerErrorMessage = ({ error, onRetry }) => /* @__PURE__ */ jsx152(
33252
34047
  );
33253
34048
 
33254
34049
  // src/hooks/use-filter-used-analytics.ts
33255
- import { useEffect as useEffect22, useRef as useRef18, useState as useState20 } from "react";
34050
+ import { useEffect as useEffect23, useRef as useRef19, useState as useState22 } from "react";
33256
34051
  var FILTER_KEYS = {
33257
34052
  consumer: "service",
33258
34053
  producer: "producer",
@@ -33279,11 +34074,11 @@ var EMPTY_SEARCH = searchPart(parseQuery(""));
33279
34074
  var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, searching }) => {
33280
34075
  const api = useAppInspectorApi();
33281
34076
  const { deploymentContainer } = useAppInspector();
33282
- const previousQueryRef = useRef18(query2);
33283
- const pendingRef = useRef18();
33284
- const changeCountRef = useRef18(0);
33285
- const [settledChange, setSettledChange] = useState20(0);
33286
- useEffect22(() => {
34077
+ const previousQueryRef = useRef19(query2);
34078
+ const pendingRef = useRef19();
34079
+ const changeCountRef = useRef19(0);
34080
+ const [settledChange, setSettledChange] = useState22(0);
34081
+ useEffect23(() => {
33287
34082
  const previous = parseQuery(previousQueryRef.current);
33288
34083
  const next = parseQuery(query2);
33289
34084
  previousQueryRef.current = query2;
@@ -33306,7 +34101,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
33306
34101
  clearTimeout(timer);
33307
34102
  };
33308
34103
  }, [query2]);
33309
- useEffect22(() => {
34104
+ useEffect23(() => {
33310
34105
  const pending = pendingRef.current;
33311
34106
  if (pending === void 0 || filteredCount === void 0) {
33312
34107
  return;
@@ -33352,7 +34147,7 @@ var useFilterUsedAnalytics = ({ filteredCount, query: query2, resultVersion, sea
33352
34147
  };
33353
34148
 
33354
34149
  // src/hooks/use-operation-open-analytics.ts
33355
- import { useEffect as useEffect23, useRef as useRef19 } from "react";
34150
+ import { useEffect as useEffect24, useRef as useRef20 } from "react";
33356
34151
 
33357
34152
  // src/utils/request-id.ts
33358
34153
  var getRequestId = (spans) => {
@@ -33372,8 +34167,8 @@ var getRequestId = (spans) => {
33372
34167
  var useOperationOpenAnalytics = ({ open, shown, spans }) => {
33373
34168
  const api = useAppInspectorApi();
33374
34169
  const { deploymentContainer } = useAppInspector();
33375
- const shownKeyRef = useRef19();
33376
- useEffect23(() => {
34170
+ const shownKeyRef = useRef20();
34171
+ useEffect24(() => {
33377
34172
  const shownKey = open && shown ? `${shown.span.span_id}
33378
34173
  ${shown.view}` : void 0;
33379
34174
  const previousKey = shownKeyRef.current;
@@ -33399,12 +34194,12 @@ ${shown.view}` : void 0;
33399
34194
  };
33400
34195
 
33401
34196
  // src/hooks/use-request-open-analytics.ts
33402
- import { useEffect as useEffect24, useRef as useRef20 } from "react";
34197
+ import { useEffect as useEffect25, useRef as useRef21 } from "react";
33403
34198
  var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
33404
34199
  const api = useAppInspectorApi();
33405
34200
  const { deploymentContainer } = useAppInspector();
33406
- const firedForRef = useRef20();
33407
- useEffect24(() => {
34201
+ const firedForRef = useRef21();
34202
+ useEffect25(() => {
33408
34203
  if (loadStartedAt === void 0 || firedForRef.current === loadStartedAt) {
33409
34204
  return;
33410
34205
  }
@@ -33435,7 +34230,7 @@ var useRequestOpenAnalytics = ({ loadStartedAt, spans, view }) => {
33435
34230
  };
33436
34231
 
33437
34232
  // src/hooks/use-spans.ts
33438
- import { useCallback as useCallback11, useEffect as useEffect27, useRef as useRef23, useState as useState23 } from "react";
34233
+ import { useCallback as useCallback13, useEffect as useEffect28, useRef as useRef24, useState as useState25 } from "react";
33439
34234
  import { unstable_batchedUpdates as batchedUpdates } from "react-dom";
33440
34235
 
33441
34236
  // src/utils/pagination-buffer.ts
@@ -33690,7 +34485,7 @@ var toSpanFilterProjection = (span) => ({
33690
34485
  });
33691
34486
 
33692
34487
  // src/hooks/use-spans-compute.ts
33693
- import { useCallback as useCallback9, useEffect as useEffect25, useRef as useRef21, useState as useState21 } from "react";
34488
+ import { useCallback as useCallback11, useEffect as useEffect26, useRef as useRef22, useState as useState23 } from "react";
33694
34489
 
33695
34490
  // inline-worker:/home/runner/work/localstack-appinspector-ui/localstack-appinspector-ui/src/workers/spans-worker.worker.ts
33696
34491
  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';
@@ -33715,15 +34510,15 @@ var EMPTY_RESULT = {
33715
34510
  };
33716
34511
  var useSpansCompute = () => {
33717
34512
  const { spansWorkerUrl } = useAppInspector();
33718
- const [computeState, setComputeState] = useState21({ loaded: false, result: EMPTY_RESULT, resultVersion: 0 });
34513
+ const [computeState, setComputeState] = useState23({ loaded: false, result: EMPTY_RESULT, resultVersion: 0 });
33719
34514
  const { loaded, result, resultVersion } = computeState;
33720
- const [workerError, setWorkerError] = useState21();
33721
- const [retryCount, setRetryCount] = useState21(0);
33722
- const workerRef = useRef21();
33723
- const seqRef = useRef21(0);
33724
- const lastAppliedRef = useRef21(0);
33725
- const firstPageSeqRef = useRef21();
33726
- useEffect25(() => {
34515
+ const [workerError, setWorkerError] = useState23();
34516
+ const [retryCount, setRetryCount] = useState23(0);
34517
+ const workerRef = useRef22();
34518
+ const seqRef = useRef22(0);
34519
+ const lastAppliedRef = useRef22(0);
34520
+ const firstPageSeqRef = useRef22();
34521
+ useEffect26(() => {
33727
34522
  try {
33728
34523
  const worker = spansWorkerUrl ? new Worker(spansWorkerUrl) : createInlineWorker();
33729
34524
  worker.addEventListener("message", (event) => {
@@ -33750,26 +34545,26 @@ var useSpansCompute = () => {
33750
34545
  return;
33751
34546
  }
33752
34547
  }, [retryCount, spansWorkerUrl]);
33753
- const retryWorker = useCallback9(() => {
34548
+ const retryWorker = useCallback11(() => {
33754
34549
  setWorkerError(void 0);
33755
34550
  setRetryCount((count2) => count2 + 1);
33756
34551
  }, []);
33757
- const addPage = useCallback9((direction, projections) => {
34552
+ const addPage = useCallback11((direction, projections) => {
33758
34553
  const seq = ++seqRef.current;
33759
34554
  firstPageSeqRef.current ??= seq;
33760
34555
  workerRef.current?.postMessage({ direction, op: "addPage", projections, seq });
33761
34556
  }, []);
33762
- const setQuery = useCallback9((query2, textMatches) => {
34557
+ const setQuery = useCallback11((query2, textMatches) => {
33763
34558
  workerRef.current?.postMessage({ op: "setQuery", query: query2, seq: ++seqRef.current, textMatches });
33764
34559
  }, []);
33765
- const clear = useCallback9(() => {
34560
+ const clear = useCallback11(() => {
33766
34561
  workerRef.current?.postMessage({ op: "clear", seq: ++seqRef.current });
33767
34562
  }, []);
33768
34563
  return { addPage, clear, loaded, result, resultVersion, retryWorker, setQuery, workerError };
33769
34564
  };
33770
34565
 
33771
34566
  // src/hooks/use-spans-ws.tsx
33772
- import { useCallback as useCallback10, useEffect as useEffect26, useRef as useRef22, useState as useState22 } from "react";
34567
+ import { useCallback as useCallback12, useEffect as useEffect27, useRef as useRef23, useState as useState24 } from "react";
33773
34568
  var wsLogger = createScopedLogger("WS");
33774
34569
  var isLegacySpanFields = (value) => {
33775
34570
  return typeof value.span_id === "string" && typeof value.trace_id === "string" && typeof value.timestamp === "string";
@@ -33801,22 +34596,22 @@ var parseSpansWebSocketMessage = (raw) => {
33801
34596
  };
33802
34597
  function useSpansWebSocket(options) {
33803
34598
  const { enabled, onClose, onMessage, onOpen } = options;
33804
- const onMessageRef = useRef22(onMessage);
33805
- const onOpenRef = useRef22(onOpen);
33806
- const onCloseRef = useRef22(onClose);
33807
- useEffect26(() => {
34599
+ const onMessageRef = useRef23(onMessage);
34600
+ const onOpenRef = useRef23(onOpen);
34601
+ const onCloseRef = useRef23(onClose);
34602
+ useEffect27(() => {
33808
34603
  onMessageRef.current = onMessage;
33809
34604
  }, [onMessage]);
33810
- useEffect26(() => {
34605
+ useEffect27(() => {
33811
34606
  onOpenRef.current = onOpen;
33812
34607
  }, [onOpen]);
33813
- useEffect26(() => {
34608
+ useEffect27(() => {
33814
34609
  onCloseRef.current = onClose;
33815
34610
  }, [onClose]);
33816
- const [connected, setConnected] = useState22(false);
33817
- const wsRef = useRef22(void 0);
34611
+ const [connected, setConnected] = useState24(false);
34612
+ const wsRef = useRef23(void 0);
33818
34613
  const { localstackEndpoint } = useAppInspector();
33819
- const connect = useCallback10(() => {
34614
+ const connect = useCallback12(() => {
33820
34615
  if (wsRef.current !== void 0) return;
33821
34616
  const url = new URL(getAppInspectorApiUrl(localstackEndpoint, API_ENDPOINTS.WEBSOCKET_SPANS));
33822
34617
  url.protocol = globalThis.location.protocol === "https:" ? "wss" : "ws";
@@ -33857,7 +34652,7 @@ function useSpansWebSocket(options) {
33857
34652
  }
33858
34653
  });
33859
34654
  }, [localstackEndpoint]);
33860
- useEffect26(() => {
34655
+ useEffect27(() => {
33861
34656
  if (!enabled) {
33862
34657
  if (wsRef.current !== void 0) {
33863
34658
  wsRef.current.close();
@@ -33900,42 +34695,42 @@ var useSpans = () => {
33900
34695
  const api = useAppInspectorApi();
33901
34696
  const { onWsClose, onWsOpen, status, wsEnabled } = useAppInspectorStatus();
33902
34697
  const { addPage, clear: clearCompute, loaded: spansLoaded, result: computeResult, resultVersion, retryWorker, setQuery: setComputeQuery, workerError } = useSpansCompute();
33903
- const spanMapRef = useRef23(/* @__PURE__ */ new Map());
33904
- const newSpanIdsRef = useRef23(/* @__PURE__ */ new Set());
33905
- const caughtUpRef = useRef23(false);
33906
- const [fetchError, setFetchError] = useState23();
33907
- const [fetchingForward, setFetchingForward] = useState23(false);
33908
- const [fetchingBackward, setFetchingBackward] = useState23(false);
33909
- const [query2, setQueryState] = useState23("");
33910
- const [searching, setSearching] = useState23(false);
33911
- const paginationBufferRef = useRef23();
33912
- const [totalCount, setTotalCount] = useState23();
33913
- const [licenseLimit, setLicenseLimit] = useState23();
33914
- const [systemLimit, setSystemLimit] = useState23();
33915
- const [errorCount, setErrorCount] = useState23();
33916
- const [warningCount, setWarningCount] = useState23();
33917
- const [hasMoreBackward, setHasMoreBackward] = useState23();
33918
- const [hasMoreForward, setHasMoreForward] = useState23();
33919
- const fetchForward = useCallback11(() => {
34698
+ const spanMapRef = useRef24(/* @__PURE__ */ new Map());
34699
+ const newSpanIdsRef = useRef24(/* @__PURE__ */ new Set());
34700
+ const caughtUpRef = useRef24(false);
34701
+ const [fetchError, setFetchError] = useState25();
34702
+ const [fetchingForward, setFetchingForward] = useState25(false);
34703
+ const [fetchingBackward, setFetchingBackward] = useState25(false);
34704
+ const [query2, setQueryState] = useState25("");
34705
+ const [searching, setSearching] = useState25(false);
34706
+ const paginationBufferRef = useRef24();
34707
+ const [totalCount, setTotalCount] = useState25();
34708
+ const [licenseLimit, setLicenseLimit] = useState25();
34709
+ const [systemLimit, setSystemLimit] = useState25();
34710
+ const [errorCount, setErrorCount] = useState25();
34711
+ const [warningCount, setWarningCount] = useState25();
34712
+ const [hasMoreBackward, setHasMoreBackward] = useState25();
34713
+ const [hasMoreForward, setHasMoreForward] = useState25();
34714
+ const fetchForward = useCallback13(() => {
33920
34715
  void paginationBufferRef.current?.fetchForward();
33921
34716
  }, []);
33922
- const fetchBackward = useCallback11(() => {
34717
+ const fetchBackward = useCallback13(() => {
33923
34718
  void paginationBufferRef.current?.fetchBackward();
33924
34719
  }, []);
33925
- const resetCorpus = useCallback11(() => {
34720
+ const resetCorpus = useCallback13(() => {
33926
34721
  spanMapRef.current.clear();
33927
34722
  newSpanIdsRef.current.clear();
33928
34723
  caughtUpRef.current = false;
33929
34724
  clearCompute();
33930
34725
  }, [clearCompute]);
33931
- const [epoch, setEpoch] = useState23();
33932
- const onEpochSeen = useCallback11((observedEpoch) => {
34726
+ const [epoch, setEpoch] = useState25();
34727
+ const onEpochSeen = useCallback13((observedEpoch) => {
33933
34728
  if (observedEpoch === null || observedEpoch === void 0) {
33934
34729
  return;
33935
34730
  }
33936
34731
  setEpoch(observedEpoch);
33937
34732
  }, []);
33938
- const clearCache = useCallback11(() => {
34733
+ const clearCache = useCallback13(() => {
33939
34734
  paginationBufferRef.current?.clear();
33940
34735
  resetCorpus();
33941
34736
  setTotalCount(void 0);
@@ -33943,9 +34738,9 @@ var useSpans = () => {
33943
34738
  setWarningCount(void 0);
33944
34739
  void paginationBufferRef.current?.fetchForward();
33945
34740
  }, [resetCorpus]);
33946
- const hasFetchedWithoutEpochRef = useRef23(false);
33947
- const previousEpochRef = useRef23();
33948
- useEffect27(() => {
34741
+ const hasFetchedWithoutEpochRef = useRef24(false);
34742
+ const previousEpochRef = useRef24();
34743
+ useEffect28(() => {
33949
34744
  if (epoch === void 0) {
33950
34745
  return;
33951
34746
  }
@@ -33958,11 +34753,11 @@ var useSpans = () => {
33958
34753
  }, [epoch, clearCache]);
33959
34754
  const searchSupported = emulatorSupportsSearch(status?.localstackVersion);
33960
34755
  const freeText = parseQuery(query2).words.join(" ");
33961
- const setQuery = useCallback11((next) => {
34756
+ const setQuery = useCallback13((next) => {
33962
34757
  setQueryState(next);
33963
34758
  setComputeQuery(next);
33964
34759
  }, [setComputeQuery]);
33965
- useEffect27(() => {
34760
+ useEffect28(() => {
33966
34761
  if (!searchSupported || freeText === "") {
33967
34762
  return;
33968
34763
  }
@@ -33983,7 +34778,7 @@ var useSpans = () => {
33983
34778
  setSearching(false);
33984
34779
  };
33985
34780
  }, [api, freeText, query2, searchSupported, setComputeQuery]);
33986
- useEffect27(() => {
34781
+ useEffect28(() => {
33987
34782
  const buffer = createPaginationBuffer({
33988
34783
  async fetchPage(token, signal) {
33989
34784
  const requestPage = async (paginationToken) => {
@@ -34054,8 +34849,8 @@ var useSpans = () => {
34054
34849
  paginationBufferRef.current = buffer;
34055
34850
  void buffer.fetchForward();
34056
34851
  }, [api, addPage, onEpochSeen, resetCorpus]);
34057
- const [clearingSpans, setClearingSpans] = useState23(false);
34058
- const clearSpans = useCallback11(async () => {
34852
+ const [clearingSpans, setClearingSpans] = useState25(false);
34853
+ const clearSpans = useCallback13(async () => {
34059
34854
  if (clearingSpans) {
34060
34855
  return;
34061
34856
  }
@@ -34073,17 +34868,17 @@ var useSpans = () => {
34073
34868
  setClearingSpans(false);
34074
34869
  }
34075
34870
  }, [clearingSpans, api, resetCorpus]);
34076
- useEffect27(() => {
34871
+ useEffect28(() => {
34077
34872
  if (hasMoreForward === true && !fetchingForward) {
34078
34873
  void paginationBufferRef.current?.fetchForward();
34079
34874
  }
34080
34875
  }, [hasMoreForward, fetchingForward]);
34081
- useEffect27(() => {
34876
+ useEffect28(() => {
34082
34877
  if (hasMoreBackward === true && !fetchingBackward && !fetchingForward) {
34083
34878
  void paginationBufferRef.current?.fetchBackward();
34084
34879
  }
34085
34880
  }, [hasMoreBackward, fetchingBackward, fetchingForward]);
34086
- const [previousStatusEpoch, setPreviousStatusEpoch] = useState23();
34881
+ const [previousStatusEpoch, setPreviousStatusEpoch] = useState25();
34087
34882
  if (status !== void 0 && status.epoch !== previousStatusEpoch) {
34088
34883
  setPreviousStatusEpoch(status.epoch);
34089
34884
  onEpochSeen(status.epoch);
@@ -34108,10 +34903,10 @@ var useSpans = () => {
34108
34903
  fetchForward();
34109
34904
  }
34110
34905
  });
34111
- const clearFetchError = useCallback11(() => {
34906
+ const clearFetchError = useCallback13(() => {
34112
34907
  setFetchError(void 0);
34113
34908
  }, []);
34114
- const getSpan = useCallback11((spanId) => spanMapRef.current.get(spanId), []);
34909
+ const getSpan = useCallback13((spanId) => spanMapRef.current.get(spanId), []);
34115
34910
  const newSpanIds = newSpanIdsRef.current;
34116
34911
  return {
34117
34912
  clearFetchError,
@@ -34143,7 +34938,8 @@ var useSpans = () => {
34143
34938
  };
34144
34939
 
34145
34940
  // src/pages/spans-list-page.tsx
34146
- import { jsx as jsx153, jsxs as jsxs140 } from "react/jsx-runtime";
34941
+ import { jsx as jsx154, jsxs as jsxs141 } from "react/jsx-runtime";
34942
+ var ANALYTICS_REQUEST_VIEWS = { map: "flow_graph", sequence: "sequence_graph", waterfall: "operations" };
34147
34943
  var SpansListPage = () => {
34148
34944
  const api = useAppInspectorApi();
34149
34945
  const {
@@ -34176,49 +34972,49 @@ var SpansListPage = () => {
34176
34972
  resultVersion,
34177
34973
  searching
34178
34974
  });
34179
- const clearSpansSync = useCallback12(() => {
34975
+ const clearSpansSync = useCallback14(() => {
34180
34976
  void clearSpans();
34181
34977
  }, [clearSpans]);
34182
34978
  const localstackVersion = status?.localstackVersion ?? (statusError instanceof AppInspectorNotFoundError ? statusError.localstackVersion : void 0);
34183
34979
  const versionCompatibility = checkEmulatorVersion(localstackVersion);
34184
- const [bannerDismissed, setBannerDismissed] = useState24(false);
34980
+ const [bannerDismissed, setBannerDismissed] = useState26(false);
34185
34981
  const [order2, setOrder] = useLocalStorage("spans-order", "oldest_first");
34186
- const [selectedSpanId, setSelectedSpanId] = useState24();
34187
- const getTreeSpans = useCallback12((rootSpanId2) => Object.entries(compute.rows).filter(([, row]) => row.rootSpanId === rootSpanId2).map(([spanId]) => getSpan(spanId)).filter((span) => span !== void 0), [compute.rows, getSpan]);
34188
- const latestRef = useRef24({ compute, getTreeSpans });
34189
- useEffect28(() => {
34982
+ const [selectedSpanId, setSelectedSpanId] = useState26();
34983
+ const getTreeSpans = useCallback14((rootSpanId2) => Object.entries(compute.rows).filter(([, row]) => row.rootSpanId === rootSpanId2).map(([spanId]) => getSpan(spanId)).filter((span) => span !== void 0), [compute.rows, getSpan]);
34984
+ const latestRef = useRef25({ compute, getTreeSpans });
34985
+ useEffect29(() => {
34190
34986
  latestRef.current = { compute, getTreeSpans };
34191
34987
  }, [compute, getTreeSpans]);
34192
- const openedAtRef = useRef24();
34193
- const navigateToSpan = useCallback12((span) => {
34988
+ const openedAtRef = useRef25();
34989
+ const navigateToSpan = useCallback14((span) => {
34194
34990
  openedAtRef.current = performance.now();
34195
34991
  const { compute: { queryActive, rows }, getTreeSpans: getSpans } = latestRef.current;
34196
34992
  const rootSpanId2 = rows[span.span_id]?.rootSpanId;
34197
34993
  const firstMatch = queryActive && rootSpanId2 !== void 0 ? findFirstSpan(buildTraceTree(getSpans(rootSpanId2)).roots, (spanId) => rows[spanId]?.matches ?? false) : void 0;
34198
34994
  setSelectedSpanId(firstMatch?.span_id ?? span.span_id);
34199
34995
  }, []);
34200
- const [shownOperation, setShownOperation] = useState24();
34201
- const closeSidebar = useCallback12(() => {
34996
+ const [shownOperation, setShownOperation] = useState26();
34997
+ const closeSidebar = useCallback14(() => {
34202
34998
  setSelectedSpanId(void 0);
34203
34999
  setShownOperation(void 0);
34204
35000
  }, []);
34205
35001
  const rootSpanId = selectedSpanId === void 0 ? void 0 : compute.rows[selectedSpanId]?.rootSpanId;
34206
- const treeSpans = useMemo13(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
34207
- const spanMatches = useMemo13(
35002
+ const treeSpans = useMemo14(() => rootSpanId === void 0 ? [] : getTreeSpans(rootSpanId), [getTreeSpans, rootSpanId]);
35003
+ const spanMatches = useMemo14(
34208
35004
  () => compute.queryActive ? (spanId) => compute.rows[spanId]?.matches ?? false : void 0,
34209
35005
  [compute]
34210
35006
  );
34211
- const treeSpansRef = useRef24(treeSpans);
34212
- useEffect28(() => {
35007
+ const treeSpansRef = useRef25(treeSpans);
35008
+ useEffect29(() => {
34213
35009
  treeSpansRef.current = treeSpans;
34214
35010
  }, [treeSpans]);
34215
- const [renderedRequest, setRenderedRequest] = useState24();
34216
- const handleRequestRendered = useCallback12((view) => {
35011
+ const [renderedRequest, setRenderedRequest] = useState26();
35012
+ const handleRequestRendered = useCallback14((view) => {
34217
35013
  const openedAt = openedAtRef.current;
34218
35014
  if (openedAt === void 0) return;
34219
- setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: view === "map" ? "flow_graph" : "operations" });
35015
+ setRenderedRequest({ openedAt, spans: treeSpansRef.current, view: ANALYTICS_REQUEST_VIEWS[view] });
34220
35016
  }, []);
34221
- const handleViewChange = useCallback12(() => {
35017
+ const handleViewChange = useCallback14(() => {
34222
35018
  openedAtRef.current = performance.now();
34223
35019
  }, []);
34224
35020
  useRequestOpenAnalytics({
@@ -34227,28 +35023,28 @@ var SpansListPage = () => {
34227
35023
  view: renderedRequest?.view ?? "operations"
34228
35024
  });
34229
35025
  const sidebarOpen = selectedSpanId !== void 0 && rootSpanId !== void 0;
34230
- const handleOperationShown = useCallback12((spanId, view) => {
35026
+ const handleOperationShown = useCallback14((spanId, view) => {
34231
35027
  setShownOperation({ spanId, view });
34232
35028
  }, []);
34233
- const shown = useMemo13(() => {
35029
+ const shown = useMemo14(() => {
34234
35030
  if (shownOperation === void 0) return;
34235
35031
  const span = treeSpans.find((treeSpan) => treeSpan.span_id === shownOperation.spanId);
34236
35032
  return span && { span, view: shownOperation.view };
34237
35033
  }, [shownOperation, treeSpans]);
34238
35034
  useOperationOpenAnalytics({ open: sidebarOpen, shown, spans: treeSpans });
34239
- const handleRetry = useCallback12(() => {
35035
+ const handleRetry = useCallback14(() => {
34240
35036
  checkStatus();
34241
35037
  fetchForward();
34242
35038
  }, [checkStatus, fetchForward]);
34243
- const handleEnable = useCallback12(async () => {
35039
+ const handleEnable = useCallback14(async () => {
34244
35040
  await api.setStatus({ status: "ENABLED" });
34245
35041
  clearFetchError();
34246
35042
  checkStatus();
34247
35043
  }, [api, checkStatus, clearFetchError]);
34248
- const isDelayedRefetchRef = useRef24(false);
34249
- const delayedRefetchTimerRef = useRef24();
34250
- const prevFetchingForwardRef = useRef24(false);
34251
- useEffect28(() => {
35044
+ const isDelayedRefetchRef = useRef25(false);
35045
+ const delayedRefetchTimerRef = useRef25();
35046
+ const prevFetchingForwardRef = useRef25(false);
35047
+ useEffect29(() => {
34252
35048
  const wasFetching = prevFetchingForwardRef.current;
34253
35049
  prevFetchingForwardRef.current = fetchingForward;
34254
35050
  if (wasFetching && !fetchingForward) {
@@ -34269,10 +35065,10 @@ var SpansListPage = () => {
34269
35065
  switch (phase) {
34270
35066
  case "CHECKING_STATUS":
34271
35067
  case "CONNECTING_WS": {
34272
- return /* @__PURE__ */ jsx153(StatusMessage, { phase });
35068
+ return /* @__PURE__ */ jsx154(StatusMessage, { phase });
34273
35069
  }
34274
35070
  case "DISABLED": {
34275
- return /* @__PURE__ */ jsx153(
35071
+ return /* @__PURE__ */ jsx154(
34276
35072
  StatusMessage,
34277
35073
  {
34278
35074
  onEnable: handleEnable,
@@ -34281,7 +35077,7 @@ var SpansListPage = () => {
34281
35077
  );
34282
35078
  }
34283
35079
  case "INCOMPATIBLE": {
34284
- return /* @__PURE__ */ jsx153(
35080
+ return /* @__PURE__ */ jsx154(
34285
35081
  StatusMessage,
34286
35082
  {
34287
35083
  localstackVersion,
@@ -34292,12 +35088,12 @@ var SpansListPage = () => {
34292
35088
  }
34293
35089
  case "LIVE": {
34294
35090
  if (workerError) {
34295
- return /* @__PURE__ */ jsx153(WorkerErrorMessage, { error: workerError, onRetry: retryWorker });
35091
+ return /* @__PURE__ */ jsx154(WorkerErrorMessage, { error: workerError, onRetry: retryWorker });
34296
35092
  }
34297
35093
  break;
34298
35094
  }
34299
35095
  case "UNREACHABLE": {
34300
- return /* @__PURE__ */ jsx153(
35096
+ return /* @__PURE__ */ jsx154(
34301
35097
  StatusMessage,
34302
35098
  {
34303
35099
  onRetry: handleRetry,
@@ -34306,9 +35102,9 @@ var SpansListPage = () => {
34306
35102
  );
34307
35103
  }
34308
35104
  }
34309
- return /* @__PURE__ */ jsxs140(Paper2, { square: true, sx: { ...THEMED_SCROLLBARS, display: "flex", flexDirection: "row", flexGrow: 1, minHeight: 0, overflow: "hidden" }, children: [
34310
- /* @__PURE__ */ jsxs140(
34311
- Box24,
35105
+ return /* @__PURE__ */ jsxs141(Paper3, { square: true, sx: { ...THEMED_SCROLLBARS, display: "flex", flexDirection: "row", flexGrow: 1, minHeight: 0, overflow: "hidden" }, children: [
35106
+ /* @__PURE__ */ jsxs141(
35107
+ Box25,
34312
35108
  {
34313
35109
  "data-testid": SPANS_LIST_PAGE_TEST_ID,
34314
35110
  sx: {
@@ -34321,7 +35117,7 @@ var SpansListPage = () => {
34321
35117
  overflow: "hidden"
34322
35118
  },
34323
35119
  children: [
34324
- /* @__PURE__ */ jsx153(
35120
+ /* @__PURE__ */ jsx154(
34325
35121
  EmulatorVersionBanner,
34326
35122
  {
34327
35123
  compatibility: bannerDismissed && versionCompatibility === "warning" ? "ok" : versionCompatibility,
@@ -34331,7 +35127,7 @@ var SpansListPage = () => {
34331
35127
  } : void 0
34332
35128
  }
34333
35129
  ),
34334
- /* @__PURE__ */ jsx153(
35130
+ /* @__PURE__ */ jsx154(
34335
35131
  SpansList,
34336
35132
  {
34337
35133
  clearingSpans,
@@ -34358,7 +35154,7 @@ var SpansListPage = () => {
34358
35154
  ]
34359
35155
  }
34360
35156
  ),
34361
- selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ jsx153(
35157
+ selectedSpanId !== void 0 && rootSpanId !== void 0 && /* @__PURE__ */ jsx154(
34362
35158
  TraceSidebar,
34363
35159
  {
34364
35160
  onClose: closeSidebar,