@harbour-enterprises/superdoc 0.28.0 → 0.28.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 (55) hide show
  1. package/dist/chunks/{PdfViewer-D-d9sxeo.cjs → PdfViewer-Can0yoW4.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-COOBTu0Z.es.js → PdfViewer-DJkdA-8o.es.js} +1 -1
  3. package/dist/chunks/default-BS6z0SoE-BS6z0SoE.es.js +5 -0
  4. package/dist/chunks/default-BS6z0SoE-Gl4f7Y7J.cjs +4 -0
  5. package/dist/chunks/{index-lzF76amP.cjs → index-BY-vlgKe.cjs} +3 -3
  6. package/dist/chunks/index-CHAKf7mX-C5aFF6Zl.es.js +2213 -0
  7. package/dist/chunks/index-CHAKf7mX-Dx-DOGGJ.cjs +2213 -0
  8. package/dist/chunks/index-CSaZZzfe-BzemjgYL.cjs +264 -0
  9. package/dist/chunks/index-CSaZZzfe-CSaZZzfe.es.js +265 -0
  10. package/dist/chunks/index-C_x_N6Uh-DJn8hIEt.es.js +2200 -0
  11. package/dist/chunks/index-C_x_N6Uh-Db3CUJMX.cjs +2200 -0
  12. package/dist/chunks/index-Cd3D_8gF-CFhMnajQ.es.js +862 -0
  13. package/dist/chunks/index-Cd3D_8gF-DKJ_wTu_.cjs +861 -0
  14. package/dist/chunks/index-CvBqQJbG-CvBqQJbG.es.js +878 -0
  15. package/dist/chunks/index-CvBqQJbG-Dwm0THD7.cjs +877 -0
  16. package/dist/chunks/index-DRCvimau-Cw339678.es.js +9876 -0
  17. package/dist/chunks/index-DRCvimau-H4Ck3S9a.cjs +9876 -0
  18. package/dist/chunks/index-D_sWOSiG-BtDZzJ6I.cjs +588 -0
  19. package/dist/chunks/index-D_sWOSiG-DE96TaT5.es.js +588 -0
  20. package/dist/chunks/{index-CeV3gm4O.es.js → index-DidXsI6u.es.js} +3 -3
  21. package/dist/chunks/index-njnq8umX-DU2xcaHZ.es.js +845 -0
  22. package/dist/chunks/index-njnq8umX-_TfP84XP.cjs +845 -0
  23. package/dist/chunks/{super-editor.es-CBBT9MkW.es.js → super-editor.es-Br566URP.es.js} +6453 -24109
  24. package/dist/chunks/{super-editor.es-CsOCPht5.cjs → super-editor.es-ksiTgGLm.cjs} +6362 -24018
  25. package/dist/core/types/index.d.ts +6 -6
  26. package/dist/core/types/index.d.ts.map +1 -1
  27. package/dist/super-editor/ai-writer.es.js +2 -2
  28. package/dist/super-editor/chunks/{converter-3mtRTJOI.js → converter-D6Z6OmA3.js} +49 -49
  29. package/dist/super-editor/chunks/default-BS6z0SoE.js +5 -0
  30. package/dist/super-editor/chunks/{docx-zipper-DIkBRy6i.js → docx-zipper-Dni97kMT.js} +1 -1
  31. package/dist/super-editor/chunks/{editor-DakKNLen.js → editor-D3TKfdXs.js} +3694 -21351
  32. package/dist/super-editor/chunks/index-CHAKf7mX.js +2213 -0
  33. package/dist/super-editor/chunks/index-CSaZZzfe.js +265 -0
  34. package/dist/super-editor/chunks/index-C_x_N6Uh.js +2200 -0
  35. package/dist/super-editor/chunks/index-Cd3D_8gF.js +862 -0
  36. package/dist/super-editor/chunks/index-CvBqQJbG.js +878 -0
  37. package/dist/super-editor/chunks/index-DRCvimau.js +9876 -0
  38. package/dist/super-editor/chunks/index-D_sWOSiG.js +588 -0
  39. package/dist/super-editor/chunks/index-njnq8umX.js +845 -0
  40. package/dist/super-editor/chunks/{toolbar-D4J4zzEp.js → toolbar-fNE3luLB.js} +2 -2
  41. package/dist/super-editor/converter.es.js +2 -2
  42. package/dist/super-editor/docx-zipper.es.js +2 -2
  43. package/dist/super-editor/editor.es.js +3 -3
  44. package/dist/super-editor/file-zipper.es.js +1 -1
  45. package/dist/super-editor/super-editor/src/core/Editor.d.ts +2 -2
  46. package/dist/super-editor/super-editor/src/extensions/track-changes/permission-helpers.d.ts +6 -6
  47. package/dist/super-editor/super-editor.es.js +15 -15
  48. package/dist/super-editor/toolbar.es.js +2 -2
  49. package/dist/super-editor.cjs +1 -1
  50. package/dist/super-editor.es.js +1 -1
  51. package/dist/superdoc.cjs +2 -2
  52. package/dist/superdoc.es.js +2 -2
  53. package/dist/superdoc.umd.js +73962 -73924
  54. package/dist/superdoc.umd.js.map +1 -1
  55. package/package.json +1 -1
