"use client"; import type { ReactNode } from "react"; import ReactMarkdown, { type Components } from "react-markdown"; import remarkGfm from "remark-gfm"; import { withCitationChips } from "./citation-chips"; type SelectFn = (citationId: string) => void; const PARAGRAPH = "mb-4 text-[15px] leading-7 text-[#111111] last:mb-0"; const HEADING = "mb-3 mt-6 font-black tracking-[-0.04em] text-[#111111] first:mt-0"; function chipped(children: ReactNode, onSelect: SelectFn): ReactNode { return withCitationChips(children, onSelect); } export function AnswerMarkdown({ answer, onCitationSelect, }: { answer: string; onCitationSelect: SelectFn; }) { const components: Components = { p: ({ children }) =>

{chipped(children, onCitationSelect)}

, h1: ({ children }) =>

{chipped(children, onCitationSelect)}

, h2: ({ children }) =>

{chipped(children, onCitationSelect)}

, h3: ({ children }) =>

{chipped(children, onCitationSelect)}

, h4: ({ children }) =>

{chipped(children, onCitationSelect)}

, ul: ({ children }) => , ol: ({ children }) =>
    {children}
, li: ({ children }) =>
  • {chipped(children, onCitationSelect)}
  • , blockquote: ({ children }) => (
    {children}
    ), a: ({ children, href }) => ( {children} ), strong: ({ children }) => {children}, hr: () =>
    , table: ({ children }) => (
    {children}
    ), thead: ({ children }) => {children}, th: ({ children }) => ( {children} ), td: ({ children }) => ( {chipped(children, onCitationSelect)} ), pre: ({ children }) => (
            {children}
          
    ), code: ({ children, className }) => { const isBlock = typeof className === "string" && className.includes("language-"); if (isBlock) { return {children}; } return ( {children} ); }, img: () => null, }; return (
    {answer}
    ); }