hermium 0.2.0 → 0.3.1

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 (172) hide show
  1. package/bin/hermium.mjs +103 -58
  2. package/dist/api.mjs +35 -0
  3. package/dist/public/assets/css/styles-o9LLzp-x.css +1 -0
  4. package/dist/public/assets/js/{ChatInputBlock-Bw7AL70H.js → ChatInputBlock-BgJMx5nW.js} +1 -1
  5. package/dist/public/assets/js/{MarkdownMessage-8d7Y6VL-.js → MarkdownMessage-Dd6VsKhk.js} +1 -1
  6. package/dist/public/assets/js/{base-ui-BvQbAt_1.js → base-ui-Ls-HE_Zl.js} +1 -1
  7. package/dist/public/assets/js/{chat._sessionId-BG6lVraH.js → chat._sessionId-Yif-J0_7.js} +1 -1
  8. package/dist/public/assets/js/{chat.index-D2zdMPTT.js → chat.index-QgwoSqOs.js} +1 -1
  9. package/dist/public/assets/js/{index-C0AK45FU.js → index-BDLsrzTe.js} +26 -26
  10. package/dist/public/assets/js/{index-Cx5En4FK.js → index-DRH0t4ti.js} +1 -1
  11. package/dist/public/assets/js/{memory-CeSRdTkW.js → memory-CHpNNtU2.js} +1 -1
  12. package/dist/public/assets/js/{router-8uDKazL-.js → router-B8BATVn7.js} +1 -1
  13. package/dist/public/assets/js/{settings-Bc3Y5zXO.js → settings-CRV3Pp8x.js} +1 -1
  14. package/dist/public/assets/js/{skills-DZv7sA_5.js → skills-C8G72gXr.js} +1 -1
  15. package/dist/public/assets/js/{usage-DXQsT9_b.js → usage-Bev8hqwh.js} +1 -1
  16. package/dist/server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +6 -0
  17. package/dist/server/_chunks/ssr-renderer.mjs +22 -0
  18. package/dist/server/_libs/bail.mjs +8 -0
  19. package/dist/server/_libs/base-ui__react.mjs +9858 -0
  20. package/dist/server/_libs/base-ui__utils.mjs +1106 -0
  21. package/dist/server/_libs/ccount.mjs +16 -0
  22. package/dist/server/_libs/character-entities.mjs +2130 -0
  23. package/dist/server/_libs/class-variance-authority.mjs +44 -0
  24. package/dist/server/_libs/clsx.mjs +16 -0
  25. package/dist/server/_libs/comma-separated-tokens.mjs +10 -0
  26. package/dist/server/_libs/cookie-es.mjs +1 -0
  27. package/dist/server/_libs/croner.mjs +1 -0
  28. package/dist/server/_libs/crossws.mjs +1 -0
  29. package/dist/server/_libs/decode-named-character-reference+[...].mjs +8 -0
  30. package/dist/server/_libs/devlop.mjs +8 -0
  31. package/dist/server/_libs/escape-string-regexp.mjs +9 -0
  32. package/dist/server/_libs/estree-util-is-identifier-name.mjs +11 -0
  33. package/dist/server/_libs/extend.mjs +97 -0
  34. package/dist/server/_libs/floating-ui__core.mjs +663 -0
  35. package/dist/server/_libs/floating-ui__dom.mjs +624 -0
  36. package/dist/server/_libs/floating-ui__react-dom.mjs +279 -0
  37. package/dist/server/_libs/floating-ui__utils.mjs +322 -0
  38. package/dist/server/_libs/h3.mjs +408 -0
  39. package/dist/server/_libs/hast-util-is-element.mjs +75 -0
  40. package/dist/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
  41. package/dist/server/_libs/hast-util-to-text.mjs +305 -0
  42. package/dist/server/_libs/hast-util-whitespace.mjs +10 -0
  43. package/dist/server/_libs/highlight.js.mjs +14756 -0
  44. package/dist/server/_libs/hookable.mjs +1 -0
  45. package/dist/server/_libs/html-url-attributes.mjs +26 -0
  46. package/dist/server/_libs/inline-style-parser.mjs +142 -0
  47. package/dist/server/_libs/is-plain-obj.mjs +10 -0
  48. package/dist/server/_libs/isbot.mjs +21 -0
  49. package/dist/server/_libs/longest-streak.mjs +25 -0
  50. package/dist/server/_libs/lowlight.mjs +262 -0
  51. package/dist/server/_libs/markdown-table.mjs +142 -0
  52. package/dist/server/_libs/mdast-util-find-and-replace.mjs +109 -0
  53. package/dist/server/_libs/mdast-util-from-markdown.mjs +717 -0
  54. package/dist/server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +156 -0
  55. package/dist/server/_libs/mdast-util-gfm-footnote.mjs +117 -0
  56. package/dist/server/_libs/mdast-util-gfm-strikethrough.mjs +54 -0
  57. package/dist/server/_libs/mdast-util-gfm-table.mjs +157 -0
  58. package/dist/server/_libs/mdast-util-gfm-task-list-item.mjs +77 -0
  59. package/dist/server/_libs/mdast-util-gfm.mjs +29 -0
  60. package/dist/server/_libs/mdast-util-phrasing.mjs +30 -0
  61. package/dist/server/_libs/mdast-util-to-hast.mjs +710 -0
  62. package/dist/server/_libs/mdast-util-to-markdown.mjs +798 -0
  63. package/dist/server/_libs/mdast-util-to-string.mjs +38 -0
  64. package/dist/server/_libs/micromark-core-commonmark.mjs +2259 -0
  65. package/dist/server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +344 -0
  66. package/dist/server/_libs/micromark-extension-gfm-footnote+[...].mjs +279 -0
  67. package/dist/server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +98 -0
  68. package/dist/server/_libs/micromark-extension-gfm-table.mjs +491 -0
  69. package/dist/server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +1 -0
  70. package/dist/server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +77 -0
  71. package/dist/server/_libs/micromark-extension-gfm.mjs +18 -0
  72. package/dist/server/_libs/micromark-factory-destination.mjs +94 -0
  73. package/dist/server/_libs/micromark-factory-label.mjs +63 -0
  74. package/dist/server/_libs/micromark-factory-space.mjs +24 -0
  75. package/dist/server/_libs/micromark-factory-title.mjs +65 -0
  76. package/dist/server/_libs/micromark-factory-whitespace.mjs +22 -0
  77. package/dist/server/_libs/micromark-util-character.mjs +44 -0
  78. package/dist/server/_libs/micromark-util-chunked.mjs +36 -0
  79. package/dist/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
  80. package/dist/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
  81. package/dist/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
  82. package/dist/server/_libs/micromark-util-decode-string.mjs +21 -0
  83. package/dist/server/_libs/micromark-util-encode.mjs +1 -0
  84. package/dist/server/_libs/micromark-util-html-tag-name.mjs +69 -0
  85. package/dist/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
  86. package/dist/server/_libs/micromark-util-resolve-all.mjs +15 -0
  87. package/dist/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
  88. package/dist/server/_libs/micromark-util-subtokenize.mjs +346 -0
  89. package/dist/server/_libs/micromark.mjs +906 -0
  90. package/dist/server/_libs/ocache.mjs +1 -0
  91. package/dist/server/_libs/ohash.mjs +1 -0
  92. package/dist/server/_libs/property-information.mjs +1209 -0
  93. package/dist/server/_libs/react-dom.mjs +10779 -0
  94. package/dist/server/_libs/react-markdown.mjs +147 -0
  95. package/dist/server/_libs/react.mjs +513 -0
  96. package/dist/server/_libs/rehype-highlight.mjs +94 -0
  97. package/dist/server/_libs/remark-gfm.mjs +20 -0
  98. package/dist/server/_libs/remark-parse.mjs +19 -0
  99. package/dist/server/_libs/remark-rehype.mjs +21 -0
  100. package/dist/server/_libs/reselect.mjs +1 -0
  101. package/dist/server/_libs/rou3.mjs +8 -0
  102. package/dist/server/_libs/seroval-plugins.mjs +1 -0
  103. package/dist/server/_libs/seroval.mjs +1 -0
  104. package/dist/server/_libs/space-separated-tokens.mjs +6 -0
  105. package/dist/server/_libs/srvx.mjs +781 -0
  106. package/dist/server/_libs/style-to-js.mjs +72 -0
  107. package/dist/server/_libs/style-to-object.mjs +38 -0
  108. package/dist/server/_libs/tabler__icons-react.mjs +140 -0
  109. package/dist/server/_libs/tailwind-merge.mjs +3255 -0
  110. package/dist/server/_libs/tanstack__history.mjs +29 -0
  111. package/dist/server/_libs/tanstack__react-router.mjs +1120 -0
  112. package/dist/server/_libs/tanstack__react-store.mjs +2 -0
  113. package/dist/server/_libs/tanstack__router-core.mjs +3594 -0
  114. package/dist/server/_libs/tanstack__store.mjs +1 -0
  115. package/dist/server/_libs/trim-lines.mjs +41 -0
  116. package/dist/server/_libs/trough.mjs +85 -0
  117. package/dist/server/_libs/ufo.mjs +54 -0
  118. package/dist/server/_libs/unctx.mjs +1 -0
  119. package/dist/server/_libs/ungap__structured-clone.mjs +224 -0
  120. package/dist/server/_libs/unified.mjs +661 -0
  121. package/dist/server/_libs/unist-util-find-after.mjs +41 -0
  122. package/dist/server/_libs/unist-util-is.mjs +100 -0
  123. package/dist/server/_libs/unist-util-position.mjs +27 -0
  124. package/dist/server/_libs/unist-util-stringify-position.mjs +27 -0
  125. package/dist/server/_libs/unist-util-visit-parents.mjs +83 -0
  126. package/dist/server/_libs/unist-util-visit.mjs +24 -0
  127. package/dist/server/_libs/unstorage.mjs +1 -0
  128. package/dist/server/_libs/use-sync-external-store.mjs +139 -0
  129. package/dist/server/_libs/vfile-message.mjs +138 -0
  130. package/dist/server/_libs/vfile.mjs +467 -0
  131. package/dist/server/_libs/zustand.mjs +43 -0
  132. package/dist/server/_libs/zwitch.mjs +1 -0
  133. package/dist/server/_ssr/ChatInputBlock-Bu2-iop_.mjs +220 -0
  134. package/dist/server/_ssr/MarkdownMessage-CNS7OSKN.mjs +68 -0
  135. package/dist/server/_ssr/chat._sessionId-P02iSfut.mjs +477 -0
  136. package/dist/server/_ssr/chat.index-BYB_48NC.mjs +64 -0
  137. package/dist/server/_ssr/index-C1mT_2d8.mjs +4890 -0
  138. package/dist/server/_ssr/index-DFV9_oCk.mjs +43 -0
  139. package/dist/server/_ssr/memory-CW_fSOG9.mjs +257 -0
  140. package/dist/server/_ssr/router-CUAfx91O.mjs +2035 -0
  141. package/dist/server/_ssr/settings-DoXurzvn.mjs +10 -0
  142. package/dist/server/_ssr/skills-Cs7A5ZwO.mjs +422 -0
  143. package/dist/server/_ssr/theme-BK4-7E2h.mjs +42 -0
  144. package/dist/server/_ssr/usage-Bs2-LXGz.mjs +298 -0
  145. package/dist/server/_tanstack-start-manifest_v-C7Upe2TI.mjs +4 -0
  146. package/dist/server/index.mjs +506 -0
  147. package/dist/server/public/assets/css/index-Dfs9RUU9.css +1 -0
  148. package/dist/server/public/assets/css/styles-o9LLzp-x.css +1 -0
  149. package/dist/server/public/assets/js/ChatInputBlock-BgJMx5nW.js +1 -0
  150. package/dist/server/public/assets/js/MarkdownMessage-Dd6VsKhk.js +1 -0
  151. package/dist/server/public/assets/js/base-ui-Ls-HE_Zl.js +1 -0
  152. package/dist/server/public/assets/js/chat._sessionId-Yif-J0_7.js +1 -0
  153. package/dist/server/public/assets/js/chat.index-QgwoSqOs.js +1 -0
  154. package/dist/server/public/assets/js/index-BDLsrzTe.js +60 -0
  155. package/dist/server/public/assets/js/index-DRH0t4ti.js +1 -0
  156. package/dist/server/public/assets/js/memory-CHpNNtU2.js +3 -0
  157. package/dist/server/public/assets/js/router-B8BATVn7.js +1 -0
  158. package/dist/server/public/assets/js/settings-CRV3Pp8x.js +1 -0
  159. package/dist/server/public/assets/js/skills-C8G72gXr.js +1 -0
  160. package/dist/server/public/assets/js/theme-CPkdkpaj.js +1 -0
  161. package/dist/server/public/assets/js/usage-Bev8hqwh.js +1 -0
  162. package/dist/server/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  163. package/dist/server/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  164. package/dist/server/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  165. package/dist/server/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  166. package/dist/server/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  167. package/dist/server/public/favicon.ico +0 -0
  168. package/dist/server/public/logo.png +0 -0
  169. package/dist/server/public/manifest.json +25 -0
  170. package/dist/server/public/robots.txt +3 -0
  171. package/package.json +4 -3
  172. package/dist/public/assets/css/styles-B8p6jk5Z.css +0 -1
