"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__, {
    calculateGridAlignedHandlePositions: ()=>calculateGridAlignedHandlePositions
});
const external_constants_cjs_namespaceObject = require("../constants.cjs");
const snapToGrid = (value, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING)=>Math.round(value / gridSize) * gridSize;
const calculateGridAlignedHandlePositions = (nodeSize, numHandles, gridSize = external_constants_cjs_namespaceObject.GRID_SPACING)=>{
    if (0 === numHandles) return [];
    if (nodeSize <= 0) return [];
    if (1 === numHandles) return [
        snapToGrid(nodeSize / 2, gridSize)
    ];
    const idealSpacing = nodeSize / (numHandles + 1);
    if (nodeSize % gridSize !== 0) {
        const positions = [];
        for(let i = 0; i < numHandles; i++)positions.push(idealSpacing * (i + 1));
        return positions;
    }
    const roundedSpacing = Math.round(idealSpacing / gridSize) * gridSize;
    let gridAlignedSpacing = Math.max(gridSize, roundedSpacing);
    let totalSpan = (numHandles - 1) * gridAlignedSpacing;
    let startPosition = (nodeSize - totalSpan) / 2;
    if (startPosition % gridSize !== 0 && gridAlignedSpacing > gridSize) {
        gridAlignedSpacing -= gridSize;
        totalSpan = (numHandles - 1) * gridAlignedSpacing;
        startPosition = (nodeSize - totalSpan) / 2;
    }
    const positions = [];
    for(let i = 0; i < numHandles; i++)positions.push(startPosition + i * gridAlignedSpacing);
    return positions;
};
exports.calculateGridAlignedHandlePositions = __webpack_exports__.calculateGridAlignedHandlePositions;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "calculateGridAlignedHandlePositions"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
