import * as React from 'react';
import Link from 'next/link';

import { auth, sessionUser } from '@/auth';
import { Button } from '@/components/ui/Button';
import { UserMenu } from '@/components/UserMenu';
import { IconPlus, IconSeparator } from '@/components/ui/Icons';
import { LoginMenu } from './LoginMenu';
import { redirect } from 'next/navigation';
import Image from 'next/image';
import LandingLogo from '@/assets/svg/LandingAI_white.svg';

export async function Header() {
  const session = await auth();
  const { isAdmin } = await sessionUser();

  if (process.env.NEXT_PUBLIC_IS_HUGGING_FACE) {
    return (
      <header className="sticky top-0 z-50 flex items-center justify-end w-full h-16 px-8 border-b shrink-0 bg-gradient-to-b from-background/10 via-background/50 to-background/80 backdrop-blur-xl">
        <Button variant="link" asChild className="mr-2">
          <Link href="/chat">New Chat</Link>
        </Button>
      </header>
    );
  }
  return (
    <header className="sticky top-0 z-50 flex items-center justify-start w-full h-16 px-4 border-b shrink-0 bg-gradient-to-b from-background/10 via-background/50 to-background/80 backdrop-blur-xl">
      <div className="overflow-hidden w-[150px] h-[45px] shrink-0 grow-0 relative">
        <Image src={LandingLogo} alt="Landing AI" fill />
      </div>
      <div className="grow" />
      {/* <Tooltip>
        <TooltipTrigger asChild>
          <Button variant="link" asChild className="mr-2">
            <Link href="/chat">
              <IconPlus />
            </Link>
          </Button>
        </TooltipTrigger>
        <TooltipContent>New chat</TooltipContent>
      </Tooltip> */}
      {/* {isAdmin && (
        <Button variant="link" asChild className="mr-2">
          <Link href="/all">All Chats (Internal)</Link>
        </Button>
      )}
      {isAdmin && (
        <Button variant="link" asChild className="mr-2">
          <Link href="/project">Projects (Internal)</Link>
        </Button>
      )} */}
      <Button variant="link" asChild className="mr-2">
        <Link href="/chat">Chat</Link>
      </Button>
      <IconSeparator className="size-6 text-muted-foreground/50" />
      <div className="flex items-center grow-0">
        {session?.user ? <UserMenu user={session!.user} /> : <LoginMenu />}
      </div>
    </header>
  );
}
