@likec4/core 1.46.4 → 1.48.0

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 (181) hide show
  1. package/LICENSE +1 -1
  2. package/dist/_chunks/Builder.view-element.mjs +3284 -0
  3. package/dist/_chunks/LikeC4Model.d.mts +1287 -0
  4. package/dist/_chunks/LikeC4Styles.mjs +691 -0
  5. package/dist/_chunks/RichText.d.mts +84 -0
  6. package/dist/_chunks/RichText.mjs +148 -0
  7. package/dist/_chunks/_aux.d.mts +289 -0
  8. package/dist/_chunks/_aux.mjs +18 -0
  9. package/dist/_chunks/_types.d.mts +781 -0
  10. package/dist/_chunks/_types2.d.mts +38 -0
  11. package/dist/_chunks/assignTagColors.mjs +24 -0
  12. package/dist/_chunks/calcDriftsFromSnapshot.mjs +379 -0
  13. package/dist/_chunks/connection.mjs +0 -0
  14. package/dist/_chunks/const.d.mts +43 -0
  15. package/dist/_chunks/const.mjs +33 -0
  16. package/dist/_chunks/expression-model.d.mts +192 -0
  17. package/dist/_chunks/expression-model.mjs +103 -0
  18. package/dist/_chunks/expression.d.mts +347 -0
  19. package/dist/_chunks/expression.mjs +107 -0
  20. package/dist/_chunks/find.d.mts +82 -0
  21. package/dist/_chunks/find.mjs +646 -0
  22. package/dist/_chunks/find2.d.mts +78 -0
  23. package/dist/_chunks/find2.mjs +287 -0
  24. package/dist/_chunks/fqnRef.d.mts +58 -0
  25. package/dist/_chunks/fqnRef.mjs +41 -0
  26. package/dist/_chunks/geometry.mjs +335 -0
  27. package/dist/_chunks/index.d.mts +169 -0
  28. package/dist/_chunks/index2.d.mts +937 -0
  29. package/dist/_chunks/index3.d.mts +146 -0
  30. package/dist/_chunks/index4.d.mts +62 -0
  31. package/dist/_chunks/index5.d.mts +42 -0
  32. package/dist/_chunks/index6.d.mts +43 -0
  33. package/dist/{shared/core.OtRNdMxy.d.mts → _chunks/index7.d.mts} +113 -197
  34. package/dist/_chunks/index8.d.mts +144 -0
  35. package/dist/_chunks/invariant.mjs +18 -0
  36. package/dist/_chunks/iterable.mjs +146 -0
  37. package/dist/_chunks/libs/@mantine/colors-generator.mjs +3416 -0
  38. package/dist/_chunks/libs/@ungap/structured-clone.mjs +213 -0
  39. package/dist/_chunks/libs/bail.mjs +14 -0
  40. package/dist/_chunks/libs/ccount.mjs +25 -0
  41. package/dist/_chunks/libs/character-entities-html4.mjs +263 -0
  42. package/dist/_chunks/libs/character-entities-legacy.mjs +117 -0
  43. package/dist/_chunks/libs/character-entities.mjs +2136 -0
  44. package/dist/_chunks/libs/comma-separated-tokens.mjs +18 -0
  45. package/dist/_chunks/libs/decode-named-character-reference.mjs +21 -0
  46. package/dist/_chunks/libs/defu.mjs +42 -0
  47. package/dist/_chunks/libs/devlop.mjs +5 -0
  48. package/dist/_chunks/libs/escape-string-regexp.mjs +8 -0
  49. package/dist/_chunks/libs/extend.mjs +77 -0
  50. package/dist/_chunks/libs/graphology-dag.mjs +703 -0
  51. package/dist/_chunks/libs/graphology-types.d.mts +601 -0
  52. package/dist/_chunks/libs/graphology.d.mts +6 -0
  53. package/dist/_chunks/libs/graphology.mjs +4565 -0
  54. package/dist/_chunks/libs/hast-util-sanitize.mjs +863 -0
  55. package/dist/_chunks/libs/hast-util-to-html.mjs +2696 -0
  56. package/dist/_chunks/libs/is-plain-obj.mjs +9 -0
  57. package/dist/_chunks/libs/longest-streak.mjs +30 -0
  58. package/dist/_chunks/libs/markdown-table.mjs +290 -0
  59. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +653 -0
  60. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +8522 -0
  61. package/dist/_chunks/libs/mdast-util-gfm.mjs +2393 -0
  62. package/dist/_chunks/libs/mdast-util-to-hast.mjs +1803 -0
  63. package/dist/_chunks/libs/micromark-extension-gfm.mjs +2243 -0
  64. package/dist/_chunks/libs/mnemonist.d.mts +254 -0
  65. package/dist/_chunks/libs/mnemonist.mjs +1978 -0
  66. package/dist/_chunks/libs/natural-compare-lite.mjs +42 -0
  67. package/dist/_chunks/libs/rehype-sanitize.mjs +29 -0
  68. package/dist/_chunks/libs/rehype-stringify.mjs +34 -0
  69. package/dist/_chunks/libs/remark-gfm.mjs +36 -0
  70. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +100 -0
  71. package/dist/_chunks/libs/remark-parse.mjs +39 -0
  72. package/dist/_chunks/libs/remark-rehype.mjs +171 -0
  73. package/dist/_chunks/libs/remeda.mjs +702 -0
  74. package/dist/_chunks/libs/trough.mjs +158 -0
  75. package/dist/_chunks/libs/unified.mjs +2212 -0
  76. package/dist/_chunks/mnemonist.d.mts +1 -0
  77. package/dist/_chunks/mnemonist.mjs +0 -0
  78. package/dist/_chunks/model.mjs +1898 -0
  79. package/dist/_chunks/model2.mjs +0 -0
  80. package/dist/_chunks/relationships-view.mjs +132 -0
  81. package/dist/_chunks/rolldown-runtime.mjs +42 -0
  82. package/dist/{shared/core.C_3y3eqV.d.mts → _chunks/scalar.d.mts} +13 -43
  83. package/dist/_chunks/scalar.mjs +84 -0
  84. package/dist/_chunks/utils.mjs +483 -0
  85. package/dist/builder/index.d.mts +11 -773
  86. package/dist/builder/index.mjs +631 -978
  87. package/dist/compute-view/index.d.mts +90 -27
  88. package/dist/compute-view/index.mjs +253 -83
  89. package/dist/compute-view/relationships-view/index.d.mts +16 -51
  90. package/dist/compute-view/relationships-view/index.mjs +6 -184
  91. package/dist/geometry/index.d.mts +2 -109
  92. package/dist/geometry/index.mjs +2 -327
  93. package/dist/index.d.mts +18 -20
  94. package/dist/index.mjs +27 -18
  95. package/dist/model/connection/deployment/index.d.mts +12 -15
  96. package/dist/model/connection/deployment/index.mjs +9 -2
  97. package/dist/model/connection/index.d.mts +14 -75
  98. package/dist/model/connection/index.mjs +10 -3
  99. package/dist/model/connection/model/index.d.mts +12 -15
  100. package/dist/model/connection/model/index.mjs +8 -2
  101. package/dist/model/index.d.mts +15 -57
  102. package/dist/model/index.mjs +11 -4
  103. package/dist/styles/index.d.mts +9 -117
  104. package/dist/styles/index.mjs +26 -59
  105. package/dist/types/RichText.d.mts +3 -0
  106. package/dist/types/RichText.mjs +7 -0
  107. package/dist/types/_aux.d.mts +3 -4
  108. package/dist/types/_aux.mjs +2 -7
  109. package/dist/types/expression-model.d.mts +6 -190
  110. package/dist/types/expression-model.mjs +6 -108
  111. package/dist/types/expression.d.mts +5 -6
  112. package/dist/types/expression.mjs +6 -112
  113. package/dist/types/fqnRef.d.mts +4 -60
  114. package/dist/types/fqnRef.mjs +6 -44
  115. package/dist/types/index.d.mts +9 -47
  116. package/dist/types/index.mjs +14 -16
  117. package/dist/types/scalar.d.mts +2 -2
  118. package/dist/types/scalar.mjs +7 -4
  119. package/dist/utils/graphology/index.d.mts +2 -1864
  120. package/dist/utils/graphology/index.mjs +3 -1
  121. package/dist/utils/index.d.mts +11 -124
  122. package/dist/utils/index.mjs +16 -43
  123. package/dist/utils/iterable/index.d.mts +9 -132
  124. package/dist/utils/iterable/index.mjs +2 -61
  125. package/dist/utils/mnemonist.d.mts +2 -0
  126. package/dist/utils/mnemonist.mjs +12 -0
  127. package/package.json +18 -22
  128. package/compute-view/relationships/package.json +0 -4
  129. package/dist/shared/core.3ZhnKAlZ.mjs +0 -106
  130. package/dist/shared/core.78IWAHAE.mjs +0 -332
  131. package/dist/shared/core.B85MJLTf.mjs +0 -5
  132. package/dist/shared/core.BFd1lU9R.mjs +0 -29
  133. package/dist/shared/core.BKlholso.mjs +0 -3
  134. package/dist/shared/core.BPGOjone.d.mts +0 -46
  135. package/dist/shared/core.BYdtmqY5.mjs +0 -1255
  136. package/dist/shared/core.BZCgljZd.d.mts +0 -83
  137. package/dist/shared/core.BbE4y-yl.mjs +0 -177
  138. package/dist/shared/core.BhNcrwzK.mjs +0 -7
  139. package/dist/shared/core.BkVA6gjl.mjs +0 -5
  140. package/dist/shared/core.BoYfZOBm.mjs +0 -3
  141. package/dist/shared/core.BsSXS-_R.mjs +0 -7
  142. package/dist/shared/core.BspBF3SJ.mjs +0 -3944
  143. package/dist/shared/core.BvPm_-u3.d.mts +0 -334
  144. package/dist/shared/core.C-Jdx7xo.d.mts +0 -1263
  145. package/dist/shared/core.C3JowhaZ.mjs +0 -32
  146. package/dist/shared/core.C4x8aaWa.mjs +0 -27
  147. package/dist/shared/core.CBLX4mT8.mjs +0 -28411
  148. package/dist/shared/core.CLSZtnFh.mjs +0 -69
  149. package/dist/shared/core.CRhT4Iio.mjs +0 -785
  150. package/dist/shared/core.CbT8JVYL.mjs +0 -5
  151. package/dist/shared/core.CdNCAwq7.mjs +0 -176
  152. package/dist/shared/core.ClTP6-TN.d.mts +0 -87
  153. package/dist/shared/core.CmGY9blO.mjs +0 -6717
  154. package/dist/shared/core.CmPXpJ8l.mjs +0 -21
  155. package/dist/shared/core.Coi_LOUZ.mjs +0 -7
  156. package/dist/shared/core.CqAJJpK_.mjs +0 -3
  157. package/dist/shared/core.Ctj2S3bD.d.mts +0 -466
  158. package/dist/shared/core.CywrQs86.d.mts +0 -31
  159. package/dist/shared/core.D00YbOhQ.d.mts +0 -300
  160. package/dist/shared/core.D0WZutNd.mjs +0 -94
  161. package/dist/shared/core.D4npX2q8.mjs +0 -18
  162. package/dist/shared/core.DB0Ue5Wx.d.mts +0 -70
  163. package/dist/shared/core.DEK-BO3_.mjs +0 -1206
  164. package/dist/shared/core.DH7TXqXf.mjs +0 -136
  165. package/dist/shared/core.DRJma0Ol.mjs +0 -22
  166. package/dist/shared/core.DSalPD6v.mjs +0 -1352
  167. package/dist/shared/core.DVfPJPJj.mjs +0 -2200
  168. package/dist/shared/core.DXhDWKFZ.d.mts +0 -3
  169. package/dist/shared/core.DbfO90vF.mjs +0 -434
  170. package/dist/shared/core.DcS-0zys.mjs +0 -10
  171. package/dist/shared/core.DeDCYTDR.d.mts +0 -98
  172. package/dist/shared/core.DpKY_3NF.d.mts +0 -504
  173. package/dist/shared/core.Dt0v3djy.d.mts +0 -41
  174. package/dist/shared/core.FZ305VYd.mjs +0 -21
  175. package/dist/shared/core.RfnaEmgA.mjs +0 -7
  176. package/dist/shared/core.oSV6SRfk.mjs +0 -13
  177. package/dist/shared/core.om36dXXW.mjs +0 -41
  178. package/dist/shared/core.q10OP9oJ.mjs +0 -5
  179. package/dist/shared/core.uFk_o9X6.mjs +0 -13
  180. package/dist/shared/core.xeuDd__E.mjs +0 -300
  181. package/dist/shared/core.xgoPk2RG.mjs +0 -4989
