declare global {
  interface Window {
    ENV: envType;
  }
}

interface envType {
  VITE_APP_VERSION_TYPE: string;
  VITE_API_URL: string;
  VITE_SUPPORT_PHONE: string;
}

function isBrowser() {
  return typeof window !== "undefined";
}
function getEnv(): envType {
  return isBrowser() ? window.ENV : (process.env as unknown as envType);
}

export { getEnv };

export function isProduction() {
  if (getEnv()) return getEnv().VITE_APP_VERSION_TYPE === "production";
  else return false;
}
