export function decodeJwt(token) {
  try {
    if (!token || token.split(".").length < 2) return null;
    const payload = token.split(".")[1];
    const json = atob(payload.replace(/-/g, "+").replace(/_/g, "/"));
    return JSON.parse(json);
  } catch {
    return null;
  }
}

export function readAccessToken() {
  return (
    localStorage.getItem("kc_token") ||
    localStorage.getItem("access_token") ||
    localStorage.getItem("token") ||
    ""
  );
}
