import DH from "@/pages/login/images/dh.png";
import DHWQ from "@/pages/login/images/dhwq.png";
import TM from "@/pages/login/images/tm.png";
import WSMM from "@/pages/login/images/wsmm.png";


/**
 * 客户端配置管理模块
 * 
 * 功能说明:
 * 所有配置从根目录的 client-configs.json 文件中读取
 * 图片通过映射函数将路径转换为实际导入的模块
 */

// 直接导入配置文件
import rawConfigs from '../../client-configs.json' with { type: 'json' };

// 图片路径映射表
const imageMap = {
  '@/pages/login/images/dh.png': DH,
  '@/pages/login/images/dhwq.png': DHWQ,
  '@/pages/login/images/tm.png': TM,
  '@/pages/login/images/wsmm.png': WSMM,
};

// 处理配置中的图片路径
const processConfigs = (configs) => {
  const processed = {};
  for (const [key, config] of Object.entries(configs)) {
    processed[key] = {
      ...config,
      logo: imageMap[config.logo] || config.logo,
      subLogo: imageMap[config.subLogo] || config.subLogo,
    };
  }
  return processed;
};

// 所有用户端的配置 - 处理后的配置
export const CLIENT_CONFIGS = processConfigs(rawConfigs);

// 获取当前用户端配置
export const getCurrentConfig = () => CLIENT_CONFIGS.tianmu;
export const clientId = getCurrentConfig().clientId;
export const appId = getCurrentConfig().appId;


/// 客户端类型
export const ClientType = {
  // 智念
  ZHINIAN: "ZHINIAN",
  // 朵花
  DUOHUA: "DUOHUA",
  // 天沐
  TIANMU: "TIANMU",
};

/// 获取当前客户端类型
export const currentClientType = () => {
  switch (getCurrentConfig().name) {
    case '智念':
      return ClientType.ZHINIAN;
    case '朵朵':
      return ClientType.DUOHUA;
    case '沐沐':
      return ClientType.TIANMU;
    default:
      return ClientType.ZHINIAN;
  }
};

// 环境配置 - 智念客户端使用测试环境，其他客户端使用生产环境
export const isProd = currentClientType() !== ClientType.ZHINIAN;
