const TOKEN_KEY = "__xboard_admin_token__";

export function getAuthToken() {
  return window.localStorage.getItem(TOKEN_KEY) || "";
}

export function setAuthToken(token) {
  if (!token) {
    window.localStorage.removeItem(TOKEN_KEY);
    return;
  }

  window.localStorage.setItem(TOKEN_KEY, token);
}

export function clearAuthToken() {
  window.localStorage.removeItem(TOKEN_KEY);
}

export function getLanguage() {
  return window.localStorage.getItem("i18nextLng") || "zh-CN";
}

export function isPublicEndpoint(pathname, publicEndpoints) {
  return publicEndpoints.includes(pathname);
}
