frameboard 0.28.0 → 0.30.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.
package/dist/hook.js CHANGED
@@ -9,14 +9,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod, mod.exports), cb = null), mod.exports);
12
- var __exportAll = (all, no_symbols) => {
13
- let target = {};
12
+ var __exportAll = (all, flags) => {
13
+ let target = Object.setPrototypeOf({}, null);
14
14
  for (var name in all) __defProp(target, name, {
15
15
  get: all[name],
16
16
  enumerable: true
17
17
  });
18
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
- return target;
18
+ if (!(flags & 1)) __defProp(target, Symbol.toStringTag, { value: "Module" });
19
+ return flags & 2 ? target : Object.preventExtensions(target);
20
20
  };
21
21
  var __copyProps = (to, from, except, desc) => {
22
22
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -3537,853 +3537,137 @@ function getElementsByClassName(className, nodes, recurse = true, limit = Number
3537
3537
  function getElementsByTagType(type, nodes, recurse = true, limit = Number.POSITIVE_INFINITY) {
3538
3538
  return filter(Checks["tag_type"](type), nodes, recurse, limit);
3539
3539
  }
3540
- // node_modules/entities/dist/decode-codepoint.js
3541
- /**
3542
- * C1 Unicode control character reference replacements (code points 128–159).
3543
- * Index i gives the replacement for code point 128+i; 0 means "no replacement".
3544
- */
3545
- const c1 = [
3546
- 8364,
3547
- 0,
3548
- 8218,
3549
- 402,
3550
- 8222,
3551
- 8230,
3552
- 8224,
3553
- 8225,
3554
- 710,
3555
- 8240,
3556
- 352,
3557
- 8249,
3558
- 338,
3559
- 0,
3560
- 381,
3561
- 0,
3562
- 0,
3563
- 8216,
3564
- 8217,
3565
- 8220,
3566
- 8221,
3567
- 8226,
3568
- 8211,
3569
- 8212,
3570
- 732,
3571
- 8482,
3572
- 353,
3573
- 8250,
3574
- 339,
3575
- 0,
3576
- 382,
3577
- 376
3578
- ];
3540
+ // node_modules/dom-serializer/node_modules/entities/dist/escape.js
3579
3541
  /**
3580
- * True for NUL, UTF-16 surrogates, and values past U+10FFFF.
3581
- * @param codePoint Unicode code point to check.
3542
+ * Get the named reference for an XML special character or U+00A0.
3543
+ * @param char Code unit matched by one of the escape regexes.
3582
3544
  */
3583
- function isInvalidCodePoint(codePoint) {
3584
- return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
3545
+ function getEscape(char) {
3546
+ return char === 34 ? "&quot;" : char === 38 ? "&amp;" : char === 39 ? "&apos;" : char === 60 ? "&lt;" : char === 62 ? "&gt;" : "&nbsp;";
3585
3547
  }
3586
3548
  /**
3587
- * Replace the given code point with U+FFFD if it is NUL (0), a surrogate, or
3588
- * outside the valid Unicode range. Code points in the C1 controls range
3589
- * (128–159) are remapped to their Windows-1252 equivalents, following the
3590
- * HTML spec. All other code points are returned unchanged.
3591
- * @param codePoint Unicode code point to convert.
3549
+ * Matches exactly the characters `encodeXML` escapes: the five XML special
3550
+ * characters plus every non-ASCII code unit (lone surrogates included — no
3551
+ * `u` flag). Kept in sync with `XML_BITSET_VALUE`.
3552
+ *
3553
+ * Shared with `encodeNonAsciiHTML` in `encode.ts`. Because the regex is
3554
+ * stateful (`g` flag), every call site must set `lastIndex` before use.
3592
3555
  */
3593
- function replaceCodePoint(codePoint) {
3594
- if (isInvalidCodePoint(codePoint)) return 65533;
3595
- if (codePoint >= 128 && codePoint <= 159) return c1[codePoint - 128] || codePoint;
3596
- return codePoint;
3597
- }
3556
+ const xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
3598
3557
  /**
3599
- * XML numeric character references are the referenced Unicode code point.
3600
- * Invalid values still become U+FFFD; the HTML Windows-1252 C1 remap is not
3601
- * applied.
3602
- * @see https://www.w3.org/TR/xml/#NT-CharRef
3603
- * @param codePoint Unicode code point to convert.
3558
+ * Whether `code` (a UTF-16 code unit) is escaped by {@link encodeXML}: a
3559
+ * non-ASCII unit, or one of the five XML specials flagged in
3560
+ * `XML_BITSET_VALUE` (which is only meaningful for code units 32-63).
3561
+ * @param code Code unit to test.
3604
3562
  */
3605
- function replaceCodePointXML(codePoint) {
3606
- return isInvalidCodePoint(codePoint) ? 65533 : codePoint;
3607
- }
3608
- // node_modules/entities/dist/internal/decode-shared.js
3609
- const BASE91_INVERSE = /* #__PURE__ */ (() => {
3610
- const table = /* @__PURE__ */ new Uint8Array(127);
3611
- let code = 0;
3612
- for (let char = 33; char <= 126; char++) if (char !== 34 && char !== 36 && char !== 92) table[char] = code++;
3613
- return table;
3614
- })();
3563
+ function isXmlEscapable(code) {
3564
+ return code >= 128 || code >= 32 && code < 64 && (1342177476 >>> code & 1) === 1;
3565
+ }
3615
3566
  /**
3616
- * Decode a dictionary-encoded trie string back into its Uint16Array.
3617
- *
3618
- * Stream layout (consumed in this order):
3619
- * 1. dict1 atoms — `dict1AtomCount` uint16 values, delta+RLE encoded.
3620
- * 2. dict2 atoms — `atomCount - dict1AtomCount` values, delta+RLE.
3621
- * 3. dict2 ngrams — `ngramCount - (dictSize - dict1AtomCount)` entries,
3622
- * each a pair of slot codes that resolve to earlier slots.
3623
- * 4. dict1 ngrams — `dictSize - dict1AtomCount` entries, same shape.
3624
- * 5. data — slot codes, each expanding to one or more uint16 values.
3625
- *
3626
- * Codes use a 91-char base (printable ASCII minus `"`, `$`, `\`):
3627
- * - char1 < dictSize → 1-char code, slot = char1
3628
- * - char1 ≥ dictSize → 2-char code, slot = dictSize + (char1 - dictSize)*91 + char2
3629
- *
3630
- * Slot index → token kind:
3631
- * [0, A) dict1 atoms (1-char codes)
3632
- * [A, dictSize) dict1 ngrams (1-char codes)
3633
- * [dictSize, dictSize+D) dict2 atoms (2-char codes)
3634
- * [dictSize+D, end) dict2 ngrams (2-char codes)
3635
- *
3636
- * Both atom dicts decode before any ngram, and dict2 ngrams decode before
3637
- * dict1 ngrams. So every ngram entry references slots whose contents are
3638
- * already filled — no forward references to handle.
3567
+ * Encodes all non-ASCII characters, as well as characters not valid in XML
3568
+ * documents using XML entities.
3639
3569
  *
3640
- * This runs on library import. Flat typed arrays store each slot as either
3641
- * a plain value (`single`, covering every atom) or a range in a shared
3642
- * `pool` (ngrams).
3643
- * @param input Packed trie string.
3644
- * @param resultLength Expected number of uint16 values in the output.
3645
- * @param atomCount Total number of distinct uint16 values in the trie.
3646
- * @param dict1AtomCount Atoms in the 1-char range (`A` above).
3647
- * @param ngramCount Total number of ngram entries (dict1 + dict2).
3648
- * @param dictSize Number of 1-char code slots; the rest of `BASE - dictSize`
3649
- * first-byte values are 2-char codes.
3570
+ * If a character has no equivalent entity, a numeric hexadecimal reference
3571
+ * (eg. `&#xfc;`) will be used.
3572
+ * @param input Input string to encode.
3650
3573
  */
3651
- function decodeTrieDict(input, resultLength, atomCount, dict1AtomCount, ngramCount, dictSize) {
3652
- const base = 91;
3653
- const inputLength = input.length;
3654
- const twoCharBias = dictSize * 90;
3655
- let pos = 0;
3656
- /** Read one slot code at `pos` and return its slot index, advancing pos. */
3657
- const readSlotCode = () => {
3658
- const c1 = BASE91_INVERSE[input.charCodeAt(pos++)];
3659
- return c1 < dictSize ? c1 : c1 * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
3660
- };
3661
- const dict2AtomCount = atomCount - dict1AtomCount;
3662
- const slotCount = atomCount + ngramCount;
3663
- const single = new Int32Array(slotCount);
3664
- single.fill(-1, dict1AtomCount, dictSize);
3665
- single.fill(-1, dictSize + dict2AtomCount, slotCount);
3666
- const start = new Int32Array(slotCount);
3667
- const length = new Int32Array(slotCount);
3668
- /**
3669
- * Decode `count` ascending uint16 values from a delta+RLE stream into
3670
- * `single[off..off+count)`.
3671
- *
3672
- * code < 89 → delta = code
3673
- * code == 89 → run-length: next char encodes runLength-2; emit `runLength` consecutive +1 values
3674
- * code == 90, next < 90 → escape: delta = 89 + next * BASE + after-next
3675
- * code == 90, next == 90 → double-escape: extra char for very large deltas
3676
- * @param count
3677
- * @param off
3678
- */
3679
- function decodeDelta(count, off) {
3680
- let previous = 0;
3681
- let slot = off;
3682
- const end = off + count;
3683
- while (slot < end) {
3684
- const code = BASE91_INVERSE[input.charCodeAt(pos++)];
3685
- if (code < 89) {
3686
- previous += code;
3687
- single[slot++] = previous;
3688
- } else if (code === 89) {
3689
- let runLength = BASE91_INVERSE[input.charCodeAt(pos++)] + 2;
3690
- while (runLength--) single[slot++] = ++previous;
3691
- } else {
3692
- const next = BASE91_INVERSE[input.charCodeAt(pos++)];
3693
- previous += 89 + (next < 90 ? next * base + BASE91_INVERSE[input.charCodeAt(pos++)] : BASE91_INVERSE[input.charCodeAt(pos++)] * 8281 + BASE91_INVERSE[input.charCodeAt(pos++)] * base + BASE91_INVERSE[input.charCodeAt(pos++)]);
3694
- single[slot++] = previous;
3574
+ function encodeXML(input) {
3575
+ const { length } = input;
3576
+ let out;
3577
+ let last = 0;
3578
+ let index = 0;
3579
+ while (index < length) {
3580
+ const char = input.charCodeAt(index);
3581
+ if (!isXmlEscapable(char)) {
3582
+ const bound = Math.min(index + 32, length);
3583
+ let next = index + 1;
3584
+ while (next < bound && !isXmlEscapable(input.charCodeAt(next))) next++;
3585
+ if (next < bound) {
3586
+ index = next;
3587
+ continue;
3695
3588
  }
3589
+ if (next >= length) break;
3590
+ xmlEncodeRegex.lastIndex = next;
3591
+ if (!xmlEncodeRegex.test(input)) break;
3592
+ index = xmlEncodeRegex.lastIndex - 1;
3593
+ continue;
3696
3594
  }
3595
+ if (out === void 0) out = input.substring(0, index);
3596
+ else if (last !== index) out += input.substring(last, index);
3597
+ if (char < 64) {
3598
+ out += getEscape(char);
3599
+ last = index += 1;
3600
+ continue;
3601
+ }
3602
+ const cp = input.codePointAt(index);
3603
+ out += `&#x${cp.toString(16)};`;
3604
+ if (cp !== char) index++;
3605
+ last = index += 1;
3697
3606
  }
3698
- decodeDelta(dict1AtomCount, 0);
3699
- decodeDelta(dict2AtomCount, dictSize);
3700
- const references = new Int32Array(ngramCount * 2);
3701
- let poolSize = 0;
3702
- let ngramIndex = 0;
3703
- /**
3704
- * Read `count` ngram entries (each = 2 slot-code references) for the slots
3705
- * starting at `startSlot`, recording references and assigning pool ranges.
3706
- * @param count
3707
- * @param startSlot
3708
- */
3709
- function readNgramReferences(count, startSlot) {
3710
- for (let index = 0; index < count; index++) {
3711
- const slot = startSlot + index;
3712
- const a = readSlotCode();
3713
- const b = readSlotCode();
3714
- references[ngramIndex * 2] = a;
3715
- references[ngramIndex * 2 + 1] = b;
3716
- ngramIndex += 1;
3717
- start[slot] = poolSize;
3718
- const entryLength = (single[a] < 0 ? length[a] : 1) + (single[b] < 0 ? length[b] : 1);
3719
- length[slot] = entryLength;
3720
- poolSize += entryLength;
3721
- }
3722
- }
3723
- readNgramReferences(ngramCount - dictSize + dict1AtomCount, dictSize + dict2AtomCount);
3724
- readNgramReferences(dictSize - dict1AtomCount, dict1AtomCount);
3725
- const pool = new Uint16Array(poolSize);
3726
- let write = 0;
3727
- for (let index = 0; index < ngramIndex; index++) for (let half = 0; half < 2; half++) {
3728
- const source = references[index * 2 + half];
3729
- const value = single[source];
3730
- if (value < 0) {
3731
- let read = start[source];
3732
- const readEnd = read + length[source];
3733
- while (read < readEnd) pool[write++] = pool[read++];
3734
- } else pool[write++] = value;
3735
- }
3736
- const out = new Uint16Array(resultLength);
3737
- let outIndex = 0;
3738
- while (pos < inputLength) {
3739
- let slot = BASE91_INVERSE[input.charCodeAt(pos++)];
3740
- if (slot >= dictSize) slot = slot * base - twoCharBias + BASE91_INVERSE[input.charCodeAt(pos++)];
3741
- const value = single[slot];
3742
- if (value < 0) {
3743
- let read = start[slot];
3744
- const readEnd = read + length[slot];
3745
- while (read < readEnd) out[outIndex++] = pool[read++];
3746
- } else out[outIndex++] = value;
3747
- }
3607
+ if (out === void 0) return input;
3608
+ if (last < length) out += input.substr(last);
3748
3609
  return out;
3749
3610
  }
3750
- // node_modules/entities/dist/generated/decode-data-html.js
3751
- /** Packed HTML decode trie data. */
3752
- const htmlDecodeTree = /* #__PURE__ */ decodeTrieDict("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%7|~!G~!J~!G&~#pb~(Df}#%}*&}#%##%##%##&#-}&'#'&%#.++}%mI,#,@&(}*%}*'%&##&#%##%}&0}#.},U},%}+%}&%}#%##&}B%(}(%}+%)})%##%#&}&%##%&}<%}>%#%&}*%}(%}9%}/%})%}*%}*%}?&}&%}3%}&*#%})%#%#)}#&#-#+*%E%%'%'#%}#*V##&##I}#&&##%&%#&&Qf%%))w/0+&%#(#.%-''''++++7}>%4'',##1,#%#&%##&#'##&#*#9)%&%}#*}%,#+P(%A&%#'&##wSD',9E00#y#@}(+}&%&>~!#~!X}#*}(&&}(&}(,%}%&#+&}#&}I%#%}%)#(},'%#*}4%%#%}(''}#/##(##),%-##%%)#&}(.}&%#&}%%}*&#%},&&}&%}#%*'#%})%}D&}&%}-&}6&#&}-,%}#%})-(~+`~,=?~I9'9%~!,#%})%})%}@%}?%}(~!?~#<~#pP~#BG~#=1#%K+~#?#~%;)~#A~#mF1~#A'~'X%'~#lR~#N~'N~#r~#m#-~#i'?%#'%~#B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hK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P", 13494, 2713, 49, 25, 61);
3753
- // node_modules/entities/dist/generated/decode-data-xml.js
3754
- /** Packed XML decode trie data. */
3755
- const xmlDecodeTree = /* #__PURE__ */ new Uint16Array([
3756
- 512,
3757
- 26465,
3758
- 29036,
3759
- 7,
3760
- 0,
3761
- 2,
3762
- 4,
3763
- 116,
3764
- 24638,
3765
- 116,
3766
- 24636,
3767
- 8693,
3768
- 29807,
3769
- 24610,
3770
- 621,
3771
- 1,
3772
- 0,
3773
- 0,
3774
- 3,
3775
- 112,
3776
- 24614,
3777
- 111,
3778
- 115,
3779
- 24615
3780
- ]);
3781
- // node_modules/entities/dist/internal/bin-trie-flags.js
3782
3611
  /**
3783
- * Bit flags & masks for the binary trie encoding used for entity decoding.
3784
- *
3785
- * The trie is a flat `Uint16Array`. Every node starts with one header word:
3786
- *
3787
- * 15..14 VALUE_LENGTH Number of words the value occupies, +1.
3788
- * 0 = no value; 1 = value inline in bits 12..0;
3789
- * 2/3 = value in the 1/2 words after the header.
3790
- * 13 FLAG13 If VALUE_LENGTH > 0: semicolon required ("strict"
3791
- * entity; `;` is never stored as a branch).
3792
- * If VALUE_LENGTH == 0: this node is a compact run.
3793
- * 12..7 BRANCH_LENGTH Number of branches (or run length for runs).
3794
- * 6..0 JUMP_TABLE Jump-table offset / single-branch char / first
3795
- * run char (see below).
3796
- *
3797
- * Branch data follows the header and any value words. Its shape is selected
3798
- * by (JUMP_TABLE, BRANCH_LENGTH) in the header:
3799
- *
3800
- * Single branch JUMP_TABLE = the only child's char, BRANCH_LENGTH = 0.
3801
- * No branch words; the child node follows immediately.
3802
- * Jump table JUMP_TABLE = first covered char (> 0), BRANCH_LENGTH =
3803
- * table length. One word per covered char: 0 = no branch,
3804
- * otherwise the child's offset from the END of the table,
3805
- * +1 (so 0 stays the no-branch sentinel).
3806
- * Dictionary JUMP_TABLE = 0, BRANCH_LENGTH = number of branches.
3807
- * ceil(n/2) words of sorted keys packed two per word
3808
- * (low byte first), then n pointer words storing the
3809
- * child's offset from the END of the branch data.
3810
- * Compact run VALUE_LENGTH = 0, FLAG13 set. BRANCH_LENGTH = run
3811
- * length (3..63), JUMP_TABLE = first char; remaining run
3812
- * chars packed two per word after the header. The target
3813
- * node follows the packed words immediately.
3814
- *
3815
- * Pointers are end-relative (rather than relative to the pointer's own
3816
- * position) because that makes the common "child encoded right after the
3817
- * branch data" case a small constant, which compresses far better. Offsets
3818
- * to already-encoded (shared) nodes wrap via uint16 modulo arithmetic; the
3819
- * decoder masks navigation results with `& 0xff_ff` to match.
3612
+ * Escape `data` using `re`, mapping each matched character to its entity.
3613
+ * Every match is one UTF-16 code unit, so its index is `lastIndex - 1`.
3614
+ * @param re Global regex matching exactly the characters to escape
3615
+ * (`"`, `&`, `'`, `<`, `>`, `\u00A0` at most).
3616
+ * @param data String to escape.
3820
3617
  */
3821
- var BinTrieFlags;
3822
- (function(BinTrieFlags) {
3823
- BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
3824
- BinTrieFlags[BinTrieFlags["FLAG13"] = 8192] = "FLAG13";
3825
- BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 8064] = "BRANCH_LENGTH";
3826
- BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
3827
- /** Bits 12..0: the inline value of a VALUE_LENGTH = 1 header word. */
3828
- BinTrieFlags[BinTrieFlags["VALUE_MASK"] = 8191] = "VALUE_MASK";
3829
- })(BinTrieFlags || (BinTrieFlags = {}));
3830
- // node_modules/entities/dist/decode.js
3831
- var CharCodes;
3832
- (function(CharCodes) {
3833
- CharCodes[CharCodes["AMP"] = 38] = "AMP";
3834
- CharCodes[CharCodes["NUM"] = 35] = "NUM";
3835
- CharCodes[CharCodes["SEMI"] = 59] = "SEMI";
3836
- CharCodes[CharCodes["EQUALS"] = 61] = "EQUALS";
3837
- CharCodes[CharCodes["ZERO"] = 48] = "ZERO";
3838
- CharCodes[CharCodes["NINE"] = 57] = "NINE";
3839
- CharCodes[CharCodes["LOWER_A"] = 97] = "LOWER_A";
3840
- CharCodes[CharCodes["LOWER_X"] = 120] = "LOWER_X";
3841
- })(CharCodes || (CharCodes = {}));
3842
- /** Bit that needs to be set to convert an upper case ASCII character to lower case */
3843
- const TO_LOWER_BIT = 32;
3618
+ function escapeWithRegex(re, data) {
3619
+ re.lastIndex = 0;
3620
+ if (!re.test(data)) return data;
3621
+ let out = "";
3622
+ let last = 0;
3623
+ do {
3624
+ const index = re.lastIndex - 1;
3625
+ if (last !== index) out += data.substring(last, index);
3626
+ const char = data.charCodeAt(index);
3627
+ out += getEscape(char);
3628
+ last = index + 1;
3629
+ } while (re.test(data));
3630
+ return out + data.substring(last);
3631
+ }
3632
+ const attributeEscapeRegex = /["&\u{A0}]/gu;
3844
3633
  /**
3845
- * Unsigned subtraction trick: (code - lo) >>> 0 wraps negatives to large
3846
- * values, so a single `<=` covers the entire [lo..hi] range check.
3847
- * @param code Code point to check.
3634
+ * Encodes all characters that have to be escaped in HTML attributes,
3635
+ * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
3636
+ * @param data String to escape.
3848
3637
  */
3849
- function isNumber(code) {
3850
- return code - CharCodes.ZERO >>> 0 <= 9;
3851
- }
3852
- function isHexadecimalCharacter(code) {
3853
- return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 5;
3638
+ function escapeAttribute(data) {
3639
+ return escapeWithRegex(attributeEscapeRegex, data);
3854
3640
  }
3855
- function isAlpha(code) {
3856
- return (code | TO_LOWER_BIT) - CharCodes.LOWER_A >>> 0 <= 25;
3641
+ const textEscapeRegex = /[&<>\u{A0}]/gu;
3642
+ /**
3643
+ * Encodes all characters that have to be escaped in HTML text,
3644
+ * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
3645
+ * @param data String to escape.
3646
+ */
3647
+ function escapeText(data) {
3648
+ return escapeWithRegex(textEscapeRegex, data);
3857
3649
  }
3650
+ // node_modules/dom-serializer/dist/foreign-names.js
3858
3651
  /**
3859
- * Checks if the given character is a valid end character for an entity in an attribute.
3860
- *
3861
- * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
3862
- * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
3863
- * @param code Code point to check.
3652
+ * Mixed-case SVG and MathML element names recognized in foreign content.
3653
+ * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
3864
3654
  */
3865
- function isEntityInAttributeInvalidEnd(code) {
3866
- return code === CharCodes.EQUALS || isAlpha(code) || isNumber(code);
3867
- }
3868
- var EntityDecoderState;
3869
- (function(EntityDecoderState) {
3870
- EntityDecoderState[EntityDecoderState["EntityStart"] = 0] = "EntityStart";
3871
- EntityDecoderState[EntityDecoderState["NumericStart"] = 1] = "NumericStart";
3872
- EntityDecoderState[EntityDecoderState["NumericDecimal"] = 2] = "NumericDecimal";
3873
- EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
3874
- EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
3875
- })(EntityDecoderState || (EntityDecoderState = {}));
3655
+ const elementNames = new Map("altGlyph altGlyphDef altGlyphItem animateColor animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject glyphRef linearGradient radialGradient textPath".split(" ").map((name) => [name.toLowerCase(), name]));
3876
3656
  /**
3877
- * Decoding mode for named entities.
3657
+ * Mixed-case SVG and MathML attribute names recognized in foreign content.
3658
+ * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
3878
3659
  */
3879
- var DecodingMode;
3880
- (function(DecodingMode) {
3881
- /** Entities in text nodes that can end with any character. */
3882
- DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
3883
- /** Only allow entities terminated with a semicolon. */
3884
- DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
3885
- /** Entities in attributes have limitations on ending characters. */
3886
- DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
3887
- })(DecodingMode || (DecodingMode = {}));
3660
+ const attributeNames = new Map("definitionURL attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits diffuseConstant edgeMode filterUnits glyphRef gradientTransform gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan".split(" ").map((name) => [name.toLowerCase(), name]));
3661
+ // node_modules/dom-serializer/dist/index.js
3662
+ /** Elements whose text content is never entity-encoded. */
3663
+ const unencodedElements = new Set("style script xmp iframe noembed noframes plaintext noscript".split(" "));
3664
+ /** HTML void elements — they cannot have children. */
3665
+ const voidElements = new Set("area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr".split(" "));
3666
+ /** Elements that switch the parser into foreign (XML-like) mode. */
3667
+ const foreignElements = /* @__PURE__ */ new Set(["svg", "math"]);
3888
3668
  /**
3889
- * Token decoder with support of writing partial entities.
3890
- */
3891
- var EntityDecoder = class {
3892
- decodeTree;
3893
- emitCodePoint;
3894
- errors;
3895
- /** The current state of the decoder. */
3896
- state = EntityDecoderState.EntityStart;
3897
- /** Characters that were consumed while parsing an entity. */
3898
- consumed = 1;
3899
- /**
3900
- * The result of the entity.
3901
- *
3902
- * For named entities: the trie index of the best legacy match so far
3903
- * (0 = none). For numeric entities: the accumulated code point.
3904
- */
3905
- result = 0;
3906
- /** The current index in the decode tree. */
3907
- treeIndex = 0;
3908
- /**
3909
- * Characters consumed since the last recorded legacy match, plus one.
3910
- * Invariant at the top of the `stateNamedEntity` loop: `excess` equals
3911
- * the number of unrecorded consumed characters + 1.
3912
- */
3913
- excess = 1;
3914
- /** The mode in which the decoder is operating. */
3915
- decodeMode = DecodingMode.Strict;
3916
- /** The number of characters that have been consumed in the current run. */
3917
- runConsumed = 0;
3918
- constructor(decodeTree, emitCodePoint, errors) {
3919
- this.decodeTree = decodeTree;
3920
- this.emitCodePoint = emitCodePoint;
3921
- this.errors = errors;
3922
- }
3923
- /**
3924
- * Resets the instance to make it reusable.
3925
- * @param decodeMode Entity decoding mode to use.
3926
- */
3927
- startEntity(decodeMode) {
3928
- this.decodeMode = decodeMode;
3929
- this.state = EntityDecoderState.EntityStart;
3930
- this.result = 0;
3931
- this.treeIndex = 0;
3932
- this.excess = 1;
3933
- this.consumed = 1;
3934
- this.runConsumed = 0;
3935
- }
3936
- /**
3937
- * Write an entity to the decoder. This can be called multiple times with partial entities.
3938
- * If the entity is incomplete, the decoder will return -1.
3939
- *
3940
- * Mirrors the non-streaming `decodeWithTrie`, but with the ability to stop decoding if the
3941
- * entity is incomplete, and resume when the next string is written.
3942
- * @param input The string containing the entity (or a continuation of the entity).
3943
- * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
3944
- * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
3945
- */
3946
- write(input, offset) {
3947
- switch (this.state) {
3948
- case EntityDecoderState.EntityStart:
3949
- if (input.charCodeAt(offset) === CharCodes.NUM) {
3950
- this.state = EntityDecoderState.NumericStart;
3951
- this.consumed += 1;
3952
- return this.stateNumericStart(input, offset + 1);
3953
- }
3954
- this.state = EntityDecoderState.NamedEntity;
3955
- return this.stateNamedEntity(input, offset);
3956
- case EntityDecoderState.NumericStart: return this.stateNumericStart(input, offset);
3957
- case EntityDecoderState.NumericDecimal: return this.stateNumericDecimal(input, offset);
3958
- case EntityDecoderState.NumericHex: return this.stateNumericHex(input, offset);
3959
- default: return this.stateNamedEntity(input, offset);
3960
- }
3961
- }
3962
- /**
3963
- * Switches between the numeric decimal and hexadecimal states.
3964
- *
3965
- * Equivalent to the `Numeric character reference state` in the HTML spec.
3966
- * @param input The string containing the entity (or a continuation of the entity).
3967
- * @param offset The current offset.
3968
- * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
3969
- */
3970
- stateNumericStart(input, offset) {
3971
- if (offset >= input.length) return -1;
3972
- if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
3973
- this.state = EntityDecoderState.NumericHex;
3974
- this.consumed += 1;
3975
- return this.stateNumericHex(input, offset + 1);
3976
- }
3977
- this.state = EntityDecoderState.NumericDecimal;
3978
- return this.stateNumericDecimal(input, offset);
3979
- }
3980
- /**
3981
- * Parses a hexadecimal numeric entity.
3982
- *
3983
- * Equivalent to the `Hexademical character reference state` in the HTML
3984
- * spec. Digit parsing matches the hex loop in `parseNumericEntity`.
3985
- * The accumulated value is preserved for numeric validation callbacks.
3986
- * @param input The string containing the entity (or a continuation of the entity).
3987
- * @param offset The current offset.
3988
- * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
3989
- */
3990
- stateNumericHex(input, offset) {
3991
- const inputLength = input.length;
3992
- let { result } = this;
3993
- let { consumed } = this;
3994
- while (offset < inputLength) {
3995
- const char = input.charCodeAt(offset);
3996
- if (isNumber(char) || isHexadecimalCharacter(char)) {
3997
- const digit = char <= CharCodes.NINE ? char - CharCodes.ZERO : (char | TO_LOWER_BIT) - CharCodes.LOWER_A + 10;
3998
- result = result * 16 + digit;
3999
- consumed += 1;
4000
- offset += 1;
4001
- } else {
4002
- this.result = result;
4003
- this.consumed = consumed;
4004
- return this.emitNumericEntity(char, 3);
4005
- }
4006
- }
4007
- this.result = result;
4008
- this.consumed = consumed;
4009
- return -1;
4010
- }
4011
- /**
4012
- * Parses a decimal numeric entity.
4013
- *
4014
- * Equivalent to the `Decimal character reference state` in the HTML
4015
- * spec. Digit parsing matches the decimal loop in `parseNumericEntity`.
4016
- * The accumulated value is preserved for numeric validation callbacks.
4017
- * @param input The string containing the entity (or a continuation of the entity).
4018
- * @param offset The current offset.
4019
- * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
4020
- */
4021
- stateNumericDecimal(input, offset) {
4022
- const inputLength = input.length;
4023
- let { result } = this;
4024
- let { consumed } = this;
4025
- while (offset < inputLength) {
4026
- const digit = input.charCodeAt(offset) - CharCodes.ZERO;
4027
- if (digit >>> 0 > 9) {
4028
- this.result = result;
4029
- this.consumed = consumed;
4030
- return this.emitNumericEntity(digit + CharCodes.ZERO, 2);
4031
- }
4032
- result = result * 10 + digit;
4033
- consumed += 1;
4034
- offset += 1;
4035
- }
4036
- this.result = result;
4037
- this.consumed = consumed;
4038
- return -1;
4039
- }
4040
- /**
4041
- * Validate and emit a numeric entity.
4042
- *
4043
- * Implements the logic from the `Hexademical character reference start
4044
- * state` and `Numeric character reference end state` in the HTML spec.
4045
- * @param lastCp The last code point of the entity. Used to see if the
4046
- * entity was terminated with a semicolon.
4047
- * @param expectedLength The minimum number of characters that should be
4048
- * consumed. Used to validate that at least one digit
4049
- * was consumed.
4050
- * @returns The number of characters that were consumed.
4051
- */
4052
- emitNumericEntity(lastCp, expectedLength) {
4053
- if (this.consumed <= expectedLength) {
4054
- this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
4055
- return 0;
4056
- }
4057
- if (lastCp === CharCodes.SEMI) this.consumed += 1;
4058
- else if (this.decodeMode === DecodingMode.Strict) return 0;
4059
- this.emitCodePoint((this.decodeTree === xmlDecodeTree ? replaceCodePointXML : replaceCodePoint)(this.result), this.consumed);
4060
- if (this.errors) {
4061
- if (lastCp !== CharCodes.SEMI) this.errors.missingSemicolonAfterCharacterReference();
4062
- this.errors.validateNumericCharacterReference(this.result);
4063
- }
4064
- return this.consumed;
4065
- }
4066
- /**
4067
- * Flush locally-tracked walk state back to the fields, then emit the
4068
- * recorded legacy match or reject (cold path — at most once per
4069
- * entity). Called after failed navigation (leaf node, branch miss, or
4070
- * compact-run mismatch). In attribute mode, reject if no legacy was
4071
- * recorded at the current node, if we descended past it, or if the
4072
- * pending input character is an invalid attribute terminator.
4073
- * @param consumed Locally-tracked consumed count.
4074
- * @param excess Locally-tracked excess count.
4075
- * @param char Pending input character (may be the mismatching char).
4076
- * @param valueLength Value length at the current trie node.
4077
- */
4078
- flushAndEmitLegacyOrReject(consumed, excess, char, valueLength) {
4079
- this.consumed = consumed;
4080
- this.excess = excess;
4081
- return this.result === 0 || this.decodeMode === DecodingMode.Attribute && (valueLength === 0 || excess > 1 || isEntityInAttributeInvalidEnd(char)) ? 0 : this.emitNotTerminatedNamedEntity();
4082
- }
4083
- /**
4084
- * Parses a named entity.
4085
- *
4086
- * Equivalent to the `Named character reference state` in the HTML spec.
4087
- * @param input The string containing the entity (or a continuation of the entity).
4088
- * @param offset The current offset.
4089
- * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
4090
- */
4091
- stateNamedEntity(input, offset) {
4092
- const { decodeTree } = this;
4093
- const inputLength = input.length;
4094
- const isStrict = this.decodeMode === DecodingMode.Strict;
4095
- let { treeIndex } = this;
4096
- let { excess } = this;
4097
- let { consumed } = this;
4098
- let current = decodeTree[treeIndex];
4099
- while (offset < inputLength) {
4100
- while ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === 0 && (current & BinTrieFlags.JUMP_TABLE) !== 0) {
4101
- const char = input.charCodeAt(offset);
4102
- const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
4103
- const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
4104
- if (branchCount === 0) {
4105
- if (char !== jumpOffset) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
4106
- treeIndex += 1;
4107
- } else {
4108
- const slot = char - jumpOffset;
4109
- if (slot >>> 0 >= branchCount) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
4110
- const stored = decodeTree[treeIndex + 1 + slot];
4111
- if (stored === 0) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
4112
- treeIndex = treeIndex + branchCount + stored & 65535;
4113
- }
4114
- current = decodeTree[treeIndex];
4115
- offset += 1;
4116
- excess += 1;
4117
- if (offset >= inputLength) break;
4118
- }
4119
- if (offset >= inputLength) break;
4120
- if ((current & (BinTrieFlags.VALUE_LENGTH | BinTrieFlags.FLAG13)) === BinTrieFlags.FLAG13) {
4121
- const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
4122
- let { runConsumed } = this;
4123
- if (runConsumed === 0) {
4124
- const char = input.charCodeAt(offset);
4125
- if (char !== (current & BinTrieFlags.JUMP_TABLE)) return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
4126
- offset += 1;
4127
- excess += 1;
4128
- runConsumed = 1;
4129
- }
4130
- while (runConsumed < runLength) {
4131
- if (offset >= inputLength) {
4132
- this.treeIndex = treeIndex;
4133
- this.excess = excess;
4134
- this.consumed = consumed;
4135
- this.runConsumed = runConsumed;
4136
- return -1;
4137
- }
4138
- const charIndexInPacked = runConsumed - 1;
4139
- const expectedChar = decodeTree[treeIndex + 1 + (charIndexInPacked >> 1)] >> ((charIndexInPacked & 1) << 3) & 255;
4140
- const char = input.charCodeAt(offset);
4141
- if (char !== expectedChar) {
4142
- this.runConsumed = 0;
4143
- return this.flushAndEmitLegacyOrReject(consumed, excess, char, 0);
4144
- }
4145
- offset += 1;
4146
- excess += 1;
4147
- runConsumed += 1;
4148
- }
4149
- this.runConsumed = 0;
4150
- treeIndex += 1 + (runLength >> 1);
4151
- current = decodeTree[treeIndex];
4152
- continue;
4153
- }
4154
- const valueLength = current >>> 14;
4155
- const char = input.charCodeAt(offset);
4156
- if (valueLength !== 0) {
4157
- if (!isStrict && (current & BinTrieFlags.FLAG13) === 0) {
4158
- this.result = treeIndex;
4159
- consumed += excess - 1;
4160
- excess = 1;
4161
- }
4162
- if (char === CharCodes.SEMI) return this.emitNamedEntityData(treeIndex, valueLength, consumed + excess);
4163
- if (valueLength === 1) return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
4164
- }
4165
- const next = determineBranch(decodeTree, current, treeIndex + (valueLength || 1), char);
4166
- if (next < 0) return this.flushAndEmitLegacyOrReject(consumed, excess, char, valueLength);
4167
- treeIndex = next;
4168
- current = decodeTree[treeIndex];
4169
- offset += 1;
4170
- excess += 1;
4171
- }
4172
- if (!isStrict && current >>> 14 !== 0 && (current & BinTrieFlags.FLAG13) === 0) {
4173
- this.result = treeIndex;
4174
- consumed += excess - 1;
4175
- excess = 1;
4176
- }
4177
- this.treeIndex = treeIndex;
4178
- this.excess = excess;
4179
- this.consumed = consumed;
4180
- return -1;
4181
- }
4182
- /**
4183
- * Emit a named entity that was not terminated with a semicolon.
4184
- * @returns The number of characters consumed.
4185
- */
4186
- emitNotTerminatedNamedEntity() {
4187
- const { result, decodeTree } = this;
4188
- const valueLength = decodeTree[result] >>> 14;
4189
- this.emitNamedEntityData(result, valueLength, this.consumed);
4190
- this.errors?.missingSemicolonAfterCharacterReference();
4191
- return this.consumed;
4192
- }
4193
- /**
4194
- * Emit a named entity.
4195
- * @param result The index of the entity in the decode tree.
4196
- * @param valueLength Encoded value length (header plus any value words).
4197
- * @param consumed The number of characters consumed.
4198
- * @returns The number of characters consumed.
4199
- */
4200
- emitNamedEntityData(result, valueLength, consumed) {
4201
- const { decodeTree } = this;
4202
- this.emitCodePoint(valueLength === 1 ? decodeTree[result] & BinTrieFlags.VALUE_MASK : decodeTree[result + 1], consumed);
4203
- if (valueLength === 3) this.emitCodePoint(decodeTree[result + 2], consumed);
4204
- return consumed;
4205
- }
4206
- /**
4207
- * Signal to the parser that the end of the input was reached.
4208
- *
4209
- * Remaining data will be emitted and relevant errors will be produced.
4210
- * @returns The number of characters consumed.
4211
- */
4212
- end() {
4213
- switch (this.state) {
4214
- case EntityDecoderState.NamedEntity: return this.result !== 0 && (this.decodeMode !== DecodingMode.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
4215
- case EntityDecoderState.NumericDecimal: return this.emitNumericEntity(0, 2);
4216
- case EntityDecoderState.NumericHex: return this.emitNumericEntity(0, 3);
4217
- case EntityDecoderState.NumericStart:
4218
- this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
4219
- return 0;
4220
- default: return 0;
4221
- }
4222
- }
4223
- };
4224
- /**
4225
- * Determines the branch of the current node that is taken given the current
4226
- * character. This function is used to traverse the trie.
4227
- *
4228
- * See `BinTrieFlags` for the branch-data layouts handled here.
4229
- * @param decodeTree The trie.
4230
- * @param current The current node's header word.
4231
- * @param nodeIndex Index of the node's first branch-data word (the header
4232
- * plus any value words have been skipped by the caller).
4233
- * @param char The current character.
4234
- * @returns The index of the next node, or -1 if no branch is taken.
4235
- */
4236
- function determineBranch(decodeTree, current, nodeIndex, char) {
4237
- const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
4238
- const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
4239
- if (jumpOffset) {
4240
- if (branchCount === 0) return char === jumpOffset ? nodeIndex : -1;
4241
- const slot = char - jumpOffset;
4242
- if (slot >>> 0 >= branchCount) return -1;
4243
- const stored = decodeTree[nodeIndex + slot];
4244
- return stored === 0 ? -1 : nodeIndex + branchCount + stored - 1 & 65535;
4245
- }
4246
- if (branchCount === 0) return -1;
4247
- const packedKeySlots = branchCount + 1 >> 1;
4248
- const branchEnd = nodeIndex + packedKeySlots + branchCount;
4249
- for (let index = 0; index < branchCount; index++) {
4250
- const key = decodeTree[nodeIndex + (index >> 1)] >> ((index & 1) << 3) & 255;
4251
- if (key === char) return branchEnd + decodeTree[nodeIndex + packedKeySlots + index] & 65535;
4252
- if (key > char) return -1;
4253
- }
4254
- return -1;
4255
- }
4256
- // node_modules/entities/dist/escape.js
4257
- /**
4258
- * Get the named reference for an XML special character or U+00A0.
4259
- * @param char Code unit matched by one of the escape regexes.
4260
- */
4261
- function getEscape(char) {
4262
- return char === 34 ? "&quot;" : char === 38 ? "&amp;" : char === 39 ? "&apos;" : char === 60 ? "&lt;" : char === 62 ? "&gt;" : "&nbsp;";
4263
- }
4264
- /**
4265
- * Matches exactly the characters `encodeXML` escapes: the five XML special
4266
- * characters plus every non-ASCII code unit (lone surrogates included — no
4267
- * `u` flag). Kept in sync with `XML_BITSET_VALUE`.
4268
- *
4269
- * Shared with `encodeNonAsciiHTML` in `encode.ts`. Because the regex is
4270
- * stateful (`g` flag), every call site must set `lastIndex` before use.
4271
- */
4272
- const xmlEncodeRegex = /["&'<>\u0080-\uFFFF]/g;
4273
- /**
4274
- * Whether `code` (a UTF-16 code unit) is escaped by {@link encodeXML}: a
4275
- * non-ASCII unit, or one of the five XML specials flagged in
4276
- * `XML_BITSET_VALUE` (which is only meaningful for code units 32-63).
4277
- * @param code Code unit to test.
4278
- */
4279
- function isXmlEscapable(code) {
4280
- return code >= 128 || code >= 32 && code < 64 && (1342177476 >>> code & 1) === 1;
4281
- }
4282
- /**
4283
- * Encodes all non-ASCII characters, as well as characters not valid in XML
4284
- * documents using XML entities.
4285
- *
4286
- * If a character has no equivalent entity, a numeric hexadecimal reference
4287
- * (eg. `&#xfc;`) will be used.
4288
- * @param input Input string to encode.
4289
- */
4290
- function encodeXML(input) {
4291
- const { length } = input;
4292
- let out;
4293
- let last = 0;
4294
- let index = 0;
4295
- while (index < length) {
4296
- const char = input.charCodeAt(index);
4297
- if (!isXmlEscapable(char)) {
4298
- const bound = Math.min(index + 32, length);
4299
- let next = index + 1;
4300
- while (next < bound && !isXmlEscapable(input.charCodeAt(next))) next++;
4301
- if (next < bound) {
4302
- index = next;
4303
- continue;
4304
- }
4305
- if (next >= length) break;
4306
- xmlEncodeRegex.lastIndex = next;
4307
- if (!xmlEncodeRegex.test(input)) break;
4308
- index = xmlEncodeRegex.lastIndex - 1;
4309
- continue;
4310
- }
4311
- if (out === void 0) out = input.substring(0, index);
4312
- else if (last !== index) out += input.substring(last, index);
4313
- if (char < 64) {
4314
- out += getEscape(char);
4315
- last = index += 1;
4316
- continue;
4317
- }
4318
- const cp = input.codePointAt(index);
4319
- out += `&#x${cp.toString(16)};`;
4320
- if (cp !== char) index++;
4321
- last = index += 1;
4322
- }
4323
- if (out === void 0) return input;
4324
- if (last < length) out += input.substr(last);
4325
- return out;
4326
- }
4327
- /**
4328
- * Escape `data` using `re`, mapping each matched character to its entity.
4329
- * Every match is one UTF-16 code unit, so its index is `lastIndex - 1`.
4330
- * @param re Global regex matching exactly the characters to escape
4331
- * (`"`, `&`, `'`, `<`, `>`, `\u00A0` at most).
4332
- * @param data String to escape.
4333
- */
4334
- function escapeWithRegex(re, data) {
4335
- re.lastIndex = 0;
4336
- if (!re.test(data)) return data;
4337
- let out = "";
4338
- let last = 0;
4339
- do {
4340
- const index = re.lastIndex - 1;
4341
- if (last !== index) out += data.substring(last, index);
4342
- const char = data.charCodeAt(index);
4343
- out += getEscape(char);
4344
- last = index + 1;
4345
- } while (re.test(data));
4346
- return out + data.substring(last);
4347
- }
4348
- const attributeEscapeRegex = /["&\u{A0}]/gu;
4349
- /**
4350
- * Encodes all characters that have to be escaped in HTML attributes,
4351
- * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
4352
- * @param data String to escape.
4353
- */
4354
- function escapeAttribute(data) {
4355
- return escapeWithRegex(attributeEscapeRegex, data);
4356
- }
4357
- const textEscapeRegex = /[&<>\u{A0}]/gu;
4358
- /**
4359
- * Encodes all characters that have to be escaped in HTML text,
4360
- * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
4361
- * @param data String to escape.
4362
- */
4363
- function escapeText(data) {
4364
- return escapeWithRegex(textEscapeRegex, data);
4365
- }
4366
- // node_modules/dom-serializer/dist/foreign-names.js
4367
- /**
4368
- * Mixed-case SVG and MathML element names recognized in foreign content.
4369
- * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
4370
- */
4371
- const elementNames = new Map("altGlyph altGlyphDef altGlyphItem animateColor animateMotion animateTransform clipPath feBlend feColorMatrix feComponentTransfer feComposite feConvolveMatrix feDiffuseLighting feDisplacementMap feDistantLight feDropShadow feFlood feFuncA feFuncB feFuncG feFuncR feGaussianBlur feImage feMerge feMergeNode feMorphology feOffset fePointLight feSpecularLighting feSpotLight feTile feTurbulence foreignObject glyphRef linearGradient radialGradient textPath".split(" ").map((name) => [name.toLowerCase(), name]));
4372
- /**
4373
- * Mixed-case SVG and MathML attribute names recognized in foreign content.
4374
- * @see https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
4375
- */
4376
- const attributeNames = new Map("definitionURL attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits diffuseConstant edgeMode filterUnits glyphRef gradientTransform gradientUnits kernelMatrix kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan".split(" ").map((name) => [name.toLowerCase(), name]));
4377
- // node_modules/dom-serializer/dist/index.js
4378
- /** Elements whose text content is never entity-encoded. */
4379
- const unencodedElements = new Set("style script xmp iframe noembed noframes plaintext noscript".split(" "));
4380
- /** HTML void elements — they cannot have children. */
4381
- const voidElements = new Set("area base basefont br col command embed frame hr img input isindex keygen link meta param source track wbr".split(" "));
4382
- /** Elements that switch the parser into foreign (XML-like) mode. */
4383
- const foreignElements = /* @__PURE__ */ new Set(["svg", "math"]);
4384
- /**
4385
- * Foreign-mode integration points: children of these elements are parsed
4386
- * as HTML again, not as foreign content.
3669
+ * Foreign-mode integration points: children of these elements are parsed
3670
+ * as HTML again, not as foreign content.
4387
3671
  */
4388
3672
  const foreignModeIntegrationPoints = new Set("mi mo mn ms mtext annotation-xml foreignObject desc title".split(" "));
4389
3673
  /**
@@ -12344,8 +11628,13 @@ var Preprocessor = class {
12344
11628
  get col() {
12345
11629
  return this.pos - this.lineStartPos + Number(this.lastGapPos !== this.pos);
12346
11630
  }
11631
+ /** The index in `html` at which the current code point starts (the high surrogate of a pair). */
11632
+ get codePointStart() {
11633
+ return this.pos - Number(this.lastGapPos === this.pos);
11634
+ }
11635
+ /** The offset of the current code point, before the second unit of a surrogate pair. */
12347
11636
  get offset() {
12348
- return this.droppedBufferSize + this.pos;
11637
+ return this.droppedBufferSize + this.codePointStart;
12349
11638
  }
12350
11639
  getError(code, cpOffset) {
12351
11640
  const { line, col, offset } = this;
@@ -12367,126 +11656,811 @@ var Preprocessor = class {
12367
11656
  this.handler.onParseError(this.getError(code, 0));
12368
11657
  }
12369
11658
  }
12370
- _addGap() {
12371
- this.gapStack.push(this.lastGapPos);
12372
- this.lastGapPos = this.pos;
12373
- }
12374
- _processSurrogate(cp) {
12375
- if (this.pos !== this.html.length - 1) {
12376
- const nextCp = this.html.charCodeAt(this.pos + 1);
12377
- if (isSurrogatePair(nextCp)) {
12378
- this.pos++;
12379
- this._addGap();
12380
- return getSurrogatePairCodePoint(cp, nextCp);
12381
- }
12382
- } else if (!this.lastChunkWritten) {
12383
- this.endOfChunkHit = true;
12384
- return CODE_POINTS.EOF;
11659
+ _addGap() {
11660
+ this.gapStack.push(this.lastGapPos);
11661
+ this.lastGapPos = this.pos;
11662
+ }
11663
+ _processSurrogate(cp) {
11664
+ if (this.pos !== this.html.length - 1) {
11665
+ const nextCp = this.html.charCodeAt(this.pos + 1);
11666
+ if (!isSurrogatePair(cp) && isSurrogatePair(nextCp)) {
11667
+ this.pos++;
11668
+ this._addGap();
11669
+ return getSurrogatePairCodePoint(cp, nextCp);
11670
+ }
11671
+ } else if (!this.lastChunkWritten) {
11672
+ this.endOfChunkHit = true;
11673
+ return CODE_POINTS.EOF;
11674
+ }
11675
+ this._err(ERR.surrogateInInputStream);
11676
+ return cp;
11677
+ }
11678
+ willDropParsedChunk() {
11679
+ return this.pos > this.bufferWaterline;
11680
+ }
11681
+ /**
11682
+ * Drop the parsed input, except for the current code point and the `keep` code units before it. The gap history is
11683
+ * reset, so the kept units must contain no preprocessing gap.
11684
+ */
11685
+ dropParsedChunk(keep = 0) {
11686
+ if (this.willDropParsedChunk()) {
11687
+ const droppedSize = this.offset - this.droppedBufferSize - keep;
11688
+ this.html = this.html.substring(droppedSize);
11689
+ this.lineStartPos -= droppedSize;
11690
+ this.droppedBufferSize += droppedSize;
11691
+ this.pos -= droppedSize;
11692
+ this.lastGapPos = -2;
11693
+ this.gapStack.length = 0;
11694
+ if (this.pos > keep) this._addGap();
11695
+ }
11696
+ }
11697
+ write(chunk, isLastChunk) {
11698
+ if (this.html.length > 0) this.html += chunk;
11699
+ else this.html = chunk;
11700
+ this.endOfChunkHit = false;
11701
+ this.lastChunkWritten = isLastChunk;
11702
+ }
11703
+ insertHtmlAtCurrentPos(chunk) {
11704
+ this.html = this.html.substring(0, this.pos + 1) + chunk + this.html.substring(this.pos + 1);
11705
+ this.endOfChunkHit = false;
11706
+ }
11707
+ startsWith(pattern, caseSensitive) {
11708
+ if (this.pos + pattern.length > this.html.length) {
11709
+ this.endOfChunkHit = !this.lastChunkWritten;
11710
+ return false;
11711
+ }
11712
+ if (caseSensitive) return this.html.startsWith(pattern, this.pos);
11713
+ for (let i = 0; i < pattern.length; i++) if ((this.html.charCodeAt(this.pos + i) | 32) !== pattern.charCodeAt(i)) return false;
11714
+ return true;
11715
+ }
11716
+ peek(offset) {
11717
+ const pos = this.pos + offset;
11718
+ if (pos >= this.html.length) {
11719
+ this.endOfChunkHit = !this.lastChunkWritten;
11720
+ return CODE_POINTS.EOF;
11721
+ }
11722
+ const code = this.html.charCodeAt(pos);
11723
+ return code === CODE_POINTS.CARRIAGE_RETURN ? CODE_POINTS.LINE_FEED : code;
11724
+ }
11725
+ advance() {
11726
+ this.pos++;
11727
+ if (this.isEol) {
11728
+ this.isEol = false;
11729
+ this.line++;
11730
+ this.lineStartPos = this.pos;
11731
+ }
11732
+ if (this.pos >= this.html.length) {
11733
+ this.endOfChunkHit = !this.lastChunkWritten;
11734
+ return CODE_POINTS.EOF;
11735
+ }
11736
+ let cp = this.html.charCodeAt(this.pos);
11737
+ if (cp === CODE_POINTS.CARRIAGE_RETURN) {
11738
+ this.isEol = true;
11739
+ this.skipNextNewLine = true;
11740
+ return CODE_POINTS.LINE_FEED;
11741
+ }
11742
+ if (cp === CODE_POINTS.LINE_FEED) {
11743
+ this.isEol = true;
11744
+ if (this.skipNextNewLine) {
11745
+ this.line--;
11746
+ this.skipNextNewLine = false;
11747
+ this._addGap();
11748
+ return this.advance();
11749
+ }
11750
+ }
11751
+ this.skipNextNewLine = false;
11752
+ if (isSurrogate(cp)) cp = this._processSurrogate(cp);
11753
+ if (!(this.handler.onParseError === null || cp > 31 && cp < 127 || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.CARRIAGE_RETURN || cp > 159 && cp < 64976)) this._checkForProblematicCharacters(cp);
11754
+ return cp;
11755
+ }
11756
+ _checkForProblematicCharacters(cp) {
11757
+ if (isControlCodePoint(cp)) this._err(ERR.controlCharacterInInputStream);
11758
+ else if (isUndefinedCodePoint(cp)) this._err(ERR.noncharacterInInputStream);
11759
+ }
11760
+ retreat(count) {
11761
+ this.pos -= count;
11762
+ while (this.pos < this.lastGapPos) {
11763
+ this.lastGapPos = this.gapStack.pop();
11764
+ this.pos--;
11765
+ }
11766
+ this.isEol = false;
11767
+ }
11768
+ };
11769
+ // node_modules/parse5/dist/common/token.js
11770
+ var TokenType;
11771
+ (function(TokenType) {
11772
+ TokenType[TokenType["CHARACTER"] = 0] = "CHARACTER";
11773
+ TokenType[TokenType["NULL_CHARACTER"] = 1] = "NULL_CHARACTER";
11774
+ TokenType[TokenType["WHITESPACE_CHARACTER"] = 2] = "WHITESPACE_CHARACTER";
11775
+ TokenType[TokenType["START_TAG"] = 3] = "START_TAG";
11776
+ TokenType[TokenType["END_TAG"] = 4] = "END_TAG";
11777
+ TokenType[TokenType["COMMENT"] = 5] = "COMMENT";
11778
+ TokenType[TokenType["DOCTYPE"] = 6] = "DOCTYPE";
11779
+ TokenType[TokenType["EOF"] = 7] = "EOF";
11780
+ TokenType[TokenType["HIBERNATION"] = 8] = "HIBERNATION";
11781
+ })(TokenType || (TokenType = {}));
11782
+ function getTokenAttr(token, attrName) {
11783
+ for (let i = token.attrs.length - 1; i >= 0; i--) if (token.attrs[i].name === attrName) return token.attrs[i].value;
11784
+ return null;
11785
+ }
11786
+ // node_modules/entities/dist/decode-codepoint.js
11787
+ /**
11788
+ * C1 Unicode control character reference replacements (code points 128-159).
11789
+ * Index i gives the replacement for code point 128+i; 0 means "no replacement".
11790
+ */
11791
+ const c1 = [
11792
+ 8364,
11793
+ 0,
11794
+ 8218,
11795
+ 402,
11796
+ 8222,
11797
+ 8230,
11798
+ 8224,
11799
+ 8225,
11800
+ 710,
11801
+ 8240,
11802
+ 352,
11803
+ 8249,
11804
+ 338,
11805
+ 0,
11806
+ 381,
11807
+ 0,
11808
+ 0,
11809
+ 8216,
11810
+ 8217,
11811
+ 8220,
11812
+ 8221,
11813
+ 8226,
11814
+ 8211,
11815
+ 8212,
11816
+ 732,
11817
+ 8482,
11818
+ 353,
11819
+ 8250,
11820
+ 339,
11821
+ 0,
11822
+ 382,
11823
+ 376
11824
+ ];
11825
+ /**
11826
+ * True for NUL, UTF-16 surrogates, and values past U+10FFFF.
11827
+ * @param codePoint Unicode code point to check.
11828
+ */
11829
+ function isInvalidCodePoint(codePoint) {
11830
+ return codePoint === 0 || codePoint >= 55296 && codePoint <= 57343 || codePoint > 1114111;
11831
+ }
11832
+ /**
11833
+ * Replace the given code point with U+FFFD if it is NUL (0), a surrogate, or
11834
+ * outside the valid Unicode range. Code points in the C1 controls range
11835
+ * (128-159) are remapped to their Windows-1252 equivalents, following the
11836
+ * HTML spec. All other code points are returned unchanged.
11837
+ * @param codePoint Unicode code point to convert.
11838
+ */
11839
+ function replaceCodePoint(codePoint) {
11840
+ if (isInvalidCodePoint(codePoint)) return 65533;
11841
+ if (codePoint >= 128 && codePoint <= 159) return c1[codePoint - 128] || codePoint;
11842
+ return codePoint;
11843
+ }
11844
+ // node_modules/entities/dist/generated/decode-data-html.js
11845
+ /**
11846
+ * Serialized decode data; the format is documented in
11847
+ * `src/internal/decode-data-format.ts`. `[0]` is one-byte data (all char
11848
+ * codes <= 0xFF: header, front-coded name suffixes, per-name metadata,
11849
+ * cuckoo choice bits); `[1]` holds the replacement values.
11850
+ */
11851
+ const htmlDecodeData = ["Q=¨`p0AEligMPacutebrevecircyfrgravelphamacrndogonpfpplyFunctionringscrsigntildeumlBackslashrvwedcyecausernoullistafropfrevescrumpeqCHcyOPYacutepitalDifferentialDyleyscaronedilirconintdotedillanterDotfrhiircleDotMinusPlusTimeslockwiseContourIntegralseCurlyDoubleQuoteQuoteolonengruentinttourIntegralpfroductunterClockwiseContourIntegralrossscrupCapDDotrahdJcyScyZcyaggerrrshvcaronyeltafriacriticalAcuteDotubleAcuteGraveTildemondfferentialDopftDotEqualubleContourIntegralDotwnArrowLeftArrowRightArrowTeeongLeftArrowRightArrowRightArrowRightArrowTeeUpArrowDownArrowVerticalBarwnArrowBarUpArrowBreveLeftRightVectorTeeVectorVectorBarRightTeeVectorVectorBarTeeArrowarrowscrtrokENGTHacutecaronircydotfrgravelementmacrptySmallSquareVerySmallSquareogonpfpsilonqualTildeilibriumscrimtaumlxistsponentialEFcyfrilledSmallSquareVerySmallSquareopfrAlluriertrfscrGJcyTammadbrevecedilircydotfrgopfreaterEqualLessFullEqualGreaterLessSlantEqualTildescrtHARDcyacektcircfrilbertSpaceopfrizontalLinescrtrokumpDownHumpEqualIEcyJligOcyacutecircydotfrgravemacrginaryIpliesntegralrsectionvisibleCommaTimesogonpftascrtildeukcymlJcircyfropfscrercyukcyKHcyJcyappacedilyfropfscrLJcyTacutembdangplacetrfrrcaronedilyeftAngleBracketrrowBarRightArrowCeilingDoubleBracketwnTeeVectorVectorBarFloorRightArrowVectorTeeArrowVectorriangleBarEqualUpDownVectorTeeVectorVectorBarVectorBararrowrightarrowssEqualGreaterFullEqualGreaterLessSlantEqualTildefrleftarrowmidotongLeftArrowRightArrowRightArrowleftarrowrightarrowrightarrowpfwerLeftArrowRightArrowscrhtroktMapcyediumSpacellintrffrinusPlusopfscruNJcyacutecaronedilyegativeMediumSpaceThickSpacenSpaceVeryThinSpacestedGreaterGreaterLessLesswLinefroBreaknBreakingSpacepftCongruentupCapDoubleVerticalBarElementqualTildexistsGreaterEqualFullEqualGreaterLessSlantEqualTildeHumpDownHumpEqualLeftTriangleBarEqualssEqualGreaterLessSlantEqualTildeNestedGreaterGreaterLessLessPrecedesEqualSlantEqualReverseElementightTriangleBarEqualSquareSubsetEqualpersetEqualubsetEqualcceedsEqualSlantEqualTildepersetEqualTildeEqualFullEqualTildeVerticalBarscrtildeuOEligacutecircydblacfrgravemacregaicronopfpenCurlyDoubleQuoteQuoterscrlashtildemesumlverBarraceketParenthesisPartialDcyfrhiilusMinusoincareplanepfrecedesEqualSlantEqualTildeimeoductportionalscriQUOTfropfscrRBarrEGacutengrrtlcaronedilyeverseElementquilibriumUpEquilibriumfrhoightAngleBracketrrowBarLeftArrowCeilingDoubleBracketwnTeeVectorVectorBarFloorTeeArrowVectorriangleBarEqualUpDownVectorTeeVectorVectorBarVectorBararrowopfundImpliesrightarrowscrhuleDelayedSHCHcycyOFTcyacutecaronedilircyfrhortDownArrowLeftArrowRightArrowUpArrowigmamallCircleopfqrtuareIntersectionSubsetEqualpersetEqualUnionscrtarubsetEqualcceedsEqualSlantEqualTildehThatmpersetEqualsetTHORNRADESHcycyabucaronedilyfrhereforetaickSpacenSpaceildeEqualFullEqualTildeopfripleDotscrtrokUacuterrocirbrcyevecircydblacfrgravemacrnderBarraceketParenthesisionPlusogonpfpArrowBarDownArrowDownArrowEquilibriumTeeArrowarrowdownarrowperLeftArrowRightArrowsilonringscrtildeumlVDashbarcydashleerbarticalBarLineSeparatorTildeyThinSpacefropfscrvdashWcircedgefropfscrXfriopfscrYAcyIcyUcyacutecircyfropfscrumlZHcyacutecaronydoteroWidthSpacetafropfscraacutebrevecEdircuteyeligfrgravelefsymphphamacrlgpndanddslopevgelemsdaabcdefghrtvbdsphtzarrogonpfpEacireidosproxeqringscrtympeqtildeumlwconintintbNotackcongepsilonprimesimeqrveewedgebrktbrkcongydquoecausemptyvpsirnoutahweenfrigcapircupodotplustimessqcuptartriangledownupuplusveewedgekarowlacklozengesquaretriangledownleftrightnkk12434ocknequivotopfttomwtiexDLRlrHDUduULRlrVHLRhlrboxdLRlrhDUduminusplustimesuLRlrvHLRhlrprimerevevbarscremiimeolbhsubulletmpEeqcacutepandbrcupcapupdotsretoncapsronedilircupssmdotedilmptyvnterdotfrhcyeckmarkiirEceqlearrowleftrightdRSastcircdashefnintmidscirlubsuitoloneqmmatpfnlementxesngdotintpfrodysrrarrossscrubepetdotudarrlreprsclarrppbrcapcapupdotorsrarrmlyeqprecsuccveewedgerenvearrowleftrightveewedwconintintylctydArrHaraggerlethrrshvbkarowlaccaronydaggerrrotseqegltamptyvfishtrharlriamondsuitsegammasinvideontimesonxjcylcornropollarpfteqdotminusplussquareublebarwedgewnarrowdownarrowsharpoonleftrightrbkarowcornropscryoltroktdotrifuarrharwanglezcyigrarreDDototacutestercaronircolonydotefDotrgravesdotlinterslsdotmacrptysetvsp134ngspogonpfparsllussilonvqcircolonsimlantgtrlessualsestivDDvparslrDotarrscrdotimtahumlroxclistpectationonentialefallingdotseqcyemalefiligligligriligjliglatligtnsnofopfrallkvpartintrac123456823534584556878slownscrgElacutemmadpbrevecircydotelqqslantsccdotollesfrggimeljcylEajnEapproxeqqsimopfravescrimeltccirdotlParquestrapproxrrdoteqlessqlesslesssimvertneqqnEhArrairsplfmiltrdcyrcirwbarcirceartsuitlliprconfrksearowwarowoarrmthtokleftarrowrightarrowpfrbarscrlashtrokybullpheniacutecircyecyxclffrgraveiiintntnfinotajligmacrgelinepartthofpedncarefintieodottcalegersrcallarhkprodocygonpftaprodquestscrinEdotsvvtildeukcymljcircyfrmathopfscrercyukcykappavcedilyfrgreenhcyjcyopfscrlAarrrrtailBarrEgHaracuteemptyvgranmbdangdlepquorrbfsfshklpplsimtltailesbarrbrkracekkeslducaronedililubydcaquorrdharusharsheftarrowtailharpoondownupleftarrowsrightarrowsharpoonssquigarrowthreetimesgqqslantsccdotorgessapproxdoteqgtrqgtrgtrsimfishtloorrgEhardulblkjcylarrcornerhardtrimidotoustachenEapproxeqqsimoangrrbrkngleftarrowrightarrowmapstorightarrowoparrowleftrightparflustimeswastbarzengefparltrarrcornerhardmtrisaquocrhimegqbuortroktccirdothreeimeslarrquestrPariefurdsharuharvertneqqnEmDDotacrletesepstodownleftuprkercommaydasheasuredanglefrhoicrodastcirdotnusbdulcpdrnplusodelspfpscrtposultimapmapnGgtvLeftarrowrightarrowltvRightarrowVDashdashablacutengpEidosproxturalsbspumpecapronedilongdotupydasheArrarhkrowdotquivsearimxistsfrgEeqqslantssimtrhArrarrparisdvjcylArrEarrdreftarrowrightarrowqqslantsssimtriemidopftinEdotvabcnivabcparallelsltolintrcueeceqrArrarrcwightarrowtriesccueerhortmidparallelimeqmidparqsubepeubEeseteqqcceqpEeseteqqtglildelgrianglelefteqrightequmerospvDashHarrapdashgetinfinlArretrierArrtriesimwArrarhkrownearoSacutestcircydashblacivotsoldeligfcirrgonravethbarmintlarrcirrossinetmacregaicrondnusopfparerplusrarrderoffmigoforslopevscrlasholtildemesasumlvbarparallelsimltcyercntiodmilptenkfrhivmmatoneitchforkvlanckhkvusacirbcirdouemnsimtwomointintpfundrEapcueecapproxcurlyeqeqnapproxeqqsimsimimesnEapsimodfalarlinesurfptosimurelscriuncspqfrintopfprimescruaternionsintesteqotrAarrrrtailBarrHaraceutedicemptyvngdelequorrapbfscfshklpplsimtlwtailionalsbarrbrkracekkeslducaronedililubydcaldharquorshealinepartsctgfishtloorrhardulovightarrowtailharpoondownupleftarrowsharpoonsrightarrowssquigarrowthreetimesngsingdotseqlarrharmmoustachenmidoangrrbrkparflustimespargtpolintrarrsaquocrhqbuorthreeimesriefltriuluharxsacutebquocEaproncueedilircnEapsimpolintsimydotbeeArrarhkrowctmiswartminusnxtfrownharpchcyyortmidparallelyigmafvmdoteqgElEneplusrarrlarrmallsetminusshpeparslidletesoftcylbarpfpadesuitrqcapsupssubeseteqpesetequareffrarrscretmnmiletarftarfraightepsilonphinsubEdotedotmultnEeplusrarrseteqqneqqimubpccapproxcurlyeqeqnapproxeqqsimsimmngp123EdotsubedothsolublarrmultnEeplusseteqqneqqimubpwArrarhkrownwarzligtargetubrkcaronedilydotelrecfrhere4foretasymvickapproxsimnspkapsimornildemesbardntoeapbotcirforksaprimeradeiangledownlefteqqrighteqdoteminusplussbtimepeziumscryhcytrokwixtoheadleftarrowrightarrowuArrHaracuterrbrcyevecircydarrblacharfishtrgraveharlrblklcornerroptrimacrlogonpfparrowdownarrowharpoonleftrightlussihlonuparrowsrcornerropingtriscrtdotilderifuarrmlwanglevArrBarvDashangrtrepsilonkappanothingphiiroptorhosigmaubsetneqqpsetneqqthetariangleleftrightcydasheebareqlliprbartfrltrinsubpopfproprtriscrubnEepnEezigzagwcircedbargeqierpfropfpreathscrxcapircupdtrifrhArrarrilArrarrmapnisodotpflustimerArrarrscrqcupuplustriveewedgeyacuteycircyenfricyopfscrucymlzacutecaronydoteetrftafrhcyigrarropfscrwjnjC(D%D($(D'%$$ED($'$'$%$'%E$/D'$F%'D(D&#,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%&%&&%%&(''''&$'%%&%'$F%$$(#F$&$F$($F$-'&%&(%E%#(%%%'$'$&$F&&%&%)%%'$'$'%E&%%'%'$(%'$'%'%'%'%'&'%'$%'&%('$'%&%'($&%'&)$$(%'&%%%%$$&%(%&($%%$&'&'''$%%E$$(%'%D$''$($%$&$$,-'(./%(-,+(.(-(-%%%-$'%&%$$()'$'$'&%%&%&&D&&%($&'%%)$'$(%E%$%%&%($$(%'%%'$'$''$)$$#)$'$$%$%%&&%&%$&&%&%%&%&&%)%&%$$&'$'$$'%''$(%E%%%%'%)'$%%$E&&$'%'&$%)(+E$$'($($%$&&&$'$&$'$&$'$&%&'&'$'$/&&%)%%&%%$&$'D$(%$&$'%%E$()&&$$'(D&%(D%&($(&+%'$($(&+%%$&&($&$$'$F%'%'%'$&'$%0+&&%$%&$&&&$'&&'&%'$&'&'&&)%+$)&,$'%'%($%%')'*'%'*(&(&'&%$%%%$F$F$F$&$&&'&&$'&&'(%&'&'&%'$&'&&)%+$)&,$'%'%($$'%''$(%%'D'#)%$$&$(%'%$$&$($E$(('&%(&($%,(&&&%&&&E&$'E&($)%($%%$&%$&&&&&D'&%%$($'%)+'+'/%+$+(0%&&&$&(&'&%&'%)$F&$%&%'$'%1*-#'$&D(%%$'&&D'%$$'%'%&$(%DD($''$%&$()%&&%&$'E$$'%E$)%,%.,(%&%%'$'&%+$()%&&%&%&$F$'%'%%'$$'E%$)#'$&'$$'$(%+&(&*&&'$'(&$'%&('K/D(J/D&('..($%$'$%&&&%%'%'&$$E$'$G'D$F$'$'$F%G(D&F(D$)#($(&%($%'$E$F$$$$%'$F#'%&%%$'$E$'%&$$$'%&$&$&$'%E&&%'$'%&$F%'$(%&$&$(C)&$$'%$D%$E$&$F$F$&E%#)$(%$$&$(%%$E$&$)$F$F$%%%0@0000H8H40H000047P00P@001000@0B0HP@:H9T8P000LB8d@800@I0<110000QQ8400P10030005940@410020000Q02000@0200000@P0101@8000440400000000808000000000@00000000P`0000000040400@0004<000000000008000030000000000P020T400020@0@00000000000000000000000000P0000000400400000400220080000100000000000000000P000000000000P000000@00402000000000@00000000000000000000040000000000000", "Æ&ÁĂÂА𝔄ÀΑĀ⩓Ą𝔸⁡Å𝒜≔ÃÄ∖⫧⌆Б∵ℬΒ𝔅𝔹˘ℬ≎Ч©Ć⋒ⅅℭČÇĈ∰Ċ¸·ℭΧ⊙⊖⊕⊗∲”’∷⩴≡∯∮ℂ∐∳⨯𝒞⋓≍ⅅ⤑ЂЅЏ‡↡⫤ĎД∇Δ𝔇´˙˝`˜⋄ⅆ𝔻¨⃜≐∯¨⇓⇐⇔⫤⟸⟺⟹⇒⊨⇑⇕∥↓⤓⇵̑⥐⥞↽⥖⥟⇁⥗⊤↧⇓𝒟ĐŊÐÉĚÊЭĖ𝔈È∈Ē◻▫Ę𝔼Ε⩵≂⇌ℰ⩳ΗË∃ⅇФ𝔉◼▪𝔽∀ℱℱЃ>ΓϜĞĢĜГĠ𝔊⋙𝔾≥⋛≧⪢≷⩾≳𝒢≫Ъˇ^Ĥℌℋℍ─ℋĦ≎≏ЕIJЁÍÎИİℑÌℑĪⅈ⇒∬∫⋂⁣⁢Į𝕀ΙℐĨІÏĴЙ𝔍𝕁𝒥ЈЄХЌΚĶК𝔎𝕂𝒦Љ<ĹΛ⟪ℒ↞ĽĻЛ⟨←⇤⇆⌈⟦⥡⇃⥙⌊↔⥎⊣↤⥚⊲⧏⊴⥑⥠↿⥘↼⥒⇐⇔⋚≦≶⪡⩽≲𝔏⋘⇚Ŀ⟵⟷⟶⟸⟺⟹𝕃↙↘ℒ↰Ł≪⤅М ℳ𝔐∓𝕄ℳΜЊŃŇŅН​​​​≫≪\n𝔑⁠\xA0ℕ⫬≢≭∦∉≠≂̸∄≯≱≧̸≫̸≹⩾̸≵≎̸≏̸⋪⧏̸⋬≮≰≸≪̸⩽̸≴⪢̸⪡̸⊀⪯̸⋠∌⋫⧐̸⋭⊏̸⋢⊐̸⋣⊂⃒⊈⊁⪰̸⋡≿̸⊃⃒⊉≁≄≇≉∤𝒩ÑΝŒÓÔОŐ𝔒ÒŌΩΟ𝕆“‘⩔𝒪ØÕ⨷Ö‾⏞⎴⏜∂П𝔓ΦΠ±ℌℙ⪻≺⪯≼≾″∏∷∝𝒫Ψ\"𝔔ℚ𝒬⤐®Ŕ⟫↠⤖ŘŖРℜ∋⇋⥯ℜΡ⟩→⇥⇄⌉⟧⥝⇂⥕⌋⊢↦⥛⊳⧐⊵⥏⥜↾⥔⇀⥓⇒ℝ⥰⇛ℛ↱⧴ЩШЬŚ⪼ŠŞŜС𝔖↓←→↑Σ∘𝕊√□⊓⊏⊑⊐⊒⊔𝒮⋆⋐⋐⊆≻⪰≽≿∋∑⋑⊃⊇⋑Þ™ЋЦ ΤŤŢТ𝔗∴Θ   ∼≃≅≈𝕋⃛𝒯ŦÚ↟⥉ЎŬÛУŰ𝔘ÙŪ_⏟⎵⏝⋃⊎Ų𝕌↑⤒⇅↕⥮⊥↥⇑⇕↖↗ϒΥŮ𝒰ŨÜ⊫⫫В⊩⫦⋁‖‖∣|❘≀ 𝔙𝕍𝒱⊪Ŵ⋀𝔚𝕎𝒲𝔛Ξ𝕏𝒳ЯЇЮÝŶЫ𝔜𝕐𝒴ŸЖŹŽЗŻ​Ζℨℤ𝒵áă∾∾̳∿â´аæ⁡𝔞àℵℵαā⨿&∧⩕⩜⩘⩚∠⦤∠∡⦨⦩⦪⦫⦬⦭⦮⦯∟⊾⦝∢Å⍼ą𝕒≈⩰⩯≊≋'≈≊å𝒶*≈≍ãä∳⨑⫭≌϶‵∽⋍⊽⌅⌅⎵⎶≌б„∵∵⦰϶ℬβℶ≬𝔟⋂◯⋃⨀⨁⨂⨆★▽△⨄⋁⋀⤍⧫▪▴▾◂▸␣▒░▓█=⃥≡⃥⌐𝕓⊥⊥⋈╗╔╖╓═╦╩╤╧╝╚╜╙║╬╣╠╫╢╟⧉╕╒┐┌─╥╨┬┴⊟⊞⊠╛╘┘└│╪╡╞┼┤├‵˘¦𝒷⁏∽⋍\\⧅⟈••≎⪮≏≏ć∩⩄⩉⩋⩇⩀∩︀⁁ˇ⩍čçĉ⩌⩐ċ¸⦲¢·𝔠ч✓✓χ○⧃ˆ≗↺↻®Ⓢ⊛⊚⊝≗⨐⫯⧂♣♣:≔≔,@∁∘∁ℂ≅⩭∮𝕔∐©℗↵✗𝒸⫏⫑⫐⫒⋯⤸⤵⋞⋟↶⤽∪⩈⩆⩊⊍⩅∪︀↷⤼⋞⋟⋎⋏¤↶↷⋎⋏∲∱⌭⇓⥥†ℸ↓‐⊣⤏˝ďдⅆ‡⇊⩷°δ⦱⥿𝔡⇃⇂⋄⋄♦♦¨ϝ⋲÷÷⋇⋇ђ⌞⌍$𝕕˙≐≑∸∔⊡⌆↓⇊⇃⇂⤐⌟⌌𝒹ѕ⧶đ⋱▿▾⇵⥯⦦џ⟿⩷≑é⩮ě≖ê≕эėⅇ≒𝔢⪚è⪖⪘⪙⏧ℓ⪕⪗ē∅∅∅   ŋ ę𝕖⋕⧣⩱εεϵ≖≕≂⪖⪕=≟≡⩸⧥≓⥱ℯ≐≂ηðë€!∃ℰⅇ≒ф♀ffiffffl𝔣fifj♭fl▱ƒ𝕗∀⋔⫙⨍½⅓¼⅕⅙⅛⅔⅖¾⅗⅜⅘⅚⅝⅞⁄⌢𝒻≧⪌ǵγϝ⪆ğĝгġ≥⋛≥≧⩾⩾⪩⪀⪂⪄⋛︀⪔𝔤≫⋙ℷѓ≷⪒⪥⪤≩⪊⪊⪈⪈≩⋧𝕘`ℊ≳⪎⪐>⪧⩺⋗⦕⩼⪆⥸⋗⋛⪌≷≳≩︀≩︀⇔ ½ℋъ↔⥈↭ℏĥ♥♥…⊹𝔥⤥⤦⇿∻↩↪𝕙―𝒽ℏħ⁃‐í⁣îие¡⇔𝔦ìⅈ⨌∭⧜℩ijīℑℐℑı⊷Ƶ∈℅∞⧝ı∫⊺ℤ⊺⨗⨼ёį𝕚ι⨼¿𝒾∈⋹⋵⋴⋳∈⁢ĩіïĵй𝔧ȷ𝕛𝒿јєκϰķк𝔨ĸхќ𝕜𝓀⇚⇐⤛⤎≦⪋⥢ĺ⦴ℒλ⟨⦑⟨⪅«←⇤⤟⤝↩↫⤹⥳↢⪫⤙⪭⪭︀⤌❲{[⦋⦏⦍ľļ⌈{л⤶“„⥧⥋↲≤←↢↽↼⇇↔⇆⇋↭⋋⋚≤≦⩽⩽⪨⩿⪁⪃⋚︀⪓⪅⋖⋚⪋≶≲⥼⌊𝔩≶⪑↽↼⥪▄љ≪⇇⌞⥫◺ŀ⎰⎰≨⪉⪉⪇⪇≨⋦⟬⇽⟦⟵⟷⟼⟶↫↬⦅𝕝⨭⨴∗_◊◊⧫(⦓⇆⌟⇋⥭‎⊿‹𝓁↰≲⪍⪏[‘‚ł<⪦⩹⋖⋋⋉⥶⩻⦖◃⊴◂⥊⥦≨︀≨︀∺¯♂✠✠↦↦↧↤↥▮⨩м—∡𝔪℧µ∣*⫰·−⊟∸⨪⫛…∓⊧𝕞∓𝓂∾μ⊸⊸⋙̸≫⃒≫̸⇍⇎⋘̸≪⃒≪̸⇏⊯⊮∇ń∠⃒≉⩰̸≋̸ʼn≉♮♮ℕ\xA0≎̸≏̸⩃ňņ≇⩭̸⩂н–≠⇗⤤↗↗≐̸≢⤨≂̸∄∄𝔫≧̸≱≱≧̸⩾̸⩾̸≵≯≯⇎↮⫲∋⋼⋺∋њ⇍≦̸↚‥≰↚↮≰≦̸⩽̸⩽̸≮≴≮⋪⋬∤𝕟¬∉⋹̸⋵̸∉⋷⋶∌∌⋾⋽∦∦⫽⃥∂̸⨔⊀⋠⪯̸⊀⪯̸⇏↛⤳̸↝̸↛⋫⋭⊁⋡⪰̸𝓃∤∦≁≄≄∤∦⋢⋣⊄⫅̸⊈⊂⃒⊈⫅̸⊁⪰̸⊅⫆̸⊉⊃⃒⊉⫆̸≹ñ≸⋪⋬⋫⋭ν#№ ⊭⤄≍⃒⊬≥⃒>⃒⧞⤂≤⃒<⃒⊴⃒⤃⊵⃒∼⃒⇖⤣↖↖⤧Ⓢó⊛⊚ôо⊝ő⨸⊙⦼œ⦿𝔬˛ò⧁⦵Ω∮↺⦾⦻‾⧀ōωο⦶⊖𝕠⦷⦹⊕∨↻⩝ℴℴªº⊶⩖⩗⩛ℴø⊘õ⊗⨶ö⌽∥¶∥⫳⫽∂п%.‰⊥‱𝔭φϕℳ☎π⋔ϖℏℎℏ+⨣⊞⨢∔⨥⩲±⨦⨧±⨕𝕡£≺⪳⪷≼⪯≺⪷≼⪯⪹⪵⋨≾′ℙ⪵⪹⋨∏⌮⌒⌓∝∝≾⊰𝓅ψ 𝔮⨌𝕢⁗𝓆ℍ⨖?≟\"⇛⇒⤜⤏⥤∽̱ŕ√⦳⟩⦒⦥⟩»→⥵⇥⤠⤳⤞↪↬⥅⥴↣↝⤚∶ℚ⤍❳}]⦌⦎⦐řŗ⌉}р⤷⥩””↳ℜℛℜℝ▭®⥽⌋𝔯⇁⇀⥬ρϱ→↣⇁⇀⇄⇌⇉↝⋌˚≓⇄⇌‏⎱⎱⫮⟭⇾⟧⦆𝕣⨮⨵)⦔⨒⇉›𝓇↱]’’⋌⋊▹⊵▸⧎⥨℞ś‚≻⪴⪸š≽⪰şŝ⪶⪺⋩⨓≿с⋅⊡⩦⇘⤥↘↘§;⤩∖∖✶𝔰⌢♯щш∣∥­σςς∼⩪≃≃⪞⪠⪝⪟≆⨤⥲←∖⨳⧤∣⌣⪪⪬⪬︀ь/⧄⌿𝕤♠♠∥⊓⊓︀⊔⊔︀⊏⊑⊏⊑⊐⊒⊐⊒□□▪▪→𝓈∖⌣⋆☆★ϵϕ¯⊂⫅⪽⊆⫃⫁⫋⊊⪿⥹⊂⊆⫅⊊⫋⫇⫕⫓≻⪸≽⪰⪺⪶⋩≿∑♪⊃¹²³⫆⪾⫘⊇⫄⟉⫗⥻⫂⫌⊋⫀⊃⊇⫆⊋⫌⫈⫔⫖⇙⤦↙↙⤪ß⌖τ⎴ťţт⃛⌕𝔱∴∴θϑϑ≈∼ ≈∼þ˜×⊠⨱⨰∭⤨⊤⌶⫱𝕥⫚⤩‴™▵▿◃⊴≜▹⊵◬≜⨺⨹⧍⨻⏢𝓉цћŧ≬↞↠⇑⥣ú↑ўŭûу⇅ű⥮⥾𝔲ù↿↾▀⌜⌜⌏◸ū¨ų𝕦↑↕↿↾⊎υϒυ⇈⌝⌝⌎ů◹𝓊⋰ũ▵▴⇈ü⦧⇕⫨⫩⊨⦜ϵϰ∅ϕϖ∝↕ϱς⊊︀⫋︀⊋︀⫌︀ϑ⊲⊳в⊢∨⊻≚⋮||𝔳⊲⊂⃒⊃⃒𝕧∝⊳𝓋⫋︀⊊︀⫌︀⊋︀⦚ŵ⩟∧≙℘𝔴𝕨℘≀≀𝓌⋂◯⋃▽𝔵⟺⟷ξ⟸⟵⟼⋻⨀𝕩⨁⨂⟹⟶𝓍⨆⨄△⋁⋀ýяŷы¥𝔶ї𝕪𝓎юÿźžзżℨζ𝔷ж⇝𝕫𝓏‍‌"];
11852
+ /** Multiplier deriving the first candidate bucket from a key. */
11853
+ const BUCKET_HASH_1 = 2654435761;
11854
+ /** Multiplier deriving the second candidate bucket from a key. */
11855
+ const BUCKET_HASH_2 = 2246822507;
11856
+ /** Size of the (c0,c1) class table (10-bit index). */
11857
+ const PAIR_TABLE_SIZE = 1024;
11858
+ /**
11859
+ * Map an alphanumeric char code to 6 bits (1..62); 0 = not alphanumeric.
11860
+ * Used for the key's last-character field.
11861
+ */
11862
+ const CHAR_REMAP = (() => {
11863
+ const remap = /* @__PURE__ */ new Uint8Array(128);
11864
+ for (let code = 48; code <= 57; code++) remap[code] = code - 47;
11865
+ for (let code = 65; code <= 90; code++) remap[code] = code - 54;
11866
+ for (let code = 97; code <= 122; code++) remap[code] = code - 60;
11867
+ return remap;
11868
+ })();
11869
+ /**
11870
+ * The exact 32-bit key for a name occurring at `nameStart` with `length`
11871
+ * chars. Covers the first two and last two characters plus the length;
11872
+ * middle characters are verified separately against the names blob.
11873
+ *
11874
+ * The hot decoder inlines this computation; tests assert both stay in sync
11875
+ * by looking every entity up through the public API.
11876
+ * @param text Text containing the name.
11877
+ * @param nameStart Index of the name's first character.
11878
+ * @param length Length of the name.
11879
+ */
11880
+ function exactKey(text, nameStart, length) {
11881
+ return text.charCodeAt(nameStart) << 25 | text.charCodeAt(nameStart + 1) << 18 | text.charCodeAt(nameStart + length - 2) << 11 | CHAR_REMAP[text.charCodeAt(nameStart + length - 1)] << 5 | length;
11882
+ }
11883
+ /**
11884
+ * The 10-bit (c0,c1) class index used by the probe front end. The function
11885
+ * was chosen by exhaustive search over load-free mixers for minimal
11886
+ * candidate-set collisions on the real entity set.
11887
+ * @param c0 First char code of the candidate name.
11888
+ * @param c1 Second char code.
11889
+ */
11890
+ function pairIndex(c0, c1) {
11891
+ return (c0 * 3 << 3 ^ c1) & 1023;
11892
+ }
11893
+ /**
11894
+ * First candidate bucket for a key in a table of `buckets` buckets.
11895
+ * @param key Exact key.
11896
+ * @param buckets Bucket count.
11897
+ */
11898
+ function bucketOne(key, buckets) {
11899
+ return (Math.imul(key, BUCKET_HASH_1) >>> 16) * buckets >>> 16;
11900
+ }
11901
+ /**
11902
+ * Second candidate bucket for a key.
11903
+ * @param key Exact key.
11904
+ * @param buckets Bucket count.
11905
+ */
11906
+ function bucketTwo(key, buckets) {
11907
+ return (Math.imul(key, BUCKET_HASH_2) >>> 16) * buckets >>> 16;
11908
+ }
11909
+ /**
11910
+ * Build the lookup structures from a serialized dataset.
11911
+ * @param packed Serialized decode data, see `decode-data-format.ts`.
11912
+ */
11913
+ function initDecodeData(packed) {
11914
+ const [data, values] = packed;
11915
+ const nameCount = data.charCodeAt(0) - 48 << 6 | data.charCodeAt(1) - 48;
11916
+ const suffixesLength = data.charCodeAt(2) - 48 << 6 | data.charCodeAt(3) - 48;
11917
+ const buckets = data.charCodeAt(4) - 48 << 6 | data.charCodeAt(5) - 48;
11918
+ const metaStart = 6 + suffixesLength;
11919
+ const choicesStart = metaStart + 2 * nameCount;
11920
+ const slotCount = 2 * buckets;
11921
+ const keys = new Int32Array(slotCount);
11922
+ const slotMidOff = new Uint16Array(slotCount);
11923
+ const slotValue = new Uint16Array(slotCount);
11924
+ const lengthBits = new Uint32Array(PAIR_TABLE_SIZE);
11925
+ const middleOffsets = /* @__PURE__ */ new Map();
11926
+ const middles = [];
11927
+ let name = "";
11928
+ let suffixOffset = 6;
11929
+ let valueOffset = 0;
11930
+ for (let index = 0; index < nameCount; index++) {
11931
+ const meta0 = data.charCodeAt(metaStart + 2 * index) - 35;
11932
+ const meta1 = data.charCodeAt(metaStart + 2 * index + 1) - 35;
11933
+ const prefixLength = meta0 & 31;
11934
+ const length = prefixLength + (meta1 & 31);
11935
+ const valueLength = (meta1 >> 5) + 1;
11936
+ name = name.slice(0, prefixLength) + data.slice(suffixOffset, suffixOffset + length - prefixLength);
11937
+ suffixOffset += length - prefixLength;
11938
+ const key = exactKey(name, 0, length);
11939
+ let slot = 2 * ((data.charCodeAt(choicesStart + Math.floor(index / 6)) - 48 & 1 << index % 6) === 0 ? bucketOne : bucketTwo)(key, buckets);
11940
+ if (keys[slot] !== 0) slot += 1;
11941
+ keys[slot] = key;
11942
+ if (length > 4) {
11943
+ const middle = name.slice(2, length - 2);
11944
+ const existing = middleOffsets.get(middle);
11945
+ if (existing === void 0) {
11946
+ middleOffsets.set(middle, middles.length);
11947
+ slotMidOff[slot] = middles.length;
11948
+ for (let middleIndex = 0; middleIndex < middle.length; middleIndex += 2) middles.push(middle.charCodeAt(middleIndex) | middle.charCodeAt(middleIndex + 1) << 16);
11949
+ } else slotMidOff[slot] = existing;
11950
+ }
11951
+ const pair = pairIndex(name.charCodeAt(0), name.charCodeAt(1));
11952
+ lengthBits[pair] |= length <= 16 ? 1 << length - 2 : 32768;
11953
+ if ((meta0 & 32) !== 0) lengthBits[pair] |= 1 << length - 2 + 16;
11954
+ slotValue[slot] = valueOffset << 2 | valueLength - 1 | (meta0 & 32) >> 4;
11955
+ valueOffset += valueLength;
11956
+ }
11957
+ return {
11958
+ keys,
11959
+ buckets,
11960
+ slotMidOff,
11961
+ slotValue,
11962
+ values,
11963
+ lengthBits,
11964
+ middles: new Uint32Array(middles)
11965
+ };
11966
+ }
11967
+ // node_modules/entities/dist/decode.js
11968
+ const CHAR_NUM = 35;
11969
+ const CHAR_SEMI = 59;
11970
+ const CHAR_EQUALS = 61;
11971
+ const CHAR_ZERO = 48;
11972
+ const CHAR_LOWER_A = 97;
11973
+ const CHAR_LOWER_X = 120;
11974
+ const CHAR_UPPER_A = 65;
11975
+ /** Bit that needs to be set to convert an upper case ASCII character to lower case */
11976
+ const TO_LOWER_BIT = 32;
11977
+ /**
11978
+ * Unsigned subtraction trick: (code - lo) >>> 0 wraps negatives to large
11979
+ * values, so a single `<=` covers the entire [lo..hi] range check.
11980
+ * @param code Code point to check.
11981
+ */
11982
+ function isNumber(code) {
11983
+ return code - CHAR_ZERO >>> 0 <= 9;
11984
+ }
11985
+ function isAlphaNumeric(code) {
11986
+ return isNumber(code) || (code | TO_LOWER_BIT) - CHAR_LOWER_A >>> 0 <= 25;
11987
+ }
11988
+ /**
11989
+ * Checks if the given character is a valid end character for an entity in an attribute.
11990
+ *
11991
+ * Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
11992
+ * See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
11993
+ * @param code Code point to check.
11994
+ */
11995
+ function isEntityInAttributeInvalidEnd(code) {
11996
+ return code === CHAR_EQUALS || isAlphaNumeric(code);
11997
+ }
11998
+ /**
11999
+ * Decoding mode for named entities.
12000
+ */
12001
+ var DecodingMode;
12002
+ (function(DecodingMode) {
12003
+ /** Entities in text nodes that can end with any character. */
12004
+ DecodingMode[DecodingMode["Legacy"] = 0] = "Legacy";
12005
+ /** Only allow entities terminated with a semicolon. */
12006
+ DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
12007
+ /** Entities in attributes have limitations on ending characters. */
12008
+ DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
12009
+ })(DecodingMode || (DecodingMode = {}));
12010
+ /** Decode data for HTML entities. */
12011
+ const htmlDecode = /* #__PURE__ */ initDecodeData(htmlDecodeData);
12012
+ const htmlKeys = /* #__PURE__ */ (() => htmlDecode.keys)();
12013
+ const htmlBuckets = /* #__PURE__ */ (() => htmlDecode.buckets)();
12014
+ const htmlSlotMidOff = /* #__PURE__ */ (() => htmlDecode.slotMidOff)();
12015
+ const htmlLengthBits = /* #__PURE__ */ (() => htmlDecode.lengthBits)();
12016
+ const htmlMiddles = /* #__PURE__ */ (() => htmlDecode.middles)();
12017
+ /** Hoisted for the specialized HTML cores; see `emitHtmlValue`. */
12018
+ const htmlSlotValue = /* #__PURE__ */ (() => htmlDecode.slotValue)();
12019
+ const htmlValues = /* #__PURE__ */ (() => htmlDecode.values)();
12020
+ /**
12021
+ * Find the slot matching `text[start..start+length)`, or -1. A match proves
12022
+ * every character of the span (exact key + middle comparison).
12023
+ * @param text Input text.
12024
+ * @param start Start of the span in `text`.
12025
+ * @param length Length of the span.
12026
+ */
12027
+ function findSlotHtml(text, start, length) {
12028
+ const c0 = text.charCodeAt(start);
12029
+ const c1 = text.charCodeAt(start + 1);
12030
+ const c2 = text.charCodeAt(start + length - 2);
12031
+ const c3 = text.charCodeAt(start + length - 1);
12032
+ if ((c0 | c1 | c2 | c3) > 127) return -1;
12033
+ const key = c0 << 25 | c1 << 18 | c2 << 11 | CHAR_REMAP[c3] << 5 | length;
12034
+ let slot = 2 * ((Math.imul(key, BUCKET_HASH_1) >>> 16) * htmlBuckets >>> 16);
12035
+ for (let attempt = 0;; attempt++) {
12036
+ if (htmlKeys[slot] === key && (length <= 4 || isMidMatchHtml(slot, text, start, length))) return slot;
12037
+ if (htmlKeys[slot + 1] === key && (length <= 4 || isMidMatchHtml(slot + 1, text, start, length))) return slot + 1;
12038
+ if (attempt === 1) return -1;
12039
+ slot = 2 * ((Math.imul(key, BUCKET_HASH_2) >>> 16) * htmlBuckets >>> 16);
12040
+ }
12041
+ }
12042
+ /**
12043
+ * Compare the middle characters (positions 2..length-3) of the candidate at
12044
+ * `slot` against the input. The key already proves the outer characters and
12045
+ * the length. Names of length at most four are accepted by the caller.
12046
+ * @param slot Slot of the candidate.
12047
+ * @param text Input text.
12048
+ * @param start Start of the span in `text`.
12049
+ * @param length Length of the span.
12050
+ */
12051
+ function isMidMatchHtml(slot, text, start, length) {
12052
+ let wordIndex = htmlSlotMidOff[slot];
12053
+ let index = start + 2;
12054
+ const end = start + length - 2;
12055
+ while (index + 1 < end) {
12056
+ if ((text.charCodeAt(index) | text.charCodeAt(index + 1) << 16) !== htmlMiddles[wordIndex++]) return false;
12057
+ index += 2;
12058
+ }
12059
+ return index === end || text.charCodeAt(index) === (htmlMiddles[wordIndex] & 65535);
12060
+ }
12061
+ /** ASCII digit values; 0xff marks characters outside the hexadecimal range. */
12062
+ const numericDigits = /* #__PURE__ */ (() => {
12063
+ const digits = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
12064
+ for (let digit = 0; digit < 10; digit++) digits[CHAR_ZERO + digit] = digit;
12065
+ for (let digit = 0; digit < 6; digit++) {
12066
+ digits[CHAR_UPPER_A + digit] = digit + 10;
12067
+ digits[CHAR_LOWER_A + digit] = digit + 10;
12068
+ }
12069
+ return digits;
12070
+ })();
12071
+ /**
12072
+ * Find the longest legacy (semicolon-less) match for the name starting at
12073
+ * `start`, using the per-class legacy length bits. Returns
12074
+ * `slot << 3 | matchLength`, or -1 if there is no match. Only called after
12075
+ * the exact probes failed (the miss path).
12076
+ * @param input Input text.
12077
+ * @param start Start of the name.
12078
+ * @param maxLength Number of available run characters.
12079
+ */
12080
+ function findLegacySlot(input, start, maxLength) {
12081
+ let legacy = htmlLengthBits[pairIndex(input.charCodeAt(start), input.charCodeAt(start + 1))] >>> 16 & 31;
12082
+ while (legacy !== 0) {
12083
+ const top = 31 - Math.clz32(legacy);
12084
+ legacy ^= 1 << top;
12085
+ if (top + 2 > maxLength) continue;
12086
+ const slot = findSlotHtml(input, start, top + 2);
12087
+ if (slot >= 0 && (htmlSlotValue[slot] & 2) !== 0) return slot << 3 | top + 2;
12088
+ }
12089
+ return -1;
12090
+ }
12091
+ /**
12092
+ * Match a class containing long names without probing all its shorter lengths.
12093
+ * The 32-character window bounds the scan even for invalid or unterminated runs.
12094
+ * Returns `(slot << 6) | consumed`, excluding the `&`, or -1 on a miss.
12095
+ * @param input Input containing the candidate name.
12096
+ * @param start Start of the name.
12097
+ * @param mode Decoding mode, including the rules for legacy matches.
12098
+ */
12099
+ function findLongClassMatch(input, start, mode) {
12100
+ const length = input.slice(start, start + 32).indexOf(";");
12101
+ if (length - 2 >>> 0 <= 29) {
12102
+ const slot = findSlotHtml(input, start, length);
12103
+ if (slot >= 0) return slot << 6 | length + 1;
12104
+ }
12105
+ if (mode !== DecodingMode.Strict) {
12106
+ const packed = findLegacySlot(input, start, Math.min(31, input.length - start));
12107
+ if (packed >= 0) {
12108
+ const length = packed & 7;
12109
+ if (mode !== DecodingMode.Attribute || start + length >= input.length || !isEntityInAttributeInvalidEnd(input.charCodeAt(start + length))) return packed >> 3 << 6 | length;
12110
+ }
12111
+ }
12112
+ return -1;
12113
+ }
12114
+ const STATE_ENTITY_START = 0;
12115
+ const STATE_NUMERIC_START = 1;
12116
+ const STATE_NUMERIC_DECIMAL = 2;
12117
+ const STATE_NUMERIC_HEX = 3;
12118
+ const STATE_NAMED_ENTITY = 4;
12119
+ /**
12120
+ * Token decoder with support of writing partial entities; the shared base
12121
+ * of `HtmlEntityDecoder` and `XmlEntityDecoder`. Numeric entities are
12122
+ * identical in both document types and are handled here; named entities are
12123
+ * left to the subclasses.
12124
+ *
12125
+ * The decoder is driven by a tokenizer: after a `&`, write the following
12126
+ * input (possibly in chunks). `write` returns the number of characters
12127
+ * consumed once the entity is decided, or -1 while more input is needed.
12128
+ * Rejection may surface later than strictly possible (the decoder buffers
12129
+ * until a terminator or the name-length limit), but emitted code points,
12130
+ * consumed counts, and final return values are exact.
12131
+ */
12132
+ var EntityDecoderBase = class {
12133
+ emitCodePoint;
12134
+ errors;
12135
+ /** The current state of the decoder. */
12136
+ state = STATE_ENTITY_START;
12137
+ /** Characters that were consumed while parsing an entity. */
12138
+ consumed = 1;
12139
+ /** Accumulated numeric code point, or a packed partial XML name. */
12140
+ result = 0;
12141
+ /** The mode in which the decoder is operating. */
12142
+ decodeMode = DecodingMode.Strict;
12143
+ /** Replacement rules for numeric character references. */
12144
+ replaceNumericCodePoint = replaceCodePoint;
12145
+ constructor(emitCodePoint, errors) {
12146
+ this.emitCodePoint = emitCodePoint;
12147
+ this.errors = errors;
12148
+ }
12149
+ /**
12150
+ * Switches between the numeric decimal and hexadecimal states.
12151
+ *
12152
+ * Equivalent to the `Numeric character reference state` in the HTML spec.
12153
+ * @param input The string containing the entity (or a continuation of the entity).
12154
+ * @param offset The current offset.
12155
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
12156
+ */
12157
+ stateNumericStart(input, offset) {
12158
+ if (offset >= input.length) return -1;
12159
+ if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CHAR_LOWER_X) {
12160
+ this.state = STATE_NUMERIC_HEX;
12161
+ this.consumed += 1;
12162
+ return this.stateNumericHex(input, offset + 1);
12163
+ }
12164
+ this.state = STATE_NUMERIC_DECIMAL;
12165
+ return this.stateNumericDecimal(input, offset);
12166
+ }
12167
+ /**
12168
+ * Parses a hexadecimal numeric entity.
12169
+ *
12170
+ * Equivalent to the `Hexadecimal character reference state` in the HTML spec.
12171
+ * @param input The string containing the entity (or a continuation of the entity).
12172
+ * @param offset The current offset.
12173
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
12174
+ */
12175
+ stateNumericHex(input, offset) {
12176
+ const inputLength = input.length;
12177
+ let { result, consumed } = this;
12178
+ let index = offset;
12179
+ while (index < inputLength) {
12180
+ const char = input.charCodeAt(index);
12181
+ const digit = numericDigits[char];
12182
+ if (digit <= 15) result = result * 16 + digit;
12183
+ else {
12184
+ this.result = result;
12185
+ this.consumed = consumed;
12186
+ return this.emitNumericEntity(char, 3);
12187
+ }
12188
+ consumed += 1;
12189
+ index += 1;
12190
+ }
12191
+ this.result = result;
12192
+ this.consumed = consumed;
12193
+ return -1;
12194
+ }
12195
+ /**
12196
+ * Parses a decimal numeric entity.
12197
+ *
12198
+ * Equivalent to the `Decimal character reference state` in the HTML spec.
12199
+ * @param input The string containing the entity (or a continuation of the entity).
12200
+ * @param offset The current offset.
12201
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
12202
+ */
12203
+ stateNumericDecimal(input, offset) {
12204
+ const inputLength = input.length;
12205
+ let { result, consumed } = this;
12206
+ let index = offset;
12207
+ while (index < inputLength) {
12208
+ const digit = input.charCodeAt(index) - CHAR_ZERO;
12209
+ if (digit >>> 0 > 9) {
12210
+ this.result = result;
12211
+ this.consumed = consumed;
12212
+ return this.emitNumericEntity(digit + CHAR_ZERO, 2);
12213
+ }
12214
+ result = result * 10 + digit;
12215
+ consumed += 1;
12216
+ index += 1;
12217
+ }
12218
+ this.result = result;
12219
+ this.consumed = consumed;
12220
+ return -1;
12221
+ }
12222
+ /**
12223
+ * Validate and emit a numeric entity.
12224
+ *
12225
+ * Implements the logic from the `Hexadecimal character reference start
12226
+ * state` and `Numeric character reference end state` in the HTML spec.
12227
+ * @param lastCp The last code point of the entity. Used to see if the
12228
+ * entity was terminated with a semicolon.
12229
+ * @param expectedLength The minimum number of characters that should be
12230
+ * consumed. Used to validate that at least one digit
12231
+ * was consumed.
12232
+ * @returns The number of characters that were consumed.
12233
+ */
12234
+ emitNumericEntity(lastCp, expectedLength) {
12235
+ if (this.consumed <= expectedLength) {
12236
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
12237
+ return 0;
12385
12238
  }
12386
- this._err(ERR.surrogateInInputStream);
12387
- return cp;
12239
+ if (lastCp === CHAR_SEMI) this.consumed += 1;
12240
+ else if (this.decodeMode === DecodingMode.Strict) return 0;
12241
+ this.emitCodePoint(this.replaceNumericCodePoint(this.result), this.consumed);
12242
+ if (this.errors) {
12243
+ if (lastCp !== CHAR_SEMI) this.errors.missingSemicolonAfterCharacterReference();
12244
+ this.errors.validateNumericCharacterReference(this.result);
12245
+ }
12246
+ return this.consumed;
12388
12247
  }
12389
- willDropParsedChunk() {
12390
- return this.pos > this.bufferWaterline;
12248
+ /**
12249
+ * Resets the instance to make it reusable.
12250
+ * @param decodeMode Entity decoding mode to use.
12251
+ */
12252
+ startEntity(decodeMode) {
12253
+ this.decodeMode = decodeMode;
12254
+ this.state = STATE_ENTITY_START;
12255
+ this.result = 0;
12256
+ this.consumed = 1;
12391
12257
  }
12392
- dropParsedChunk() {
12393
- if (this.willDropParsedChunk()) {
12394
- this.html = this.html.substring(this.pos);
12395
- this.lineStartPos -= this.pos;
12396
- this.droppedBufferSize += this.pos;
12397
- this.pos = 0;
12398
- this.lastGapPos = -2;
12399
- this.gapStack.length = 0;
12258
+ /**
12259
+ * Write an entity to the decoder. This can be called multiple times with partial entities.
12260
+ * If the entity is incomplete, the decoder will return -1.
12261
+ * @param input The string containing the entity (or a continuation of the entity).
12262
+ * @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
12263
+ * @returns The number of characters that were consumed, or -1 if the entity is incomplete.
12264
+ */
12265
+ write(input, offset) {
12266
+ switch (this.state) {
12267
+ case STATE_ENTITY_START:
12268
+ if (input.charCodeAt(offset) === CHAR_NUM) {
12269
+ this.state = STATE_NUMERIC_START;
12270
+ this.consumed += 1;
12271
+ return this.stateNumericStart(input, offset + 1);
12272
+ }
12273
+ this.state = STATE_NAMED_ENTITY;
12274
+ return this.stateNamedEntity(input, offset);
12275
+ case STATE_NUMERIC_START: return this.stateNumericStart(input, offset);
12276
+ case STATE_NUMERIC_DECIMAL: return this.stateNumericDecimal(input, offset);
12277
+ case STATE_NUMERIC_HEX: return this.stateNumericHex(input, offset);
12278
+ default: return this.stateNamedEntity(input, offset);
12400
12279
  }
12401
12280
  }
12402
- write(chunk, isLastChunk) {
12403
- if (this.html.length > 0) this.html += chunk;
12404
- else this.html = chunk;
12405
- this.endOfChunkHit = false;
12406
- this.lastChunkWritten = isLastChunk;
12281
+ /**
12282
+ * Signal to the parser that the end of the input was reached.
12283
+ *
12284
+ * Remaining data will be emitted and relevant errors will be produced.
12285
+ * @returns The number of characters consumed.
12286
+ */
12287
+ end() {
12288
+ switch (this.state) {
12289
+ case STATE_NAMED_ENTITY: return this.endNamedEntity();
12290
+ case STATE_NUMERIC_DECIMAL: return this.emitNumericEntity(0, 2);
12291
+ case STATE_NUMERIC_HEX: return this.emitNumericEntity(0, 3);
12292
+ case STATE_NUMERIC_START:
12293
+ this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
12294
+ return 0;
12295
+ default: return 0;
12296
+ }
12407
12297
  }
12408
- insertHtmlAtCurrentPos(chunk) {
12409
- this.html = this.html.substring(0, this.pos + 1) + chunk + this.html.substring(this.pos + 1);
12410
- this.endOfChunkHit = false;
12298
+ };
12299
+ /**
12300
+ * Streaming decoder for HTML entities.
12301
+ *
12302
+ * When the entity fits inside the current chunk (the common case), the
12303
+ * lookup runs directly on the chunk via the same length-probe scheme as the
12304
+ * synchronous decoder; chunk-boundary runs use a reusable character buffer.
12305
+ */
12306
+ var HtmlEntityDecoder = class extends EntityDecoderBase {
12307
+ /** Total name characters seen for the current named entity. */
12308
+ runLength = 0;
12309
+ /** Reused for ASCII alphanumerics; the 32nd character rules out an exact match. */
12310
+ nameBuffer = /* @__PURE__ */ new Uint8Array(32);
12311
+ /**
12312
+ * Emit the replacement for a matched slot. Values are at most two
12313
+ * UTF-16 code units; like previous versions, each unit is emitted as
12314
+ * its own callback (surrogate halves included).
12315
+ * @param slot The matched slot.
12316
+ */
12317
+ emitSlot(slot) {
12318
+ const packed = htmlSlotValue[slot];
12319
+ const off = packed >> 2;
12320
+ this.emitCodePoint(htmlValues.charCodeAt(off), this.consumed);
12321
+ if ((packed & 1) !== 0) this.emitCodePoint(htmlValues.charCodeAt(off + 1), this.consumed);
12411
12322
  }
12412
- startsWith(pattern, caseSensitive) {
12413
- if (this.pos + pattern.length > this.html.length) {
12414
- this.endOfChunkHit = !this.lastChunkWritten;
12415
- return false;
12416
- }
12417
- if (caseSensitive) return this.html.startsWith(pattern, this.pos);
12418
- for (let i = 0; i < pattern.length; i++) if ((this.html.charCodeAt(this.pos + i) | 32) !== pattern.charCodeAt(i)) return false;
12419
- return true;
12323
+ startEntity(decodeMode) {
12324
+ super.startEntity(decodeMode);
12325
+ this.runLength = 0;
12420
12326
  }
12421
- peek(offset) {
12422
- const pos = this.pos + offset;
12423
- if (pos >= this.html.length) {
12424
- this.endOfChunkHit = !this.lastChunkWritten;
12425
- return CODE_POINTS.EOF;
12327
+ stateNamedEntity(input, offset) {
12328
+ const inputLength = input.length;
12329
+ if (this.runLength === 0 && offset + 17 <= inputLength) {
12330
+ const pair = pairIndex(input.charCodeAt(offset), input.charCodeAt(offset + 1));
12331
+ const bits = htmlLengthBits[pair];
12332
+ if ((bits & 32768) !== 0 && offset + 32 <= inputLength) {
12333
+ const packed = findLongClassMatch(input, offset, this.decodeMode);
12334
+ if (packed >= 0) {
12335
+ const length = packed & 63;
12336
+ this.consumed = length + 1;
12337
+ this.emitSlot(packed >> 6);
12338
+ if (input.charCodeAt(offset + length - 1) !== CHAR_SEMI) this.errors?.missingSemicolonAfterCharacterReference();
12339
+ return this.consumed;
12340
+ }
12341
+ return 0;
12342
+ }
12343
+ let probed = bits & 32767;
12344
+ while (probed !== 0) {
12345
+ const low = probed & -probed;
12346
+ probed ^= low;
12347
+ const length = 33 - Math.clz32(low);
12348
+ if (input.charCodeAt(offset + length) === CHAR_SEMI) {
12349
+ const slot = findSlotHtml(input, offset, length);
12350
+ if (slot >= 0) {
12351
+ this.consumed = length + 2;
12352
+ this.emitSlot(slot);
12353
+ return this.consumed;
12354
+ }
12355
+ }
12356
+ }
12357
+ if ((bits & 32768) === 0) {
12358
+ if (this.decodeMode !== DecodingMode.Strict) {
12359
+ const packed = findLegacySlot(input, offset, 31);
12360
+ if (packed >= 0) {
12361
+ const matchLength = packed & 7;
12362
+ const next = input.charCodeAt(offset + matchLength);
12363
+ if (this.decodeMode === DecodingMode.Attribute && isEntityInAttributeInvalidEnd(next)) return 0;
12364
+ this.consumed = matchLength + 1;
12365
+ this.emitSlot(packed >> 3);
12366
+ this.errors?.missingSemicolonAfterCharacterReference();
12367
+ return this.consumed;
12368
+ }
12369
+ }
12370
+ return 0;
12371
+ }
12426
12372
  }
12427
- const code = this.html.charCodeAt(pos);
12428
- return code === CODE_POINTS.CARRIAGE_RETURN ? CODE_POINTS.LINE_FEED : code;
12429
- }
12430
- advance() {
12431
- this.pos++;
12432
- if (this.isEol) {
12433
- this.isEol = false;
12434
- this.line++;
12435
- this.lineStartPos = this.pos;
12373
+ let index = offset;
12374
+ let { runLength } = this;
12375
+ let terminator = -1;
12376
+ const scanEnd = Math.min(inputLength, offset + 32 - runLength);
12377
+ while (index < scanEnd) {
12378
+ const char = input.charCodeAt(index);
12379
+ if (!isAlphaNumeric(char)) {
12380
+ terminator = char;
12381
+ break;
12382
+ }
12383
+ this.nameBuffer[runLength++] = char;
12384
+ index++;
12436
12385
  }
12437
- if (this.pos >= this.html.length) {
12438
- this.endOfChunkHit = !this.lastChunkWritten;
12439
- return CODE_POINTS.EOF;
12386
+ if (terminator < 0 && runLength < 32) {
12387
+ this.runLength = runLength;
12388
+ return -1;
12440
12389
  }
12441
- let cp = this.html.charCodeAt(this.pos);
12442
- if (cp === CODE_POINTS.CARRIAGE_RETURN) {
12443
- this.isEol = true;
12444
- this.skipNextNewLine = true;
12445
- return CODE_POINTS.LINE_FEED;
12390
+ if (terminator === CHAR_SEMI && runLength - 2 >>> 0 <= 29) {
12391
+ const slot = findBufferedHtmlSlot(this.nameBuffer, runLength);
12392
+ if (slot >= 0) {
12393
+ this.consumed = runLength + 2;
12394
+ this.emitSlot(slot);
12395
+ return this.consumed;
12396
+ }
12446
12397
  }
12447
- if (cp === CODE_POINTS.LINE_FEED) {
12448
- this.isEol = true;
12449
- if (this.skipNextNewLine) {
12450
- this.line--;
12451
- this.skipNextNewLine = false;
12452
- this._addGap();
12453
- return this.advance();
12398
+ if (this.decodeMode !== DecodingMode.Strict && runLength >= 2) {
12399
+ const packed = findBufferedLegacySlot(this.nameBuffer, runLength);
12400
+ if (packed >= 0) {
12401
+ const length = packed & 7;
12402
+ const next = length < runLength ? this.nameBuffer[length] : terminator;
12403
+ if (this.decodeMode === DecodingMode.Attribute && isEntityInAttributeInvalidEnd(next)) return 0;
12404
+ this.consumed = length + 1;
12405
+ this.emitSlot(packed >> 3);
12406
+ this.errors?.missingSemicolonAfterCharacterReference();
12407
+ return this.consumed;
12454
12408
  }
12455
12409
  }
12456
- this.skipNextNewLine = false;
12457
- if (isSurrogate(cp)) cp = this._processSurrogate(cp);
12458
- if (!(this.handler.onParseError === null || cp > 31 && cp < 127 || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.CARRIAGE_RETURN || cp > 159 && cp < 64976)) this._checkForProblematicCharacters(cp);
12459
- return cp;
12460
- }
12461
- _checkForProblematicCharacters(cp) {
12462
- if (isControlCodePoint(cp)) this._err(ERR.controlCharacterInInputStream);
12463
- else if (isUndefinedCodePoint(cp)) this._err(ERR.noncharacterInInputStream);
12410
+ return 0;
12464
12411
  }
12465
- retreat(count) {
12466
- this.pos -= count;
12467
- while (this.pos < this.lastGapPos) {
12468
- this.lastGapPos = this.gapStack.pop();
12469
- this.pos--;
12470
- }
12471
- this.isEol = false;
12412
+ endNamedEntity() {
12413
+ if (this.decodeMode === DecodingMode.Strict || this.runLength < 2) return 0;
12414
+ const packed = findBufferedLegacySlot(this.nameBuffer, this.runLength);
12415
+ if (packed < 0) return 0;
12416
+ if (this.decodeMode === DecodingMode.Attribute && (packed & 7) < this.runLength) return 0;
12417
+ this.consumed = (packed & 7) + 1;
12418
+ this.emitSlot(packed >> 3);
12419
+ this.errors?.missingSemicolonAfterCharacterReference();
12420
+ return this.consumed;
12472
12421
  }
12473
12422
  };
12474
- // node_modules/parse5/dist/common/token.js
12475
- var TokenType;
12476
- (function(TokenType) {
12477
- TokenType[TokenType["CHARACTER"] = 0] = "CHARACTER";
12478
- TokenType[TokenType["NULL_CHARACTER"] = 1] = "NULL_CHARACTER";
12479
- TokenType[TokenType["WHITESPACE_CHARACTER"] = 2] = "WHITESPACE_CHARACTER";
12480
- TokenType[TokenType["START_TAG"] = 3] = "START_TAG";
12481
- TokenType[TokenType["END_TAG"] = 4] = "END_TAG";
12482
- TokenType[TokenType["COMMENT"] = 5] = "COMMENT";
12483
- TokenType[TokenType["DOCTYPE"] = 6] = "DOCTYPE";
12484
- TokenType[TokenType["EOF"] = 7] = "EOF";
12485
- TokenType[TokenType["HIBERNATION"] = 8] = "HIBERNATION";
12486
- })(TokenType || (TokenType = {}));
12487
- function getTokenAttr(token, attrName) {
12488
- for (let i = token.attrs.length - 1; i >= 0; i--) if (token.attrs[i].name === attrName) return token.attrs[i].value;
12489
- return null;
12423
+ /**
12424
+ * Find a buffered name. Its characters were already checked as ASCII
12425
+ * alphanumerics while scanning, so no outer-character range check is needed.
12426
+ * @param buffer Reusable character buffer.
12427
+ * @param length Number of characters to match.
12428
+ */
12429
+ function findBufferedHtmlSlot(buffer, length) {
12430
+ const key = buffer[0] << 25 | buffer[1] << 18 | buffer[length - 2] << 11 | CHAR_REMAP[buffer[length - 1]] << 5 | length;
12431
+ let slot = 2 * ((Math.imul(key, BUCKET_HASH_1) >>> 16) * htmlBuckets >>> 16);
12432
+ for (let attempt = 0;; attempt++) {
12433
+ if (htmlKeys[slot] === key && (length <= 4 || isBufferedMiddle(slot, buffer, length))) return slot;
12434
+ if (htmlKeys[slot + 1] === key && (length <= 4 || isBufferedMiddle(slot + 1, buffer, length))) return slot + 1;
12435
+ if (attempt === 1) return -1;
12436
+ slot = 2 * ((Math.imul(key, BUCKET_HASH_2) >>> 16) * htmlBuckets >>> 16);
12437
+ }
12438
+ }
12439
+ function isBufferedMiddle(slot, buffer, length) {
12440
+ let wordIndex = htmlSlotMidOff[slot];
12441
+ let index = 2;
12442
+ const end = length - 2;
12443
+ while (index + 1 < end) {
12444
+ if ((buffer[index] | buffer[index + 1] << 16) !== htmlMiddles[wordIndex++]) return false;
12445
+ index += 2;
12446
+ }
12447
+ return index === end || buffer[index] === (htmlMiddles[wordIndex] & 65535);
12448
+ }
12449
+ /**
12450
+ * Find the longest legacy name in the buffer, packed as `(slot << 3) | length`.
12451
+ * @param buffer Reusable character buffer.
12452
+ * @param length Number of buffered characters.
12453
+ */
12454
+ function findBufferedLegacySlot(buffer, length) {
12455
+ let legacy = htmlLengthBits[pairIndex(buffer[0], buffer[1])] >>> 16 & 31;
12456
+ while (legacy !== 0) {
12457
+ const top = 31 - Math.clz32(legacy);
12458
+ legacy ^= 1 << top;
12459
+ if (top + 2 > length) continue;
12460
+ const slot = findBufferedHtmlSlot(buffer, top + 2);
12461
+ if (slot >= 0 && (htmlSlotValue[slot] & 2) !== 0) return slot << 3 | top + 2;
12462
+ }
12463
+ return -1;
12490
12464
  }
12491
12465
  // node_modules/parse5/dist/common/html.js
12492
12466
  /** All valid namespaces in HTML. */
@@ -13010,7 +12984,7 @@ const SPECIAL_ELEMENTS = {
13010
12984
  [NS.XML]: /* @__PURE__ */ new Set(),
13011
12985
  [NS.XMLNS]: /* @__PURE__ */ new Set()
13012
12986
  };
13013
- const NUMBERED_HEADERS = /* @__PURE__ */ new Set([
12987
+ const NUMBERED_HEADERS$1 = /* @__PURE__ */ new Set([
13014
12988
  $.H1,
13015
12989
  $.H2,
13016
12990
  $.H3,
@@ -13020,6 +12994,7 @@ const NUMBERED_HEADERS = /* @__PURE__ */ new Set([
13020
12994
  ]);
13021
12995
  TAG_NAMES.STYLE, TAG_NAMES.SCRIPT, TAG_NAMES.XMP, TAG_NAMES.IFRAME, TAG_NAMES.NOEMBED, TAG_NAMES.NOFRAMES, TAG_NAMES.PLAINTEXT;
13022
12996
  // node_modules/parse5/dist/tokenizer/index.js
12997
+ const ATTR_NAME_SET_THRESHOLD = 64;
13023
12998
  var State;
13024
12999
  (function(State) {
13025
13000
  State[State["DATA"] = 0] = "DATA";
@@ -13123,7 +13098,7 @@ function toAsciiLower(cp) {
13123
13098
  return cp + 32;
13124
13099
  }
13125
13100
  function isWhitespace(cp) {
13126
- return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED;
13101
+ return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED || cp === CODE_POINTS.CARRIAGE_RETURN;
13127
13102
  }
13128
13103
  function isScriptDataDoubleEscapeSequenceEnd(cp) {
13129
13104
  return isWhitespace(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
@@ -13162,11 +13137,21 @@ var Tokenizer = class {
13162
13137
  name: "",
13163
13138
  value: ""
13164
13139
  };
13140
+ this.currentAttrLocation = null;
13141
+ this.currentAttrNames = null;
13142
+ /**
13143
+ * `[start, end)` of `preprocessor.html` still to be appended to the attribute value, comment data or character
13144
+ * token being built (`_flushRun`): input that is used as is is appended as one slice, not a code point at a time.
13145
+ */
13146
+ this.runStart = 0;
13147
+ this.runEnd = 0;
13165
13148
  this.preprocessor = new Preprocessor(handler);
13166
13149
  this.currentLocation = this.getCurrentLocation(-1);
13167
- this.entityDecoder = new EntityDecoder(htmlDecodeTree, (cp, consumed) => {
13150
+ this.entityDecoder = new HtmlEntityDecoder((cp, consumed) => {
13168
13151
  this.preprocessor.pos = this.entityStartPos + consumed - 1;
13169
- this._flushCodePointConsumedAsCharacterReference(cp);
13152
+ if (!this._isCharacterReferenceInAttribute()) this._ensureCharacterToken(isWhitespace(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER);
13153
+ this._extendRunWith(String.fromCodePoint(cp), 0);
13154
+ this.entityStartPos = this.preprocessor.pos - consumed + 1;
13170
13155
  }, handler.onParseError ? {
13171
13156
  missingSemicolonAfterCharacterReference: () => {
13172
13157
  this._err(ERR.missingSemicolonAfterCharacterReference, 1);
@@ -13205,6 +13190,76 @@ var Tokenizer = class {
13205
13190
  }
13206
13191
  this.inLoop = false;
13207
13192
  }
13193
+ /** Emit buffered character tokens without completing the current token or emitting EOF. */
13194
+ flushCharacters() {
13195
+ var _a;
13196
+ if (this.inLoop) throw new Error("Cannot flush characters from a tokenizer callback");
13197
+ const location = (_a = this.currentCharacterToken) === null || _a === void 0 ? void 0 : _a.location;
13198
+ let nextLocation = null;
13199
+ if (location) {
13200
+ nextLocation = this.getCharacterTokenEndLocation(location);
13201
+ this.currentLocation = nextLocation;
13202
+ }
13203
+ this.inLoop = true;
13204
+ try {
13205
+ this._emitCurrentCharacterToken(nextLocation);
13206
+ } finally {
13207
+ this.inLoop = false;
13208
+ }
13209
+ this._runParsingLoop();
13210
+ }
13211
+ getCharacterTokenEndLocation(location) {
13212
+ const endOffset = this.getCharacterTokenEndOffset();
13213
+ const html = this.preprocessor.html.slice(location.startOffset - this.preprocessor.droppedBufferSize, endOffset - this.preprocessor.droppedBufferSize);
13214
+ let line = location.startLine;
13215
+ let lastLineBreak = -1;
13216
+ for (let i = html.indexOf("\n"); i !== -1; i = html.indexOf("\n", i + 1)) {
13217
+ line++;
13218
+ lastLineBreak = i;
13219
+ }
13220
+ for (let i = html.indexOf("\r"); i !== -1; i = html.indexOf("\r", i + 1)) if (html.charCodeAt(i + 1) !== CODE_POINTS.LINE_FEED) {
13221
+ line++;
13222
+ lastLineBreak = Math.max(lastLineBreak, i);
13223
+ }
13224
+ return {
13225
+ startLine: line,
13226
+ startCol: lastLineBreak === -1 ? location.startCol + html.length : html.length - lastLineBreak,
13227
+ startOffset: endOffset,
13228
+ endLine: -1,
13229
+ endCol: -1,
13230
+ endOffset: -1
13231
+ };
13232
+ }
13233
+ getCharacterTokenEndOffset() {
13234
+ var _a;
13235
+ const end = this.preprocessor.droppedBufferSize + this.preprocessor.pos + 1;
13236
+ const tokenLocation = (_a = this.currentToken) === null || _a === void 0 ? void 0 : _a.location;
13237
+ switch (this.state) {
13238
+ case State.TAG_OPEN:
13239
+ case State.RCDATA_LESS_THAN_SIGN:
13240
+ case State.RAWTEXT_LESS_THAN_SIGN:
13241
+ case State.SCRIPT_DATA_LESS_THAN_SIGN:
13242
+ case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:
13243
+ case State.CDATA_SECTION_BRACKET: return end - 1;
13244
+ case State.END_TAG_OPEN:
13245
+ case State.MARKUP_DECLARATION_OPEN:
13246
+ case State.RCDATA_END_TAG_OPEN:
13247
+ case State.RCDATA_END_TAG_NAME:
13248
+ case State.RAWTEXT_END_TAG_OPEN:
13249
+ case State.RAWTEXT_END_TAG_NAME:
13250
+ case State.SCRIPT_DATA_END_TAG_OPEN:
13251
+ case State.SCRIPT_DATA_END_TAG_NAME:
13252
+ case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:
13253
+ case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME:
13254
+ case State.CDATA_SECTION_END: return end - 2;
13255
+ case State.CHARACTER_REFERENCE: return this._isCharacterReferenceInAttribute() && tokenLocation ? tokenLocation.startOffset : this.preprocessor.droppedBufferSize + this.entityStartPos;
13256
+ case State.DOCTYPE:
13257
+ case State.BEFORE_DOCTYPE_NAME: return this.currentLocation.startOffset;
13258
+ default:
13259
+ if (tokenLocation && (this.state === State.TAG_NAME || this.state >= State.BEFORE_ATTRIBUTE_NAME && this.state <= State.BOGUS_COMMENT || this.state >= State.COMMENT_START && this.state <= State.BOGUS_DOCTYPE)) return tokenLocation.startOffset;
13260
+ return end;
13261
+ }
13262
+ }
13208
13263
  pause() {
13209
13264
  this.paused = true;
13210
13265
  }
@@ -13226,6 +13281,18 @@ var Tokenizer = class {
13226
13281
  this.preprocessor.insertHtmlAtCurrentPos(chunk);
13227
13282
  this._runParsingLoop();
13228
13283
  }
13284
+ /** @internal Flush completed streaming text without splitting an unfinished token. */
13285
+ flushCurrentCharacterToken() {
13286
+ if (this.paused || this.active || !this.currentCharacterToken || this.currentToken || this.state === State.DOCTYPE || this.state === State.BEFORE_DOCTYPE_NAME || !this.preprocessor.willDropParsedChunk()) return;
13287
+ const pending = this.preprocessor.droppedBufferSize + this.preprocessor.pos + 1 - this.getCharacterTokenEndOffset();
13288
+ this.preprocessor.advance();
13289
+ this.currentLocation = this.getCurrentLocation(pending);
13290
+ this.preprocessor.retreat(1);
13291
+ this._emitCurrentCharacterToken(this.currentLocation);
13292
+ this._createCharacterToken(TokenType.CHARACTER);
13293
+ this.preprocessor.dropParsedChunk(Math.max(pending - 1, 0));
13294
+ this.entityStartPos = this.preprocessor.pos + 1 - pending;
13295
+ }
13229
13296
  _ensureHibernation() {
13230
13297
  if (this.preprocessor.endOfChunkHit) {
13231
13298
  this.preprocessor.retreat(this.consumedAfterSnapshot);
@@ -13251,6 +13318,7 @@ var Tokenizer = class {
13251
13318
  return false;
13252
13319
  }
13253
13320
  _createStartTagToken() {
13321
+ this._flushRun("");
13254
13322
  this.currentToken = {
13255
13323
  type: TokenType.START_TAG,
13256
13324
  tagName: "",
@@ -13262,6 +13330,7 @@ var Tokenizer = class {
13262
13330
  };
13263
13331
  }
13264
13332
  _createEndTagToken() {
13333
+ this._flushRun("");
13265
13334
  this.currentToken = {
13266
13335
  type: TokenType.END_TAG,
13267
13336
  tagName: "",
@@ -13273,6 +13342,7 @@ var Tokenizer = class {
13273
13342
  };
13274
13343
  }
13275
13344
  _createCommentToken(offset) {
13345
+ this._flushRun("");
13276
13346
  this.currentToken = {
13277
13347
  type: TokenType.COMMENT,
13278
13348
  data: "",
@@ -13280,6 +13350,7 @@ var Tokenizer = class {
13280
13350
  };
13281
13351
  }
13282
13352
  _createDoctypeToken(initialName) {
13353
+ this._flushRun("");
13283
13354
  this.currentToken = {
13284
13355
  type: TokenType.DOCTYPE,
13285
13356
  name: initialName,
@@ -13289,39 +13360,104 @@ var Tokenizer = class {
13289
13360
  location: this.currentLocation
13290
13361
  };
13291
13362
  }
13292
- _createCharacterToken(type, chars) {
13363
+ _createCharacterToken(type) {
13364
+ if (this.currentLocation) {
13365
+ const start = this.currentLocation.startOffset - this.preprocessor.droppedBufferSize;
13366
+ if (this.preprocessor.html[start] === "\n" && this.preprocessor.html[start - 1] === "\r") this.currentLocation.startOffset++;
13367
+ }
13293
13368
  this.currentCharacterToken = {
13294
13369
  type,
13295
- chars,
13370
+ chars: "",
13296
13371
  location: this.currentLocation
13297
13372
  };
13298
13373
  }
13299
13374
  _createAttr(attrNameFirstCh) {
13375
+ this._flushRun("");
13300
13376
  this.currentAttr = {
13301
13377
  name: attrNameFirstCh,
13302
13378
  value: ""
13303
13379
  };
13304
- this.currentLocation = this.getCurrentLocation(0);
13380
+ this.currentAttrLocation = this.getCurrentLocation(0);
13305
13381
  }
13306
13382
  _leaveAttrName() {
13307
13383
  var _a;
13308
13384
  var _b;
13309
13385
  const token = this.currentToken;
13310
- if (getTokenAttr(token, this.currentAttr.name) === null) {
13386
+ const { name } = this.currentAttr;
13387
+ const names = this.currentAttrNames;
13388
+ let duplicate;
13389
+ if (names === null) {
13390
+ duplicate = getTokenAttr(token, name) !== null;
13391
+ if (!duplicate && token.attrs.length === ATTR_NAME_SET_THRESHOLD) this.currentAttrNames = new Set(token.attrs.map((attr) => attr.name)).add(name);
13392
+ } else {
13393
+ duplicate = names.has(name);
13394
+ if (!duplicate) names.add(name);
13395
+ }
13396
+ if (duplicate) this._err(ERR.duplicateAttribute);
13397
+ else {
13311
13398
  token.attrs.push(this.currentAttr);
13312
- if (token.location && this.currentLocation) {
13399
+ if (token.location && this.currentAttrLocation) {
13313
13400
  const attrLocations = (_a = (_b = token.location).attrs) !== null && _a !== void 0 ? _a : _b.attrs = Object.create(null);
13314
- attrLocations[this.currentAttr.name] = this.currentLocation;
13401
+ attrLocations[this.currentAttr.name] = this.currentAttrLocation;
13315
13402
  this._leaveAttrValue();
13316
13403
  }
13317
- } else this._err(ERR.duplicateAttribute);
13404
+ }
13318
13405
  }
13319
13406
  _leaveAttrValue() {
13320
- if (this.currentLocation) {
13321
- this.currentLocation.endLine = this.preprocessor.line;
13322
- this.currentLocation.endCol = this.preprocessor.col;
13323
- this.currentLocation.endOffset = this.preprocessor.offset;
13407
+ if (this.currentAttrLocation) {
13408
+ this.currentAttrLocation.endLine = this.preprocessor.line;
13409
+ this.currentAttrLocation.endCol = this.preprocessor.col;
13410
+ this.currentAttrLocation.endOffset = this.preprocessor.offset;
13411
+ }
13412
+ }
13413
+ /**
13414
+ * Append the pending run and `text` to the attribute value, comment data or character token being built.
13415
+ * The run is a string of its own: V8 copies a slice of fewer than 13 characters but lets a longer one share
13416
+ * the input's buffer, which would keep that buffer alive for as long as any attribute value or text cut from
13417
+ * it is; a concatenation is flattened into a buffer of its own when it is sliced.
13418
+ */
13419
+ _flushRun(text) {
13420
+ if (this.runEnd === this.runStart && text.length === 0) return;
13421
+ const slice = this.preprocessor.html.slice(this.runStart, this.runEnd);
13422
+ const run = (slice.length < 13 ? slice : ` ${slice}`.slice(1)) + text;
13423
+ const token = this.currentToken;
13424
+ this.runStart = this.runEnd;
13425
+ if (token === null) this.currentCharacterToken.chars += run;
13426
+ else if (token.type === TokenType.COMMENT) token.data += run;
13427
+ else this.currentAttr.value += run;
13428
+ }
13429
+ /** Extend the pending run by the current input code point, read as `cp`, or flush it and start a new one. */
13430
+ _extendRun(cp) {
13431
+ const { preprocessor } = this;
13432
+ if (cp === CODE_POINTS.LINE_FEED && preprocessor.html.charCodeAt(preprocessor.pos) !== CODE_POINTS.LINE_FEED) {
13433
+ this._flushRun("\n");
13434
+ this.runStart = preprocessor.pos + 1;
13435
+ } else {
13436
+ const start = preprocessor.pos - Number(cp > 65535);
13437
+ if (start !== this.runEnd) {
13438
+ this._flushRun("");
13439
+ this.runStart = start;
13440
+ }
13441
+ }
13442
+ this.runEnd = preprocessor.pos + 1;
13443
+ }
13444
+ /**
13445
+ * Extend the pending run by `text`, the input that ends `cpOffset` code points after the current one, or flush
13446
+ * the run and append `text` where the input differs (a NUL replacement, a decoded reference, a dropped chunk).
13447
+ */
13448
+ _extendRunWith(text, cpOffset) {
13449
+ const { preprocessor } = this;
13450
+ const start = preprocessor.codePointStart + 1 + cpOffset - text.length;
13451
+ if (start >= 0 && preprocessor.html.startsWith(text, start)) {
13452
+ if (start !== this.runEnd) {
13453
+ this._flushRun("");
13454
+ this.runStart = start;
13455
+ }
13456
+ } else {
13457
+ this._flushRun(text);
13458
+ this.runStart = start + text.length;
13324
13459
  }
13460
+ this.runEnd = start + text.length;
13325
13461
  }
13326
13462
  prepareToken(ct) {
13327
13463
  this._emitCurrentCharacterToken(ct.location);
@@ -13335,6 +13471,7 @@ var Tokenizer = class {
13335
13471
  }
13336
13472
  emitCurrentTagToken() {
13337
13473
  const ct = this.currentToken;
13474
+ this.currentAttrNames = null;
13338
13475
  this.prepareToken(ct);
13339
13476
  ct.tagID = getTagID(ct.tagName);
13340
13477
  if (ct.type === TokenType.START_TAG) {
@@ -13358,6 +13495,7 @@ var Tokenizer = class {
13358
13495
  this.preprocessor.dropParsedChunk();
13359
13496
  }
13360
13497
  _emitCurrentCharacterToken(nextLocation) {
13498
+ this._flushRun("");
13361
13499
  if (this.currentCharacterToken) {
13362
13500
  if (nextLocation && this.currentCharacterToken.location) {
13363
13501
  this.currentCharacterToken.location.endLine = nextLocation.startLine;
@@ -13377,38 +13515,44 @@ var Tokenizer = class {
13377
13515
  }
13378
13516
  }
13379
13517
  _emitEOFToken() {
13518
+ var _a, _b;
13380
13519
  const location = this.getCurrentLocation(0);
13381
13520
  if (location) {
13382
13521
  location.endLine = location.startLine;
13383
13522
  location.endCol = location.startCol;
13384
13523
  location.endOffset = location.startOffset;
13385
13524
  }
13386
- this._emitCurrentCharacterToken(location);
13525
+ this._emitCurrentCharacterToken((_b = (_a = this.currentToken) === null || _a === void 0 ? void 0 : _a.location) !== null && _b !== void 0 ? _b : location);
13387
13526
  this.handler.onEof({
13388
13527
  type: TokenType.EOF,
13389
13528
  location
13390
13529
  });
13391
13530
  this.active = false;
13392
13531
  }
13393
- _appendCharToCurrentCharacterToken(type, ch) {
13532
+ /** Make the current character token one of `type`, emitting the current one if it has another type. */
13533
+ _ensureCharacterToken(type) {
13394
13534
  if (this.currentCharacterToken) {
13395
- if (this.currentCharacterToken.type === type) {
13396
- this.currentCharacterToken.chars += ch;
13397
- return;
13398
- } else {
13399
- this.currentLocation = this.getCurrentLocation(0);
13400
- this._emitCurrentCharacterToken(this.currentLocation);
13401
- this.preprocessor.dropParsedChunk();
13402
- }
13535
+ if (this.currentCharacterToken.type === type) return;
13536
+ this.currentLocation = this.getCurrentLocation(0);
13537
+ this._emitCurrentCharacterToken(this.currentLocation);
13538
+ this.preprocessor.dropParsedChunk();
13403
13539
  }
13404
- this._createCharacterToken(type, ch);
13540
+ this._createCharacterToken(type);
13405
13541
  }
13542
+ /** Emit the current input code point, read as `cp`. */
13406
13543
  _emitCodePoint(cp) {
13407
13544
  const type = isWhitespace(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
13408
- this._appendCharToCurrentCharacterToken(type, cp < 65536 ? String.fromCharCode(cp) : String.fromCodePoint(cp));
13409
- }
13410
- _emitChars(ch) {
13411
- this._appendCharToCurrentCharacterToken(TokenType.CHARACTER, ch);
13545
+ const token = this.currentCharacterToken;
13546
+ if (token === null || token.type !== type) this._ensureCharacterToken(type);
13547
+ this._extendRun(cp);
13548
+ }
13549
+ _emitChars(ch, cpOffset = 0) {
13550
+ if (this.options.sourceCodeLocationInfo && cpOffset !== 0 && this.currentCharacterToken && this.currentCharacterToken.type !== TokenType.CHARACTER) {
13551
+ this.currentLocation = this.getCurrentLocation(ch.length - 1 - cpOffset);
13552
+ this._emitCurrentCharacterToken(this.currentLocation);
13553
+ this._createCharacterToken(TokenType.CHARACTER);
13554
+ } else this._ensureCharacterToken(TokenType.CHARACTER);
13555
+ this._extendRunWith(ch, cpOffset);
13412
13556
  }
13413
13557
  _startCharacterReference() {
13414
13558
  this.returnState = this.state;
@@ -13420,7 +13564,7 @@ var Tokenizer = class {
13420
13564
  return this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED;
13421
13565
  }
13422
13566
  _flushCodePointConsumedAsCharacterReference(cp) {
13423
- if (this._isCharacterReferenceInAttribute()) this.currentAttr.value += String.fromCodePoint(cp);
13567
+ if (this._isCharacterReferenceInAttribute()) this._extendRun(cp);
13424
13568
  else this._emitCodePoint(cp);
13425
13569
  }
13426
13570
  _callState(cp) {
@@ -13745,12 +13889,12 @@ var Tokenizer = class {
13745
13889
  break;
13746
13890
  case CODE_POINTS.EOF:
13747
13891
  this._err(ERR.eofBeforeTagName);
13748
- this._emitChars("<");
13892
+ this._emitChars("<", -1);
13749
13893
  this._emitEOFToken();
13750
13894
  break;
13751
13895
  default:
13752
13896
  this._err(ERR.invalidFirstCharacterOfTagName);
13753
- this._emitChars("<");
13897
+ this._emitChars("<", -1);
13754
13898
  this.state = State.DATA;
13755
13899
  this._stateData(cp);
13756
13900
  }
@@ -13767,7 +13911,7 @@ var Tokenizer = class {
13767
13911
  break;
13768
13912
  case CODE_POINTS.EOF:
13769
13913
  this._err(ERR.eofBeforeTagName);
13770
- this._emitChars("</");
13914
+ this._emitChars("</", -1);
13771
13915
  this._emitEOFToken();
13772
13916
  break;
13773
13917
  default:
@@ -13807,7 +13951,7 @@ var Tokenizer = class {
13807
13951
  _stateRcdataLessThanSign(cp) {
13808
13952
  if (cp === CODE_POINTS.SOLIDUS) this.state = State.RCDATA_END_TAG_OPEN;
13809
13953
  else {
13810
- this._emitChars("<");
13954
+ this._emitChars("<", -1);
13811
13955
  this.state = State.RCDATA;
13812
13956
  this._stateRcdata(cp);
13813
13957
  }
@@ -13817,7 +13961,7 @@ var Tokenizer = class {
13817
13961
  this.state = State.RCDATA_END_TAG_NAME;
13818
13962
  this._stateRcdataEndTagName(cp);
13819
13963
  } else {
13820
- this._emitChars("</");
13964
+ this._emitChars("</", -1);
13821
13965
  this.state = State.RCDATA;
13822
13966
  this._stateRcdata(cp);
13823
13967
  }
@@ -13844,12 +13988,14 @@ var Tokenizer = class {
13844
13988
  this.emitCurrentTagToken();
13845
13989
  this.state = State.DATA;
13846
13990
  return false;
13847
- default: return !this._ensureHibernation();
13991
+ default:
13992
+ this.currentToken = null;
13993
+ return !this._ensureHibernation();
13848
13994
  }
13849
13995
  }
13850
13996
  _stateRcdataEndTagName(cp) {
13851
13997
  if (this.handleSpecialEndTag(cp)) {
13852
- this._emitChars("</");
13998
+ this._emitChars("</", -1);
13853
13999
  this.state = State.RCDATA;
13854
14000
  this._stateRcdata(cp);
13855
14001
  }
@@ -13857,7 +14003,7 @@ var Tokenizer = class {
13857
14003
  _stateRawtextLessThanSign(cp) {
13858
14004
  if (cp === CODE_POINTS.SOLIDUS) this.state = State.RAWTEXT_END_TAG_OPEN;
13859
14005
  else {
13860
- this._emitChars("<");
14006
+ this._emitChars("<", -1);
13861
14007
  this.state = State.RAWTEXT;
13862
14008
  this._stateRawtext(cp);
13863
14009
  }
@@ -13867,14 +14013,14 @@ var Tokenizer = class {
13867
14013
  this.state = State.RAWTEXT_END_TAG_NAME;
13868
14014
  this._stateRawtextEndTagName(cp);
13869
14015
  } else {
13870
- this._emitChars("</");
14016
+ this._emitChars("</", -1);
13871
14017
  this.state = State.RAWTEXT;
13872
14018
  this._stateRawtext(cp);
13873
14019
  }
13874
14020
  }
13875
14021
  _stateRawtextEndTagName(cp) {
13876
14022
  if (this.handleSpecialEndTag(cp)) {
13877
- this._emitChars("</");
14023
+ this._emitChars("</", -1);
13878
14024
  this.state = State.RAWTEXT;
13879
14025
  this._stateRawtext(cp);
13880
14026
  }
@@ -13889,7 +14035,7 @@ var Tokenizer = class {
13889
14035
  this._emitChars("<!");
13890
14036
  break;
13891
14037
  default:
13892
- this._emitChars("<");
14038
+ this._emitChars("<", -1);
13893
14039
  this.state = State.SCRIPT_DATA;
13894
14040
  this._stateScriptData(cp);
13895
14041
  }
@@ -13899,14 +14045,14 @@ var Tokenizer = class {
13899
14045
  this.state = State.SCRIPT_DATA_END_TAG_NAME;
13900
14046
  this._stateScriptDataEndTagName(cp);
13901
14047
  } else {
13902
- this._emitChars("</");
14048
+ this._emitChars("</", -1);
13903
14049
  this.state = State.SCRIPT_DATA;
13904
14050
  this._stateScriptData(cp);
13905
14051
  }
13906
14052
  }
13907
14053
  _stateScriptDataEndTagName(cp) {
13908
14054
  if (this.handleSpecialEndTag(cp)) {
13909
- this._emitChars("</");
14055
+ this._emitChars("</", -1);
13910
14056
  this.state = State.SCRIPT_DATA;
13911
14057
  this._stateScriptData(cp);
13912
14058
  }
@@ -14001,11 +14147,11 @@ var Tokenizer = class {
14001
14147
  _stateScriptDataEscapedLessThanSign(cp) {
14002
14148
  if (cp === CODE_POINTS.SOLIDUS) this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
14003
14149
  else if (isAsciiLetter(cp)) {
14004
- this._emitChars("<");
14150
+ this._emitChars("<", -1);
14005
14151
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
14006
14152
  this._stateScriptDataDoubleEscapeStart(cp);
14007
14153
  } else {
14008
- this._emitChars("<");
14154
+ this._emitChars("<", -1);
14009
14155
  this.state = State.SCRIPT_DATA_ESCAPED;
14010
14156
  this._stateScriptDataEscaped(cp);
14011
14157
  }
@@ -14015,14 +14161,14 @@ var Tokenizer = class {
14015
14161
  this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
14016
14162
  this._stateScriptDataEscapedEndTagName(cp);
14017
14163
  } else {
14018
- this._emitChars("</");
14164
+ this._emitChars("</", -1);
14019
14165
  this.state = State.SCRIPT_DATA_ESCAPED;
14020
14166
  this._stateScriptDataEscaped(cp);
14021
14167
  }
14022
14168
  }
14023
14169
  _stateScriptDataEscapedEndTagName(cp) {
14024
14170
  if (this.handleSpecialEndTag(cp)) {
14025
- this._emitChars("</");
14171
+ this._emitChars("</", -1);
14026
14172
  this.state = State.SCRIPT_DATA_ESCAPED;
14027
14173
  this._stateScriptDataEscaped(cp);
14028
14174
  }
@@ -14239,13 +14385,13 @@ var Tokenizer = class {
14239
14385
  break;
14240
14386
  case CODE_POINTS.NULL:
14241
14387
  this._err(ERR.unexpectedNullCharacter);
14242
- this.currentAttr.value += "�";
14388
+ this._extendRunWith("�", 0);
14243
14389
  break;
14244
14390
  case CODE_POINTS.EOF:
14245
14391
  this._err(ERR.eofInTag);
14246
14392
  this._emitEOFToken();
14247
14393
  break;
14248
- default: this.currentAttr.value += String.fromCodePoint(cp);
14394
+ default: this._extendRun(cp);
14249
14395
  }
14250
14396
  }
14251
14397
  _stateAttributeValueSingleQuoted(cp) {
@@ -14258,13 +14404,13 @@ var Tokenizer = class {
14258
14404
  break;
14259
14405
  case CODE_POINTS.NULL:
14260
14406
  this._err(ERR.unexpectedNullCharacter);
14261
- this.currentAttr.value += "�";
14407
+ this._extendRunWith("�", 0);
14262
14408
  break;
14263
14409
  case CODE_POINTS.EOF:
14264
14410
  this._err(ERR.eofInTag);
14265
14411
  this._emitEOFToken();
14266
14412
  break;
14267
- default: this.currentAttr.value += String.fromCodePoint(cp);
14413
+ default: this._extendRun(cp);
14268
14414
  }
14269
14415
  }
14270
14416
  _stateAttributeValueUnquoted(cp) {
@@ -14286,7 +14432,7 @@ var Tokenizer = class {
14286
14432
  break;
14287
14433
  case CODE_POINTS.NULL:
14288
14434
  this._err(ERR.unexpectedNullCharacter);
14289
- this.currentAttr.value += "�";
14435
+ this._extendRunWith("�", 0);
14290
14436
  break;
14291
14437
  case CODE_POINTS.QUOTATION_MARK:
14292
14438
  case CODE_POINTS.APOSTROPHE:
@@ -14294,13 +14440,13 @@ var Tokenizer = class {
14294
14440
  case CODE_POINTS.EQUALS_SIGN:
14295
14441
  case CODE_POINTS.GRAVE_ACCENT:
14296
14442
  this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);
14297
- this.currentAttr.value += String.fromCodePoint(cp);
14443
+ this._extendRun(cp);
14298
14444
  break;
14299
14445
  case CODE_POINTS.EOF:
14300
14446
  this._err(ERR.eofInTag);
14301
14447
  this._emitEOFToken();
14302
14448
  break;
14303
- default: this.currentAttr.value += String.fromCodePoint(cp);
14449
+ default: this._extendRun(cp);
14304
14450
  }
14305
14451
  }
14306
14452
  _stateAfterAttributeValueQuoted(cp) {
@@ -14327,6 +14473,7 @@ var Tokenizer = class {
14327
14473
  break;
14328
14474
  default:
14329
14475
  this._err(ERR.missingWhitespaceBetweenAttributes);
14476
+ this._leaveAttrValue();
14330
14477
  this.state = State.BEFORE_ATTRIBUTE_NAME;
14331
14478
  this._stateBeforeAttributeName(cp);
14332
14479
  }
@@ -14363,9 +14510,9 @@ var Tokenizer = class {
14363
14510
  break;
14364
14511
  case CODE_POINTS.NULL:
14365
14512
  this._err(ERR.unexpectedNullCharacter);
14366
- token.data += "�";
14513
+ this._extendRunWith("�", 0);
14367
14514
  break;
14368
- default: token.data += String.fromCodePoint(cp);
14515
+ default: this._extendRun(cp);
14369
14516
  }
14370
14517
  }
14371
14518
  _stateMarkupDeclarationOpen(cp) {
@@ -14424,7 +14571,7 @@ var Tokenizer = class {
14424
14571
  this._emitEOFToken();
14425
14572
  break;
14426
14573
  default:
14427
- token.data += "-";
14574
+ this._extendRunWith("-", -1);
14428
14575
  this.state = State.COMMENT;
14429
14576
  this._stateComment(cp);
14430
14577
  }
@@ -14436,30 +14583,29 @@ var Tokenizer = class {
14436
14583
  this.state = State.COMMENT_END_DASH;
14437
14584
  break;
14438
14585
  case CODE_POINTS.LESS_THAN_SIGN:
14439
- token.data += "<";
14586
+ this._extendRunWith("<", 0);
14440
14587
  this.state = State.COMMENT_LESS_THAN_SIGN;
14441
14588
  break;
14442
14589
  case CODE_POINTS.NULL:
14443
14590
  this._err(ERR.unexpectedNullCharacter);
14444
- token.data += "�";
14591
+ this._extendRunWith("�", 0);
14445
14592
  break;
14446
14593
  case CODE_POINTS.EOF:
14447
14594
  this._err(ERR.eofInComment);
14448
14595
  this.emitCurrentComment(token);
14449
14596
  this._emitEOFToken();
14450
14597
  break;
14451
- default: token.data += String.fromCodePoint(cp);
14598
+ default: this._extendRun(cp);
14452
14599
  }
14453
14600
  }
14454
14601
  _stateCommentLessThanSign(cp) {
14455
- const token = this.currentToken;
14456
14602
  switch (cp) {
14457
14603
  case CODE_POINTS.EXCLAMATION_MARK:
14458
- token.data += "!";
14604
+ this._extendRunWith("!", 0);
14459
14605
  this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
14460
14606
  break;
14461
14607
  case CODE_POINTS.LESS_THAN_SIGN:
14462
- token.data += "<";
14608
+ this._extendRunWith("<", 0);
14463
14609
  break;
14464
14610
  default:
14465
14611
  this.state = State.COMMENT;
@@ -14497,7 +14643,7 @@ var Tokenizer = class {
14497
14643
  this._emitEOFToken();
14498
14644
  break;
14499
14645
  default:
14500
- token.data += "-";
14646
+ this._extendRunWith("-", -1);
14501
14647
  this.state = State.COMMENT;
14502
14648
  this._stateComment(cp);
14503
14649
  }
@@ -14513,7 +14659,7 @@ var Tokenizer = class {
14513
14659
  this.state = State.COMMENT_END_BANG;
14514
14660
  break;
14515
14661
  case CODE_POINTS.HYPHEN_MINUS:
14516
- token.data += "-";
14662
+ this._extendRunWith("-", -2);
14517
14663
  break;
14518
14664
  case CODE_POINTS.EOF:
14519
14665
  this._err(ERR.eofInComment);
@@ -14521,7 +14667,7 @@ var Tokenizer = class {
14521
14667
  this._emitEOFToken();
14522
14668
  break;
14523
14669
  default:
14524
- token.data += "--";
14670
+ this._extendRunWith("--", -1);
14525
14671
  this.state = State.COMMENT;
14526
14672
  this._stateComment(cp);
14527
14673
  }
@@ -14530,7 +14676,7 @@ var Tokenizer = class {
14530
14676
  const token = this.currentToken;
14531
14677
  switch (cp) {
14532
14678
  case CODE_POINTS.HYPHEN_MINUS:
14533
- token.data += "--!";
14679
+ this._extendRunWith("--!", -1);
14534
14680
  this.state = State.COMMENT_END_DASH;
14535
14681
  break;
14536
14682
  case CODE_POINTS.GREATER_THAN_SIGN:
@@ -14544,7 +14690,7 @@ var Tokenizer = class {
14544
14690
  this._emitEOFToken();
14545
14691
  break;
14546
14692
  default:
14547
- token.data += "--!";
14693
+ this._extendRunWith("--!", -1);
14548
14694
  this.state = State.COMMENT;
14549
14695
  this._stateComment(cp);
14550
14696
  }
@@ -15031,7 +15177,7 @@ var Tokenizer = class {
15031
15177
  _stateCdataSectionBracket(cp) {
15032
15178
  if (cp === CODE_POINTS.RIGHT_SQUARE_BRACKET) this.state = State.CDATA_SECTION_END;
15033
15179
  else {
15034
- this._emitChars("]");
15180
+ this._emitChars("]", -1);
15035
15181
  this.state = State.CDATA_SECTION;
15036
15182
  this._stateCdataSection(cp);
15037
15183
  }
@@ -15042,10 +15188,10 @@ var Tokenizer = class {
15042
15188
  this.state = State.DATA;
15043
15189
  break;
15044
15190
  case CODE_POINTS.RIGHT_SQUARE_BRACKET:
15045
- this._emitChars("]");
15191
+ this._emitChars("]", -2);
15046
15192
  break;
15047
15193
  default:
15048
- this._emitChars("]]");
15194
+ this._emitChars("]]", -1);
15049
15195
  this.state = State.CDATA_SECTION;
15050
15196
  this._stateCdataSection(cp);
15051
15197
  }
@@ -15101,54 +15247,112 @@ const IMPLICIT_END_TAG_REQUIRED_THOROUGHLY = /* @__PURE__ */ new Set([
15101
15247
  TAG_ID.THEAD,
15102
15248
  TAG_ID.TR
15103
15249
  ]);
15104
- const SCOPING_ELEMENTS_HTML = /* @__PURE__ */ new Set([
15105
- TAG_ID.APPLET,
15106
- TAG_ID.CAPTION,
15107
- TAG_ID.HTML,
15108
- TAG_ID.MARQUEE,
15109
- TAG_ID.OBJECT,
15110
- TAG_ID.TABLE,
15111
- TAG_ID.TD,
15112
- TAG_ID.TEMPLATE,
15113
- TAG_ID.TH
15114
- ]);
15115
- const SCOPING_ELEMENTS_HTML_LIST = /* @__PURE__ */ new Set([
15116
- ...SCOPING_ELEMENTS_HTML,
15117
- TAG_ID.OL,
15118
- TAG_ID.UL
15119
- ]);
15120
- const SCOPING_ELEMENTS_HTML_BUTTON = /* @__PURE__ */ new Set([...SCOPING_ELEMENTS_HTML, TAG_ID.BUTTON]);
15121
- const SCOPING_ELEMENTS_MATHML = /* @__PURE__ */ new Set([
15122
- TAG_ID.ANNOTATION_XML,
15123
- TAG_ID.MI,
15124
- TAG_ID.MN,
15125
- TAG_ID.MO,
15126
- TAG_ID.MS,
15127
- TAG_ID.MTEXT
15128
- ]);
15129
- const SCOPING_ELEMENTS_SVG = /* @__PURE__ */ new Set([
15130
- TAG_ID.DESC,
15131
- TAG_ID.FOREIGN_OBJECT,
15132
- TAG_ID.TITLE
15133
- ]);
15134
- const TABLE_ROW_CONTEXT = /* @__PURE__ */ new Set([
15250
+ /** A stack this deep starts to index its elements; a shallower one is cheaper to scan than to index. */
15251
+ const INDEX_DEPTH = 64;
15252
+ const SVG_KEYS = 256;
15253
+ const MATHML_KEYS = 512;
15254
+ const NAME_KEYS = 768;
15255
+ const NUMBERED_HEADERS = [
15256
+ TAG_ID.H1,
15257
+ TAG_ID.H2,
15258
+ TAG_ID.H3,
15259
+ TAG_ID.H4,
15260
+ TAG_ID.H5,
15261
+ TAG_ID.H6
15262
+ ];
15263
+ const TABLE_BODIES = [
15264
+ TAG_ID.TBODY,
15265
+ TAG_ID.TFOOT,
15266
+ TAG_ID.THEAD
15267
+ ];
15268
+ const TABLE_ROW_CONTEXT = [
15135
15269
  TAG_ID.TR,
15136
15270
  TAG_ID.TEMPLATE,
15137
15271
  TAG_ID.HTML
15138
- ]);
15139
- const TABLE_BODY_CONTEXT = /* @__PURE__ */ new Set([
15140
- TAG_ID.TBODY,
15141
- TAG_ID.TFOOT,
15142
- TAG_ID.THEAD,
15272
+ ];
15273
+ const TABLE_BODY_CONTEXT = [
15274
+ ...TABLE_BODIES,
15143
15275
  TAG_ID.TEMPLATE,
15144
15276
  TAG_ID.HTML
15145
- ]);
15146
- const TABLE_CONTEXT = /* @__PURE__ */ new Set([
15277
+ ];
15278
+ const TABLE_CONTEXT = [
15147
15279
  TAG_ID.TABLE,
15148
15280
  TAG_ID.TEMPLATE,
15149
15281
  TAG_ID.HTML
15150
- ]);
15151
- const TABLE_CELLS = /* @__PURE__ */ new Set([TAG_ID.TD, TAG_ID.TH]);
15282
+ ];
15283
+ const TABLE_CELLS = [TAG_ID.TD, TAG_ID.TH];
15284
+ const SPECIAL = 1;
15285
+ const LIST_ITEM_BOUNDARY = 2;
15286
+ const SCOPE = 4;
15287
+ const LIST_ITEM_SCOPE = 8;
15288
+ const BUTTON_SCOPE = 16;
15289
+ const TABLE_SCOPE = 32;
15290
+ const KEY_CLASSES = new Uint8Array(NAME_KEYS);
15291
+ for (const [ns, offset] of [
15292
+ [NS.HTML, 0],
15293
+ [NS.SVG, SVG_KEYS],
15294
+ [NS.MATHML, MATHML_KEYS]
15295
+ ]) for (const tn of SPECIAL_ELEMENTS[ns]) KEY_CLASSES[offset + tn] = ns === NS.HTML && (tn === TAG_ID.ADDRESS || tn === TAG_ID.DIV || tn === TAG_ID.P) ? SPECIAL : 3;
15296
+ for (const key of [
15297
+ TAG_ID.APPLET,
15298
+ TAG_ID.CAPTION,
15299
+ TAG_ID.HTML,
15300
+ TAG_ID.MARQUEE,
15301
+ TAG_ID.OBJECT,
15302
+ TAG_ID.TABLE,
15303
+ TAG_ID.TD,
15304
+ TAG_ID.TEMPLATE,
15305
+ TAG_ID.TH,
15306
+ SVG_KEYS + TAG_ID.DESC,
15307
+ SVG_KEYS + TAG_ID.FOREIGN_OBJECT,
15308
+ SVG_KEYS + TAG_ID.TITLE,
15309
+ MATHML_KEYS + TAG_ID.ANNOTATION_XML,
15310
+ MATHML_KEYS + TAG_ID.MI,
15311
+ MATHML_KEYS + TAG_ID.MN,
15312
+ MATHML_KEYS + TAG_ID.MO,
15313
+ MATHML_KEYS + TAG_ID.MS,
15314
+ MATHML_KEYS + TAG_ID.MTEXT
15315
+ ]) KEY_CLASSES[key] |= 28;
15316
+ KEY_CLASSES[TAG_ID.OL] |= LIST_ITEM_SCOPE;
15317
+ KEY_CLASSES[TAG_ID.UL] |= LIST_ITEM_SCOPE;
15318
+ KEY_CLASSES[TAG_ID.BUTTON] |= BUTTON_SCOPE;
15319
+ KEY_CLASSES[TAG_ID.TABLE] |= TABLE_SCOPE;
15320
+ KEY_CLASSES[TAG_ID.HTML] |= TABLE_SCOPE;
15321
+ const FORMATTING_TAGS = new Uint8Array(NAME_KEYS);
15322
+ for (const tn of [
15323
+ TAG_ID.A,
15324
+ TAG_ID.B,
15325
+ TAG_ID.BIG,
15326
+ TAG_ID.CODE,
15327
+ TAG_ID.EM,
15328
+ TAG_ID.FONT,
15329
+ TAG_ID.I,
15330
+ TAG_ID.NOBR,
15331
+ TAG_ID.S,
15332
+ TAG_ID.SMALL,
15333
+ TAG_ID.STRIKE,
15334
+ TAG_ID.STRONG,
15335
+ TAG_ID.TT,
15336
+ TAG_ID.U
15337
+ ]) FORMATTING_TAGS[tn] = 1;
15338
+ /** The key of an element with a tag ID in HTML, SVG or MathML, or -1 for an element keyed by its name. */
15339
+ function tagKey(ns, tagID) {
15340
+ if (tagID === TAG_ID.UNKNOWN) return -1;
15341
+ switch (ns) {
15342
+ case NS.HTML: return tagID;
15343
+ case NS.SVG: return SVG_KEYS + tagID;
15344
+ case NS.MATHML: return MATHML_KEYS + tagID;
15345
+ default: return -1;
15346
+ }
15347
+ }
15348
+ /**
15349
+ * The stack of open elements. Each element has a slot in `items` and `tagIDs`. Once the stack is `INDEX_DEPTH` deep, it
15350
+ * indexes its elements so that the searches the parser repeats per token take constant time: it chains the elements
15351
+ * with each key, so that the topmost one is found without a scan, and counts per slot the special elements and scope
15352
+ * boundaries at or below it, which tell whether one lies between two slots. Removing an element from the middle then
15353
+ * leaves its slot free instead of moving the elements above it; `slotBelow` and `slotAbove` step over free slots, and
15354
+ * `depth` counts the open elements.
15355
+ */
15152
15356
  var OpenElementStack = class {
15153
15357
  get currentTmplContentOrNode() {
15154
15358
  return this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : this.current;
@@ -15158,14 +15362,49 @@ var OpenElementStack = class {
15158
15362
  this.handler = handler;
15159
15363
  this.items = [];
15160
15364
  this.tagIDs = [];
15365
+ /** The slot of the current element. */
15161
15366
  this.stackTop = -1;
15367
+ /** The number of open elements. */
15368
+ this.depth = 0;
15162
15369
  this.tmplCount = 0;
15163
15370
  this.currentTagId = TAG_ID.UNKNOWN;
15371
+ this.indexed = false;
15372
+ /** The slot of the open element below, and above, each open element's slot; -1 for none. */
15373
+ this.below = [];
15374
+ this.above = [];
15375
+ this.keys = [];
15376
+ /** The slot of the next lower, and higher, open element with the same key; -1 for none. */
15377
+ this.keyPrev = [];
15378
+ this.keyNext = [];
15379
+ /** The slot of the topmost open element with each key, -1 for none. */
15380
+ this.keyTops = /* @__PURE__ */ new Int32Array(0);
15381
+ /** Per slot, the open special elements, list item boundaries and scope boundaries at or below it. */
15382
+ this.specials = [];
15383
+ this.listItemBoundaries = [];
15384
+ this.scopeBoundaries = [];
15385
+ /** Per slot, the slot of the topmost open HTML element at or below it, or -1. */
15386
+ this.htmlSlots = [];
15387
+ this.formattingSlots = /* @__PURE__ */ new Map();
15164
15388
  this.current = document;
15165
15389
  }
15390
+ /** The slot of an open element, or -1. */
15166
15391
  _indexOf(element) {
15392
+ if (this.indexed) {
15393
+ const idx = this.formattingSlots.get(element);
15394
+ if (idx !== void 0) return idx;
15395
+ if (FORMATTING_TAGS[getTagID(this.treeAdapter.getTagName(element))]) return -1;
15396
+ }
15167
15397
  return this.items.lastIndexOf(element, this.stackTop);
15168
15398
  }
15399
+ /** The slot of the open element below the one at `idx`, or -1. */
15400
+ slotBelow(idx) {
15401
+ return this.indexed ? this.below[idx] : idx - 1;
15402
+ }
15403
+ /** The slot of the open element above the one at `idx`, or -1. */
15404
+ slotAbove(idx) {
15405
+ if (this.indexed) return this.above[idx];
15406
+ return idx === this.stackTop ? -1 : idx + 1;
15407
+ }
15169
15408
  _isInTemplate() {
15170
15409
  return this.currentTagId === TAG_ID.TEMPLATE && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML;
15171
15410
  }
@@ -15173,48 +15412,243 @@ var OpenElementStack = class {
15173
15412
  this.current = this.items[this.stackTop];
15174
15413
  this.currentTagId = this.tagIDs[this.stackTop];
15175
15414
  }
15415
+ _nameKey(ns, tagName, create) {
15416
+ var _a, _b;
15417
+ const name = `${ns} ${tagName}`;
15418
+ let key = (_a = this.nameKeys) === null || _a === void 0 ? void 0 : _a.get(name);
15419
+ if (key === void 0 && create) {
15420
+ (_b = this.nameKeys) !== null && _b !== void 0 || (this.nameKeys = /* @__PURE__ */ new Map());
15421
+ key = NAME_KEYS + this.nameKeys.size;
15422
+ this.nameKeys.set(name, key);
15423
+ if (key === this.keyTops.length) {
15424
+ const keyTops = new Int32Array(2 * key).fill(-1);
15425
+ keyTops.set(this.keyTops);
15426
+ this.keyTops = keyTops;
15427
+ }
15428
+ }
15429
+ return key !== null && key !== void 0 ? key : -1;
15430
+ }
15431
+ /** Indexes the open elements once the stack is `INDEX_DEPTH` deep. */
15432
+ _indexAll() {
15433
+ this.indexed = true;
15434
+ this.keyTops = new Int32Array(NAME_KEYS).fill(-1);
15435
+ for (let i = 0; i <= this.stackTop; i++) this._index(i, i - 1);
15436
+ }
15437
+ /** Indexes the element at `slot`, above the open element at `belowIdx`. */
15438
+ _index(slot, belowIdx) {
15439
+ const element = this.items[slot];
15440
+ const tagID = this.tagIDs[slot];
15441
+ const ns = this.treeAdapter.getNamespaceURI(element);
15442
+ let key = tagKey(ns, tagID);
15443
+ if (key === -1) key = this._nameKey(ns, this.treeAdapter.getTagName(element), true);
15444
+ const keyPrev = this.keyTops[key];
15445
+ this.keys[slot] = key;
15446
+ this.keyPrev[slot] = keyPrev;
15447
+ this.keyNext[slot] = -1;
15448
+ if (keyPrev !== -1) this.keyNext[keyPrev] = slot;
15449
+ this.keyTops[key] = slot;
15450
+ this.above[slot] = -1;
15451
+ this._link(slot, belowIdx, ns === NS.HTML);
15452
+ if (FORMATTING_TAGS[tagID]) this.formattingSlots.set(element, slot);
15453
+ }
15454
+ /** Puts the indexed element at `slot` above the one at `belowIdx`, and counts the elements of each class. */
15455
+ _link(slot, belowIdx, isHtml) {
15456
+ const key = this.keys[slot];
15457
+ const classes = key < NAME_KEYS ? KEY_CLASSES[key] : 0;
15458
+ this.below[slot] = belowIdx;
15459
+ if (belowIdx === -1) {
15460
+ this.specials[slot] = classes & SPECIAL;
15461
+ this.listItemBoundaries[slot] = (classes & LIST_ITEM_BOUNDARY) >> 1;
15462
+ this.scopeBoundaries[slot] = (classes & SCOPE) >> 2;
15463
+ this.htmlSlots[slot] = isHtml ? slot : -1;
15464
+ } else {
15465
+ this.above[belowIdx] = slot;
15466
+ this.specials[slot] = this.specials[belowIdx] + (classes & SPECIAL);
15467
+ this.listItemBoundaries[slot] = this.listItemBoundaries[belowIdx] + ((classes & LIST_ITEM_BOUNDARY) >> 1);
15468
+ this.scopeBoundaries[slot] = this.scopeBoundaries[belowIdx] + ((classes & SCOPE) >> 2);
15469
+ this.htmlSlots[slot] = isHtml ? slot : this.htmlSlots[belowIdx];
15470
+ }
15471
+ }
15472
+ /** Takes the element at `slot` out of the index, except for the links between slots. */
15473
+ _unindex(slot) {
15474
+ const key = this.keys[slot];
15475
+ const keyPrev = this.keyPrev[slot];
15476
+ const keyNext = this.keyNext[slot];
15477
+ if (keyPrev !== -1) this.keyNext[keyPrev] = keyNext;
15478
+ if (keyNext === -1) this.keyTops[key] = keyPrev;
15479
+ else this.keyPrev[keyNext] = keyPrev;
15480
+ if (FORMATTING_TAGS[this.tagIDs[slot]]) this.formattingSlots.delete(this.items[slot]);
15481
+ }
15482
+ /** Moves the indexed element at `from` down to the free slot `to`, keeping its key chain in order. */
15483
+ _move(from, to) {
15484
+ const element = this.items[from];
15485
+ const key = this.keys[from];
15486
+ const keyPrev = this.keyPrev[from];
15487
+ const keyNext = this.keyNext[from];
15488
+ this.items[to] = element;
15489
+ this.tagIDs[to] = this.tagIDs[from];
15490
+ this.keys[to] = key;
15491
+ this.keyPrev[to] = keyPrev;
15492
+ this.keyNext[to] = keyNext;
15493
+ if (keyPrev !== -1) this.keyNext[keyPrev] = to;
15494
+ if (keyNext === -1) this.keyTops[key] = to;
15495
+ else this.keyPrev[keyNext] = to;
15496
+ if (FORMATTING_TAGS[this.tagIDs[to]]) this.formattingSlots.set(element, to);
15497
+ }
15498
+ /** The slot of the topmost open HTML element with this tag, or -1. */
15499
+ indexOfTopmost(tagID) {
15500
+ if (this.indexed) return this.keyTops[tagID];
15501
+ for (let i = this.stackTop; i >= 0; i--) if (this.tagIDs[i] === tagID && this.treeAdapter.getNamespaceURI(this.items[i]) === NS.HTML) return i;
15502
+ return -1;
15503
+ }
15504
+ /** The slot of the topmost open HTML element with any of these tags, or -1. */
15505
+ indexOfTopmostOf(tagIDs) {
15506
+ if (this.indexed) {
15507
+ let top = -1;
15508
+ for (const tagID of tagIDs) if (this.keyTops[tagID] > top) top = this.keyTops[tagID];
15509
+ return top;
15510
+ }
15511
+ for (let i = this.stackTop; i >= 0; i--) if (tagIDs.includes(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === NS.HTML) return i;
15512
+ return -1;
15513
+ }
15514
+ /** The slot of the topmost open element in this namespace with this tag name, or -1. */
15515
+ indexOfTopmostByName(ns, tagName) {
15516
+ if (this.indexed) {
15517
+ let key = tagKey(ns, getTagID(tagName));
15518
+ if (key === -1) key = this._nameKey(ns, tagName, false);
15519
+ return key === -1 ? -1 : this.keyTops[key];
15520
+ }
15521
+ for (let i = this.stackTop; i >= 0; i--) {
15522
+ const element = this.items[i];
15523
+ if (this.treeAdapter.getTagName(element) === tagName && this.treeAdapter.getNamespaceURI(element) === ns) return i;
15524
+ }
15525
+ return -1;
15526
+ }
15527
+ /** The slot of the topmost open HTML element, or -1. */
15528
+ indexOfTopmostHtmlElement() {
15529
+ if (this.indexed) return this.stackTop === -1 ? -1 : this.htmlSlots[this.stackTop];
15530
+ let i = this.stackTop;
15531
+ while (i >= 0 && this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) i--;
15532
+ return i;
15533
+ }
15534
+ /** Whether an element of the classes is open above the slot `idx`, on a stack that is not indexed. */
15535
+ _hasAbove(idx, classes) {
15536
+ for (let i = this.stackTop; i > idx; i--) {
15537
+ const key = tagKey(this.treeAdapter.getNamespaceURI(this.items[i]), this.tagIDs[i]);
15538
+ if (key !== -1 && KEY_CLASSES[key] & classes) return true;
15539
+ }
15540
+ return false;
15541
+ }
15542
+ /** Whether a special element is open above the slot `idx`. */
15543
+ hasSpecialElementAbove(idx) {
15544
+ return this.indexed ? this.specials[this.stackTop] !== this.specials[idx] : this._hasAbove(idx, SPECIAL);
15545
+ }
15546
+ /** Whether a special element other than HTML `address`, `div` and `p` is open above the slot `idx`. */
15547
+ hasListItemBoundaryAbove(idx) {
15548
+ return this.indexed ? this.listItemBoundaries[this.stackTop] !== this.listItemBoundaries[idx] : this._hasAbove(idx, LIST_ITEM_BOUNDARY);
15549
+ }
15176
15550
  push(element, tagID) {
15551
+ const belowIdx = this.stackTop;
15177
15552
  this.stackTop++;
15553
+ this.depth++;
15178
15554
  this.items[this.stackTop] = element;
15179
15555
  this.current = element;
15180
15556
  this.tagIDs[this.stackTop] = tagID;
15181
15557
  this.currentTagId = tagID;
15558
+ if (this.indexed) this._index(this.stackTop, belowIdx);
15559
+ else if (this.depth === INDEX_DEPTH) this._indexAll();
15182
15560
  if (this._isInTemplate()) this.tmplCount++;
15183
15561
  this.handler.onItemPush(element, tagID, true);
15184
15562
  }
15185
- pop() {
15186
- const popped = this.current;
15563
+ /** Pops the current element without calling the handler. */
15564
+ _popCurrent() {
15187
15565
  if (this.tmplCount > 0 && this._isInTemplate()) this.tmplCount--;
15188
- this.stackTop--;
15566
+ if (this.indexed) {
15567
+ this._unindex(this.stackTop);
15568
+ this.stackTop = this.below[this.stackTop];
15569
+ if (this.stackTop !== -1) this.above[this.stackTop] = -1;
15570
+ } else this.stackTop--;
15571
+ this.depth--;
15189
15572
  this._updateCurrentElement();
15573
+ }
15574
+ pop() {
15575
+ const popped = this.current;
15576
+ this._popCurrent();
15190
15577
  this.handler.onItemPop(popped, true);
15191
15578
  }
15192
15579
  replace(oldElement, newElement) {
15193
15580
  const idx = this._indexOf(oldElement);
15194
15581
  this.items[idx] = newElement;
15582
+ if (this.indexed && FORMATTING_TAGS[this.tagIDs[idx]]) {
15583
+ this.formattingSlots.delete(oldElement);
15584
+ this.formattingSlots.set(newElement, idx);
15585
+ }
15195
15586
  if (idx === this.stackTop) this.current = newElement;
15196
15587
  }
15197
- insertAfter(referenceElement, newElement, newElementID) {
15198
- const insertionIdx = this._indexOf(referenceElement) + 1;
15199
- this.items.splice(insertionIdx, 0, newElement);
15200
- this.tagIDs.splice(insertionIdx, 0, newElementID);
15201
- this.stackTop++;
15202
- if (insertionIdx === this.stackTop) this._updateCurrentElement();
15203
- if (this.current && this.currentTagId !== void 0) this.handler.onItemPush(this.current, this.currentTagId, insertionIdx === this.stackTop);
15588
+ /**
15589
+ * The adoption agency's last stack step: removes the formatting element at `formattingIdx` and opens `element`
15590
+ * directly above the furthest block at `furthestBlockIdx`. On an indexed stack, only formatting elements the agency
15591
+ * kept are still open between them; the furthest block, with those directly below it, moves down by one slot, and
15592
+ * `element` takes the furthest block's slot. No open element above the furthest block moves, and as all these
15593
+ * elements are HTML elements and only the furthest block is special, the counts above it stay the same.
15594
+ */
15595
+ replaceFormattingElement(formattingIdx, furthestBlockIdx, element, tagID) {
15596
+ const formattingElement = this.items[formattingIdx];
15597
+ if (!this.indexed) {
15598
+ this.items.splice(formattingIdx, 1);
15599
+ this.tagIDs.splice(formattingIdx, 1);
15600
+ this.handler.onItemPop(formattingElement, false);
15601
+ this.items.splice(furthestBlockIdx, 0, element);
15602
+ this.tagIDs.splice(furthestBlockIdx, 0, tagID);
15603
+ if (furthestBlockIdx === this.stackTop) this._updateCurrentElement();
15604
+ if (this.current && this.currentTagId !== void 0) this.handler.onItemPush(this.current, this.currentTagId, furthestBlockIdx === this.stackTop);
15605
+ return;
15606
+ }
15607
+ const key = this.keys[formattingIdx];
15608
+ const belowIdx = this.below[formattingIdx];
15609
+ const aboveIdx = this.above[furthestBlockIdx];
15610
+ const kept = [];
15611
+ for (let i = this.above[formattingIdx]; i !== furthestBlockIdx; i = this.above[i]) kept.push(i);
15612
+ const keyNext = this.keyNext[formattingIdx];
15613
+ this._unindex(formattingIdx);
15614
+ this.items[formattingIdx] = void 0;
15615
+ this.handler.onItemPop(formattingElement, false);
15616
+ let free = furthestBlockIdx - 1;
15617
+ while (kept.length > 0 && kept[kept.length - 1] === free) {
15618
+ kept.pop();
15619
+ free--;
15620
+ }
15621
+ for (let i = free + 1; i <= furthestBlockIdx; i++) this._move(i, i - 1);
15622
+ const keyPrev = keyNext === -1 ? this.keyTops[key] : this.keyPrev[keyNext];
15623
+ this.items[furthestBlockIdx] = element;
15624
+ this.tagIDs[furthestBlockIdx] = tagID;
15625
+ this.keys[furthestBlockIdx] = key;
15626
+ this.keyPrev[furthestBlockIdx] = keyPrev;
15627
+ this.keyNext[furthestBlockIdx] = keyNext;
15628
+ if (keyPrev !== -1) this.keyNext[keyPrev] = furthestBlockIdx;
15629
+ if (keyNext === -1) this.keyTops[key] = furthestBlockIdx;
15630
+ else this.keyPrev[keyNext] = furthestBlockIdx;
15631
+ if (FORMATTING_TAGS[tagID]) this.formattingSlots.set(element, furthestBlockIdx);
15632
+ let prev = belowIdx;
15633
+ for (const i of kept) {
15634
+ this._link(i, prev, true);
15635
+ prev = i;
15636
+ }
15637
+ for (let i = free; i < furthestBlockIdx; i++) {
15638
+ this._link(i, prev, true);
15639
+ prev = i;
15640
+ }
15641
+ this._link(furthestBlockIdx, prev, true);
15642
+ if (aboveIdx === -1) this._updateCurrentElement();
15643
+ if (this.current && this.currentTagId !== void 0) this.handler.onItemPush(this.current, this.currentTagId, aboveIdx === -1);
15204
15644
  }
15205
15645
  popUntilTagNamePopped(tagName) {
15206
- let targetIdx = this.stackTop + 1;
15207
- do
15208
- targetIdx = this.tagIDs.lastIndexOf(tagName, targetIdx - 1);
15209
- while (targetIdx > 0 && this.treeAdapter.getNamespaceURI(this.items[targetIdx]) !== NS.HTML);
15210
- this.shortenToLength(Math.max(targetIdx, 0));
15646
+ this.shortenToLength(Math.max(this.indexOfTopmost(tagName), 0));
15211
15647
  }
15212
15648
  shortenToLength(idx) {
15213
15649
  while (this.stackTop >= idx) {
15214
15650
  const popped = this.current;
15215
- if (this.tmplCount > 0 && this._isInTemplate()) this.tmplCount -= 1;
15216
- this.stackTop--;
15217
- this._updateCurrentElement();
15651
+ this._popCurrent();
15218
15652
  this.handler.onItemPop(popped, this.stackTop < idx);
15219
15653
  }
15220
15654
  }
@@ -15222,49 +15656,59 @@ var OpenElementStack = class {
15222
15656
  const idx = this._indexOf(element);
15223
15657
  this.shortenToLength(Math.max(idx, 0));
15224
15658
  }
15225
- popUntilPopped(tagNames, targetNS) {
15226
- const idx = this._indexOfTagNames(tagNames, targetNS);
15227
- this.shortenToLength(Math.max(idx, 0));
15228
- }
15229
15659
  popUntilNumberedHeaderPopped() {
15230
- this.popUntilPopped(NUMBERED_HEADERS, NS.HTML);
15660
+ this.shortenToLength(Math.max(this.indexOfTopmostOf(NUMBERED_HEADERS), 0));
15231
15661
  }
15232
15662
  popUntilTableCellPopped() {
15233
- this.popUntilPopped(TABLE_CELLS, NS.HTML);
15663
+ this.shortenToLength(Math.max(this.indexOfTopmostOf(TABLE_CELLS), 0));
15234
15664
  }
15235
15665
  popAllUpToHtmlElement() {
15236
15666
  this.tmplCount = 0;
15237
15667
  this.shortenToLength(1);
15238
15668
  }
15239
- _indexOfTagNames(tagNames, namespace) {
15240
- for (let i = this.stackTop; i >= 0; i--) if (tagNames.has(this.tagIDs[i]) && this.treeAdapter.getNamespaceURI(this.items[i]) === namespace) return i;
15241
- return -1;
15242
- }
15243
- clearBackTo(tagNames, targetNS) {
15244
- const idx = this._indexOfTagNames(tagNames, targetNS);
15245
- this.shortenToLength(idx + 1);
15246
- }
15247
15669
  clearBackToTableContext() {
15248
- this.clearBackTo(TABLE_CONTEXT, NS.HTML);
15670
+ this.shortenToLength(this.indexOfTopmostOf(TABLE_CONTEXT) + 1);
15249
15671
  }
15250
15672
  clearBackToTableBodyContext() {
15251
- this.clearBackTo(TABLE_BODY_CONTEXT, NS.HTML);
15673
+ this.shortenToLength(this.indexOfTopmostOf(TABLE_BODY_CONTEXT) + 1);
15252
15674
  }
15253
15675
  clearBackToTableRowContext() {
15254
- this.clearBackTo(TABLE_ROW_CONTEXT, NS.HTML);
15676
+ this.shortenToLength(this.indexOfTopmostOf(TABLE_ROW_CONTEXT) + 1);
15255
15677
  }
15256
15678
  remove(element) {
15257
15679
  const idx = this._indexOf(element);
15258
- if (idx >= 0) {
15259
- if (idx === this.stackTop) this.pop();
15260
- else {
15261
- this.items.splice(idx, 1);
15262
- this.tagIDs.splice(idx, 1);
15263
- this.stackTop--;
15264
- this._updateCurrentElement();
15265
- this.handler.onItemPop(element, false);
15680
+ if (idx !== -1) this.removeAt(idx);
15681
+ }
15682
+ /** Removes the open element at the slot `idx`; on an indexed stack, the elements above it keep their slots. */
15683
+ removeAt(idx) {
15684
+ if (idx === this.stackTop) {
15685
+ this.pop();
15686
+ return;
15687
+ }
15688
+ const element = this.items[idx];
15689
+ this.depth--;
15690
+ if (this.indexed) {
15691
+ const classes = this.keys[idx] < NAME_KEYS ? KEY_CLASSES[this.keys[idx]] : 0;
15692
+ const belowIdx = this.below[idx];
15693
+ const aboveIdx = this.above[idx];
15694
+ this._unindex(idx);
15695
+ this.items[idx] = void 0;
15696
+ this.below[aboveIdx] = belowIdx;
15697
+ if (belowIdx !== -1) this.above[belowIdx] = aboveIdx;
15698
+ if (classes !== 0) for (let i = aboveIdx; i !== -1; i = this.above[i]) {
15699
+ this.specials[i] -= classes & SPECIAL;
15700
+ this.listItemBoundaries[i] -= (classes & LIST_ITEM_BOUNDARY) >> 1;
15701
+ this.scopeBoundaries[i] -= (classes & SCOPE) >> 2;
15266
15702
  }
15703
+ const html = belowIdx === -1 ? -1 : this.htmlSlots[belowIdx];
15704
+ for (let i = aboveIdx; i !== -1 && this.htmlSlots[i] === idx; i = this.above[i]) this.htmlSlots[i] = html;
15705
+ } else {
15706
+ this.items.splice(idx, 1);
15707
+ this.tagIDs.splice(idx, 1);
15708
+ this.stackTop--;
15709
+ this._updateCurrentElement();
15267
15710
  }
15711
+ this.handler.onItemPop(element, false);
15268
15712
  }
15269
15713
  tryPeekProperlyNestedBodyElement() {
15270
15714
  return this.stackTop >= 1 && this.tagIDs[1] === TAG_ID.BODY ? this.items[1] : null;
@@ -15273,79 +15717,67 @@ var OpenElementStack = class {
15273
15717
  return this._indexOf(element) > -1;
15274
15718
  }
15275
15719
  getCommonAncestor(element) {
15276
- const elementIdx = this._indexOf(element) - 1;
15277
- return elementIdx >= 0 ? this.items[elementIdx] : null;
15720
+ const idx = this._indexOf(element);
15721
+ const belowIdx = idx === -1 ? -1 : this.slotBelow(idx);
15722
+ return belowIdx === -1 ? null : this.items[belowIdx];
15278
15723
  }
15279
15724
  isRootHtmlElementCurrent() {
15280
15725
  return this.stackTop === 0 && this.tagIDs[0] === TAG_ID.HTML;
15281
15726
  }
15282
- hasInDynamicScope(tagName, htmlScope) {
15727
+ /**
15728
+ * On an indexed stack: whether no element of the `scope` class is open above the slot `target`. A target that is not
15729
+ * open is in scope only on a stack without such an element, as a scan from the top would end there.
15730
+ */
15731
+ _isInScope(target, scope) {
15732
+ let boundary = -1;
15733
+ switch (scope) {
15734
+ case LIST_ITEM_SCOPE:
15735
+ boundary = Math.max(this.keyTops[TAG_ID.OL], this.keyTops[TAG_ID.UL]);
15736
+ break;
15737
+ case BUTTON_SCOPE:
15738
+ boundary = this.keyTops[TAG_ID.BUTTON];
15739
+ break;
15740
+ case TABLE_SCOPE:
15741
+ boundary = Math.max(this.keyTops[TAG_ID.TABLE], this.keyTops[TAG_ID.HTML]);
15742
+ return target === -1 ? boundary === -1 : target >= boundary;
15743
+ }
15744
+ return target === -1 ? boundary === -1 && (this.stackTop === -1 || this.scopeBoundaries[this.stackTop] === 0) : target >= boundary && this.scopeBoundaries[this.stackTop] === this.scopeBoundaries[target];
15745
+ }
15746
+ /**
15747
+ * On a stack that is not indexed: whether an HTML element with the tag, or one of the tags, and if passed the element
15748
+ * itself, is open above every element of the `scope` class; true if neither is open.
15749
+ */
15750
+ _scanScope(tagID, tagIDs, scope, element) {
15283
15751
  for (let i = this.stackTop; i >= 0; i--) {
15284
- const tn = this.tagIDs[i];
15285
- switch (this.treeAdapter.getNamespaceURI(this.items[i])) {
15286
- case NS.HTML:
15287
- if (tn === tagName) return true;
15288
- if (htmlScope.has(tn)) return false;
15289
- break;
15290
- case NS.SVG:
15291
- if (SCOPING_ELEMENTS_SVG.has(tn)) return false;
15292
- break;
15293
- case NS.MATHML: if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
15294
- }
15752
+ const key = tagKey(this.treeAdapter.getNamespaceURI(this.items[i]), this.tagIDs[i]);
15753
+ if (key === -1) continue;
15754
+ if ((tagIDs ? tagIDs.includes(key) : key === tagID) && (!element || this.items[i] === element)) return true;
15755
+ if (KEY_CLASSES[key] & scope) return false;
15295
15756
  }
15296
15757
  return true;
15297
15758
  }
15298
- hasInScope(tagName) {
15299
- return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML);
15759
+ /** If `element` is passed, only that element (which has to be a `tagName` element) is looked for. */
15760
+ hasInScope(tagName, element) {
15761
+ if (!this.indexed) return this._scanScope(tagName, null, SCOPE, element);
15762
+ return this._isInScope(element ? this._indexOf(element) : this.keyTops[tagName], SCOPE);
15300
15763
  }
15301
15764
  hasInListItemScope(tagName) {
15302
- return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML_LIST);
15765
+ return this.indexed ? this._isInScope(this.keyTops[tagName], LIST_ITEM_SCOPE) : this._scanScope(tagName, null, LIST_ITEM_SCOPE);
15303
15766
  }
15304
15767
  hasInButtonScope(tagName) {
15305
- return this.hasInDynamicScope(tagName, SCOPING_ELEMENTS_HTML_BUTTON);
15768
+ return this.indexed ? this._isInScope(this.keyTops[tagName], BUTTON_SCOPE) : this._scanScope(tagName, null, BUTTON_SCOPE);
15306
15769
  }
15307
15770
  hasNumberedHeaderInScope() {
15308
- for (let i = this.stackTop; i >= 0; i--) {
15309
- const tn = this.tagIDs[i];
15310
- switch (this.treeAdapter.getNamespaceURI(this.items[i])) {
15311
- case NS.HTML:
15312
- if (NUMBERED_HEADERS.has(tn)) return true;
15313
- if (SCOPING_ELEMENTS_HTML.has(tn)) return false;
15314
- break;
15315
- case NS.SVG:
15316
- if (SCOPING_ELEMENTS_SVG.has(tn)) return false;
15317
- break;
15318
- case NS.MATHML: if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
15319
- }
15320
- }
15321
- return true;
15771
+ return this.indexed ? this._isInScope(this.indexOfTopmostOf(NUMBERED_HEADERS), SCOPE) : this._scanScope(TAG_ID.UNKNOWN, NUMBERED_HEADERS, SCOPE);
15322
15772
  }
15323
15773
  hasInTableScope(tagName) {
15324
- for (let i = this.stackTop; i >= 0; i--) {
15325
- if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) continue;
15326
- switch (this.tagIDs[i]) {
15327
- case tagName: return true;
15328
- case TAG_ID.TABLE:
15329
- case TAG_ID.HTML: return false;
15330
- }
15331
- }
15332
- return true;
15774
+ return this.indexed ? this._isInScope(this.keyTops[tagName], TABLE_SCOPE) : this._scanScope(tagName, null, TABLE_SCOPE);
15333
15775
  }
15334
15776
  hasTableBodyContextInTableScope() {
15335
- for (let i = this.stackTop; i >= 0; i--) {
15336
- if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) continue;
15337
- switch (this.tagIDs[i]) {
15338
- case TAG_ID.TBODY:
15339
- case TAG_ID.THEAD:
15340
- case TAG_ID.TFOOT: return true;
15341
- case TAG_ID.TABLE:
15342
- case TAG_ID.HTML: return false;
15343
- }
15344
- }
15345
- return true;
15777
+ return this.indexed ? this._isInScope(this.indexOfTopmostOf(TABLE_BODIES), TABLE_SCOPE) : this._scanScope(TAG_ID.UNKNOWN, TABLE_BODIES, TABLE_SCOPE);
15346
15778
  }
15347
15779
  hasInSelectScope(tagName) {
15348
- for (let i = this.stackTop; i >= 0; i--) {
15780
+ for (let i = this.stackTop; i >= 0; i = this.slotBelow(i)) {
15349
15781
  if (this.treeAdapter.getNamespaceURI(this.items[i]) !== NS.HTML) continue;
15350
15782
  switch (this.tagIDs[i]) {
15351
15783
  case tagName: return true;
@@ -15357,13 +15789,13 @@ var OpenElementStack = class {
15357
15789
  return true;
15358
15790
  }
15359
15791
  generateImpliedEndTags() {
15360
- while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId)) this.pop();
15792
+ while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED.has(this.currentTagId) && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML) this.pop();
15361
15793
  }
15362
15794
  generateImpliedEndTagsThoroughly() {
15363
- while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) this.pop();
15795
+ while (this.currentTagId !== void 0 && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId) && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML) this.pop();
15364
15796
  }
15365
15797
  generateImpliedEndTagsWithExclusion(exclusionId) {
15366
- while (this.currentTagId !== void 0 && this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId)) this.pop();
15798
+ while (this.currentTagId !== void 0 && this.currentTagId !== exclusionId && IMPLICIT_END_TAG_REQUIRED_THOROUGHLY.has(this.currentTagId) && this.treeAdapter.getNamespaceURI(this.current) === NS.HTML) this.pop();
15367
15799
  }
15368
15800
  };
15369
15801
  // node_modules/parse5/dist/parser/formatting-element-list.js
@@ -15373,69 +15805,114 @@ var EntryType;
15373
15805
  EntryType[EntryType["Marker"] = 0] = "Marker";
15374
15806
  EntryType[EntryType["Element"] = 1] = "Element";
15375
15807
  })(EntryType || (EntryType = {}));
15376
- const MARKER = { type: EntryType.Marker };
15377
15808
  var FormattingElementList = class {
15378
- constructor(treeAdapter) {
15379
- this.treeAdapter = treeAdapter;
15380
- this.entries = [];
15809
+ constructor() {
15810
+ this.newest = null;
15381
15811
  this.bookmark = null;
15382
- }
15383
- _getNoahArkConditionCandidates(newElement, neAttrs) {
15384
- const candidates = [];
15385
- const neAttrsLength = neAttrs.length;
15386
- const neTagName = this.treeAdapter.getTagName(newElement);
15387
- const neNamespaceURI = this.treeAdapter.getNamespaceURI(newElement);
15388
- for (let i = 0; i < this.entries.length; i++) {
15389
- const entry = this.entries[i];
15390
- if (entry.type === EntryType.Marker) break;
15391
- const { element } = entry;
15392
- if (this.treeAdapter.getTagName(element) === neTagName && this.treeAdapter.getNamespaceURI(element) === neNamespaceURI) {
15393
- const elementAttrs = this.treeAdapter.getAttrList(element);
15394
- if (elementAttrs.length === neAttrsLength) candidates.push({
15395
- idx: i,
15396
- attrs: elementAttrs
15397
- });
15398
- }
15399
- }
15400
- return candidates;
15401
- }
15402
- _ensureNoahArkCondition(newElement) {
15403
- if (this.entries.length < NOAH_ARK_CAPACITY) return;
15404
- const neAttrs = this.treeAdapter.getAttrList(newElement);
15405
- const candidates = this._getNoahArkConditionCandidates(newElement, neAttrs);
15406
- if (candidates.length < NOAH_ARK_CAPACITY) return;
15407
- const neAttrsMap = new Map(neAttrs.map((neAttr) => [neAttr.name, neAttr.value]));
15408
- let validCandidates = 0;
15409
- for (let i = 0; i < candidates.length; i++) {
15410
- const candidate = candidates[i];
15411
- if (candidate.attrs.every((cAttr) => neAttrsMap.get(cAttr.name) === cAttr.value)) {
15412
- validCandidates += 1;
15413
- if (validCandidates >= NOAH_ARK_CAPACITY) this.entries.splice(candidate.idx, 1);
15414
- }
15415
- }
15812
+ /** The index of the entries after the last marker; null only while there are at most NOAH_ARK_CAPACITY of them. */
15813
+ this.index = null;
15814
+ /** The entries by element, except possibly those after the last marker while they are not indexed. */
15815
+ this.elementEntries = /* @__PURE__ */ new Map();
15816
+ }
15817
+ /** Returns the entry's ark, or null if the entries after the last marker are not indexed. */
15818
+ _insertElementEntry(element, token, older) {
15819
+ const newer = older === null ? null : older.newer;
15820
+ const entry = {
15821
+ type: EntryType.Element,
15822
+ element,
15823
+ token,
15824
+ older,
15825
+ newer,
15826
+ ark: null,
15827
+ olderSameTag: null,
15828
+ newerSameTag: null
15829
+ };
15830
+ if (newer === null) this.newest = entry;
15831
+ else newer.older = entry;
15832
+ if (older !== null) older.newer = entry;
15833
+ return this.index === null ? null : this._addToIndex(this.index, entry);
15834
+ }
15835
+ _addToIndex(index, entry) {
15836
+ const { tagName, attrs } = entry.token;
15837
+ const key = tagName + attrs.map(({ name, value }) => `\0${name}\0${value}`).sort().join("");
15838
+ let ark = index.arks.get(key);
15839
+ if (ark === void 0) {
15840
+ ark = {
15841
+ entries: [],
15842
+ key
15843
+ };
15844
+ index.arks.set(key, ark);
15845
+ }
15846
+ ark.entries.push(entry);
15847
+ entry.ark = ark;
15848
+ this.elementEntries.set(entry.element, entry);
15849
+ let head = index.tagNames.get(tagName);
15850
+ if (head === void 0) {
15851
+ head = { olderSameTag: null };
15852
+ index.tagNames.set(tagName, head);
15853
+ }
15854
+ entry.olderSameTag = head.olderSameTag;
15855
+ entry.newerSameTag = head;
15856
+ if (head.olderSameTag !== null) head.olderSameTag.newerSameTag = entry;
15857
+ head.olderSameTag = entry;
15858
+ return ark;
15416
15859
  }
15417
15860
  insertMarker() {
15418
- this.entries.unshift(MARKER);
15861
+ if (this.index === null) for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) this.elementEntries.set(entry.element, entry);
15862
+ const marker = {
15863
+ type: EntryType.Marker,
15864
+ older: this.newest,
15865
+ newer: null,
15866
+ outerIndex: this.index
15867
+ };
15868
+ if (this.newest !== null) this.newest.newer = marker;
15869
+ this.newest = marker;
15870
+ this.index = null;
15419
15871
  }
15420
15872
  pushElement(element, token) {
15421
- this._ensureNoahArkCondition(element);
15422
- this.entries.unshift({
15423
- type: EntryType.Element,
15424
- element,
15425
- token
15426
- });
15873
+ if (this.index === null) {
15874
+ let oldest = null;
15875
+ let count = 0;
15876
+ for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) {
15877
+ oldest = entry;
15878
+ count++;
15879
+ }
15880
+ if (count >= NOAH_ARK_CAPACITY) {
15881
+ this.index = {
15882
+ arks: /* @__PURE__ */ new Map(),
15883
+ tagNames: /* @__PURE__ */ new Map()
15884
+ };
15885
+ for (let entry = oldest; entry !== null && entry.type === EntryType.Element; entry = entry.newer) this._addToIndex(this.index, entry);
15886
+ }
15887
+ }
15888
+ const ark = this._insertElementEntry(element, token, this.newest);
15889
+ if (ark !== null && ark.entries.length > NOAH_ARK_CAPACITY) this.removeEntry(ark.entries[0]);
15427
15890
  }
15428
15891
  insertElementAfterBookmark(element, token) {
15429
- const bookmarkIdx = this.entries.indexOf(this.bookmark);
15430
- this.entries.splice(bookmarkIdx, 0, {
15431
- type: EntryType.Element,
15432
- element,
15433
- token
15434
- });
15892
+ const { bookmark } = this;
15893
+ this.bookmark = null;
15894
+ this._insertElementEntry(element, token, bookmark);
15435
15895
  }
15436
15896
  removeEntry(entry) {
15437
- const entryIndex = this.entries.indexOf(entry);
15438
- if (entryIndex !== -1) this.entries.splice(entryIndex, 1);
15897
+ var _a;
15898
+ if (entry.newer === null ? this.newest !== entry : entry.newer.older !== entry) return;
15899
+ this.elementEntries.delete(entry.element);
15900
+ if (entry.newer === null) this.newest = entry.older;
15901
+ else entry.newer.older = entry.older;
15902
+ if (entry.older !== null) entry.older.newer = entry.newer;
15903
+ if (entry.ark !== null) {
15904
+ const { entries, key } = entry.ark;
15905
+ entries.splice(entries.indexOf(entry), 1);
15906
+ if (entries.length === 0) (_a = this.index) === null || _a === void 0 || _a.arks.delete(key);
15907
+ }
15908
+ if (entry.newerSameTag !== null) {
15909
+ entry.newerSameTag.olderSameTag = entry.olderSameTag;
15910
+ if (entry.olderSameTag !== null) entry.olderSameTag.newerSameTag = entry.newerSameTag;
15911
+ }
15912
+ }
15913
+ replaceElement(entry, element) {
15914
+ if (this.elementEntries.delete(entry.element)) this.elementEntries.set(element, entry);
15915
+ entry.element = element;
15439
15916
  }
15440
15917
  /**
15441
15918
  * Clears the list of formatting elements up to the last marker.
@@ -15443,19 +15920,28 @@ var FormattingElementList = class {
15443
15920
  * @see https://html.spec.whatwg.org/multipage/parsing.html#clear-the-list-of-active-formatting-elements-up-to-the-last-marker
15444
15921
  */
15445
15922
  clearToLastMarker() {
15446
- const markerIdx = this.entries.indexOf(MARKER);
15447
- if (markerIdx === -1) this.entries.length = 0;
15448
- else this.entries.splice(0, markerIdx + 1);
15923
+ let marker = this.newest;
15924
+ for (; marker !== null && marker.type === EntryType.Element; marker = marker.older) this.elementEntries.delete(marker.element);
15925
+ this.newest = marker === null ? null : marker.older;
15926
+ this.index = marker === null ? null : marker.outerIndex;
15927
+ if (this.newest !== null) this.newest.newer = null;
15449
15928
  }
15450
15929
  getElementEntryInScopeWithTagName(tagName) {
15451
- const entry = this.entries.find((entry) => entry.type === EntryType.Marker || this.treeAdapter.getTagName(entry.element) === tagName);
15452
- return entry && entry.type === EntryType.Element ? entry : null;
15930
+ var _a, _b;
15931
+ if (this.index !== null) return (_b = (_a = this.index.tagNames.get(tagName)) === null || _a === void 0 ? void 0 : _a.olderSameTag) !== null && _b !== void 0 ? _b : null;
15932
+ for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) if (entry.token.tagName === tagName) return entry;
15933
+ return null;
15453
15934
  }
15454
15935
  getElementEntry(element) {
15455
- return this.entries.find((entry) => entry.type === EntryType.Element && entry.element === element);
15936
+ if (this.index === null) {
15937
+ for (let entry = this.newest; entry !== null && entry.type === EntryType.Element; entry = entry.older) if (entry.element === element) return entry;
15938
+ }
15939
+ return this.elementEntries.get(element);
15456
15940
  }
15457
15941
  };
15458
15942
  // node_modules/parse5/dist/tree-adapters/default.js
15943
+ /** The position of each name in the attribute lists `adoptAttributes` merged into, kept for the next merge into that list. */
15944
+ const attrListIndexes = /* @__PURE__ */ new WeakMap();
15459
15945
  const defaultTreeAdapter = {
15460
15946
  createDocument() {
15461
15947
  return {
@@ -15499,8 +15985,9 @@ const defaultTreeAdapter = {
15499
15985
  newNode.parentNode = parentNode;
15500
15986
  },
15501
15987
  insertBefore(parentNode, newNode, referenceNode) {
15502
- const insertionIdx = parentNode.childNodes.indexOf(referenceNode);
15503
- parentNode.childNodes.splice(insertionIdx, 0, newNode);
15988
+ const { childNodes } = parentNode;
15989
+ const insertionIdx = childNodes[childNodes.length - 1] === referenceNode ? childNodes.length - 1 : childNodes.indexOf(referenceNode);
15990
+ childNodes.splice(insertionIdx, 0, newNode);
15504
15991
  newNode.parentNode = parentNode;
15505
15992
  },
15506
15993
  setTemplateContent(templateElement, contentElement) {
@@ -15534,8 +16021,9 @@ const defaultTreeAdapter = {
15534
16021
  },
15535
16022
  detachNode(node) {
15536
16023
  if (node.parentNode) {
15537
- const idx = node.parentNode.childNodes.indexOf(node);
15538
- node.parentNode.childNodes.splice(idx, 1);
16024
+ const { childNodes } = node.parentNode;
16025
+ const idx = childNodes[childNodes.length - 1] === node ? childNodes.length - 1 : childNodes.indexOf(node);
16026
+ childNodes.splice(idx, 1);
15539
16027
  node.parentNode = null;
15540
16028
  }
15541
16029
  },
@@ -15550,13 +16038,36 @@ const defaultTreeAdapter = {
15550
16038
  defaultTreeAdapter.appendChild(parentNode, defaultTreeAdapter.createTextNode(text));
15551
16039
  },
15552
16040
  insertTextBefore(parentNode, text, referenceNode) {
15553
- const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
16041
+ const { childNodes } = parentNode;
16042
+ const prevNode = childNodes[(childNodes[childNodes.length - 1] === referenceNode ? childNodes.length - 1 : childNodes.indexOf(referenceNode)) - 1];
15554
16043
  if (prevNode && defaultTreeAdapter.isTextNode(prevNode)) prevNode.value += text;
15555
16044
  else defaultTreeAdapter.insertBefore(parentNode, defaultTreeAdapter.createTextNode(text), referenceNode);
15556
16045
  },
16046
+ /**
16047
+ * Keeps the recipient's names between merges as a map from name to position. The map is rebuilt when the list changed
16048
+ * length or has a repeated name, or when a merged name it holds no longer names the entry at that position. A name that
16049
+ * other code gives an existing entry between two merges is missed otherwise, and merging it appends it a second time.
16050
+ */
15557
16051
  adoptAttributes(recipient, attrs) {
15558
- const recipientAttrsMap = new Set(recipient.attrs.map((attr) => attr.name));
16052
+ if (attrs.length === 0 || attrs === recipient.attrs) return;
16053
+ const cached = attrListIndexes.get(recipient.attrs);
16054
+ const isIndexed = (cached === null || cached === void 0 ? void 0 : cached.size) === recipient.attrs.length && attrs.every(({ name }) => {
16055
+ var _a;
16056
+ const index = cached.get(name);
16057
+ return index === void 0 || ((_a = recipient.attrs[index]) === null || _a === void 0 ? void 0 : _a.name) === name;
16058
+ });
16059
+ const recipientAttrsMap = isIndexed ? cached : /* @__PURE__ */ new Map();
16060
+ if (!isIndexed) {
16061
+ for (let i = 0; i < recipient.attrs.length; i++) {
16062
+ const attr = recipient.attrs[i];
16063
+ if (attr !== void 0) recipientAttrsMap.set(attr.name, i);
16064
+ }
16065
+ attrListIndexes.set(recipient.attrs, recipientAttrsMap);
16066
+ }
16067
+ const adoptedFrom = recipient.attrs.length;
15559
16068
  for (let j = 0; j < attrs.length; j++) if (!recipientAttrsMap.has(attrs[j].name)) recipient.attrs.push(attrs[j]);
16069
+ for (let j = adoptedFrom; j < recipient.attrs.length; j++) recipientAttrsMap.set(recipient.attrs[j].name, j);
16070
+ if (recipientAttrsMap.size !== recipient.attrs.length) attrListIndexes.delete(recipient.attrs);
15560
16071
  },
15561
16072
  getFirstChild(node) {
15562
16073
  return node.childNodes[0];
@@ -15971,7 +16482,25 @@ function isIntegrationPoint(tn, ns, attrs, foreignNS) {
15971
16482
  return (!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs) || (!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns);
15972
16483
  }
15973
16484
  // node_modules/parse5/dist/parser/index.js
16485
+ const INSERTION_MODE_TAGS = [
16486
+ TAG_ID.TR,
16487
+ TAG_ID.TBODY,
16488
+ TAG_ID.THEAD,
16489
+ TAG_ID.TFOOT,
16490
+ TAG_ID.CAPTION,
16491
+ TAG_ID.COLGROUP,
16492
+ TAG_ID.TABLE,
16493
+ TAG_ID.FRAMESET,
16494
+ TAG_ID.SELECT,
16495
+ TAG_ID.TEMPLATE,
16496
+ TAG_ID.TD,
16497
+ TAG_ID.TH,
16498
+ TAG_ID.HEAD,
16499
+ TAG_ID.BODY,
16500
+ TAG_ID.HTML
16501
+ ];
15974
16502
  const HIDDEN_INPUT_TYPE = "hidden";
16503
+ const EMPTY_ATTRS = [];
15975
16504
  const AA_OUTER_LOOP_ITER = 8;
15976
16505
  const AA_INNER_LOOP_ITER = 3;
15977
16506
  var InsertionMode;
@@ -16038,8 +16567,7 @@ var Parser = class {
16038
16567
  /** Indicates that the current node is not an element in the HTML namespace */
16039
16568
  this.currentNotInHTML = false;
16040
16569
  /**
16041
- * The template insertion mode stack is maintained from the left.
16042
- * Ie. the topmost element will always have index 0.
16570
+ * The topmost template insertion mode is the last element.
16043
16571
  *
16044
16572
  * @internal
16045
16573
  */
@@ -16063,7 +16591,7 @@ var Parser = class {
16063
16591
  if (this.onParseError) this.options.sourceCodeLocationInfo = true;
16064
16592
  this.document = document !== null && document !== void 0 ? document : this.treeAdapter.createDocument();
16065
16593
  this.tokenizer = new Tokenizer(this.options, this);
16066
- this.activeFormattingElements = new FormattingElementList(this.treeAdapter);
16594
+ this.activeFormattingElements = new FormattingElementList();
16067
16595
  this.fragmentContextID = fragmentContext ? getTagID(this.treeAdapter.getTagName(fragmentContext)) : TAG_ID.UNKNOWN;
16068
16596
  this._setContextModes(fragmentContext !== null && fragmentContext !== void 0 ? fragmentContext : this.document, this.fragmentContextID);
16069
16597
  this.openElements = new OpenElementStack(this.document, this.treeAdapter, this);
@@ -16081,7 +16609,7 @@ var Parser = class {
16081
16609
  fragmentContext !== null && fragmentContext !== void 0 || (fragmentContext = opts.treeAdapter.createElement(TAG_NAMES.TEMPLATE, NS.HTML, []));
16082
16610
  const documentMock = opts.treeAdapter.createElement("documentmock", NS.HTML, []);
16083
16611
  const parser = new this(opts, documentMock, fragmentContext);
16084
- if (parser.fragmentContextID === TAG_ID.TEMPLATE) parser.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
16612
+ if (parser.fragmentContextID === TAG_ID.TEMPLATE) parser.tmplInsertionModeStack.push(InsertionMode.IN_TEMPLATE);
16085
16613
  parser._initTokenizerForFragmentParsing();
16086
16614
  parser._insertFakeRootElement();
16087
16615
  parser._resetInsertionMode();
@@ -16118,9 +16646,10 @@ var Parser = class {
16118
16646
  }
16119
16647
  /** @internal */
16120
16648
  onItemPop(node, isTop) {
16121
- var _a, _b;
16649
+ var _a, _b, _c;
16122
16650
  if (this.options.sourceCodeLocationInfo) this._setEndLocation(node, this.currentToken);
16123
16651
  (_b = (_a = this.treeAdapter).onItemPop) === null || _b === void 0 || _b.call(_a, node, this.openElements.current);
16652
+ (_c = this.annotationXmlIntegrationPoints) === null || _c === void 0 || _c.delete(node);
16124
16653
  if (isTop) {
16125
16654
  let current;
16126
16655
  let currentTagId;
@@ -16156,7 +16685,7 @@ var Parser = class {
16156
16685
  _findFormInFragmentContext() {
16157
16686
  let node = this.fragmentContext;
16158
16687
  while (node) {
16159
- if (this.treeAdapter.getTagName(node) === TAG_NAMES.FORM) {
16688
+ if (this.treeAdapter.getTagName(node) === TAG_NAMES.FORM && this.treeAdapter.getNamespaceURI(node) === NS.HTML) {
16160
16689
  this.formElement = node;
16161
16690
  break;
16162
16691
  }
@@ -16196,7 +16725,7 @@ var Parser = class {
16196
16725
  }
16197
16726
  }
16198
16727
  /** @protected */
16199
- _attachElementToTree(element, location) {
16728
+ _attachElementToTree(element, location, insertionLocation) {
16200
16729
  if (this.options.sourceCodeLocationInfo) {
16201
16730
  const loc = location && {
16202
16731
  ...location,
@@ -16204,11 +16733,28 @@ var Parser = class {
16204
16733
  };
16205
16734
  this.treeAdapter.setNodeSourceCodeLocation(element, loc);
16206
16735
  }
16207
- if (this._shouldFosterParentOnInsertion()) this._fosterParentElement(element);
16208
- else {
16209
- const parent = this.openElements.currentTmplContentOrNode;
16210
- this.treeAdapter.appendChild(parent !== null && parent !== void 0 ? parent : this.document, element);
16211
- }
16736
+ if (insertionLocation.beforeElement) this.treeAdapter.insertBefore(insertionLocation.parent, element, insertionLocation.beforeElement);
16737
+ else this.treeAdapter.appendChild(insertionLocation.parent, element);
16738
+ }
16739
+ /** @protected */
16740
+ _getInsertionLocation() {
16741
+ var _a;
16742
+ if (this._shouldFosterParentOnInsertion()) return this._findFosterParentingLocation();
16743
+ return {
16744
+ parent: (_a = this.openElements.currentTmplContentOrNode) !== null && _a !== void 0 ? _a : this.document,
16745
+ beforeElement: null
16746
+ };
16747
+ }
16748
+ /** @protected */
16749
+ _createElement(tagName, namespaceURI, attrs, intendedParent) {
16750
+ var _a, _b;
16751
+ const element = this.treeAdapter.createElement(tagName, namespaceURI, attrs);
16752
+ (_b = (_a = this.treeAdapter).onElementCreated) === null || _b === void 0 || _b.call(_a, element, {
16753
+ intendedParent,
16754
+ formElement: this.formElement,
16755
+ isInTemplate: this.openElements.tmplCount > 0
16756
+ });
16757
+ return element;
16212
16758
  }
16213
16759
  /**
16214
16760
  * For self-closing tags. Add an element to the tree, but skip adding it
@@ -16216,35 +16762,39 @@ var Parser = class {
16216
16762
  */
16217
16763
  /** @protected */
16218
16764
  _appendElement(token, namespaceURI) {
16219
- const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
16220
- this._attachElementToTree(element, token.location);
16765
+ const insertionLocation = this._getInsertionLocation();
16766
+ const element = this._createElement(token.tagName, namespaceURI, token.attrs, insertionLocation.parent);
16767
+ this._attachElementToTree(element, token.location, insertionLocation);
16221
16768
  }
16222
16769
  /** @protected */
16223
16770
  _insertElement(token, namespaceURI) {
16224
- const element = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
16225
- this._attachElementToTree(element, token.location);
16771
+ const insertionLocation = this._getInsertionLocation();
16772
+ const element = this._createElement(token.tagName, namespaceURI, token.attrs, insertionLocation.parent);
16773
+ this._attachElementToTree(element, token.location, insertionLocation);
16226
16774
  this.openElements.push(element, token.tagID);
16227
16775
  }
16228
16776
  /** @protected */
16229
16777
  _insertFakeElement(tagName, tagID) {
16230
- const element = this.treeAdapter.createElement(tagName, NS.HTML, []);
16231
- this._attachElementToTree(element, null);
16778
+ const insertionLocation = this._getInsertionLocation();
16779
+ const element = this._createElement(tagName, NS.HTML, [], insertionLocation.parent);
16780
+ this._attachElementToTree(element, null, insertionLocation);
16232
16781
  this.openElements.push(element, tagID);
16233
16782
  }
16234
16783
  /** @protected */
16235
16784
  _insertTemplate(token) {
16236
- const tmpl = this.treeAdapter.createElement(token.tagName, NS.HTML, token.attrs);
16785
+ const insertionLocation = this._getInsertionLocation();
16786
+ const tmpl = this._createElement(token.tagName, NS.HTML, token.attrs, insertionLocation.parent);
16237
16787
  const content = this.treeAdapter.createDocumentFragment();
16238
16788
  this.treeAdapter.setTemplateContent(tmpl, content);
16239
- this._attachElementToTree(tmpl, token.location);
16789
+ this._attachElementToTree(tmpl, token.location, insertionLocation);
16240
16790
  this.openElements.push(tmpl, token.tagID);
16241
16791
  if (this.options.sourceCodeLocationInfo) this.treeAdapter.setNodeSourceCodeLocation(content, null);
16242
16792
  }
16243
16793
  /** @protected */
16244
16794
  _insertFakeRootElement() {
16245
- const element = this.treeAdapter.createElement(TAG_NAMES.HTML, NS.HTML, []);
16795
+ const element = this._createElement(TAG_NAMES.HTML, NS.HTML, [], this.document);
16246
16796
  if (this.options.sourceCodeLocationInfo) this.treeAdapter.setNodeSourceCodeLocation(element, null);
16247
- this.treeAdapter.appendChild(this.openElements.current, element);
16797
+ this.treeAdapter.appendChild(this.document, element);
16248
16798
  this.openElements.push(element, TAG_ID.HTML);
16249
16799
  }
16250
16800
  /** @protected */
@@ -16279,10 +16829,9 @@ var Parser = class {
16279
16829
  }
16280
16830
  /** @protected */
16281
16831
  _adoptNodes(donor, recipient) {
16282
- for (let child = this.treeAdapter.getFirstChild(donor); child; child = this.treeAdapter.getFirstChild(donor)) {
16283
- this.treeAdapter.detachNode(child);
16284
- this.treeAdapter.appendChild(recipient, child);
16285
- }
16832
+ const children = [...this.treeAdapter.getChildNodes(donor)];
16833
+ for (let i = children.length - 1; i >= 0; i--) this.treeAdapter.detachNode(children[i]);
16834
+ for (const child of children) this.treeAdapter.appendChild(recipient, child);
16286
16835
  }
16287
16836
  /** @protected */
16288
16837
  _setEndLocation(element, closingToken) {
@@ -16342,19 +16891,26 @@ var Parser = class {
16342
16891
  }
16343
16892
  /** @protected */
16344
16893
  _isIntegrationPoint(tid, element, foreignNS) {
16345
- return isIntegrationPoint(tid, this.treeAdapter.getNamespaceURI(element), this.treeAdapter.getAttrList(element), foreignNS);
16894
+ var _a;
16895
+ const ns = this.treeAdapter.getNamespaceURI(element);
16896
+ if (tid === TAG_ID.ANNOTATION_XML && ns === NS.MATHML && foreignNS !== NS.MATHML) {
16897
+ const verdicts = (_a = this.annotationXmlIntegrationPoints) !== null && _a !== void 0 ? _a : this.annotationXmlIntegrationPoints = /* @__PURE__ */ new Map();
16898
+ let isIntegrationPoint$1 = verdicts.get(element);
16899
+ if (isIntegrationPoint$1 === void 0) {
16900
+ isIntegrationPoint$1 = isIntegrationPoint(tid, ns, this.treeAdapter.getAttrList(element));
16901
+ verdicts.set(element, isIntegrationPoint$1);
16902
+ }
16903
+ return isIntegrationPoint$1;
16904
+ }
16905
+ return isIntegrationPoint(tid, ns, EMPTY_ATTRS, foreignNS);
16346
16906
  }
16347
16907
  /** @protected */
16348
16908
  _reconstructActiveFormattingElements() {
16349
- const listLength = this.activeFormattingElements.entries.length;
16350
- if (listLength) {
16351
- const endIndex = this.activeFormattingElements.entries.findIndex((entry) => entry.type === EntryType.Marker || this.openElements.contains(entry.element));
16352
- const unopenIdx = endIndex === -1 ? listLength - 1 : endIndex - 1;
16353
- for (let i = unopenIdx; i >= 0; i--) {
16354
- const entry = this.activeFormattingElements.entries[i];
16355
- this._insertElement(entry.token, this.treeAdapter.getNamespaceURI(entry.element));
16356
- entry.element = this.openElements.current;
16357
- }
16909
+ let oldest = null;
16910
+ for (let entry = this.activeFormattingElements.newest; entry !== null && entry.type === EntryType.Element && !this.openElements.contains(entry.element); entry = entry.older) oldest = entry;
16911
+ for (let entry = oldest; entry !== null && entry.type === EntryType.Element; entry = entry.newer) {
16912
+ this._insertElement(entry.token, this.treeAdapter.getNamespaceURI(entry.element));
16913
+ this.activeFormattingElements.replaceElement(entry, this.openElements.current);
16358
16914
  }
16359
16915
  }
16360
16916
  /** @protected */
@@ -16371,7 +16927,10 @@ var Parser = class {
16371
16927
  }
16372
16928
  /** @protected */
16373
16929
  _resetInsertionMode() {
16374
- for (let i = this.openElements.stackTop; i >= 0; i--) switch (i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i]) {
16930
+ const i = this.openElements.indexOfTopmostOf(INSERTION_MODE_TAGS);
16931
+ const tn = i === 0 && this.fragmentContext ? this.fragmentContextID : this.openElements.tagIDs[i];
16932
+ const node = i === 0 && this.fragmentContext ? this.fragmentContext : this.openElements.items[i];
16933
+ if (node !== void 0 && this.treeAdapter.getNamespaceURI(node) === NS.HTML) switch (tn) {
16375
16934
  case TAG_ID.TR:
16376
16935
  this.insertionMode = InsertionMode.IN_ROW;
16377
16936
  return;
@@ -16399,7 +16958,7 @@ var Parser = class {
16399
16958
  this._resetInsertionModeForSelect(i);
16400
16959
  return;
16401
16960
  case TAG_ID.TEMPLATE:
16402
- this.insertionMode = this.tmplInsertionModeStack[0];
16961
+ this.insertionMode = this.tmplInsertionModeStack[this.tmplInsertionModeStack.length - 1];
16403
16962
  return;
16404
16963
  case TAG_ID.HTML:
16405
16964
  this.insertionMode = this.headElement ? InsertionMode.AFTER_HEAD : InsertionMode.BEFORE_HEAD;
@@ -16420,10 +16979,9 @@ var Parser = class {
16420
16979
  }
16421
16980
  /** @protected */
16422
16981
  _resetInsertionModeForSelect(selectIdx) {
16423
- if (selectIdx > 0) for (let i = selectIdx - 1; i > 0; i--) {
16424
- const tn = this.openElements.tagIDs[i];
16425
- if (tn === TAG_ID.TEMPLATE) break;
16426
- else if (tn === TAG_ID.TABLE) {
16982
+ if (selectIdx > 0) {
16983
+ const tableIdx = this.openElements.indexOfTopmost(TAG_ID.TABLE);
16984
+ if (tableIdx > 0 && tableIdx > this.openElements.indexOfTopmost(TAG_ID.TEMPLATE)) {
16427
16985
  this.insertionMode = InsertionMode.IN_SELECT_IN_TABLE;
16428
16986
  return;
16429
16987
  }
@@ -16440,30 +16998,27 @@ var Parser = class {
16440
16998
  }
16441
16999
  /** @protected */
16442
17000
  _findFosterParentingLocation() {
16443
- for (let i = this.openElements.stackTop; i >= 0; i--) {
16444
- const openElement = this.openElements.items[i];
16445
- switch (this.openElements.tagIDs[i]) {
16446
- case TAG_ID.TEMPLATE:
16447
- if (this.treeAdapter.getNamespaceURI(openElement) === NS.HTML) return {
16448
- parent: this.treeAdapter.getTemplateContent(openElement),
16449
- beforeElement: null
16450
- };
16451
- break;
16452
- case TAG_ID.TABLE: {
16453
- const parent = this.treeAdapter.getParentNode(openElement);
16454
- if (parent) return {
16455
- parent,
16456
- beforeElement: openElement
16457
- };
16458
- return {
16459
- parent: this.openElements.items[i - 1],
16460
- beforeElement: null
16461
- };
16462
- }
16463
- }
17001
+ const { openElements } = this;
17002
+ const tableIdx = openElements.indexOfTopmost(TAG_ID.TABLE);
17003
+ const templateIdx = openElements.indexOfTopmost(TAG_ID.TEMPLATE);
17004
+ if (templateIdx > tableIdx) return {
17005
+ parent: this.treeAdapter.getTemplateContent(openElements.items[templateIdx]),
17006
+ beforeElement: null
17007
+ };
17008
+ if (tableIdx !== -1) {
17009
+ const table = openElements.items[tableIdx];
17010
+ const parent = this.treeAdapter.getParentNode(table);
17011
+ if (parent) return {
17012
+ parent,
17013
+ beforeElement: table
17014
+ };
17015
+ return {
17016
+ parent: openElements.items[openElements.slotBelow(tableIdx)],
17017
+ beforeElement: null
17018
+ };
16464
17019
  }
16465
17020
  return {
16466
- parent: this.openElements.items[0],
17021
+ parent: openElements.items[0],
16467
17022
  beforeElement: null
16468
17023
  };
16469
17024
  }
@@ -16893,36 +17448,33 @@ function aaObtainFormattingElementEntry(p, token) {
16893
17448
  if (!p.openElements.contains(formattingElementEntry.element)) {
16894
17449
  p.activeFormattingElements.removeEntry(formattingElementEntry);
16895
17450
  formattingElementEntry = null;
16896
- } else if (!p.openElements.hasInScope(token.tagID)) formattingElementEntry = null;
17451
+ } else if (!p.openElements.hasInScope(token.tagID, formattingElementEntry.element)) formattingElementEntry = null;
16897
17452
  } else genericEndTagInBody(p, token);
16898
17453
  return formattingElementEntry;
16899
17454
  }
16900
17455
  function aaObtainFurthestBlock(p, formattingElementEntry) {
16901
- let furthestBlock = null;
16902
- let idx = p.openElements.stackTop;
16903
- for (; idx >= 0; idx--) {
16904
- const element = p.openElements.items[idx];
16905
- if (element === formattingElementEntry.element) break;
16906
- if (p._isSpecialElement(element, p.openElements.tagIDs[idx])) furthestBlock = element;
16907
- }
16908
- if (!furthestBlock) {
16909
- p.openElements.shortenToLength(Math.max(idx, 0));
16910
- p.activeFormattingElements.removeEntry(formattingElementEntry);
16911
- }
16912
- return furthestBlock;
17456
+ const { openElements } = p;
17457
+ const formattingIdx = openElements._indexOf(formattingElementEntry.element);
17458
+ for (let idx = openElements.slotAbove(formattingIdx); idx !== -1; idx = openElements.slotAbove(idx)) if (p._isSpecialElement(openElements.items[idx], openElements.tagIDs[idx])) return idx;
17459
+ openElements.shortenToLength(formattingIdx);
17460
+ p.activeFormattingElements.removeEntry(formattingElementEntry);
17461
+ return -1;
16913
17462
  }
16914
- function aaInnerLoop(p, furthestBlock, formattingElement) {
17463
+ function aaInnerLoop(p, furthestBlockIdx, formattingElement) {
17464
+ const furthestBlock = p.openElements.items[furthestBlockIdx];
16915
17465
  let lastElement = furthestBlock;
16916
- let nextElement = p.openElements.getCommonAncestor(furthestBlock);
16917
- for (let i = 0, element = nextElement; element !== formattingElement; i++, element = nextElement) {
16918
- nextElement = p.openElements.getCommonAncestor(element);
17466
+ let nextIdx = p.openElements.slotBelow(furthestBlockIdx);
17467
+ const intendedParent = p.openElements.getCommonAncestor(formattingElement);
17468
+ for (let i = 0, idx = nextIdx; p.openElements.items[idx] !== formattingElement; i++, idx = nextIdx) {
17469
+ let element = p.openElements.items[idx];
17470
+ nextIdx = p.openElements.slotBelow(idx);
16919
17471
  const elementEntry = p.activeFormattingElements.getElementEntry(element);
16920
17472
  const counterOverflow = elementEntry && i >= AA_INNER_LOOP_ITER;
16921
17473
  if (!elementEntry || counterOverflow) {
16922
17474
  if (counterOverflow) p.activeFormattingElements.removeEntry(elementEntry);
16923
- p.openElements.remove(element);
17475
+ p.openElements.removeAt(idx);
16924
17476
  } else {
16925
- element = aaRecreateElementFromEntry(p, elementEntry);
17477
+ element = aaRecreateElementFromEntry(p, elementEntry, intendedParent);
16926
17478
  if (lastElement === furthestBlock) p.activeFormattingElements.bookmark = elementEntry;
16927
17479
  p.treeAdapter.detachNode(lastElement);
16928
17480
  p.treeAdapter.appendChild(element, lastElement);
@@ -16931,11 +17483,11 @@ function aaInnerLoop(p, furthestBlock, formattingElement) {
16931
17483
  }
16932
17484
  return lastElement;
16933
17485
  }
16934
- function aaRecreateElementFromEntry(p, elementEntry) {
17486
+ function aaRecreateElementFromEntry(p, elementEntry, intendedParent) {
16935
17487
  const ns = p.treeAdapter.getNamespaceURI(elementEntry.element);
16936
- const newElement = p.treeAdapter.createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs);
17488
+ const newElement = p._createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs, intendedParent);
16937
17489
  p.openElements.replace(elementEntry.element, newElement);
16938
- elementEntry.element = newElement;
17490
+ p.activeFormattingElements.replaceElement(elementEntry, newElement);
16939
17491
  return newElement;
16940
17492
  }
16941
17493
  function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) {
@@ -16950,22 +17502,30 @@ function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) {
16950
17502
  function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {
16951
17503
  const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element);
16952
17504
  const { token } = formattingElementEntry;
16953
- const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);
17505
+ const newElement = p._createElement(token.tagName, ns, token.attrs, furthestBlock);
16954
17506
  p._adoptNodes(furthestBlock, newElement);
16955
17507
  p.treeAdapter.appendChild(furthestBlock, newElement);
16956
17508
  p.activeFormattingElements.insertElementAfterBookmark(newElement, token);
16957
17509
  p.activeFormattingElements.removeEntry(formattingElementEntry);
16958
- p.openElements.remove(formattingElementEntry.element);
16959
- p.openElements.insertAfter(furthestBlock, newElement, token.tagID);
17510
+ const formattingIdx = p.openElements._indexOf(formattingElementEntry.element);
17511
+ let furthestBlockIdx = p.openElements.slotAbove(formattingIdx);
17512
+ while (p.openElements.items[furthestBlockIdx] !== furthestBlock) furthestBlockIdx = p.openElements.slotAbove(furthestBlockIdx);
17513
+ p.openElements.replaceFormattingElement(formattingIdx, furthestBlockIdx, newElement, token.tagID);
16960
17514
  }
16961
17515
  function callAdoptionAgency(p, token) {
17516
+ const { current, currentTagId } = p.openElements;
17517
+ if (currentTagId === token.tagID && p.treeAdapter.getNamespaceURI(current) === NS.HTML && !p.activeFormattingElements.getElementEntry(current)) {
17518
+ p.openElements.pop();
17519
+ return;
17520
+ }
16962
17521
  for (let i = 0; i < AA_OUTER_LOOP_ITER; i++) {
16963
17522
  const formattingElementEntry = aaObtainFormattingElementEntry(p, token);
16964
17523
  if (!formattingElementEntry) break;
16965
- const furthestBlock = aaObtainFurthestBlock(p, formattingElementEntry);
16966
- if (!furthestBlock) break;
17524
+ const furthestBlockIdx = aaObtainFurthestBlock(p, formattingElementEntry);
17525
+ if (furthestBlockIdx === -1) break;
17526
+ const furthestBlock = p.openElements.items[furthestBlockIdx];
16967
17527
  p.activeFormattingElements.bookmark = formattingElementEntry;
16968
- const lastElement = aaInnerLoop(p, furthestBlock, formattingElementEntry.element);
17528
+ const lastElement = aaInnerLoop(p, furthestBlockIdx, formattingElementEntry.element);
16969
17529
  const commonAncestor = p.openElements.getCommonAncestor(formattingElementEntry.element);
16970
17530
  p.treeAdapter.detachNode(lastElement);
16971
17531
  if (commonAncestor) aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement);
@@ -16985,7 +17545,7 @@ function stopParsing(p, token) {
16985
17545
  p.stopped = true;
16986
17546
  if (token.location) {
16987
17547
  const target = p.fragmentContext ? 0 : 2;
16988
- for (let i = p.openElements.stackTop; i >= target; i--) p._setEndLocation(p.openElements.items[i], token);
17548
+ for (let i = p.openElements.stackTop; i >= target; i = p.openElements.slotBelow(i)) p._setEndLocation(p.openElements.items[i], token);
16989
17549
  if (!p.fragmentContext && p.openElements.stackTop >= 0) {
16990
17550
  const htmlElement = p.openElements.items[0];
16991
17551
  const htmlLocation = p.treeAdapter.getNodeSourceCodeLocation(htmlElement);
@@ -17087,7 +17647,7 @@ function startTagInHead(p, token) {
17087
17647
  p.activeFormattingElements.insertMarker();
17088
17648
  p.framesetOk = false;
17089
17649
  p.insertionMode = InsertionMode.IN_TEMPLATE;
17090
- p.tmplInsertionModeStack.unshift(InsertionMode.IN_TEMPLATE);
17650
+ p.tmplInsertionModeStack.push(InsertionMode.IN_TEMPLATE);
17091
17651
  break;
17092
17652
  case TAG_ID.HEAD:
17093
17653
  p._err(token, ERR.misplacedStartTagForHeadElement);
@@ -17118,7 +17678,7 @@ function templateEndTagInHead(p, token) {
17118
17678
  if (p.openElements.currentTagId !== TAG_ID.TEMPLATE) p._err(token, ERR.closingOfElementWithOpenChildElements);
17119
17679
  p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
17120
17680
  p.activeFormattingElements.clearToLastMarker();
17121
- p.tmplInsertionModeStack.shift();
17681
+ p.tmplInsertionModeStack.pop();
17122
17682
  p._resetInsertionMode();
17123
17683
  } else p._err(token, ERR.endTagWithoutMatchingOpenElement);
17124
17684
  }
@@ -17273,7 +17833,7 @@ function addressStartTagInBody(p, token) {
17273
17833
  }
17274
17834
  function numberedHeaderStartTagInBody(p, token) {
17275
17835
  if (p.openElements.hasInButtonScope(TAG_ID.P)) p._closePElement();
17276
- if (p.openElements.currentTagId !== void 0 && NUMBERED_HEADERS.has(p.openElements.currentTagId)) p.openElements.pop();
17836
+ if (p.openElements.currentTagId !== void 0 && NUMBERED_HEADERS$1.has(p.openElements.currentTagId)) p.openElements.pop();
17277
17837
  p._insertElement(token, NS.HTML);
17278
17838
  }
17279
17839
  function preStartTagInBody(p, token) {
@@ -17292,15 +17852,11 @@ function formStartTagInBody(p, token) {
17292
17852
  }
17293
17853
  function listItemStartTagInBody(p, token) {
17294
17854
  p.framesetOk = false;
17295
- const tn = token.tagID;
17296
- for (let i = p.openElements.stackTop; i >= 0; i--) {
17297
- const elementId = p.openElements.tagIDs[i];
17298
- if (tn === TAG_ID.LI && elementId === TAG_ID.LI || (tn === TAG_ID.DD || tn === TAG_ID.DT) && (elementId === TAG_ID.DD || elementId === TAG_ID.DT)) {
17299
- p.openElements.generateImpliedEndTagsWithExclusion(elementId);
17300
- p.openElements.popUntilTagNamePopped(elementId);
17301
- break;
17302
- }
17303
- if (elementId !== TAG_ID.ADDRESS && elementId !== TAG_ID.DIV && elementId !== TAG_ID.P && p._isSpecialElement(p.openElements.items[i], elementId)) break;
17855
+ const idx = token.tagID === TAG_ID.LI ? p.openElements.indexOfTopmost(TAG_ID.LI) : Math.max(p.openElements.indexOfTopmost(TAG_ID.DD), p.openElements.indexOfTopmost(TAG_ID.DT));
17856
+ if (idx !== -1 && !p.openElements.hasListItemBoundaryAbove(idx)) {
17857
+ const elementId = p.openElements.tagIDs[idx];
17858
+ p.openElements.generateImpliedEndTagsWithExclusion(elementId);
17859
+ p.openElements.popUntilTagNamePopped(elementId);
17304
17860
  }
17305
17861
  if (p.openElements.hasInButtonScope(TAG_ID.P)) p._closePElement();
17306
17862
  p._insertElement(token, NS.HTML);
@@ -17694,17 +18250,11 @@ function brEndTagInBody(p) {
17694
18250
  p.framesetOk = false;
17695
18251
  }
17696
18252
  function genericEndTagInBody(p, token) {
17697
- const tn = token.tagName;
17698
18253
  const tid = token.tagID;
17699
- for (let i = p.openElements.stackTop; i > 0; i--) {
17700
- const element = p.openElements.items[i];
17701
- const elementId = p.openElements.tagIDs[i];
17702
- if (tid === elementId && (tid !== TAG_ID.UNKNOWN || p.treeAdapter.getTagName(element) === tn)) {
17703
- p.openElements.generateImpliedEndTagsWithExclusion(tid);
17704
- if (p.openElements.stackTop >= i) p.openElements.shortenToLength(i);
17705
- break;
17706
- }
17707
- if (p._isSpecialElement(element, elementId)) break;
18254
+ const i = tid === TAG_ID.UNKNOWN ? p.openElements.indexOfTopmostByName(NS.HTML, token.tagName) : p.openElements.indexOfTopmost(tid);
18255
+ if (i > 0 && !p.openElements.hasSpecialElementAbove(i)) {
18256
+ p.openElements.generateImpliedEndTagsWithExclusion(tid);
18257
+ if (p.openElements.stackTop >= i) p.openElements.shortenToLength(i);
17708
18258
  }
17709
18259
  }
17710
18260
  function endTagInBody(p, token) {
@@ -18241,7 +18791,7 @@ function startTagInSelect(p, token) {
18241
18791
  function endTagInSelect(p, token) {
18242
18792
  switch (token.tagID) {
18243
18793
  case TAG_ID.OPTGROUP:
18244
- if (p.openElements.stackTop > 0 && p.openElements.currentTagId === TAG_ID.OPTION && p.openElements.tagIDs[p.openElements.stackTop - 1] === TAG_ID.OPTGROUP) p.openElements.pop();
18794
+ if (p.openElements.stackTop > 0 && p.openElements.currentTagId === TAG_ID.OPTION && p.openElements.tagIDs[p.openElements.slotBelow(p.openElements.stackTop)] === TAG_ID.OPTGROUP) p.openElements.pop();
18245
18795
  if (p.openElements.currentTagId === TAG_ID.OPTGROUP) p.openElements.pop();
18246
18796
  break;
18247
18797
  case TAG_ID.OPTION:
@@ -18293,28 +18843,28 @@ function startTagInTemplate(p, token) {
18293
18843
  case TAG_ID.TBODY:
18294
18844
  case TAG_ID.TFOOT:
18295
18845
  case TAG_ID.THEAD:
18296
- p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE;
18846
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_TABLE;
18297
18847
  p.insertionMode = InsertionMode.IN_TABLE;
18298
18848
  startTagInTable(p, token);
18299
18849
  break;
18300
18850
  case TAG_ID.COL:
18301
- p.tmplInsertionModeStack[0] = InsertionMode.IN_COLUMN_GROUP;
18851
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_COLUMN_GROUP;
18302
18852
  p.insertionMode = InsertionMode.IN_COLUMN_GROUP;
18303
18853
  startTagInColumnGroup(p, token);
18304
18854
  break;
18305
18855
  case TAG_ID.TR:
18306
- p.tmplInsertionModeStack[0] = InsertionMode.IN_TABLE_BODY;
18856
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_TABLE_BODY;
18307
18857
  p.insertionMode = InsertionMode.IN_TABLE_BODY;
18308
18858
  startTagInTableBody(p, token);
18309
18859
  break;
18310
18860
  case TAG_ID.TD:
18311
18861
  case TAG_ID.TH:
18312
- p.tmplInsertionModeStack[0] = InsertionMode.IN_ROW;
18862
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_ROW;
18313
18863
  p.insertionMode = InsertionMode.IN_ROW;
18314
18864
  startTagInRow(p, token);
18315
18865
  break;
18316
18866
  default:
18317
- p.tmplInsertionModeStack[0] = InsertionMode.IN_BODY;
18867
+ p.tmplInsertionModeStack[p.tmplInsertionModeStack.length - 1] = InsertionMode.IN_BODY;
18318
18868
  p.insertionMode = InsertionMode.IN_BODY;
18319
18869
  startTagInBody(p, token);
18320
18870
  }
@@ -18324,9 +18874,11 @@ function endTagInTemplate(p, token) {
18324
18874
  }
18325
18875
  function eofInTemplate(p, token) {
18326
18876
  if (p.openElements.tmplCount > 0) {
18327
- p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
18328
- p.activeFormattingElements.clearToLastMarker();
18329
- p.tmplInsertionModeStack.shift();
18877
+ do {
18878
+ p.openElements.popUntilTagNamePopped(TAG_ID.TEMPLATE);
18879
+ p.activeFormattingElements.clearToLastMarker();
18880
+ p.tmplInsertionModeStack.pop();
18881
+ } while (p.openElements.tmplCount > 0);
18330
18882
  p._resetInsertionMode();
18331
18883
  p.onEof(token);
18332
18884
  } else stopParsing(p, token);
@@ -18433,19 +18985,15 @@ function endTagInForeignContent(p, token) {
18433
18985
  p._endTagOutsideForeignContent(token);
18434
18986
  return;
18435
18987
  }
18436
- for (let i = p.openElements.stackTop; i > 0; i--) {
18437
- const element = p.openElements.items[i];
18438
- if (p.treeAdapter.getNamespaceURI(element) === NS.HTML) {
18439
- p._endTagOutsideForeignContent(token);
18440
- break;
18441
- }
18442
- const tagName = p.treeAdapter.getTagName(element);
18443
- if (tagName.toLowerCase() === token.tagName) {
18444
- token.tagName = tagName;
18445
- p.openElements.shortenToLength(i);
18446
- break;
18447
- }
18448
- }
18988
+ if (p.openElements.stackTop === 0) return;
18989
+ const { tagName } = token;
18990
+ const adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP.get(tagName);
18991
+ const contextNs = p.fragmentContext ? p.treeAdapter.getNamespaceURI(p.fragmentContext) : NS.HTML;
18992
+ const i = Math.max(p.openElements.indexOfTopmostByName(NS.SVG, tagName), p.openElements.indexOfTopmostByName(NS.MATHML, tagName), adjustedTagName === void 0 ? -1 : p.openElements.indexOfTopmostByName(NS.SVG, adjustedTagName), contextNs === NS.HTML || contextNs === NS.SVG || contextNs === NS.MATHML ? -1 : p.openElements.indexOfTopmostByName(contextNs, tagName));
18993
+ if (i > p.openElements.indexOfTopmostHtmlElement()) {
18994
+ token.tagName = p.treeAdapter.getTagName(p.openElements.items[i]);
18995
+ p.openElements.shortenToLength(i);
18996
+ } else p._endTagOutsideForeignContent(token);
18449
18997
  }
18450
18998
  TAG_NAMES.AREA, TAG_NAMES.BASE, TAG_NAMES.BASEFONT, TAG_NAMES.BGSOUND, TAG_NAMES.BR, TAG_NAMES.COL, TAG_NAMES.EMBED, TAG_NAMES.FRAME, TAG_NAMES.HR, TAG_NAMES.IMG, TAG_NAMES.INPUT, TAG_NAMES.KEYGEN, TAG_NAMES.LINK, TAG_NAMES.META, TAG_NAMES.PARAM, TAG_NAMES.SOURCE, TAG_NAMES.TRACK, TAG_NAMES.WBR;
18451
18999
  // node_modules/parse5/dist/index.js
@@ -18527,7 +19075,8 @@ const adapter = {
18527
19075
  newNode.parent = parentNode;
18528
19076
  },
18529
19077
  insertBefore(parentNode, newNode, referenceNode) {
18530
- const insertionIdx = parentNode.children.indexOf(referenceNode);
19078
+ const { children } = parentNode;
19079
+ const insertionIdx = children[children.length - 1] === referenceNode ? children.length - 1 : children.indexOf(referenceNode);
18531
19080
  const { prev } = referenceNode;
18532
19081
  if (prev) {
18533
19082
  prev.next = newNode;
@@ -18564,13 +19113,14 @@ const adapter = {
18564
19113
  },
18565
19114
  detachNode(node) {
18566
19115
  if (node.parent) {
18567
- const idx = node.parent.children.indexOf(node);
19116
+ const { children } = node.parent;
19117
+ const idx = children[children.length - 1] === node ? children.length - 1 : children.indexOf(node);
18568
19118
  const { prev, next } = node;
18569
19119
  node.prev = null;
18570
19120
  node.next = null;
18571
19121
  if (prev) prev.next = next;
18572
19122
  if (next) next.prev = prev;
18573
- node.parent.children.splice(idx, 1);
19123
+ children.splice(idx, 1);
18574
19124
  node.parent = null;
18575
19125
  }
18576
19126
  },
@@ -18580,7 +19130,7 @@ const adapter = {
18580
19130
  else adapter.appendChild(parentNode, adapter.createTextNode(text));
18581
19131
  },
18582
19132
  insertTextBefore(parentNode, text, referenceNode) {
18583
- const prevNode = parentNode.children[parentNode.children.indexOf(referenceNode) - 1];
19133
+ const prevNode = referenceNode.prev;
18584
19134
  if (prevNode && isText(prevNode)) prevNode.data += text;
18585
19135
  else adapter.insertBefore(parentNode, adapter.createTextNode(text), referenceNode);
18586
19136
  },
@@ -18907,15 +19457,23 @@ const finding$5 = findingFor([{
18907
19457
  id: "unknown-token",
18908
19458
  tier: "exact",
18909
19459
  severity: "warning",
18910
- description: "A var() with no fallback names a custom property no token sheet, frame sheet, or style attribute declares"
19460
+ description: "A var() with no fallback names a custom property no token sheet, frame sheet, style attribute, or script write declares"
18911
19461
  }]);
18912
19462
  /** A `var()` naming its property, with no fallback after a comma. */
18913
19463
  const BARE_VAR = /var\(\s*(--[\w-]+)\s*\)/g;
18914
19464
  /**
19465
+ * The two ways a script writes a custom property by a name it spells out:
19466
+ * `setProperty('--name', …)`, and a `--name:` declaration in a string it
19467
+ * hands a style attribute or `cssText`. A read such as `getPropertyValue`
19468
+ * matches neither, so it still reports.
19469
+ */
19470
+ const SCRIPT_WRITES = [/\.setProperty\(\s*(['"`])(--[\w-]+)\1/g, /(?<![\w-])(--[\w-]+)\s*:/g];
19471
+ /**
18915
19472
  * `unknown-token`, one finding per bare `var()` in the frame's own sheets
18916
19473
  * and style attributes whose name nothing declares. A token sheet's own
18917
19474
  * references are the board's to answer for, so only its declarations count.
18918
- * A property a script sets reads as unknown, which a fallback silences.
19475
+ * A name a `<script>` writes counts as declared, read off its text since the
19476
+ * check never runs it, so a name the script builds at runtime still reports.
18919
19477
  * A linked sheet's rule matching no element in the frame stays quiet, since a
18920
19478
  * site sheet styles other pages. The frame's own `<style>` keeps reporting,
18921
19479
  * since its theme and state rules match elements no static tree marks.
@@ -18955,10 +19513,14 @@ function checkUnknownTokens(source, tokens) {
18955
19513
  });
18956
19514
  });
18957
19515
  }
19516
+ for (const element of source.elements) {
19517
+ if (element.name !== "script") continue;
19518
+ for (const name of scriptWrites(scriptText(element, source))) declared.add(name);
19519
+ }
18958
19520
  return uses.filter((use) => !declared.has(use.name)).map((use) => finding$5("unknown-token", {
18959
19521
  frame: source.ref,
18960
19522
  path: use.path,
18961
- message: `var(${use.name}) names a custom property nothing declares, so the declaration resolves to nothing. Use a token the project's tokens.css declares, or give it a fallback, such as var(${use.name}, red).`,
19523
+ message: `var(${use.name}) names a custom property nothing declares, so the declaration resolves to nothing. Use a token the project's tokens.css declares, or give it a fallback, such as var(${use.name}, red). If a script sets it at runtime under a name the check cannot read, the fallback is the way out.`,
18962
19524
  location: use.location
18963
19525
  }));
18964
19526
  }
@@ -18978,6 +19540,28 @@ function matchesNothing(node, elements) {
18978
19540
  function bareVars(value) {
18979
19541
  return [...new Set([...value.matchAll(BARE_VAR)].map((match) => match[1] ?? ""))];
18980
19542
  }
19543
+ function scriptWrites(text) {
19544
+ return SCRIPT_WRITES.flatMap((pattern) => [...text.matchAll(pattern)].map((match) => match.at(-1) ?? ""));
19545
+ }
19546
+ /**
19547
+ * A script's inline text, or its `src` file's when the file sits in the
19548
+ * board. A remote, outside, or unreadable `src` reads as empty, since the
19549
+ * write hook never reports a read as failed.
19550
+ */
19551
+ function scriptText(element, source) {
19552
+ const src = element.attribs.src;
19553
+ if (src === void 0) return textOf(element);
19554
+ const file = localTarget(src, source.pageDir);
19555
+ if (!file || !isInside(source.root, file)) return "";
19556
+ try {
19557
+ return readFileSync(file, "utf8");
19558
+ } catch {
19559
+ return "";
19560
+ }
19561
+ }
19562
+ function textOf(element) {
19563
+ return element.children.map((node) => "data" in node ? node.data : "").join("");
19564
+ }
18981
19565
  function parseOrNull(css) {
18982
19566
  try {
18983
19567
  return postcss_default.parse(css);
@@ -19726,7 +20310,7 @@ function readProjectContext(root, project, boardSheet) {
19726
20310
  * The project's `checks` config, read by hand rather than through the
19727
20311
  * project record's schema, which the hook cannot afford to load. A file that
19728
20312
  * does not read, or a key of the wrong type, leaves that rule off. The
19729
- * server's browser checker reads it too, for `minFontSize`.
20313
+ * server's browser checker reads it too, for `minFontSize` and `minContrast`.
19730
20314
  */
19731
20315
  function readConfig(root, project) {
19732
20316
  let parsed;
@@ -19741,6 +20325,7 @@ function readConfig(root, project) {
19741
20325
  if (Array.isArray(checks.allowedFonts) && checks.allowedFonts.every((font) => typeof font === "string")) config.allowedFonts = checks.allowedFonts;
19742
20326
  if (typeof checks.noUppercase === "boolean") config.noUppercase = checks.noUppercase;
19743
20327
  if (typeof checks.minFontSize === "number" && checks.minFontSize > 0) config.minFontSize = checks.minFontSize;
20328
+ if (typeof checks.minContrast === "number" && checks.minContrast >= 1) config.minContrast = checks.minContrast;
19744
20329
  return config;
19745
20330
  }
19746
20331
  function isRecord(value) {