"use client";

import type { ReactNode } from "react";

import { ChatProvider } from "@/stores/chat/chat-context";
import { PaymentProvider } from "@/stores/payment/payment-context";
import { ChatAuthSync } from "@/stores/sync/chat-auth-sync";
import { ChatPaymentSuccessSync } from "@/stores/sync/chat-payment-success-sync";
import { PaymentSuccessSync } from "@/stores/sync/payment-success-sync";

export interface ChatRouteProvidersProps {
  children: ReactNode;
  characterId: string;
  emptyChatGreeting: string;
}

export function ChatRouteProviders({
  children,
  characterId,
  emptyChatGreeting,
}: ChatRouteProvidersProps) {
  return (
    <PaymentProvider key={characterId}>
      <PaymentSuccessSync />
      <ChatProvider
        key={characterId}
        characterId={characterId}
        emptyChatGreeting={emptyChatGreeting}
      >
        <ChatAuthSync />
        <ChatPaymentSuccessSync />
        {children}
      </ChatProvider>
    </PaymentProvider>
  );
}
