"use client";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import Link from "next/link";
import Image from "next/image";
import { usePathname } from "next/navigation";
import { useAuth } from "../../../hooks/useAuth.js";
import { useSidebar } from "../../../contexts/sidebar-context.js";
import { Button } from "../../ui/button.js";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuTrigger
} from "../../ui/dropdown-menu.js";
import { Menu, X, LogOut, User, Settings, CreditCard, HelpCircle, Shield, PanelLeft, PanelLeftClose, Key, Code, Layers, Tags } from "lucide-react";
import { useState, useEffect, useCallback } from "react";
import { ThemeToggle } from "../../app/misc/ThemeToggle.js";
import { NotificationsDropdown } from "../misc/NotificationsDropdown.js";
import { SearchDropdown } from "../misc/SearchDropdown.js";
import { QuickCreateDropdown } from "../misc/QuickCreateDropdown.js";
import { cn } from "../../../lib/utils/index.js";
import { sel, createAriaLabel } from "../../../lib/test/index.js";
import { useTranslations } from "next-intl";
import { useIsSuperAdmin } from "../../app/guards/SuperAdminGuard.js";
import { useIsDeveloper } from "../../app/guards/DeveloperGuard.js";
import { DynamicNavigation } from "../navigation/DynamicNavigation.js";
import { isTopbarFeatureEnabled, getTopbarFeatureConfig, TOPBAR_CONFIG } from "../../../lib/config/index.js";
function TopNavbar({ entities, className }) {
  var _a, _b, _c;
  const { user, signOut, isLoading } = useAuth();
  const pathname = usePathname();
  const { isCollapsed, toggleSidebar } = useSidebar();
  const [isMenuOpen, setIsMenuOpen] = useState(false);
  const [statusMessage, setStatusMessage] = useState("");
  const t = useTranslations("common");
  const isSuperAdmin = useIsSuperAdmin();
  const isDeveloper = useIsDeveloper();
  const superadminConfig = getTopbarFeatureConfig("superadminAccess");
  const devtoolsConfig = getTopbarFeatureConfig("devtoolsAccess");
  const showSuperadmin = (superadminConfig == null ? void 0 : superadminConfig.enabled) && (isSuperAdmin || isDeveloper && (superadminConfig == null ? void 0 : superadminConfig.showToDevelopers));
  const showDevZone = (devtoolsConfig == null ? void 0 : devtoolsConfig.enabled) && isDeveloper;
  const iconMap = {
    "user": User,
    "settings": Settings,
    "credit-card": CreditCard,
    "key": Key,
    "shield": Shield,
    "log-out": LogOut,
    "layers": Layers,
    "tags": Tags
  };
  const getUserInitials = (user2) => {
    if (user2.firstName && user2.lastName) {
      return `${user2.firstName[0]}${user2.lastName[0]}`.toUpperCase();
    }
    if (user2.firstName) {
      return user2.firstName.slice(0, 2).toUpperCase();
    }
    if (user2.email) {
      return user2.email.slice(0, 2).toUpperCase();
    }
    return "U";
  };
  const getAvatarColor = (email) => {
    const colors = [
      "bg-red-500",
      "bg-blue-500",
      "bg-green-500",
      "bg-yellow-500",
      "bg-purple-500",
      "bg-pink-500",
      "bg-indigo-500",
      "bg-orange-500"
    ];
    const index = email.charCodeAt(0) % colors.length;
    return colors[index];
  };
  const handleMenuToggle = useCallback(() => {
    const newState = !isMenuOpen;
    setIsMenuOpen(newState);
    setStatusMessage(newState ? "Men\xFA m\xF3vil abierto" : "Men\xFA m\xF3vil cerrado");
  }, [isMenuOpen]);
  const handleSignOut = useCallback(async () => {
    try {
      setStatusMessage("Cerrando sesi\xF3n...");
      await signOut();
      setStatusMessage("Sesi\xF3n cerrada exitosamente");
    } catch {
      setStatusMessage("Error al cerrar sesi\xF3n");
    }
  }, [signOut]);
  const handleMenuClose = useCallback(() => {
    setIsMenuOpen(false);
    setStatusMessage("Men\xFA cerrado");
  }, []);
  const handleToggleSidebar = useCallback(() => {
    toggleSidebar();
    const newState = !isCollapsed;
    setStatusMessage(newState ? "Sidebar expandido" : "Sidebar contra\xEDdo");
  }, [isCollapsed, toggleSidebar]);
  useEffect(() => {
    const handleKeyDown = (e) => {
      if (e.key === "Escape" && isMenuOpen) {
        handleMenuClose();
      }
    };
    if (isMenuOpen) {
      document.addEventListener("keydown", handleKeyDown);
      return () => document.removeEventListener("keydown", handleKeyDown);
    }
  }, [isMenuOpen, handleMenuClose]);
  return /* @__PURE__ */ jsxs(Fragment, { children: [
    /* @__PURE__ */ jsx(
      "div",
      {
        "aria-live": "polite",
        "aria-atomic": "true",
        className: "sr-only",
        children: statusMessage
      }
    ),
    /* @__PURE__ */ jsxs(
      "nav",
      {
        className: cn(
          "bg-background border-b border-border fixed top-0 right-0 z-40 transition-all duration-300",
          "lg:left-64",
          // Default left position when sidebar is expanded
          isCollapsed && "lg:left-16",
          // Adjusted left position when sidebar is collapsed
          className
        ),
        role: "banner",
        "aria-label": "Navegaci\xF3n principal",
        "data-cy": sel("dashboard.topnav.container"),
        children: [
          /* @__PURE__ */ jsx("div", { className: "w-full pl-2.5 pr-4 sm:pr-6 lg:pr-8", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between h-16", children: [
            /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 flex-1", children: [
              !user && /* @__PURE__ */ jsx(
                Link,
                {
                  href: "/",
                  className: "text-xl font-bold text-foreground lg:hidden",
                  "aria-label": "Ir a la p\xE1gina principal",
                  "data-cy": sel("dashboard.topnav.logo"),
                  children: t("appName")
                }
              ),
              user && /* @__PURE__ */ jsxs(Fragment, { children: [
                /* @__PURE__ */ jsx(
                  Button,
                  {
                    variant: "ghost",
                    size: "icon",
                    onClick: handleToggleSidebar,
                    className: "hidden lg:flex h-8 w-8",
                    "aria-label": isCollapsed ? "Expandir sidebar" : "Contraer sidebar",
                    "aria-expanded": !isCollapsed,
                    "aria-controls": "sidebar-navigation",
                    "data-cy": sel("dashboard.topnav.sidebarToggle"),
                    children: isCollapsed ? /* @__PURE__ */ jsx(PanelLeft, { className: "h-4 w-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(PanelLeftClose, { className: "h-4 w-4", "aria-hidden": "true" })
                  }
                ),
                isTopbarFeatureEnabled("quickCreate") && /* @__PURE__ */ jsx("div", { className: "hidden lg:block", children: /* @__PURE__ */ jsx(QuickCreateDropdown, {}) }),
                isTopbarFeatureEnabled("search") && /* @__PURE__ */ jsx(
                  "div",
                  {
                    className: "hidden lg:flex items-center min-w-0 max-w-sm",
                    role: "search",
                    "aria-label": "B\xFAsqueda de tareas",
                    "data-cy": sel("dashboard.topnav.search.container"),
                    children: /* @__PURE__ */ jsx(SearchDropdown, {})
                  }
                )
              ] })
            ] }),
            /* @__PURE__ */ jsxs(
              "div",
              {
                className: "flex items-center space-x-4 flex-shrink-0",
                role: "toolbar",
                "aria-label": "Acciones y configuraci\xF3n",
                "data-cy": sel("dashboard.topnav.actions"),
                children: [
                  user && isTopbarFeatureEnabled("notifications") && /* @__PURE__ */ jsx(NotificationsDropdown, {}),
                  user && isTopbarFeatureEnabled("support") && /* @__PURE__ */ jsx(
                    Button,
                    {
                      variant: "ghost",
                      size: "sm",
                      asChild: true,
                      "data-cy": sel("dashboard.topnav.help"),
                      children: /* @__PURE__ */ jsxs(
                        Link,
                        {
                          href: "/support",
                          target: "_blank",
                          rel: "noopener noreferrer",
                          "aria-label": "Abrir centro de ayuda en nueva pesta\xF1a",
                          children: [
                            /* @__PURE__ */ jsx(HelpCircle, { className: "h-4 w-4", "aria-hidden": "true" }),
                            /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Ayuda" })
                          ]
                        }
                      )
                    }
                  ),
                  isTopbarFeatureEnabled("themeToggle") && /* @__PURE__ */ jsx(
                    "div",
                    {
                      "data-cy": sel("dashboard.topnav.themeToggle"),
                      children: /* @__PURE__ */ jsx(ThemeToggle, {})
                    }
                  ),
                  user && showSuperadmin && /* @__PURE__ */ jsx(
                    Button,
                    {
                      variant: "ghost",
                      size: "sm",
                      asChild: true,
                      "data-cy": sel("dashboard.topnav.superadmin"),
                      children: /* @__PURE__ */ jsxs(
                        Link,
                        {
                          href: "/superadmin",
                          "aria-label": "Acceder a Super Admin - \xC1rea de super administrador",
                          title: "Super Admin - Super Admin Area",
                          children: [
                            /* @__PURE__ */ jsx(Shield, { className: "h-4 w-4", "aria-hidden": "true" }),
                            /* @__PURE__ */ jsx("span", { className: "sr-only", children: "\xC1rea de super administrador" })
                          ]
                        }
                      )
                    }
                  ),
                  user && showDevZone && /* @__PURE__ */ jsx(
                    Button,
                    {
                      variant: "ghost",
                      size: "sm",
                      asChild: true,
                      "data-cy": sel("dashboard.topnav.devtools"),
                      children: /* @__PURE__ */ jsxs(
                        Link,
                        {
                          href: "/devtools",
                          "aria-label": "Acceder a DevTools - \xC1rea de desarrolladores",
                          title: "DevTools - Developer Area",
                          children: [
                            /* @__PURE__ */ jsx(Code, { className: "h-4 w-4 text-violet-600 dark:text-violet-400", "aria-hidden": "true" }),
                            /* @__PURE__ */ jsx("span", { className: "sr-only", children: "\xC1rea de desarrolladores" })
                          ]
                        }
                      )
                    }
                  ),
                  user && isTopbarFeatureEnabled("settingsMenu") && /* @__PURE__ */ jsxs(DropdownMenu, { children: [
                    /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
                      Button,
                      {
                        variant: "ghost",
                        size: "sm",
                        "data-cy": sel("dashboard.topnav.settingsMenu.trigger"),
                        children: [
                          /* @__PURE__ */ jsx(Settings, { className: "h-4 w-4", "aria-hidden": "true" }),
                          /* @__PURE__ */ jsx("span", { className: "sr-only", children: t("navigation.settings") })
                        ]
                      }
                    ) }),
                    /* @__PURE__ */ jsxs(
                      DropdownMenuContent,
                      {
                        align: "end",
                        className: "w-56",
                        "data-cy": sel("dashboard.topnav.settingsMenu.content"),
                        children: [
                          /* @__PURE__ */ jsx(DropdownMenuLabel, { children: t("navigation.settings") }),
                          /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
                          (_b = (_a = TOPBAR_CONFIG.settingsMenu) == null ? void 0 : _a.links) == null ? void 0 : _b.map((link, index) => {
                            const IconComponent = iconMap[link.icon];
                            return /* @__PURE__ */ jsx(
                              DropdownMenuItem,
                              {
                                asChild: true,
                                "data-cy": sel("dashboard.topnav.settingsMenu.item", { index }),
                                children: /* @__PURE__ */ jsxs(
                                  Link,
                                  {
                                    href: link.href,
                                    className: "flex items-center",
                                    "data-cy": sel("dashboard.topnav.settingsMenu.link", { index }),
                                    children: [
                                      IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: "mr-2 h-4 w-4", "aria-hidden": "true" }),
                                      t(link.label)
                                    ]
                                  }
                                )
                              },
                              index
                            );
                          })
                        ]
                      }
                    )
                  ] }),
                  isLoading ? /* @__PURE__ */ jsx(
                    "div",
                    {
                      className: "h-8 w-20 bg-muted animate-pulse rounded",
                      role: "status",
                      "aria-label": "Cargando informaci\xF3n del usuario",
                      "data-cy": sel("dashboard.topnav.userLoading"),
                      children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Cargando..." })
                    }
                  ) : user ? TOPBAR_CONFIG.userMenu.enabled ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
                    /* @__PURE__ */ jsx(
                      DropdownMenuTrigger,
                      {
                        asChild: true,
                        "data-cy": sel("dashboard.topnav.userMenu.trigger"),
                        children: /* @__PURE__ */ jsxs(
                          Button,
                          {
                            variant: "ghost",
                            className: "flex items-center gap-3 h-auto p-2",
                            "aria-label": createAriaLabel(
                              "Men\xFA de usuario. Cuenta: {name}",
                              { name: user.firstName || user.email }
                            ),
                            "aria-haspopup": "menu",
                            "aria-expanded": "false",
                            children: [
                              user.image ? /* @__PURE__ */ jsx(
                                Image,
                                {
                                  src: user.image,
                                  alt: "",
                                  width: 32,
                                  height: 32,
                                  className: "h-8 w-8 rounded-full object-cover border border-border"
                                }
                              ) : /* @__PURE__ */ jsx(
                                "div",
                                {
                                  className: `h-8 w-8 rounded-full flex items-center justify-center text-white text-sm font-medium ${getAvatarColor(user.email)}`,
                                  role: "img",
                                  "aria-label": `Avatar de ${user.firstName || user.email}`,
                                  children: getUserInitials(user)
                                }
                              ),
                              /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground", children: user.firstName || user.email })
                            ]
                          }
                        )
                      }
                    ),
                    /* @__PURE__ */ jsxs(
                      DropdownMenuContent,
                      {
                        align: "end",
                        className: "w-56",
                        "data-cy": sel("dashboard.topnav.userMenu.content"),
                        children: [
                          (TOPBAR_CONFIG.userMenu.showAvatar || TOPBAR_CONFIG.userMenu.showEmail || TOPBAR_CONFIG.userMenu.showRole) && /* @__PURE__ */ jsx(DropdownMenuLabel, { children: /* @__PURE__ */ jsxs(
                            "div",
                            {
                              className: "flex flex-col space-y-1",
                              role: "group",
                              "aria-label": "Informaci\xF3n del usuario",
                              children: [
                                TOPBAR_CONFIG.userMenu.showAvatar && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: user.firstName || "Usuario" }),
                                TOPBAR_CONFIG.userMenu.showEmail && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: user.email }),
                                TOPBAR_CONFIG.userMenu.showRole && user.role && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t(`userRoles.${user.role}`) })
                              ]
                            }
                          ) }),
                          TOPBAR_CONFIG.userMenu.items.map((item, index) => {
                            if (item.type === "divider") {
                              return /* @__PURE__ */ jsx(DropdownMenuSeparator, {}, `divider-${index}`);
                            }
                            if (item.type === "link" && item.href) {
                              const IconComponent = iconMap[item.icon];
                              return /* @__PURE__ */ jsx(
                                DropdownMenuItem,
                                {
                                  asChild: true,
                                  "data-cy": sel("dashboard.topnav.userMenu.item", { icon: item.icon }),
                                  children: /* @__PURE__ */ jsxs(
                                    Link,
                                    {
                                      href: item.href,
                                      className: "flex items-center",
                                      "aria-label": t(item.label),
                                      children: [
                                        IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: "mr-2 h-4 w-4", "aria-hidden": "true" }),
                                        t(item.label)
                                      ]
                                    }
                                  )
                                },
                                `link-${index}`
                              );
                            }
                            if (item.type === "action" && item.action) {
                              const IconComponent = iconMap[item.icon];
                              const isSignOut = item.action === "signOut";
                              return /* @__PURE__ */ jsxs(
                                DropdownMenuItem,
                                {
                                  onClick: isSignOut ? handleSignOut : void 0,
                                  className: isSignOut ? "text-red-600 focus:text-red-600" : void 0,
                                  "data-cy": sel("dashboard.topnav.userMenu.action", { action: item.action }),
                                  children: [
                                    IconComponent && /* @__PURE__ */ jsx(IconComponent, { className: "mr-2 h-4 w-4", "aria-hidden": "true" }),
                                    t(item.label)
                                  ]
                                },
                                `action-${index}`
                              );
                            }
                            return null;
                          })
                        ]
                      }
                    )
                  ] }) : (
                    /* Simple avatar without dropdown when userMenu is disabled */
                    /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
                      user.image ? /* @__PURE__ */ jsx(
                        Image,
                        {
                          src: user.image,
                          alt: `Avatar de ${user.firstName || user.email}`,
                          width: 32,
                          height: 32,
                          className: "h-8 w-8 rounded-full object-cover border border-border"
                        }
                      ) : /* @__PURE__ */ jsx(
                        "div",
                        {
                          className: `h-8 w-8 rounded-full flex items-center justify-center text-white text-sm font-medium ${getAvatarColor(user.email)}`,
                          "aria-label": `Avatar de ${user.firstName || user.email}`,
                          children: getUserInitials(user)
                        }
                      ),
                      /* @__PURE__ */ jsx("span", { className: "text-sm text-foreground hidden sm:block", children: user.firstName || ((_c = user.email) == null ? void 0 : _c.split("@")[0]) })
                    ] })
                  ) : /* @__PURE__ */ jsxs(Fragment, { children: [
                    /* @__PURE__ */ jsx(
                      Link,
                      {
                        href: "/login",
                        "data-cy": sel("dashboard.topnav.signin"),
                        children: /* @__PURE__ */ jsx(
                          Button,
                          {
                            variant: "ghost",
                            size: "sm",
                            "aria-label": "Iniciar sesi\xF3n",
                            children: t("buttons.signIn")
                          }
                        )
                      }
                    ),
                    /* @__PURE__ */ jsx(
                      Link,
                      {
                        href: "/signup",
                        "data-cy": sel("dashboard.topnav.signup"),
                        children: /* @__PURE__ */ jsx(
                          Button,
                          {
                            size: "sm",
                            "aria-label": "Registrarse",
                            children: t("buttons.signUp")
                          }
                        )
                      }
                    )
                  ] })
                ]
              }
            ),
            /* @__PURE__ */ jsxs(
              "div",
              {
                className: "lg:hidden flex items-center space-x-2",
                role: "group",
                "aria-label": "Acciones m\xF3viles",
                "data-cy": sel("dashboard.topnav.mobileMenu.actions"),
                children: [
                  isTopbarFeatureEnabled("themeToggle") && /* @__PURE__ */ jsx(
                    "div",
                    {
                      children: /* @__PURE__ */ jsx(ThemeToggle, {})
                    }
                  ),
                  user && /* @__PURE__ */ jsx(
                    "button",
                    {
                      onClick: handleMenuToggle,
                      className: "text-foreground/70 hover:text-foreground",
                      "aria-label": isMenuOpen ? "Cerrar men\xFA de navegaci\xF3n" : "Abrir men\xFA de navegaci\xF3n",
                      "aria-expanded": isMenuOpen,
                      "aria-controls": "mobile-menu",
                      "data-cy": sel("dashboard.topnav.mobileMenu.toggle"),
                      children: isMenuOpen ? /* @__PURE__ */ jsx(X, { className: "h-6 w-6", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Menu, { className: "h-6 w-6", "aria-hidden": "true" })
                    }
                  )
                ]
              }
            )
          ] }) }),
          isMenuOpen && /* @__PURE__ */ jsx(
            "div",
            {
              className: "lg:hidden border-t border-border",
              id: "mobile-menu",
              role: "navigation",
              "aria-label": "Men\xFA de navegaci\xF3n m\xF3vil",
              "data-cy": sel("dashboard.topnav.mobileMenu.container"),
              children: /* @__PURE__ */ jsx("div", { className: "px-2 pt-2 pb-3 space-y-1", children: user ? /* @__PURE__ */ jsxs(Fragment, { children: [
                /* @__PURE__ */ jsxs(
                  "div",
                  {
                    className: "mb-4",
                    role: "group",
                    "aria-label": "Navegaci\xF3n principal",
                    children: [
                      /* @__PURE__ */ jsx(
                        DynamicNavigation,
                        {
                          entities,
                          isMobile: true,
                          onItemClick: handleMenuClose
                        }
                      ),
                      showSuperadmin && /* @__PURE__ */ jsxs(
                        Link,
                        {
                          href: "/superadmin",
                          className: cn(
                            "block px-3 py-2 rounded-md text-base font-medium hover:bg-red-50 text-red-600 flex items-center w-fit",
                            pathname.startsWith("/superadmin") ? "bg-red-50 text-red-700" : "text-red-600"
                          ),
                          onClick: handleMenuClose,
                          "aria-label": "Ir a Super Admin - \xC1rea de super administrador",
                          "data-cy": sel("dashboard.topnav.mobileMenu.superadmin"),
                          children: [
                            /* @__PURE__ */ jsx(Shield, { className: "h-4 w-4", "aria-hidden": "true" }),
                            /* @__PURE__ */ jsx("span", { className: "sr-only", children: "\xC1rea de super administrador" })
                          ]
                        }
                      ),
                      showDevZone && /* @__PURE__ */ jsxs(
                        Link,
                        {
                          href: "/devtools",
                          className: cn(
                            "block px-3 py-2 rounded-md text-base font-medium hover:bg-violet-50 dark:hover:bg-violet-950/50 flex items-center w-fit",
                            pathname.startsWith("/devtools") ? "bg-violet-50 dark:bg-violet-950/50 text-violet-700 dark:text-violet-400" : "text-violet-600 dark:text-violet-400"
                          ),
                          onClick: handleMenuClose,
                          "aria-label": "Ir a DevTools - \xC1rea de desarrolladores",
                          "data-cy": sel("dashboard.topnav.mobileMenu.devtools"),
                          children: [
                            /* @__PURE__ */ jsx(Code, { className: "h-4 w-4", "aria-hidden": "true" }),
                            /* @__PURE__ */ jsx("span", { className: "sr-only", children: "\xC1rea de desarrolladores" })
                          ]
                        }
                      )
                    ]
                  }
                ),
                /* @__PURE__ */ jsxs(
                  "div",
                  {
                    className: "flex items-center gap-3 px-3 py-2 border-t border-border pt-4",
                    role: "group",
                    "aria-label": "Informaci\xF3n del usuario",
                    "data-cy": sel("dashboard.topnav.mobileMenu.userInfo"),
                    children: [
                      user.image ? /* @__PURE__ */ jsx(
                        Image,
                        {
                          src: user.image,
                          alt: "",
                          width: 32,
                          height: 32,
                          className: "h-8 w-8 rounded-full object-cover border border-border"
                        }
                      ) : /* @__PURE__ */ jsx(
                        "div",
                        {
                          className: `h-8 w-8 rounded-full flex items-center justify-center text-white text-sm font-medium ${getAvatarColor(user.email)}`,
                          role: "img",
                          "aria-label": `Avatar de ${user.firstName || user.email}`,
                          children: getUserInitials(user)
                        }
                      ),
                      /* @__PURE__ */ jsxs("div", { children: [
                        /* @__PURE__ */ jsx("div", { className: "text-sm font-medium text-foreground", children: user.firstName || "Usuario" }),
                        /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: user.email })
                      ] })
                    ]
                  }
                ),
                /* @__PURE__ */ jsxs(
                  Link,
                  {
                    href: "/dashboard/settings/profile",
                    className: "block px-3 py-2 rounded-md text-base font-medium text-foreground hover:bg-accent",
                    onClick: handleMenuClose,
                    "aria-label": "Ir a perfil",
                    "data-cy": sel("dashboard.topnav.mobileMenu.linkProfile"),
                    children: [
                      /* @__PURE__ */ jsx(User, { className: "inline mr-2 h-4 w-4", "aria-hidden": "true" }),
                      "Profile"
                    ]
                  }
                ),
                /* @__PURE__ */ jsxs(
                  Link,
                  {
                    href: "/dashboard/settings",
                    className: "block px-3 py-2 rounded-md text-base font-medium text-foreground hover:bg-accent",
                    onClick: handleMenuClose,
                    "aria-label": "Ir a configuraci\xF3n",
                    "data-cy": sel("dashboard.topnav.mobileMenu.linkSettings"),
                    children: [
                      /* @__PURE__ */ jsx(Settings, { className: "inline mr-2 h-4 w-4", "aria-hidden": "true" }),
                      "Settings"
                    ]
                  }
                ),
                /* @__PURE__ */ jsxs(
                  Link,
                  {
                    href: "/dashboard/settings/billing",
                    className: "block px-3 py-2 rounded-md text-base font-medium text-foreground hover:bg-accent",
                    onClick: handleMenuClose,
                    "aria-label": "Ir a facturaci\xF3n",
                    "data-cy": sel("dashboard.topnav.mobileMenu.linkBilling"),
                    children: [
                      /* @__PURE__ */ jsx(CreditCard, { className: "inline mr-2 h-4 w-4", "aria-hidden": "true" }),
                      "Billing"
                    ]
                  }
                ),
                /* @__PURE__ */ jsxs(
                  "button",
                  {
                    onClick: () => {
                      handleSignOut();
                      handleMenuClose();
                    },
                    className: "w-full text-left px-3 py-2 rounded-md text-base font-medium text-red-600 hover:bg-accent",
                    "aria-label": "Cerrar sesi\xF3n",
                    "data-cy": sel("dashboard.topnav.mobileMenu.signout"),
                    children: [
                      /* @__PURE__ */ jsx(LogOut, { className: "inline mr-2 h-4 w-4", "aria-hidden": "true" }),
                      "Sign out"
                    ]
                  }
                )
              ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
                /* @__PURE__ */ jsx(
                  Link,
                  {
                    href: "/login",
                    className: "block px-3 py-2 rounded-md text-base font-medium text-foreground hover:bg-accent",
                    onClick: handleMenuClose,
                    "aria-label": "Iniciar sesi\xF3n",
                    "data-cy": sel("dashboard.topnav.signin"),
                    children: "Sign in"
                  }
                ),
                /* @__PURE__ */ jsx(
                  Link,
                  {
                    href: "/signup",
                    className: "block px-3 py-2 rounded-md text-base font-medium text-foreground hover:bg-accent",
                    onClick: handleMenuClose,
                    "aria-label": "Registrarse",
                    "data-cy": sel("dashboard.topnav.signup"),
                    children: "Sign up"
                  }
                )
              ] }) })
            }
          )
        ]
      }
    )
  ] });
}
export {
  TopNavbar
};
