import { jsx } from "react/jsx-runtime";
import { ViewportPortal, useInternalNode } from "../xyflow/react.js";
const NODE_VIEWPORT_OVERLAY_Z_INDEX = {
    nodeHandleAffordance: 1002,
    nodeToolbar: 1003
};
function NodeViewportOverlay({ nodeId, anchor, layer, children }) {
    const internalNode = useInternalNode(nodeId);
    const positionAbsolute = internalNode?.internals.positionAbsolute;
    const width = anchor?.width ?? internalNode?.measured?.width ?? internalNode?.width;
    const height = anchor?.height ?? internalNode?.measured?.height ?? internalNode?.height;
    if (!positionAbsolute || null == width || null == height) return children;
    return /*#__PURE__*/ jsx(ViewportPortal, {
        children: /*#__PURE__*/ jsx("div", {
            className: "absolute pointer-events-none",
            style: {
                position: 'absolute',
                left: positionAbsolute.x + (anchor?.left ?? 0),
                top: positionAbsolute.y + (anchor?.top ?? 0),
                width,
                height,
                transform: anchor?.transform,
                zIndex: layer ? NODE_VIEWPORT_OVERLAY_Z_INDEX[layer] : void 0
            },
            children: children
        })
    });
}
export { NodeViewportOverlay };
