import {checkDev} from "@/utils/utils";

/**
 * 医生小程序环境唯一开关：旧 HTTP、newApi、WebSocket 均由此派生。
 * 发布生产前将 USE_DOCTOR_WX_DEV 改为 false。
 */
// const USE_DOCTOR_WX_DEV = true;
const USE_DOCTOR_WX_DEV = false;

const DEV = {
  legacyApiBase: 'http://127.0.0.1:18000/service/v1/',
  newApiBase: 'http://127.0.0.1:18001/api/doctor/',
  wsUrl: 'ws://127.0.0.1:12080/ws',
};

const PROD = {
  legacyApiBase: 'https://app.xiaokang88.com/service/v1/',
  newApiBase: 'https://api.xiaokang88.com/api/doctor/',
  wsUrl: 'wss://api.ws.g.xiaokang88.com/ws',
};

// const TEST = {
const TEST = {
  legacyApiBase: 'https://xk.test.saas.api-yii.nailaoyun.cn/service/v1/',
  newApiBase: 'https://xk.test.saas.api.nailaoyun.cn/api/doctor/',
  // wsUrl: 'wss://api.ws.g.xiaokang88.com/ws',
  wsUrl: 'wss://xk.ws.nailaoyun.cn/ws',
  // wsUrl: '',
};

export function isDoctorWxDev() {
  return checkDev('dev');
}

export function getDoctorWxEnv() {
  let env = checkDev('dev') ? DEV : PROD;
  if (checkDev('test')) {
    env = TEST;
  }
  return env;
}

/** 开发 / 生产 WebSocket 地址（与 getDoctorWxEnv 同源，供 websocket 配置展示） */
export function getDoctorWxWsUrls() {
  return {
    dev: DEV.wsUrl,
    prod: PROD.wsUrl,
  };
}
