import { Node } from "@antv/x6";
import { cloneDeep } from "lodash-es";

import { basic } from "./basic";
import { flowchart } from "./flowchart";
import { er } from "./er";
import { lane } from "./lane";
import { umlBase } from "./uml/common";
import { umlUseCase } from "./uml/usecase";
import { umlSequence } from "./uml/sequence";
import { umlClass } from "./uml/class";

const compMap: Record<string, Node.Metadata> = {};
/**
 * 导出flowchart自定义组件列表
 * @returns 组件列表
 */
export const getCompMap = () => {
  const compList = [
    ...basic,
    ...flowchart,
    ...er,
    ...lane,
    ...umlBase,
    ...umlUseCase,
    ...umlSequence,
    ...umlClass,
  ];

  compList.forEach((item) => {
    compMap[item.node.shape as string] = cloneDeep(item.node);
  });

  return compMap;
};