import { EtibBlock } from './types';
import { HeroVideo } from '@/components/blocks/HeroVideo';
import { SubCompanyTiles } from '@/components/blocks/SubCompanyTiles';
import { CompetenceBentoGrid } from '@/components/blocks/CompetenceBentoGrid';
import { ReferencesSlider } from '@/components/blocks/ReferencesSlider';
import Hero from '@/components/home/Hero';
import ProductCategories from '@/components/home/ProductCategories';
import WhatWeDo from '@/components/home/WhatWeDo';
import RecentPosts from '@/components/home/RecentPosts';
import Experience from '@/components/home/Experience';
import WhyChooseUs from '@/components/home/WhyChooseUs';
import MeetTheTeam from '@/components/home/MeetTheTeam';
import GallerySection from '@/components/home/GallerySection';
import VideoSection from '@/components/home/VideoSection';
import CTA from '@/components/home/CTA';

export const HomeHero: EtibBlock = {
  slug: 'homeHero',
  interfaceName: 'HomeHeroBlock',
  render: HeroVideo,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
    { name: 'videoUrl', type: 'text', admin: { description: 'URL to the background mp4 video' } },
    { name: 'posterImage', type: 'upload', relationTo: 'media' },
    { name: 'ctaLabel', type: 'text', localized: true },
    { name: 'ctaHref', type: 'text' },
    { name: 'secondaryCtaLabel', type: 'text', localized: true },
    { name: 'secondaryCtaHref', type: 'text' },
  ],
};

export const HomeSubCompanyTiles: EtibBlock = {
  slug: 'homeSubCompanyTiles',
  interfaceName: 'HomeSubCompanyTilesBlock',
  render: SubCompanyTiles,
  fields: [
    { name: 'badge', type: 'text', localized: true },
    { name: 'title', type: 'text', localized: true },
    {
      name: 'companies',
      type: 'array',
      localized: true,
      fields: [
        { name: 'title', type: 'text' },
        { name: 'description', type: 'textarea' },
        { name: 'icon', type: 'text', admin: { description: 'SVG path for the icon' } },
        { name: 'backgroundImage', type: 'upload', relationTo: 'media' },
      ],
    },
  ],
};

export const HomeCompetenceBentoGrid: EtibBlock = {
  slug: 'homeCompetenceBentoGrid',
  interfaceName: 'HomeCompetenceBentoGridBlock',
  render: CompetenceBentoGrid,
  fields: [
    { name: 'badge', type: 'text', localized: true },
    { name: 'title', type: 'text', localized: true },
    { name: 'ctaLabel', type: 'text', localized: true },
    { name: 'ctaHref', type: 'text' },
    {
      name: 'items',
      type: 'array',
      localized: true,
      fields: [
        { name: 'title', type: 'text' },
        { name: 'description', type: 'textarea' },
        { name: 'tag', type: 'text' },
        { name: 'image', type: 'upload', relationTo: 'media' },
        {
          name: 'size',
          type: 'select',
          options: [
            { label: 'Large (2x2)', value: 'large' },
            { label: 'Medium (1x2)', value: 'medium' },
            { label: 'Small (1x1)', value: 'small' },
            { label: 'Accent (Text only)', value: 'accent' },
          ],
          defaultValue: 'small',
        },
      ],
    },
  ],
};

export const HomeReferencesSlider: EtibBlock = {
  slug: 'homeReferencesSlider',
  interfaceName: 'HomeReferencesSliderBlock',
  render: ReferencesSlider,
  fields: [
    { name: 'badge', type: 'text', localized: true },
    { name: 'title', type: 'text', localized: true },
    { name: 'description', type: 'textarea', localized: true },
    { name: 'ctaLabel', type: 'text', localized: true },
    { name: 'ctaHref', type: 'text' },
  ],
};

export const HomeProductCategories: EtibBlock = {
  slug: 'homeProductCategories',
  interfaceName: 'HomeProductCategoriesBlock',
  render: ProductCategories,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
  ],
};

export const HomeWhatWeDo: EtibBlock = {
  slug: 'homeWhatWeDo',
  interfaceName: 'HomeWhatWeDoBlock',
  render: WhatWeDo,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
    { name: 'expertiseLabel', type: 'text', localized: true },
    { name: 'quote', type: 'textarea', localized: true },
    {
      name: 'items',
      type: 'array',
      localized: true,
      fields: [
        { name: 'title', type: 'text' },
        { name: 'description', type: 'textarea' },
      ],
    },
  ],
};

export const HomeRecentPosts: EtibBlock = {
  slug: 'homeRecentPosts',
  interfaceName: 'HomeRecentPostsBlock',
  render: RecentPosts,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
  ],
};

export const HomeExperience: EtibBlock = {
  slug: 'homeExperience',
  interfaceName: 'HomeExperienceBlock',
  render: Experience,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
    { name: 'paragraph1', type: 'textarea', localized: true },
    { name: 'paragraph2', type: 'textarea', localized: true },
    { name: 'badge1', type: 'text', localized: true },
    { name: 'badge1Text', type: 'text', localized: true },
    { name: 'badge2', type: 'text', localized: true },
    { name: 'badge2Text', type: 'text', localized: true },
  ],
};

export const HomeWhyChooseUs: EtibBlock = {
  slug: 'homeWhyChooseUs',
  interfaceName: 'HomeWhyChooseUsBlock',
  render: WhyChooseUs,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
    { name: 'tagline', type: 'text', localized: true },
    {
      name: 'features',
      type: 'array',
      localized: true,
      fields: [{ name: 'feature', type: 'text' }],
    },
    {
      name: 'items',
      type: 'array',
      localized: true,
      fields: [
        { name: 'title', type: 'text' },
        { name: 'description', type: 'textarea' },
      ],
    },
  ],
};

export const HomeMeetTheTeam: EtibBlock = {
  slug: 'homeMeetTheTeam',
  interfaceName: 'HomeMeetTheTeamBlock',
  render: MeetTheTeam,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
    { name: 'description', type: 'textarea', localized: true },
    { name: 'ctaLabel', type: 'text', localized: true },
    { name: 'networkLabel', type: 'text', localized: true },
  ],
};

export const HomeGallery: EtibBlock = {
  slug: 'homeGallery',
  interfaceName: 'HomeGalleryBlock',
  render: GallerySection,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
  ],
};

export const HomeVideo: EtibBlock = {
  slug: 'homeVideo',
  interfaceName: 'HomeVideoBlock',
  render: VideoSection,
  fields: [{ name: 'title', type: 'text', localized: true }],
};

export const HomeCTA: EtibBlock = {
  slug: 'homeCTA',
  interfaceName: 'HomeCTABlock',
  render: CTA,
  fields: [
    { name: 'title', type: 'text', localized: true },
    { name: 'subtitle', type: 'text', localized: true },
    { name: 'description', type: 'textarea', localized: true },
    { name: 'buttonLabel', type: 'text', localized: true },
  ],
};

export const homeBlocksArray = [
    HomeHero,
    HomeSubCompanyTiles,
    HomeCompetenceBentoGrid,
    HomeReferencesSlider,
    HomeProductCategories,
    HomeWhatWeDo,
    HomeRecentPosts,
    HomeExperience,
    HomeWhyChooseUs,
    HomeMeetTheTeam,
    HomeGallery,
    HomeVideo,
    HomeCTA,
];
