import { MindmapConnectorType, TopicType } from "@/enum";
import { cellStyle, TopicItem } from "@/types";
import { getRandomColor, lightenColor } from "@/utils/color";
import { Node } from "@antv/x6";

export const getTheme = (key?: string, parentNode?: Node): Record<string, any> => {
  const color1 = getRandomColor(["#3D4BCF", "#9C2CB8"]);
  const map = {
    // 默认主题
    default: {
      main: {
        fill: {
          fillType: "color",
          color1: "#30304D",
        },
        text: {
          color: "#fff",
          fontSize: 30,
        },
        stroke: {
          width: 0,
        },
        edge: {
          color: "#fff"
        }
      },
      branch: {
        fill: {
          fillType: "color",
          color1,
        },
        text: {
          color: "#fff",
          fontSize: 18,
        },
        stroke: {
          width: 0,
        },
        edge: {
          color: color1,
          width: 3,
        }
      },
      sub: {
        fill: {
          fillType: "color",
          color1: parentNode?.data?.type === TopicType.branch ? lightenColor(parentNode.data.fill.color1, 150) : parentNode?.data?.fill?.color1,
        },
        text: {
          color: parentNode?.data?.type === TopicType.branch ? lightenColor(parentNode.data.fill.color1, -10) : parentNode?.data?.text?.color,
          fontSize: 14,
        },
        stroke: {
          width: 0,
        },
        edge: {
          color: parentNode?.data?.type === TopicType.branch ? parentNode?.data?.fill?.color1 : parentNode?.data?.edge?.color || '#323232',
          width: 2,
        }
      },
      branchConnector: MindmapConnectorType.curve,
      subConnector: MindmapConnectorType.rounded,
    }
  }

  return map[key as keyof typeof map] || {};
};