import {
  getElementId,
  randomCode,
  deepCopy,
  getNumList,
  objAssign,
} from "../../../card/plugins/utils";

const MODEL = {
  type: "PAGE",
  pageSize: "A3",
  columnNumber: 2,
  columnGap: 40,
  showPageNo: true,
  showSide: true,
  sides: [],
  columns: [],
};
// 可编辑栏
const COLUMN = {
  type: "COLUMN",
  x: "",
  y: "",
  w: "",
  h: "",
  isFull: false, // 是否已经填满元素
  elements: [],
};

const getModel = (datas = {}) => {
  let npage = deepCopy(MODEL);
  npage = objAssign(npage, datas);
  npage.id = getElementId();
  const { columnNumber } = npage;

  npage.columns = getNumList(columnNumber).map(() => {
    return { id: `column-${randomCode()}`, ...deepCopy(COLUMN) };
  });
  return npage;
};

export { MODEL, getModel };
