"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var cell_position_exports = {};
__export(cell_position_exports, {
  getCellMidAngleDeg: () => getCellMidAngleDeg,
  getCellPositionDataAttrs: () => getCellPositionDataAttrs,
  getCircleCellStyle: () => getCircleCellStyle,
  getColumnsPerRow: () => getColumnsPerRow,
  getResponsiveColumnsPerRow: () => getResponsiveColumnsPerRow,
  hasBottomCenterCell: () => hasBottomCenterCell
});
module.exports = __toCommonJS(cell_position_exports);
const COLUMN_SIZE_TO_COLS = {
  SMALL: 4,
  MEDIUM: 3,
  LARGE: 2,
  EXTRA_LARGE: 1
};
const RESPONSIVE_COLS = {
  SMALL: 2,
  MEDIUM: 2,
  LARGE: 1,
  EXTRA_LARGE: 1
};
const getColumnsPerRow = (columnSize) => COLUMN_SIZE_TO_COLS[columnSize] ?? 3;
const getResponsiveColumnsPerRow = (columnSize) => RESPONSIVE_COLS[columnSize] ?? 2;
const getCellPositionDataAttrs = (cellIndex, totalCells, columnSize) => {
  const lrp = calculateLastRowPosition(
    cellIndex,
    totalCells,
    getColumnsPerRow(columnSize),
    getResponsiveColumnsPerRow(columnSize)
  );
  return {
    "data-cell-index": cellIndex,
    "data-cells-total": totalCells,
    "data-last-row": lrp.isInLastRow || void 0,
    "data-last-row-cells": lrp.isInLastRow ? lrp.cellsInLastRow : void 0,
    "data-last-row-2col": lrp.isInLastRow2Col || void 0,
    "data-last-row-cells-2col": lrp.isInLastRow2Col ? lrp.cellsInLastRow2Col : void 0
  };
};
const calculateLastRowPosition = (cellIndex, totalCells, columnsPerRow, responsiveColumnsPerRow) => {
  const cellsInLastRow = totalCells % columnsPerRow || columnsPerRow;
  const lastRowStart = totalCells - cellsInLastRow;
  const cellsInLastRow2 = totalCells % responsiveColumnsPerRow || responsiveColumnsPerRow;
  const lastRowStart2 = totalCells - cellsInLastRow2;
  return {
    isInLastRow: cellIndex >= lastRowStart,
    cellsInLastRow,
    isInLastRow2Col: cellIndex >= lastRowStart2,
    cellsInLastRow2Col: cellsInLastRow2
  };
};
const getCellMidAngleDeg = (cellIndex, totalCells) => {
  if (totalCells <= 1) {
    return -90;
  }
  return -180 / totalCells + cellIndex * (360 / totalCells);
};
const isBottomCenterCell = (cellIndex, totalCells) => {
  if (totalCells <= 1) {
    return false;
  }
  return Math.abs(getCellMidAngleDeg(cellIndex, totalCells) - 180) < 1e-6;
};
const hasBottomCenterCell = (totalCells) => totalCells >= 3 && totalCells % 2 === 1;
const getCircleCellStyle = (cellIndex, totalCells) => {
  if (isBottomCenterCell(cellIndex, totalCells)) {
    const row2 = (totalCells + 1) / 2;
    return {
      style: { "--ricos-internal-sb-row": `${row2}` },
      side: "bottom",
      row: row2
    };
  }
  const midAngleDeg = getCellMidAngleDeg(cellIndex, totalCells);
  const side = Math.sin(midAngleDeg * Math.PI / 180) >= 0 ? "right" : "left";
  const row = side === "right" ? cellIndex : (totalCells - cellIndex) % totalCells + 1;
  return {
    style: { "--ricos-internal-sb-row": `${row}` },
    side,
    row
  };
};
//# sourceMappingURL=cell-position.js.map
