"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__, {
    useEdgeGeometry: ()=>useEdgeGeometry
});
const external_react_namespaceObject = require("react");
const index_cjs_namespaceObject = require("../../../../hooks/index.cjs");
const external_constants_cjs_namespaceObject = require("../constants.cjs");
const external_geometry_cjs_namespaceObject = require("../geometry.cjs");
const EMPTY_VERTICES = [];
const EMPTY_SEGMENTS = [];
function useEdgeGeometry(args) {
    const { routing, sourceNodeId, targetNodeId, sourceHandleId, targetHandleId, sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints, enableSegments = true, hideArrowHead = false } = args;
    const arrowOffset = external_constants_cjs_namespaceObject.ARROW_OFFSETS[targetPosition];
    const isWaypoint = 'waypoint' === routing;
    const isHandle = 'handle' === routing;
    const pathPoints = (0, external_react_namespaceObject.useMemo)(()=>isWaypoint ? (0, external_geometry_cjs_namespaceObject.buildPathVertices)(sourceX, sourceY, sourcePosition, targetX, targetY, targetPosition, waypoints) : EMPTY_VERTICES, [
        isWaypoint,
        sourceX,
        sourceY,
        sourcePosition,
        targetX,
        targetY,
        targetPosition,
        waypoints
    ]);
    const segments = (0, external_react_namespaceObject.useMemo)(()=>enableSegments ? (0, external_geometry_cjs_namespaceObject.extractSegments)(pathPoints) : EMPTY_SEGMENTS, [
        enableSegments,
        pathPoints
    ]);
    const waypointPath = (0, external_react_namespaceObject.useMemo)(()=>(0, external_geometry_cjs_namespaceObject.createRoundedPath)(pathPoints, external_constants_cjs_namespaceObject.EDGE_CONSTANTS.BORDER_RADIUS), [
        pathPoints
    ]);
    const handle = (0, index_cjs_namespaceObject.useEdgePath)({
        sourceNodeId: isHandle ? sourceNodeId : '',
        targetNodeId: isHandle ? targetNodeId : '',
        sourceHandleId: isHandle ? sourceHandleId : null,
        targetHandleId: isHandle ? targetHandleId : null,
        sourceX: isHandle ? sourceX : 0,
        sourceY: isHandle ? sourceY : 0,
        sourcePosition,
        targetX: isHandle ? hideArrowHead ? targetX + arrowOffset.x : targetX : 0,
        targetY: isHandle ? hideArrowHead ? targetY + arrowOffset.y : targetY : 0,
        targetPosition
    });
    const labelPoint = (0, external_react_namespaceObject.useMemo)(()=>isHandle ? {
            x: handle.labelX,
            y: handle.labelY
        } : (0, external_geometry_cjs_namespaceObject.getPathArcMidpoint)(pathPoints), [
        isHandle,
        handle.labelX,
        handle.labelY,
        pathPoints
    ]);
    const arrow = {
        angle: external_constants_cjs_namespaceObject.ARROW_ANGLE_MAP[targetPosition],
        offset: arrowOffset
    };
    if (isHandle) return {
        edgePath: handle.edgePath,
        pathPoints: EMPTY_VERTICES,
        segments: EMPTY_SEGMENTS,
        labelPoint,
        arrow
    };
    return {
        edgePath: waypointPath,
        pathPoints,
        segments,
        labelPoint,
        arrow
    };
}
exports.useEdgeGeometry = __webpack_exports__.useEdgeGeometry;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "useEdgeGeometry"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
