'use client';

import { TooltipProvider } from '@radix-ui/react-tooltip';
import { Provider } from 'react-redux';

import { TextControlProvider } from '../language';
import { MediaControlProvider } from '../media/context/media-control.provider';
import { store } from '../store';
import { ThemeProvider } from '../theme/theme-provider';
import { MediaItem } from '../types/media.type';
import { TextItem } from '../types/text.types';
import { AosProvider } from './aos-provider';
import { Toaster } from './toaster';

type ProvidersProps = {
  children: React.ReactNode;
  textItems: TextItem[];
  mediaItems: MediaItem[];
};

export const Providers = ({
  children,
  textItems,
  mediaItems,
}: ProvidersProps) => {
  return (
    <Provider store={store}>
      <TextControlProvider textItems={textItems}>
        <MediaControlProvider mediaItems={mediaItems}>
          <ThemeProvider
            attribute='class'
            defaultTheme='light'
            enableSystem
            disableTransitionOnChange
          >
            <TooltipProvider>
              <AosProvider>
                {children}
                <Toaster />
              </AosProvider>
            </TooltipProvider>
          </ThemeProvider>
        </MediaControlProvider>
      </TextControlProvider>
    </Provider>
  );
};