@@ -0,0 +1,906 @@
1
+ import { c as combineExtensions } from "./micromark-util-combine-extensions+[...].mjs";
2
+ import { f as factorySpace } from "./micromark-factory-space.mjs";
3
+ import { m as markdownLineEnding } from "./micromark-util-character.mjs";
4
+ import { s as splice, p as push } from "./micromark-util-chunked.mjs";
5
+ import { c as blankLine, j as content$1, k as definition, d as blockQuote, t as list, g as codeFenced, v as thematicBreak, u as setextUnderline, n as htmlFlow, m as headingAtx, h as codeIndented, a as attention, e as characterEscape, f as characterReference, i as codeText, p as labelEnd, l as hardBreakEscape, r as labelStartLink, b as autolink, o as htmlText, q as labelStartImage, s as lineEnding } from "./micromark-core-commonmark.mjs";
6
+ import { r as resolveAll } from "./micromark-util-resolve-all.mjs";
7
+ import { s as subtokenize } from "./micromark-util-subtokenize.mjs";
8
+ const content = {
9
+ tokenize: initializeContent
10
+ };
11
+ function initializeContent(effects) {
12
+ const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);
13
+ let previous;
14
+ return contentStart;
15
+ function afterContentStartConstruct(code) {
16
+ if (code === null) {
17
+ effects.consume(code);
18
+ return;
19
+ }
20
+ effects.enter("lineEnding");
21
+ effects.consume(code);
22
+ effects.exit("lineEnding");
23
+ return factorySpace(effects, contentStart, "linePrefix");
24
+ }
25
+ function paragraphInitial(code) {
26
+ effects.enter("paragraph");
27
+ return lineStart(code);
28
+ }
29
+ function lineStart(code) {
30
+ const token = effects.enter("chunkText", {
31
+ contentType: "text",
32
+ previous
33
+ });
34
+ if (previous) {
35
+ previous.next = token;
36
+ }
37
+ previous = token;
38
+ return data(code);
39
+ }
40
+ function data(code) {
41
+ if (code === null) {
42
+ effects.exit("chunkText");
43
+ effects.exit("paragraph");
44
+ effects.consume(code);
45
+ return;
46
+ }
47
+ if (markdownLineEnding(code)) {
48
+ effects.consume(code);
49
+ effects.exit("chunkText");
50
+ return lineStart;
51
+ }
52
+ effects.consume(code);
53
+ return data;
54
+ }
55
+ }
56
+ const document$1 = {
57
+ tokenize: initializeDocument
58
+ };
59
+ const containerConstruct = {
60
+ tokenize: tokenizeContainer
61
+ };
62
+ function initializeDocument(effects) {
63
+ const self = this;
64
+ const stack = [];
65
+ let continued = 0;
66
+ let childFlow;
67
+ let childToken;
68
+ let lineStartOffset;
69
+ return start;
70
+ function start(code) {
71
+ if (continued < stack.length) {
72
+ const item = stack[continued];
73
+ self.containerState = item[1];
74
+ return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
75
+ }
76
+ return checkNewContainers(code);
77
+ }
78
+ function documentContinue(code) {
79
+ continued++;
80
+ if (self.containerState._closeFlow) {
81
+ self.containerState._closeFlow = void 0;
82
+ if (childFlow) {
83
+ closeFlow();
84
+ }
85
+ const indexBeforeExits = self.events.length;
86
+ let indexBeforeFlow = indexBeforeExits;
87
+ let point;
88
+ while (indexBeforeFlow--) {
89
+ if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
90
+ point = self.events[indexBeforeFlow][1].end;
91
+ break;
92
+ }
93
+ }
94
+ exitContainers(continued);
95
+ let index = indexBeforeExits;
96
+ while (index < self.events.length) {
97
+ self.events[index][1].end = {
98
+ ...point
99
+ };
100
+ index++;
101
+ }
102
+ splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
103
+ self.events.length = index;
104
+ return checkNewContainers(code);
105
+ }
106
+ return start(code);
107
+ }
108
+ function checkNewContainers(code) {
109
+ if (continued === stack.length) {
110
+ if (!childFlow) {
111
+ return documentContinued(code);
112
+ }
113
+ if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) {
114
+ return flowStart(code);
115
+ }
116
+ self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
117
+ }
118
+ self.containerState = {};
119
+ return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);
120
+ }
121
+ function thereIsANewContainer(code) {
122
+ if (childFlow) closeFlow();
123
+ exitContainers(continued);
124
+ return documentContinued(code);
125
+ }
126
+ function thereIsNoNewContainer(code) {
127
+ self.parser.lazy[self.now().line] = continued !== stack.length;
128
+ lineStartOffset = self.now().offset;
129
+ return flowStart(code);
130
+ }
131
+ function documentContinued(code) {
132
+ self.containerState = {};
133
+ return effects.attempt(containerConstruct, containerContinue, flowStart)(code);
134
+ }
135
+ function containerContinue(code) {
136
+ continued++;
137
+ stack.push([self.currentConstruct, self.containerState]);
138
+ return documentContinued(code);
139
+ }
140
+ function flowStart(code) {
141
+ if (code === null) {
142
+ if (childFlow) closeFlow();
143
+ exitContainers(0);
144
+ effects.consume(code);
145
+ return;
146
+ }
147
+ childFlow = childFlow || self.parser.flow(self.now());
148
+ effects.enter("chunkFlow", {
149
+ _tokenizer: childFlow,
150
+ contentType: "flow",
151
+ previous: childToken
152
+ });
153
+ return flowContinue(code);
154
+ }
155
+ function flowContinue(code) {
156
+ if (code === null) {
157
+ writeToChild(effects.exit("chunkFlow"), true);
158
+ exitContainers(0);
159
+ effects.consume(code);
160
+ return;
161
+ }
162
+ if (markdownLineEnding(code)) {
163
+ effects.consume(code);
164
+ writeToChild(effects.exit("chunkFlow"));
165
+ continued = 0;
166
+ self.interrupt = void 0;
167
+ return start;
168
+ }
169
+ effects.consume(code);
170
+ return flowContinue;
171
+ }
172
+ function writeToChild(token, endOfFile) {
173
+ const stream = self.sliceStream(token);
174
+ if (endOfFile) stream.push(null);
175
+ token.previous = childToken;
176
+ if (childToken) childToken.next = token;
177
+ childToken = token;
178
+ childFlow.defineSkip(token.start);
179
+ childFlow.write(stream);
180
+ if (self.parser.lazy[token.start.line]) {
181
+ let index = childFlow.events.length;
182
+ while (index--) {
183
+ if (
184
+ // The token starts before the line ending…
185
+ childFlow.events[index][1].start.offset < lineStartOffset && // …and either is not ended yet…
186
+ (!childFlow.events[index][1].end || // …or ends after it.
187
+ childFlow.events[index][1].end.offset > lineStartOffset)
188
+ ) {
189
+ return;
190
+ }
191
+ }
192
+ const indexBeforeExits = self.events.length;
193
+ let indexBeforeFlow = indexBeforeExits;
194
+ let seen;
195
+ let point;
196
+ while (indexBeforeFlow--) {
197
+ if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
198
+ if (seen) {
199
+ point = self.events[indexBeforeFlow][1].end;
200
+ break;
201
+ }
202
+ seen = true;
203
+ }
204
+ }
205
+ exitContainers(continued);
206
+ index = indexBeforeExits;
207
+ while (index < self.events.length) {
208
+ self.events[index][1].end = {
209
+ ...point
210
+ };
211
+ index++;
212
+ }
213
+ splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
214
+ self.events.length = index;
215
+ }
216
+ }
217
+ function exitContainers(size) {
218
+ let index = stack.length;
219
+ while (index-- > size) {
220
+ const entry = stack[index];
221
+ self.containerState = entry[1];
222
+ entry[0].exit.call(self, effects);
223
+ }
224
+ stack.length = size;
225
+ }
226
+ function closeFlow() {
227
+ childFlow.write([null]);
228
+ childToken = void 0;
229
+ childFlow = void 0;
230
+ self.containerState._closeFlow = void 0;
231
+ }
232
+ }
233
+ function tokenizeContainer(effects, ok, nok) {
234
+ return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), "linePrefix", this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
235
+ }
236
+ const flow$1 = {
237
+ tokenize: initializeFlow
238
+ };
239
+ function initializeFlow(effects) {
240
+ const self = this;
241
+ const initial = effects.attempt(
242
+ // Try to parse a blank line.
243
+ blankLine,
244
+ atBlankEnding,
245
+ // Try to parse initial flow (essentially, only code).
246
+ effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content$1, afterConstruct)), "linePrefix"))
247
+ );
248
+ return initial;
249
+ function atBlankEnding(code) {
250
+ if (code === null) {
251
+ effects.consume(code);
252
+ return;
253
+ }
254
+ effects.enter("lineEndingBlank");
255
+ effects.consume(code);
256
+ effects.exit("lineEndingBlank");
257
+ self.currentConstruct = void 0;
258
+ return initial;
259
+ }
260
+ function afterConstruct(code) {
261
+ if (code === null) {
262
+ effects.consume(code);
263
+ return;
264
+ }
265
+ effects.enter("lineEnding");
266
+ effects.consume(code);
267
+ effects.exit("lineEnding");
268
+ self.currentConstruct = void 0;
269
+ return initial;
270
+ }
271
+ }
272
+ const resolver = {
273
+ resolveAll: createResolver()
274
+ };
275
+ const string$1 = initializeFactory("string");
276
+ const text$1 = initializeFactory("text");
277
+ function initializeFactory(field) {
278
+ return {
279
+ resolveAll: createResolver(field === "text" ? resolveAllLineSuffixes : void 0),
280
+ tokenize: initializeText
281
+ };
282
+ function initializeText(effects) {
283
+ const self = this;
284
+ const constructs = this.parser.constructs[field];
285
+ const text2 = effects.attempt(constructs, start, notText);
286
+ return start;
287
+ function start(code) {
288
+ return atBreak(code) ? text2(code) : notText(code);
289
+ }
290
+ function notText(code) {
291
+ if (code === null) {
292
+ effects.consume(code);
293
+ return;
294
+ }
295
+ effects.enter("data");
296
+ effects.consume(code);
297
+ return data;
298
+ }
299
+ function data(code) {
300
+ if (atBreak(code)) {
301
+ effects.exit("data");
302
+ return text2(code);
303
+ }
304
+ effects.consume(code);
305
+ return data;
306
+ }
307
+ function atBreak(code) {
308
+ if (code === null) {
309
+ return true;
310
+ }
311
+ const list2 = constructs[code];
312
+ let index = -1;
313
+ if (list2) {
314
+ while (++index < list2.length) {
315
+ const item = list2[index];
316
+ if (!item.previous || item.previous.call(self, self.previous)) {
317
+ return true;
318
+ }
319
+ }
320
+ }
321
+ return false;
322
+ }
323
+ }
324
+ }
325
+ function createResolver(extraResolver) {
326
+ return resolveAllText;
327
+ function resolveAllText(events, context) {
328
+ let index = -1;
329
+ let enter;
330
+ while (++index <= events.length) {
331
+ if (enter === void 0) {
332
+ if (events[index] && events[index][1].type === "data") {
333
+ enter = index;
334
+ index++;
335
+ }
336
+ } else if (!events[index] || events[index][1].type !== "data") {
337
+ if (index !== enter + 2) {
338
+ events[enter][1].end = events[index - 1][1].end;
339
+ events.splice(enter + 2, index - enter - 2);
340
+ index = enter + 2;
341
+ }
342
+ enter = void 0;
343
+ }
344
+ }
345
+ return extraResolver ? extraResolver(events, context) : events;
346
+ }
347
+ }
348
+ function resolveAllLineSuffixes(events, context) {
349
+ let eventIndex = 0;
350
+ while (++eventIndex <= events.length) {
351
+ if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
352
+ const data = events[eventIndex - 1][1];
353
+ const chunks = context.sliceStream(data);
354
+ let index = chunks.length;
355
+ let bufferIndex = -1;
356
+ let size = 0;
357
+ let tabs;
358
+ while (index--) {
359
+ const chunk = chunks[index];
360
+ if (typeof chunk === "string") {
361
+ bufferIndex = chunk.length;
362
+ while (chunk.charCodeAt(bufferIndex - 1) === 32) {
363
+ size++;
364
+ bufferIndex--;
365
+ }
366
+ if (bufferIndex) break;
367
+ bufferIndex = -1;
368
+ } else if (chunk === -2) {
369
+ tabs = true;
370
+ size++;
371
+ } else if (chunk === -1) ;
372
+ else {
373
+ index++;
374
+ break;
375
+ }
376
+ }
377
+ if (context._contentTypeTextTrailing && eventIndex === events.length) {
378
+ size = 0;
379
+ }
380
+ if (size) {
381
+ const token = {
382
+ type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
383
+ start: {
384
+ _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex,
385
+ _index: data.start._index + index,
386
+ line: data.end.line,
387
+ column: data.end.column - size,
388
+ offset: data.end.offset - size
389
+ },
390
+ end: {
391
+ ...data.end
392
+ }
393
+ };
394
+ data.end = {
395
+ ...token.start
396
+ };
397
+ if (data.start.offset === data.end.offset) {
398
+ Object.assign(data, token);
399
+ } else {
400
+ events.splice(eventIndex, 0, ["enter", token, context], ["exit", token, context]);
401
+ eventIndex += 2;
402
+ }
403
+ }
404
+ eventIndex++;
405
+ }
406
+ }
407
+ return events;
408
+ }
409
+ const document = {
410
+ [42]: list,
411
+ [43]: list,
412
+ [45]: list,
413
+ [48]: list,
414
+ [49]: list,
415
+ [50]: list,
416
+ [51]: list,
417
+ [52]: list,
418
+ [53]: list,
419
+ [54]: list,
420
+ [55]: list,
421
+ [56]: list,
422
+ [57]: list,
423
+ [62]: blockQuote
424
+ };
425
+ const contentInitial = {
426
+ [91]: definition
427
+ };
428
+ const flowInitial = {
429
+ [-2]: codeIndented,
430
+ [-1]: codeIndented,
431
+ [32]: codeIndented
432
+ };
433
+ const flow = {
434
+ [35]: headingAtx,
435
+ [42]: thematicBreak,
436
+ [45]: [setextUnderline, thematicBreak],
437
+ [60]: htmlFlow,
438
+ [61]: setextUnderline,
439
+ [95]: thematicBreak,
440
+ [96]: codeFenced,
441
+ [126]: codeFenced
442
+ };
443
+ const string = {
444
+ [38]: characterReference,
445
+ [92]: characterEscape
446
+ };
447
+ const text = {
448
+ [-5]: lineEnding,
449
+ [-4]: lineEnding,
450
+ [-3]: lineEnding,
451
+ [33]: labelStartImage,
452
+ [38]: characterReference,
453
+ [42]: attention,
454
+ [60]: [autolink, htmlText],
455
+ [91]: labelStartLink,
456
+ [92]: [hardBreakEscape, characterEscape],
457
+ [93]: labelEnd,
458
+ [95]: attention,
459
+ [96]: codeText
460
+ };
461
+ const insideSpan = {
462
+ null: [attention, resolver]
463
+ };
464
+ const attentionMarkers = {
465
+ null: [42, 95]
466
+ };
467
+ const disable = {
468
+ null: []
469
+ };
470
+ const defaultConstructs = /* @__PURE__ */ Object.freeze({
471
+ __proto__: null,
472
+ attentionMarkers,
473
+ contentInitial,
474
+ disable,
475
+ document,
476
+ flow,
477
+ flowInitial,
478
+ insideSpan,
479
+ string,
480
+ text
481
+ });
482
+ function createTokenizer(parser, initialize, from) {
483
+ let point = {
484
+ _bufferIndex: -1,
485
+ _index: 0,
486
+ line: from && from.line || 1,
487
+ column: from && from.column || 1,
488
+ offset: from && from.offset || 0
489
+ };
490
+ const columnStart = {};
491
+ const resolveAllConstructs = [];
492
+ let chunks = [];
493
+ let stack = [];
494
+ const effects = {
495
+ attempt: constructFactory(onsuccessfulconstruct),
496
+ check: constructFactory(onsuccessfulcheck),
497
+ consume,
498
+ enter,
499
+ exit,
500
+ interrupt: constructFactory(onsuccessfulcheck, {
501
+ interrupt: true
502
+ })
503
+ };
504
+ const context = {
505
+ code: null,
506
+ containerState: {},
507
+ defineSkip,
508
+ events: [],
509
+ now,
510
+ parser,
511
+ previous: null,
512
+ sliceSerialize,
513
+ sliceStream,
514
+ write
515
+ };
516
+ let state = initialize.tokenize.call(context, effects);
517
+ if (initialize.resolveAll) {
518
+ resolveAllConstructs.push(initialize);
519
+ }
520
+ return context;
521
+ function write(slice) {
522
+ chunks = push(chunks, slice);
523
+ main();
524
+ if (chunks[chunks.length - 1] !== null) {
525
+ return [];
526
+ }
527
+ addResult(initialize, 0);
528
+ context.events = resolveAll(resolveAllConstructs, context.events, context);
529
+ return context.events;
530
+ }
531
+ function sliceSerialize(token, expandTabs) {
532
+ return serializeChunks(sliceStream(token), expandTabs);
533
+ }
534
+ function sliceStream(token) {
535
+ return sliceChunks(chunks, token);
536
+ }
537
+ function now() {
538
+ const {
539
+ _bufferIndex,
540
+ _index,
541
+ line,
542
+ column,
543
+ offset
544
+ } = point;
545
+ return {
546
+ _bufferIndex,
547
+ _index,
548
+ line,
549
+ column,
550
+ offset
551
+ };
552
+ }
553
+ function defineSkip(value) {
554
+ columnStart[value.line] = value.column;
555
+ accountForPotentialSkip();
556
+ }
557
+ function main() {
558
+ let chunkIndex;
559
+ while (point._index < chunks.length) {
560
+ const chunk = chunks[point._index];
561
+ if (typeof chunk === "string") {
562
+ chunkIndex = point._index;
563
+ if (point._bufferIndex < 0) {
564
+ point._bufferIndex = 0;
565
+ }
566
+ while (point._index === chunkIndex && point._bufferIndex < chunk.length) {
567
+ go(chunk.charCodeAt(point._bufferIndex));
568
+ }
569
+ } else {
570
+ go(chunk);
571
+ }
572
+ }
573
+ }
574
+ function go(code) {
575
+ state = state(code);
576
+ }
577
+ function consume(code) {
578
+ if (markdownLineEnding(code)) {
579
+ point.line++;
580
+ point.column = 1;
581
+ point.offset += code === -3 ? 2 : 1;
582
+ accountForPotentialSkip();
583
+ } else if (code !== -1) {
584
+ point.column++;
585
+ point.offset++;
586
+ }
587
+ if (point._bufferIndex < 0) {
588
+ point._index++;
589
+ } else {
590
+ point._bufferIndex++;
591
+ if (point._bufferIndex === // Points w/ non-negative `_bufferIndex` reference
592
+ // strings.
593
+ /** @type {string} */
594
+ chunks[point._index].length) {
595
+ point._bufferIndex = -1;
596
+ point._index++;
597
+ }
598
+ }
599
+ context.previous = code;
600
+ }
601
+ function enter(type, fields) {
602
+ const token = fields || {};
603
+ token.type = type;
604
+ token.start = now();
605
+ context.events.push(["enter", token, context]);
606
+ stack.push(token);
607
+ return token;
608
+ }
609
+ function exit(type) {
610
+ const token = stack.pop();
611
+ token.end = now();
612
+ context.events.push(["exit", token, context]);
613
+ return token;
614
+ }
615
+ function onsuccessfulconstruct(construct, info) {
616
+ addResult(construct, info.from);
617
+ }
618
+ function onsuccessfulcheck(_, info) {
619
+ info.restore();
620
+ }
621
+ function constructFactory(onreturn, fields) {
622
+ return hook;
623
+ function hook(constructs, returnState, bogusState) {
624
+ let listOfConstructs;
625
+ let constructIndex;
626
+ let currentConstruct;
627
+ let info;
628
+ return Array.isArray(constructs) ? (
629
+ /* c8 ignore next 1 */
630
+ handleListOfConstructs(constructs)
631
+ ) : "tokenize" in constructs ? (
632
+ // Looks like a construct.
633
+ handleListOfConstructs([
634
+ /** @type {Construct} */
635
+ constructs
636
+ ])
637
+ ) : handleMapOfConstructs(constructs);
638
+ function handleMapOfConstructs(map) {
639
+ return start;
640
+ function start(code) {
641
+ const left = code !== null && map[code];
642
+ const all = code !== null && map.null;
643
+ const list2 = [
644
+ // To do: add more extension tests.
645
+ /* c8 ignore next 2 */
646
+ ...Array.isArray(left) ? left : left ? [left] : [],
647
+ ...Array.isArray(all) ? all : all ? [all] : []
648
+ ];
649
+ return handleListOfConstructs(list2)(code);
650
+ }
651
+ }
652
+ function handleListOfConstructs(list2) {
653
+ listOfConstructs = list2;
654
+ constructIndex = 0;
655
+ if (list2.length === 0) {
656
+ return bogusState;
657
+ }
658
+ return handleConstruct(list2[constructIndex]);
659
+ }
660
+ function handleConstruct(construct) {
661
+ return start;
662
+ function start(code) {
663
+ info = store();
664
+ currentConstruct = construct;
665
+ if (!construct.partial) {
666
+ context.currentConstruct = construct;
667
+ }
668
+ if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) {
669
+ return nok();
670
+ }
671
+ return construct.tokenize.call(
672
+ // If we do have fields, create an object w/ `context` as its
673
+ // prototype.
674
+ // This allows a “live binding”, which is needed for `interrupt`.
675
+ fields ? Object.assign(Object.create(context), fields) : context,
676
+ effects,
677
+ ok,
678
+ nok
679
+ )(code);
680
+ }
681
+ }
682
+ function ok(code) {
683
+ onreturn(currentConstruct, info);
684
+ return returnState;
685
+ }
686
+ function nok(code) {
687
+ info.restore();
688
+ if (++constructIndex < listOfConstructs.length) {
689
+ return handleConstruct(listOfConstructs[constructIndex]);
690
+ }
691
+ return bogusState;
692
+ }
693
+ }
694
+ }
695
+ function addResult(construct, from2) {
696
+ if (construct.resolveAll && !resolveAllConstructs.includes(construct)) {
697
+ resolveAllConstructs.push(construct);
698
+ }
699
+ if (construct.resolve) {
700
+ splice(context.events, from2, context.events.length - from2, construct.resolve(context.events.slice(from2), context));
701
+ }
702
+ if (construct.resolveTo) {
703
+ context.events = construct.resolveTo(context.events, context);
704
+ }
705
+ }
706
+ function store() {
707
+ const startPoint = now();
708
+ const startPrevious = context.previous;
709
+ const startCurrentConstruct = context.currentConstruct;
710
+ const startEventsIndex = context.events.length;
711
+ const startStack = Array.from(stack);
712
+ return {
713
+ from: startEventsIndex,
714
+ restore
715
+ };
716
+ function restore() {
717
+ point = startPoint;
718
+ context.previous = startPrevious;
719
+ context.currentConstruct = startCurrentConstruct;
720
+ context.events.length = startEventsIndex;
721
+ stack = startStack;
722
+ accountForPotentialSkip();
723
+ }
724
+ }
725
+ function accountForPotentialSkip() {
726
+ if (point.line in columnStart && point.column < 2) {
727
+ point.column = columnStart[point.line];
728
+ point.offset += columnStart[point.line] - 1;
729
+ }
730
+ }
731
+ }
732
+ function sliceChunks(chunks, token) {
733
+ const startIndex = token.start._index;
734
+ const startBufferIndex = token.start._bufferIndex;
735
+ const endIndex = token.end._index;
736
+ const endBufferIndex = token.end._bufferIndex;
737
+ let view;
738
+ if (startIndex === endIndex) {
739
+ view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
740
+ } else {
741
+ view = chunks.slice(startIndex, endIndex);
742
+ if (startBufferIndex > -1) {
743
+ const head = view[0];
744
+ if (typeof head === "string") {
745
+ view[0] = head.slice(startBufferIndex);
746
+ } else {
747
+ view.shift();
748
+ }
749
+ }
750
+ if (endBufferIndex > 0) {
751
+ view.push(chunks[endIndex].slice(0, endBufferIndex));
752
+ }
753
+ }
754
+ return view;
755
+ }
756
+ function serializeChunks(chunks, expandTabs) {
757
+ let index = -1;
758
+ const result = [];
759
+ let atTab;
760
+ while (++index < chunks.length) {
761
+ const chunk = chunks[index];
762
+ let value;
763
+ if (typeof chunk === "string") {
764
+ value = chunk;
765
+ } else switch (chunk) {
766
+ case -5: {
767
+ value = "\r";
768
+ break;
769
+ }
770
+ case -4: {
771
+ value = "\n";
772
+ break;
773
+ }
774
+ case -3: {
775
+ value = "\r\n";
776
+ break;
777
+ }
778
+ case -2: {
779
+ value = expandTabs ? " " : " ";
780
+ break;
781
+ }
782
+ case -1: {
783
+ if (!expandTabs && atTab) continue;
784
+ value = " ";
785
+ break;
786
+ }
787
+ default: {
788
+ value = String.fromCharCode(chunk);
789
+ }
790
+ }
791
+ atTab = chunk === -2;
792
+ result.push(value);
793
+ }
794
+ return result.join("");
795
+ }
796
+ function parse(options) {
797
+ const settings = options || {};
798
+ const constructs = (
799
+ /** @type {FullNormalizedExtension} */
800
+ combineExtensions([defaultConstructs, ...settings.extensions || []])
801
+ );
802
+ const parser = {
803
+ constructs,
804
+ content: create(content),
805
+ defined: [],
806
+ document: create(document$1),
807
+ flow: create(flow$1),
808
+ lazy: {},
809
+ string: create(string$1),
810
+ text: create(text$1)
811
+ };
812
+ return parser;
813
+ function create(initial) {
814
+ return creator;
815
+ function creator(from) {
816
+ return createTokenizer(parser, initial, from);
817
+ }
818
+ }
819
+ }
820
+ function postprocess(events) {
821
+ while (!subtokenize(events)) {
822
+ }
823
+ return events;
824
+ }
825
+ const search = /[\0\t\n\r]/g;
826
+ function preprocess() {
827
+ let column = 1;
828
+ let buffer = "";
829
+ let start = true;
830
+ let atCarriageReturn;
831
+ return preprocessor;
832
+ function preprocessor(value, encoding, end) {
833
+ const chunks = [];
834
+ let match;
835
+ let next;
836
+ let startPosition;
837
+ let endPosition;
838
+ let code;
839
+ value = buffer + (typeof value === "string" ? value.toString() : new TextDecoder(encoding || void 0).decode(value));
840
+ startPosition = 0;
841
+ buffer = "";
842
+ if (start) {
843
+ if (value.charCodeAt(0) === 65279) {
844
+ startPosition++;
845
+ }
846
+ start = void 0;
847
+ }
848
+ while (startPosition < value.length) {
849
+ search.lastIndex = startPosition;
850
+ match = search.exec(value);
851
+ endPosition = match && match.index !== void 0 ? match.index : value.length;
852
+ code = value.charCodeAt(endPosition);
853
+ if (!match) {
854
+ buffer = value.slice(startPosition);
855
+ break;
856
+ }
857
+ if (code === 10 && startPosition === endPosition && atCarriageReturn) {
858
+ chunks.push(-3);
859
+ atCarriageReturn = void 0;
860
+ } else {
861
+ if (atCarriageReturn) {
862
+ chunks.push(-5);
863
+ atCarriageReturn = void 0;
864
+ }
865
+ if (startPosition < endPosition) {
866
+ chunks.push(value.slice(startPosition, endPosition));
867
+ column += endPosition - startPosition;
868
+ }
869
+ switch (code) {
870
+ case 0: {
871
+ chunks.push(65533);
872
+ column++;
873
+ break;
874
+ }
875
+ case 9: {
876
+ next = Math.ceil(column / 4) * 4;
877
+ chunks.push(-2);
878
+ while (column++ < next) chunks.push(-1);
879
+ break;
880
+ }
881
+ case 10: {
882
+ chunks.push(-4);
883
+ column = 1;
884
+ break;
885
+ }
886
+ default: {
887
+ atCarriageReturn = true;
888
+ column = 1;
889
+ }
890
+ }
891
+ }
892
+ startPosition = endPosition + 1;
893
+ }
894
+ if (end) {
895
+ if (atCarriageReturn) chunks.push(-5);
896
+ if (buffer) chunks.push(buffer);
897
+ chunks.push(null);
898
+ }
899
+ return chunks;
900
+ }
901
+ }
902
+ export {
903
+ postprocess as a,
904
+ preprocess as b,
905
+ parse as p
906
+ };