{"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,EAAE,EAClB,qBAAqB,EAAE,KACrB,oBAAoB;CAExB,MAAM,cAAc,cAEhB;EACE,aAAa;EACb,qBAAqB;EACrB,eAAe;EACf,eAAe;EACf,yBAAyB;EAC1B,CAAC,OAAO,QAAQ,EACnB;EAAC;EAAa;EAAmB;EAAuB;EAAU,CACnE;AAED,QAAO,cACC;EAAC,GAAG;EAAoB,GAAG;EAAa,GAAG;EAAc,EAC/D;EAAC;EAAe;EAAa;EAAmB,CACjD"}