react-reason-editor 1.0.76 → 1.0.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/dist/Ai-CfgczVyp.cjs +1 -0
  2. package/dist/Ai-DsWeNKXF.js +1 -0
  3. package/dist/Ai.cjs +1 -1
  4. package/dist/Ai.js +1 -1
  5. package/dist/{Attachment-bBEf8uOc.js → Attachment-BmQoshq_.js} +1 -1
  6. package/dist/Attachment.cjs +1 -1
  7. package/dist/Attachment.js +1 -1
  8. package/dist/{Blockquote-Cw5Zty9X.js → Blockquote-cNS4L62L.js} +1 -1
  9. package/dist/Blockquote.cjs +1 -1
  10. package/dist/Blockquote.js +1 -1
  11. package/dist/{Bold-BwuX7fZs.js → Bold-DiKXbC2z.js} +1 -1
  12. package/dist/Bold.cjs +1 -1
  13. package/dist/Bold.js +1 -1
  14. package/dist/BubbleMenus-CIOMgQ-M.js +216 -0
  15. package/dist/BubbleMenus-vqNuXWlm.cjs +1 -0
  16. package/dist/BulletList.cjs +1 -1
  17. package/dist/BulletList.js +1 -1
  18. package/dist/{Callout-CJofZEpX.js → Callout-BLkbFKjv.js} +1 -1
  19. package/dist/{Callout-wjo2BYZi.cjs → Callout-CpkjGEBS.cjs} +1 -1
  20. package/dist/Callout.cjs +1 -1
  21. package/dist/Callout.js +1 -1
  22. package/dist/Clear.cjs +1 -1
  23. package/dist/Clear.js +1 -1
  24. package/dist/{Code-CtIvf6_L.js → Code-DvYJ892R.js} +1 -1
  25. package/dist/Code.cjs +1 -1
  26. package/dist/Code.js +1 -1
  27. package/dist/{CodeBlock-DoIb7GC2.js → CodeBlock-B3dLyClh.js} +1 -1
  28. package/dist/CodeBlock.cjs +1 -1
  29. package/dist/CodeBlock.js +1 -1
  30. package/dist/CodeView.cjs +1 -1
  31. package/dist/CodeView.js +1 -1
  32. package/dist/{Color-DSs2MkQU.js → Color-Cng09GRR.js} +1 -1
  33. package/dist/{Color-B9PloDr5.cjs → Color-ZjBs7t7J.cjs} +1 -1
  34. package/dist/Color.cjs +1 -1
  35. package/dist/Color.js +1 -1
  36. package/dist/{Column-BXSoMVXw.cjs → Column-BaMOYvoO.cjs} +1 -1
  37. package/dist/{Column-CrT9596v.js → Column-DO6MfrOQ.js} +1 -1
  38. package/dist/Column.cjs +1 -1
  39. package/dist/Column.js +1 -1
  40. package/dist/{Drawer-CfcCPGCn.cjs → Drawer-CC24iVYp.cjs} +1 -1
  41. package/dist/{Drawer-DuQ5tw2t.js → Drawer-CL5Rhqw4.js} +1 -1
  42. package/dist/Drawer.cjs +1 -1
  43. package/dist/Drawer.js +1 -1
  44. package/dist/{Drawio-DQEgw3du.cjs → Drawio-CD_Tea_o.cjs} +1 -1
  45. package/dist/{Drawio-P620K_Ps.js → Drawio-LEtUoVAY.js} +1 -1
  46. package/dist/Drawio.cjs +1 -1
  47. package/dist/Drawio.js +1 -1
  48. package/dist/{Emoji-CYM4tY7s.js → Emoji-DN3yfwz_.js} +1 -1
  49. package/dist/Emoji.cjs +1 -1
  50. package/dist/Emoji.js +1 -1
  51. package/dist/{ExportPdf-BoD_D91q.js → ExportPdf-CrQVmD4l.js} +1 -1
  52. package/dist/ExportPdf.cjs +1 -1
  53. package/dist/ExportPdf.js +1 -1
  54. package/dist/{ExportWord-Bj9q_cyK.js → ExportWord-BM4ogH_i.js} +1 -1
  55. package/dist/ExportWord.cjs +1 -1
  56. package/dist/ExportWord.js +1 -1
  57. package/dist/FontFamily.cjs +1 -1
  58. package/dist/FontFamily.js +1 -1
  59. package/dist/FontSize.cjs +1 -1
  60. package/dist/FontSize.js +1 -1
  61. package/dist/{Heading-BHOPoy3X.js → Heading-Bcrl3eKU.js} +1 -1
  62. package/dist/Heading.cjs +1 -1
  63. package/dist/Heading.js +1 -1
  64. package/dist/{Highlight-BxKQNHmT.cjs → Highlight-cO9V18Me.cjs} +1 -1
  65. package/dist/{Highlight-3SpxpGDw.js → Highlight-uXDlNgw3.js} +1 -1
  66. package/dist/Highlight.cjs +1 -1
  67. package/dist/Highlight.js +1 -1
  68. package/dist/{History-CmI6jUTV.js → History-BoHiw0Bn.js} +1 -1
  69. package/dist/History.cjs +1 -1
  70. package/dist/History.js +1 -1
  71. package/dist/{HorizontalRule-BeLfU92F.js → HorizontalRule-C7mAKdzL.js} +1 -1
  72. package/dist/HorizontalRule.cjs +1 -1
  73. package/dist/HorizontalRule.js +1 -1
  74. package/dist/{Iframe-D-WaYtdF.cjs → Iframe-DGL_MOLf.cjs} +1 -1
  75. package/dist/{Iframe-C0ozlEX4.js → Iframe-D_IjezyZ.js} +1 -1
  76. package/dist/Iframe.cjs +1 -1
  77. package/dist/Iframe.js +1 -1
  78. package/dist/Image.cjs +1 -1
  79. package/dist/Image.js +1 -1
  80. package/dist/{ImageCropper-BVl7AuRL.js → ImageCropper-ChOGJuHZ.js} +1 -1
  81. package/dist/{ImageCropper-DqHxEOtN.cjs → ImageCropper-DDWnFI2-.cjs} +1 -1
  82. package/dist/{ImageGif-BSVyqEv6.cjs → ImageGif-3dik7FeU.cjs} +1 -1
  83. package/dist/{ImageGif-BvthT-Lc.js → ImageGif-D_kKkBU5.js} +1 -1
  84. package/dist/ImageGif.cjs +1 -1
  85. package/dist/ImageGif.js +1 -1
  86. package/dist/{ImportWord-C6EnXbyR.js → ImportWord-CtFBb_n4.js} +1 -1
  87. package/dist/ImportWord.cjs +1 -1
  88. package/dist/ImportWord.js +1 -1
  89. package/dist/{Indent-BuzxHbMb.js → Indent-BIk98fDV.js} +1 -1
  90. package/dist/{Indent-eL-WNEF4.cjs → Indent-BVMl9zKV.cjs} +1 -1
  91. package/dist/Indent.cjs +1 -1
  92. package/dist/Indent.js +1 -1
  93. package/dist/{Italic-D8ZI09FZ.js → Italic-3mlmsxqN.js} +1 -1
  94. package/dist/Italic.cjs +1 -1
  95. package/dist/Italic.js +1 -1
  96. package/dist/{Katex-46mDLDuw.cjs → Katex-C2AcX_Un.cjs} +1 -1
  97. package/dist/{Katex-B-lo5eMz.js → Katex-DRPWO2AM.js} +1 -1
  98. package/dist/Katex.cjs +1 -1
  99. package/dist/Katex.js +1 -1
  100. package/dist/LineHeight.cjs +1 -1
  101. package/dist/LineHeight.js +1 -1
  102. package/dist/{Link-CDtipqwb.js → Link-D5y_0ekP.js} +1 -1
  103. package/dist/Link.cjs +1 -1
  104. package/dist/Link.js +1 -1
  105. package/dist/{LinkEditBlock-D0V9PwbF.cjs → LinkEditBlock-D78J06F7.cjs} +1 -1
  106. package/dist/MarkdownPaste.cjs +1 -1
  107. package/dist/MarkdownPaste.js +1 -1
  108. package/dist/{Mermaid-DDV93CBT.cjs → Mermaid-B6SL3cf5.cjs} +1 -1
  109. package/dist/{Mermaid-Cb8MiE1N.js → Mermaid-BaTtCsrD.js} +1 -1
  110. package/dist/Mermaid.cjs +1 -1
  111. package/dist/Mermaid.js +1 -1
  112. package/dist/{MoreMark-CJ3nTD1T.js → MoreMark-Bfsa3STU.js} +1 -1
  113. package/dist/MoreMark.cjs +1 -1
  114. package/dist/MoreMark.js +1 -1
  115. package/dist/OrderedList.cjs +1 -1
  116. package/dist/OrderedList.js +1 -1
  117. package/dist/{ReasonDocs-BliNN1Tt.cjs → ReasonDocs-Bjefr26w.cjs} +1 -1
  118. package/dist/{ReasonDocs-4vxZ3zY7.js → ReasonDocs-_hTAa8-q.js} +1 -1
  119. package/dist/{RichTextProvider-Dl77gVJI.cjs → RichTextProvider-BuTrDlZY.cjs} +1 -1
  120. package/dist/{RichTextProvider-E6rbc_J2.js → RichTextProvider-D9EtjDKS.js} +1 -1
  121. package/dist/SearchAndReplace.cjs +1 -1
  122. package/dist/SearchAndReplace.js +1 -1
  123. package/dist/{SlashCommand-DtlUkwyM.js → SlashCommand-Cg-Rvv3o.js} +1 -1
  124. package/dist/SlashCommand.js +1 -1
  125. package/dist/{Strike-CWYl45VK.js → Strike-CSxbYwpk.js} +1 -1
  126. package/dist/Strike.cjs +1 -1
  127. package/dist/Strike.js +1 -1
  128. package/dist/{Table-DCLsW5DJ.js → Table-CFcOg-4n.js} +1 -1
  129. package/dist/{Table-C9RAHNEk.cjs → Table-Do_kTawS.cjs} +1 -1
  130. package/dist/Table.cjs +1 -1
  131. package/dist/Table.js +1 -1
  132. package/dist/TaskList.cjs +1 -1
  133. package/dist/TaskList.js +1 -1
  134. package/dist/{TextAlign-D4UgbJ7F.cjs → TextAlign-CcsTIs-9.cjs} +1 -1
  135. package/dist/{TextAlign-9ezg8E99.js → TextAlign-Dun3_Ozv.js} +1 -1
  136. package/dist/TextAlign.cjs +1 -1
  137. package/dist/TextAlign.js +1 -1
  138. package/dist/TextDirection.cjs +1 -1
  139. package/dist/TextDirection.js +1 -1
  140. package/dist/{TextUnderline-C5A078R0.js → TextUnderline-Cqm5NQVW.js} +1 -1
  141. package/dist/TextUnderline.cjs +1 -1
  142. package/dist/TextUnderline.js +1 -1
  143. package/dist/{Twitter-D7ulyHFD.cjs → Twitter-B4IYTs3E.cjs} +1 -1
  144. package/dist/{Twitter-ByGJ4v1K.js → Twitter-CZHAICpz.js} +1 -1
  145. package/dist/Twitter.cjs +1 -1
  146. package/dist/Twitter.js +1 -1
  147. package/dist/{Video-hhw77FP4.js → Video-5nw_Zeob.js} +1 -1
  148. package/dist/{Video-ConJGjxP.cjs → Video-CtGR5VVD.cjs} +1 -1
  149. package/dist/Video.cjs +1 -1
  150. package/dist/Video.js +1 -1
  151. package/dist/WordCount.cjs +1 -1
  152. package/dist/WordCount.js +1 -1
  153. package/dist/bubble-BhkjoWdo.js +79 -0
  154. package/dist/bubble.cjs +1 -1
  155. package/dist/bubble.js +1 -1
  156. package/dist/{cdn-loader-BGIuN138-wkFA6jnE.cjs → cdn-loader-BGIuN138-7PrAg-Ef.cjs} +1 -1
  157. package/dist/docs-agent.cjs +1 -1
  158. package/dist/docs-agent.js +1 -1
  159. package/dist/editor-kit.cjs +1 -1
  160. package/dist/editor-kit.js +1 -1
  161. package/dist/editorConfig-BR7z-P0e.js +18 -0
  162. package/dist/editorConfig-CHBSp2KG.cjs +1 -0
  163. package/dist/extensions/Ai/Ai.d.ts +22 -5
  164. package/dist/extensions/Ai/commands.d.ts +6 -1
  165. package/dist/extensions/Ai/components/AiMenu.d.ts +6 -5
  166. package/dist/extensions/Ai/components/RichTextAi.d.ts +12 -0
  167. package/dist/extensions/Ai/index.d.ts +9 -3
  168. package/dist/extensions/Ai/lib/completionToContent.d.ts +35 -0
  169. package/dist/extensions/Ai/lib/createStreamingCompletion.d.ts +27 -0
  170. package/dist/extensions/Ai/lib/prompt.d.ts +38 -0
  171. package/dist/extensions/Ai/lib/sanitizeCompletion.d.ts +37 -0
  172. package/dist/extensions/Ai/types.d.ts +47 -3
  173. package/dist/index.cjs +1 -1
  174. package/dist/index.js +1 -1
  175. package/dist/marked.esm-B7mQ2Kzc.cjs +1 -0
  176. package/dist/marked.esm-CNm6O672.js +1 -0
  177. package/dist/{react-BQVDEMs2.cjs → react-Bfe0Tko8.cjs} +1 -1
  178. package/dist/reason-docs.cjs +1 -1
  179. package/dist/reason-docs.js +1 -1
  180. package/dist/{reason-toolbar-skin-9xQLtzeK.js → reason-toolbar-skin-BNYK97ET.js} +1 -1
  181. package/dist/{reason-toolbar-skin-DyYu9ywU.cjs → reason-toolbar-skin-CD4T53He.cjs} +1 -1
  182. package/dist/style.css +1 -1
  183. package/dist/useButtonProps-BBiR6DPI.cjs +1 -0
  184. package/dist/useButtonProps-Codtb0k0.js +1 -0
  185. package/package.json +1 -1
  186. package/dist/Ai-BGpnAE8s.js +0 -1
  187. package/dist/Ai-CORhNCSN.cjs +0 -1
  188. package/dist/BubbleMenus-QlttKSIN.cjs +0 -1
  189. package/dist/BubbleMenus-mwxYB3IU.js +0 -195
  190. package/dist/MarkdownPaste-C5jQ33SR.js +0 -1
  191. package/dist/bubble-CpeBzXMe.js +0 -78
  192. package/dist/editorConfig-D-Tlrdwj.js +0 -18
  193. package/dist/editorConfig-Du7YaEDm.cjs +0 -1
  194. package/dist/useButtonProps-BFfsKvCi.cjs +0 -1
  195. package/dist/useButtonProps-BZwO1Of-.js +0 -1
