// Server-side token functions (only for Server Components)
export async function getServerAccessToken() {
  const { cookies } = await import("next/headers");
  return (await cookies()).get("accessToken")?.value;
}

// Client-side token functions
export function getClientAccessToken(): string | undefined {
  if (typeof window === "undefined") return undefined;

  const cookies = document.cookie.split(";");
  const accessTokenCookie = cookies.find((cookie) =>
    cookie.trim().startsWith("accessToken=")
  );

  return accessTokenCookie?.split("=")[1];
}
