const getServiceHost = api => {
  const apimodules = [{ OP: 3116 }, { BD: 3101 }, { DD: 3102 }, { EA: 3103 }, { ED: 3104 }, { EM: 3105 }, { FC: 3106 },
  { FM: 3107 }, { KR: 3108 }, { LG: 3109 }, { MR: 3110 }, { NW: 3111 }, { PF: 3112 }, { PM: 3113 }, { QC: 3114 }, { FW: 3115 }, { OP: 3116 },
  { HM: 3117 }, { PP: 3118 }, { FO: 3119 }, { UT: 3177 }, { BS: 3178 }, { SC: 3179 }, { TI: 3179 }, { SE: 3179 }, { AE: 3179 }, { PT: 3179 }, { LR: 3179 }, { OG: 3179 }, { PE: 3179 }, { OH: 3179 }, { CM: 3179 }, { PR: 3179 }, { DM: 3179 }, { BI: 3179 }, { TL: 3179 }]
  let port = 3112
  for (let i = 0; i < apimodules.length; i++) {
    const apimodule = apimodules[i]
    const key = Object.keys(apimodule)[0]
    if (api.indexOf(`/${key}/`) > -1) {
      port = apimodule[key]
      break
    }
  }
  return `${port}/${api}`
}
let version = 2024011601;
const config = {
  local: {
    serviceHost: api => {
      const apis = getServiceHost(api)
      return `http://localhost:${apis}`
    },
    cookieDomain: "",
    flowServiceHost: "http://120.25.146.51:3188/",
    hmiUrl: "http://localhost:8060/",
    webSocketHost: 'ws://localhost:3140/',
    picServerHost: 'http://47.122.43.22:3199',
    dataVUrl: "http://localhost:8062/home",
    version:version,
    guideSeverHost:"http://47.122.43.22/apk/",
    guideH5Host:"http://47.122.43.22:9100/",
  },
  cloud: {
    serviceHost: api => {
      const apis = getServiceHost(api)
      return `http://120.25.146.51:${apis}`
    },
    flowServiceHost: "http://120.25.146.51:3188",
    cookieDomain: "",
    hmiUrl: "http://120.25.146.51:8098/",
    webSocketHost: 'ws://120.25.146.51:3140/',
    picServerHost: 'http://120.25.146.51:3199',
    dataVUrl: "http://120.25.146.51:3167/home",
    version:version,
    guideSeverHost:"http://www.xmmhe.com/apk/",
    guideH5Host:"http://www.xmmhe.com:9100/",
  },
  test: {
    serviceHost: api => {
      const apis = getServiceHost(api)
      return `http://47.122.43.22:${apis}`
    },
    flowServiceHost: "http://47.122.43.22:3188",
    cookieDomain: "",
    hmiUrl: "http://47.122.43.22:8098/",
    webSocketHost: 'ws://47.122.43.22:3140/',
    picServerHost: 'http://47.122.43.22:3199',
    dataVUrl: "http://47.122.43.22:3167/home",
    version:version,
    guideSeverHost:"http://47.122.43.22/apk/",
    guideH5Host:"http://47.122.43.22:9100/",
  },
}

let env = ""
switch (window.location.host) {
  case "120.25.146.51":
    env = "cloud"
    break
  case "120.25.146.51:8001":
    env = "cloud"
    break
  case "120.25.146.51:8002":
    env = "cloud"
    break
  case "120.25.146.51:8003":
    env = "cloud"
    break
  case "120.25.146.51:8004":
    env = "cloud"
    break
  case "120.25.146.51:8005":
    env = "cloud"
    break
  case "www.xmmhe.com:8001":
    env = "cloud"
    break
  case "www.xmmhe.com:8002":
    env = "cloud"
    break
  case "www.xmmhe.com:8003":
    env = "cloud"
    break
  case "www.xmmhe.com:8004":
    env = "cloud"
    break
  case "www.xmmhe.com:8005":
    env = "cloud"
    break
  case "xmmhe.com:8001":
    env = "cloud"
    break
  case "xmmhe.com:8002":
    env = "cloud"
    break
  case "xmmhe.com:8003":
    env = "cloud"
    break
  case "xmmhe.com:8004":
    env = "cloud"
    break
  case "xmmhe.com:8005":
    env = "cloud"
    break
  case "10.50.4.139:8000":
    env = "cloud"
    break
  case "10.50.2.189:8000":
    env = "test"
    break
  case "47.122.43.22:8001":
    env = "test"
    break
  case "47.122.43.22:8002":
    env = "test"
    break
  case "47.122.43.22:8003":
    env = "test"
    break
  case "47.122.43.22:8004":
    env = "test"
    break
  default:
    env = "local"
    break
}

export default config[env]