@@ -3,16 +3,29 @@ import { PluginKey, EditorState } from '@tiptap/pm/state';
3
3
  import { DecorationSet } from '@tiptap/pm/view';
4
4
  import { AiCommandDefinition, AiCompletionFn, AiLastRequest, AiPanelState } from './types';
5
5
  export * from './types';
6
- export { DEFAULT_AI_COMMANDS } from './commands';
6
+ export { DEFAULT_AI_COMMANDS, DEFAULT_AI_LANGUAGES, AI_COMMAND_GROUP_LABELS } from './commands';
7
+ export { AI_SYSTEM_PROMPT } from './lib/prompt';
7
8
  export interface AiOptions {
8
9
  /** Quick commands offered in the "Ask AI anything…" menu. */
9
10
  commands: AiCommandDefinition[];
10
11
  /**
11
12
  * Runs a completion for an instruction. Defaults to an offline demo
12
13
  * transform; host apps should supply a real implementation, the same way
13
- * `Image`/`Video` take an `upload` callback.
14
+ * `Image`/`Video` take an `upload` callback. See `createStreamingCompletion`
15
+ * for a ready-made fetch/stream implementation.
14
16
  */
15
17
  getCompletion: AiCompletionFn;
18
+ /**
19
+ * System message sent with every request. Constrains the model to return
20
+ * only the replacement text — override to add house style or domain rules.
21
+ */
22
+ systemPrompt: string;
23
+ /**
24
+ * How much surrounding document text (in characters) is sent as context.
25
+ * The window is taken from around the selection, so the nearest text is
26
+ * what survives the clamp. Set to `0` to send no context at all.
27
+ */
28
+ contextChars: number;
16
29
  /** Class applied to the (still-present) original text while a replacement is reviewed. */
17
30
  removedClass: string;
18
31
  /** Class applied to the streamed/suggested text widget. */
@@ -33,6 +46,8 @@ export declare const aiPluginKey: PluginKey<AiPluginState>;
33
46
  export declare function getAiState(state: EditorState): AiPluginState | undefined;
34
47
  /** Reads the live, resolved options (including any `commands` override) off the registered extension instance. */
35
48
  export declare function getAiOptions(editor: Editor): AiOptions | undefined;
49
+ /** Whether the Ai extension is registered on this editor, for hosts that render its controls conditionally. */
50
+ export declare function isAiEnabled(editor: Editor | null | undefined): boolean;
36
51
  declare module '@tiptap/core' {
37
52
  interface Commands<ReturnType> {
38
53
  ai: {
@@ -40,15 +55,17 @@ declare module '@tiptap/core' {
40
55
  openAiMenu: () => ReturnType;
41
56
  /** Close the menu and discard any pending suggestion without touching the document. */
42
57
  closeAiMenu: () => ReturnType;
43
- /** Run one of `options.commands` against the menu's range. */
44
- runAiCommand: (commandId: string) => ReturnType;
58
+ /** Run one of `options.commands` against the menu's range, optionally with a submenu choice. */
59
+ runAiCommand: (commandId: string, option?: string) => ReturnType;
45
60
  /** Run a free-form instruction typed into the menu's input. */
46
61
  submitAiPrompt: (instruction: string) => ReturnType;
62
+ /** Abort an in-flight completion and return to the command menu. */
63
+ stopAiGeneration: () => ReturnType;
47
64
  /** Replace the original range with the suggestion (or insert it, when there was no selection). */
48
65
  acceptAiSuggestion: () => ReturnType;
49
66
  /** Discard the suggestion, leaving the document untouched. */
50
67
  discardAiSuggestion: () => ReturnType;
51
- /** Keep the original text and insert the suggestion as a new paragraph below it. */
68
+ /** Keep the original text and insert the suggestion as a new block below it. */
52
69
  insertAiSuggestionBelow: () => ReturnType;
53
70
  /** Re-run the last instruction against its original range. */
54
71
  retryAiSuggestion: () => ReturnType;
@@ -1,2 +1,7 @@
1
- import { AiCommandDefinition } from './types';
1
+ import { AiCommandDefinition, AiCommandOption } from './types';
2
+ /** Target languages offered by the Translate command. */
3
+ export declare const DEFAULT_AI_LANGUAGES: AiCommandOption[];
2
4
  export declare const DEFAULT_AI_COMMANDS: AiCommandDefinition[];
5
+ /** Order the menu renders groups in, with the heading shown above each. */
6
+ export declare const AI_COMMAND_GROUP_LABELS: Record<string, string>;
7
+ export declare const AI_COMMAND_GROUP_ORDER: readonly ["edit", "tone", "transform", "generate"];
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Floating "Ask AI anything…" panel for the Ai extension. Reads the
3
3
  * extension's ProseMirror plugin state (menu / loading / reviewing / error)
4
- * and renders the matching UI: the quick-command list, a streaming spinner,
5
- * the accept/discard/insert-below/try-again review controls, or an error
6
- * with a retry action. Positioned with `@floating-ui/dom` and rendered
7
- * through a portal so it floats above the editor regardless of scroll
8
- * containers, the same approach `SlashCommand` uses for its own popup.
4
+ * and renders the matching UI: the filterable quick-command list, a streaming
5
+ * indicator with a Stop control, the accept/insert-below/try-again/discard
6
+ * review controls over a preview of the result, or an error with a retry
7
+ * action. Positioned with `@floating-ui/dom` and rendered through a portal so
8
+ * it floats above the editor regardless of scroll containers, the same
9
+ * approach `SlashCommand` uses for its own popup.
9
10
  *
10
11
  * Styled with hand-written `.ai-menu*` classes (see `src/styles/ProseMirror.scss`)
11
12
  * rather than Tailwind utilities: this component ships inside the published
@@ -0,0 +1,12 @@
1
+ import { Editor } from '@tiptap/core';
2
+ export interface RichTextAiProps {
3
+ /** Editor to act on. Falls back to the one from Tiptap context. */
4
+ editor?: Editor | null;
5
+ /** Label shown next to the icon. Pass `''` for an icon-only button. */
6
+ label?: string;
7
+ }
8
+ /**
9
+ * Renders nothing when the Ai extension is not registered on the editor, so
10
+ * hosts can drop it into a toolbar unconditionally.
11
+ */
12
+ export declare function RichTextAi({ editor: providedEditor, label }: RichTextAiProps): import("react").JSX.Element | null;
@@ -1,8 +1,14 @@
1
1
  /**
2
- * Entry point for the Ai extension that re-exports the extension and its
3
- * React components. Lets the app import the AI writing assistant from a
4
- * single, stable module path.
2
+ * Entry point for the Ai extension that re-exports the extension, its React
3
+ * components, and the helpers host apps need to wire a real model in. Lets
4
+ * the app import the AI writing assistant from a single, stable module path.
5
5
  */
6
6
  export * from './Ai';
7
7
  export * from './components/AiMenu';
8
+ export * from './components/RichTextAi';
8
9
  export { mockAiCompletion } from './lib/mockCompletion';
10
+ export { createStreamingCompletion } from './lib/createStreamingCompletion';
11
+ export type { StreamingCompletionOptions } from './lib/createStreamingCompletion';
12
+ export { buildAiInstruction, buildAiUserPrompt, clampContext, commandRequiresSelection, commandsForSelection, groupCommands, } from './lib/prompt';
13
+ export { sanitizeCompletion } from './lib/sanitizeCompletion';
14
+ export { completionToContent, completionToHtml, needsRichInsert } from './lib/completionToContent';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Turns a sanitised completion into content the editor can insert.
3
+ *
4
+ * Models answer in Markdown even when nobody asked: "Key takeaways" comes back
5
+ * as `- ` lines, "Draft an outline" as `## ` headings, emphasis as `**bold**`.
6
+ * Inserting that as plain text writes the punctuation into the document and
7
+ * loses the structure, so the same `marked` conversion the MarkdownPaste
8
+ * extension uses on pasted text is applied here before accepting.
9
+ *
10
+ * Text with no Markdown structure and no paragraph breaks is left as plain
11
+ * text, so a simple rewrite keeps the marks (bold, links, highlights) that
12
+ * were already on the replaced range.
13
+ */
14
+ /** Whether the completion carries formatting that should become real nodes. */
15
+ export declare function hasMarkdownStructure(text: string): boolean;
16
+ /**
17
+ * Whether the completion should be inserted as HTML rather than plain text:
18
+ * either it carries Markdown structure, or it spans more than one paragraph
19
+ * (which as plain text would collapse into one block with literal newlines).
20
+ */
21
+ export declare function needsRichInsert(text: string): boolean;
22
+ /**
23
+ * Renders a completion to HTML for `insertContentAt`. `<thead>`/`<tbody>` are
24
+ * dropped for the same reason MarkdownPaste drops them: the editor's table
25
+ * schema has no node for them, so ProseMirror would discard the rows inside.
26
+ */
27
+ export declare function completionToHtml(text: string): string;
28
+ /**
29
+ * The content to hand `insertContentAt`, plus whether it is HTML. Plain-text
30
+ * results are returned untouched so simple rewrites keep the existing marks.
31
+ */
32
+ export declare function completionToContent(text: string): {
33
+ content: string;
34
+ isHtml: boolean;
35
+ };
@@ -0,0 +1,27 @@
1
+ import { AiCompletionFn, AiCompletionRequest } from '../types';
2
+ export interface StreamingCompletionOptions {
3
+ /** URL the completion is POSTed to. Defaults to `/api/ai`. */
4
+ endpoint?: string;
5
+ /** Extra request headers (auth, workspace id, …). */
6
+ headers?: HeadersInit | (() => HeadersInit);
7
+ /**
8
+ * Builds the JSON body. Defaults to sending the whole
9
+ * {@link AiCompletionRequest} — instruction, selection, context window,
10
+ * command id and the system prompt — so the route can prompt as it likes.
11
+ */
12
+ body?: (request: AiCompletionRequest) => unknown;
13
+ /**
14
+ * Response format. `auto` (the default) detects Server-Sent Events from the
15
+ * `Content-Type` header or a leading `data:` line and otherwise treats the
16
+ * body as a plain text stream.
17
+ */
18
+ format?: 'auto' | 'text' | 'sse';
19
+ /**
20
+ * Pulls the text out of one parsed payload — an SSE event, or the whole body
21
+ * for a non-streaming JSON response. Defaults to the OpenAI-compatible
22
+ * shapes (`choices[0].delta.content`, `choices[0].text`, `delta`, `text`,
23
+ * `content`, `rewrittenText`, or a bare string).
24
+ */
25
+ parseEvent?: (payload: unknown) => string;
26
+ }
27
+ export declare function createStreamingCompletion(options?: StreamingCompletionOptions): AiCompletionFn;
@@ -0,0 +1,38 @@
1
+ import { AiCommandDefinition, AiCommandGroup, AiSuggestionMode } from '../types';
2
+ /**
3
+ * System message sent with every request. It exists because a chat-tuned model
4
+ * left to itself answers *about* the edit ("Sure! Here's a tighter version:")
5
+ * — and in an editor that preamble is what lands in the document.
6
+ */
7
+ export declare const AI_SYSTEM_PROMPT: string;
8
+ /** Whether a command needs a non-empty selection (the default for everything that rewrites text). */
9
+ export declare function commandRequiresSelection(command: AiCommandDefinition): boolean;
10
+ /**
11
+ * Commands offered for the current selection state: with the caret collapsed,
12
+ * the rewrite commands are hidden rather than left to misfire on no input.
13
+ */
14
+ export declare function commandsForSelection(commands: AiCommandDefinition[], hasSelection: boolean): AiCommandDefinition[];
15
+ /** Groups commands for rendering, in `AI_COMMAND_GROUP_ORDER`, dropping empty groups. */
16
+ export declare function groupCommands(commands: AiCommandDefinition[]): {
17
+ group: AiCommandGroup;
18
+ commands: AiCommandDefinition[];
19
+ }[];
20
+ /** Joins a command's prompt with the submenu choice it was run with, if any. */
21
+ export declare function buildAiInstruction(command: AiCommandDefinition, option?: string): string;
22
+ /**
23
+ * Trims a context window to `max` characters, cutting from the start so the
24
+ * text nearest the selection — the part that actually informs the completion —
25
+ * is what survives.
26
+ */
27
+ export declare function clampContext(text: string, max: number): string;
28
+ /**
29
+ * Renders the request as a single user message, for completion functions that
30
+ * only take one string (a plain `/api/ai` route, an OpenAI-compatible
31
+ * endpoint). Sent alongside {@link AI_SYSTEM_PROMPT}.
32
+ */
33
+ export declare function buildAiUserPrompt(request: {
34
+ instruction: string;
35
+ selectedText: string;
36
+ documentText: string;
37
+ mode: AiSuggestionMode;
38
+ }): string;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Cleans a model response into text that is safe to paste into the document.
3
+ *
4
+ * The system prompt asks for a bare replacement, but chat-tuned models still
5
+ * lead with "Sure — here's a tighter version:", wrap prose in ```code fences,
6
+ * or quote the whole answer. Accepting a suggestion writes it into the user's
7
+ * document verbatim, so the response is normalised on the way in — while it
8
+ * streams as well as at the end, so the review diff shows what accepting will
9
+ * actually produce.
10
+ *
11
+ * Every step is conservative: it only strips a wrapper when the whole response
12
+ * is wrapped, so a genuinely fenced or quoted answer keeps its markers.
13
+ */
14
+ /**
15
+ * Removes a fence that wraps the *entire* response. While streaming, the
16
+ * closing fence has not arrived yet, so an opening fence alone is dropped too.
17
+ */
18
+ export declare function stripCodeFences(text: string): string;
19
+ /** Removes a leading "Sure, here's the rewrite:" style lead-in. */
20
+ export declare function stripPreamble(text: string): string;
21
+ /** Removes quotation marks that wrap the whole response and nothing else. */
22
+ export declare function stripWrappingQuotes(text: string): string;
23
+ /** Collapses the runs of blank lines models like to emit, and trims trailing space. */
24
+ export declare function normalizeWhitespace(text: string): string;
25
+ export interface SanitizeOptions {
26
+ /**
27
+ * True while chunks are still arriving. Trailing whitespace is meaningful
28
+ * mid-stream (the next chunk continues the word), so it is preserved; the
29
+ * final pass trims it.
30
+ */
31
+ streaming?: boolean;
32
+ }
33
+ /**
34
+ * Runs the full clean-up. Idempotent, so it can be applied to every streamed
35
+ * chunk and again to the final text without compounding.
36
+ */
37
+ export declare function sanitizeCompletion(text: string, { streaming }?: SanitizeOptions): string;
@@ -1,4 +1,13 @@
1
1
  import { ComponentType } from 'react';
2
+ /** Section a command is listed under in the menu. Purely presentational grouping. */
3
+ export type AiCommandGroup = 'edit' | 'tone' | 'transform' | 'generate';
4
+ /** One choice offered by a command that needs an argument (e.g. a target language). */
5
+ export interface AiCommandOption {
6
+ /** Stable identifier, also used as the React key. */
7
+ id: string;
8
+ /** Label shown in the submenu. */
9
+ label: string;
10
+ }
2
11
  /** A single quick-action offered in the "Ask AI anything…" command list. */
3
12
  export interface AiCommandDefinition {
4
13
  /** Stable identifier, also used as the React key. */
@@ -11,6 +20,20 @@ export interface AiCommandDefinition {
11
20
  icon: ComponentType<{
12
21
  className?: string;
13
22
  }>;
23
+ /** Section the command is listed under. Defaults to `edit`. */
24
+ group?: AiCommandGroup;
25
+ /**
26
+ * Whether the command only makes sense with text selected. Commands that
27
+ * rewrite the selection are hidden (rather than silently misfiring on an
28
+ * empty selection) when the caret is collapsed. Defaults to `true`.
29
+ */
30
+ requiresSelection?: boolean;
31
+ /**
32
+ * Choices the command needs before it can run — rendered as a submenu.
33
+ * The picked option's `label` is appended to `prompt` and passed to the
34
+ * completion function as `request.option`.
35
+ */
36
+ options?: AiCommandOption[];
14
37
  /**
15
38
  * Instruction sent to the completion function as `request.instruction`.
16
39
  * The selection (or, when nothing is selected, an empty string) is passed
@@ -25,8 +48,26 @@ export interface AiCompletionRequest {
25
48
  instruction: string;
26
49
  /** The selected text the instruction should act on. Empty when generating fresh content. */
27
50
  selectedText: string;
28
- /** Plain-text of the whole document, for context. */
51
+ /**
52
+ * Plain text around the selection, for context. Clamped to a bounded window
53
+ * (see `AiOptions.contextChars`) so a long document does not blow up the
54
+ * request — never assume it is the whole document.
55
+ */
29
56
  documentText: string;
57
+ /** `id` of the quick command that ran, or `'custom'` for a free-form prompt. */
58
+ commandId: string;
59
+ /** Human label of the command that ran, for logging/telemetry. */
60
+ commandLabel: string;
61
+ /** The submenu choice the command was run with (e.g. `'Spanish'`), when it has options. */
62
+ option?: string;
63
+ /**
64
+ * A ready-to-use system message that constrains the model to return only the
65
+ * replacement text — no preamble, no Markdown fences. Pass it straight
66
+ * through to the provider; the editor sanitises the response either way.
67
+ */
68
+ systemPrompt: string;
69
+ /** `replace` when the result will swap the selection, `insert` when it will be added at the caret. */
70
+ mode: AiSuggestionMode;
30
71
  }
31
72
  /**
32
73
  * Runs an AI completion. Called with an `onChunk` callback so implementations
@@ -36,21 +77,24 @@ export interface AiCompletionRequest {
36
77
  * take an `upload` callback.
37
78
  */
38
79
  export type AiCompletionFn = (request: AiCompletionRequest, onChunk: (accumulatedText: string) => void, signal: AbortSignal) => Promise<string>;
80
+ /** `replace` swaps `[from, to]` on accept; `insert` adds the text at the caret. */
81
+ export type AiSuggestionMode = 'replace' | 'insert';
39
82
  /** A suggestion currently being reviewed: either a replacement for a selection or a fresh insertion at the cursor. */
40
83
  export interface AiSuggestion {
41
84
  from: number;
42
85
  to: number;
43
86
  originalText: string;
44
87
  suggestedText: string;
45
- /** `replace` swaps `[from, to]` on accept; `insert` adds a new block below on accept. */
46
- mode: 'replace' | 'insert';
88
+ mode: AiSuggestionMode;
47
89
  /** True while text is still streaming in; accept/insert-below are disabled until it settles. */
48
90
  isStreaming: boolean;
49
91
  }
50
92
  /** The last request that ran, kept around so "Try again" can be re-issued without retyping. */
51
93
  export interface AiLastRequest {
52
94
  instruction: string;
95
+ commandId: string;
53
96
  commandLabel: string;
97
+ option?: string;
54
98
  from: number;
55
99
  to: number;
56
100
  }
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./editorConfig-Du7YaEDm.cjs"),o=require("./ReasonDocs-BliNN1Tt.cjs"),r=require("./RichTextProvider-Dl77gVJI.cjs"),t=require("./externalLibsMode-Dm8a-Jd9.cjs");exports.NovelEditor=e.NovelEditor,exports.ReasonDocs=o.Index,exports.RichTextProvider=r.RichTextProvider,exports.externalLibsModeActions=t.externalLibsModeActions,exports.getExternalLibsMode=t.getExternalLibsMode,exports.useExternalLibsMode=t.useExternalLibsMode,exports.useNovelEditor=e.useNovelEditor;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./editorConfig-CHBSp2KG.cjs"),o=require("./ReasonDocs-Bjefr26w.cjs"),r=require("./RichTextProvider-BuTrDlZY.cjs"),t=require("./externalLibsMode-Dm8a-Jd9.cjs");exports.NovelEditor=e.NovelEditor,exports.ReasonDocs=o.Index,exports.RichTextProvider=r.RichTextProvider,exports.externalLibsModeActions=t.externalLibsModeActions,exports.getExternalLibsMode=t.getExternalLibsMode,exports.useExternalLibsMode=t.useExternalLibsMode,exports.useNovelEditor=e.useNovelEditor;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as o,i as s}from"./editorConfig-D-Tlrdwj.js";import{t as r}from"./ReasonDocs-4vxZ3zY7.js";import{t as a}from"./RichTextProvider-E6rbc_J2.js";import{n as t,r as i,t as e}from"./externalLibsMode-DEDBnK98.js";export{s as NovelEditor,r as ReasonDocs,a as RichTextProvider,e as externalLibsModeActions,t as getExternalLibsMode,i as useExternalLibsMode,o as useNovelEditor};
1
+ import{a as o,i as s}from"./editorConfig-BR7z-P0e.js";import{t as r}from"./ReasonDocs-_hTAa8-q.js";import{t as a}from"./RichTextProvider-D9EtjDKS.js";import{n as t,r as i,t as e}from"./externalLibsMode-DEDBnK98.js";export{s as NovelEditor,r as ReasonDocs,a as RichTextProvider,e as externalLibsModeActions,t as getExternalLibsMode,i as useExternalLibsMode,o as useNovelEditor};
@@ -0,0 +1 @@
1
+ function e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var t={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function n(e){t=e}var r={exec:()=>null};function s(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),s=t[r];return s||(s=e(r),t[r]=s),s}}function l(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(a.caret,"$1"),n=n.replace(e,s),r},getRegex:()=>new RegExp(n,t)};return r}var i=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),a={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:s(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`)),hrRegex:s(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:s(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:s(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:s(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:s(e=>new RegExp(`^ {0,${e}}>`))},o=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,c=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,h=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,p=l(h).replace(/bull/g,c).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),u=l(h).replace(/bull/g,c).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),g=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,k=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,d=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",k).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),f=l(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,c).getRegex(),x="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",b=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,w=l("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",b).replace("tag",x).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),m=e=>l(g).replace("hr",o).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),y=m(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),$=m(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),R={blockquote:l(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",$).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:d,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:o,html:w,lheading:p,list:f,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:y,table:r,text:/^[^\n]+/},S=l("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",o).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),T={...R,lheading:u,table:S,paragraph:l(g).replace("hr",o).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",S).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex()},z={...R,html:l("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",b).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:r,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:l(g).replace("hr",o).replace("heading"," *#{1,6} *[^\n]").replace("lheading",p).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},A=/^( {2,}|\\)\n(?!\s*$)/,_=/[\p{P}\p{S}]/u,P=/[\s\p{P}\p{S}]/u,L=/[^\s\p{P}\p{S}]/u,I=l(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,P).getRegex(),E=/(?!~)[\p{P}\p{S}]/u,C=l(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",i?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),B=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,q=l(B,"u").replace(/punct/g,_).getRegex(),v=l(B,"u").replace(/punct/g,E).getRegex(),Z="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",D=l(Z,"gu").replace(/notPunctSpace/g,L).replace(/punctSpace/g,P).replace(/punct/g,_).getRegex(),Q=l(Z,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,E).getRegex(),M=l("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,L).replace(/punctSpace/g,P).replace(/punct/g,_).getRegex(),j=l(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,_).getRegex(),O=l("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,L).replace(/punctSpace/g,P).replace(/punct/g,_).getRegex(),H=l(/\\(punct)/,"gu").replace(/punct/g,_).getRegex(),N=l(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),G=l(b).replace("(?:--\x3e|$)","--\x3e").getRegex(),X=l("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",G).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),W=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,F=l(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",W).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),U=l(/^!?\[(label)\]\[(ref)\]/).replace("label",W).replace("ref",k).getRegex(),J=l(/^!?\[(ref)\](?:\[\])?/).replace("ref",k).getRegex(),K=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,V={_backpedal:r,anyPunctuation:H,autolink:N,blockSkip:C,br:A,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:r,delLDelim:r,delRDelim:r,emStrongLDelim:q,emStrongRDelimAst:D,emStrongRDelimUnd:M,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:F,nolink:J,punctuation:I,reflink:U,reflinkSearch:l("reflink|nolink(?!\\()","g").replace("reflink",U).replace("nolink",J).getRegex(),tag:X,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:r},Y={...V,link:l(/^!?\[(label)\]\((.*?)\)/).replace("label",W).getRegex(),reflink:l(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",W).getRegex()},ee={...V,emStrongRDelimAst:Q,emStrongLDelim:v,delLDelim:j,delRDelim:O,url:l(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",K).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:l(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",K).getRegex()},te={...ee,br:l(A).replace("{2,}","*").getRegex(),text:l(ee.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ne={normal:R,gfm:T,pedantic:z},re={normal:V,gfm:ee,breaks:te,pedantic:Y},se={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},le=e=>se[e];function ie(e,t){if(t){if(a.escapeTest.test(e))return e.replace(a.escapeReplace,le)}else if(a.escapeTestNoEncode.test(e))return e.replace(a.escapeReplaceNoEncode,le);return e}function ae(e){try{e=encodeURI(e).replace(a.percentDecode,"%")}catch{return null}return e}function oe(e,t){let n=e.replace(a.findPipe,(e,t,n)=>{let r=!1,s=t;for(;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"}).split(a.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(a.slashPipe,"|");return n}function ce(e,t,n){let r=e.length;if(0===r)return"";let s=0;for(;s<r;){let l=e.charAt(r-s-1);if(l!==t||n){if(l===t||!n)break;s++}else s++}return e.slice(0,r-s)}function he(e){let t=e.split("\n"),n=t.length-1;for(;n>=0&&a.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join("\n")}function pe(e,t=0){let n=t,r="";for(let s of e)if("\t"===s){let e=4-n%4;r+=" ".repeat(e),n+=e}else r+=s,n++;return r}function ue(e,t,n,r,s){let l=t.href,i=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let o={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:l,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,o}var ge=class{options;rules;lexer;constructor(e){this.options=e||t}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:he(t[0]);return{type:"code",raw:e,codeBlockStyle:"indented",text:e.replace(this.rules.other.codeRemoveIndent,"")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let s=r[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=ce(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:ce(t[0],"\n"),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ce(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=ce(t[0],"\n").split("\n"),n="",r="",s=[];for(;e.length>0;){let t,l=!1,i=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))i.push(e[t]),l=!0;else{if(l)break;i.push(e[t])}e=e.slice(t);let a=i.join("\n"),o=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,r=r?`${r}\n${o}`:o;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(o,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,l=t.raw+"\n"+e.join("\n"),i=this.blockquote(l);s[s.length-1]=i,n=n.substring(0,n.length-t.raw.length)+i.raw,r=r.substring(0,r.length-t.text.length)+i.text;break}if("list"===h?.type){let t=h,l=t.raw+"\n"+e.join("\n"),i=this.list(l);s[s.length-1]=i,n=n.substring(0,n.length-h.raw.length)+i.raw,r=r.substring(0,r.length-t.raw.length)+i.raw,e=l.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let l=this.rules.other.listItemRegex(n),i=!1;for(;e;){let n=!1,r="",a="";if(!(t=l.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let o=pe(t[2].split("\n",1)[0],t[1].length),c=e.split("\n",1)[0],h=!o.trim(),p=0;if(this.options.pedantic?(p=2,a=o.trimStart()):h?p=t[1].length+1:(p=o.search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=o.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),s=this.rules.other.fencesBeginRegex(p),l=this.rules.other.headingBeginRegex(p),i=this.rules.other.htmlBeginRegex(p),u=this.rules.other.blockquoteBeginRegex(p);for(;e;){let g,k=e.split("\n",1)[0];if(c=k,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),g=c):g=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||l.test(c)||i.test(c)||u.test(c)||t.test(c)||n.test(c))break;if(g.search(this.rules.other.nonSpaceChar)>=p||!c.trim())a+="\n"+g.slice(p);else{if(h||o.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(o)||l.test(o)||n.test(o))break;a+="\n"+c}h=!c.trim(),r+=k+"\n",e=e.substring(k.length+1),o=g.slice(p)}}s.loose||(i?s.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(i=!0)),s.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=r}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(!e.task||"text"!==t?.type&&"paragraph"!==t?.type)e.task&&(e.task=!1);else{e.text=e.text.replace(this.rules.other.listReplaceTask,""),t.raw=t.raw.replace(this.rules.other.listReplaceTask,""),t.text=t.text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type);s.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=he(t[0]);return{type:"html",block:!0,raw:e,pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:ce(t[0],"\n"),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=oe(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],l={type:"table",raw:ce(t[0],"\n"),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?l.align.push("right"):this.rules.other.tableAlignCenter.test(e)?l.align.push("center"):this.rules.other.tableAlignLeft.test(e)?l.align.push("left"):l.align.push(null);for(let e=0;e<n.length;e++)l.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:l.align[e]});for(let e of s)l.rows.push(oe(e,l.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:l.align[t]})));return l}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:"heading",raw:ce(t[0],"\n"),depth:"="===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=ce(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ue(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ue(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&(r[1]||r[2]||r[3]||r[4])&&(!r[4]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[3]||!n||this.rules.inline.punctuation.exec(n))){let n,s,l=[...r[0]].length-1,i=l,a=0,o="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(o.lastIndex=0,t=t.slice(-1*e.length+l);null!==(r=o.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(s=[...n].length,r[3]||r[4]){i+=s;continue}if((r[5]||r[6])&&l%3&&!((l+s)%3)){a+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i+a);let t=[...r[0]][0].length,o=e.slice(0,l+r.index+t+s);if(Math.min(l,s)%2){let e=o.slice(1,-1);return{type:"em",raw:o,text:e,tokens:this.lexer.inlineTokens(e)}}let c=o.slice(2,-2);return{type:"strong",raw:o,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n,s,l=[...r[0]].length-1,i=l,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+l);null!==(r=a.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n||(s=[...n].length,s!==l))continue;if(r[3]||r[4]){i+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i);let t=[...r[0]][0].length,a=e.slice(0,l+r.index+t+s),o=a.slice(l,-l);return{type:"del",raw:a,text:o,tokens:this.lexer.inlineTokens(o)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},ke=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||t,this.options.tokenizer=this.options.tokenizer||new ge,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:a,block:ne.normal,inline:re.normal};this.options.pedantic?(n.block=ne.pedantic,n.inline=re.pedantic):this.options.gfm&&(n.block=ne.gfm,this.options.breaks?n.inline=re.breaks:n.inline=re.gfm),this.tokenizer.rules=n}static get rules(){return{block:ne,inline:re}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(a.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(a.tabCharGlobal," ").replace(a.spaceLine,""));let r=1/0;for(;e;){if(!(e.length<r)){this.infiniteLoopError(e.charCodeAt(0));break}let s;if(r=e.length,this.options.extensions?.block?.some(n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let n=t.at(-1);1===s.raw.length&&void 0!==n?n.raw+="\n":t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},t.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let l=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(l=e.substring(0,n+1))}if(this.state.top&&(s=this.tokenizer.paragraph(l))){let r=t.at(-1);n&&"paragraph"===r?.type?(r.raw+=(r.raw.endsWith("\n")?"":"\n")+s.raw,r.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),n=l.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(n=n.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf("[")+1,-1))?"["+"a".repeat(t.length-2)+"]":t))}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+"["+"a".repeat(e.length-r-2)+"]"}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,s="",l=1/0;for(;e;){if(!(e.length<l)){this.infiniteLoopError(e.charCodeAt(0));break}let i;if(l=e.length,r||(s=""),r=!1,this.options.extensions?.inline?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===i.type&&"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,n,s)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e,n,s)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(a=e.substring(0,n+1))}if(i=this.tokenizer.inlineText(a)){e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(s=i.raw.slice(-1)),r=!0;let n=t.at(-1);"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(!this.options.silent)throw new Error(t)}},de=class{options;parser;constructor(e){this.options=e||t}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(a.notSpaceStart)?.[0],s=e.replace(a.endingNewline,"")+"\n";return r?'<pre><code class="language-'+ie(r)+'">'+(n?s:ie(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:ie(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let t=e.items[l];r+=this.listitem(t)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let r="";for(let s=0;s<e.rows.length;s++){let t=e.rows[s];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ie(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),s=ae(e);if(null===s)return r;let l='<a href="'+(e=s)+'"';return t&&(l+=' title="'+ie(t)+'"'),l+=">"+r+"</a>",l}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=ae(e);if(null===s)return ie(n);let l=`<img src="${e=s}" alt="${ie(n)}"`;return t&&(l+=` title="${ie(t)}"`),l+=">",l}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ie(e.text)}},fe=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},xe=class e{options;renderer;textRenderer;constructor(e){this.options=e||t,this.options.renderer=this.options.renderer||new de,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new fe}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=r;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let l=s;switch(l.type){case"escape":case"text":n+=t.text(l);break;case"html":n+=t.html(l);break;case"link":n+=t.link(l);break;case"image":n+=t.image(l);break;case"checkbox":n+=t.checkbox(l);break;case"strong":n+=t.strong(l);break;case"em":n+=t.em(l);break;case"codespan":n+=t.codespan(l);break;case"br":n+=t.br(l);break;case"del":n+=t.del(l);break;default:{let e='Token with "'+l.type+'" type was not found.';if(this.options.silent)return"";throw new Error(e)}}}return n}},be=class{options;block;constructor(e){this.options=e||t}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ke.lex:ke.lexInline}provideParser(e=this.block){return e?xe.parse:xe.parseInline}},we=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=xe;Renderer=de;TextRenderer=fe;Lexer=ke;Tokenizer=ge;Hooks=be;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let s=e[r].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new de(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,s=e.renderer[r],l=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ge(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,s=e.tokenizer[r],l=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new be;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,s=e.hooks[r],l=t[r];be.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&be.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return l.call(t,n)})();let r=s.call(t,e);return l.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await l.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ke.lex(e,t??this.defaults)}parser(e,t){return xe.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},s={...this.defaults,...r},l=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===r.async)return l(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return l(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return l(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer(e):e?ke.lex:ke.lexInline)(n,s),l=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let i=await(s.hooks?await s.hooks.provideParser(e):e?xe.parse:xe.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(i):i})().catch(l);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer(e):e?ke.lex:ke.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let r=(s.hooks?s.hooks.provideParser(e):e?xe.parse:xe.parseInline)(n,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(i){return l(i)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+ie(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function me(e,t){return we.parse(e,t)}me.options=me.setOptions=function(e){return we.setOptions(e),me.defaults=we.defaults,n(me.defaults),me},me.getDefaults=e,me.defaults=t,me.use=function(...e){return we.use(...e),me.defaults=we.defaults,n(me.defaults),me},me.walkTokens=function(e,t){return we.walkTokens(e,t)},me.parseInline=we.parseInline,me.Parser=xe,me.parser=xe.parse,me.Renderer=de,me.TextRenderer=fe,me.Lexer=ke,me.lexer=ke.lex,me.Tokenizer=ge,me.Hooks=be,me.parse=me;me.options,me.setOptions,me.use,me.walkTokens,me.parseInline,xe.parse,ke.lex;Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return me}});
@@ -0,0 +1 @@
1
+ function e(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var t={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function n(e){t=e}var r={exec:()=>null};function s(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),s=t[r];return s||(s=e(r),t[r]=s),s}}function l(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(a.caret,"$1"),n=n.replace(e,s),r},getRegex:()=>new RegExp(n,t)};return r}var i=((e="")=>{try{return!!new RegExp("(?<=1)(?<!1)"+e)}catch{return!1}})(),a={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:s(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`)),hrRegex:s(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:s(e=>new RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:s(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:s(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,"i")),blockquoteBeginRegex:s(e=>new RegExp(`^ {0,${e}}>`))},o=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,c=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,h=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,p=l(h).replace(/bull/g,c).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),u=l(h).replace(/bull/g,c).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),g=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,k=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,d=l(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",k).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),f=l(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,c).getRegex(),x="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",b=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,w=l("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",b).replace("tag",x).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),m=e=>l(g).replace("hr",o).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list",e).replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),y=m(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),$=m(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),R={blockquote:l(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",$).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:d,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:o,html:w,lheading:p,list:f,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:y,table:r,text:/^[^\n]+/},S=l("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",o).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex(),T={...R,lheading:u,table:S,paragraph:l(g).replace("hr",o).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",S).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",x).getRegex()},z={...R,html:l("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",b).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:r,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:l(g).replace("hr",o).replace("heading"," *#{1,6} *[^\n]").replace("lheading",p).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},A=/^( {2,}|\\)\n(?!\s*$)/,_=/[\p{P}\p{S}]/u,P=/[\s\p{P}\p{S}]/u,L=/[^\s\p{P}\p{S}]/u,I=l(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,P).getRegex(),E=/(?!~)[\p{P}\p{S}]/u,C=l(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",i?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),B=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,q=l(B,"u").replace(/punct/g,_).getRegex(),v=l(B,"u").replace(/punct/g,E).getRegex(),Z="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",D=l(Z,"gu").replace(/notPunctSpace/g,L).replace(/punctSpace/g,P).replace(/punct/g,_).getRegex(),Q=l(Z,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,E).getRegex(),M=l("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,L).replace(/punctSpace/g,P).replace(/punct/g,_).getRegex(),j=l(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,_).getRegex(),H=l("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,L).replace(/punctSpace/g,P).replace(/punct/g,_).getRegex(),N=l(/\\(punct)/,"gu").replace(/punct/g,_).getRegex(),O=l(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),G=l(b).replace("(?:--\x3e|$)","--\x3e").getRegex(),X=l("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",G).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),W=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,F=l(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",W).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),U=l(/^!?\[(label)\]\[(ref)\]/).replace("label",W).replace("ref",k).getRegex(),J=l(/^!?\[(ref)\](?:\[\])?/).replace("ref",k).getRegex(),K=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,V={_backpedal:r,anyPunctuation:N,autolink:O,blockSkip:C,br:A,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:r,delLDelim:r,delRDelim:r,emStrongLDelim:q,emStrongRDelimAst:D,emStrongRDelimUnd:M,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:F,nolink:J,punctuation:I,reflink:U,reflinkSearch:l("reflink|nolink(?!\\()","g").replace("reflink",U).replace("nolink",J).getRegex(),tag:X,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:r},Y={...V,link:l(/^!?\[(label)\]\((.*?)\)/).replace("label",W).getRegex(),reflink:l(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",W).getRegex()},ee={...V,emStrongRDelimAst:Q,emStrongLDelim:v,delLDelim:j,delRDelim:H,url:l(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",K).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:l(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",K).getRegex()},te={...ee,br:l(A).replace("{2,}","*").getRegex(),text:l(ee.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},ne={normal:R,gfm:T,pedantic:z},re={normal:V,gfm:ee,breaks:te,pedantic:Y},se={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},le=e=>se[e];function ie(e,t){if(t){if(a.escapeTest.test(e))return e.replace(a.escapeReplace,le)}else if(a.escapeTestNoEncode.test(e))return e.replace(a.escapeReplaceNoEncode,le);return e}function ae(e){try{e=encodeURI(e).replace(a.percentDecode,"%")}catch{return null}return e}function oe(e,t){let n=e.replace(a.findPipe,(e,t,n)=>{let r=!1,s=t;for(;--s>=0&&"\\"===n[s];)r=!r;return r?"|":" |"}).split(a.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(a.slashPipe,"|");return n}function ce(e,t,n){let r=e.length;if(0===r)return"";let s=0;for(;s<r;){let l=e.charAt(r-s-1);if(l!==t||n){if(l===t||!n)break;s++}else s++}return e.slice(0,r-s)}function he(e){let t=e.split("\n"),n=t.length-1;for(;n>=0&&a.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join("\n")}function pe(e,t=0){let n=t,r="";for(let s of e)if("\t"===s){let e=4-n%4;r+=" ".repeat(e),n+=e}else r+=s,n++;return r}function ue(e,t,n,r,s){let l=t.href,i=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");r.state.inLink=!0;let o={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:l,title:i,text:a,tokens:r.inlineTokens(a)};return r.state.inLink=!1,o}var ge=class{options;rules;lexer;constructor(e){this.options=e||t}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:he(t[0]);return{type:"code",raw:e,codeBlockStyle:"indented",text:e.replace(this.rules.other.codeRemoveIndent,"")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let s=r[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=ce(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:ce(t[0],"\n"),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ce(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=ce(t[0],"\n").split("\n"),n="",r="",s=[];for(;e.length>0;){let t,l=!1,i=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))i.push(e[t]),l=!0;else{if(l)break;i.push(e[t])}e=e.slice(t);let a=i.join("\n"),o=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,r=r?`${r}\n${o}`:o;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(o,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,l=t.raw+"\n"+e.join("\n"),i=this.blockquote(l);s[s.length-1]=i,n=n.substring(0,n.length-t.raw.length)+i.raw,r=r.substring(0,r.length-t.text.length)+i.text;break}if("list"===h?.type){let t=h,l=t.raw+"\n"+e.join("\n"),i=this.list(l);s[s.length-1]=i,n=n.substring(0,n.length-h.raw.length)+i.raw,r=r.substring(0,r.length-t.raw.length)+i.raw,e=l.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,s={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let l=this.rules.other.listItemRegex(n),i=!1;for(;e;){let n=!1,r="",a="";if(!(t=l.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let o=pe(t[2].split("\n",1)[0],t[1].length),c=e.split("\n",1)[0],h=!o.trim(),p=0;if(this.options.pedantic?(p=2,a=o.trimStart()):h?p=t[1].length+1:(p=o.search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=o.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),s=this.rules.other.fencesBeginRegex(p),l=this.rules.other.headingBeginRegex(p),i=this.rules.other.htmlBeginRegex(p),u=this.rules.other.blockquoteBeginRegex(p);for(;e;){let g,k=e.split("\n",1)[0];if(c=k,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),g=c):g=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||l.test(c)||i.test(c)||u.test(c)||t.test(c)||n.test(c))break;if(g.search(this.rules.other.nonSpaceChar)>=p||!c.trim())a+="\n"+g.slice(p);else{if(h||o.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(o)||l.test(o)||n.test(o))break;a+="\n"+c}h=!c.trim(),r+=k+"\n",e=e.substring(k.length+1),o=g.slice(p)}}s.loose||(i?s.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(i=!0)),s.items.push({type:"list_item",raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=r}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(!e.task||"text"!==t?.type&&"paragraph"!==t?.type)e.task&&(e.task=!1);else{e.text=e.text.replace(this.rules.other.listReplaceTask,""),t.raw=t.raw.replace(this.rules.other.listReplaceTask,""),t.text=t.text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:"checkbox",raw:n[0]+" ",checked:"[ ]"!==n[0]};e.checked=t.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:"paragraph",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type);s.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=he(t[0]);return{type:"html",block:!0,raw:e,pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:ce(t[0],"\n"),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=oe(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],l={type:"table",raw:ce(t[0],"\n"),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?l.align.push("right"):this.rules.other.tableAlignCenter.test(e)?l.align.push("center"):this.rules.other.tableAlignLeft.test(e)?l.align.push("left"):l.align.push(null);for(let e=0;e<n.length;e++)l.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:l.align[e]});for(let e of s)l.rows.push(oe(e,l.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:l.align[t]})));return l}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:"heading",raw:ce(t[0],"\n"),depth:"="===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=ce(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r<e.length;r++)if("\\"===e[r])r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ue(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ue(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&(r[1]||r[2]||r[3]||r[4])&&(!r[4]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[3]||!n||this.rules.inline.punctuation.exec(n))){let n,s,l=[...r[0]].length-1,i=l,a=0,o="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(o.lastIndex=0,t=t.slice(-1*e.length+l);null!==(r=o.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(s=[...n].length,r[3]||r[4]){i+=s;continue}if((r[5]||r[6])&&l%3&&!((l+s)%3)){a+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i+a);let t=[...r[0]][0].length,o=e.slice(0,l+r.index+t+s);if(Math.min(l,s)%2){let e=o.slice(1,-1);return{type:"em",raw:o,text:e,tokens:this.lexer.inlineTokens(e)}}let c=o.slice(2,-2);return{type:"strong",raw:o,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n,s,l=[...r[0]].length-1,i=l,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+l);null!==(r=a.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n||(s=[...n].length,s!==l))continue;if(r[3]||r[4]){i+=s;continue}if(i-=s,i>0)continue;s=Math.min(s,s+i);let t=[...r[0]][0].length,a=e.slice(0,l+r.index+t+s),o=a.slice(l,-l);return{type:"del",raw:a,text:o,tokens:this.lexer.inlineTokens(o)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},ke=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||t,this.options.tokenizer=this.options.tokenizer||new ge,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:a,block:ne.normal,inline:re.normal};this.options.pedantic?(n.block=ne.pedantic,n.inline=re.pedantic):this.options.gfm&&(n.block=ne.gfm,this.options.breaks?n.inline=re.breaks:n.inline=re.gfm),this.tokenizer.rules=n}static get rules(){return{block:ne,inline:re}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(a.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(a.tabCharGlobal," ").replace(a.spaceLine,""));let r=1/0;for(;e;){if(!(e.length<r)){this.infiniteLoopError(e.charCodeAt(0));break}let s;if(r=e.length,this.options.extensions?.block?.some(n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let n=t.at(-1);1===s.raw.length&&void 0!==n?n.raw+="\n":t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},t.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let l=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(l=e.substring(0,n+1))}if(this.state.top&&(s=this.tokenizer.paragraph(l))){let r=t.at(-1);n&&"paragraph"===r?.type?(r.raw+=(r.raw.endsWith("\n")?"":"\n")+s.raw,r.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),n=l.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+s.raw,n.text+="\n"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e;if(this.tokens.links){let e=Object.keys(this.tokens.links);e.length>0&&(n=n.replace(this.tokenizer.rules.inline.reflinkSearch,t=>e.includes(t.slice(t.lastIndexOf("[")+1,-1))?"["+"a".repeat(t.length-2)+"]":t))}n=n.replace(this.tokenizer.rules.inline.anyPunctuation,"++"),n=n.replace(this.tokenizer.rules.inline.blockSkip,(e,t,n)=>{let r=n?n.length:0;return e.slice(0,r)+"["+"a".repeat(e.length-r-2)+"]"}),n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let r=!1,s="",l=1/0;for(;e;){if(!(e.length<l)){this.infiniteLoopError(e.charCodeAt(0));break}let i;if(l=e.length,r||(s=""),r=!1,this.options.extensions?.inline?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===i.type&&"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,n,s)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e,n,s)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e))){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(a=e.substring(0,n+1))}if(i=this.tokenizer.inlineText(a)){e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(s=i.raw.slice(-1)),r=!0;let n=t.at(-1);"text"===n?.type?(n.raw+=i.raw,n.text+=i.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t="Infinite loop on byte: "+e;if(!this.options.silent)throw new Error(t)}},de=class{options;parser;constructor(e){this.options=e||t}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(a.notSpaceStart)?.[0],s=e.replace(a.endingNewline,"")+"\n";return r?'<pre><code class="language-'+ie(r)+'">'+(n?s:ie(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:ie(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,r="";for(let l=0;l<e.items.length;l++){let t=e.items[l];r+=this.listitem(t)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+r+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let r="";for(let s=0;s<e.rows.length;s++){let t=e.rows[s];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+r+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ie(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),s=ae(e);if(null===s)return r;let l='<a href="'+(e=s)+'"';return t&&(l+=' title="'+ie(t)+'"'),l+=">"+r+"</a>",l}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let s=ae(e);if(null===s)return ie(n);let l=`<img src="${e=s}" alt="${ie(n)}"`;return t&&(l+=` title="${ie(t)}"`),l+=">",l}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:ie(e.text)}},fe=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},xe=class e{options;renderer;textRenderer;constructor(e){this.options=e||t,this.options.renderer=this.options.renderer||new de,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new fe}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=r;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let l=s;switch(l.type){case"escape":case"text":n+=t.text(l);break;case"html":n+=t.html(l);break;case"link":n+=t.link(l);break;case"image":n+=t.image(l);break;case"checkbox":n+=t.checkbox(l);break;case"strong":n+=t.strong(l);break;case"em":n+=t.em(l);break;case"codespan":n+=t.codespan(l);break;case"br":n+=t.br(l);break;case"del":n+=t.del(l);break;default:{let e='Token with "'+l.type+'" type was not found.';if(this.options.silent)return"";throw new Error(e)}}}return n}},be=class{options;block;constructor(e){this.options=e||t}static passThroughHooks=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?ke.lex:ke.lexInline}provideParser(e=this.block){return e?xe.parse:xe.parseInline}},we=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=xe;Renderer=de;TextRenderer=fe;Lexer=ke;Tokenizer=ge;Hooks=be;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case"table":{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let s=e[r].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new de(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,s=e.renderer[r],l=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ge(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,s=e.tokenizer[r],l=t[r];t[r]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new be;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,s=e.hooks[r],l=t[r];be.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&be.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return l.call(t,n)})();let r=s.call(t,e);return l.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await l.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=l.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return ke.lex(e,t??this.defaults)}parser(e,t){return xe.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},s={...this.defaults,...r},l=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===r.async)return l(/* @__PURE__ */new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return l(/* @__PURE__ */new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return l(/* @__PURE__ */new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,r=await(s.hooks?await s.hooks.provideLexer(e):e?ke.lex:ke.lexInline)(n,s),l=s.hooks?await s.hooks.processAllTokens(r):r;s.walkTokens&&await Promise.all(this.walkTokens(l,s.walkTokens));let i=await(s.hooks?await s.hooks.provideParser(e):e?xe.parse:xe.parseInline)(l,s);return s.hooks?await s.hooks.postprocess(i):i})().catch(l);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer(e):e?ke.lex:ke.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let r=(s.hooks?s.hooks.provideParser(e):e?xe.parse:xe.parseInline)(n,s);return s.hooks&&(r=s.hooks.postprocess(r)),r}catch(i){return l(i)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+ie(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function me(e,t){return we.parse(e,t)}me.options=me.setOptions=function(e){return we.setOptions(e),me.defaults=we.defaults,n(me.defaults),me},me.getDefaults=e,me.defaults=t,me.use=function(...e){return we.use(...e),me.defaults=we.defaults,n(me.defaults),me},me.walkTokens=function(e,t){return we.walkTokens(e,t)},me.parseInline=we.parseInline,me.Parser=xe,me.parser=xe.parse,me.Renderer=de,me.TextRenderer=fe,me.Lexer=ke,me.lexer=ke.lex,me.Tokenizer=ge,me.Hooks=be,me.parse=me;me.options,me.setOptions,me.use,me.walkTokens,me.parseInline,xe.parse,ke.lex;export{me as t};
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./custom-media-element-D6ffcXSN.cjs");let n=require("react");n=e.__toESM(n,1);var o=class extends t.CustomVideoElement{static shadowRootOptions={...t.CustomVideoElement.shadowRootOptions};static getTemplateHTML=e=>{const{src:n,...o}=e;return t.CustomVideoElement.getTemplateHTML(o)};#e;attributeChangedCallback(e,t,n){"src"!==e&&super.attributeChangedCallback(e,t,n),"src"===e&&t!=n&&this.load()}async load(){if(this.#e)this.api.attachSource(this.src);else{this.#e=!0;const e=await Promise.resolve().then(()=>require("./dash.all.min-DprN68bc.cjs"));this.api=e.MediaPlayer().create(),this.api.initialize(this.nativeEl,this.src,this.autoplay)}}};globalThis.customElements&&!globalThis.customElements.get("dash-video")&&globalThis.customElements.define("dash-video",o);var s=o,i=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),r={className:"class",htmlFor:"for"};function a(e){return e.toLowerCase()}function l(e){return"boolean"==typeof e?e?"":void 0:"function"==typeof e||"object"==typeof e&&null!==e?void 0:e}function u(e,t,n){var o;e[t]=n,null==n&&t in((null==(o=globalThis.HTMLElement)?void 0:o.prototype)??{})&&e.removeAttribute(t)}var c=function({react:e,tagName:t,elementClass:n,events:o,displayName:s,defaultProps:c,toAttributeName:d=a,toAttributeValue:f=l}){const m=Number.parseInt(e.version)>=19,p=e.forwardRef((s,a)=>{var p,h;const v=e.useRef(null),y=e.useRef(new Map),b={},g={},w={},E={};for(const[e,t]of Object.entries(s)){if(i.has(e)){w[e]=t;continue}const o=d(r[e]??e);if(e in n.prototype&&!(e in((null==(p=globalThis.HTMLElement)?void 0:p.prototype)??{}))&&!(null==(h=n.observedAttributes)?void 0:h.some(e=>e===o))){E[e]=t;continue}if(e.startsWith("on")){b[e]=t;continue}const s=f(t);o&&null!=s&&(g[o]=String(s),m||(w[o]=s)),o&&m&&(s!==l(t)?w[o]=s:w[o]=t)}if("undefined"!=typeof window){for(const t in b){const n=b[t],s=t.endsWith("Capture"),i=((null==o?void 0:o[t])??t.slice(2).toLowerCase()).slice(0,s?-7:void 0);e.useLayoutEffect(()=>{const e=null==v?void 0:v.current;if(e&&"function"==typeof n)return e.addEventListener(i,n,s),()=>{e.removeEventListener(i,n,s)}},[null==v?void 0:v.current,n])}e.useLayoutEffect(()=>{if(null===v.current)return;const e=new Map;for(const t in E)u(v.current,t,E[t]),y.current.delete(t),e.set(t,E[t]);for(const[t,n]of y.current)u(v.current,t,void 0);y.current=e})}if("undefined"==typeof window&&(null==n?void 0:n.getTemplateHTML)&&(null==n?void 0:n.shadowRootOptions)){const{mode:t,delegatesFocus:o}=n.shadowRootOptions;w.children=[e.createElement("template",{shadowrootmode:t,shadowrootdelegatesfocus:o,dangerouslySetInnerHTML:{__html:n.getTemplateHTML(g,s)}}),w.children]}return e.createElement(t,{...c,...w,ref:e.useCallback(e=>{v.current=e,"function"==typeof a?a(e):null!==a&&(a.current=e)},[a])})});return p.displayName=s??n.name,p}({react:n.default,tagName:"dash-video",elementClass:s,toAttributeName:e=>"muted"===e?"":"defaultMuted"===e?"muted":a(e)});exports.default=c;
1
+ const e=require("./rolldown-runtime-BeavJI0R.cjs"),t=require("./custom-media-element-D6ffcXSN.cjs");let n=require("react");n=e.__toESM(n,1);var o=class extends t.CustomVideoElement{static shadowRootOptions={...t.CustomVideoElement.shadowRootOptions};static getTemplateHTML=e=>{const{src:n,...o}=e;return t.CustomVideoElement.getTemplateHTML(o)};#e;attributeChangedCallback(e,t,n){"src"!==e&&super.attributeChangedCallback(e,t,n),"src"===e&&t!=n&&this.load()}async load(){if(this.#e)this.api.attachSource(this.src);else{this.#e=!0;const e=await Promise.resolve().then(()=>require("./dash.all.min-DprN68bc.cjs"));this.api=e.MediaPlayer().create(),this.api.initialize(this.nativeEl,this.src,this.autoplay)}}};globalThis.customElements&&!globalThis.customElements.get("dash-video")&&globalThis.customElements.define("dash-video",o);var s=o,i=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),r={className:"class",htmlFor:"for"};function a(e){return e.toLowerCase()}function l(e){return"boolean"==typeof e?e?"":void 0:"function"==typeof e||"object"==typeof e&&null!==e?void 0:e}function u(e,t,n){var o;e[t]=n,null==n&&t in((null==(o=globalThis.HTMLElement)?void 0:o.prototype)??{})&&e.removeAttribute(t)}var c=function({react:e,tagName:t,elementClass:n,events:o,displayName:s,defaultProps:c,toAttributeName:d=a,toAttributeValue:m=l}){const f=Number.parseInt(e.version)>=19,p=e.forwardRef((s,a)=>{var p,h;const v=e.useRef(null),y=e.useRef(new Map),b={},g={},w={},E={};for(const[e,t]of Object.entries(s)){if(i.has(e)){w[e]=t;continue}const o=d(r[e]??e);if(e in n.prototype&&!(e in((null==(p=globalThis.HTMLElement)?void 0:p.prototype)??{}))&&!(null==(h=n.observedAttributes)?void 0:h.some(e=>e===o))){E[e]=t;continue}if(e.startsWith("on")){b[e]=t;continue}const s=m(t);o&&null!=s&&(g[o]=String(s),f||(w[o]=s)),o&&f&&(s!==l(t)?w[o]=s:w[o]=t)}if("undefined"!=typeof window){for(const t in b){const n=b[t],s=t.endsWith("Capture"),i=((null==o?void 0:o[t])??t.slice(2).toLowerCase()).slice(0,s?-7:void 0);e.useLayoutEffect(()=>{const e=null==v?void 0:v.current;if(e&&"function"==typeof n)return e.addEventListener(i,n,s),()=>{e.removeEventListener(i,n,s)}},[null==v?void 0:v.current,n])}e.useLayoutEffect(()=>{if(null===v.current)return;const e=new Map;for(const t in E)u(v.current,t,E[t]),y.current.delete(t),e.set(t,E[t]);for(const[t,n]of y.current)u(v.current,t,void 0);y.current=e})}if("undefined"==typeof window&&(null==n?void 0:n.getTemplateHTML)&&(null==n?void 0:n.shadowRootOptions)){const{mode:t,delegatesFocus:o}=n.shadowRootOptions;w.children=[e.createElement("template",{shadowrootmode:t,shadowrootdelegatesfocus:o,dangerouslySetInnerHTML:{__html:n.getTemplateHTML(g,s)}}),w.children]}return e.createElement(t,{...c,...w,ref:e.useCallback(e=>{v.current=e,"function"==typeof a?a(e):null!==a&&(a.current=e)},[a])})});return p.displayName=s??n.name,p}({react:n.default,tagName:"dash-video",elementClass:s,toAttributeName:e=>"muted"===e?"":"defaultMuted"===e?"muted":a(e)});exports.default=c;