"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import Link from "next/link";
import { useAuth } from "../../../hooks/useAuth.js";
import { Button } from "../../ui/button.js";
import { ThemeToggle } from "../misc/ThemeToggle.js";
import { Menu, X } from "lucide-react";
import { useState } from "react";
import { sel } from "../../../lib/test/index.js";
import { useTranslations } from "next-intl";
function PublicNavbar() {
  const { user, isLoading } = useAuth();
  const [isMenuOpen, setIsMenuOpen] = useState(false);
  const tNav = useTranslations("navigation");
  const tHome = useTranslations("home");
  const tCommon = useTranslations("common");
  const appName = tCommon("appName");
  const navigationItems = [
    { name: "features", href: "/features" },
    { name: "pricing", href: "/pricing" },
    { name: "support", href: "/support" },
    { name: "docs", href: "/docs" }
  ];
  return /* @__PURE__ */ jsxs(
    "header",
    {
      className: "sticky top-0 z-50 w-full border-b border-border/40 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60",
      "data-cy": sel("public.navbar.container"),
      children: [
        /* @__PURE__ */ jsxs("div", { className: "container max-w-7xl mx-auto px-4 flex h-14 items-center", children: [
          /* @__PURE__ */ jsx("div", { className: "mr-4 flex", children: /* @__PURE__ */ jsxs(
            Link,
            {
              href: "/",
              className: "mr-6 flex items-center space-x-2",
              "data-cy": sel("public.navbar.logo"),
              children: [
                /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-lg bg-primary flex items-center justify-center", children: /* @__PURE__ */ jsx("span", { className: "text-primary-foreground font-bold text-sm", children: appName.charAt(0) }) }),
                /* @__PURE__ */ jsx("span", { className: "hidden font-bold sm:inline-block", children: appName })
              ]
            }
          ) }),
          /* @__PURE__ */ jsx("div", { className: "hidden md:flex", children: /* @__PURE__ */ jsx("nav", { className: "flex items-center gap-6 text-sm", children: navigationItems.map((item) => /* @__PURE__ */ jsx(
            Link,
            {
              href: item.href,
              className: "transition-colors hover:text-foreground/80 text-foreground/60",
              children: tNav(item.name)
            },
            item.name
          )) }) }),
          /* @__PURE__ */ jsxs("div", { className: "flex flex-1 items-center justify-between space-x-2 md:justify-end", children: [
            /* @__PURE__ */ jsx("div", { className: "w-full flex-1 md:w-auto md:flex-none" }),
            /* @__PURE__ */ jsxs("div", { className: "hidden md:flex items-center gap-2", children: [
              /* @__PURE__ */ jsx(ThemeToggle, {}),
              isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
                /* @__PURE__ */ jsx("div", { className: "h-9 w-16 bg-muted animate-pulse rounded-md" }),
                /* @__PURE__ */ jsx("div", { className: "h-9 w-20 bg-muted animate-pulse rounded-md" })
              ] }) : user ? /* @__PURE__ */ jsx(Button, { asChild: true, children: /* @__PURE__ */ jsx(Link, { href: "/dashboard", children: tHome("auth.goToDashboard") }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
                /* @__PURE__ */ jsx(Button, { variant: "ghost", asChild: true, "data-cy": sel("public.navbar.loginButton"), children: /* @__PURE__ */ jsx(Link, { href: "/login", children: tHome("auth.signIn") }) }),
                /* @__PURE__ */ jsx(Button, { asChild: true, "data-cy": sel("public.navbar.signupButton"), children: /* @__PURE__ */ jsx(Link, { href: "/signup", children: tHome("auth.createAccount") }) })
              ] })
            ] }),
            /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 md:hidden", children: [
              /* @__PURE__ */ jsx(ThemeToggle, {}),
              /* @__PURE__ */ jsx(
                Button,
                {
                  variant: "ghost",
                  size: "sm",
                  onClick: () => setIsMenuOpen(!isMenuOpen),
                  children: isMenuOpen ? /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) : /* @__PURE__ */ jsx(Menu, { className: "h-5 w-5" })
                }
              )
            ] })
          ] })
        ] }),
        isMenuOpen && /* @__PURE__ */ jsx("div", { className: "md:hidden border-t border-border", children: /* @__PURE__ */ jsxs("div", { className: "container px-4 py-4", children: [
          /* @__PURE__ */ jsx("nav", { className: "flex flex-col space-y-2 mb-4", children: navigationItems.map((item) => /* @__PURE__ */ jsx(
            Link,
            {
              href: item.href,
              className: "px-3 py-2 text-sm rounded-md hover:bg-accent transition-colors",
              onClick: () => setIsMenuOpen(false),
              children: tNav(item.name)
            },
            item.name
          )) }),
          /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-2 pt-4 border-t border-border", children: isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-2", children: [
            /* @__PURE__ */ jsx("div", { className: "h-9 bg-muted animate-pulse rounded-md" }),
            /* @__PURE__ */ jsx("div", { className: "h-9 bg-muted animate-pulse rounded-md" })
          ] }) : user ? /* @__PURE__ */ jsx(Button, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(Link, { href: "/dashboard", onClick: () => setIsMenuOpen(false), children: tHome("auth.goToDashboard") }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
            /* @__PURE__ */ jsx(Button, { variant: "ghost", asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(Link, { href: "/login", onClick: () => setIsMenuOpen(false), children: tHome("auth.signIn") }) }),
            /* @__PURE__ */ jsx(Button, { asChild: true, className: "w-full", children: /* @__PURE__ */ jsx(Link, { href: "/signup", onClick: () => setIsMenuOpen(false), children: tHome("auth.createAccount") }) })
          ] }) })
        ] }) })
      ]
    }
  );
}
export {
  PublicNavbar
};
