import { getElementModel } from "./elementModel";

export const getPageInitElements = (cardHeadInfo) => {
  const templateInfo = cardHeadInfo.templateInfo;
  let pageInit = {};
  Object.keys(templateInfo).forEach((k) => {
    pageInit[k] = templateInfo[k].map((item) => {
      const model = getElementModel(item.type, cardHeadInfo);
      return Object.assign(model, item);
    });
  });
  if (!pageInit.elements) pageInit.elements = [];

  return pageInit;
};
