import React, { useState } from 'react';
import truck from '../assets/images/truckdelivery_obrez.jpg'
import caterpillar from '../assets/images/company/caterpilar.png'
import komatsu from '../assets/images/company/komatsu.png'
import cummins from '../assets/images/company/cummins.png'
import hitachi from '../assets/images/company/hitachi.png'
import liebherr from '../assets/images/company/liebherr.png'
import shantui from '../assets/images/company/shantui.png'
import shacman from '../assets/images/company/shacman.png'
import shaanxi from '../assets/images/company/shaanxi.png'
import howo from '../assets/images/company/howo.png'
import volvo from '../assets/images/company/volvo.png'
import john_deree from '../assets/images/company/john_deere.png'
import atlas_copco from '../assets/images/company/atlas_copso.png'
import epiroc from '../assets/images/company/epiroc.png'

const MarqueeBrands = () => {
  const [isPaused, setIsPaused] = useState(false);

  const tiles = [
    {
      image: caterpillar,
      title: 'Caterpillar'
    },
    {
      image: komatsu,
      title: 'Komatsu'
    },
    {
      image: cummins,
      title: 'Cummins'
    },
    {
      image: hitachi,
      title: 'Hitachi'
    },
    {
      image: liebherr,
      title: 'Liebherr'
    },
    {
      image: shantui,
      title: 'Shantui'
    },
    {
      image: shacman,
      title: 'Shacman'
    },
    {
      image: howo,
      title: 'Howo'
    },
    {
      image: volvo,
      title: 'Volvo'
    },
    {
      image: shaanxi,
      title: 'Shaanxi'
    },
    {
      image: john_deree,
      title: 'John Deere'
    },
    {
      image: atlas_copco,
      title: 'Atlas Copco'
    },
    {
      image: epiroc,
      title: 'Epiroc'
    },
  ];
  
  // Массив брендов
  const brands = [
    "Caterpillar", 
    "Komatsu", 
    "Cummins", 
    "Hitachi", 
    "Liebherr",
    "Shantui", 
    "Shacman", 
    "Shaanxi", 
    "Howo", 
    "Volvo",
    "John Deere", 
    "Atlas Copco/Epiroc"
  ];

  // Обработчики событий для паузы
  const handleMouseEnter = () => setIsPaused(true);
  const handleMouseLeave = () => setIsPaused(false);
  // 232323
  // c1ff72
  return (
    <div className="w-full bg-[#ffffff] py-8 overflow-hidden">
      <div 
        className="relative"
        onMouseEnter={handleMouseEnter}
        onMouseLeave={handleMouseLeave}
      >
        {/* Градиент затухания слева */}
        <div className="absolute left-0 top-0 bottom-0 w-24 bg-gradient-to-r from-[#ffffff] to-transparent z-10" />
        
        {/* Контейнер для анимации */}
        <div className={`flex whitespace-nowrap ${isPaused ? 'animate-marquee-pause' : 'animate-marquee'}`}>
          {/* Первая копия списка */}
          {brands.map((brand, index) => (
            <span
              key={`first-${index}`}
              className="text-black text-4xl font-bold mx-8 flex items-center"
            >
              {brand}
              {/* Разделитель (кроме последнего элемента) */}
              {index !== brands.length - 1 && (
                <span className="mx-8 text-white/20">|</span>
              )}
            </span>
          ))}

          {/* Вторая копия списка для бесшовной анимации */}
          {brands.map((brand, index) => (
            <span
              key={`second-${index}`}
              className="text-white text-4xl font-bold mx-8 flex items-center"
            >
              {brand}
              {/* Разделитель (кроме последнего элемента) */}
              {index !== brands.length - 1 && (
                <span className="mx-8 text-black/20">|</span>
              )}
            </span>
          ))}
        </div>

        {/* Градиент затухания справа */}
        <div className="absolute right-0 top-0 bottom-0 h-24 w-24 bg-gradient-to-l from-[#ffffff] to-transparent z-10" />
      </div>
    </div>
  );
};

export default MarqueeBrands;