import type { DataSource } from '#/echart';
import { defaultsDeep } from "lodash";
import { containerDefaultConfig } from "@/config/containerDefaultConfig";
import { PropType } from "vue";
import { DataSourceType } from "@/enum/index";

/**
 * 获取容器组件属性
 *  @param {Record<string, any>} config - 传入属性
 *  @returns {Record<string, any>} - 返回与默认配置合并后的属性
 */
export function getNormalizedContainer(config: Record<string, any>) {
  return defaultsDeep(config, containerDefaultConfig);
}

// 图表组件数据来源prop
export const dataSource = {
  type: Object as PropType<DataSource>,
  default: () => ({
    sourceType: DataSourceType.STATIC,
    data: [],
    url: "",
    method: "GET",
    params: {},
    headers: {},
    refreshTime: 0,
    dataProcess: () => [],
  }),
}
