const getServiceHost = api => {
  const apimodules = [{ OP: 7116 }, { BD: 7101 }, { DD: 7102 }, { EA: 7103 }, { ED: 7104 }, { EM: 7105 }, { FC: 7106 },
  { FM: 7107 }, { KR: 7108 }, { LG: 7109 }, { MR: 7110 }, { NW: 7111 }, { PF: 7112 }, { PM: 7113 }, { QC: 7114 }, { FW: 7115 }, { OP: 7116 },
  { HM: 7117 }, { PP: 7118 }, { FO: 7119 }, { UT: 7177 }, { BS: 7178 }, { SC: 7179 }, { TI: 7179 }, { SE: 7179 }, { AE: 7179 }, { PT: 7179 }, { LR: 7179 }, { OG: 7179 }, { PE: 7179 }, { OH: 7179 }, { CM: 7179 }, { PR: 7179 }, { DM: 7179 }, { BI: 7179 }, { TL: 7179 }]
  let port = 7112
  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:7188/",
    hmiUrl: "http://localhost:8060/",
    webSocketHost: 'ws://localhost:7140/',
    picServerHost: 'http://47.122.43.22:7199',
    dataVUrl: "http://localhost:8062/home",
    version: version,
    guideSeverHost: "http://47.122.43.22/lmapk/",
    guideH5Host: "http://47.122.43.22:9200/",
  },
  cloud: {
    serviceHost: api => {
      const apis = getServiceHost(api)
      return `http://120.25.146.51:${apis}`
    },
    flowServiceHost: "http://120.25.146.51:7188",
    cookieDomain: "",
    hmiUrl: "http://120.25.146.51:8098/",
    webSocketHost: 'ws://120.25.146.51:7140/',
    picServerHost: 'http://120.25.146.51:7199',
    dataVUrl: "http://120.25.146.51:7167/home",
    version: version,
    guideSeverHost: "http://www.xmmhe.com/lmapk/",
    guideH5Host: "http://www.xmmhe.com:9200/",
  },
  test: {
    serviceHost: api => {
      const apis = getServiceHost(api)
      return `http://47.122.43.22:${apis}`
    },
    flowServiceHost: "http://47.122.43.22:7188",
    cookieDomain: "",
    hmiUrl: "http://47.122.43.22:8098/",
    webSocketHost: 'ws://47.122.43.22:7140/',
    picServerHost: 'http://47.122.43.22:7199',
    dataVUrl: "http://47.122.43.22:7167/home",
    version: version,
    guideSeverHost: "http://47.122.43.22/lmapk/",
    guideH5Host: "http://47.122.43.22:9200/",
  },
}

let env = ""
switch (window.location.host) {
  case "120.25.146.51:7001":
    env = "cloud"
    break
  case "www.xmmhe.com:7001":
    env = "cloud"
    break
  case "xmmhe.com:7001":
    env = "cloud"
    break
  case "47.122.43.22:7001":
    env = "test"
    break
  case "47.122.43.22:7999":
    env = "test"
    break
  default:
    env = "local"
    break
}

export default config[env]
