import type { CustomElement } from "#/project";
/**
 * 计算组合组件几何信息
 * @param elements 组件列表
 * @returns 
 */
export const calcComboInfo = (elements: CustomElement[]) => {
  const minX = Math.min(...elements.map((item) => item.container.props.x));
  const minY = Math.min(...elements.map((item) => item.container.props.y));
  const maxX = Math.max(...elements.map((item) => item.container.props.x + item.container.props.width));
  const maxY = Math.max(...elements.map((item) => item.container.props.y + item.container.props.height));
  const maxZIndex = Math.max(...elements.map((item) => item.zIndex));

  return {
    minX,
    minY,
    maxX,
    maxY,
    maxZIndex
  }
}