"use client"; import { useState, useEffect, useRef } from "react"; import { Button } from "@/components/ui/button"; import { Switch } from "@/components/ui/switch"; import { motion, Variants } from "framer-motion"; import { Shield, EyeOff } from "lucide-react"; import { useTheme } from "next-themes"; import dynamic from "next/dynamic"; import { Dictionary } from "@/lib/IDict"; import Link from "next/link"; const MatrixBackground = dynamic(() => import("./MatrixBackground"), { ssr: false, }); 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"); useEffect(() => { 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, }); }; if (!isClosed) window.addEventListener("mousemove", handleMouseMove); return () => window.removeEventListener("mousemove", handleMouseMove); }, [isClosed]); 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 }, }, }; // ИНВЕРСИЯ: Активный VPN (vpnOn) теперь фиолетовый (Primary), выключенный - циан (Secondary) const borderColor = vpnOn ? "border-purple-600 dark:border-primary shadow-[0_0_15px_rgba(139,61,255,0.3)] dark:shadow-[0_0_20px_rgba(139,61,255,0.4)]" : "border-cyan-600 dark:border-secondary shadow-[0_0_15px_rgba(0,229,242,0.3)] dark:shadow-[0_0_20px_rgba(0,229,242,0.4)]"; return ( {/* ИНВЕРСИЯ ЦВЕТА ПОЛОСКИ */} ); } function CyberWatcherEyes({ vpnOn }: { vpnOn: boolean }) { const [isBlinking, setIsBlinking] = useState(false); const blinkTimerRef = useRef(null); const unblinkTimerRef = useRef(null); useEffect(() => { if (vpnOn) { if (blinkTimerRef.current) clearTimeout(blinkTimerRef.current); if (unblinkTimerRef.current) clearTimeout(unblinkTimerRef.current); return; } const scheduleNextBlink = () => { const delay = Math.random() * 3500 + 1500; blinkTimerRef.current = setTimeout(() => { setIsBlinking(true); unblinkTimerRef.current = setTimeout(() => { setIsBlinking(false); scheduleNextBlink(); }, 140); }, delay); }; scheduleNextBlink(); return () => { if (blinkTimerRef.current) clearTimeout(blinkTimerRef.current); if (unblinkTimerRef.current) clearTimeout(unblinkTimerRef.current); }; }, [vpnOn]); const shouldBeClosed = vpnOn || isBlinking; return (
); } export function Hero({ dict, lang, }: { dict: Dictionary["hero"]; lang: string; }) { const [isVpnOn, setIsVpnOn] = useState(false); const { resolvedTheme } = useTheme(); return (
{/* ИНВЕРСИЯ БЕЙДЖА */} {isVpnOn ? ( ) : ( )} {isVpnOn ? dict.badgeSecure : dict.badge} {/* ИНВЕРСИЯ ЗАГОЛОВКА */}

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

{dict.subtitle}

{/* ИНВЕРСИЯ SWITCH'А */}
Netrunner VPN
{/* ИНВЕРСИЯ КНОПОК */}
); }