/**config api */
import { ref } from "vue";

const env = ref<string>(process.env.NODE_ENV || "development");
export const apiUrlConfig = import.meta.env.VITE_API_URI_CONFIG;
export const apiUrlSsoConfig = import.meta.env.VITE_API_SSO;
export const urlAdmin = import.meta.env.VITE_URL_ADMIN;
export const urlUser = import.meta.env.VITE_URL_USER;
export const urlMgt = import.meta.env.VITE_URL_MGT;
export const urlCheckin = import.meta.env.VITE_URL_CHECKIN;
export const urlSSO = import.meta.env.VITE_URL_SSO;

// if (process.env.VUE_APP_TEST) {
//   env = "test";
// }

const config = ref<any>({
  development: {
    // API_URI: "https://localhost:7260/api",
    API_URI: "https://hrms.chin.in.th/api/v1",
    API_SSO: "http://localhost:3001/api/v1/sso",
    URL_ADMIN: urlAdmin,
    URL_USER: urlUser,
    URL_MGT: urlMgt,
    URL_CHECKIN: urlCheckin,
    URL_SSO: urlSSO,
  },
  test: {
    API_URI: "http://localhost:5010/api/v1",
  },
  production: {
    API_URI: apiUrlConfig,
    API_SSO: apiUrlSsoConfig,
    URL_ADMIN: urlAdmin,
    URL_USER: urlUser,
    URL_MGT: urlMgt,
    URL_CHECKIN: urlCheckin,
    URL_SSO: urlSSO,
  },
});

const API_URI = ref<string>(config.value[env.value].API_URI);
const API_SSO = ref<string>(config.value[env.value].API_SSO);

const URL_ADMIN = ref<string>(config.value[env.value].URL_ADMIN);
const URL_USER = ref<string>(config.value[env.value].URL_USER);
const URL_MGT = ref<string>(config.value[env.value].URL_MGT);
const URL_CHECKIN = ref<string>(config.value[env.value].URL_CHECKIN);
const URL_SSO = ref<string>(config.value[env.value].URL_SSO);

export default {
  env: env.value,
  config: config.value,
  API_URI: API_URI.value,
  API_SSO: API_SSO.value,
  URL_ADMIN: URL_ADMIN.value,
  URL_USER: URL_USER.value,
  URL_MGT: URL_MGT.value,
  URL_CHECKIN: URL_CHECKIN.value,
  URL_SSO: URL_SSO.value,
};
