"use client"; import { AnimatePresence, motion, useMotionValue, useSpring, useTransform } from "framer-motion"; import { Menu, X } from "lucide-react"; import Image from "next/image"; import { type MouseEvent, type PointerEvent, useState } from "react"; import { business, type Locale } from "@/config/business"; import type { Messages } from "@/messages"; import LanguageSwitcher from "./LanguageSwitcher"; import PhysicsButton from "./PhysicsButton"; const navCtaClassName = "rounded-full border border-white/45 bg-[linear-gradient(180deg,#565b63_0%,#20242a_48%,#111317_100%)] font-semibold text-white shadow-[inset_0_1px_0_rgba(255,255,255,0.38),inset_0_-10px_18px_rgba(0,0,0,0.18),0_14px_32px_rgba(17,19,23,0.18)] transition-colors hover:bg-[linear-gradient(180deg,#476a95_0%,#264b73_54%,#173655_100%)]"; export default function Navbar({ locale, onLocaleChange, t, whatsappUrl }: { locale: Locale; onLocaleChange: (locale: Locale) => void; t: Messages; whatsappUrl: string }) { const [open, setOpen] = useState(false); function scrollToSection(event: MouseEvent, href: string) { if (!href.startsWith("#")) return; event.preventDefault(); const target = document.querySelector(href); if (!target) return; setOpen(false); target.scrollIntoView({ behavior: "smooth", block: "start" }); window.history.replaceState(null, "", href); } return (
{open ? (
{t.nav.links.map((link) => ( scrollToSection(event, link.href)} initial={{ opacity: 0, x: locale === "ar" ? -8 : 8 }} animate={{ opacity: 1, x: 0 }} transition={{ duration: 0.1, ease: "easeOut" }} whileTap={{ scale: 0.98 }} className="rounded-2xl px-4 py-3 text-sm font-semibold text-ink/72 hover:bg-smoke" > {link.label} ))}
) : null}
); } function StretchNavLink({ href, label, onClick }: { href: string; label: string; onClick: (event: MouseEvent) => void }) { const pullX = useMotionValue(0); const pullY = useMotionValue(0); const x = useSpring(pullX, { stiffness: 260, damping: 16, mass: 0.3 }); const y = useSpring(pullY, { stiffness: 260, damping: 16, mass: 0.3 }); const scaleX = useTransform(x, [-18, 0, 18], [1.12, 1, 1.12]); const scaleY = useTransform(y, [-12, 0, 12], [0.94, 1, 0.94]); function handlePointerMove(event: PointerEvent) { if (event.pointerType === "touch") return; const bounds = event.currentTarget.getBoundingClientRect(); const localX = event.clientX - bounds.left - bounds.width / 2; const localY = event.clientY - bounds.top - bounds.height / 2; pullX.set(Math.max(-18, Math.min(18, localX * 0.42))); pullY.set(Math.max(-12, Math.min(12, localY * 0.38))); } function release() { pullX.set(0); pullY.set(0); } return ( {label} ); }