@@ -0,0 +1,2200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const indexCSaZZzfe = require("./index-CSaZZzfe-BzemjgYL.cjs");
4
+ const VOID = -1;
5
+ const PRIMITIVE = 0;
6
+ const ARRAY = 1;
7
+ const OBJECT = 2;
8
+ const DATE = 3;
9
+ const REGEXP = 4;
10
+ const MAP = 5;
11
+ const SET = 6;
12
+ const ERROR = 7;
13
+ const BIGINT = 8;
14
+ const env = typeof self === "object" ? self : globalThis;
15
+ const deserializer = ($, _) => {
16
+ const as = (out, index) => {
17
+ $.set(index, out);
18
+ return out;
19
+ };
20
+ const unpair = (index) => {
21
+ if ($.has(index))
22
+ return $.get(index);
23
+ const [type, value] = _[index];
24
+ switch (type) {
25
+ case PRIMITIVE:
26
+ case VOID:
27
+ return as(value, index);
28
+ case ARRAY: {
29
+ const arr = as([], index);
30
+ for (const index2 of value)
31
+ arr.push(unpair(index2));
32
+ return arr;
33
+ }
34
+ case OBJECT: {
35
+ const object = as({}, index);
36
+ for (const [key, index2] of value)
37
+ object[unpair(key)] = unpair(index2);
38
+ return object;
39
+ }
40
+ case DATE:
41
+ return as(new Date(value), index);
42
+ case REGEXP: {
43
+ const { source, flags } = value;
44
+ return as(new RegExp(source, flags), index);
45
+ }
46
+ case MAP: {
47
+ const map = as(/* @__PURE__ */ new Map(), index);
48
+ for (const [key, index2] of value)
49
+ map.set(unpair(key), unpair(index2));
50
+ return map;
51
+ }
52
+ case SET: {
53
+ const set = as(/* @__PURE__ */ new Set(), index);
54
+ for (const index2 of value)
55
+ set.add(unpair(index2));
56
+ return set;
57
+ }
58
+ case ERROR: {
59
+ const { name, message } = value;
60
+ return as(new env[name](message), index);
61
+ }
62
+ case BIGINT:
63
+ return as(BigInt(value), index);
64
+ case "BigInt":
65
+ return as(Object(BigInt(value)), index);
66
+ case "ArrayBuffer":
67
+ return as(new Uint8Array(value).buffer, value);
68
+ case "DataView": {
69
+ const { buffer } = new Uint8Array(value);
70
+ return as(new DataView(buffer), value);
71
+ }
72
+ }
73
+ return as(new env[type](value), index);
74
+ };
75
+ return unpair;
76
+ };
77
+ const deserialize = (serialized) => deserializer(/* @__PURE__ */ new Map(), serialized)(0);
78
+ const EMPTY = "";
79
+ const { toString } = {};
80
+ const { keys } = Object;
81
+ const typeOf = (value) => {
82
+ const type = typeof value;
83
+ if (type !== "object" || !value)
84
+ return [PRIMITIVE, type];
85
+ const asString = toString.call(value).slice(8, -1);
86
+ switch (asString) {
87
+ case "Array":
88
+ return [ARRAY, EMPTY];
89
+ case "Object":
90
+ return [OBJECT, EMPTY];
91
+ case "Date":
92
+ return [DATE, EMPTY];
93
+ case "RegExp":
94
+ return [REGEXP, EMPTY];
95
+ case "Map":
96
+ return [MAP, EMPTY];
97
+ case "Set":
98
+ return [SET, EMPTY];
99
+ case "DataView":
100
+ return [ARRAY, asString];
101
+ }
102
+ if (asString.includes("Array"))
103
+ return [ARRAY, asString];
104
+ if (asString.includes("Error"))
105
+ return [ERROR, asString];
106
+ return [OBJECT, asString];
107
+ };
108
+ const shouldSkip = ([TYPE, type]) => TYPE === PRIMITIVE && (type === "function" || type === "symbol");
109
+ const serializer = (strict, json, $, _) => {
110
+ const as = (out, value) => {
111
+ const index = _.push(out) - 1;
112
+ $.set(value, index);
113
+ return index;
114
+ };
115
+ const pair = (value) => {
116
+ if ($.has(value))
117
+ return $.get(value);
118
+ let [TYPE, type] = typeOf(value);
119
+ switch (TYPE) {
120
+ case PRIMITIVE: {
121
+ let entry = value;
122
+ switch (type) {
123
+ case "bigint":
124
+ TYPE = BIGINT;
125
+ entry = value.toString();
126
+ break;
127
+ case "function":
128
+ case "symbol":
129
+ if (strict)
130
+ throw new TypeError("unable to serialize " + type);
131
+ entry = null;
132
+ break;
133
+ case "undefined":
134
+ return as([VOID], value);
135
+ }
136
+ return as([TYPE, entry], value);
137
+ }
138
+ case ARRAY: {
139
+ if (type) {
140
+ let spread = value;
141
+ if (type === "DataView") {
142
+ spread = new Uint8Array(value.buffer);
143
+ } else if (type === "ArrayBuffer") {
144
+ spread = new Uint8Array(value);
145
+ }
146
+ return as([type, [...spread]], value);
147
+ }
148
+ const arr = [];
149
+ const index = as([TYPE, arr], value);
150
+ for (const entry of value)
151
+ arr.push(pair(entry));
152
+ return index;
153
+ }
154
+ case OBJECT: {
155
+ if (type) {
156
+ switch (type) {
157
+ case "BigInt":
158
+ return as([type, value.toString()], value);
159
+ case "Boolean":
160
+ case "Number":
161
+ case "String":
162
+ return as([type, value.valueOf()], value);
163
+ }
164
+ }
165
+ if (json && "toJSON" in value)
166
+ return pair(value.toJSON());
167
+ const entries = [];
168
+ const index = as([TYPE, entries], value);
169
+ for (const key of keys(value)) {
170
+ if (strict || !shouldSkip(typeOf(value[key])))
171
+ entries.push([pair(key), pair(value[key])]);
172
+ }
173
+ return index;
174
+ }
175
+ case DATE:
176
+ return as([TYPE, value.toISOString()], value);
177
+ case REGEXP: {
178
+ const { source, flags } = value;
179
+ return as([TYPE, { source, flags }], value);
180
+ }
181
+ case MAP: {
182
+ const entries = [];
183
+ const index = as([TYPE, entries], value);
184
+ for (const [key, entry] of value) {
185
+ if (strict || !(shouldSkip(typeOf(key)) || shouldSkip(typeOf(entry))))
186
+ entries.push([pair(key), pair(entry)]);
187
+ }
188
+ return index;
189
+ }
190
+ case SET: {
191
+ const entries = [];
192
+ const index = as([TYPE, entries], value);
193
+ for (const entry of value) {
194
+ if (strict || !shouldSkip(typeOf(entry)))
195
+ entries.push(pair(entry));
196
+ }
197
+ return index;
198
+ }
199
+ }
200
+ const { message } = value;
201
+ return as([TYPE, { name: type, message }], value);
202
+ };
203
+ return pair;
204
+ };
205
+ const serialize = (value, { json, lossy } = {}) => {
206
+ const _ = [];
207
+ return serializer(!(json || lossy), !!json, /* @__PURE__ */ new Map(), _)(value), _;
208
+ };
209
+ const structuredClone$1 = typeof structuredClone === "function" ? (
210
+ /* c8 ignore start */
211
+ ((any, options) => options && ("json" in options || "lossy" in options) ? deserialize(serialize(any, options)) : structuredClone(any))
212
+ ) : (any, options) => deserialize(serialize(any, options));
213
+ const isElement = (
214
+ // Note: overloads in JSDoc can’t yet use different `@template`s.
215
+ /**
216
+ * @type {(
217
+ * (<Condition extends TestFunction>(element: unknown, test: Condition, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
218
+ * (<Condition extends string>(element: unknown, test: Condition, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
219
+ * ((element?: null | undefined) => false) &
220
+ * ((element: unknown, test?: null | undefined, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
221
+ * ((element: unknown, test?: Test, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => boolean)
222
+ * )}
223
+ */
224
+ /**
225
+ * @param {unknown} [element]
226
+ * @param {Test | undefined} [test]
227
+ * @param {number | null | undefined} [index]
228
+ * @param {Parents | null | undefined} [parent]
229
+ * @param {unknown} [context]
230
+ * @returns {boolean}
231
+ */
232
+ // eslint-disable-next-line max-params
233
+ (function(element2, test, index, parent, context) {
234
+ const check = convertElement(test);
235
+ return looksLikeAnElement(element2) ? check.call(context, element2, index, parent) : false;
236
+ })
237
+ );
238
+ const convertElement = (
239
+ // Note: overloads in JSDoc can’t yet use different `@template`s.
240
+ /**
241
+ * @type {(
242
+ * (<Condition extends TestFunction>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & Predicate<Condition, Element>) &
243
+ * (<Condition extends string>(test: Condition) => (element: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element & {tagName: Condition}) &
244
+ * ((test?: null | undefined) => (element?: unknown, index?: number | null | undefined, parent?: Parents | null | undefined, context?: unknown) => element is Element) &
245
+ * ((test?: Test) => Check)
246
+ * )}
247
+ */
248
+ /**
249
+ * @param {Test | null | undefined} [test]
250
+ * @returns {Check}
251
+ */
252
+ (function(test) {
253
+ if (test === null || test === void 0) {
254
+ return element;
255
+ }
256
+ if (typeof test === "string") {
257
+ return tagNameFactory(test);
258
+ }
259
+ if (typeof test === "object") {
260
+ return anyFactory(test);
261
+ }
262
+ if (typeof test === "function") {
263
+ return castFactory(test);
264
+ }
265
+ throw new Error("Expected function, string, or array as `test`");
266
+ })
267
+ );
268
+ function anyFactory(tests) {
269
+ const checks = [];
270
+ let index = -1;
271
+ while (++index < tests.length) {
272
+ checks[index] = convertElement(tests[index]);
273
+ }
274
+ return castFactory(any);
275
+ function any(...parameters) {
276
+ let index2 = -1;
277
+ while (++index2 < checks.length) {
278
+ if (checks[index2].apply(this, parameters)) return true;
279
+ }
280
+ return false;
281
+ }
282
+ }
283
+ function tagNameFactory(check) {
284
+ return castFactory(tagName);
285
+ function tagName(element2) {
286
+ return element2.tagName === check;
287
+ }
288
+ }
289
+ function castFactory(testFunction) {
290
+ return check;
291
+ function check(value, index, parent) {
292
+ return Boolean(
293
+ looksLikeAnElement(value) && testFunction.call(
294
+ this,
295
+ value,
296
+ typeof index === "number" ? index : void 0,
297
+ parent || void 0
298
+ )
299
+ );
300
+ }
301
+ }
302
+ function element(element2) {
303
+ return Boolean(
304
+ element2 && typeof element2 === "object" && "type" in element2 && element2.type === "element" && "tagName" in element2 && typeof element2.tagName === "string"
305
+ );
306
+ }
307
+ function looksLikeAnElement(value) {
308
+ return value !== null && typeof value === "object" && "type" in value && "tagName" in value;
309
+ }
310
+ const embedded = convertElement(
311
+ /**
312
+ * @param element
313
+ * @returns {element is {tagName: 'audio' | 'canvas' | 'embed' | 'iframe' | 'img' | 'math' | 'object' | 'picture' | 'svg' | 'video'}}
314
+ */
315
+ function(element2) {
316
+ return element2.tagName === "audio" || element2.tagName === "canvas" || element2.tagName === "embed" || element2.tagName === "iframe" || element2.tagName === "img" || element2.tagName === "math" || element2.tagName === "object" || element2.tagName === "picture" || element2.tagName === "svg" || element2.tagName === "video";
317
+ }
318
+ );
319
+ const re = /[ \t\n\f\r]/g;
320
+ function whitespace(thing) {
321
+ return typeof thing === "object" ? thing.type === "text" ? empty(thing.value) : false : empty(thing);
322
+ }
323
+ function empty(value) {
324
+ return value.replace(re, "") === "";
325
+ }
326
+ const blocks = [
327
+ "address",
328
+ // Flow content.
329
+ "article",
330
+ // Sections and headings.
331
+ "aside",
332
+ // Sections and headings.
333
+ "blockquote",
334
+ // Flow content.
335
+ "body",
336
+ // Page.
337
+ "br",
338
+ // Contribute whitespace intrinsically.
339
+ "caption",
340
+ // Similar to block.
341
+ "center",
342
+ // Flow content, legacy.
343
+ "col",
344
+ // Similar to block.
345
+ "colgroup",
346
+ // Similar to block.
347
+ "dd",
348
+ // Lists.
349
+ "dialog",
350
+ // Flow content.
351
+ "dir",
352
+ // Lists, legacy.
353
+ "div",
354
+ // Flow content.
355
+ "dl",
356
+ // Lists.
357
+ "dt",
358
+ // Lists.
359
+ "figcaption",
360
+ // Flow content.
361
+ "figure",
362
+ // Flow content.
363
+ "footer",
364
+ // Flow content.
365
+ "form",
366
+ // Flow content.
367
+ "h1",
368
+ // Sections and headings.
369
+ "h2",
370
+ // Sections and headings.
371
+ "h3",
372
+ // Sections and headings.
373
+ "h4",
374
+ // Sections and headings.
375
+ "h5",
376
+ // Sections and headings.
377
+ "h6",
378
+ // Sections and headings.
379
+ "head",
380
+ // Page.
381
+ "header",
382
+ // Flow content.
383
+ "hgroup",
384
+ // Sections and headings.
385
+ "hr",
386
+ // Flow content.
387
+ "html",
388
+ // Page.
389
+ "legend",
390
+ // Flow content.
391
+ "li",
392
+ // Block-like.
393
+ "li",
394
+ // Similar to block.
395
+ "listing",
396
+ // Flow content, legacy
397
+ "main",
398
+ // Flow content.
399
+ "menu",
400
+ // Lists.
401
+ "nav",
402
+ // Sections and headings.
403
+ "ol",
404
+ // Lists.
405
+ "optgroup",
406
+ // Similar to block.
407
+ "option",
408
+ // Similar to block.
409
+ "p",
410
+ // Flow content.
411
+ "plaintext",
412
+ // Flow content, legacy
413
+ "pre",
414
+ // Flow content.
415
+ "section",
416
+ // Sections and headings.
417
+ "summary",
418
+ // Similar to block.
419
+ "table",
420
+ // Similar to block.
421
+ "tbody",
422
+ // Similar to block.
423
+ "td",
424
+ // Block-like.
425
+ "td",
426
+ // Similar to block.
427
+ "tfoot",
428
+ // Similar to block.
429
+ "th",
430
+ // Block-like.
431
+ "th",
432
+ // Similar to block.
433
+ "thead",
434
+ // Similar to block.
435
+ "tr",
436
+ // Similar to block.
437
+ "ul",
438
+ // Lists.
439
+ "wbr",
440
+ // Contribute whitespace intrinsically.
441
+ "xmp"
442
+ // Flow content, legacy
443
+ ];
444
+ const content$1 = [
445
+ // Form.
446
+ "button",
447
+ "input",
448
+ "select",
449
+ "textarea"
450
+ ];
451
+ const skippable$1 = [
452
+ "area",
453
+ "base",
454
+ "basefont",
455
+ "dialog",
456
+ "datalist",
457
+ "head",
458
+ "link",
459
+ "meta",
460
+ "noembed",
461
+ "noframes",
462
+ "param",
463
+ "rp",
464
+ "script",
465
+ "source",
466
+ "style",
467
+ "template",
468
+ "track",
469
+ "title"
470
+ ];
471
+ const emptyOptions$1 = {};
472
+ const ignorableNode = indexCSaZZzfe.convert(["comment", "doctype"]);
473
+ function minifyWhitespace(tree, options) {
474
+ const settings = options || emptyOptions$1;
475
+ minify(tree, {
476
+ collapse: collapseFactory(
477
+ settings.newlines ? replaceNewlines : replaceWhitespace
478
+ ),
479
+ whitespace: "normal"
480
+ });
481
+ }
482
+ function minify(node, state) {
483
+ if ("children" in node) {
484
+ const settings = { ...state };
485
+ if (node.type === "root" || blocklike(node)) {
486
+ settings.before = true;
487
+ settings.after = true;
488
+ }
489
+ settings.whitespace = inferWhiteSpace(node, state);
490
+ return all$2(node, settings);
491
+ }
492
+ if (node.type === "text") {
493
+ if (state.whitespace === "normal") {
494
+ return minifyText(node, state);
495
+ }
496
+ if (state.whitespace === "nowrap") {
497
+ node.value = state.collapse(node.value);
498
+ }
499
+ }
500
+ return { ignore: ignorableNode(node), stripAtStart: false, remove: false };
501
+ }
502
+ function minifyText(node, state) {
503
+ const value = state.collapse(node.value);
504
+ const result = { ignore: false, stripAtStart: false, remove: false };
505
+ let start = 0;
506
+ let end = value.length;
507
+ if (state.before && removable(value.charAt(0))) {
508
+ start++;
509
+ }
510
+ if (start !== end && removable(value.charAt(end - 1))) {
511
+ if (state.after) {
512
+ end--;
513
+ } else {
514
+ result.stripAtStart = true;
515
+ }
516
+ }
517
+ if (start === end) {
518
+ result.remove = true;
519
+ } else {
520
+ node.value = value.slice(start, end);
521
+ }
522
+ return result;
523
+ }
524
+ function all$2(parent, state) {
525
+ let before = state.before;
526
+ const after = state.after;
527
+ const children = parent.children;
528
+ let length = children.length;
529
+ let index = -1;
530
+ while (++index < length) {
531
+ const result = minify(children[index], {
532
+ ...state,
533
+ after: collapsableAfter(children, index, after),
534
+ before
535
+ });
536
+ if (result.remove) {
537
+ children.splice(index, 1);
538
+ index--;
539
+ length--;
540
+ } else if (!result.ignore) {
541
+ before = result.stripAtStart;
542
+ }
543
+ if (content(children[index])) {
544
+ before = false;
545
+ }
546
+ }
547
+ return { ignore: false, stripAtStart: Boolean(before || after), remove: false };
548
+ }
549
+ function collapsableAfter(nodes, index, after) {
550
+ while (++index < nodes.length) {
551
+ const node = nodes[index];
552
+ let result = inferBoundary(node);
553
+ if (result === void 0 && "children" in node && !skippable(node)) {
554
+ result = collapsableAfter(node.children, -1);
555
+ }
556
+ if (typeof result === "boolean") {
557
+ return result;
558
+ }
559
+ }
560
+ return after;
561
+ }
562
+ function inferBoundary(node) {
563
+ if (node.type === "element") {
564
+ if (content(node)) {
565
+ return false;
566
+ }
567
+ if (blocklike(node)) {
568
+ return true;
569
+ }
570
+ } else if (node.type === "text") {
571
+ if (!whitespace(node)) {
572
+ return false;
573
+ }
574
+ } else if (!ignorableNode(node)) {
575
+ return false;
576
+ }
577
+ }
578
+ function content(node) {
579
+ return embedded(node) || isElement(node, content$1);
580
+ }
581
+ function blocklike(node) {
582
+ return isElement(node, blocks);
583
+ }
584
+ function skippable(node) {
585
+ return Boolean(node.type === "element" && node.properties.hidden) || ignorableNode(node) || isElement(node, skippable$1);
586
+ }
587
+ function removable(character) {
588
+ return character === " " || character === "\n";
589
+ }
590
+ function replaceNewlines(value) {
591
+ const match = /\r?\n|\r/.exec(value);
592
+ return match ? match[0] : " ";
593
+ }
594
+ function replaceWhitespace() {
595
+ return " ";
596
+ }
597
+ function collapseFactory(replace) {
598
+ return collapse;
599
+ function collapse(value) {
600
+ return String(value).replace(/[\t\n\v\f\r ]+/g, replace);
601
+ }
602
+ }
603
+ function inferWhiteSpace(node, state) {
604
+ if ("tagName" in node && node.properties) {
605
+ switch (node.tagName) {
606
+ // Whitespace in script/style, while not displayed by CSS as significant,
607
+ // could have some meaning in JS/CSS, so we can’t touch them.
608
+ case "listing":
609
+ case "plaintext":
610
+ case "script":
611
+ case "style":
612
+ case "xmp": {
613
+ return "pre";
614
+ }
615
+ case "nobr": {
616
+ return "nowrap";
617
+ }
618
+ case "pre": {
619
+ return node.properties.wrap ? "pre-wrap" : "pre";
620
+ }
621
+ case "td":
622
+ case "th": {
623
+ return node.properties.noWrap ? "nowrap" : state.whitespace;
624
+ }
625
+ case "textarea": {
626
+ return "pre-wrap";
627
+ }
628
+ }
629
+ }
630
+ return state.whitespace;
631
+ }
632
+ function rehypeMinifyWhitespace(options) {
633
+ return function(tree) {
634
+ minifyWhitespace(tree, options);
635
+ };
636
+ }
637
+ const pointEnd = point("end");
638
+ const pointStart = point("start");
639
+ function point(type) {
640
+ return point2;
641
+ function point2(node) {
642
+ const point3 = node && node.position && node.position[type] || {};
643
+ if (typeof point3.line === "number" && point3.line > 0 && typeof point3.column === "number" && point3.column > 0) {
644
+ return {
645
+ line: point3.line,
646
+ column: point3.column,
647
+ offset: typeof point3.offset === "number" && point3.offset > -1 ? point3.offset : void 0
648
+ };
649
+ }
650
+ }
651
+ }
652
+ function position(node) {
653
+ const start = pointStart(node);
654
+ const end = pointEnd(node);
655
+ if (start && end) {
656
+ return { start, end };
657
+ }
658
+ }
659
+ function a(state, node) {
660
+ const properties = node.properties || {};
661
+ const children = (
662
+ /** @type {Array<PhrasingContent>} */
663
+ state.all(node)
664
+ );
665
+ const result = {
666
+ type: "link",
667
+ url: state.resolve(String(properties.href || "") || null),
668
+ title: properties.title ? String(properties.title) : null,
669
+ children
670
+ };
671
+ state.patch(node, result);
672
+ return result;
673
+ }
674
+ function base(state, node) {
675
+ if (!state.baseFound) {
676
+ state.frozenBaseUrl = String(node.properties && node.properties.href || "") || void 0;
677
+ state.baseFound = true;
678
+ }
679
+ }
680
+ function blockquote(state, node) {
681
+ const result = { type: "blockquote", children: state.toFlow(state.all(node)) };
682
+ state.patch(node, result);
683
+ return result;
684
+ }
685
+ function br$1(state, node) {
686
+ const result = { type: "break" };
687
+ state.patch(node, result);
688
+ return result;
689
+ }
690
+ const findAfter = (
691
+ // Note: overloads like this are needed to support optional generics.
692
+ /**
693
+ * @type {(
694
+ * (<Kind extends UnistParent, Check extends Test>(parent: Kind, index: Child<Kind> | number, test: Check) => Matches<Child<Kind>, Check> | undefined) &
695
+ * (<Kind extends UnistParent>(parent: Kind, index: Child<Kind> | number, test?: null | undefined) => Child<Kind> | undefined)
696
+ * )}
697
+ */
698
+ /**
699
+ * @param {UnistParent} parent
700
+ * @param {UnistNode | number} index
701
+ * @param {Test} [test]
702
+ * @returns {UnistNode | undefined}
703
+ */
704
+ (function(parent, index, test) {
705
+ const is = indexCSaZZzfe.convert(test);
706
+ if (!parent || !parent.type || !parent.children) {
707
+ throw new Error("Expected parent node");
708
+ }
709
+ if (typeof index === "number") {
710
+ if (index < 0 || index === Number.POSITIVE_INFINITY) {
711
+ throw new Error("Expected positive finite number as index");
712
+ }
713
+ } else {
714
+ index = parent.children.indexOf(index);
715
+ if (index < 0) {
716
+ throw new Error("Expected child node or index");
717
+ }
718
+ }
719
+ while (++index < parent.children.length) {
720
+ if (is(parent.children[index], index, parent)) {
721
+ return parent.children[index];
722
+ }
723
+ }
724
+ return void 0;
725
+ })
726
+ );
727
+ const searchLineFeeds = /\n/g;
728
+ const searchTabOrSpaces = /[\t ]+/g;
729
+ const br = convertElement("br");
730
+ const cell = convertElement(isCell);
731
+ const p$1 = convertElement("p");
732
+ const row = convertElement("tr");
733
+ const notRendered = convertElement([
734
+ // List from: <https://html.spec.whatwg.org/multipage/rendering.html#hidden-elements>
735
+ "datalist",
736
+ "head",
737
+ "noembed",
738
+ "noframes",
739
+ "noscript",
740
+ // Act as if we support scripting.
741
+ "rp",
742
+ "script",
743
+ "style",
744
+ "template",
745
+ "title",
746
+ // Hidden attribute.
747
+ hidden,
748
+ // From: <https://html.spec.whatwg.org/multipage/rendering.html#flow-content-3>
749
+ closedDialog
750
+ ]);
751
+ const blockOrCaption = convertElement([
752
+ "address",
753
+ // Flow content
754
+ "article",
755
+ // Sections and headings
756
+ "aside",
757
+ // Sections and headings
758
+ "blockquote",
759
+ // Flow content
760
+ "body",
761
+ // Page
762
+ "caption",
763
+ // `table-caption`
764
+ "center",
765
+ // Flow content (legacy)
766
+ "dd",
767
+ // Lists
768
+ "dialog",
769
+ // Flow content
770
+ "dir",
771
+ // Lists (legacy)
772
+ "dl",
773
+ // Lists
774
+ "dt",
775
+ // Lists
776
+ "div",
777
+ // Flow content
778
+ "figure",
779
+ // Flow content
780
+ "figcaption",
781
+ // Flow content
782
+ "footer",
783
+ // Flow content
784
+ "form,",
785
+ // Flow content
786
+ "h1",
787
+ // Sections and headings
788
+ "h2",
789
+ // Sections and headings
790
+ "h3",
791
+ // Sections and headings
792
+ "h4",
793
+ // Sections and headings
794
+ "h5",
795
+ // Sections and headings
796
+ "h6",
797
+ // Sections and headings
798
+ "header",
799
+ // Flow content
800
+ "hgroup",
801
+ // Sections and headings
802
+ "hr",
803
+ // Flow content
804
+ "html",
805
+ // Page
806
+ "legend",
807
+ // Flow content
808
+ "li",
809
+ // Lists (as `display: list-item`)
810
+ "listing",
811
+ // Flow content (legacy)
812
+ "main",
813
+ // Flow content
814
+ "menu",
815
+ // Lists
816
+ "nav",
817
+ // Sections and headings
818
+ "ol",
819
+ // Lists
820
+ "p",
821
+ // Flow content
822
+ "plaintext",
823
+ // Flow content (legacy)
824
+ "pre",
825
+ // Flow content
826
+ "section",
827
+ // Sections and headings
828
+ "ul",
829
+ // Lists
830
+ "xmp"
831
+ // Flow content (legacy)
832
+ ]);
833
+ function toText(tree, options) {
834
+ const options_ = {};
835
+ const children = "children" in tree ? tree.children : [];
836
+ const block = blockOrCaption(tree);
837
+ const whitespace2 = inferWhitespace(tree, {
838
+ whitespace: options_.whitespace || "normal"
839
+ });
840
+ const results = [];
841
+ if (tree.type === "text" || tree.type === "comment") {
842
+ results.push(
843
+ ...collectText(tree, {
844
+ breakBefore: true,
845
+ breakAfter: true
846
+ })
847
+ );
848
+ }
849
+ let index = -1;
850
+ while (++index < children.length) {
851
+ results.push(
852
+ ...renderedTextCollection(
853
+ children[index],
854
+ // @ts-expect-error: `tree` is a parent if we’re here.
855
+ tree,
856
+ {
857
+ whitespace: whitespace2,
858
+ breakBefore: index ? void 0 : block,
859
+ breakAfter: index < children.length - 1 ? br(children[index + 1]) : block
860
+ }
861
+ )
862
+ );
863
+ }
864
+ const result = [];
865
+ let count;
866
+ index = -1;
867
+ while (++index < results.length) {
868
+ const value = results[index];
869
+ if (typeof value === "number") {
870
+ if (count !== void 0 && value > count) count = value;
871
+ } else if (value) {
872
+ if (count !== void 0 && count > -1) {
873
+ result.push("\n".repeat(count) || " ");
874
+ }
875
+ count = -1;
876
+ result.push(value);
877
+ }
878
+ }
879
+ return result.join("");
880
+ }
881
+ function renderedTextCollection(node, parent, info) {
882
+ if (node.type === "element") {
883
+ return collectElement(node, parent, info);
884
+ }
885
+ if (node.type === "text") {
886
+ return info.whitespace === "normal" ? collectText(node, info) : collectPreText(node);
887
+ }
888
+ return [];
889
+ }
890
+ function collectElement(node, parent, info) {
891
+ const whitespace2 = inferWhitespace(node, info);
892
+ const children = node.children || [];
893
+ let index = -1;
894
+ let items = [];
895
+ if (notRendered(node)) {
896
+ return items;
897
+ }
898
+ let prefix2;
899
+ let suffix;
900
+ if (br(node)) {
901
+ suffix = "\n";
902
+ } else if (row(node) && // @ts-expect-error: something up with types of parents.
903
+ findAfter(parent, node, row)) {
904
+ suffix = "\n";
905
+ } else if (p$1(node)) {
906
+ prefix2 = 2;
907
+ suffix = 2;
908
+ } else if (blockOrCaption(node)) {
909
+ prefix2 = 1;
910
+ suffix = 1;
911
+ }
912
+ while (++index < children.length) {
913
+ items = items.concat(
914
+ renderedTextCollection(children[index], node, {
915
+ whitespace: whitespace2,
916
+ breakBefore: index ? void 0 : prefix2,
917
+ breakAfter: index < children.length - 1 ? br(children[index + 1]) : suffix
918
+ })
919
+ );
920
+ }
921
+ if (cell(node) && // @ts-expect-error: something up with types of parents.
922
+ findAfter(parent, node, cell)) {
923
+ items.push(" ");
924
+ }
925
+ if (prefix2) items.unshift(prefix2);
926
+ if (suffix) items.push(suffix);
927
+ return items;
928
+ }
929
+ function collectText(node, info) {
930
+ const value = String(node.value);
931
+ const lines = [];
932
+ const result = [];
933
+ let start = 0;
934
+ while (start <= value.length) {
935
+ searchLineFeeds.lastIndex = start;
936
+ const match = searchLineFeeds.exec(value);
937
+ const end = match && "index" in match ? match.index : value.length;
938
+ lines.push(
939
+ // Any sequence of collapsible spaces and tabs immediately preceding or
940
+ // following a segment break is removed.
941
+ trimAndCollapseSpacesAndTabs(
942
+ // […] ignoring bidi formatting characters (characters with the
943
+ // Bidi_Control property [UAX9]: ALM, LTR, RTL, LRE-RLO, LRI-PDI) as if
944
+ // they were not there.
945
+ value.slice(start, end).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g, ""),
946
+ start === 0 ? info.breakBefore : true,
947
+ end === value.length ? info.breakAfter : true
948
+ )
949
+ );
950
+ start = end + 1;
951
+ }
952
+ let index = -1;
953
+ let join;
954
+ while (++index < lines.length) {
955
+ if (lines[index].charCodeAt(lines[index].length - 1) === 8203 || index < lines.length - 1 && lines[index + 1].charCodeAt(0) === 8203) {
956
+ result.push(lines[index]);
957
+ join = void 0;
958
+ } else if (lines[index]) {
959
+ if (typeof join === "number") result.push(join);
960
+ result.push(lines[index]);
961
+ join = 0;
962
+ } else if (index === 0 || index === lines.length - 1) {
963
+ result.push(0);
964
+ }
965
+ }
966
+ return result;
967
+ }
968
+ function collectPreText(node) {
969
+ return [String(node.value)];
970
+ }
971
+ function trimAndCollapseSpacesAndTabs(value, breakBefore, breakAfter) {
972
+ const result = [];
973
+ let start = 0;
974
+ let end;
975
+ while (start < value.length) {
976
+ searchTabOrSpaces.lastIndex = start;
977
+ const match = searchTabOrSpaces.exec(value);
978
+ end = match ? match.index : value.length;
979
+ if (!start && !end && match && !breakBefore) {
980
+ result.push("");
981
+ }
982
+ if (start !== end) {
983
+ result.push(value.slice(start, end));
984
+ }
985
+ start = match ? end + match[0].length : end;
986
+ }
987
+ if (start !== end && !breakAfter) {
988
+ result.push("");
989
+ }
990
+ return result.join(" ");
991
+ }
992
+ function inferWhitespace(node, info) {
993
+ if (node.type === "element") {
994
+ const properties = node.properties || {};
995
+ switch (node.tagName) {
996
+ case "listing":
997
+ case "plaintext":
998
+ case "xmp": {
999
+ return "pre";
1000
+ }
1001
+ case "nobr": {
1002
+ return "nowrap";
1003
+ }
1004
+ case "pre": {
1005
+ return properties.wrap ? "pre-wrap" : "pre";
1006
+ }
1007
+ case "td":
1008
+ case "th": {
1009
+ return properties.noWrap ? "nowrap" : info.whitespace;
1010
+ }
1011
+ case "textarea": {
1012
+ return "pre-wrap";
1013
+ }
1014
+ }
1015
+ }
1016
+ return info.whitespace;
1017
+ }
1018
+ function hidden(node) {
1019
+ return Boolean((node.properties || {}).hidden);
1020
+ }
1021
+ function isCell(node) {
1022
+ return node.tagName === "td" || node.tagName === "th";
1023
+ }
1024
+ function closedDialog(node) {
1025
+ return node.tagName === "dialog" && !(node.properties || {}).open;
1026
+ }
1027
+ function trimTrailingLines(value) {
1028
+ const input2 = String(value);
1029
+ let end = input2.length;
1030
+ while (end > 0) {
1031
+ const code2 = input2.codePointAt(end - 1);
1032
+ if (code2 !== void 0 && (code2 === 10 || code2 === 13)) {
1033
+ end--;
1034
+ } else {
1035
+ break;
1036
+ }
1037
+ }
1038
+ return input2.slice(0, end);
1039
+ }
1040
+ const prefix = "language-";
1041
+ function code(state, node) {
1042
+ const children = node.children;
1043
+ let index = -1;
1044
+ let classList;
1045
+ let lang;
1046
+ if (node.tagName === "pre") {
1047
+ while (++index < children.length) {
1048
+ const child = children[index];
1049
+ if (child.type === "element" && child.tagName === "code" && child.properties && child.properties.className && Array.isArray(child.properties.className)) {
1050
+ classList = child.properties.className;
1051
+ break;
1052
+ }
1053
+ }
1054
+ }
1055
+ if (classList) {
1056
+ index = -1;
1057
+ while (++index < classList.length) {
1058
+ if (String(classList[index]).slice(0, prefix.length) === prefix) {
1059
+ lang = String(classList[index]).slice(prefix.length);
1060
+ break;
1061
+ }
1062
+ }
1063
+ }
1064
+ const result = {
1065
+ type: "code",
1066
+ lang: lang || null,
1067
+ meta: null,
1068
+ value: trimTrailingLines(toText(node))
1069
+ };
1070
+ state.patch(node, result);
1071
+ return result;
1072
+ }
1073
+ function comment(state, node) {
1074
+ const result = {
1075
+ type: "html",
1076
+ value: "<!--" + node.value + "-->"
1077
+ };
1078
+ state.patch(node, result);
1079
+ return result;
1080
+ }
1081
+ function del(state, node) {
1082
+ const children = (
1083
+ /** @type {Array<PhrasingContent>} */
1084
+ state.all(node)
1085
+ );
1086
+ const result = { type: "delete", children };
1087
+ state.patch(node, result);
1088
+ return result;
1089
+ }
1090
+ function listItemsSpread(children) {
1091
+ let index = -1;
1092
+ if (children.length > 1) {
1093
+ while (++index < children.length) {
1094
+ if (children[index].spread) {
1095
+ return true;
1096
+ }
1097
+ }
1098
+ }
1099
+ return false;
1100
+ }
1101
+ function dl(state, node) {
1102
+ const clean = [];
1103
+ const groups = [];
1104
+ let index = -1;
1105
+ while (++index < node.children.length) {
1106
+ const child = node.children[index];
1107
+ if (child.type === "element" && child.tagName === "div") {
1108
+ clean.push(...child.children);
1109
+ } else {
1110
+ clean.push(child);
1111
+ }
1112
+ }
1113
+ let group = { definitions: [], titles: [] };
1114
+ index = -1;
1115
+ while (++index < clean.length) {
1116
+ const child = clean[index];
1117
+ if (child.type === "element" && child.tagName === "dt") {
1118
+ const previous = clean[index - 1];
1119
+ if (previous && previous.type === "element" && previous.tagName === "dd") {
1120
+ groups.push(group);
1121
+ group = { definitions: [], titles: [] };
1122
+ }
1123
+ group.titles.push(child);
1124
+ } else {
1125
+ group.definitions.push(child);
1126
+ }
1127
+ }
1128
+ groups.push(group);
1129
+ index = -1;
1130
+ const content2 = [];
1131
+ while (++index < groups.length) {
1132
+ const result = [
1133
+ ...handle(state, groups[index].titles),
1134
+ ...handle(state, groups[index].definitions)
1135
+ ];
1136
+ if (result.length > 0) {
1137
+ content2.push({
1138
+ type: "listItem",
1139
+ spread: result.length > 1,
1140
+ checked: null,
1141
+ children: result
1142
+ });
1143
+ }
1144
+ }
1145
+ if (content2.length > 0) {
1146
+ const result = {
1147
+ type: "list",
1148
+ ordered: false,
1149
+ start: null,
1150
+ spread: listItemsSpread(content2),
1151
+ children: content2
1152
+ };
1153
+ state.patch(node, result);
1154
+ return result;
1155
+ }
1156
+ }
1157
+ function handle(state, children) {
1158
+ const nodes = state.all({ type: "root", children });
1159
+ const listItems = state.toSpecificContent(nodes, create$2);
1160
+ if (listItems.length === 0) {
1161
+ return [];
1162
+ }
1163
+ if (listItems.length === 1) {
1164
+ return listItems[0].children;
1165
+ }
1166
+ return [
1167
+ {
1168
+ type: "list",
1169
+ ordered: false,
1170
+ start: null,
1171
+ spread: listItemsSpread(listItems),
1172
+ children: listItems
1173
+ }
1174
+ ];
1175
+ }
1176
+ function create$2() {
1177
+ return { type: "listItem", spread: false, checked: null, children: [] };
1178
+ }
1179
+ function em(state, node) {
1180
+ const children = (
1181
+ /** @type {Array<PhrasingContent>} */
1182
+ state.all(node)
1183
+ );
1184
+ const result = { type: "emphasis", children };
1185
+ state.patch(node, result);
1186
+ return result;
1187
+ }
1188
+ function dropSurroundingBreaks(nodes) {
1189
+ let start = 0;
1190
+ let end = nodes.length;
1191
+ while (start < end && nodes[start].type === "break") start++;
1192
+ while (end > start && nodes[end - 1].type === "break") end--;
1193
+ return start === 0 && end === nodes.length ? nodes : nodes.slice(start, end);
1194
+ }
1195
+ function heading(state, node) {
1196
+ const depth = (
1197
+ /** @type {Heading['depth']} */
1198
+ /* c8 ignore next */
1199
+ Number(node.tagName.charAt(1)) || 1
1200
+ );
1201
+ const children = dropSurroundingBreaks(
1202
+ /** @type {Array<PhrasingContent>} */
1203
+ state.all(node)
1204
+ );
1205
+ const result = { type: "heading", depth, children };
1206
+ state.patch(node, result);
1207
+ return result;
1208
+ }
1209
+ function hr(state, node) {
1210
+ const result = { type: "thematicBreak" };
1211
+ state.patch(node, result);
1212
+ return result;
1213
+ }
1214
+ function iframe(state, node) {
1215
+ const properties = node.properties || {};
1216
+ const source = String(properties.src || "");
1217
+ const title = String(properties.title || "");
1218
+ if (source && title) {
1219
+ const result = {
1220
+ type: "link",
1221
+ title: null,
1222
+ url: state.resolve(source),
1223
+ children: [{ type: "text", value: title }]
1224
+ };
1225
+ state.patch(node, result);
1226
+ return result;
1227
+ }
1228
+ }
1229
+ function img(state, node) {
1230
+ const properties = node.properties || {};
1231
+ const result = {
1232
+ type: "image",
1233
+ url: state.resolve(String(properties.src || "") || null),
1234
+ title: properties.title ? String(properties.title) : null,
1235
+ alt: properties.alt ? String(properties.alt) : ""
1236
+ };
1237
+ state.patch(node, result);
1238
+ return result;
1239
+ }
1240
+ function inlineCode(state, node) {
1241
+ const result = { type: "inlineCode", value: toText(node) };
1242
+ state.patch(node, result);
1243
+ return result;
1244
+ }
1245
+ function findSelectedOptions(node, explicitProperties) {
1246
+ const selectedOptions = [];
1247
+ const values = [];
1248
+ const properties = explicitProperties || node.properties || {};
1249
+ const options = findOptions(node);
1250
+ const size = Math.min(Number.parseInt(String(properties.size), 10), 0) || (properties.multiple ? 4 : 1);
1251
+ let index = -1;
1252
+ while (++index < options.length) {
1253
+ const option = options[index];
1254
+ if (option && option.properties && option.properties.selected) {
1255
+ selectedOptions.push(option);
1256
+ }
1257
+ }
1258
+ const list2 = selectedOptions.length > 0 ? selectedOptions : options;
1259
+ const max = Math.min(list2.length, size);
1260
+ index = -1;
1261
+ while (++index < max) {
1262
+ const option = list2[index];
1263
+ const properties2 = option.properties || {};
1264
+ const content2 = toText(option);
1265
+ const label = content2 || String(properties2.label || "");
1266
+ const value = String(properties2.value || "") || content2;
1267
+ values.push([value, label === value ? void 0 : label]);
1268
+ }
1269
+ return values;
1270
+ }
1271
+ function findOptions(node) {
1272
+ const results = [];
1273
+ let index = -1;
1274
+ while (++index < node.children.length) {
1275
+ const child = node.children[index];
1276
+ if ("children" in child && Array.isArray(child.children)) {
1277
+ results.push(...findOptions(child));
1278
+ }
1279
+ if (child.type === "element" && child.tagName === "option" && (!child.properties || !child.properties.disabled)) {
1280
+ results.push(child);
1281
+ }
1282
+ }
1283
+ return results;
1284
+ }
1285
+ const defaultChecked = "[x]";
1286
+ const defaultUnchecked = "[ ]";
1287
+ function input(state, node) {
1288
+ const properties = node.properties || {};
1289
+ const value = String(properties.value || properties.placeholder || "");
1290
+ if (properties.disabled || properties.type === "hidden" || properties.type === "file") {
1291
+ return;
1292
+ }
1293
+ if (properties.type === "checkbox" || properties.type === "radio") {
1294
+ const result2 = {
1295
+ type: "text",
1296
+ value: properties.checked ? state.options.checked || defaultChecked : state.options.unchecked || defaultUnchecked
1297
+ };
1298
+ state.patch(node, result2);
1299
+ return result2;
1300
+ }
1301
+ if (properties.type === "image") {
1302
+ const alt = properties.alt || value;
1303
+ if (alt) {
1304
+ const result2 = {
1305
+ type: "image",
1306
+ url: state.resolve(String(properties.src || "") || null),
1307
+ title: String(properties.title || "") || null,
1308
+ alt: String(alt)
1309
+ };
1310
+ state.patch(node, result2);
1311
+ return result2;
1312
+ }
1313
+ return;
1314
+ }
1315
+ let values = [];
1316
+ if (value) {
1317
+ values = [[value, void 0]];
1318
+ } else if (
1319
+ // `list` is not supported on these types:
1320
+ properties.type !== "button" && properties.type !== "file" && properties.type !== "password" && properties.type !== "reset" && properties.type !== "submit" && properties.list
1321
+ ) {
1322
+ const list2 = String(properties.list);
1323
+ const datalist = state.elementById.get(list2);
1324
+ if (datalist && datalist.tagName === "datalist") {
1325
+ values = findSelectedOptions(datalist, properties);
1326
+ }
1327
+ }
1328
+ if (values.length === 0) {
1329
+ return;
1330
+ }
1331
+ if (properties.type === "password") {
1332
+ values[0] = ["•".repeat(values[0][0].length), void 0];
1333
+ }
1334
+ if (properties.type === "email" || properties.type === "url") {
1335
+ const results = [];
1336
+ let index2 = -1;
1337
+ while (++index2 < values.length) {
1338
+ const value2 = state.resolve(values[index2][0]);
1339
+ const result2 = {
1340
+ type: "link",
1341
+ title: null,
1342
+ url: properties.type === "email" ? "mailto:" + value2 : value2,
1343
+ children: [{ type: "text", value: values[index2][1] || value2 }]
1344
+ };
1345
+ results.push(result2);
1346
+ if (index2 !== values.length - 1) {
1347
+ results.push({ type: "text", value: ", " });
1348
+ }
1349
+ }
1350
+ return results;
1351
+ }
1352
+ const texts = [];
1353
+ let index = -1;
1354
+ while (++index < values.length) {
1355
+ texts.push(
1356
+ values[index][1] ? values[index][1] + " (" + values[index][0] + ")" : values[index][0]
1357
+ );
1358
+ }
1359
+ const result = { type: "text", value: texts.join(", ") };
1360
+ state.patch(node, result);
1361
+ return result;
1362
+ }
1363
+ const own$1 = {}.hasOwnProperty;
1364
+ function hasProperty(node, name) {
1365
+ const value = node.type === "element" && own$1.call(node.properties, name) && node.properties[name];
1366
+ return value !== null && value !== void 0 && value !== false;
1367
+ }
1368
+ const list$1 = /* @__PURE__ */ new Set(["pingback", "prefetch", "stylesheet"]);
1369
+ function isBodyOkLink(node) {
1370
+ if (node.type !== "element" || node.tagName !== "link") {
1371
+ return false;
1372
+ }
1373
+ if (node.properties.itemProp) {
1374
+ return true;
1375
+ }
1376
+ const value = node.properties.rel;
1377
+ let index = -1;
1378
+ if (!Array.isArray(value) || value.length === 0) {
1379
+ return false;
1380
+ }
1381
+ while (++index < value.length) {
1382
+ if (!list$1.has(String(value[index]))) {
1383
+ return false;
1384
+ }
1385
+ }
1386
+ return true;
1387
+ }
1388
+ const basic = convertElement([
1389
+ "a",
1390
+ "abbr",
1391
+ // `area` is in fact only phrasing if it is inside a `map` element.
1392
+ // However, since `area`s are required to be inside a `map` element, and it’s
1393
+ // a rather involved check, it’s ignored here for now.
1394
+ "area",
1395
+ "b",
1396
+ "bdi",
1397
+ "bdo",
1398
+ "br",
1399
+ "button",
1400
+ "cite",
1401
+ "code",
1402
+ "data",
1403
+ "datalist",
1404
+ "del",
1405
+ "dfn",
1406
+ "em",
1407
+ "i",
1408
+ "input",
1409
+ "ins",
1410
+ "kbd",
1411
+ "keygen",
1412
+ "label",
1413
+ "map",
1414
+ "mark",
1415
+ "meter",
1416
+ "noscript",
1417
+ "output",
1418
+ "progress",
1419
+ "q",
1420
+ "ruby",
1421
+ "s",
1422
+ "samp",
1423
+ "script",
1424
+ "select",
1425
+ "small",
1426
+ "span",
1427
+ "strong",
1428
+ "sub",
1429
+ "sup",
1430
+ "template",
1431
+ "textarea",
1432
+ "time",
1433
+ "u",
1434
+ "var",
1435
+ "wbr"
1436
+ ]);
1437
+ const meta = convertElement("meta");
1438
+ function phrasing$1(value) {
1439
+ return Boolean(
1440
+ value.type === "text" || basic(value) || embedded(value) || isBodyOkLink(value) || meta(value) && hasProperty(value, "itemProp")
1441
+ );
1442
+ }
1443
+ function li(state, node) {
1444
+ const { rest, checkbox } = extractLeadingCheckbox(node);
1445
+ const checked = checkbox ? Boolean(checkbox.properties.checked) : null;
1446
+ const spread = spreadout(rest);
1447
+ const children = state.toFlow(state.all(rest));
1448
+ const result = { type: "listItem", spread, checked, children };
1449
+ state.patch(node, result);
1450
+ return result;
1451
+ }
1452
+ function spreadout(node) {
1453
+ let index = -1;
1454
+ let seenFlow = false;
1455
+ while (++index < node.children.length) {
1456
+ const child = node.children[index];
1457
+ if (child.type === "element") {
1458
+ if (phrasing$1(child)) continue;
1459
+ if (child.tagName === "p" || seenFlow || spreadout(child)) {
1460
+ return true;
1461
+ }
1462
+ seenFlow = true;
1463
+ }
1464
+ }
1465
+ return false;
1466
+ }
1467
+ function extractLeadingCheckbox(node) {
1468
+ const head = node.children[0];
1469
+ if (head && head.type === "element" && head.tagName === "input" && head.properties && (head.properties.type === "checkbox" || head.properties.type === "radio")) {
1470
+ const rest = { ...node, children: node.children.slice(1) };
1471
+ return { checkbox: head, rest };
1472
+ }
1473
+ if (head && head.type === "element" && head.tagName === "p") {
1474
+ const { checkbox, rest: restHead } = extractLeadingCheckbox(head);
1475
+ if (checkbox) {
1476
+ const rest = { ...node, children: [restHead, ...node.children.slice(1)] };
1477
+ return { checkbox, rest };
1478
+ }
1479
+ }
1480
+ return { checkbox: void 0, rest: node };
1481
+ }
1482
+ function list(state, node) {
1483
+ const ordered = node.tagName === "ol";
1484
+ const children = state.toSpecificContent(state.all(node), create$1);
1485
+ let start = null;
1486
+ if (ordered) {
1487
+ start = node.properties && node.properties.start ? Number.parseInt(String(node.properties.start), 10) : 1;
1488
+ }
1489
+ const result = {
1490
+ type: "list",
1491
+ ordered,
1492
+ start,
1493
+ spread: listItemsSpread(children),
1494
+ children
1495
+ };
1496
+ state.patch(node, result);
1497
+ return result;
1498
+ }
1499
+ function create$1() {
1500
+ return { type: "listItem", spread: false, checked: null, children: [] };
1501
+ }
1502
+ function wrapNeeded(nodes) {
1503
+ let index = -1;
1504
+ while (++index < nodes.length) {
1505
+ const node = nodes[index];
1506
+ if (!phrasing(node) || "children" in node && wrapNeeded(node.children)) {
1507
+ return true;
1508
+ }
1509
+ }
1510
+ return false;
1511
+ }
1512
+ function wrap(nodes) {
1513
+ return runs(nodes, onphrasing, function(d) {
1514
+ return d;
1515
+ });
1516
+ function onphrasing(nodes2) {
1517
+ return nodes2.every(function(d) {
1518
+ return d.type === "text" ? whitespace(d.value) : false;
1519
+ }) ? [] : [{ type: "paragraph", children: dropSurroundingBreaks(nodes2) }];
1520
+ }
1521
+ }
1522
+ function split(node) {
1523
+ return runs(node.children, onphrasing, onnonphrasing);
1524
+ function onphrasing(nodes) {
1525
+ const newParent = cloneWithoutChildren(node);
1526
+ newParent.children = nodes;
1527
+ return [newParent];
1528
+ }
1529
+ function onnonphrasing(child) {
1530
+ if ("children" in child && "children" in node) {
1531
+ const newParent = cloneWithoutChildren(node);
1532
+ const newChild = cloneWithoutChildren(child);
1533
+ newParent.children = child.children;
1534
+ newChild.children.push(newParent);
1535
+ return newChild;
1536
+ }
1537
+ return { ...child };
1538
+ }
1539
+ }
1540
+ function runs(nodes, onphrasing, onnonphrasing) {
1541
+ const flattened = flatten(nodes);
1542
+ const result = [];
1543
+ let queue = [];
1544
+ let index = -1;
1545
+ while (++index < flattened.length) {
1546
+ const node = flattened[index];
1547
+ if (phrasing(node)) {
1548
+ queue.push(node);
1549
+ } else {
1550
+ if (queue.length > 0) {
1551
+ result.push(...onphrasing(queue));
1552
+ queue = [];
1553
+ }
1554
+ result.push(onnonphrasing(node));
1555
+ }
1556
+ }
1557
+ if (queue.length > 0) {
1558
+ result.push(...onphrasing(queue));
1559
+ queue = [];
1560
+ }
1561
+ return result;
1562
+ }
1563
+ function flatten(nodes) {
1564
+ const flattened = [];
1565
+ let index = -1;
1566
+ while (++index < nodes.length) {
1567
+ const node = nodes[index];
1568
+ if ((node.type === "delete" || node.type === "link") && wrapNeeded(node.children)) {
1569
+ flattened.push(...split(node));
1570
+ } else {
1571
+ flattened.push(node);
1572
+ }
1573
+ }
1574
+ return flattened;
1575
+ }
1576
+ function phrasing(node) {
1577
+ const tagName = node.data && node.data.hName;
1578
+ return tagName ? phrasing$1({ type: "element", tagName, properties: {}, children: [] }) : indexCSaZZzfe.phrasing(node);
1579
+ }
1580
+ function cloneWithoutChildren(node) {
1581
+ return structuredClone$1({ ...node, children: [] });
1582
+ }
1583
+ function media(state, node) {
1584
+ const properties = node.properties || {};
1585
+ const poster = node.tagName === "video" ? String(properties.poster || "") : "";
1586
+ let source = String(properties.src || "");
1587
+ let index = -1;
1588
+ let linkInFallbackContent = false;
1589
+ let nodes = state.all(node);
1590
+ const fragment = { type: "root", children: nodes };
1591
+ indexCSaZZzfe.visit(fragment, function(node2) {
1592
+ if (node2.type === "link") {
1593
+ linkInFallbackContent = true;
1594
+ return indexCSaZZzfe.EXIT;
1595
+ }
1596
+ });
1597
+ if (linkInFallbackContent || wrapNeeded(nodes)) {
1598
+ return nodes;
1599
+ }
1600
+ while (!source && ++index < node.children.length) {
1601
+ const child = node.children[index];
1602
+ if (child.type === "element" && child.tagName === "source" && child.properties) {
1603
+ source = String(child.properties.src || "");
1604
+ }
1605
+ }
1606
+ if (poster) {
1607
+ const image = {
1608
+ type: "image",
1609
+ title: null,
1610
+ url: state.resolve(poster),
1611
+ alt: indexCSaZZzfe.toString(nodes)
1612
+ };
1613
+ state.patch(node, image);
1614
+ nodes = [image];
1615
+ }
1616
+ const children = (
1617
+ /** @type {Array<PhrasingContent>} */
1618
+ nodes
1619
+ );
1620
+ const result = {
1621
+ type: "link",
1622
+ title: properties.title ? String(properties.title) : null,
1623
+ url: state.resolve(source),
1624
+ children
1625
+ };
1626
+ state.patch(node, result);
1627
+ return result;
1628
+ }
1629
+ function p(state, node) {
1630
+ const children = dropSurroundingBreaks(
1631
+ // Allow potentially “invalid” nodes, they might be unknown.
1632
+ // We also support straddling later.
1633
+ /** @type {Array<PhrasingContent>} */
1634
+ state.all(node)
1635
+ );
1636
+ if (children.length > 0) {
1637
+ const result = { type: "paragraph", children };
1638
+ state.patch(node, result);
1639
+ return result;
1640
+ }
1641
+ }
1642
+ const defaultQuotes = ['"'];
1643
+ function q(state, node) {
1644
+ const quotes = state.options.quotes || defaultQuotes;
1645
+ state.qNesting++;
1646
+ const contents = state.all(node);
1647
+ state.qNesting--;
1648
+ const quote = quotes[state.qNesting % quotes.length];
1649
+ const head = contents[0];
1650
+ const tail = contents[contents.length - 1];
1651
+ const open = quote.charAt(0);
1652
+ const close = quote.length > 1 ? quote.charAt(1) : quote;
1653
+ if (head && head.type === "text") {
1654
+ head.value = open + head.value;
1655
+ } else {
1656
+ contents.unshift({ type: "text", value: open });
1657
+ }
1658
+ if (tail && tail.type === "text") {
1659
+ tail.value += close;
1660
+ } else {
1661
+ contents.push({ type: "text", value: close });
1662
+ }
1663
+ return contents;
1664
+ }
1665
+ function root(state, node) {
1666
+ let children = state.all(node);
1667
+ if (state.options.document || wrapNeeded(children)) {
1668
+ children = wrap(children);
1669
+ }
1670
+ const result = { type: "root", children };
1671
+ state.patch(node, result);
1672
+ return result;
1673
+ }
1674
+ function select(state, node) {
1675
+ const values = findSelectedOptions(node);
1676
+ let index = -1;
1677
+ const results = [];
1678
+ while (++index < values.length) {
1679
+ const value = values[index];
1680
+ results.push(value[1] ? value[1] + " (" + value[0] + ")" : value[0]);
1681
+ }
1682
+ if (results.length > 0) {
1683
+ const result = { type: "text", value: results.join(", ") };
1684
+ state.patch(node, result);
1685
+ return result;
1686
+ }
1687
+ }
1688
+ function strong(state, node) {
1689
+ const children = (
1690
+ /** @type {Array<PhrasingContent>} */
1691
+ state.all(node)
1692
+ );
1693
+ const result = { type: "strong", children };
1694
+ state.patch(node, result);
1695
+ return result;
1696
+ }
1697
+ function tableCell(state, node) {
1698
+ const children = (
1699
+ /** @type {Array<PhrasingContent>} */
1700
+ state.all(node)
1701
+ );
1702
+ const result = { type: "tableCell", children };
1703
+ state.patch(node, result);
1704
+ if (node.properties) {
1705
+ const rowSpan = node.properties.rowSpan;
1706
+ const colSpan = node.properties.colSpan;
1707
+ if (rowSpan || colSpan) {
1708
+ const data = (
1709
+ /** @type {Record<string, unknown>} */
1710
+ result.data || (result.data = {})
1711
+ );
1712
+ if (rowSpan) data.hastUtilToMdastTemporaryRowSpan = rowSpan;
1713
+ if (colSpan) data.hastUtilToMdastTemporaryColSpan = colSpan;
1714
+ }
1715
+ }
1716
+ return result;
1717
+ }
1718
+ function tableRow(state, node) {
1719
+ const children = state.toSpecificContent(state.all(node), create);
1720
+ const result = { type: "tableRow", children };
1721
+ state.patch(node, result);
1722
+ return result;
1723
+ }
1724
+ function create() {
1725
+ return { type: "tableCell", children: [] };
1726
+ }
1727
+ function table(state, node) {
1728
+ if (state.inTable) {
1729
+ const result2 = { type: "text", value: toText(node) };
1730
+ state.patch(node, result2);
1731
+ return result2;
1732
+ }
1733
+ state.inTable = true;
1734
+ const { align, headless } = inspect(node);
1735
+ const rows = state.toSpecificContent(state.all(node), createRow);
1736
+ if (headless) {
1737
+ rows.unshift(createRow());
1738
+ }
1739
+ let rowIndex = -1;
1740
+ while (++rowIndex < rows.length) {
1741
+ const row2 = rows[rowIndex];
1742
+ const cells = state.toSpecificContent(row2.children, createCell);
1743
+ row2.children = cells;
1744
+ }
1745
+ let columns = 1;
1746
+ rowIndex = -1;
1747
+ while (++rowIndex < rows.length) {
1748
+ const cells = rows[rowIndex].children;
1749
+ let cellIndex = -1;
1750
+ while (++cellIndex < cells.length) {
1751
+ const cell2 = cells[cellIndex];
1752
+ if (cell2.data) {
1753
+ const data = (
1754
+ /** @type {Record<string, unknown>} */
1755
+ cell2.data
1756
+ );
1757
+ const colSpan = Number.parseInt(String(data.hastUtilToMdastTemporaryColSpan), 10) || 1;
1758
+ const rowSpan = Number.parseInt(String(data.hastUtilToMdastTemporaryRowSpan), 10) || 1;
1759
+ if (colSpan > 1 || rowSpan > 1) {
1760
+ let otherRowIndex = rowIndex - 1;
1761
+ while (++otherRowIndex < rowIndex + rowSpan) {
1762
+ let colIndex = cellIndex - 1;
1763
+ while (++colIndex < cellIndex + colSpan) {
1764
+ if (!rows[otherRowIndex]) {
1765
+ break;
1766
+ }
1767
+ const newCells = [];
1768
+ if (otherRowIndex !== rowIndex || colIndex !== cellIndex) {
1769
+ newCells.push({ type: "tableCell", children: [] });
1770
+ }
1771
+ rows[otherRowIndex].children.splice(colIndex, 0, ...newCells);
1772
+ }
1773
+ }
1774
+ }
1775
+ if ("hastUtilToMdastTemporaryColSpan" in cell2.data)
1776
+ delete cell2.data.hastUtilToMdastTemporaryColSpan;
1777
+ if ("hastUtilToMdastTemporaryRowSpan" in cell2.data)
1778
+ delete cell2.data.hastUtilToMdastTemporaryRowSpan;
1779
+ if (Object.keys(cell2.data).length === 0) delete cell2.data;
1780
+ }
1781
+ }
1782
+ if (cells.length > columns) columns = cells.length;
1783
+ }
1784
+ rowIndex = -1;
1785
+ while (++rowIndex < rows.length) {
1786
+ const cells = rows[rowIndex].children;
1787
+ let cellIndex = cells.length - 1;
1788
+ while (++cellIndex < columns) {
1789
+ cells.push({ type: "tableCell", children: [] });
1790
+ }
1791
+ }
1792
+ let alignIndex = align.length - 1;
1793
+ while (++alignIndex < columns) {
1794
+ align.push(null);
1795
+ }
1796
+ state.inTable = false;
1797
+ const result = { type: "table", align, children: rows };
1798
+ state.patch(node, result);
1799
+ return result;
1800
+ }
1801
+ function inspect(node) {
1802
+ const info = { align: [null], headless: true };
1803
+ let rowIndex = 0;
1804
+ let cellIndex = 0;
1805
+ indexCSaZZzfe.visit(node, function(child) {
1806
+ if (child.type === "element") {
1807
+ if (child.tagName === "table" && node !== child) {
1808
+ return indexCSaZZzfe.SKIP;
1809
+ }
1810
+ if ((child.tagName === "th" || child.tagName === "td") && child.properties) {
1811
+ if (!info.align[cellIndex]) {
1812
+ const value = String(child.properties.align || "") || null;
1813
+ if (value === "center" || value === "left" || value === "right" || value === null) {
1814
+ info.align[cellIndex] = value;
1815
+ }
1816
+ }
1817
+ if (info.headless && rowIndex < 2 && child.tagName === "th") {
1818
+ info.headless = false;
1819
+ }
1820
+ cellIndex++;
1821
+ } else if (child.tagName === "thead") {
1822
+ info.headless = false;
1823
+ } else if (child.tagName === "tr") {
1824
+ rowIndex++;
1825
+ cellIndex = 0;
1826
+ }
1827
+ }
1828
+ });
1829
+ return info;
1830
+ }
1831
+ function createCell() {
1832
+ return { type: "tableCell", children: [] };
1833
+ }
1834
+ function createRow() {
1835
+ return { type: "tableRow", children: [] };
1836
+ }
1837
+ function text(state, node) {
1838
+ const result = { type: "text", value: node.value };
1839
+ state.patch(node, result);
1840
+ return result;
1841
+ }
1842
+ function textarea(state, node) {
1843
+ const result = { type: "text", value: toText(node) };
1844
+ state.patch(node, result);
1845
+ return result;
1846
+ }
1847
+ function wbr(state, node) {
1848
+ const result = { type: "text", value: "​" };
1849
+ state.patch(node, result);
1850
+ return result;
1851
+ }
1852
+ const nodeHandlers = {
1853
+ comment,
1854
+ doctype: ignore,
1855
+ root,
1856
+ text
1857
+ };
1858
+ const handlers = {
1859
+ // Ignore:
1860
+ applet: ignore,
1861
+ area: ignore,
1862
+ basefont: ignore,
1863
+ bgsound: ignore,
1864
+ caption: ignore,
1865
+ col: ignore,
1866
+ colgroup: ignore,
1867
+ command: ignore,
1868
+ content: ignore,
1869
+ datalist: ignore,
1870
+ dialog: ignore,
1871
+ element: ignore,
1872
+ embed: ignore,
1873
+ frame: ignore,
1874
+ frameset: ignore,
1875
+ isindex: ignore,
1876
+ keygen: ignore,
1877
+ link: ignore,
1878
+ math: ignore,
1879
+ menu: ignore,
1880
+ menuitem: ignore,
1881
+ meta: ignore,
1882
+ nextid: ignore,
1883
+ noembed: ignore,
1884
+ noframes: ignore,
1885
+ optgroup: ignore,
1886
+ option: ignore,
1887
+ param: ignore,
1888
+ script: ignore,
1889
+ shadow: ignore,
1890
+ source: ignore,
1891
+ spacer: ignore,
1892
+ style: ignore,
1893
+ svg: ignore,
1894
+ template: ignore,
1895
+ title: ignore,
1896
+ track: ignore,
1897
+ // Use children:
1898
+ abbr: all$1,
1899
+ acronym: all$1,
1900
+ bdi: all$1,
1901
+ bdo: all$1,
1902
+ big: all$1,
1903
+ blink: all$1,
1904
+ button: all$1,
1905
+ canvas: all$1,
1906
+ cite: all$1,
1907
+ data: all$1,
1908
+ details: all$1,
1909
+ dfn: all$1,
1910
+ font: all$1,
1911
+ ins: all$1,
1912
+ label: all$1,
1913
+ map: all$1,
1914
+ marquee: all$1,
1915
+ meter: all$1,
1916
+ nobr: all$1,
1917
+ noscript: all$1,
1918
+ object: all$1,
1919
+ output: all$1,
1920
+ progress: all$1,
1921
+ rb: all$1,
1922
+ rbc: all$1,
1923
+ rp: all$1,
1924
+ rt: all$1,
1925
+ rtc: all$1,
1926
+ ruby: all$1,
1927
+ slot: all$1,
1928
+ small: all$1,
1929
+ span: all$1,
1930
+ sup: all$1,
1931
+ sub: all$1,
1932
+ tbody: all$1,
1933
+ tfoot: all$1,
1934
+ thead: all$1,
1935
+ time: all$1,
1936
+ // Use children as flow.
1937
+ address: flow,
1938
+ article: flow,
1939
+ aside: flow,
1940
+ body: flow,
1941
+ center: flow,
1942
+ div: flow,
1943
+ fieldset: flow,
1944
+ figcaption: flow,
1945
+ figure: flow,
1946
+ form: flow,
1947
+ footer: flow,
1948
+ header: flow,
1949
+ hgroup: flow,
1950
+ html: flow,
1951
+ legend: flow,
1952
+ main: flow,
1953
+ multicol: flow,
1954
+ nav: flow,
1955
+ picture: flow,
1956
+ section: flow,
1957
+ // Handle.
1958
+ a,
1959
+ audio: media,
1960
+ b: strong,
1961
+ base,
1962
+ blockquote,
1963
+ br: br$1,
1964
+ code: inlineCode,
1965
+ dir: list,
1966
+ dl,
1967
+ dt: li,
1968
+ dd: li,
1969
+ del,
1970
+ em,
1971
+ h1: heading,
1972
+ h2: heading,
1973
+ h3: heading,
1974
+ h4: heading,
1975
+ h5: heading,
1976
+ h6: heading,
1977
+ hr,
1978
+ i: em,
1979
+ iframe,
1980
+ img,
1981
+ image: img,
1982
+ input,
1983
+ kbd: inlineCode,
1984
+ li,
1985
+ listing: code,
1986
+ mark: em,
1987
+ ol: list,
1988
+ p,
1989
+ plaintext: code,
1990
+ pre: code,
1991
+ q,
1992
+ s: del,
1993
+ samp: inlineCode,
1994
+ select,
1995
+ strike: del,
1996
+ strong,
1997
+ summary: p,
1998
+ table,
1999
+ td: tableCell,
2000
+ textarea,
2001
+ th: tableCell,
2002
+ tr: tableRow,
2003
+ tt: inlineCode,
2004
+ u: em,
2005
+ ul: list,
2006
+ var: inlineCode,
2007
+ video: media,
2008
+ wbr,
2009
+ xmp: code
2010
+ };
2011
+ function all$1(state, node) {
2012
+ return state.all(node);
2013
+ }
2014
+ function flow(state, node) {
2015
+ return state.toFlow(state.all(node));
2016
+ }
2017
+ function ignore() {
2018
+ }
2019
+ const own = {}.hasOwnProperty;
2020
+ function createState(options) {
2021
+ return {
2022
+ all,
2023
+ baseFound: false,
2024
+ elementById: /* @__PURE__ */ new Map(),
2025
+ frozenBaseUrl: void 0,
2026
+ handlers: { ...handlers, ...options.handlers },
2027
+ inTable: false,
2028
+ nodeHandlers: { ...nodeHandlers, ...options.nodeHandlers },
2029
+ one,
2030
+ options,
2031
+ patch,
2032
+ qNesting: 0,
2033
+ resolve,
2034
+ toFlow,
2035
+ toSpecificContent
2036
+ };
2037
+ }
2038
+ function all(parent) {
2039
+ const children = parent.children || [];
2040
+ const results = [];
2041
+ let index = -1;
2042
+ while (++index < children.length) {
2043
+ const child = children[index];
2044
+ const result = (
2045
+ /** @type {Array<MdastRootContent> | MdastRootContent | undefined} */
2046
+ this.one(child, parent)
2047
+ );
2048
+ if (Array.isArray(result)) {
2049
+ results.push(...result);
2050
+ } else if (result) {
2051
+ results.push(result);
2052
+ }
2053
+ }
2054
+ return results;
2055
+ }
2056
+ function one(node, parent) {
2057
+ if (node.type === "element") {
2058
+ if (node.properties && node.properties.dataMdast === "ignore") {
2059
+ return;
2060
+ }
2061
+ if (own.call(this.handlers, node.tagName)) {
2062
+ return this.handlers[node.tagName](this, node, parent) || void 0;
2063
+ }
2064
+ } else if (own.call(this.nodeHandlers, node.type)) {
2065
+ return this.nodeHandlers[node.type](this, node, parent) || void 0;
2066
+ }
2067
+ if ("value" in node && typeof node.value === "string") {
2068
+ const result = { type: "text", value: node.value };
2069
+ this.patch(node, result);
2070
+ return result;
2071
+ }
2072
+ if ("children" in node) {
2073
+ return this.all(node);
2074
+ }
2075
+ }
2076
+ function patch(origin, node) {
2077
+ if (origin.position) node.position = position(origin);
2078
+ }
2079
+ function resolve(url) {
2080
+ const base2 = this.frozenBaseUrl;
2081
+ if (url === null || url === void 0) {
2082
+ return "";
2083
+ }
2084
+ if (base2) {
2085
+ return String(new URL(url, base2));
2086
+ }
2087
+ return url;
2088
+ }
2089
+ function toFlow(nodes) {
2090
+ return wrap(nodes);
2091
+ }
2092
+ function toSpecificContent(nodes, build) {
2093
+ const reference = build();
2094
+ const results = [];
2095
+ let queue = [];
2096
+ let index = -1;
2097
+ while (++index < nodes.length) {
2098
+ const node = nodes[index];
2099
+ if (expectedParent(node)) {
2100
+ if (queue.length > 0) {
2101
+ node.children.unshift(...queue);
2102
+ queue = [];
2103
+ }
2104
+ results.push(node);
2105
+ } else {
2106
+ const child = (
2107
+ /** @type {ChildType} */
2108
+ node
2109
+ );
2110
+ queue.push(child);
2111
+ }
2112
+ }
2113
+ if (queue.length > 0) {
2114
+ let node = results[results.length - 1];
2115
+ if (!node) {
2116
+ node = build();
2117
+ results.push(node);
2118
+ }
2119
+ node.children.push(...queue);
2120
+ queue = [];
2121
+ }
2122
+ return results;
2123
+ function expectedParent(node) {
2124
+ return node.type === reference.type;
2125
+ }
2126
+ }
2127
+ const emptyOptions = {};
2128
+ function toMdast(tree, options) {
2129
+ const cleanTree = structuredClone$1(tree);
2130
+ const settings = options || emptyOptions;
2131
+ const transformWhitespace = rehypeMinifyWhitespace({
2132
+ newlines: settings.newlines === true
2133
+ });
2134
+ const state = createState(settings);
2135
+ let mdast;
2136
+ transformWhitespace(cleanTree);
2137
+ indexCSaZZzfe.visit(cleanTree, function(node) {
2138
+ if (node && node.type === "element" && node.properties) {
2139
+ const id = String(node.properties.id || "") || void 0;
2140
+ if (id && !state.elementById.has(id)) {
2141
+ state.elementById.set(id, node);
2142
+ }
2143
+ }
2144
+ });
2145
+ const result = state.one(cleanTree, void 0);
2146
+ if (!result) {
2147
+ mdast = { type: "root", children: [] };
2148
+ } else if (Array.isArray(result)) {
2149
+ const children = (
2150
+ /** @type {Array<MdastRootContent>} */
2151
+ result
2152
+ );
2153
+ mdast = { type: "root", children };
2154
+ } else {
2155
+ mdast = result;
2156
+ }
2157
+ indexCSaZZzfe.visit(mdast, function(node, index, parent) {
2158
+ if (node.type === "text" && index !== void 0 && parent) {
2159
+ const previous = parent.children[index - 1];
2160
+ if (previous && previous.type === node.type) {
2161
+ previous.value += node.value;
2162
+ parent.children.splice(index, 1);
2163
+ if (previous.position && node.position) {
2164
+ previous.position.end = node.position.end;
2165
+ }
2166
+ return index - 1;
2167
+ }
2168
+ node.value = node.value.replace(/[\t ]*(\r?\n|\r)[\t ]*/, "$1");
2169
+ if (parent && (parent.type === "heading" || parent.type === "paragraph" || parent.type === "root")) {
2170
+ if (!index) {
2171
+ node.value = node.value.replace(/^[\t ]+/, "");
2172
+ }
2173
+ if (index === parent.children.length - 1) {
2174
+ node.value = node.value.replace(/[\t ]+$/, "");
2175
+ }
2176
+ }
2177
+ if (!node.value) {
2178
+ parent.children.splice(index, 1);
2179
+ return index;
2180
+ }
2181
+ }
2182
+ });
2183
+ return mdast;
2184
+ }
2185
+ const defaults = { document: true };
2186
+ function rehypeRemark(destination, options) {
2187
+ if (destination && "run" in destination) {
2188
+ return async function(tree, file) {
2189
+ const mdastTree = toMdast(tree, { ...defaults, ...options });
2190
+ await destination.run(mdastTree, file);
2191
+ };
2192
+ }
2193
+ return function(tree) {
2194
+ return (
2195
+ /** @type {MdastRoot} */
2196
+ toMdast(tree, { ...defaults, ...destination })
2197
+ );
2198
+ };
2199
+ }
2200
+ exports.default = rehypeRemark;