let origin, host, protocol;
if (process.env.VUE_APP_CORE_HOST_URL) {
  const hostUrl = new URL(process.env.VUE_APP_CORE_HOST_URL);
  origin = hostUrl.toString();
  host = hostUrl.host;
  protocol = hostUrl.protocol.replace("http", "ws"); // http: => ws:
} else {
  origin = window.location.origin;
  host = window.location.host;
  protocol = window.location.protocol.replace("http", "ws"); // http: => ws:
}

export const FACEID_LINENESS_URL =
  "https://api.megvii.com/faceid/liveness/v2/do?token=";

export const TK_SERVER_HTML_URL = origin;

export const VUE_APP_WK_SERVER_SOCKET =
  protocol + "//" + host + "/api/ws/faceBiopsy";

export const VUE_APP_WK_SERVER_SOCKET_FOR_AUDIO =
  protocol + "//" + host + "/api/ws/fileAnswer";

export const VUE_APP_CONFIG_FILE_SEVER_URL =
  process.env.VUE_APP_CONFIG_FILE_SEVER_URL;

export const VUE_APP_SLS_STORE_NAME = process.env.VUE_APP_SLS_STORE_NAME;

export const FACE_API_MODEL_PATH =
  process.env.VUE_APP_PUBLIC_PATH + "models/20190620/";

// export const EPCC_DOMAIN = "iepcc-ps.ecs.qmth.com.cn";
export const EPCC_DOMAIN = "bds.ecs.qmth.com.cn";
export const CUG_DOMAIN = "cug.ecs.qmth.com.cn";
// export const CUG_DOMAIN = "ecs-test.qmth.com.cn";

let domain;
if (process.env.VUE_APP_SELF_DEFINE_DOMAIN === "true") {
  domain = window.localStorage.getItem("exam_cloud_domain_in_url");
}
if (!domain) domain = window.location.hostname.split(".")[0];
export const DOMAIN_IN_URL = domain + ".ecs.qmth.com.cn";

export const PRIVACY_READ_VERSION_NUMBER = "1";

export const HOST_FILE_HASH_MAP = new Map([
  [
    "pc-test.ea100.com.cn",
    "7501fb797d0bac668e13f392b42e1b9f6464442c2ffc03c2a3243416ef226eb8",
  ],
  [
    "qmtest.exam-cloud.cn",
    "a31c9eb84fe82031fb01e9e25262f0b407caa705b5245654faeed1490bff67f9",
  ],
  // [
  //   "uestccourse.exam-cloud.cn",
  //   "1ebdaa1e00fbefca0f6519e252e4d372bcb9c3f96c45760b032ca58683d28306",
  // ],
]);

export const STRICT_CHECK_HOSTS = [...HOST_FILE_HASH_MAP.keys()];