@@ -0,0 +1,1803 @@
1
+ import { t as esm_default } from "./@ungap/structured-clone.mjs";
2
+ import { a as position, i as pointStart, r as pointEnd } from "./hast-util-sanitize.mjs";
3
+ import { t as ok } from "./devlop.mjs";
4
+ import { f as asciiAlphanumeric } from "./mdast-util-from-markdown.mjs";
5
+ import { r as visit } from "./mdast-util-gfm.mjs";
6
+
7
+ //#region ../../node_modules/.pnpm/micromark-util-sanitize-uri@2.0.1/node_modules/micromark-util-sanitize-uri/index.js
8
+ /**
9
+ * Normalize a URL.
10
+ *
11
+ * Encode unsafe characters with percent-encoding, skipping already encoded
12
+ * sequences.
13
+ *
14
+ * @param {string} value
15
+ * URI to normalize.
16
+ * @returns {string}
17
+ * Normalized URI.
18
+ */
19
+ function normalizeUri(value) {
20
+ /** @type {Array<string>} */
21
+ const result = [];
22
+ let index = -1;
23
+ let start = 0;
24
+ let skip = 0;
25
+ while (++index < value.length) {
26
+ const code = value.charCodeAt(index);
27
+ /** @type {string} */
28
+ let replace = "";
29
+ if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) skip = 2;
30
+ else if (code < 128) {
31
+ if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) replace = String.fromCharCode(code);
32
+ } else if (code > 55295 && code < 57344) {
33
+ const next = value.charCodeAt(index + 1);
34
+ if (code < 56320 && next > 56319 && next < 57344) {
35
+ replace = String.fromCharCode(code, next);
36
+ skip = 1;
37
+ } else replace = "�";
38
+ } else replace = String.fromCharCode(code);
39
+ if (replace) {
40
+ result.push(value.slice(start, index), encodeURIComponent(replace));
41
+ start = index + skip + 1;
42
+ replace = "";
43
+ }
44
+ if (skip) {
45
+ index += skip;
46
+ skip = 0;
47
+ }
48
+ }
49
+ return result.join("") + value.slice(start);
50
+ }
51
+
52
+ //#endregion
53
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
54
+ /**
55
+ * @import {Element} from 'hast'
56
+ * @import {Blockquote} from 'mdast'
57
+ * @import {State} from '../state.js'
58
+ */
59
+ /**
60
+ * Turn an mdast `blockquote` node into hast.
61
+ *
62
+ * @param {State} state
63
+ * Info passed around.
64
+ * @param {Blockquote} node
65
+ * mdast node.
66
+ * @returns {Element}
67
+ * hast node.
68
+ */
69
+ function blockquote(state, node) {
70
+ /** @type {Element} */
71
+ const result = {
72
+ type: "element",
73
+ tagName: "blockquote",
74
+ properties: {},
75
+ children: state.wrap(state.all(node), true)
76
+ };
77
+ state.patch(node, result);
78
+ return state.applyData(node, result);
79
+ }
80
+
81
+ //#endregion
82
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/break.js
83
+ /**
84
+ * @import {Element, Text} from 'hast'
85
+ * @import {Break} from 'mdast'
86
+ * @import {State} from '../state.js'
87
+ */
88
+ /**
89
+ * Turn an mdast `break` node into hast.
90
+ *
91
+ * @param {State} state
92
+ * Info passed around.
93
+ * @param {Break} node
94
+ * mdast node.
95
+ * @returns {Array<Element | Text>}
96
+ * hast element content.
97
+ */
98
+ function hardBreak(state, node) {
99
+ /** @type {Element} */
100
+ const result = {
101
+ type: "element",
102
+ tagName: "br",
103
+ properties: {},
104
+ children: []
105
+ };
106
+ state.patch(node, result);
107
+ return [state.applyData(node, result), {
108
+ type: "text",
109
+ value: "\n"
110
+ }];
111
+ }
112
+
113
+ //#endregion
114
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/code.js
115
+ /**
116
+ * @import {Element, Properties} from 'hast'
117
+ * @import {Code} from 'mdast'
118
+ * @import {State} from '../state.js'
119
+ */
120
+ /**
121
+ * Turn an mdast `code` node into hast.
122
+ *
123
+ * @param {State} state
124
+ * Info passed around.
125
+ * @param {Code} node
126
+ * mdast node.
127
+ * @returns {Element}
128
+ * hast node.
129
+ */
130
+ function code(state, node) {
131
+ const value = node.value ? node.value + "\n" : "";
132
+ /** @type {Properties} */
133
+ const properties = {};
134
+ const language = node.lang ? node.lang.split(/\s+/) : [];
135
+ if (language.length > 0) properties.className = ["language-" + language[0]];
136
+ /** @type {Element} */
137
+ let result = {
138
+ type: "element",
139
+ tagName: "code",
140
+ properties,
141
+ children: [{
142
+ type: "text",
143
+ value
144
+ }]
145
+ };
146
+ if (node.meta) result.data = { meta: node.meta };
147
+ state.patch(node, result);
148
+ result = state.applyData(node, result);
149
+ result = {
150
+ type: "element",
151
+ tagName: "pre",
152
+ properties: {},
153
+ children: [result]
154
+ };
155
+ state.patch(node, result);
156
+ return result;
157
+ }
158
+
159
+ //#endregion
160
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/delete.js
161
+ /**
162
+ * @import {Element} from 'hast'
163
+ * @import {Delete} from 'mdast'
164
+ * @import {State} from '../state.js'
165
+ */
166
+ /**
167
+ * Turn an mdast `delete` node into hast.
168
+ *
169
+ * @param {State} state
170
+ * Info passed around.
171
+ * @param {Delete} node
172
+ * mdast node.
173
+ * @returns {Element}
174
+ * hast node.
175
+ */
176
+ function strikethrough(state, node) {
177
+ /** @type {Element} */
178
+ const result = {
179
+ type: "element",
180
+ tagName: "del",
181
+ properties: {},
182
+ children: state.all(node)
183
+ };
184
+ state.patch(node, result);
185
+ return state.applyData(node, result);
186
+ }
187
+
188
+ //#endregion
189
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/emphasis.js
190
+ /**
191
+ * @import {Element} from 'hast'
192
+ * @import {Emphasis} from 'mdast'
193
+ * @import {State} from '../state.js'
194
+ */
195
+ /**
196
+ * Turn an mdast `emphasis` node into hast.
197
+ *
198
+ * @param {State} state
199
+ * Info passed around.
200
+ * @param {Emphasis} node
201
+ * mdast node.
202
+ * @returns {Element}
203
+ * hast node.
204
+ */
205
+ function emphasis(state, node) {
206
+ /** @type {Element} */
207
+ const result = {
208
+ type: "element",
209
+ tagName: "em",
210
+ properties: {},
211
+ children: state.all(node)
212
+ };
213
+ state.patch(node, result);
214
+ return state.applyData(node, result);
215
+ }
216
+
217
+ //#endregion
218
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js
219
+ /**
220
+ * @import {Element} from 'hast'
221
+ * @import {FootnoteReference} from 'mdast'
222
+ * @import {State} from '../state.js'
223
+ */
224
+ /**
225
+ * Turn an mdast `footnoteReference` node into hast.
226
+ *
227
+ * @param {State} state
228
+ * Info passed around.
229
+ * @param {FootnoteReference} node
230
+ * mdast node.
231
+ * @returns {Element}
232
+ * hast node.
233
+ */
234
+ function footnoteReference(state, node) {
235
+ const clobberPrefix = typeof state.options.clobberPrefix === "string" ? state.options.clobberPrefix : "user-content-";
236
+ const id = String(node.identifier).toUpperCase();
237
+ const safeId = normalizeUri(id.toLowerCase());
238
+ const index = state.footnoteOrder.indexOf(id);
239
+ /** @type {number} */
240
+ let counter;
241
+ let reuseCounter = state.footnoteCounts.get(id);
242
+ if (reuseCounter === void 0) {
243
+ reuseCounter = 0;
244
+ state.footnoteOrder.push(id);
245
+ counter = state.footnoteOrder.length;
246
+ } else counter = index + 1;
247
+ reuseCounter += 1;
248
+ state.footnoteCounts.set(id, reuseCounter);
249
+ /** @type {Element} */
250
+ const link = {
251
+ type: "element",
252
+ tagName: "a",
253
+ properties: {
254
+ href: "#" + clobberPrefix + "fn-" + safeId,
255
+ id: clobberPrefix + "fnref-" + safeId + (reuseCounter > 1 ? "-" + reuseCounter : ""),
256
+ dataFootnoteRef: true,
257
+ ariaDescribedBy: ["footnote-label"]
258
+ },
259
+ children: [{
260
+ type: "text",
261
+ value: String(counter)
262
+ }]
263
+ };
264
+ state.patch(node, link);
265
+ /** @type {Element} */
266
+ const sup = {
267
+ type: "element",
268
+ tagName: "sup",
269
+ properties: {},
270
+ children: [link]
271
+ };
272
+ state.patch(node, sup);
273
+ return state.applyData(node, sup);
274
+ }
275
+
276
+ //#endregion
277
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/heading.js
278
+ /**
279
+ * @import {Element} from 'hast'
280
+ * @import {Heading} from 'mdast'
281
+ * @import {State} from '../state.js'
282
+ */
283
+ /**
284
+ * Turn an mdast `heading` node into hast.
285
+ *
286
+ * @param {State} state
287
+ * Info passed around.
288
+ * @param {Heading} node
289
+ * mdast node.
290
+ * @returns {Element}
291
+ * hast node.
292
+ */
293
+ function heading(state, node) {
294
+ /** @type {Element} */
295
+ const result = {
296
+ type: "element",
297
+ tagName: "h" + node.depth,
298
+ properties: {},
299
+ children: state.all(node)
300
+ };
301
+ state.patch(node, result);
302
+ return state.applyData(node, result);
303
+ }
304
+
305
+ //#endregion
306
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/html.js
307
+ /**
308
+ * @import {Element} from 'hast'
309
+ * @import {Html} from 'mdast'
310
+ * @import {State} from '../state.js'
311
+ * @import {Raw} from '../../index.js'
312
+ */
313
+ /**
314
+ * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise
315
+ * nothing).
316
+ *
317
+ * @param {State} state
318
+ * Info passed around.
319
+ * @param {Html} node
320
+ * mdast node.
321
+ * @returns {Element | Raw | undefined}
322
+ * hast node.
323
+ */
324
+ function html(state, node) {
325
+ if (state.options.allowDangerousHtml) {
326
+ /** @type {Raw} */
327
+ const result = {
328
+ type: "raw",
329
+ value: node.value
330
+ };
331
+ state.patch(node, result);
332
+ return state.applyData(node, result);
333
+ }
334
+ }
335
+
336
+ //#endregion
337
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/revert.js
338
+ /**
339
+ * @import {ElementContent} from 'hast'
340
+ * @import {Reference, Nodes} from 'mdast'
341
+ * @import {State} from './state.js'
342
+ */
343
+ /**
344
+ * Return the content of a reference without definition as plain text.
345
+ *
346
+ * @param {State} state
347
+ * Info passed around.
348
+ * @param {Extract<Nodes, Reference>} node
349
+ * Reference node (image, link).
350
+ * @returns {Array<ElementContent>}
351
+ * hast content.
352
+ */
353
+ function revert(state, node) {
354
+ const subtype = node.referenceType;
355
+ let suffix = "]";
356
+ if (subtype === "collapsed") suffix += "[]";
357
+ else if (subtype === "full") suffix += "[" + (node.label || node.identifier) + "]";
358
+ if (node.type === "imageReference") return [{
359
+ type: "text",
360
+ value: "![" + node.alt + suffix
361
+ }];
362
+ const contents = state.all(node);
363
+ const head = contents[0];
364
+ if (head && head.type === "text") head.value = "[" + head.value;
365
+ else contents.unshift({
366
+ type: "text",
367
+ value: "["
368
+ });
369
+ const tail = contents[contents.length - 1];
370
+ if (tail && tail.type === "text") tail.value += suffix;
371
+ else contents.push({
372
+ type: "text",
373
+ value: suffix
374
+ });
375
+ return contents;
376
+ }
377
+
378
+ //#endregion
379
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/image-reference.js
380
+ /**
381
+ * @import {ElementContent, Element, Properties} from 'hast'
382
+ * @import {ImageReference} from 'mdast'
383
+ * @import {State} from '../state.js'
384
+ */
385
+ /**
386
+ * Turn an mdast `imageReference` node into hast.
387
+ *
388
+ * @param {State} state
389
+ * Info passed around.
390
+ * @param {ImageReference} node
391
+ * mdast node.
392
+ * @returns {Array<ElementContent> | ElementContent}
393
+ * hast node.
394
+ */
395
+ function imageReference(state, node) {
396
+ const id = String(node.identifier).toUpperCase();
397
+ const definition = state.definitionById.get(id);
398
+ if (!definition) return revert(state, node);
399
+ /** @type {Properties} */
400
+ const properties = {
401
+ src: normalizeUri(definition.url || ""),
402
+ alt: node.alt
403
+ };
404
+ if (definition.title !== null && definition.title !== void 0) properties.title = definition.title;
405
+ /** @type {Element} */
406
+ const result = {
407
+ type: "element",
408
+ tagName: "img",
409
+ properties,
410
+ children: []
411
+ };
412
+ state.patch(node, result);
413
+ return state.applyData(node, result);
414
+ }
415
+
416
+ //#endregion
417
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/image.js
418
+ /**
419
+ * @import {Element, Properties} from 'hast'
420
+ * @import {Image} from 'mdast'
421
+ * @import {State} from '../state.js'
422
+ */
423
+ /**
424
+ * Turn an mdast `image` node into hast.
425
+ *
426
+ * @param {State} state
427
+ * Info passed around.
428
+ * @param {Image} node
429
+ * mdast node.
430
+ * @returns {Element}
431
+ * hast node.
432
+ */
433
+ function image(state, node) {
434
+ /** @type {Properties} */
435
+ const properties = { src: normalizeUri(node.url) };
436
+ if (node.alt !== null && node.alt !== void 0) properties.alt = node.alt;
437
+ if (node.title !== null && node.title !== void 0) properties.title = node.title;
438
+ /** @type {Element} */
439
+ const result = {
440
+ type: "element",
441
+ tagName: "img",
442
+ properties,
443
+ children: []
444
+ };
445
+ state.patch(node, result);
446
+ return state.applyData(node, result);
447
+ }
448
+
449
+ //#endregion
450
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/inline-code.js
451
+ /**
452
+ * @import {Element, Text} from 'hast'
453
+ * @import {InlineCode} from 'mdast'
454
+ * @import {State} from '../state.js'
455
+ */
456
+ /**
457
+ * Turn an mdast `inlineCode` node into hast.
458
+ *
459
+ * @param {State} state
460
+ * Info passed around.
461
+ * @param {InlineCode} node
462
+ * mdast node.
463
+ * @returns {Element}
464
+ * hast node.
465
+ */
466
+ function inlineCode(state, node) {
467
+ /** @type {Text} */
468
+ const text = {
469
+ type: "text",
470
+ value: node.value.replace(/\r?\n|\r/g, " ")
471
+ };
472
+ state.patch(node, text);
473
+ /** @type {Element} */
474
+ const result = {
475
+ type: "element",
476
+ tagName: "code",
477
+ properties: {},
478
+ children: [text]
479
+ };
480
+ state.patch(node, result);
481
+ return state.applyData(node, result);
482
+ }
483
+
484
+ //#endregion
485
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
486
+ /**
487
+ * @import {ElementContent, Element, Properties} from 'hast'
488
+ * @import {LinkReference} from 'mdast'
489
+ * @import {State} from '../state.js'
490
+ */
491
+ /**
492
+ * Turn an mdast `linkReference` node into hast.
493
+ *
494
+ * @param {State} state
495
+ * Info passed around.
496
+ * @param {LinkReference} node
497
+ * mdast node.
498
+ * @returns {Array<ElementContent> | ElementContent}
499
+ * hast node.
500
+ */
501
+ function linkReference(state, node) {
502
+ const id = String(node.identifier).toUpperCase();
503
+ const definition = state.definitionById.get(id);
504
+ if (!definition) return revert(state, node);
505
+ /** @type {Properties} */
506
+ const properties = { href: normalizeUri(definition.url || "") };
507
+ if (definition.title !== null && definition.title !== void 0) properties.title = definition.title;
508
+ /** @type {Element} */
509
+ const result = {
510
+ type: "element",
511
+ tagName: "a",
512
+ properties,
513
+ children: state.all(node)
514
+ };
515
+ state.patch(node, result);
516
+ return state.applyData(node, result);
517
+ }
518
+
519
+ //#endregion
520
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/link.js
521
+ /**
522
+ * @import {Element, Properties} from 'hast'
523
+ * @import {Link} from 'mdast'
524
+ * @import {State} from '../state.js'
525
+ */
526
+ /**
527
+ * Turn an mdast `link` node into hast.
528
+ *
529
+ * @param {State} state
530
+ * Info passed around.
531
+ * @param {Link} node
532
+ * mdast node.
533
+ * @returns {Element}
534
+ * hast node.
535
+ */
536
+ function link(state, node) {
537
+ /** @type {Properties} */
538
+ const properties = { href: normalizeUri(node.url) };
539
+ if (node.title !== null && node.title !== void 0) properties.title = node.title;
540
+ /** @type {Element} */
541
+ const result = {
542
+ type: "element",
543
+ tagName: "a",
544
+ properties,
545
+ children: state.all(node)
546
+ };
547
+ state.patch(node, result);
548
+ return state.applyData(node, result);
549
+ }
550
+
551
+ //#endregion
552
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/list-item.js
553
+ /**
554
+ * @import {ElementContent, Element, Properties} from 'hast'
555
+ * @import {ListItem, Parents} from 'mdast'
556
+ * @import {State} from '../state.js'
557
+ */
558
+ /**
559
+ * Turn an mdast `listItem` node into hast.
560
+ *
561
+ * @param {State} state
562
+ * Info passed around.
563
+ * @param {ListItem} node
564
+ * mdast node.
565
+ * @param {Parents | undefined} parent
566
+ * Parent of `node`.
567
+ * @returns {Element}
568
+ * hast node.
569
+ */
570
+ function listItem(state, node, parent) {
571
+ const results = state.all(node);
572
+ const loose = parent ? listLoose(parent) : listItemLoose(node);
573
+ /** @type {Properties} */
574
+ const properties = {};
575
+ /** @type {Array<ElementContent>} */
576
+ const children = [];
577
+ if (typeof node.checked === "boolean") {
578
+ const head = results[0];
579
+ /** @type {Element} */
580
+ let paragraph;
581
+ if (head && head.type === "element" && head.tagName === "p") paragraph = head;
582
+ else {
583
+ paragraph = {
584
+ type: "element",
585
+ tagName: "p",
586
+ properties: {},
587
+ children: []
588
+ };
589
+ results.unshift(paragraph);
590
+ }
591
+ if (paragraph.children.length > 0) paragraph.children.unshift({
592
+ type: "text",
593
+ value: " "
594
+ });
595
+ paragraph.children.unshift({
596
+ type: "element",
597
+ tagName: "input",
598
+ properties: {
599
+ type: "checkbox",
600
+ checked: node.checked,
601
+ disabled: true
602
+ },
603
+ children: []
604
+ });
605
+ properties.className = ["task-list-item"];
606
+ }
607
+ let index = -1;
608
+ while (++index < results.length) {
609
+ const child = results[index];
610
+ if (loose || index !== 0 || child.type !== "element" || child.tagName !== "p") children.push({
611
+ type: "text",
612
+ value: "\n"
613
+ });
614
+ if (child.type === "element" && child.tagName === "p" && !loose) children.push(...child.children);
615
+ else children.push(child);
616
+ }
617
+ const tail = results[results.length - 1];
618
+ if (tail && (loose || tail.type !== "element" || tail.tagName !== "p")) children.push({
619
+ type: "text",
620
+ value: "\n"
621
+ });
622
+ /** @type {Element} */
623
+ const result = {
624
+ type: "element",
625
+ tagName: "li",
626
+ properties,
627
+ children
628
+ };
629
+ state.patch(node, result);
630
+ return state.applyData(node, result);
631
+ }
632
+ /**
633
+ * @param {Parents} node
634
+ * @return {Boolean}
635
+ */
636
+ function listLoose(node) {
637
+ let loose = false;
638
+ if (node.type === "list") {
639
+ loose = node.spread || false;
640
+ const children = node.children;
641
+ let index = -1;
642
+ while (!loose && ++index < children.length) loose = listItemLoose(children[index]);
643
+ }
644
+ return loose;
645
+ }
646
+ /**
647
+ * @param {ListItem} node
648
+ * @return {Boolean}
649
+ */
650
+ function listItemLoose(node) {
651
+ const spread = node.spread;
652
+ return spread === null || spread === void 0 ? node.children.length > 1 : spread;
653
+ }
654
+
655
+ //#endregion
656
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/list.js
657
+ /**
658
+ * @import {Element, Properties} from 'hast'
659
+ * @import {List} from 'mdast'
660
+ * @import {State} from '../state.js'
661
+ */
662
+ /**
663
+ * Turn an mdast `list` node into hast.
664
+ *
665
+ * @param {State} state
666
+ * Info passed around.
667
+ * @param {List} node
668
+ * mdast node.
669
+ * @returns {Element}
670
+ * hast node.
671
+ */
672
+ function list(state, node) {
673
+ /** @type {Properties} */
674
+ const properties = {};
675
+ const results = state.all(node);
676
+ let index = -1;
677
+ if (typeof node.start === "number" && node.start !== 1) properties.start = node.start;
678
+ while (++index < results.length) {
679
+ const child = results[index];
680
+ if (child.type === "element" && child.tagName === "li" && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes("task-list-item")) {
681
+ properties.className = ["contains-task-list"];
682
+ break;
683
+ }
684
+ }
685
+ /** @type {Element} */
686
+ const result = {
687
+ type: "element",
688
+ tagName: node.ordered ? "ol" : "ul",
689
+ properties,
690
+ children: state.wrap(results, true)
691
+ };
692
+ state.patch(node, result);
693
+ return state.applyData(node, result);
694
+ }
695
+
696
+ //#endregion
697
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
698
+ /**
699
+ * @import {Element} from 'hast'
700
+ * @import {Paragraph} from 'mdast'
701
+ * @import {State} from '../state.js'
702
+ */
703
+ /**
704
+ * Turn an mdast `paragraph` node into hast.
705
+ *
706
+ * @param {State} state
707
+ * Info passed around.
708
+ * @param {Paragraph} node
709
+ * mdast node.
710
+ * @returns {Element}
711
+ * hast node.
712
+ */
713
+ function paragraph(state, node) {
714
+ /** @type {Element} */
715
+ const result = {
716
+ type: "element",
717
+ tagName: "p",
718
+ properties: {},
719
+ children: state.all(node)
720
+ };
721
+ state.patch(node, result);
722
+ return state.applyData(node, result);
723
+ }
724
+
725
+ //#endregion
726
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/root.js
727
+ /**
728
+ * @import {Parents as HastParents, Root as HastRoot} from 'hast'
729
+ * @import {Root as MdastRoot} from 'mdast'
730
+ * @import {State} from '../state.js'
731
+ */
732
+ /**
733
+ * Turn an mdast `root` node into hast.
734
+ *
735
+ * @param {State} state
736
+ * Info passed around.
737
+ * @param {MdastRoot} node
738
+ * mdast node.
739
+ * @returns {HastParents}
740
+ * hast node.
741
+ */
742
+ function root(state, node) {
743
+ /** @type {HastRoot} */
744
+ const result = {
745
+ type: "root",
746
+ children: state.wrap(state.all(node))
747
+ };
748
+ state.patch(node, result);
749
+ return state.applyData(node, result);
750
+ }
751
+
752
+ //#endregion
753
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/strong.js
754
+ /**
755
+ * @import {Element} from 'hast'
756
+ * @import {Strong} from 'mdast'
757
+ * @import {State} from '../state.js'
758
+ */
759
+ /**
760
+ * Turn an mdast `strong` node into hast.
761
+ *
762
+ * @param {State} state
763
+ * Info passed around.
764
+ * @param {Strong} node
765
+ * mdast node.
766
+ * @returns {Element}
767
+ * hast node.
768
+ */
769
+ function strong(state, node) {
770
+ /** @type {Element} */
771
+ const result = {
772
+ type: "element",
773
+ tagName: "strong",
774
+ properties: {},
775
+ children: state.all(node)
776
+ };
777
+ state.patch(node, result);
778
+ return state.applyData(node, result);
779
+ }
780
+
781
+ //#endregion
782
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/table.js
783
+ /**
784
+ * @import {Table} from 'mdast'
785
+ * @import {Element} from 'hast'
786
+ * @import {State} from '../state.js'
787
+ */
788
+ /**
789
+ * Turn an mdast `table` node into hast.
790
+ *
791
+ * @param {State} state
792
+ * Info passed around.
793
+ * @param {Table} node
794
+ * mdast node.
795
+ * @returns {Element}
796
+ * hast node.
797
+ */
798
+ function table(state, node) {
799
+ const rows = state.all(node);
800
+ const firstRow = rows.shift();
801
+ /** @type {Array<Element>} */
802
+ const tableContent = [];
803
+ if (firstRow) {
804
+ /** @type {Element} */
805
+ const head = {
806
+ type: "element",
807
+ tagName: "thead",
808
+ properties: {},
809
+ children: state.wrap([firstRow], true)
810
+ };
811
+ state.patch(node.children[0], head);
812
+ tableContent.push(head);
813
+ }
814
+ if (rows.length > 0) {
815
+ /** @type {Element} */
816
+ const body = {
817
+ type: "element",
818
+ tagName: "tbody",
819
+ properties: {},
820
+ children: state.wrap(rows, true)
821
+ };
822
+ const start = pointStart(node.children[1]);
823
+ const end = pointEnd(node.children[node.children.length - 1]);
824
+ if (start && end) body.position = {
825
+ start,
826
+ end
827
+ };
828
+ tableContent.push(body);
829
+ }
830
+ /** @type {Element} */
831
+ const result = {
832
+ type: "element",
833
+ tagName: "table",
834
+ properties: {},
835
+ children: state.wrap(tableContent, true)
836
+ };
837
+ state.patch(node, result);
838
+ return state.applyData(node, result);
839
+ }
840
+
841
+ //#endregion
842
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/table-row.js
843
+ /**
844
+ * @import {Element, ElementContent, Properties} from 'hast'
845
+ * @import {Parents, TableRow} from 'mdast'
846
+ * @import {State} from '../state.js'
847
+ */
848
+ /**
849
+ * Turn an mdast `tableRow` node into hast.
850
+ *
851
+ * @param {State} state
852
+ * Info passed around.
853
+ * @param {TableRow} node
854
+ * mdast node.
855
+ * @param {Parents | undefined} parent
856
+ * Parent of `node`.
857
+ * @returns {Element}
858
+ * hast node.
859
+ */
860
+ function tableRow(state, node, parent) {
861
+ const siblings = parent ? parent.children : void 0;
862
+ const tagName = (siblings ? siblings.indexOf(node) : 1) === 0 ? "th" : "td";
863
+ const align = parent && parent.type === "table" ? parent.align : void 0;
864
+ const length = align ? align.length : node.children.length;
865
+ let cellIndex = -1;
866
+ /** @type {Array<ElementContent>} */
867
+ const cells = [];
868
+ while (++cellIndex < length) {
869
+ const cell = node.children[cellIndex];
870
+ /** @type {Properties} */
871
+ const properties = {};
872
+ const alignValue = align ? align[cellIndex] : void 0;
873
+ if (alignValue) properties.align = alignValue;
874
+ /** @type {Element} */
875
+ let result = {
876
+ type: "element",
877
+ tagName,
878
+ properties,
879
+ children: []
880
+ };
881
+ if (cell) {
882
+ result.children = state.all(cell);
883
+ state.patch(cell, result);
884
+ result = state.applyData(cell, result);
885
+ }
886
+ cells.push(result);
887
+ }
888
+ /** @type {Element} */
889
+ const result = {
890
+ type: "element",
891
+ tagName: "tr",
892
+ properties: {},
893
+ children: state.wrap(cells, true)
894
+ };
895
+ state.patch(node, result);
896
+ return state.applyData(node, result);
897
+ }
898
+
899
+ //#endregion
900
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/table-cell.js
901
+ /**
902
+ * @import {Element} from 'hast'
903
+ * @import {TableCell} from 'mdast'
904
+ * @import {State} from '../state.js'
905
+ */
906
+ /**
907
+ * Turn an mdast `tableCell` node into hast.
908
+ *
909
+ * @param {State} state
910
+ * Info passed around.
911
+ * @param {TableCell} node
912
+ * mdast node.
913
+ * @returns {Element}
914
+ * hast node.
915
+ */
916
+ function tableCell(state, node) {
917
+ /** @type {Element} */
918
+ const result = {
919
+ type: "element",
920
+ tagName: "td",
921
+ properties: {},
922
+ children: state.all(node)
923
+ };
924
+ state.patch(node, result);
925
+ return state.applyData(node, result);
926
+ }
927
+
928
+ //#endregion
929
+ //#region ../../node_modules/.pnpm/trim-lines@3.0.1/node_modules/trim-lines/index.js
930
+ const tab = 9;
931
+ const space = 32;
932
+ /**
933
+ * Remove initial and final spaces and tabs at the line breaks in `value`.
934
+ * Does not trim initial and final spaces and tabs of the value itself.
935
+ *
936
+ * @param {string} value
937
+ * Value to trim.
938
+ * @returns {string}
939
+ * Trimmed value.
940
+ */
941
+ function trimLines(value) {
942
+ const source = String(value);
943
+ const search = /\r?\n|\r/g;
944
+ let match = search.exec(source);
945
+ let last = 0;
946
+ /** @type {Array<string>} */
947
+ const lines = [];
948
+ while (match) {
949
+ lines.push(trimLine(source.slice(last, match.index), last > 0, true), match[0]);
950
+ last = match.index + match[0].length;
951
+ match = search.exec(source);
952
+ }
953
+ lines.push(trimLine(source.slice(last), last > 0, false));
954
+ return lines.join("");
955
+ }
956
+ /**
957
+ * @param {string} value
958
+ * Line to trim.
959
+ * @param {boolean} start
960
+ * Whether to trim the start of the line.
961
+ * @param {boolean} end
962
+ * Whether to trim the end of the line.
963
+ * @returns {string}
964
+ * Trimmed line.
965
+ */
966
+ function trimLine(value, start, end) {
967
+ let startIndex = 0;
968
+ let endIndex = value.length;
969
+ if (start) {
970
+ let code = value.codePointAt(startIndex);
971
+ while (code === tab || code === space) {
972
+ startIndex++;
973
+ code = value.codePointAt(startIndex);
974
+ }
975
+ }
976
+ if (end) {
977
+ let code = value.codePointAt(endIndex - 1);
978
+ while (code === tab || code === space) {
979
+ endIndex--;
980
+ code = value.codePointAt(endIndex - 1);
981
+ }
982
+ }
983
+ return endIndex > startIndex ? value.slice(startIndex, endIndex) : "";
984
+ }
985
+
986
+ //#endregion
987
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/text.js
988
+ /**
989
+ * @import {Element as HastElement, Text as HastText} from 'hast'
990
+ * @import {Text as MdastText} from 'mdast'
991
+ * @import {State} from '../state.js'
992
+ */
993
+ /**
994
+ * Turn an mdast `text` node into hast.
995
+ *
996
+ * @param {State} state
997
+ * Info passed around.
998
+ * @param {MdastText} node
999
+ * mdast node.
1000
+ * @returns {HastElement | HastText}
1001
+ * hast node.
1002
+ */
1003
+ function text(state, node) {
1004
+ /** @type {HastText} */
1005
+ const result = {
1006
+ type: "text",
1007
+ value: trimLines(String(node.value))
1008
+ };
1009
+ state.patch(node, result);
1010
+ return state.applyData(node, result);
1011
+ }
1012
+
1013
+ //#endregion
1014
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
1015
+ /**
1016
+ * @import {Element} from 'hast'
1017
+ * @import {ThematicBreak} from 'mdast'
1018
+ * @import {State} from '../state.js'
1019
+ */
1020
+ /**
1021
+ * Turn an mdast `thematicBreak` node into hast.
1022
+ *
1023
+ * @param {State} state
1024
+ * Info passed around.
1025
+ * @param {ThematicBreak} node
1026
+ * mdast node.
1027
+ * @returns {Element}
1028
+ * hast node.
1029
+ */
1030
+ function thematicBreak(state, node) {
1031
+ /** @type {Element} */
1032
+ const result = {
1033
+ type: "element",
1034
+ tagName: "hr",
1035
+ properties: {},
1036
+ children: []
1037
+ };
1038
+ state.patch(node, result);
1039
+ return state.applyData(node, result);
1040
+ }
1041
+
1042
+ //#endregion
1043
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/handlers/index.js
1044
+ /**
1045
+ * @import {Handlers} from '../state.js'
1046
+ */
1047
+ /**
1048
+ * Default handlers for nodes.
1049
+ *
1050
+ * @satisfies {Handlers}
1051
+ */
1052
+ const handlers = {
1053
+ blockquote,
1054
+ break: hardBreak,
1055
+ code,
1056
+ delete: strikethrough,
1057
+ emphasis,
1058
+ footnoteReference,
1059
+ heading,
1060
+ html,
1061
+ imageReference,
1062
+ image,
1063
+ inlineCode,
1064
+ linkReference,
1065
+ link,
1066
+ listItem,
1067
+ list,
1068
+ paragraph,
1069
+ root,
1070
+ strong,
1071
+ table,
1072
+ tableCell,
1073
+ tableRow,
1074
+ text,
1075
+ thematicBreak,
1076
+ toml: ignore,
1077
+ yaml: ignore,
1078
+ definition: ignore,
1079
+ footnoteDefinition: ignore
1080
+ };
1081
+ function ignore() {}
1082
+
1083
+ //#endregion
1084
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/footer.js
1085
+ /**
1086
+ * @import {ElementContent, Element} from 'hast'
1087
+ * @import {State} from './state.js'
1088
+ */
1089
+ /**
1090
+ * @callback FootnoteBackContentTemplate
1091
+ * Generate content for the backreference dynamically.
1092
+ *
1093
+ * For the following markdown:
1094
+ *
1095
+ * ```markdown
1096
+ * Alpha[^micromark], bravo[^micromark], and charlie[^remark].
1097
+ *
1098
+ * [^remark]: things about remark
1099
+ * [^micromark]: things about micromark
1100
+ * ```
1101
+ *
1102
+ * This function will be called with:
1103
+ *
1104
+ * * `0` and `0` for the backreference from `things about micromark` to
1105
+ * `alpha`, as it is the first used definition, and the first call to it
1106
+ * * `0` and `1` for the backreference from `things about micromark` to
1107
+ * `bravo`, as it is the first used definition, and the second call to it
1108
+ * * `1` and `0` for the backreference from `things about remark` to
1109
+ * `charlie`, as it is the second used definition
1110
+ * @param {number} referenceIndex
1111
+ * Index of the definition in the order that they are first referenced,
1112
+ * 0-indexed.
1113
+ * @param {number} rereferenceIndex
1114
+ * Index of calls to the same definition, 0-indexed.
1115
+ * @returns {Array<ElementContent> | ElementContent | string}
1116
+ * Content for the backreference when linking back from definitions to their
1117
+ * reference.
1118
+ *
1119
+ * @callback FootnoteBackLabelTemplate
1120
+ * Generate a back label dynamically.
1121
+ *
1122
+ * For the following markdown:
1123
+ *
1124
+ * ```markdown
1125
+ * Alpha[^micromark], bravo[^micromark], and charlie[^remark].
1126
+ *
1127
+ * [^remark]: things about remark
1128
+ * [^micromark]: things about micromark
1129
+ * ```
1130
+ *
1131
+ * This function will be called with:
1132
+ *
1133
+ * * `0` and `0` for the backreference from `things about micromark` to
1134
+ * `alpha`, as it is the first used definition, and the first call to it
1135
+ * * `0` and `1` for the backreference from `things about micromark` to
1136
+ * `bravo`, as it is the first used definition, and the second call to it
1137
+ * * `1` and `0` for the backreference from `things about remark` to
1138
+ * `charlie`, as it is the second used definition
1139
+ * @param {number} referenceIndex
1140
+ * Index of the definition in the order that they are first referenced,
1141
+ * 0-indexed.
1142
+ * @param {number} rereferenceIndex
1143
+ * Index of calls to the same definition, 0-indexed.
1144
+ * @returns {string}
1145
+ * Back label to use when linking back from definitions to their reference.
1146
+ */
1147
+ /**
1148
+ * Generate the default content that GitHub uses on backreferences.
1149
+ *
1150
+ * @param {number} _
1151
+ * Index of the definition in the order that they are first referenced,
1152
+ * 0-indexed.
1153
+ * @param {number} rereferenceIndex
1154
+ * Index of calls to the same definition, 0-indexed.
1155
+ * @returns {Array<ElementContent>}
1156
+ * Content.
1157
+ */
1158
+ function defaultFootnoteBackContent(_, rereferenceIndex) {
1159
+ /** @type {Array<ElementContent>} */
1160
+ const result = [{
1161
+ type: "text",
1162
+ value: "↩"
1163
+ }];
1164
+ if (rereferenceIndex > 1) result.push({
1165
+ type: "element",
1166
+ tagName: "sup",
1167
+ properties: {},
1168
+ children: [{
1169
+ type: "text",
1170
+ value: String(rereferenceIndex)
1171
+ }]
1172
+ });
1173
+ return result;
1174
+ }
1175
+ /**
1176
+ * Generate the default label that GitHub uses on backreferences.
1177
+ *
1178
+ * @param {number} referenceIndex
1179
+ * Index of the definition in the order that they are first referenced,
1180
+ * 0-indexed.
1181
+ * @param {number} rereferenceIndex
1182
+ * Index of calls to the same definition, 0-indexed.
1183
+ * @returns {string}
1184
+ * Label.
1185
+ */
1186
+ function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {
1187
+ return "Back to reference " + (referenceIndex + 1) + (rereferenceIndex > 1 ? "-" + rereferenceIndex : "");
1188
+ }
1189
+ /**
1190
+ * Generate a hast footer for called footnote definitions.
1191
+ *
1192
+ * @param {State} state
1193
+ * Info passed around.
1194
+ * @returns {Element | undefined}
1195
+ * `section` element or `undefined`.
1196
+ */
1197
+ function footer(state) {
1198
+ const clobberPrefix = typeof state.options.clobberPrefix === "string" ? state.options.clobberPrefix : "user-content-";
1199
+ const footnoteBackContent = state.options.footnoteBackContent || defaultFootnoteBackContent;
1200
+ const footnoteBackLabel = state.options.footnoteBackLabel || defaultFootnoteBackLabel;
1201
+ const footnoteLabel = state.options.footnoteLabel || "Footnotes";
1202
+ const footnoteLabelTagName = state.options.footnoteLabelTagName || "h2";
1203
+ const footnoteLabelProperties = state.options.footnoteLabelProperties || { className: ["sr-only"] };
1204
+ /** @type {Array<ElementContent>} */
1205
+ const listItems = [];
1206
+ let referenceIndex = -1;
1207
+ while (++referenceIndex < state.footnoteOrder.length) {
1208
+ const definition = state.footnoteById.get(state.footnoteOrder[referenceIndex]);
1209
+ if (!definition) continue;
1210
+ const content = state.all(definition);
1211
+ const id = String(definition.identifier).toUpperCase();
1212
+ const safeId = normalizeUri(id.toLowerCase());
1213
+ let rereferenceIndex = 0;
1214
+ /** @type {Array<ElementContent>} */
1215
+ const backReferences = [];
1216
+ const counts = state.footnoteCounts.get(id);
1217
+ while (counts !== void 0 && ++rereferenceIndex <= counts) {
1218
+ if (backReferences.length > 0) backReferences.push({
1219
+ type: "text",
1220
+ value: " "
1221
+ });
1222
+ let children = typeof footnoteBackContent === "string" ? footnoteBackContent : footnoteBackContent(referenceIndex, rereferenceIndex);
1223
+ if (typeof children === "string") children = {
1224
+ type: "text",
1225
+ value: children
1226
+ };
1227
+ backReferences.push({
1228
+ type: "element",
1229
+ tagName: "a",
1230
+ properties: {
1231
+ href: "#" + clobberPrefix + "fnref-" + safeId + (rereferenceIndex > 1 ? "-" + rereferenceIndex : ""),
1232
+ dataFootnoteBackref: "",
1233
+ ariaLabel: typeof footnoteBackLabel === "string" ? footnoteBackLabel : footnoteBackLabel(referenceIndex, rereferenceIndex),
1234
+ className: ["data-footnote-backref"]
1235
+ },
1236
+ children: Array.isArray(children) ? children : [children]
1237
+ });
1238
+ }
1239
+ const tail = content[content.length - 1];
1240
+ if (tail && tail.type === "element" && tail.tagName === "p") {
1241
+ const tailTail = tail.children[tail.children.length - 1];
1242
+ if (tailTail && tailTail.type === "text") tailTail.value += " ";
1243
+ else tail.children.push({
1244
+ type: "text",
1245
+ value: " "
1246
+ });
1247
+ tail.children.push(...backReferences);
1248
+ } else content.push(...backReferences);
1249
+ /** @type {Element} */
1250
+ const listItem = {
1251
+ type: "element",
1252
+ tagName: "li",
1253
+ properties: { id: clobberPrefix + "fn-" + safeId },
1254
+ children: state.wrap(content, true)
1255
+ };
1256
+ state.patch(definition, listItem);
1257
+ listItems.push(listItem);
1258
+ }
1259
+ if (listItems.length === 0) return;
1260
+ return {
1261
+ type: "element",
1262
+ tagName: "section",
1263
+ properties: {
1264
+ dataFootnotes: true,
1265
+ className: ["footnotes"]
1266
+ },
1267
+ children: [
1268
+ {
1269
+ type: "element",
1270
+ tagName: footnoteLabelTagName,
1271
+ properties: {
1272
+ ...esm_default(footnoteLabelProperties),
1273
+ id: "footnote-label"
1274
+ },
1275
+ children: [{
1276
+ type: "text",
1277
+ value: footnoteLabel
1278
+ }]
1279
+ },
1280
+ {
1281
+ type: "text",
1282
+ value: "\n"
1283
+ },
1284
+ {
1285
+ type: "element",
1286
+ tagName: "ol",
1287
+ properties: {},
1288
+ children: state.wrap(listItems, true)
1289
+ },
1290
+ {
1291
+ type: "text",
1292
+ value: "\n"
1293
+ }
1294
+ ]
1295
+ };
1296
+ }
1297
+
1298
+ //#endregion
1299
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/state.js
1300
+ /**
1301
+ * @import {
1302
+ * ElementContent as HastElementContent,
1303
+ * Element as HastElement,
1304
+ * Nodes as HastNodes,
1305
+ * Properties as HastProperties,
1306
+ * RootContent as HastRootContent,
1307
+ * Text as HastText
1308
+ * } from 'hast'
1309
+ * @import {
1310
+ * Definition as MdastDefinition,
1311
+ * FootnoteDefinition as MdastFootnoteDefinition,
1312
+ * Nodes as MdastNodes,
1313
+ * Parents as MdastParents
1314
+ * } from 'mdast'
1315
+ * @import {VFile} from 'vfile'
1316
+ * @import {
1317
+ * FootnoteBackContentTemplate,
1318
+ * FootnoteBackLabelTemplate
1319
+ * } from './footer.js'
1320
+ */
1321
+ /**
1322
+ * @callback Handler
1323
+ * Handle a node.
1324
+ * @param {State} state
1325
+ * Info passed around.
1326
+ * @param {any} node
1327
+ * mdast node to handle.
1328
+ * @param {MdastParents | undefined} parent
1329
+ * Parent of `node`.
1330
+ * @returns {Array<HastElementContent> | HastElementContent | undefined}
1331
+ * hast node.
1332
+ *
1333
+ * @typedef {Partial<Record<MdastNodes['type'], Handler>>} Handlers
1334
+ * Handle nodes.
1335
+ *
1336
+ * @typedef Options
1337
+ * Configuration (optional).
1338
+ * @property {boolean | null | undefined} [allowDangerousHtml=false]
1339
+ * Whether to persist raw HTML in markdown in the hast tree (default:
1340
+ * `false`).
1341
+ * @property {string | null | undefined} [clobberPrefix='user-content-']
1342
+ * Prefix to use before the `id` property on footnotes to prevent them from
1343
+ * *clobbering* (default: `'user-content-'`).
1344
+ *
1345
+ * Pass `''` for trusted markdown and when you are careful with
1346
+ * polyfilling.
1347
+ * You could pass a different prefix.
1348
+ *
1349
+ * DOM clobbering is this:
1350
+ *
1351
+ * ```html
1352
+ * <p id="x"></p>
1353
+ * <script>alert(x) // `x` now refers to the `p#x` DOM element<\/script>
1354
+ * ```
1355
+ *
1356
+ * The above example shows that elements are made available by browsers, by
1357
+ * their ID, on the `window` object.
1358
+ * This is a security risk because you might be expecting some other variable
1359
+ * at that place.
1360
+ * It can also break polyfills.
1361
+ * Using a prefix solves these problems.
1362
+ * @property {VFile | null | undefined} [file]
1363
+ * Corresponding virtual file representing the input document (optional).
1364
+ * @property {FootnoteBackContentTemplate | string | null | undefined} [footnoteBackContent]
1365
+ * Content of the backreference back to references (default: `defaultFootnoteBackContent`).
1366
+ *
1367
+ * The default value is:
1368
+ *
1369
+ * ```js
1370
+ * function defaultFootnoteBackContent(_, rereferenceIndex) {
1371
+ * const result = [{type: 'text', value: '↩'}]
1372
+ *
1373
+ * if (rereferenceIndex > 1) {
1374
+ * result.push({
1375
+ * type: 'element',
1376
+ * tagName: 'sup',
1377
+ * properties: {},
1378
+ * children: [{type: 'text', value: String(rereferenceIndex)}]
1379
+ * })
1380
+ * }
1381
+ *
1382
+ * return result
1383
+ * }
1384
+ * ```
1385
+ *
1386
+ * This content is used in the `a` element of each backreference (the `↩`
1387
+ * links).
1388
+ * @property {FootnoteBackLabelTemplate | string | null | undefined} [footnoteBackLabel]
1389
+ * Label to describe the backreference back to references (default:
1390
+ * `defaultFootnoteBackLabel`).
1391
+ *
1392
+ * The default value is:
1393
+ *
1394
+ * ```js
1395
+ * function defaultFootnoteBackLabel(referenceIndex, rereferenceIndex) {
1396
+ * return (
1397
+ * 'Back to reference ' +
1398
+ * (referenceIndex + 1) +
1399
+ * (rereferenceIndex > 1 ? '-' + rereferenceIndex : '')
1400
+ * )
1401
+ * }
1402
+ * ```
1403
+ *
1404
+ * Change it when the markdown is not in English.
1405
+ *
1406
+ * This label is used in the `ariaLabel` property on each backreference
1407
+ * (the `↩` links).
1408
+ * It affects users of assistive technology.
1409
+ * @property {string | null | undefined} [footnoteLabel='Footnotes']
1410
+ * Textual label to use for the footnotes section (default: `'Footnotes'`).
1411
+ *
1412
+ * Change it when the markdown is not in English.
1413
+ *
1414
+ * This label is typically hidden visually (assuming a `sr-only` CSS class
1415
+ * is defined that does that) and so affects screen readers only.
1416
+ * If you do have such a class, but want to show this section to everyone,
1417
+ * pass different properties with the `footnoteLabelProperties` option.
1418
+ * @property {HastProperties | null | undefined} [footnoteLabelProperties={className: ['sr-only']}]
1419
+ * Properties to use on the footnote label (default: `{className:
1420
+ * ['sr-only']}`).
1421
+ *
1422
+ * Change it to show the label and add other properties.
1423
+ *
1424
+ * This label is typically hidden visually (assuming an `sr-only` CSS class
1425
+ * is defined that does that) and so affects screen readers only.
1426
+ * If you do have such a class, but want to show this section to everyone,
1427
+ * pass an empty string.
1428
+ * You can also add different properties.
1429
+ *
1430
+ * > **Note**: `id: 'footnote-label'` is always added, because footnote
1431
+ * > calls use it with `aria-describedby` to provide an accessible label.
1432
+ * @property {string | null | undefined} [footnoteLabelTagName='h2']
1433
+ * HTML tag name to use for the footnote label element (default: `'h2'`).
1434
+ *
1435
+ * Change it to match your document structure.
1436
+ *
1437
+ * This label is typically hidden visually (assuming a `sr-only` CSS class
1438
+ * is defined that does that) and so affects screen readers only.
1439
+ * If you do have such a class, but want to show this section to everyone,
1440
+ * pass different properties with the `footnoteLabelProperties` option.
1441
+ * @property {Handlers | null | undefined} [handlers]
1442
+ * Extra handlers for nodes (optional).
1443
+ * @property {Array<MdastNodes['type']> | null | undefined} [passThrough]
1444
+ * List of custom mdast node types to pass through (keep) in hast (note that
1445
+ * the node itself is passed, but eventual children are transformed)
1446
+ * (optional).
1447
+ * @property {Handler | null | undefined} [unknownHandler]
1448
+ * Handler for all unknown nodes (optional).
1449
+ *
1450
+ * @typedef State
1451
+ * Info passed around.
1452
+ * @property {(node: MdastNodes) => Array<HastElementContent>} all
1453
+ * Transform the children of an mdast parent to hast.
1454
+ * @property {<Type extends HastNodes>(from: MdastNodes, to: Type) => HastElement | Type} applyData
1455
+ * Honor the `data` of `from`, and generate an element instead of `node`.
1456
+ * @property {Map<string, MdastDefinition>} definitionById
1457
+ * Definitions by their identifier.
1458
+ * @property {Map<string, MdastFootnoteDefinition>} footnoteById
1459
+ * Footnote definitions by their identifier.
1460
+ * @property {Map<string, number>} footnoteCounts
1461
+ * Counts for how often the same footnote was called.
1462
+ * @property {Array<string>} footnoteOrder
1463
+ * Identifiers of order when footnote calls first appear in tree order.
1464
+ * @property {Handlers} handlers
1465
+ * Applied handlers.
1466
+ * @property {(node: MdastNodes, parent: MdastParents | undefined) => Array<HastElementContent> | HastElementContent | undefined} one
1467
+ * Transform an mdast node to hast.
1468
+ * @property {Options} options
1469
+ * Configuration.
1470
+ * @property {(from: MdastNodes, node: HastNodes) => undefined} patch
1471
+ * Copy a node’s positional info.
1472
+ * @property {<Type extends HastRootContent>(nodes: Array<Type>, loose?: boolean | undefined) => Array<HastText | Type>} wrap
1473
+ * Wrap `nodes` with line endings between each node, adds initial/final line endings when `loose`.
1474
+ */
1475
+ const own = {}.hasOwnProperty;
1476
+ /** @type {Options} */
1477
+ const emptyOptions = {};
1478
+ /**
1479
+ * Create `state` from an mdast tree.
1480
+ *
1481
+ * @param {MdastNodes} tree
1482
+ * mdast node to transform.
1483
+ * @param {Options | null | undefined} [options]
1484
+ * Configuration (optional).
1485
+ * @returns {State}
1486
+ * `state` function.
1487
+ */
1488
+ function createState(tree, options) {
1489
+ const settings = options || emptyOptions;
1490
+ /** @type {Map<string, MdastDefinition>} */
1491
+ const definitionById = /* @__PURE__ */ new Map();
1492
+ /** @type {Map<string, MdastFootnoteDefinition>} */
1493
+ const footnoteById = /* @__PURE__ */ new Map();
1494
+ /** @type {State} */
1495
+ const state = {
1496
+ all,
1497
+ applyData,
1498
+ definitionById,
1499
+ footnoteById,
1500
+ footnoteCounts: /* @__PURE__ */ new Map(),
1501
+ footnoteOrder: [],
1502
+ handlers: {
1503
+ ...handlers,
1504
+ ...settings.handlers
1505
+ },
1506
+ one,
1507
+ options: settings,
1508
+ patch,
1509
+ wrap
1510
+ };
1511
+ visit(tree, function(node) {
1512
+ if (node.type === "definition" || node.type === "footnoteDefinition") {
1513
+ const map = node.type === "definition" ? definitionById : footnoteById;
1514
+ const id = String(node.identifier).toUpperCase();
1515
+ if (!map.has(id)) map.set(id, node);
1516
+ }
1517
+ });
1518
+ return state;
1519
+ /**
1520
+ * Transform an mdast node into a hast node.
1521
+ *
1522
+ * @param {MdastNodes} node
1523
+ * mdast node.
1524
+ * @param {MdastParents | undefined} [parent]
1525
+ * Parent of `node`.
1526
+ * @returns {Array<HastElementContent> | HastElementContent | undefined}
1527
+ * Resulting hast node.
1528
+ */
1529
+ function one(node, parent) {
1530
+ const type = node.type;
1531
+ const handle = state.handlers[type];
1532
+ if (own.call(state.handlers, type) && handle) return handle(state, node, parent);
1533
+ if (state.options.passThrough && state.options.passThrough.includes(type)) {
1534
+ if ("children" in node) {
1535
+ const { children, ...shallow } = node;
1536
+ const result = esm_default(shallow);
1537
+ result.children = state.all(node);
1538
+ return result;
1539
+ }
1540
+ return esm_default(node);
1541
+ }
1542
+ return (state.options.unknownHandler || defaultUnknownHandler)(state, node, parent);
1543
+ }
1544
+ /**
1545
+ * Transform the children of an mdast node into hast nodes.
1546
+ *
1547
+ * @param {MdastNodes} parent
1548
+ * mdast node to compile
1549
+ * @returns {Array<HastElementContent>}
1550
+ * Resulting hast nodes.
1551
+ */
1552
+ function all(parent) {
1553
+ /** @type {Array<HastElementContent>} */
1554
+ const values = [];
1555
+ if ("children" in parent) {
1556
+ const nodes = parent.children;
1557
+ let index = -1;
1558
+ while (++index < nodes.length) {
1559
+ const result = state.one(nodes[index], parent);
1560
+ if (result) {
1561
+ if (index && nodes[index - 1].type === "break") {
1562
+ if (!Array.isArray(result) && result.type === "text") result.value = trimMarkdownSpaceStart(result.value);
1563
+ if (!Array.isArray(result) && result.type === "element") {
1564
+ const head = result.children[0];
1565
+ if (head && head.type === "text") head.value = trimMarkdownSpaceStart(head.value);
1566
+ }
1567
+ }
1568
+ if (Array.isArray(result)) values.push(...result);
1569
+ else values.push(result);
1570
+ }
1571
+ }
1572
+ }
1573
+ return values;
1574
+ }
1575
+ }
1576
+ /**
1577
+ * Copy a node’s positional info.
1578
+ *
1579
+ * @param {MdastNodes} from
1580
+ * mdast node to copy from.
1581
+ * @param {HastNodes} to
1582
+ * hast node to copy into.
1583
+ * @returns {undefined}
1584
+ * Nothing.
1585
+ */
1586
+ function patch(from, to) {
1587
+ if (from.position) to.position = position(from);
1588
+ }
1589
+ /**
1590
+ * Honor the `data` of `from` and maybe generate an element instead of `to`.
1591
+ *
1592
+ * @template {HastNodes} Type
1593
+ * Node type.
1594
+ * @param {MdastNodes} from
1595
+ * mdast node to use data from.
1596
+ * @param {Type} to
1597
+ * hast node to change.
1598
+ * @returns {HastElement | Type}
1599
+ * Nothing.
1600
+ */
1601
+ function applyData(from, to) {
1602
+ /** @type {HastElement | Type} */
1603
+ let result = to;
1604
+ if (from && from.data) {
1605
+ const hName = from.data.hName;
1606
+ const hChildren = from.data.hChildren;
1607
+ const hProperties = from.data.hProperties;
1608
+ if (typeof hName === "string") if (result.type === "element") result.tagName = hName;
1609
+ else result = {
1610
+ type: "element",
1611
+ tagName: hName,
1612
+ properties: {},
1613
+ children: "children" in result ? result.children : [result]
1614
+ };
1615
+ if (result.type === "element" && hProperties) Object.assign(result.properties, esm_default(hProperties));
1616
+ if ("children" in result && result.children && hChildren !== null && hChildren !== void 0) result.children = hChildren;
1617
+ }
1618
+ return result;
1619
+ }
1620
+ /**
1621
+ * Transform an unknown node.
1622
+ *
1623
+ * @param {State} state
1624
+ * Info passed around.
1625
+ * @param {MdastNodes} node
1626
+ * Unknown mdast node.
1627
+ * @returns {HastElement | HastText}
1628
+ * Resulting hast node.
1629
+ */
1630
+ function defaultUnknownHandler(state, node) {
1631
+ const data = node.data || {};
1632
+ /** @type {HastElement | HastText} */
1633
+ const result = "value" in node && !(own.call(data, "hProperties") || own.call(data, "hChildren")) ? {
1634
+ type: "text",
1635
+ value: node.value
1636
+ } : {
1637
+ type: "element",
1638
+ tagName: "div",
1639
+ properties: {},
1640
+ children: state.all(node)
1641
+ };
1642
+ state.patch(node, result);
1643
+ return state.applyData(node, result);
1644
+ }
1645
+ /**
1646
+ * Wrap `nodes` with line endings between each node.
1647
+ *
1648
+ * @template {HastRootContent} Type
1649
+ * Node type.
1650
+ * @param {Array<Type>} nodes
1651
+ * List of nodes to wrap.
1652
+ * @param {boolean | undefined} [loose=false]
1653
+ * Whether to add line endings at start and end (default: `false`).
1654
+ * @returns {Array<HastText | Type>}
1655
+ * Wrapped nodes.
1656
+ */
1657
+ function wrap(nodes, loose) {
1658
+ /** @type {Array<HastText | Type>} */
1659
+ const result = [];
1660
+ let index = -1;
1661
+ if (loose) result.push({
1662
+ type: "text",
1663
+ value: "\n"
1664
+ });
1665
+ while (++index < nodes.length) {
1666
+ if (index) result.push({
1667
+ type: "text",
1668
+ value: "\n"
1669
+ });
1670
+ result.push(nodes[index]);
1671
+ }
1672
+ if (loose && nodes.length > 0) result.push({
1673
+ type: "text",
1674
+ value: "\n"
1675
+ });
1676
+ return result;
1677
+ }
1678
+ /**
1679
+ * Trim spaces and tabs at the start of `value`.
1680
+ *
1681
+ * @param {string} value
1682
+ * Value to trim.
1683
+ * @returns {string}
1684
+ * Result.
1685
+ */
1686
+ function trimMarkdownSpaceStart(value) {
1687
+ let index = 0;
1688
+ let code = value.charCodeAt(index);
1689
+ while (code === 9 || code === 32) {
1690
+ index++;
1691
+ code = value.charCodeAt(index);
1692
+ }
1693
+ return value.slice(index);
1694
+ }
1695
+
1696
+ //#endregion
1697
+ //#region ../../node_modules/.pnpm/mdast-util-to-hast@13.2.1/node_modules/mdast-util-to-hast/lib/index.js
1698
+ /**
1699
+ * @import {Nodes as HastNodes} from 'hast'
1700
+ * @import {Nodes as MdastNodes} from 'mdast'
1701
+ * @import {Options} from './state.js'
1702
+ */
1703
+ /**
1704
+ * Transform mdast to hast.
1705
+ *
1706
+ * ##### Notes
1707
+ *
1708
+ * ###### HTML
1709
+ *
1710
+ * Raw HTML is available in mdast as `html` nodes and can be embedded in hast
1711
+ * as semistandard `raw` nodes.
1712
+ * Most utilities ignore `raw` nodes but two notable ones don’t:
1713
+ *
1714
+ * * `hast-util-to-html` also has an option `allowDangerousHtml` which will
1715
+ * output the raw HTML.
1716
+ * This is typically discouraged as noted by the option name but is useful
1717
+ * if you completely trust authors
1718
+ * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them
1719
+ * into standard hast nodes (`element`, `text`, etc).
1720
+ * This is a heavy task as it needs a full HTML parser, but it is the only
1721
+ * way to support untrusted content
1722
+ *
1723
+ * ###### Footnotes
1724
+ *
1725
+ * Many options supported here relate to footnotes.
1726
+ * Footnotes are not specified by CommonMark, which we follow by default.
1727
+ * They are supported by GitHub, so footnotes can be enabled in markdown with
1728
+ * `mdast-util-gfm`.
1729
+ *
1730
+ * The options `footnoteBackLabel` and `footnoteLabel` define natural language
1731
+ * that explains footnotes, which is hidden for sighted users but shown to
1732
+ * assistive technology.
1733
+ * When your page is not in English, you must define translated values.
1734
+ *
1735
+ * Back references use ARIA attributes, but the section label itself uses a
1736
+ * heading that is hidden with an `sr-only` class.
1737
+ * To show it to sighted users, define different attributes in
1738
+ * `footnoteLabelProperties`.
1739
+ *
1740
+ * ###### Clobbering
1741
+ *
1742
+ * Footnotes introduces a problem, as it links footnote calls to footnote
1743
+ * definitions on the page through `id` attributes generated from user content,
1744
+ * which results in DOM clobbering.
1745
+ *
1746
+ * DOM clobbering is this:
1747
+ *
1748
+ * ```html
1749
+ * <p id=x></p>
1750
+ * <script>alert(x) // `x` now refers to the DOM `p#x` element<\/script>
1751
+ * ```
1752
+ *
1753
+ * Elements by their ID are made available by browsers on the `window` object,
1754
+ * which is a security risk.
1755
+ * Using a prefix solves this problem.
1756
+ *
1757
+ * More information on how to handle clobbering and the prefix is explained in
1758
+ * Example: headings (DOM clobbering) in `rehype-sanitize`.
1759
+ *
1760
+ * ###### Unknown nodes
1761
+ *
1762
+ * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.
1763
+ * The default behavior for unknown nodes is:
1764
+ *
1765
+ * * when the node has a `value` (and doesn’t have `data.hName`,
1766
+ * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`
1767
+ * node
1768
+ * * otherwise, create a `<div>` element (which could be changed with
1769
+ * `data.hName`), with its children mapped from mdast to hast as well
1770
+ *
1771
+ * This behavior can be changed by passing an `unknownHandler`.
1772
+ *
1773
+ * @param {MdastNodes} tree
1774
+ * mdast tree.
1775
+ * @param {Options | null | undefined} [options]
1776
+ * Configuration (optional).
1777
+ * @returns {HastNodes}
1778
+ * hast tree.
1779
+ */
1780
+ function toHast(tree, options) {
1781
+ const state = createState(tree, options);
1782
+ const node = state.one(tree, void 0);
1783
+ const foot = footer(state);
1784
+ /** @type {HastNodes} */
1785
+ const result = Array.isArray(node) ? {
1786
+ type: "root",
1787
+ children: node
1788
+ } : node || {
1789
+ type: "root",
1790
+ children: []
1791
+ };
1792
+ if (foot) {
1793
+ /* @__PURE__ */ ok("children" in result);
1794
+ result.children.push({
1795
+ type: "text",
1796
+ value: "\n"
1797
+ }, foot);
1798
+ }
1799
+ return result;
1800
+ }
1801
+
1802
+ //#endregion
1803
+ export { toHast as t };