"use strict";
var __webpack_require__ = {};
(()=>{
    __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__, {
    useFloatingPosition: ()=>useFloatingPosition
});
const react_namespaceObject = require("@floating-ui/react");
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
const external_react_namespaceObject = require("react");
function useFloatingPosition({ open = true, nodeId, anchorRect, placement = 'right-start', offset: offsetValue = 20, fallbackPlacement = 'none' }) {
    const referenceRef = (0, external_react_namespaceObject.useRef)(null);
    const internalNode = (0, react_cjs_namespaceObject.useInternalNode)(nodeId || '');
    const computedAnchor = (0, external_react_namespaceObject.useMemo)(()=>{
        if (anchorRect) return anchorRect;
        if (!internalNode) return null;
        const position = internalNode.internals?.positionAbsolute || {
            x: 0,
            y: 0
        };
        const width = internalNode.measured?.width ?? internalNode.width ?? 200;
        const height = internalNode.measured?.height ?? internalNode.height ?? 100;
        return {
            x: position.x,
            y: position.y,
            width,
            height
        };
    }, [
        anchorRect,
        internalNode
    ]);
    const { refs, floatingStyles, update } = (0, react_namespaceObject.useFloating)({
        placement,
        open: !!open && !!computedAnchor,
        middleware: [
            (0, react_namespaceObject.offset)(offsetValue),
            (0, react_namespaceObject.flip)({
                fallbackAxisSideDirection: fallbackPlacement
            })
        ],
        whileElementsMounted: react_namespaceObject.autoUpdate
    });
    const mergedReferenceRef = (0, react_namespaceObject.useMergeRefs)([
        refs.setReference,
        referenceRef
    ]);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (open) update();
    }, [
        open,
        computedAnchor?.x,
        computedAnchor?.y,
        computedAnchor?.width,
        computedAnchor?.height,
        update
    ]);
    return {
        computedAnchor,
        floatingStyles,
        refs,
        mergedReferenceRef
    };
}
exports.useFloatingPosition = __webpack_exports__.useFloatingPosition;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "useFloatingPosition"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
