"use client";
import { Img } from '@page-speed/img';
import { Markdown } from '@page-speed/markdown-to-jsx/core';
import * as React from 'react';
import { Pressable } from '@page-speed/pressable';
import { jsx, Fragment } from 'react/jsx-runtime';

// components/ui/longform-content.tsx
function LongformContent({
  children,
  renderMode = "markdown",
  markdownString,
  optixFlowConfig,
  markdownStyles
}) {
  const shouldRenderMarkdown = React.useMemo(() => {
    return renderMode === "markdown" && typeof markdownString === "string" && markdownString.length > 0;
  }, [renderMode, markdownString]);
  if (shouldRenderMarkdown && markdownString) {
    return /* @__PURE__ */ jsx(
      Markdown,
      {
        markdownStyles,
        optixFlowConfig,
        overrides: {
          img: Img,
          a: Pressable
        },
        children: markdownString
      }
    );
  }
  if (children) {
    return /* @__PURE__ */ jsx(Fragment, { children });
  }
  return null;
}

export { LongformContent };
