{"version":3,"file":"useMarkdownRehypePlugins.mjs","names":[],"sources":["../../../src/hooks/useMarkdown/useMarkdownRehypePlugins.ts"],"sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport { rehypeGithubAlerts } from 'rehype-github-alerts';\nimport rehypeKatex from 'rehype-katex';\nimport rehypeRaw from 'rehype-raw';\nimport type { Pluggable } from 'unified';\n\nimport { useMarkdownContext } from '@/Markdown/components/MarkdownProvider';\nimport { rehypeCustomFootnotes } from '@/Markdown/plugins/rehypeCustomFootnotes';\nimport { rehypeKatexDir } from '@/Markdown/plugins/rehypeKatexDir';\n\nexport const useMarkdownRehypePlugins = (): Pluggable[] => {\n  const {\n    enableLatex,\n    enableCustomFootnotes,\n    enableGithubAlert,\n    allowHtml,\n    rehypePlugins = [],\n    rehypePluginsAhead = [],\n  } = useMarkdownContext();\n\n  const memoPlugins = useMemo(\n    () =>\n      [\n        allowHtml && rehypeRaw,\n        enableGithubAlert && rehypeGithubAlerts,\n        enableLatex && rehypeKatex,\n        enableLatex && rehypeKatexDir,\n        enableCustomFootnotes && rehypeCustomFootnotes,\n      ].filter(Boolean) as Pluggable[],\n    [enableLatex, enableGithubAlert, enableCustomFootnotes, allowHtml],\n  );\n\n  return useMemo(\n    () => [...rehypePluginsAhead, ...memoPlugins, ...rehypePlugins],\n    [rehypePlugins, memoPlugins, rehypePluginsAhead],\n  );\n};\n"],"mappings":";;;;;;;;;AAYA,MAAa,iCAA8C;CACzD,MAAM,EACJ,aACA,uBACA,mBACA,WACA,gBAAgB,CAAC,GACjB,qBAAqB,CAAC,MACpB,mBAAmB;CAEvB,MAAM,cAAc,cAEhB;EACE,aAAa;EACb,qBAAqB;EACrB,eAAe;EACf,eAAe;EACf,yBAAyB;CAC3B,CAAC,CAAC,OAAO,OAAO,GAClB;EAAC;EAAa;EAAmB;EAAuB;CAAS,CACnE;CAEA,OAAO,cACC;EAAC,GAAG;EAAoB,GAAG;EAAa,GAAG;CAAa,GAC9D;EAAC;EAAe;EAAa;CAAkB,CACjD;AACF"}