{"version":3,"file":"index.mjs","names":[],"sources":["../src/parser.tsx","../src/Markdown.tsx","../src/index.ts"],"sourcesContent":["/**\n * Parses markdown content into React nodes with support for custom styles, classes, and various markdown features.\n *\n * @param markdown - The markdown string to parse.\n * @param options - Optional settings for parsing the markdown.\n * @returns An array of React nodes representing the parsed markdown content.\n *\n * @example\n * ```ts\n * const markdown = \"# Hello World\\nThis is a paragraph.\";\n * const options = {\n *   customClasses: {\n *     headings: \"my-heading-class\",\n *     paragraphs: \"my-paragraph-class\",\n *   },\n *   customStyles: {\n *     headings: { color: \"red\" },\n *     paragraphs: { fontSize: \"16px\" },\n *   },\n * };\n * const parsedContent = parse(markdown, options);\n * ```\n *\n * @remarks\n * This code is open source under the MIT license. The author can be hired by visiting [Code Media Labs](https://codemedialabs.in).\n */\n\nimport React, { CSSProperties } from \"react\";\n\nexport interface CustomClasses {\n  headings?: string;\n  paragraphs?: string;\n  lists?: string;\n  blockquotes?: string;\n  codeBlocks?: string;\n  tables?: string;\n  links?: string;\n  images?: string;\n  footnotes?: string;\n  footnoteReference?: string;\n  orderedLists?: string;\n  unorderedLists?: string;\n  listItems?: string;\n}\n\nexport interface CustomStyles {\n  headings?: CSSProperties;\n  paragraphs?: CSSProperties;\n  lists?: CSSProperties;\n  blockquotes?: CSSProperties;\n  codeBlocks?: CSSProperties;\n  tables?: CSSProperties;\n  links?: CSSProperties;\n  images?: CSSProperties;\n  footnotes?: CSSProperties;\n  footnoteReference?: CSSProperties;\n  orderedLists?: CSSProperties;\n  unorderedLists?: CSSProperties;\n  listItems?: CSSProperties;\n}\n\n/**\n * Custom components to override default markdown elements.\n */\nexport interface CustomComponents {\n  h1?: React.ComponentType<any>;\n  h2?: React.ComponentType<any>;\n  h3?: React.ComponentType<any>;\n  h4?: React.ComponentType<any>;\n  h5?: React.ComponentType<any>;\n  h6?: React.ComponentType<any>;\n  p?: React.ComponentType<any>;\n  ul?: React.ComponentType<any>;\n  ol?: React.ComponentType<any>;\n  li?: React.ComponentType<any>;\n  dl?: React.ComponentType<any>;\n  dt?: React.ComponentType<any>;\n  dd?: React.ComponentType<any>;\n  blockquote?: React.ComponentType<any>;\n  code?: React.ComponentType<any>;\n  pre?: React.ComponentType<any>;\n  table?: React.ComponentType<any>;\n  thead?: React.ComponentType<any>;\n  tbody?: React.ComponentType<any>;\n  tr?: React.ComponentType<any>;\n  th?: React.ComponentType<any>;\n  td?: React.ComponentType<any>;\n  a?: React.ComponentType<any>;\n  img?: React.ComponentType<any>;\n  del?: React.ComponentType<any>;\n  sup?: React.ComponentType<any>;\n  sub?: React.ComponentType<any>;\n  mark?: React.ComponentType<any>;\n  strong?: React.ComponentType<any>;\n  em?: React.ComponentType<any>;\n  math?: React.ComponentType<{ content: string; isBlock: boolean }>;\n  alert?: React.ComponentType<{ type: string; children: React.ReactNode }>;\n  footnoteReference?: React.ComponentType<{ id: string; label: string }>;\n  footnoteDefinition?: React.ComponentType<{ id: string; children: React.ReactNode }>;\n}\n\n/**\n * Options for parsing markdown content.\n */\nexport interface ParseOptions {\n  /**\n   * Prefix for language-specific code block classes.\n   * @example \"language-\"\n   */\n  langPrefix?: string;\n\n  /**\n   * Custom CSS classes for different markdown elements.\n   */\n  customClasses?: CustomClasses;\n\n  /**\n   * Custom CSS styles for different markdown elements.\n   */\n  customStyles?: CustomStyles;\n\n  /**\n   * Target attribute for links.\n   * @default \"_blank\"\n   */\n  linkTarget?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n\n  /**\n   * Whether to sanitize HTML content.\n   * @default false\n   */\n  sanitizeHtml?: boolean;\n\n  /**\n   * Maximum allowed nesting level for lists.\n   * @default 6\n   */\n  maxNestingLevel?: number;\n\n  /**\n   * Custom components to override default markdown elements.\n   */\n  components?: CustomComponents;\n\n  /**\n   * Callback for rendering math content.\n   * If provided, this function will be called for both inline ($) and block ($$) math.\n   * @param content - The raw math content (TeX/LaTeX).\n   * @param isBlock - Whether the math is a block-level element ($$).\n   */\n  onRenderMath?: (content: string, isBlock: boolean) => React.ReactNode;\n\n  /**\n   * Callback for custom syntax highlighting.\n   * If provided, this function will be called for all code blocks (```).\n   * @param code - The raw code content.\n   * @param language - The language identifier (e.g. \"javascript\", \"python\").\n   */\n  onRenderCode?: (code: string, language?: string) => React.ReactNode;\n}\n\ntype ElementType =\n  | \"headings\"\n  | \"paragraphs\"\n  | \"lists\"\n  | \"blockquotes\"\n  | \"codeBlocks\"\n  | \"tables\"\n  | \"links\"\n  | \"images\"\n  | \"footnotes\"\n  | \"footnoteReference\"\n  | \"orderedLists\"\n  | \"unorderedLists\"\n  | \"listItems\";\n\n/**\n * Modern token-based markdown parser for React.\n * \n * This function performs a two-pass scan on the input markdown:\n * 1. Scans for footnote definitions (`[^1]:`) and hoists them.\n * 2. Parses the content into a tree of React components without using `dangerouslySetInnerHTML`.\n *\n * Support is included for:\n * - GitHub Alerts (`> [!NOTE]`)\n * - Footnotes (`[^1]`)\n * - Math (inline and block)\n * - Tables, Code Blocks, Task Lists, and more.\n *\n * @param markdown - The raw markdown string.\n * @param options - Configuration for styling and component overrides.\n * @returns An array of uniquely keyed React fragments/nodes.\n */\nexport function parse(\n  markdown: string,\n  options: ParseOptions = {},\n  depth = 0\n): React.ReactNode[] {\n  const {\n    langPrefix = \"language-\",\n    customClasses = {},\n    customStyles = {},\n    linkTarget = \"_blank\",\n    sanitizeHtml = true,\n    maxNestingLevel = 6,\n  } = options;\n\n  const lines = markdown.split(/\\r?\\n/);\n  const html: React.ReactNode[] = [];\n\n  if (depth >= maxNestingLevel) {\n    return [<p key=\"max-nest\">Maximum nesting level reached</p>];\n  }\n  let inCodeBlock = false;\n  let codeBlock: string[] = [];\n  let codeBlockLang: string | null = null;\n  let inMathBlock = false;\n  let mathBlock: string[] = [];\n  let nestingLevel = 0;\n  let skipLines = 0;\n\n  const getComponent = (tag: keyof CustomComponents, defaultTag: any) =>\n    options.components?.[tag] || defaultTag;\n\n  const getElementProperties = (\n    elementType: ElementType,\n    additionalProps: Record<string, any> = {}\n  ): { style?: CSSProperties; className?: string } => {\n    const style: CSSProperties = {\n      ...customStyles[elementType],\n      ...additionalProps.style,\n    };\n    const className = customClasses[elementType]\n      ? `${customClasses[elementType]}${\n          additionalProps.className ? ` ${additionalProps.className}` : \"\"\n        }`\n      : additionalProps.className;\n    return {\n      ...additionalProps,\n      style: Object.keys(style).length > 0 ? style : undefined,\n      className: className || undefined,\n    };\n  };\n\n  // Enhanced sanitization function\n  // const sanitize = (text: string): string => {\n  //   if (!sanitizeHtml) return text;\n  //   return text\n  //     .replace(/&/g, \"&amp;\")\n  //     .replace(/</g, \"&lt;\")\n  //     .replace(/>/g, \"&gt;\")\n  //     .replace(/\"/g, \"&quot;\")\n  //     .replace(/'/g, \"&#039;\");\n  // };\n\n  /**\n   * Process inline formatting into React nodes.\n   * This handles bold, italic, links, images, math, and more.\n   */\n  const processInlineFormatting = (text: string): React.ReactNode[] => {\n    if (!text) return [];\n\n    const tokenize = (input: string): React.ReactNode[] => {\n      if (!input) return [];\n      let earliestMatch: any = null;\n      let earliestRule: any = null;\n\n      // Rule definitions: consolidated to save space\n      const rules = [\n        {\n          regex: /!\\[([^\\]]*)\\]\\(([^)\\s]+)(?:\\s+\"([^\"]+)\")?\\)/,\n          render: (m: string, alt: string, src: string, title?: string) => {\n            const Img = getComponent(\"img\", \"img\");\n            return <Img key={m} {...getElementProperties(\"images\", { src, alt: alt || \"\", title })} />;\n          },\n        },\n        {\n          regex: /\\[([^\\]]+)\\]\\(([^)\"'\\s]+)(?:\\s+\"([^\"]+)\")?\\)/,\n          render: (m: string, label: string, url: string, title?: string) => {\n            const A = getComponent(\"a\", \"a\");\n            return (\n              <A key={m} {...getElementProperties(\"links\", { href: url, title, target: linkTarget, rel: linkTarget === \"_blank\" ? \"noopener noreferrer\" : undefined })}>\n                {tokenize(label)}\n              </A>\n            );\n          },\n        },\n        {\n          regex: /\\$?\\$\\$\\s*([\\s\\S]+?)\\s*\\$\\$\\$?/,\n          render: (m: string, content: string) => {\n            if (options.onRenderMath) return <React.Fragment key={m}>{options.onRenderMath(content, true)}</React.Fragment>;\n            const MathComp = getComponent(\"math\", \"div\");\n            const props = getElementProperties(\"paragraphs\", { className: \"math-block\", style: { textAlign: \"center\", margin: \"1rem 0\" } });\n            const isCustom = typeof MathComp !== \"string\";\n            return (\n              <MathComp key={m} {...props} {...(isCustom ? { content, isBlock: true } : {})}>\n                {content}\n              </MathComp>\n            );\n          },\n        },\n        {\n          regex: /\\$([^$\\n]+)\\$/,\n          render: (m: string, content: string) => {\n            if (options.onRenderMath) return <React.Fragment key={m}>{options.onRenderMath(content, false)}</React.Fragment>;\n            const MathComp = getComponent(\"math\", \"span\");\n            const props = getElementProperties(\"paragraphs\", { className: \"math-inline\" });\n            const isCustom = typeof MathComp !== \"string\";\n            return (\n              <MathComp key={m} {...props} {...(isCustom ? { content, isBlock: false } : {})}>\n                {content}\n              </MathComp>\n            );\n          },\n        },\n        // Simple formatting rules using a shorter notation\n        { regex: /~~(.+?)~~/, tag: \"del\" },\n        { regex: /\\^(.+?)\\^/, tag: \"sup\" },\n        { regex: /~(.+?)~/, tag: \"sub\" },\n        { regex: /==(.+?)==/, tag: \"mark\" },\n        { regex: /\\*\\*\\*(.+?)\\*\\*\\*/, render: (m: string, c: string) => <strong key={m}><em>{tokenize(c)}</em></strong> },\n        { regex: /\\*\\*(.+?)\\*\\*/, tag: \"strong\" },\n        { regex: /__(.+?)__/, tag: \"strong\" },\n        { regex: /\\*(.+?)\\*/, tag: \"em\" },\n        { regex: /_(.+?)_/, tag: \"em\" },\n        { regex: /`([^`]+)`/, render: (m: string, c: string) => { const Code = getComponent(\"code\", \"code\"); return <Code key={m}>{c}</Code>; } },\n        {\n          regex: /\\[\\^([^\\]]+)\\]/,\n          render: (m: string, label: string) => {\n            const FootRef = getComponent(\"footnoteReference\", \"sup\");\n            return <FootRef key={m} {...getElementProperties(\"footnoteReference\", { id: `fnref-${label}`, className: \"footnote-ref\" })}><a href={`#fn-${label}`}>{label}</a></FootRef>;\n          },\n        },\n      ];\n\n      for (const rule of rules) {\n        const match = rule.regex.exec(input);\n        if (match && (!earliestMatch || match.index < earliestMatch.index)) {\n          earliestMatch = match;\n          earliestRule = rule;\n        }\n      }\n\n      if (earliestMatch && earliestRule) {\n        const before = input.slice(0, earliestMatch.index);\n        const after = input.slice(earliestMatch.index + earliestMatch[0].length);\n        const matchContent = earliestRule.render \n          ? earliestRule.render(...earliestMatch) \n          : React.createElement(getComponent(earliestRule.tag as any, earliestRule.tag), { key: earliestMatch[0] }, tokenize(earliestMatch[1]));\n\n        return [before, matchContent, ...tokenize(after)].filter(Boolean);\n      }\n      return [input];\n    };\n\n    return tokenize(text);\n  };\n\n  // First pass: scan for footnote definitions\n  const footnotes: Record<string, React.ReactNode[]> = {};\n  const processedLines: string[] = [];\n  lines.forEach((line) => {\n    const fnMatch = line.match(/^\\[\\^([^\\]]+)\\]:\\s*(.*)$/);\n    if (fnMatch) footnotes[fnMatch[1]] = processInlineFormatting(fnMatch[2]);\n    else processedLines.push(line);\n  });\n\n  // Process each line\n  for (let i = 0; i < processedLines.length; i++) {\n    const line = processedLines[i];\n    const index = i;\n\n    if (skipLines > 0) {\n      skipLines--;\n      continue;\n    }\n    // Calculate nesting level for lists/tasks to check before rendering\n    let currentNestingLevel = 0;\n    const isListItem = /^(\\s*)([-*+]|\\d+\\.)\\s/.test(line);\n    const isTaskItem = /^(\\s*)-\\s\\[(x| )\\]/.test(line.trim());\n    \n    if (isListItem || isTaskItem) {\n      const indent = (line.match(/^(\\s*)/)?.[0] || \"\").length;\n      currentNestingLevel = Math.floor(indent / 2);\n    }\n    \n    if (currentNestingLevel > maxNestingLevel) {\n      html.push(<p key={`error-${index}`}>Maximum nesting level reached</p>);\n      continue;\n    }\n    \n    nestingLevel = currentNestingLevel;\n\n    // Handle definition lists - needs multiple line lookahead\n    if (i < processedLines.length - 1) {\n      const currentLine = line.trim();\n      const nextLine = processedLines[i + 1].trim();\n\n      if (\n        currentLine !== \"\" &&\n        !currentLine.startsWith(\":\") &&\n        nextLine.startsWith(\":\")\n      ) {\n        const term = currentLine;\n        const definitions: string[] = [];\n        let j = i + 1;\n\n        // Collect all subsequent definitions\n        while (j < processedLines.length && processedLines[j].trim().startsWith(\":\")) {\n          definitions.push(processedLines[j].trim().slice(1).trim());\n          j++;\n        }\n\n        // Set the number of lines to skip\n        skipLines = definitions.length;\n\n        // Create the definition list element\n        const Dl = getComponent(\"dl\", \"dl\");\n        const Dt = getComponent(\"dt\", \"dt\");\n        const Dd = getComponent(\"dd\", \"dd\");\n        html.push(\n          <Dl key={`dl-${i}`} {...getElementProperties(\"lists\")}>\n            <Dt>{processInlineFormatting(term)}</Dt>\n            {definitions.map((def, defIndex) => (\n              <Dd key={defIndex}>{processInlineFormatting(def)}</Dd>\n            ))}\n          </Dl>\n        );\n\n        continue;\n      }\n    }\n\n    // Headers with custom IDs\n    if (/^#{1,6}\\s/.test(line.trim())) {\n      const level = line.trim().match(/^#{1,6}/)![0].length;\n      const text = line.replace(/^#{1,6}\\s/, \"\");\n      const idMatch = text.match(/\\{#([^}]+)\\}/);\n      const id = idMatch ? idMatch[1] : undefined;\n      const cleanText = text.replace(/\\{#([^}]+)\\}/, \"\").trim();\n\n      const Header = getComponent(`h${level}` as keyof CustomComponents, `h${level}`);\n      html.push(\n        <Header\n          key={`h-${i}`}\n          id={id}\n          {...getElementProperties(\"headings\")}\n        >\n          {processInlineFormatting(cleanText)}\n        </Header>\n      );\n      continue;\n    }\n\n    // Single-line math block ($$ ... $$)\n    if (/^\\$\\$\\s*(.+)\\s*\\$\\$$/.test(line.trim())) {\n      const match = line.trim().match(/^\\$\\$\\s*(.+)\\s*\\$\\$$/);\n      const content = (match?.[1] || \"\").trim();\n      if (options.onRenderMath) {\n        html.push(\n          <React.Fragment key={`math-inline-block-${i}`}>\n            {options.onRenderMath(content, true)}\n          </React.Fragment>\n        );\n      } else {\n        const MathComp = getComponent(\"math\", \"div\");\n        const props = getElementProperties(\"paragraphs\", {\n          className: \"math-block\",\n          style: { textAlign: \"center\", margin: \"1rem 0\" },\n        });\n        const isCustom = typeof MathComp !== \"string\";\n        html.push(\n          <MathComp\n            key={`math-inline-block-${i}`}\n            {...(isCustom ? { content, isBlock: true } : {})}\n            {...props}\n          >\n            {content}\n          </MathComp>\n        );\n      }\n      continue;\n    }\n\n    // Math blocks (multiline)\n    if (line.trim() === \"$$\") {\n      inMathBlock = !inMathBlock;\n      if (inMathBlock) {\n        mathBlock = [];\n      } else {\n        const content = mathBlock.join(\"\\n\");\n        if (options.onRenderMath) {\n          html.push(\n            <React.Fragment key={`math-block-${i}`}>\n              {options.onRenderMath(content, true)}\n            </React.Fragment>\n          );\n        } else {\n          const MathComp = getComponent(\"math\", \"div\");\n          const props = getElementProperties(\"paragraphs\", {\n            className: \"math-block\",\n            style: { textAlign: \"center\", margin: \"1rem 0\" },\n          });\n          const isCustom = typeof MathComp !== \"string\";\n          html.push(\n            <MathComp\n              key={`math-block-${i}`}\n              {...(isCustom ? { content, isBlock: true } : {})}\n              {...props}\n            >\n              {content}\n            </MathComp>\n          );\n        }\n        mathBlock = [];\n      }\n      continue;\n    }\n\n    if (inMathBlock) {\n      mathBlock.push(line);\n      continue;\n    }\n\n    // Code blocks\n    if (/^```(\\S+)?(\\s+\\{.*\\})?$/.test(line.trim())) {\n      inCodeBlock = !inCodeBlock;\n      if (inCodeBlock) {\n        const match = line.trim().match(/^```(\\S+)?/);\n        codeBlockLang = match ? (match[1] || null) : null;\n        codeBlock = [];\n      } else {\n        const code = codeBlock.join(\"\\n\");\n        if (options.onRenderCode) {\n          html.push(\n            <React.Fragment key={`code-${i}`}>\n              {options.onRenderCode(code, codeBlockLang || undefined)}\n            </React.Fragment>\n          );\n        } else {\n          const Pre = getComponent(\"pre\", \"pre\");\n          const Code = getComponent(\"code\", \"code\");\n          html.push(\n            <Pre key={`code-${i}`} {...getElementProperties(\"codeBlocks\")}>\n              <Code\n                className={\n                  codeBlockLang ? `${langPrefix}${codeBlockLang}` : undefined\n                }\n              >\n                {code}\n              </Code>\n            </Pre>\n          );\n        }\n        codeBlock = [];\n        codeBlockLang = null;\n      }\n      continue;\n    }\n\n    if (inCodeBlock) {\n      codeBlock.push(line);\n      continue;\n    }\n\n    if (/^>\\s/.test(line.trim())) {\n      let j = i;\n      const bqLines = [];\n      let alertType: string | null = null;\n      let firstLineContent: string | null = null;\n\n      while (j < processedLines.length) {\n        const currLine = processedLines[j];\n        if (!currLine || !/^>\\s?/.test(currLine.trim())) break;\n\n        const stripped = currLine.trim().replace(/^>\\s?/, \"\");\n        \n        // Check for alert on the FIRST line of the block\n        if (j === i) {\n          const alertMatch = stripped.match(/^\\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\\]\\s*(.*)$/i);\n          if (alertMatch) {\n            alertType = alertMatch[1].toUpperCase();\n            firstLineContent = alertMatch[2];\n            if (firstLineContent.trim()) {\n              bqLines.push(firstLineContent);\n            }\n          } else {\n            bqLines.push(stripped);\n          }\n        } else {\n          bqLines.push(stripped);\n        }\n        j++;\n      }\n\n      const content = parse(bqLines.join(\"\\n\"), options, depth + 1);\n      \n      if (alertType) {\n        const AlertComp = getComponent(\"alert\", \"div\");\n        html.push(\n          <AlertComp\n            key={`alert-${i}`}\n            type={alertType}\n            className={`markdown-alert markdown-alert-${alertType.toLowerCase()}`}\n          >\n            {content}\n          </AlertComp>\n        );\n      } else {\n        // Check for citation in the last line (optional, but keep compatibility)\n        let footer: React.ReactNode = null;\n        const lastLineIdx = bqLines.length - 1;\n        const citationMatch = bqLines[lastLineIdx]?.match(/^(.+?)(?:\\s+--\\s+(.+))$/);\n        \n        let parsedContent = content;\n        if (citationMatch) {\n          const [, text, author] = citationMatch;\n          const linesWithoutCitation = [...bqLines.slice(0, lastLineIdx), text];\n          parsedContent = parse(linesWithoutCitation.join(\"\\n\"), options, depth + 1);\n          footer = (\n            <footer\n              style={{\n                marginTop: \"0.5rem\",\n                fontSize: \"0.9em\",\n                textAlign: \"right\",\n              }}\n            >\n              &mdash; {author}\n            </footer>\n          );\n        }\n\n        const Blockquote = getComponent(\"blockquote\", \"blockquote\");\n        html.push(\n          <Blockquote key={`bq-${i}`} {...getElementProperties(\"blockquotes\")}>\n            {parsedContent}\n            {footer}\n          </Blockquote>\n        );\n      }\n      i = j - 1;\n      continue;\n    }\n\n    // Tables with alignment\n    if (/^\\|(.+\\|)+/.test(line.trim())) {\n      // Check if this is not an alignment row\n      if (!/^\\|(\\s*:?-+:?\\s*\\|)+/.test(line.trim())) {\n        const tableRows: string[] = [line.trim()];\n        const alignments: Array<\"left\" | \"center\" | \"right\"> = [];\n\n        // Check for alignment row\n        if (\n          i + 1 < processedLines.length &&\n          /^\\|(\\s*:?-+:?\\s*\\|)+/.test(processedLines[i + 1].trim())\n        ) {\n          const alignmentRow = processedLines[i + 1].trim();\n          alignments.push(\n            ...alignmentRow\n              .split(\"|\")\n              .slice(1, -1)\n              .map((cell) => {\n                if (cell.trim().startsWith(\":\") && cell.trim().endsWith(\":\"))\n                  return \"center\";\n                if (cell.trim().endsWith(\":\")) return \"right\";\n                return \"left\";\n              })\n          );\n          i++; // Skip alignment row\n        }\n\n        // Collect body rows\n        while (\n          i + 1 < processedLines.length &&\n          /^\\|(.+\\|)+/.test(processedLines[i + 1].trim()) &&\n          !/^\\|(\\s*:?-+:?\\s*\\|)+/.test(processedLines[i + 1].trim())\n        ) {\n          tableRows.push(processedLines[i + 1].trim());\n          i++;\n        }\n\n        const headerColumns = tableRows[0]\n          .split(\"|\")\n          .slice(1, -1)\n          .map((col) => col.trim());\n\n        const tableProps = getElementProperties(\"tables\");\n        const Table = getComponent(\"table\", \"table\");\n        const Thead = getComponent(\"thead\", \"thead\");\n        const Tbody = getComponent(\"tbody\", \"tbody\");\n        const Tr = getComponent(\"tr\", \"tr\");\n        const Th = getComponent(\"th\", \"th\");\n        const Td = getComponent(\"td\", \"td\");\n\n        html.push(\n          <Table key={`table-${i}`} {...tableProps}>\n            <Thead>\n              <Tr>\n                {headerColumns.map((col, idx) => (\n                  <Th key={idx} style={{ textAlign: alignments[idx] || \"left\" }}>\n                    {processInlineFormatting(col)}\n                  </Th>\n                ))}\n              </Tr>\n            </Thead>\n            <Tbody>\n              {tableRows.slice(1).map((row, rowIndex) => (\n                <Tr key={rowIndex}>\n                  {row\n                    .split(\"|\")\n                    .slice(1, -1)\n                    .map((cell, cellIndex) => (\n                      <Td\n                        key={cellIndex}\n                        style={{ textAlign: alignments[cellIndex] || \"left\" }}\n                      >\n                        {processInlineFormatting(cell.trim())}\n                      </Td>\n                    ))}\n                </Tr>\n              ))}\n            </Tbody>\n          </Table>\n        );\n        continue;\n      }\n    }\n\n    // Images\n    if (/^!\\[([^\\]]*)\\]\\(([^)\\s]+)(?:\\s+\"([^\"]+)\")?\\)$/.test(line.trim())) {\n      const match = line.trim().match(/^!\\[([^\\]]*)\\]\\(([^)\\s]+)(?:\\s+\"([^\"]+)\")?\\)$/);\n      const [, alt = \"\", src = \"\", title = \"\"] = match!;\n      html.push(\n        <img\n          key={`img-${i}`}\n          src={src}\n          alt={alt}\n          title={title || undefined}\n          {...getElementProperties(\"images\")}\n        />\n      );\n      continue;\n    }\n\n    // Lists (ordered and unordered)\n    if (/^(\\s*)([-*+]|\\d+\\.)\\s/.test(line)) {\n      const match = line.match(/^\\s*/);\n      const currentIndent = match![0].length;\n      const isOrdered = /^\\s*\\d+\\./.test(line);\n      const ListTag = isOrdered ? \"ol\" : \"ul\";\n      const ListComp = getComponent(ListTag, ListTag);\n      const Li = getComponent(\"li\", \"li\");\n\n      const items: { contentLines: string[]; isTask: boolean; checked: boolean }[] = [];\n      let j = i;\n\n      while (j < processedLines.length) {\n        const currLine = processedLines[j];\n        if (!currLine) {\n          j++;\n          continue;\n        }\n\n        const match = currLine.match(/^\\s*/);\n        const currIndent = match![0].length;\n        const currTrim = currLine.trim();\n        const currIsListItem = /^([-*+]|\\d+\\.)(\\s+|$)/.test(currTrim);\n        const currIsOrdered = /^\\d+\\./.test(currTrim);\n\n        // If it's a new item at the SAME level\n        if (currIsListItem && currIndent === currentIndent && currIsOrdered === isOrdered) {\n          const taskMatch = currTrim.match(/^([-*+]|\\d+\\.)\\s+\\[([ xX])\\](?:\\s+(.*))?$/);\n          items.push({\n            isTask: !!taskMatch,\n            checked: taskMatch ? taskMatch[2].toLowerCase() === \"x\" : false,\n            contentLines: [taskMatch ? taskMatch[3] : currTrim.replace(/^([-*+]|\\d+\\.)\\s+/, \"\")],\n          });\n          j++;\n        } \n        // If it's indented more or it's an empty line within the list\n        else if (currIndent > currentIndent || currTrim === \"\") {\n          const content = currLine.slice(currentIndent);\n          items[items.length - 1].contentLines.push(content);\n          j++;\n        } \n        // Otherwise, it's the end of the list\n        else {\n          break;\n        }\n      }\n\n      html.push(\n        <ListComp key={`list-${i}`} {...getElementProperties(isOrdered ? \"orderedLists\" : \"unorderedLists\")}>\n          {items.map((item, idx) => {\n            // Trim common leading spaces from contentLines to avoid over-indentation in recursive parse\n            const trimmedLines = item.contentLines.map(l => l.replace(/^\\s{1,4}/, \"\"));\n            const content = parse(trimmedLines.join(\"\\n\"), options, depth + 1);\n            \n            if (item.isTask) {\n              return (\n                <Li\n                  key={`li-${idx}`}\n                  {...getElementProperties(\"listItems\", {\n                    className: \"task-list-item\",\n                    style: {\n                      display: \"flex\",\n                      alignItems: \"flex-start\",\n                      gap: \"8px\",\n                      listStyleType: \"none\",\n                      marginLeft: \"-1.2rem\",\n                    },\n                  })}\n                >\n                  <input\n                    type=\"checkbox\"\n                    checked={item.checked}\n                    readOnly\n                    style={{\n                      marginTop: \"0.4rem\",\n                      cursor: \"default\",\n                    }}\n                  />\n                  <div style={{ flex: 1 }}>{content}</div>\n                </Li>\n              );\n            }\n\n            return (\n              <Li key={`li-${idx}`} {...getElementProperties(\"listItems\")}>\n                {content}\n              </Li>\n            );\n          })}\n        </ListComp>\n      );\n\n      i = j - 1;\n      continue;\n    }\n\n    // Process regular paragraphs with inline formatting\n    const processedNodes = processInlineFormatting(line.trim());\n    if (processedNodes.length > 0) {\n      const P = getComponent(\"p\", \"p\");\n      html.push(\n        <P key={`p-${i}`} {...getElementProperties(\"paragraphs\")}>\n          {processedNodes}\n        </P>\n      );\n    }\n  }\n\n  // Final pass: append footnotes section if any were used\n  const usedFootnotes = Object.keys(footnotes);\n  if (usedFootnotes.length > 0) {\n    const Section = getComponent(\"dl\", \"section\"); // Default to section\n    const FootDef = getComponent(\"footnoteDefinition\", \"div\");\n    html.push(\n      <Section key=\"footnotes-section\" {...getElementProperties(\"footnotes\", { className: \"footnotes\" })}>\n        <hr />\n        {usedFootnotes.map((id) => (\n          <FootDef\n            key={id}\n            {...getElementProperties(\"footnotes\", {\n              id: `fn-${id}`,\n              className: \"footnote-item\",\n            })}\n          >\n            <span className=\"footnote-label\">[{id}]: </span>\n            {footnotes[id]}\n          </FootDef>\n        ))}\n      </Section>\n    );\n  }\n\n  return html;\n}\n","import React, { useMemo } from \"react\";\nimport { parse, ParseOptions } from \"./parser\";\n\nexport interface MarkdownProps {\n  /**\n   * The markdown content to be rendered.\n   * @example\n   * ```md\n   * # Hello World\n   *\n   * This is a **markdown** paragraph with [links](https://example.com)\n   * ```\n   */\n  content: string;\n\n  /**\n   * Configuration options for the markdown parser.\n   * Includes component overrides, hooks, and global styling.\n   * @optional\n   */\n  options?: ParseOptions;\n\n  /**\n   * Additional CSS class names to be applied to the container.\n   * @optional\n   */\n  className?: string;\n\n  /**\n   * Custom styles to be applied to the container.\n   * @optional\n   */\n  style?: React.CSSProperties;\n\n  /**\n   * Whether to wrap the content in an article element instead of a div.\n   * Recommended for semantic HTML when rendering full articles or blog posts.\n   * @default false\n   * @optional\n   */\n  asArticle?: boolean;\n\n  /**\n   * Custom ID to be applied to the container.\n   * @optional\n   */\n  id?: string;\n\n  /**\n   * Additional accessibility attributes for the container.\n   * @optional\n   */\n  aria?: {\n    /** Accessible label for the container. */\n    label?: string;\n    /** ID of the element that describes this container. */\n    describedBy?: string;\n  };\n}\n\n/**\n * A ultra-lightweight React component that renders markdown content with a token-based React renderer.\n * \n * Key Features:\n * - Token-based rendering (No `dangerouslySetInnerHTML`)\n * - GitHub-style alerts (`> [!NOTE]`)\n * - Footnote support (`[^1]`)\n * - Mathematical blocks (`$$`) and inline math (`$`)\n * - Advanced component overrides via the `components` prop.\n *\n * @example\n * ```tsx\n * import Markdown from \"markdown-parser-react\";\n * \n * // Basic usage\n * <Markdown content=\"# Hello World\" />\n *\n * // Advanced usage with component overrides and hooks\n * <Markdown\n *   content={markdownContent}\n *   options={{\n *     customStyles: {\n *       headings: { color: \"#10b981\" }\n *     },\n *     components: {\n *       h1: ({ children }) => <h1 className=\"text-4xl font-bold\">{children}</h1>,\n *       a: (props) => <CustomLink {...props} />\n *     },\n *     onRenderMath: (content, isBlock) => (\n *       <MyMathRenderer content={content} block={isBlock} />\n *     )\n *   }}\n *   asArticle={true}\n * />\n * ```\n * @remarks\n * This library is open source under the MIT license. Support and customization \n * are available through [Code Media Labs](https://codemedialabs.in).\n */\nexport function Markdown({\n  content,\n  options,\n  className,\n  style,\n  asArticle = false,\n  id,\n  aria,\n}: MarkdownProps) {\n  // Memoize parsed content to prevent unnecessary re-renders\n  const parsedContent = useMemo(() => {\n    try {\n      return parse(content, options);\n    } catch (error) {\n      console.error(\"Error parsing markdown:\", error);\n      return [<p key=\"error\">Error parsing markdown content</p>];\n    }\n  }, [content, options]);\n\n  // Common props for container\n  const containerProps = {\n    className: className\n      ? `markdown-container ${className}`\n      : \"markdown-container\",\n    style,\n    id,\n    ...(aria?.label && { \"aria-label\": aria.label }),\n    ...(aria?.describedBy && { \"aria-describedby\": aria.describedBy }),\n  };\n\n  // Use article tag for full content, div for partial content\n  const Container = asArticle ? \"article\" : \"div\";\n\n  return <Container {...containerProps}>{parsedContent}</Container>;\n}\n\nexport const defaultStyles = `\n.markdown-container {\n  font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n  line-height: 1.6;\n  color: #1f2328;\n  max-width: 100%;\n}\n.markdown-container h1, .markdown-container h2 {\n  border-bottom: 1px solid #d0d7de;\n  padding-bottom: 0.3em;\n  margin-top: 1.5em;\n}\n.markdown-container a {\n  color: #0969da;\n  text-decoration: none;\n}\n.markdown-container a:hover {\n  text-decoration: underline;\n}\n.markdown-container img {\n  max-width: 100%;\n  height: auto;\n  border-radius: 6px;\n}\n.markdown-container pre {\n  overflow-x: auto;\n  padding: 16px;\n  background-color: #f6f8fa;\n  border-radius: 6px;\n  font-size: 85%;\n  line-height: 1.45;\n}\n.markdown-container code {\n  padding: 0.2em 0.4em;\n  margin: 0;\n  font-size: 85%;\n  background-color: rgba(175, 184, 193, 0.2);\n  border-radius: 6px;\n  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;\n}\n.markdown-container pre code {\n  background-color: transparent;\n  padding: 0;\n}\n.markdown-container blockquote {\n  border-left: 0.25em solid #d0d7de;\n  margin: 0;\n  padding: 0 1em;\n  color: #636c76;\n}\n.markdown-container table {\n  border-spacing: 0;\n  border-collapse: collapse;\n  margin-top: 0;\n  margin-bottom: 16px;\n  width: 100%;\n}\n.markdown-container table th, .markdown-container table td {\n  padding: 6px 13px;\n  border: 1px solid #d0d7de;\n}\n.markdown-container table tr {\n  background-color: #ffffff;\n  border-top: 1px solid #d0d7de;\n}\n.markdown-container table tr:nth-child(2n) {\n  background-color: #f6f8fa;\n}\n.markdown-container .task-list-item {\n  list-style-type: none;\n}\n.markdown-container .task-list-item input[type=\"checkbox\"] {\n  cursor: pointer;\n  width: 1.2rem;\n  height: 1.2rem;\n  margin: 0.2rem 0.5rem 0 0;\n  accent-color: #0969da;\n  flex-shrink: 0;\n}\n.markdown-container .markdown-alert {\n  padding: 1rem 1rem 1rem 1.25rem;\n  margin-bottom: 16px;\n  color: inherit;\n  border-left: 0.25em solid #d0d7de;\n  border-radius: 6px;\n}\n.markdown-alert > *:last-child {\n  margin-bottom: 0;\n}\n.markdown-alert > *:first-child {\n  margin-top: 0;\n}\n.markdown-alert-note { border-left-color: #0969da !important; background-color: #f0f7ff; }\n.markdown-alert-tip { border-left-color: #1a7f37 !important; background-color: #f0fff4; }\n.markdown-alert-important { border-left-color: #8250df !important; background-color: #f8f5ff; }\n.markdown-alert-warning { border-left-color: #9a6700 !important; background-color: #fff8ec; }\n.markdown-alert-caution { border-left-color: #cf222e !important; background-color: #fff1f0; }\n\n.markdown-container .math-block {\n  overflow-x: auto;\n  padding: 1rem 0;\n  font-size: 110%;\n}\n.markdown-container .task-list-item input[type=\"checkbox\"] {\n  cursor: pointer;\n  width: 1.1em;\n  height: 1.1em;\n  accent-color: #0969da;\n}\n.markdown-container .footnotes {\n  font-size: 0.85em;\n  color: #636c76;\n  margin-top: 2rem;\n}\n`;\n\nexport default Markdown;\n","/**\n * A lightweight and configurable Markdown renderer for React and Next.js.\n * Features include token-based rendering, GitHub callouts, math support, and footnotes.\n *\n * @remarks\n * This library is open source under the MIT license. Support and customization \n * are available through [Code Media Labs](https://codemedialabs.in).\n */\nimport Markdown from \"./Markdown\";\n\nexport * from \"./Markdown\";\nexport type {\n  CustomClasses,\n  CustomComponents,\n  CustomStyles,\n  ParseOptions,\n} from \"./parser\";\n\nexport default Markdown;\n"],"mappings":";;;AAiMA,SAAgB,EACd,GACA,IAAwB,EAAE,EAC1B,IAAQ,GACW;CACnB,IAAM,EACJ,gBAAa,aACb,mBAAgB,EAAE,EAClB,kBAAe,EAAE,EACjB,gBAAa,UACb,kBAAe,IACf,qBAAkB,MAChB,GAEE,IAAQ,EAAS,MAAM,QAAQ,EAC/B,IAA0B,EAAE;AAElC,KAAI,KAAS,EACX,QAAO,CAAC,kBAAC,KAAD,EAAA,UAAkB,iCAAiC,EAA5C,WAA4C,CAAC;CAE9D,IAAI,IAAc,IACd,IAAsB,EAAE,EACxB,IAA+B,MAC/B,IAAc,IACd,IAAsB,EAAE,EAExB,IAAY,GAEV,KAAgB,GAA6B,MACjD,EAAQ,aAAa,MAAQ,GAEzB,KACJ,GACA,IAAuC,EAAE,KACS;EAClD,IAA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