"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    computeSankeyDimensions: ()=>computeSankeyDimensions,
    ApSankeyDiagram: ()=>ApSankeyDiagram
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const Add_namespaceObject = require("@mui/icons-material/Add");
var Add_default = /*#__PURE__*/ __webpack_require__.n(Add_namespaceObject);
const FitScreen_namespaceObject = require("@mui/icons-material/FitScreen");
var FitScreen_default = /*#__PURE__*/ __webpack_require__.n(FitScreen_namespaceObject);
const Remove_namespaceObject = require("@mui/icons-material/Remove");
var Remove_default = /*#__PURE__*/ __webpack_require__.n(Remove_namespaceObject);
const material_namespaceObject = require("@mui/material");
const styles_namespaceObject = require("@mui/material/styles");
const apollo_core_namespaceObject = require("@uipath/apollo-core");
var apollo_core_default = /*#__PURE__*/ __webpack_require__.n(apollo_core_namespaceObject);
const external_d3_sankey_namespaceObject = require("d3-sankey");
const external_d3_scale_chromatic_namespaceObject = require("d3-scale-chromatic");
const external_d3_selection_namespaceObject = require("d3-selection");
const external_d3_zoom_namespaceObject = require("d3-zoom");
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const SankeyContainer = (0, styles_namespaceObject.styled)('div')({
    position: 'relative',
    overflow: 'hidden',
    fontFamily: apollo_core_default().FontFamily.FontNormal,
    width: '100%',
    height: '600px',
    '& svg': {
        display: 'block'
    }
});
const StyledSankeyNode = (0, styles_namespaceObject.styled)('rect')({
    transition: 'opacity 0.2s',
    cursor: 'pointer',
    '&:hover': {
        opacity: 0.8
    }
});
const StyledSankeyLink = (0, styles_namespaceObject.styled)('path')({
    transition: 'opacity 0.2s',
    mixBlendMode: 'normal',
    cursor: 'pointer',
    '&:hover': {
        opacity: 1
    }
});
const LABEL_FONT_SIZE = apollo_core_default().FontVariantToken.fontSizeL;
const LABEL_FONT_FAMILY = apollo_core_default().FontFamily.FontNormal;
const LABEL_CSS_FONT = `${apollo_core_default().Typography.fontSizeL.fontWeight} ${apollo_core_default().Typography.fontSizeL.fontSize} ${LABEL_FONT_FAMILY}`;
const StyledSankeyNodeLabel = (0, styles_namespaceObject.styled)('text')({
    fontSize: LABEL_FONT_SIZE,
    fontFamily: LABEL_FONT_FAMILY,
    fill: 'var(--color-foreground-emp)',
    pointerEvents: 'auto',
    userSelect: 'none',
    cursor: 'default'
});
const StyledSankeyNodeValue = (0, styles_namespaceObject.styled)('text')({
    fontSize: LABEL_FONT_SIZE,
    fontFamily: LABEL_FONT_FAMILY,
    fontWeight: apollo_core_default().FontFamily.FontWeightMedium,
    fill: 'var(--color-foreground-emp)',
    pointerEvents: 'auto',
    userSelect: 'none',
    cursor: 'default'
});
const LinkTooltipContent = (0, styles_namespaceObject.styled)(material_namespaceObject.Paper)({
    backgroundColor: 'var(--color-background)',
    border: '1px solid var(--color-border)',
    borderRadius: apollo_core_default().Border.BorderRadiusM,
    padding: apollo_core_default().Spacing.SpacingM,
    minWidth: '200px',
    pointerEvents: 'none'
});
const TooltipRow = (0, styles_namespaceObject.styled)('div')({
    display: 'flex',
    justifyContent: 'space-between',
    padding: `${apollo_core_default().Spacing.SpacingXs} 0`,
    fontSize: apollo_core_default().FontVariantToken.fontSizeS,
    '&:not(:last-child)': {
        borderBottom: '1px solid var(--color-border)'
    }
});
const TooltipHeader = (0, styles_namespaceObject.styled)('span')({
    fontSize: apollo_core_default().FontVariantToken.fontSizeM,
    fontWeight: apollo_core_default().FontFamily.FontWeightSemibold,
    color: 'var(--color-foreground-emp)'
});
const TooltipLabel = (0, styles_namespaceObject.styled)('span')({
    color: 'var(--color-foreground-de-emp)',
    marginRight: apollo_core_default().Spacing.SpacingM
});
const TooltipValue = (0, styles_namespaceObject.styled)('span')({
    color: 'var(--color-foreground-emp)',
    fontWeight: apollo_core_default().FontFamily.FontWeightSemibold
});
const ZoomControls = (0, styles_namespaceObject.styled)('div')({
    position: 'absolute',
    bottom: apollo_core_default().Spacing.SpacingM,
    right: apollo_core_default().Spacing.SpacingM,
    display: 'flex',
    gap: '1px',
    backgroundColor: apollo_core_default().Colors.ColorGray100,
    borderRadius: apollo_core_default().Border.BorderRadiusM,
    overflow: 'hidden',
    boxShadow: apollo_core_default().Shadow.ShadowDp2
});
const DIAGRAM_MARGIN_LEFT = 5;
const DIAGRAM_MARGIN_RIGHT = 120;
const DIAGRAM_MARGIN_TOP = 5;
const DIAGRAM_MARGIN_BOTTOM = 40;
const ZOOM_SCALE_EXTENT_MIN = 0.5;
const ZOOM_SCALE_EXTENT_MAX = 2;
function computeSankeyDimensions(data, nodePadding, minNodeHeight, minColumnWidth, marginLeft, marginRight, marginTop, marginBottom) {
    if (!data || 0 === data.nodes.length) return {
        minWidth: 0,
        minHeight: 0
    };
    const outgoing = new Map();
    const incoming = new Map();
    for (const node of data.nodes){
        outgoing.set(node.id, []);
        incoming.set(node.id, []);
    }
    for (const link of data.links){
        outgoing.get(link.source)?.push(link.target);
        incoming.get(link.target)?.push(link.source);
    }
    const depth = new Map();
    const sources = data.nodes.filter((n)=>(incoming.get(n.id)?.length ?? 0) === 0);
    const queue = [];
    for (const s of sources){
        depth.set(s.id, 0);
        queue.push(s.id);
    }
    const maxIterations = data.nodes.length * data.links.length + data.nodes.length;
    let iterations = 0;
    while(queue.length > 0 && iterations++ < maxIterations){
        const id = queue.shift();
        const d = depth.get(id);
        for (const target of outgoing.get(id) ?? [])if (!depth.has(target) || depth.get(target) < d + 1) {
            depth.set(target, d + 1);
            queue.push(target);
        }
    }
    const columnCounts = new Map();
    for (const d of depth.values())columnCounts.set(d, (columnCounts.get(d) ?? 0) + 1);
    const columnCount = columnCounts.size;
    const maxNodesPerColumn = Math.max(0, ...columnCounts.values());
    const minWidth = columnCount * minColumnWidth + marginLeft + marginRight;
    const minHeight = maxNodesPerColumn * (minNodeHeight + nodePadding) - nodePadding + marginTop + marginBottom;
    return {
        minWidth,
        minHeight
    };
}
const truncateToFit = (text, maxWidth, ctx)=>{
    if (maxWidth <= 0) return '';
    if (ctx.measureText(text).width <= maxWidth) return text;
    const ellipsis = '\u2026';
    let lo = 0;
    let hi = text.length;
    while(lo < hi){
        const mid = Math.ceil((lo + hi) / 2);
        if (ctx.measureText(text.substring(0, mid) + ellipsis).width <= maxWidth) lo = mid;
        else hi = mid - 1;
    }
    return 0 === lo ? ellipsis : text.substring(0, lo) + ellipsis;
};
const ApSankeyDiagram = /*#__PURE__*/ external_react_default().forwardRef((props, ref)=>{
    const { data, nodeAlignment = 'justify', nodePadding = 16, nodeWidth = 24, style, className, colorScheme = external_d3_scale_chromatic_namespaceObject.schemeTableau10, ariaLabel = 'Sankey diagram', onLinkClick, onNodeClick, minNodeHeight = 36, minColumnWidth = 140 } = props;
    const containerRef = (0, external_react_namespaceObject.useRef)(null);
    const svgRef = (0, external_react_namespaceObject.useRef)(null);
    const zoomGroupRef = (0, external_react_namespaceObject.useRef)(null);
    const zoomBehaviorRef = (0, external_react_namespaceObject.useRef)(null);
    const zoomTransformRef = (0, external_react_namespaceObject.useRef)(external_d3_zoom_namespaceObject.zoomIdentity);
    const hasUserZoomedRef = (0, external_react_namespaceObject.useRef)(false);
    const [containerWidth, setContainerWidth] = (0, external_react_namespaceObject.useState)(0);
    const [containerHeight, setContainerHeight] = (0, external_react_namespaceObject.useState)(0);
    const [selectedLinkIndex, setSelectedLinkIndex] = (0, external_react_namespaceObject.useState)(null);
    const [hoveredNodeId, setHoveredNodeId] = (0, external_react_namespaceObject.useState)(null);
    const [anchorEl, setAnchorEl] = (0, external_react_namespaceObject.useState)(null);
    (0, external_react_namespaceObject.useImperativeHandle)(ref, ()=>containerRef.current);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (containerRef.current) {
            const resizeObserver = new ResizeObserver((entries)=>{
                const entry = entries[0];
                if (entry) {
                    setContainerWidth(entry.contentRect.width);
                    setContainerHeight(entry.contentRect.height);
                }
            });
            resizeObserver.observe(containerRef.current);
            return ()=>resizeObserver.disconnect();
        }
    }, []);
    const actualWidth = containerWidth || 1200;
    const actualHeight = containerHeight || 600;
    const { minWidth, minHeight } = (0, external_react_namespaceObject.useMemo)(()=>{
        if (!data || 0 === data.nodes.length) return {
            minWidth: 0,
            minHeight: 0
        };
        return computeSankeyDimensions(data, nodePadding, minNodeHeight, minColumnWidth, DIAGRAM_MARGIN_LEFT, DIAGRAM_MARGIN_RIGHT, DIAGRAM_MARGIN_TOP, DIAGRAM_MARGIN_BOTTOM);
    }, [
        data,
        nodePadding,
        minNodeHeight,
        minColumnWidth
    ]);
    const svgWidth = Math.max(actualWidth, minWidth);
    const svgHeight = Math.max(actualHeight, minHeight);
    const nodeColorMap = (0, external_react_namespaceObject.useMemo)(()=>{
        const map = new Map();
        if (!data) return map;
        data.nodes.forEach((node, index)=>{
            const color = node.color || colorScheme[index % colorScheme.length];
            map.set(node.id, color || apollo_core_default().Colors.ColorGray500);
        });
        return map;
    }, [
        data,
        colorScheme
    ]);
    const sankeyGraph = (0, external_react_namespaceObject.useMemo)(()=>{
        if (!data || 0 === data.nodes.length) return null;
        const alignmentFn = 'left' === nodeAlignment ? external_d3_sankey_namespaceObject.sankeyLeft : 'right' === nodeAlignment ? external_d3_sankey_namespaceObject.sankeyRight : 'center' === nodeAlignment ? external_d3_sankey_namespaceObject.sankeyCenter : external_d3_sankey_namespaceObject.sankeyJustify;
        const sankeyGenerator = (0, external_d3_sankey_namespaceObject.sankey)().nodeId((d)=>d.id).nodeAlign(alignmentFn).nodeWidth(nodeWidth).nodePadding(nodePadding).extent([
            [
                DIAGRAM_MARGIN_LEFT,
                DIAGRAM_MARGIN_TOP
            ],
            [
                svgWidth - DIAGRAM_MARGIN_RIGHT,
                svgHeight - DIAGRAM_MARGIN_BOTTOM
            ]
        ]);
        const graph = {
            nodes: data.nodes.map((node)=>({
                    ...node
                })),
            links: data.links.map((link)=>({
                    ...link
                }))
        };
        return sankeyGenerator(graph);
    }, [
        data,
        nodeAlignment,
        nodeWidth,
        nodePadding,
        svgWidth,
        svgHeight
    ]);
    const linkPaths = (0, external_react_namespaceObject.useMemo)(()=>{
        if (!sankeyGraph) return [];
        const linkPathGenerator = (0, external_d3_sankey_namespaceObject.sankeyLinkHorizontal)();
        return sankeyGraph.links.map((link, index)=>{
            const sourceNode = link.source;
            const targetNode = link.target;
            const sourceColor = nodeColorMap.get(sourceNode.id) || colorScheme[0] || apollo_core_default().Colors.ColorGray500;
            const targetColor = nodeColorMap.get(targetNode.id) || colorScheme[1] || apollo_core_default().Colors.ColorGray500;
            const sourceX = sourceNode.x1 || 0;
            const targetX = targetNode.x0 || 0;
            const sourceY = link.y0 || 0;
            const targetY = link.y1 || 0;
            const centerX = (sourceX + targetX) / 2;
            const centerY = (sourceY + targetY) / 2;
            const originalLink = {
                source: sourceNode.id,
                target: targetNode.id,
                value: link.value,
                color: link.color,
                metadata: link.metadata
            };
            return {
                path: linkPathGenerator(link) || '',
                strokeWidth: Math.max(1, link.width || 0),
                color: link.color,
                sourceColor,
                targetColor,
                gradientId: `sankey-gradient-${index}`,
                originalLink,
                sourceId: sourceNode.id,
                targetId: targetNode.id,
                sourceLabel: sourceNode.label,
                targetLabel: targetNode.label,
                sourceX,
                targetX,
                centerX,
                centerY
            };
        });
    }, [
        sankeyGraph,
        nodeColorMap,
        colorScheme
    ]);
    const nodeData = (0, external_react_namespaceObject.useMemo)(()=>{
        if (!sankeyGraph) return [];
        const labelPad = parseInt(apollo_core_default().Spacing.SpacingXs, 10);
        const ctx = "u" > typeof document ? document.createElement('canvas').getContext('2d') : null;
        if (ctx) ctx.font = LABEL_CSS_FONT;
        const columnSet = new Map();
        for (const n of sankeyGraph.nodes){
            const ext = n;
            const x0 = ext.x0 || 0;
            const x1 = ext.x1 || 0;
            if (!columnSet.has(x0)) columnSet.set(x0, x1);
        }
        const columns = Array.from(columnSet.entries()).map(([x0, x1])=>({
                x0,
                x1
            })).sort((a, b)=>a.x0 - b.x0);
        return sankeyGraph.nodes.map((node, index)=>{
            const extNode = node;
            const x0 = extNode.x0 || 0;
            const x1 = extNode.x1 || 0;
            const y0 = extNode.y0 || 0;
            const y1 = extNode.y1 || 0;
            const colIndex = columns.findIndex((col)=>col.x0 === x0);
            const nextCol = columns[colIndex + 1];
            const displayLabel = nextCol && ctx ? truncateToFit(extNode.label, Math.max(0, nextCol.x0 - x1 - labelPad), ctx) : extNode.label;
            return {
                node: extNode,
                x: x0,
                y: y0,
                width: x1 - x0,
                height: y1 - y0,
                color: nodeColorMap.get(extNode.id) || colorScheme[index % colorScheme.length],
                labelX: x1 + labelPad,
                labelY: (y0 + y1) / 2,
                labelAnchor: 'start',
                value: extNode.value || 0,
                displayLabel,
                fullLabel: extNode.label
            };
        });
    }, [
        sankeyGraph,
        nodeColorMap,
        colorScheme
    ]);
    const fitToView = (0, external_react_namespaceObject.useCallback)(()=>{
        const svg = svgRef.current;
        const zoomBehavior = zoomBehaviorRef.current;
        if (!svg || !zoomBehavior || 0 === svgWidth || 0 === svgHeight) return;
        hasUserZoomedRef.current = false;
        const cw = containerWidth || 1;
        const ch = containerHeight || 1;
        const scale = 0.95 * Math.min(cw / svgWidth, ch / svgHeight);
        const tx = (cw - svgWidth * scale) / 2;
        const ty = (ch - svgHeight * scale) / 2;
        const t = external_d3_zoom_namespaceObject.zoomIdentity.translate(tx, ty).scale(scale);
        (0, external_d3_selection_namespaceObject.select)(svg).transition().duration(300).call(zoomBehavior.transform, t);
    }, [
        containerWidth,
        containerHeight,
        svgWidth,
        svgHeight
    ]);
    (0, external_react_namespaceObject.useEffect)(()=>{
        const svg = svgRef.current;
        const zoomGroup = zoomGroupRef.current;
        if (!svg || !zoomGroup) return;
        const zoomBehavior = (0, external_d3_zoom_namespaceObject.zoom)().scaleExtent([
            ZOOM_SCALE_EXTENT_MIN,
            ZOOM_SCALE_EXTENT_MAX
        ]).filter((event)=>{
            if ('wheel' === event.type) return event.ctrlKey || event.metaKey;
            return !event.button;
        }).on('zoom', (event)=>{
            const t = event.transform;
            zoomTransformRef.current = t;
            zoomGroup.setAttribute('transform', `translate(${t.x},${t.y}) scale(${t.k})`);
            if (event.sourceEvent) hasUserZoomedRef.current = true;
        });
        zoomBehaviorRef.current = zoomBehavior;
        (0, external_d3_selection_namespaceObject.select)(svg).call(zoomBehavior);
        return ()=>{
            (0, external_d3_selection_namespaceObject.select)(svg).on('.zoom', null);
            zoomBehaviorRef.current = null;
        };
    }, []);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (!sankeyGraph || 0 === containerWidth || 0 === containerHeight) return;
        if (hasUserZoomedRef.current) return;
        fitToView();
    }, [
        sankeyGraph,
        containerWidth,
        containerHeight,
        fitToView
    ]);
    const handleZoomIn = (0, external_react_namespaceObject.useCallback)(()=>{
        const svg = svgRef.current;
        const zoomBehavior = zoomBehaviorRef.current;
        if (!svg || !zoomBehavior) return;
        (0, external_d3_selection_namespaceObject.select)(svg).transition().duration(200).call(zoomBehavior.scaleBy, 1.3);
    }, []);
    const handleZoomOut = (0, external_react_namespaceObject.useCallback)(()=>{
        const svg = svgRef.current;
        const zoomBehavior = zoomBehaviorRef.current;
        if (!svg || !zoomBehavior) return;
        (0, external_d3_selection_namespaceObject.select)(svg).transition().duration(200).call(zoomBehavior.scaleBy, 1 / 1.3);
    }, []);
    const handleLinkMouseEnter = (0, external_react_namespaceObject.useCallback)((index, centerX, centerY)=>{
        if (selectedLinkIndex === index) return;
        const svgRect = svgRef.current?.getBoundingClientRect();
        if (svgRect) {
            const t = zoomTransformRef.current;
            const screenX = svgRect.left + centerX * t.k + t.x;
            const screenY = svgRect.top + centerY * t.k + t.y;
            const virtualAnchor = {
                getBoundingClientRect: ()=>({
                        x: screenX,
                        y: screenY,
                        left: screenX,
                        top: screenY,
                        right: screenX,
                        bottom: screenY,
                        width: 0,
                        height: 0,
                        toJSON: ()=>{}
                    })
            };
            setAnchorEl(virtualAnchor);
        }
        setSelectedLinkIndex(index);
    }, [
        selectedLinkIndex
    ]);
    const handleLinkMouseLeave = (0, external_react_namespaceObject.useCallback)(()=>{
        setSelectedLinkIndex(null);
        setAnchorEl(null);
    }, []);
    const handleNodeMouseEnter = (0, external_react_namespaceObject.useCallback)((nodeId)=>{
        setHoveredNodeId(nodeId);
    }, []);
    const handleNodeMouseLeave = (0, external_react_namespaceObject.useCallback)(()=>{
        setHoveredNodeId(null);
    }, []);
    const connectedLinkIndices = (0, external_react_namespaceObject.useMemo)(()=>{
        if (!hoveredNodeId) return new Set();
        const indices = new Set();
        linkPaths.forEach((linkData, index)=>{
            if (linkData.sourceId === hoveredNodeId || linkData.targetId === hoveredNodeId) indices.add(index);
        });
        return indices;
    }, [
        hoveredNodeId,
        linkPaths
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(SankeyContainer, {
        ref: containerRef,
        style: style,
        className: className,
        role: "figure",
        "aria-label": ariaLabel,
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("svg", {
                ref: svgRef,
                width: svgWidth,
                height: svgHeight,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("g", {
                    ref: zoomGroupRef,
                    children: [
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("defs", {
                            children: linkPaths.map((linkData)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("linearGradient", {
                                    id: linkData.gradientId,
                                    gradientUnits: "userSpaceOnUse",
                                    x1: linkData.sourceX,
                                    y1: 0,
                                    x2: linkData.targetX,
                                    y2: 0,
                                    children: [
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("stop", {
                                            offset: "0%",
                                            stopColor: linkData.sourceColor
                                        }),
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("stop", {
                                            offset: "100%",
                                            stopColor: linkData.targetColor
                                        })
                                    ]
                                }, linkData.gradientId))
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("g", {
                            children: linkPaths.map((linkData, index)=>{
                                const isConnectedToHoveredNode = connectedLinkIndices.has(index);
                                let opacity = 0.6;
                                if (selectedLinkIndex === index) opacity = 1;
                                else if (hoveredNodeId) opacity = isConnectedToHoveredNode ? 1 : 0.3;
                                return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StyledSankeyLink, {
                                    d: linkData.path,
                                    stroke: linkData.color ? linkData.color : `url(#${linkData.gradientId})`,
                                    strokeWidth: linkData.strokeWidth,
                                    fill: "none",
                                    opacity: opacity,
                                    onMouseEnter: ()=>handleLinkMouseEnter(index, linkData.centerX, linkData.centerY),
                                    onMouseLeave: handleLinkMouseLeave,
                                    onClick: (e)=>onLinkClick?.(linkData.originalLink, e),
                                    "aria-label": `Link from ${linkData.sourceLabel} to ${linkData.targetLabel}`
                                }, `link-${index}`);
                            })
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("g", {
                            children: nodeData.map((nodeItem)=>{
                                const nodeOpacity = hoveredNodeId ? hoveredNodeId === nodeItem.node.id ? 1 : 0.4 : 1;
                                return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("g", {
                                    children: [
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StyledSankeyNode, {
                                            x: nodeItem.x,
                                            y: nodeItem.y,
                                            width: nodeItem.width,
                                            height: nodeItem.height,
                                            fill: nodeItem.color,
                                            opacity: nodeOpacity,
                                            onMouseEnter: ()=>handleNodeMouseEnter(nodeItem.node.id),
                                            onMouseLeave: handleNodeMouseLeave,
                                            onClick: (e)=>onNodeClick?.(nodeItem.node, e)
                                        }),
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(StyledSankeyNodeLabel, {
                                            x: nodeItem.labelX,
                                            y: nodeItem.labelY,
                                            dy: "0.35em",
                                            textAnchor: nodeItem.labelAnchor,
                                            children: [
                                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("title", {
                                                    children: nodeItem.fullLabel
                                                }),
                                                nodeItem.displayLabel
                                            ]
                                        }),
                                        nodeItem.value > 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(StyledSankeyNodeValue, {
                                            x: nodeItem.labelX,
                                            y: nodeItem.labelY + parseInt(apollo_core_default().Spacing.SpacingM, 10),
                                            dy: "0.35em",
                                            textAnchor: nodeItem.labelAnchor,
                                            children: nodeItem.value
                                        })
                                    ]
                                }, `node-${nodeItem.node.id}`);
                            })
                        })
                    ]
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(ZoomControls, {
                children: [
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.IconButton, {
                        size: "small",
                        onClick: handleZoomIn,
                        "aria-label": "Zoom in",
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Add_default(), {
                            fontSize: "small"
                        })
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.IconButton, {
                        size: "small",
                        onClick: handleZoomOut,
                        "aria-label": "Zoom out",
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Remove_default(), {
                            fontSize: "small"
                        })
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.IconButton, {
                        size: "small",
                        onClick: fitToView,
                        "aria-label": "Fit to view",
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(FitScreen_default(), {
                            fontSize: "small"
                        })
                    })
                ]
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.Popper, {
                open: null !== selectedLinkIndex && null !== anchorEl,
                anchorEl: anchorEl,
                placement: "top",
                style: {
                    pointerEvents: 'none'
                },
                modifiers: [
                    {
                        name: 'flip',
                        enabled: true,
                        options: {
                            fallbackPlacements: [
                                'bottom',
                                'top',
                                'left',
                                'right'
                            ]
                        }
                    },
                    {
                        name: 'preventOverflow',
                        enabled: true,
                        options: {
                            boundary: containerRef.current || 'clippingParents',
                            padding: 8
                        }
                    },
                    {
                        name: 'offset',
                        options: {
                            offset: [
                                0,
                                8
                            ]
                        }
                    }
                ],
                children: null !== selectedLinkIndex && linkPaths[selectedLinkIndex] && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(LinkTooltipContent, {
                    elevation: 3,
                    children: (()=>{
                        const linkPath = linkPaths[selectedLinkIndex];
                        const link = linkPath.originalLink;
                        const metadata = link.metadata || {};
                        return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TooltipRow, {
                                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(TooltipHeader, {
                                        children: [
                                            linkPath.sourceLabel,
                                            " → ",
                                            linkPath.targetLabel
                                        ]
                                    })
                                }),
                                Object.entries(metadata).map(([key, value])=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(TooltipRow, {
                                        children: [
                                            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TooltipLabel, {
                                                children: key
                                            }),
                                            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TooltipValue, {
                                                children: String(value)
                                            })
                                        ]
                                    }, key)),
                                0 === Object.keys(metadata).length && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(TooltipRow, {
                                    children: [
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TooltipLabel, {
                                            children: "Value"
                                        }),
                                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(TooltipValue, {
                                            children: link.value
                                        })
                                    ]
                                })
                            ]
                        });
                    })()
                })
            })
        ]
    });
});
ApSankeyDiagram.displayName = 'ApSankeyDiagram';
exports.ApSankeyDiagram = __webpack_exports__.ApSankeyDiagram;
exports.computeSankeyDimensions = __webpack_exports__.computeSankeyDimensions;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "ApSankeyDiagram",
    "computeSankeyDimensions"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
