"use client";

import { C1Component, ThemeProvider } from "@thesysai/genui-sdk";

type ThesysC1RendererProps = {
  c1Response: string;
  content: string;
  isStreaming: boolean;
  onAction?: (event: { llmFriendlyMessage?: string; humanFriendlyMessage?: string }) => void;
};

export function ThesysC1Renderer({ c1Response, content, isStreaming, onAction }: ThesysC1RendererProps) {
  const C1Any = C1Component as unknown as React.ComponentType<any>;
  const safeC1Response = typeof c1Response === "string" ? c1Response : "";
  const safeContent = typeof content === "string" ? content : "";

  if (!safeC1Response.trim()) {
    return null;
  }

  return (
    <ThemeProvider>
      <C1Any
        c1Response={safeC1Response}
        content={safeContent}
        isStreaming={isStreaming}
        onAction={onAction}
      />
    </ThemeProvider>
  );
}
