"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Logo } from "@/components/logo"; import { Menu } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { MegaMenuMobileCards, serviceMegaItems, ServicesMegaMenu, } from "@/components/nav-mega-menu"; import { Sheet, SheetClose, SheetContent, SheetHeader, SheetTitle, } from "@/components/ui/sheet"; import React from "react"; import { Container } from "@/components/container"; import { cn } from "@/lib/utils"; import { type } from "@/lib/typography"; import { ThemeToggle } from "@/components/theme-toggle"; type NavLeaf = { name: string; href: string; }; type NavEntry = | ({ kind: "link" } & NavLeaf) | { kind: "mega"; name: string }; /** * Top-level nav (RTL reading order, right → left): * صفحه اصلی → خدمات → نمونه کارها → درباره ما → مجله → تماس با ما */ /** Experimental: no real routes yet — keep UI, avoid 404s. */ const navEntries: NavEntry[] = [ { kind: "link", name: "صفحه اصلی", href: "/" }, { kind: "mega", name: "خدمات" }, { kind: "link", name: "نمونه کارها", href: "#" }, { kind: "link", name: "درباره ما", href: "#" }, { kind: "link", name: "مجله", href: "#" }, { kind: "link", name: "تماس با ما", href: "#contact" }, ]; const CTA = { name: "درخواست مشاوره", href: "#contact", } as const; const ENGLISH = { name: "English", href: "#", } as const; /** Scroll threshold before the floating glass shell engages. */ const SCROLL_THRESHOLD = 24; /** Animate only the floating shell chrome — never content size or vertical layout. */ const HEADER_SHELL_EASE = "transition-[padding,border-radius,background-color,border-color,box-shadow,backdrop-filter,-webkit-backdrop-filter,height] duration-300 ease-out"; /** Dim siblings on nav hover; hovered + active routes stay full strength. */ const navItemInteractionClass = cn( "transition-[opacity,background-color,color] duration-300 ease-out", "text-foreground opacity-100", "group-hover/nav:opacity-40", "hover:opacity-100", "group-hover/nav:hover:opacity-100" ); const navItemActiveClass = cn( "bg-muted/60 text-foreground group-hover/nav:opacity-100", "hover:bg-muted/70" ); const navTriggerClass = cn( "group relative inline-flex h-auto items-center gap-1 whitespace-nowrap", type.nav, navItemInteractionClass, "rounded-md bg-transparent px-2.5 py-1.5 shadow-none", "hover:bg-muted/50", "focus-visible:bg-muted/50 focus-visible:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2", "data-[state=open]:bg-muted/60 data-[state=open]:text-foreground", "data-[state=open]:opacity-100 group-hover/nav:data-[state=open]:opacity-100" ); function isLinkActive(pathname: string, href: string): boolean { if (href === "/") return pathname === "/"; if (href.startsWith("/#")) return pathname === "/"; return pathname === href || pathname.startsWith(href + "/"); } function isGroupActive(pathname: string): boolean { return serviceMegaItems.some((item) => isLinkActive(pathname, item.href)); } function NavLink({ href, name, active, className, }: { href: string; name: string; active: boolean; className?: string; }) { return ( {name} ); } function DesktopNav({ pathname }: { pathname: string }) { return (