import {jsx}from'react/jsx-runtime';import {useState,useEffect}from'react';import {useParams}from'@remix-run/react';import {MarkdownPage}from'@admin-layout/tailwind-ui/components/Markdown/MarkdownPage.js';import {getCategoryByIdSync,loadArticleContent}from'../../utils/markdownLoader.js';/**
 * Wrapper component that uses Remix useParams to automatically load article data.
 * This maintains backward compatibility with the existing routing structure.
 *
 * For a more reusable approach, use ArticlePage directly with props.
 */
const MarkdownPageWithParams = () => {
  const {
    categoryId,
    articleSlug
  } = useParams();
  const [markdown, setMarkdown] = useState(null);
  const [previousMarkdown, setPreviousMarkdown] = useState(null);
  const [nextMarkdown, setNextMarkdown] = useState(null);
  useEffect(() => {
    if (articleSlug) {
      const loadContent = async () => {
        const articleData = await loadArticleContent(articleSlug);
        setMarkdown(articleData);
        // Calculate previous/next markdown from category
        if (articleData) {
          const category = getCategoryByIdSync(articleData.categoryId || categoryId || '');
          const categoryArticles = category?.articles ?? [];
          const currentIndex = categoryArticles.findIndex(a => a.slug === articleData.slug);
          if (currentIndex > 0) {
            const prev = categoryArticles[currentIndex - 1];
            setPreviousMarkdown({
              categoryId: articleData.categoryId || categoryId || '',
              slug: prev.slug,
              title: prev.title
            });
          } else {
            setPreviousMarkdown(null);
          }
          if (currentIndex >= 0 && currentIndex < categoryArticles.length - 1) {
            const next = categoryArticles[currentIndex + 1];
            setNextMarkdown({
              categoryId: articleData.categoryId || categoryId || '',
              slug: next.slug,
              title: next.title
            });
          } else {
            setNextMarkdown(null);
          }
        }
      };
      loadContent();
    }
  }, [articleSlug, categoryId]);
  const category = markdown ? getCategoryByIdSync(markdown.categoryId || categoryId || '') : null;
  console.log('markdown---->>>>', markdown);
  return jsx(MarkdownPage, {
    article: markdown,
    categoryId: categoryId,
    categoryTitle: category?.title,
    articleSlug: articleSlug,
    loadArticle: loadArticleContent,
    previousMarkdown: previousMarkdown,
    nextMarkdown: nextMarkdown,
    getMarkdownLink: (categoryId, slug) => `/help/${categoryId}/${slug}`,
    getCategoryLink: categoryId => `/help/${categoryId}`,
    getHelpCenterLink: () => '/help',
    helpCenterLabel: "All Collections",
    backToHelpCenterLabel: "\u2190 Back to Help Center"
  });
};export{MarkdownPageWithParams};//# sourceMappingURL=MarkdownPageWithParams.js.map
