"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.calcColumns = void 0;
var _ui = require("@mirai/ui");
const ITEMS_PER_COLUMN = 18;
const ITEM_WIDTH = 300;
const MAX_COLUMNS = 3;
const THEME_KEY = '--mirai-places';
const calcColumns = function () {
  let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
    _ref$dataSource = _ref.dataSource,
    _ref$dataSource2 = _ref$dataSource === void 0 ? [] : _ref$dataSource,
    items = _ref$dataSource2.length,
    _ref$device = _ref.device,
    _ref$device2 = _ref$device === void 0 ? {} : _ref$device,
    deviceWidth = _ref$device2.width;
  const _Theme$get = _ui.Theme.get(THEME_KEY),
    _Theme$get$ItemsPerCo = _Theme$get.ItemsPerColumn,
    ItemsPerColumn = _Theme$get$ItemsPerCo === void 0 ? ITEMS_PER_COLUMN : _Theme$get$ItemsPerCo,
    _Theme$get$ItemWidth = _Theme$get.ItemWidth,
    itemWidth = _Theme$get$ItemWidth === void 0 ? ITEM_WIDTH : _Theme$get$ItemWidth;
  const itemsPerColumn = Number(ItemsPerColumn);
  let columns = items > itemsPerColumn ? Math.ceil(items / itemsPerColumn) : undefined;
  if (columns * itemWidth > deviceWidth * 0.8 || columns > MAX_COLUMNS) columns = 1;
  return columns;
};
exports.calcColumns = calcColumns;
//# sourceMappingURL=calcColumns.js.map