"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__, {
    StageConnectionEdge: ()=>StageConnectionEdge
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
function getArrowFromBezier(path, arrowSize) {
    const pathEl = document.createElementNS('http://www.w3.org/2000/svg', 'path');
    pathEl.setAttribute('d', path);
    const totalLength = pathEl.getTotalLength();
    const endPoint = pathEl.getPointAtLength(totalLength);
    const prevPoint = pathEl.getPointAtLength(totalLength - arrowSize);
    const angle = Math.atan2(endPoint.y - prevPoint.y, endPoint.x - prevPoint.x);
    return {
        endX: endPoint.x,
        endY: endPoint.y,
        angle
    };
}
function StageConnectionEdge({ fromX, fromY, toX, toY, fromPosition, toPosition, fromNode, toNode }) {
    if (void 0 === fromX || void 0 === fromY || void 0 === toX || void 0 === toY) return null;
    const sourceX = fromNode ? fromNode.position.x + (fromNode.measured?.width ?? 0) : fromX;
    const sourceY = fromNode?.position.y ? fromNode.position.y + 32 : fromY;
    const targetX = toNode ? toNode.position.x : toX;
    const targetY = toNode ? toNode.position.y + 32 : toY;
    const [pathData] = (0, react_cjs_namespaceObject.getBezierPath)({
        sourceX,
        sourceY,
        sourcePosition: fromPosition,
        targetX,
        targetY,
        targetPosition: toPosition
    });
    const stroke = 'var(--canvas-selection-indicator)';
    const strokeWidth = 2.5;
    const arrowSize = 10;
    const { endX, endY, angle } = getArrowFromBezier(pathData, arrowSize);
    const arrowLineLength = arrowSize;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("g", {
        className: "animated",
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
                d: pathData,
                stroke: stroke,
                strokeWidth: strokeWidth,
                strokeLinecap: "round",
                strokeLinejoin: "round",
                fill: "none",
                strokeDasharray: "5,5",
                style: {
                    animation: 'dashdraw 0.5s linear infinite'
                }
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("style", {
                children: `
          @keyframes dashdraw {
            0% {
              stroke-dashoffset: 10;
            }
            100% {
              stroke-dashoffset: 0;
            }
          }
        `
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("line", {
                x1: endX,
                y1: endY,
                x2: endX - arrowLineLength * Math.cos(angle - Math.PI / 6),
                y2: endY - arrowLineLength * Math.sin(angle - Math.PI / 6),
                stroke: stroke,
                strokeWidth: strokeWidth
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("line", {
                x1: endX,
                y1: endY,
                x2: endX - arrowLineLength * Math.cos(angle + Math.PI / 6),
                y2: endY - arrowLineLength * Math.sin(angle + Math.PI / 6),
                stroke: stroke,
                strokeWidth: strokeWidth
            })
        ]
    });
}
exports.StageConnectionEdge = __webpack_exports__.StageConnectionEdge;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "StageConnectionEdge"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
