"use client"; import { useState, useRef } from "react"; import { Switch } from "@/components/ui/switch"; import { motion, Variants } from "framer-motion"; import { Shield, EyeOff } from "lucide-react"; import { Dictionary } from "@/lib/IDict"; import { CyberButton } from "../ui/cyber-button"; import { NetrunnerMatrix } from "../graphics/NetrunnerMatrix"; import { useTheme } from "next-themes"; function CyberEye({ isClosed, vpnOn }: { isClosed: boolean; vpnOn: boolean }) { const eyeRef = useRef(null); const [offset, setOffset] = useState({ x: 0, y: 0 }); const [direction, setDirection] = useState("center"); const handleMouseMove = (e: MouseEvent) => { if (isClosed || !eyeRef.current) return; const rect = eyeRef.current.getBoundingClientRect(); const eyeCenterX = rect.left + rect.width / 2; const eyeCenterY = rect.top + rect.height / 2; const dx = e.clientX - eyeCenterX; const dy = e.clientY - eyeCenterY; if (Math.abs(dx) < 30 && Math.abs(dy) < 30) { setDirection("center"); } else if (Math.abs(dx) > Math.abs(dy)) { setDirection(dx > 0 ? "right" : "left"); } else { setDirection(dy > 0 ? "down" : "up"); } const angle = Math.atan2(dy, dx); const maxRadius = 22; const distance = Math.min(maxRadius, Math.hypot(dx, dy) * 0.12); setOffset({ x: Math.cos(angle) * distance, y: Math.sin(angle) * distance }); }; useState(() => { if (typeof window !== "undefined") { window.addEventListener("mousemove", handleMouseMove); return () => window.removeEventListener("mousemove", handleMouseMove); } }); const eyeVariants: Variants = { open: { height: 72, width: 120, borderRadius: 36, borderWidth: 4, transition: { type: "spring", stiffness: 450, damping: 12 }, }, closed: { height: 6, width: 140, borderRadius: 8, borderWidth: 3, transition: { type: "spring", stiffness: 600, damping: 14 }, }, }; const borderColor = vpnOn ? "border-purple-600 dark:border-primary shadow-[0_0_15px_rgba(139,61,255,0.3)]" : "border-cyan-600 dark:border-secondary shadow-[0_0_15px_rgba(0,229,242,0.3)]"; return ( ); } function CyberWatcherEyes({ vpnOn }: { vpnOn: boolean }) { const [isBlinking, setIsBlinking] = useState(false); const timerRef = useRef(null); useState(() => { const schedule = () => { timerRef.current = setTimeout( () => { setIsBlinking(true); setTimeout(() => { setIsBlinking(false); schedule(); }, 140); }, Math.random() * 3500 + 1500, ); }; if (!vpnOn) schedule(); return () => clearTimeout(timerRef.current); }); const shouldBeClosed = vpnOn || isBlinking; return (
); } export function Hero({ dict, lang, }: { dict: Dictionary["hero"]; lang: string; }) { const [isVpnOn, setIsVpnOn] = useState(false); const { resolvedTheme } = useTheme(); return (
{/* --- RUST BACKGROUND --- */}
{/* Прозрачные слои для виньетки — теперь не мешают кликам */}
{/* Оборачиваем интерактивные элементы в pointer-events-auto, чтобы они работали на фоне некликабельного motion.div */}
{isVpnOn ? ( ) : ( )} {isVpnOn ? dict.badgeSecure : dict.badge}

{dict.titleStart}{" "} {dict.titleHighlight}

{dict.subtitle}

Netrunner VPN
{dict.ctaPrimary} {dict.ctaSecondary}
); }