@tamagui/code-to-html 1.7.7 β†’ 1.7.9

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/esm/index.js CHANGED
@@ -7,9 +7,9 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
- var __export = (target, all2) => {
11
- for (var name in all2)
12
- __defProp(target, name, { get: all2[name], enumerable: true });
10
+ var __export = (target, all3) => {
11
+ for (var name in all3)
12
+ __defProp(target, name, { get: all3[name], enumerable: true });
13
13
  };
14
14
  var __copyProps = (to, from, except, desc) => {
15
15
  if (from && typeof from === "object" || typeof from === "function") {
@@ -2633,10 +2633,10 @@ var require_open_element_stack = __commonJS({
2633
2633
  this.treeAdapter = treeAdapter;
2634
2634
  }
2635
2635
  //Index of element
2636
- _indexOf(element4) {
2636
+ _indexOf(element3) {
2637
2637
  let idx = -1;
2638
2638
  for (let i = this.stackTop; i >= 0; i--) {
2639
- if (this.items[i] === element4) {
2639
+ if (this.items[i] === element3) {
2640
2640
  idx = i;
2641
2641
  break;
2642
2642
  }
@@ -2653,8 +2653,8 @@ var require_open_element_stack = __commonJS({
2653
2653
  this.currentTmplContent = this._isInTemplate() ? this.treeAdapter.getTemplateContent(this.current) : null;
2654
2654
  }
2655
2655
  //Mutations
2656
- push(element4) {
2657
- this.items[++this.stackTop] = element4;
2656
+ push(element3) {
2657
+ this.items[++this.stackTop] = element3;
2658
2658
  this._updateCurrentElement();
2659
2659
  if (this._isInTemplate()) {
2660
2660
  this.tmplCount++;
@@ -2691,11 +2691,11 @@ var require_open_element_stack = __commonJS({
2691
2691
  }
2692
2692
  }
2693
2693
  }
2694
- popUntilElementPopped(element4) {
2694
+ popUntilElementPopped(element3) {
2695
2695
  while (this.stackTop > -1) {
2696
2696
  const poppedElement = this.current;
2697
2697
  this.pop();
2698
- if (poppedElement === element4) {
2698
+ if (poppedElement === element3) {
2699
2699
  break;
2700
2700
  }
2701
2701
  }
@@ -2739,9 +2739,9 @@ var require_open_element_stack = __commonJS({
2739
2739
  this.pop();
2740
2740
  }
2741
2741
  }
2742
- remove(element4) {
2742
+ remove(element3) {
2743
2743
  for (let i = this.stackTop; i >= 0; i--) {
2744
- if (this.items[i] === element4) {
2744
+ if (this.items[i] === element3) {
2745
2745
  this.items.splice(i, 1);
2746
2746
  this.stackTop--;
2747
2747
  this._updateCurrentElement();
@@ -2751,14 +2751,14 @@ var require_open_element_stack = __commonJS({
2751
2751
  }
2752
2752
  //Search
2753
2753
  tryPeekProperlyNestedBodyElement() {
2754
- const element4 = this.items[1];
2755
- return element4 && this.treeAdapter.getTagName(element4) === $.BODY ? element4 : null;
2754
+ const element3 = this.items[1];
2755
+ return element3 && this.treeAdapter.getTagName(element3) === $.BODY ? element3 : null;
2756
2756
  }
2757
- contains(element4) {
2758
- return this._indexOf(element4) > -1;
2757
+ contains(element3) {
2758
+ return this._indexOf(element3) > -1;
2759
2759
  }
2760
- getCommonAncestor(element4) {
2761
- let elementIdx = this._indexOf(element4);
2760
+ getCommonAncestor(element3) {
2761
+ let elementIdx = this._indexOf(element3);
2762
2762
  return --elementIdx >= 0 ? this.items[elementIdx] : null;
2763
2763
  }
2764
2764
  isRootHtmlElementCurrent() {
@@ -2912,9 +2912,9 @@ var require_formatting_element_list = __commonJS({
2912
2912
  if (entry.type === FormattingElementList.MARKER_ENTRY) {
2913
2913
  break;
2914
2914
  }
2915
- const element4 = entry.element;
2916
- const elementAttrs = this.treeAdapter.getAttrList(element4);
2917
- const isCandidate = this.treeAdapter.getTagName(element4) === neTagName && this.treeAdapter.getNamespaceURI(element4) === neNamespaceURI && elementAttrs.length === neAttrsLength;
2915
+ const element3 = entry.element;
2916
+ const elementAttrs = this.treeAdapter.getAttrList(element3);
2917
+ const isCandidate = this.treeAdapter.getTagName(element3) === neTagName && this.treeAdapter.getNamespaceURI(element3) === neNamespaceURI && elementAttrs.length === neAttrsLength;
2918
2918
  if (isCandidate) {
2919
2919
  candidates.push({ idx: i, attrs: elementAttrs });
2920
2920
  }
@@ -2956,16 +2956,16 @@ var require_formatting_element_list = __commonJS({
2956
2956
  this.entries.push({ type: FormattingElementList.MARKER_ENTRY });
2957
2957
  this.length++;
2958
2958
  }
2959
- pushElement(element4, token) {
2960
- this._ensureNoahArkCondition(element4);
2959
+ pushElement(element3, token) {
2960
+ this._ensureNoahArkCondition(element3);
2961
2961
  this.entries.push({
2962
2962
  type: FormattingElementList.ELEMENT_ENTRY,
2963
- element: element4,
2963
+ element: element3,
2964
2964
  token
2965
2965
  });
2966
2966
  this.length++;
2967
2967
  }
2968
- insertElementAfterBookmark(element4, token) {
2968
+ insertElementAfterBookmark(element3, token) {
2969
2969
  let bookmarkIdx = this.length - 1;
2970
2970
  for (; bookmarkIdx >= 0; bookmarkIdx--) {
2971
2971
  if (this.entries[bookmarkIdx] === this.bookmark) {
@@ -2974,7 +2974,7 @@ var require_formatting_element_list = __commonJS({
2974
2974
  }
2975
2975
  this.entries.splice(bookmarkIdx + 1, 0, {
2976
2976
  type: FormattingElementList.ELEMENT_ENTRY,
2977
- element: element4,
2977
+ element: element3,
2978
2978
  token
2979
2979
  });
2980
2980
  this.length++;
@@ -3010,10 +3010,10 @@ var require_formatting_element_list = __commonJS({
3010
3010
  }
3011
3011
  return null;
3012
3012
  }
3013
- getElementEntry(element4) {
3013
+ getElementEntry(element3) {
3014
3014
  for (let i = this.length - 1; i >= 0; i--) {
3015
3015
  const entry = this.entries[i];
3016
- if (entry.type === FormattingElementList.ELEMENT_ENTRY && entry.element === element4) {
3016
+ if (entry.type === FormattingElementList.ELEMENT_ENTRY && entry.element === element3) {
3017
3017
  return entry;
3018
3018
  }
3019
3019
  }
@@ -3253,9 +3253,9 @@ var require_open_element_stack_mixin = __commonJS({
3253
3253
  }
3254
3254
  orig.popAllUpToHtmlElement.call(this);
3255
3255
  },
3256
- remove(element4) {
3256
+ remove(element3) {
3257
3257
  mxn.onItemPop(this.current);
3258
- orig.remove.call(this, element4);
3258
+ orig.remove.call(this, element3);
3259
3259
  }
3260
3260
  };
3261
3261
  }
@@ -3284,20 +3284,20 @@ var require_parser_mixin = __commonJS({
3284
3284
  this.lastFosterParentingLocation = null;
3285
3285
  this.currentToken = null;
3286
3286
  }
3287
- _setStartLocation(element4) {
3287
+ _setStartLocation(element3) {
3288
3288
  let loc = null;
3289
3289
  if (this.lastStartTagToken) {
3290
3290
  loc = Object.assign({}, this.lastStartTagToken.location);
3291
3291
  loc.startTag = this.lastStartTagToken.location;
3292
3292
  }
3293
- this.treeAdapter.setNodeSourceCodeLocation(element4, loc);
3293
+ this.treeAdapter.setNodeSourceCodeLocation(element3, loc);
3294
3294
  }
3295
- _setEndLocation(element4, closingToken) {
3296
- const loc = this.treeAdapter.getNodeSourceCodeLocation(element4);
3295
+ _setEndLocation(element3, closingToken) {
3296
+ const loc = this.treeAdapter.getNodeSourceCodeLocation(element3);
3297
3297
  if (loc) {
3298
3298
  if (closingToken.location) {
3299
3299
  const ctLoc = closingToken.location;
3300
- const tn = this.treeAdapter.getTagName(element4);
3300
+ const tn = this.treeAdapter.getTagName(element3);
3301
3301
  const isClosingEndTag = closingToken.type === Tokenizer.END_TAG_TOKEN && tn === closingToken.tagName;
3302
3302
  const endLoc = {};
3303
3303
  if (isClosingEndTag) {
@@ -3310,7 +3310,7 @@ var require_parser_mixin = __commonJS({
3310
3310
  endLoc.endCol = ctLoc.startCol;
3311
3311
  endLoc.endOffset = ctLoc.startOffset;
3312
3312
  }
3313
- this.treeAdapter.updateNodeSourceCodeLocation(element4, endLoc);
3313
+ this.treeAdapter.updateNodeSourceCodeLocation(element3, endLoc);
3314
3314
  }
3315
3315
  }
3316
3316
  }
@@ -3324,8 +3324,8 @@ var require_parser_mixin = __commonJS({
3324
3324
  const tokenizerMixin = Mixin.install(this.tokenizer, LocationInfoTokenizerMixin);
3325
3325
  mxn.posTracker = tokenizerMixin.posTracker;
3326
3326
  Mixin.install(this.openElements, LocationInfoOpenElementStackMixin, {
3327
- onItemPop: function(element4) {
3328
- mxn._setEndLocation(element4, mxn.currentToken);
3327
+ onItemPop: function(element3) {
3328
+ mxn._setEndLocation(element3, mxn.currentToken);
3329
3329
  }
3330
3330
  });
3331
3331
  },
@@ -3346,9 +3346,9 @@ var require_parser_mixin = __commonJS({
3346
3346
  const requireExplicitUpdate = token.type === Tokenizer.END_TAG_TOKEN && (token.tagName === $.HTML || token.tagName === $.BODY && this.openElements.hasInScope($.BODY));
3347
3347
  if (requireExplicitUpdate) {
3348
3348
  for (let i = this.openElements.stackTop; i >= 0; i--) {
3349
- const element4 = this.openElements.items[i];
3350
- if (this.treeAdapter.getTagName(element4) === token.tagName) {
3351
- mxn._setEndLocation(element4, token);
3349
+ const element3 = this.openElements.items[i];
3350
+ if (this.treeAdapter.getTagName(element3) === token.tagName) {
3351
+ mxn._setEndLocation(element3, token);
3352
3352
  break;
3353
3353
  }
3354
3354
  }
@@ -3368,10 +3368,10 @@ var require_parser_mixin = __commonJS({
3368
3368
  }
3369
3369
  },
3370
3370
  //Elements
3371
- _attachElementToTree(element4) {
3372
- mxn._setStartLocation(element4);
3371
+ _attachElementToTree(element3) {
3372
+ mxn._setStartLocation(element3);
3373
3373
  mxn.lastStartTagToken = null;
3374
- orig._attachElementToTree.call(this, element4);
3374
+ orig._attachElementToTree.call(this, element3);
3375
3375
  },
3376
3376
  _appendElement(token, namespaceURI) {
3377
3377
  mxn.lastStartTagToken = token;
@@ -3646,22 +3646,22 @@ var require_default = __commonJS({
3646
3646
  node.parentNode = null;
3647
3647
  }
3648
3648
  };
3649
- exports.insertText = function(parentNode, text3) {
3649
+ exports.insertText = function(parentNode, text2) {
3650
3650
  if (parentNode.childNodes.length) {
3651
3651
  const prevNode = parentNode.childNodes[parentNode.childNodes.length - 1];
3652
3652
  if (prevNode.nodeName === "#text") {
3653
- prevNode.value += text3;
3653
+ prevNode.value += text2;
3654
3654
  return;
3655
3655
  }
3656
3656
  }
3657
- appendChild(parentNode, createTextNode(text3));
3657
+ appendChild(parentNode, createTextNode(text2));
3658
3658
  };
3659
- exports.insertTextBefore = function(parentNode, text3, referenceNode) {
3659
+ exports.insertTextBefore = function(parentNode, text2, referenceNode) {
3660
3660
  const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
3661
3661
  if (prevNode && prevNode.nodeName === "#text") {
3662
- prevNode.value += text3;
3662
+ prevNode.value += text2;
3663
3663
  } else {
3664
- insertBefore(parentNode, createTextNode(text3), referenceNode);
3664
+ insertBefore(parentNode, createTextNode(text2), referenceNode);
3665
3665
  }
3666
3666
  };
3667
3667
  exports.adoptAttributes = function(recipient, attrs) {
@@ -3684,14 +3684,14 @@ var require_default = __commonJS({
3684
3684
  exports.getParentNode = function(node) {
3685
3685
  return node.parentNode;
3686
3686
  };
3687
- exports.getAttrList = function(element4) {
3688
- return element4.attrs;
3687
+ exports.getAttrList = function(element3) {
3688
+ return element3.attrs;
3689
3689
  };
3690
- exports.getTagName = function(element4) {
3691
- return element4.tagName;
3690
+ exports.getTagName = function(element3) {
3691
+ return element3.tagName;
3692
3692
  };
3693
- exports.getNamespaceURI = function(element4) {
3694
- return element4.namespaceURI;
3693
+ exports.getNamespaceURI = function(element3) {
3694
+ return element3.namespaceURI;
3695
3695
  };
3696
3696
  exports.getTextNodeContent = function(textNode) {
3697
3697
  return textNode.value;
@@ -4129,7 +4129,7 @@ var require_parser = __commonJS({
4129
4129
  var Mixin = require_mixin();
4130
4130
  var defaultTreeAdapter = require_default();
4131
4131
  var mergeOptions = require_merge_options();
4132
- var doctype3 = require_doctype();
4132
+ var doctype2 = require_doctype();
4133
4133
  var foreignContent = require_foreign_content();
4134
4134
  var ERR = require_error_codes();
4135
4135
  var unicode = require_unicode();
@@ -4573,27 +4573,27 @@ var require_parser = __commonJS({
4573
4573
  const systemId = token.systemId || "";
4574
4574
  this.treeAdapter.setDocumentType(this.document, name, publicId, systemId);
4575
4575
  }
4576
- _attachElementToTree(element4) {
4576
+ _attachElementToTree(element3) {
4577
4577
  if (this._shouldFosterParentOnInsertion()) {
4578
- this._fosterParentElement(element4);
4578
+ this._fosterParentElement(element3);
4579
4579
  } else {
4580
4580
  const parent = this.openElements.currentTmplContent || this.openElements.current;
4581
- this.treeAdapter.appendChild(parent, element4);
4581
+ this.treeAdapter.appendChild(parent, element3);
4582
4582
  }
4583
4583
  }
4584
4584
  _appendElement(token, namespaceURI) {
4585
- const element4 = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
4586
- this._attachElementToTree(element4);
4585
+ const element3 = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
4586
+ this._attachElementToTree(element3);
4587
4587
  }
4588
4588
  _insertElement(token, namespaceURI) {
4589
- const element4 = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
4590
- this._attachElementToTree(element4);
4591
- this.openElements.push(element4);
4589
+ const element3 = this.treeAdapter.createElement(token.tagName, namespaceURI, token.attrs);
4590
+ this._attachElementToTree(element3);
4591
+ this.openElements.push(element3);
4592
4592
  }
4593
4593
  _insertFakeElement(tagName) {
4594
- const element4 = this.treeAdapter.createElement(tagName, NS.HTML, []);
4595
- this._attachElementToTree(element4);
4596
- this.openElements.push(element4);
4594
+ const element3 = this.treeAdapter.createElement(tagName, NS.HTML, []);
4595
+ this._attachElementToTree(element3);
4596
+ this.openElements.push(element3);
4597
4597
  }
4598
4598
  _insertTemplate(token) {
4599
4599
  const tmpl = this.treeAdapter.createElement(token.tagName, NS.HTML, token.attrs);
@@ -4603,9 +4603,9 @@ var require_parser = __commonJS({
4603
4603
  this.openElements.push(tmpl);
4604
4604
  }
4605
4605
  _insertFakeRootElement() {
4606
- const element4 = this.treeAdapter.createElement($.HTML, NS.HTML, []);
4607
- this.treeAdapter.appendChild(this.openElements.current, element4);
4608
- this.openElements.push(element4);
4606
+ const element3 = this.treeAdapter.createElement($.HTML, NS.HTML, []);
4607
+ this.treeAdapter.appendChild(this.openElements.current, element3);
4608
+ this.openElements.push(element3);
4609
4609
  }
4610
4610
  _appendCommentNode(token, parent) {
4611
4611
  const commentNode = this.treeAdapter.createCommentNode(token.data);
@@ -4680,10 +4680,10 @@ var require_parser = __commonJS({
4680
4680
  }
4681
4681
  }
4682
4682
  //Integration points
4683
- _isIntegrationPoint(element4, foreignNS) {
4684
- const tn = this.treeAdapter.getTagName(element4);
4685
- const ns = this.treeAdapter.getNamespaceURI(element4);
4686
- const attrs = this.treeAdapter.getAttrList(element4);
4683
+ _isIntegrationPoint(element3, foreignNS) {
4684
+ const tn = this.treeAdapter.getTagName(element3);
4685
+ const ns = this.treeAdapter.getNamespaceURI(element3);
4686
+ const attrs = this.treeAdapter.getAttrList(element3);
4687
4687
  return foreignContent.isIntegrationPoint(tn, ns, attrs, foreignNS);
4688
4688
  }
4689
4689
  //Active formatting elements reconstruction
@@ -4721,14 +4721,14 @@ var require_parser = __commonJS({
4721
4721
  //Insertion modes
4722
4722
  _resetInsertionMode() {
4723
4723
  for (let i = this.openElements.stackTop, last = false; i >= 0; i--) {
4724
- let element4 = this.openElements.items[i];
4724
+ let element3 = this.openElements.items[i];
4725
4725
  if (i === 0) {
4726
4726
  last = true;
4727
4727
  if (this.fragmentContext) {
4728
- element4 = this.fragmentContext;
4728
+ element3 = this.fragmentContext;
4729
4729
  }
4730
4730
  }
4731
- const tn = this.treeAdapter.getTagName(element4);
4731
+ const tn = this.treeAdapter.getTagName(element3);
4732
4732
  const newInsertionMode = INSERTION_MODE_RESET_MAP[tn];
4733
4733
  if (newInsertionMode) {
4734
4734
  this.insertionMode = newInsertionMode;
@@ -4780,8 +4780,8 @@ var require_parser = __commonJS({
4780
4780
  this.currentTmplInsertionMode = this.tmplInsertionModeStack[this.tmplInsertionModeStackTop];
4781
4781
  }
4782
4782
  //Foster parenting
4783
- _isElementCausesFosterParenting(element4) {
4784
- const tn = this.treeAdapter.getTagName(element4);
4783
+ _isElementCausesFosterParenting(element3) {
4784
+ const tn = this.treeAdapter.getTagName(element3);
4785
4785
  return tn === $.TABLE || tn === $.TBODY || tn === $.TFOOT || tn === $.THEAD || tn === $.TR;
4786
4786
  }
4787
4787
  _shouldFosterParentOnInsertion() {
@@ -4814,12 +4814,12 @@ var require_parser = __commonJS({
4814
4814
  }
4815
4815
  return location2;
4816
4816
  }
4817
- _fosterParentElement(element4) {
4817
+ _fosterParentElement(element3) {
4818
4818
  const location2 = this._findFosterParentingLocation();
4819
4819
  if (location2.beforeElement) {
4820
- this.treeAdapter.insertBefore(location2.parent, element4, location2.beforeElement);
4820
+ this.treeAdapter.insertBefore(location2.parent, element3, location2.beforeElement);
4821
4821
  } else {
4822
- this.treeAdapter.appendChild(location2.parent, element4);
4822
+ this.treeAdapter.appendChild(location2.parent, element3);
4823
4823
  }
4824
4824
  }
4825
4825
  _fosterParentText(chars) {
@@ -4831,9 +4831,9 @@ var require_parser = __commonJS({
4831
4831
  }
4832
4832
  }
4833
4833
  //Special elements
4834
- _isSpecialElement(element4) {
4835
- const tn = this.treeAdapter.getTagName(element4);
4836
- const ns = this.treeAdapter.getNamespaceURI(element4);
4834
+ _isSpecialElement(element3) {
4835
+ const tn = this.treeAdapter.getTagName(element3);
4836
+ const ns = this.treeAdapter.getNamespaceURI(element3);
4837
4837
  return HTML.SPECIAL_ELEMENTS[ns][tn];
4838
4838
  }
4839
4839
  };
@@ -4855,12 +4855,12 @@ var require_parser = __commonJS({
4855
4855
  function aaObtainFurthestBlock(p2, formattingElementEntry) {
4856
4856
  let furthestBlock = null;
4857
4857
  for (let i = p2.openElements.stackTop; i >= 0; i--) {
4858
- const element4 = p2.openElements.items[i];
4859
- if (element4 === formattingElementEntry.element) {
4858
+ const element3 = p2.openElements.items[i];
4859
+ if (element3 === formattingElementEntry.element) {
4860
4860
  break;
4861
4861
  }
4862
- if (p2._isSpecialElement(element4)) {
4863
- furthestBlock = element4;
4862
+ if (p2._isSpecialElement(element3)) {
4863
+ furthestBlock = element3;
4864
4864
  }
4865
4865
  }
4866
4866
  if (!furthestBlock) {
@@ -4872,24 +4872,24 @@ var require_parser = __commonJS({
4872
4872
  function aaInnerLoop(p2, furthestBlock, formattingElement) {
4873
4873
  let lastElement = furthestBlock;
4874
4874
  let nextElement = p2.openElements.getCommonAncestor(furthestBlock);
4875
- for (let i = 0, element4 = nextElement; element4 !== formattingElement; i++, element4 = nextElement) {
4876
- nextElement = p2.openElements.getCommonAncestor(element4);
4877
- const elementEntry = p2.activeFormattingElements.getElementEntry(element4);
4875
+ for (let i = 0, element3 = nextElement; element3 !== formattingElement; i++, element3 = nextElement) {
4876
+ nextElement = p2.openElements.getCommonAncestor(element3);
4877
+ const elementEntry = p2.activeFormattingElements.getElementEntry(element3);
4878
4878
  const counterOverflow = elementEntry && i >= AA_INNER_LOOP_ITER;
4879
4879
  const shouldRemoveFromOpenElements = !elementEntry || counterOverflow;
4880
4880
  if (shouldRemoveFromOpenElements) {
4881
4881
  if (counterOverflow) {
4882
4882
  p2.activeFormattingElements.removeEntry(elementEntry);
4883
4883
  }
4884
- p2.openElements.remove(element4);
4884
+ p2.openElements.remove(element3);
4885
4885
  } else {
4886
- element4 = aaRecreateElementFromEntry(p2, elementEntry);
4886
+ element3 = aaRecreateElementFromEntry(p2, elementEntry);
4887
4887
  if (lastElement === furthestBlock) {
4888
4888
  p2.activeFormattingElements.bookmark = elementEntry;
4889
4889
  }
4890
4890
  p2.treeAdapter.detachNode(lastElement);
4891
- p2.treeAdapter.appendChild(element4, lastElement);
4892
- lastElement = element4;
4891
+ p2.treeAdapter.appendChild(element3, lastElement);
4892
+ lastElement = element3;
4893
4893
  }
4894
4894
  }
4895
4895
  return lastElement;
@@ -4965,8 +4965,8 @@ var require_parser = __commonJS({
4965
4965
  }
4966
4966
  function doctypeInInitialMode(p2, token) {
4967
4967
  p2._setDocumentType(token);
4968
- const mode = token.forceQuirks ? HTML.DOCUMENT_MODE.QUIRKS : doctype3.getDocumentMode(token);
4969
- if (!doctype3.isConforming(token)) {
4968
+ const mode = token.forceQuirks ? HTML.DOCUMENT_MODE.QUIRKS : doctype2.getDocumentMode(token);
4969
+ if (!doctype2.isConforming(token)) {
4970
4970
  p2._err(ERR.nonConformingDoctype);
4971
4971
  }
4972
4972
  p2.treeAdapter.setDocumentMode(p2.document, mode);
@@ -5221,8 +5221,8 @@ var require_parser = __commonJS({
5221
5221
  p2.framesetOk = false;
5222
5222
  const tn = token.tagName;
5223
5223
  for (let i = p2.openElements.stackTop; i >= 0; i--) {
5224
- const element4 = p2.openElements.items[i];
5225
- const elementTn = p2.treeAdapter.getTagName(element4);
5224
+ const element3 = p2.openElements.items[i];
5225
+ const elementTn = p2.treeAdapter.getTagName(element3);
5226
5226
  let closeTn = null;
5227
5227
  if (tn === $.LI && elementTn === $.LI) {
5228
5228
  closeTn = $.LI;
@@ -5234,7 +5234,7 @@ var require_parser = __commonJS({
5234
5234
  p2.openElements.popUntilTagNamePopped(closeTn);
5235
5235
  break;
5236
5236
  }
5237
- if (elementTn !== $.ADDRESS && elementTn !== $.DIV && elementTn !== $.P && p2._isSpecialElement(element4)) {
5237
+ if (elementTn !== $.ADDRESS && elementTn !== $.DIV && elementTn !== $.P && p2._isSpecialElement(element3)) {
5238
5238
  break;
5239
5239
  }
5240
5240
  }
@@ -5669,13 +5669,13 @@ var require_parser = __commonJS({
5669
5669
  function genericEndTagInBody(p2, token) {
5670
5670
  const tn = token.tagName;
5671
5671
  for (let i = p2.openElements.stackTop; i > 0; i--) {
5672
- const element4 = p2.openElements.items[i];
5673
- if (p2.treeAdapter.getTagName(element4) === tn) {
5672
+ const element3 = p2.openElements.items[i];
5673
+ if (p2.treeAdapter.getTagName(element3) === tn) {
5674
5674
  p2.openElements.generateImpliedEndTagsWithExclusion(tn);
5675
- p2.openElements.popUntilElementPopped(element4);
5675
+ p2.openElements.popUntilElementPopped(element3);
5676
5676
  break;
5677
5677
  }
5678
- if (p2._isSpecialElement(element4)) {
5678
+ if (p2._isSpecialElement(element3)) {
5679
5679
  break;
5680
5680
  }
5681
5681
  }
@@ -6354,13 +6354,13 @@ var require_parser = __commonJS({
6354
6354
  }
6355
6355
  function endTagInForeignContent(p2, token) {
6356
6356
  for (let i = p2.openElements.stackTop; i > 0; i--) {
6357
- const element4 = p2.openElements.items[i];
6358
- if (p2.treeAdapter.getNamespaceURI(element4) === NS.HTML) {
6357
+ const element3 = p2.openElements.items[i];
6358
+ if (p2.treeAdapter.getNamespaceURI(element3) === NS.HTML) {
6359
6359
  p2._processToken(token);
6360
6360
  break;
6361
6361
  }
6362
- if (p2.treeAdapter.getTagName(element4).toLowerCase() === token.tagName) {
6363
- p2.openElements.popUntilElementPopped(element4);
6362
+ if (p2.treeAdapter.getTagName(element3).toLowerCase() === token.tagName) {
6363
+ p2.openElements.popUntilElementPopped(element3);
6364
6364
  break;
6365
6365
  }
6366
6366
  }
@@ -7697,460 +7697,25 @@ var htmlVoidElements = [
7697
7697
  "wbr"
7698
7698
  ];
7699
7699
 
7700
- // ../../node_modules/hast-util-is-element/index.js
7701
- var isElement = (
7702
- /**
7703
- * Check if a node is an element and passes a test.
7704
- * When a `parent` node is known the `index` of node should also be given.
7705
- *
7706
- * @type {(
7707
- * (() => false) &
7708
- * (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) &
7709
- * ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
7710
- * )}
7711
- */
7712
- /**
7713
- * Check if a node passes a test.
7714
- * When a `parent` node is known the `index` of node should also be given.
7715
- *
7716
- * @param {unknown} [node] Node to check
7717
- * @param {Test} [test] When nullish, checks if `node` is a `Node`.
7718
- * When `string`, works like passing `function (node) {return node.type === test}`.
7719
- * When `function` checks if function passed the node is true.
7720
- * When `array`, checks any one of the subtests pass.
7721
- * @param {number} [index] Position of `node` in `parent`
7722
- * @param {Parent} [parent] Parent of `node`
7723
- * @param {unknown} [context] Context object to invoke `test` with
7724
- * @returns {boolean} Whether test passed and `node` is an `Element` (object with `type` set to `element` and `tagName` set to a non-empty string).
7725
- */
7726
- // eslint-disable-next-line max-params
7727
- function(node, test, index2, parent, context) {
7728
- const check = convertElement(test);
7729
- if (index2 !== void 0 && index2 !== null && (typeof index2 !== "number" || index2 < 0 || index2 === Number.POSITIVE_INFINITY)) {
7730
- throw new Error("Expected positive finite index for child node");
7731
- }
7732
- if (parent !== void 0 && parent !== null && (!parent.type || !parent.children)) {
7733
- throw new Error("Expected parent node");
7734
- }
7735
- if (!node || !node.type || typeof node.type !== "string") {
7736
- return false;
7737
- }
7738
- if ((parent === void 0 || parent === null) !== (index2 === void 0 || index2 === null)) {
7739
- throw new Error("Expected both parent and index");
7740
- }
7741
- return check.call(context, node, index2, parent);
7742
- }
7743
- );
7744
- var convertElement = (
7745
- /**
7746
- * @type {(
7747
- * (<T extends Element>(test: T['tagName']|TestFunctionPredicate<T>) => AssertPredicate<T>) &
7748
- * ((test?: Test) => AssertAnything)
7749
- * )}
7750
- */
7751
- /**
7752
- * Generate an assertion from a check.
7753
- * @param {Test} [test]
7754
- * When nullish, checks if `node` is a `Node`.
7755
- * When `string`, works like passing `function (node) {return node.type === test}`.
7756
- * When `function` checks if function passed the node is true.
7757
- * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
7758
- * When `array`, checks any one of the subtests pass.
7759
- * @returns {AssertAnything}
7760
- */
7761
- function(test) {
7762
- if (test === void 0 || test === null) {
7763
- return element;
7764
- }
7765
- if (typeof test === "string") {
7766
- return tagNameFactory(test);
7767
- }
7768
- if (typeof test === "object") {
7769
- return anyFactory(test);
7770
- }
7771
- if (typeof test === "function") {
7772
- return castFactory(test);
7773
- }
7774
- throw new Error("Expected function, string, or array as test");
7775
- }
7776
- );
7777
- function anyFactory(tests) {
7778
- const checks2 = [];
7779
- let index2 = -1;
7780
- while (++index2 < tests.length) {
7781
- checks2[index2] = convertElement(tests[index2]);
7782
- }
7783
- return castFactory(any);
7784
- function any(...parameters) {
7785
- let index3 = -1;
7786
- while (++index3 < checks2.length) {
7787
- if (checks2[index3].call(this, ...parameters)) {
7788
- return true;
7789
- }
7790
- }
7791
- return false;
7792
- }
7793
- }
7794
- function tagNameFactory(check) {
7795
- return tagName;
7796
- function tagName(node) {
7797
- return element(node) && node.tagName === check;
7798
- }
7799
- }
7800
- function castFactory(check) {
7801
- return assertion;
7802
- function assertion(node, ...parameters) {
7803
- return element(node) && Boolean(check.call(this, node, ...parameters));
7804
- }
7805
- }
7806
- function element(node) {
7807
- return Boolean(
7808
- node && typeof node === "object" && // @ts-expect-error Looks like a node.
7809
- node.type === "element" && // @ts-expect-error Looks like an element.
7810
- typeof node.tagName === "string"
7811
- );
7812
- }
7813
-
7814
- // ../../node_modules/unist-util-is/index.js
7815
- var convert = (
7816
- /**
7817
- * @type {(
7818
- * (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
7819
- * ((test?: Test) => AssertAnything)
7820
- * )}
7821
- */
7822
- /**
7823
- * Generate an assertion from a check.
7824
- * @param {Test} [test]
7825
- * When nullish, checks if `node` is a `Node`.
7826
- * When `string`, works like passing `function (node) {return node.type === test}`.
7827
- * When `function` checks if function passed the node is true.
7828
- * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
7829
- * When `array`, checks any one of the subtests pass.
7830
- * @returns {AssertAnything}
7831
- */
7832
- function(test) {
7833
- if (test === void 0 || test === null) {
7834
- return ok;
7835
- }
7836
- if (typeof test === "string") {
7837
- return typeFactory(test);
7838
- }
7839
- if (typeof test === "object") {
7840
- return Array.isArray(test) ? anyFactory2(test) : propsFactory(test);
7841
- }
7842
- if (typeof test === "function") {
7843
- return castFactory2(test);
7844
- }
7845
- throw new Error("Expected function, string, or object as test");
7846
- }
7847
- );
7848
- function anyFactory2(tests) {
7849
- const checks2 = [];
7850
- let index2 = -1;
7851
- while (++index2 < tests.length) {
7852
- checks2[index2] = convert(tests[index2]);
7853
- }
7854
- return castFactory2(any);
7855
- function any(...parameters) {
7856
- let index3 = -1;
7857
- while (++index3 < checks2.length) {
7858
- if (checks2[index3].call(this, ...parameters))
7859
- return true;
7860
- }
7861
- return false;
7862
- }
7863
- }
7864
- function propsFactory(check) {
7865
- return castFactory2(all2);
7866
- function all2(node) {
7867
- let key2;
7868
- for (key2 in check) {
7869
- if (node[key2] !== check[key2])
7870
- return false;
7871
- }
7872
- return true;
7873
- }
7874
- }
7875
- function typeFactory(check) {
7876
- return castFactory2(type);
7877
- function type(node) {
7878
- return node && node.type === check;
7879
- }
7880
- }
7881
- function castFactory2(check) {
7882
- return assertion;
7883
- function assertion(...parameters) {
7884
- return Boolean(check.call(this, ...parameters));
7885
- }
7886
- }
7887
- function ok() {
7888
- return true;
7889
- }
7890
-
7891
- // ../../node_modules/hast-util-to-html/lib/omission/util/comment.js
7892
- var comment = convert("comment");
7893
-
7894
- // ../../node_modules/hast-util-whitespace/index.js
7895
- function whitespace(thing) {
7896
- var value = (
7897
- // @ts-ignore looks like a node.
7898
- thing && typeof thing === "object" && thing.type === "text" ? (
7899
- // @ts-ignore looks like a text.
7900
- thing.value || ""
7901
- ) : thing
7902
- );
7903
- return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
7904
- }
7905
-
7906
- // ../../node_modules/hast-util-to-html/lib/omission/util/siblings.js
7907
- var siblingAfter = siblings(1);
7908
- var siblingBefore = siblings(-1);
7909
- function siblings(increment2) {
7910
- return sibling;
7911
- function sibling(parent, index2, includeWhitespace) {
7912
- const siblings2 = parent && parent.children;
7913
- let offset = index2 + increment2;
7914
- let next = siblings2 && siblings2[offset];
7915
- if (!includeWhitespace) {
7916
- while (next && whitespace(next)) {
7917
- offset += increment2;
7918
- next = siblings2[offset];
7919
- }
7920
- }
7921
- return next;
7922
- }
7923
- }
7924
-
7925
- // ../../node_modules/hast-util-to-html/lib/omission/util/whitespace-start.js
7926
- var isText = convert("text");
7927
- function whitespaceStart(node) {
7928
- return isText(node) && whitespace(node.value.charAt(0));
7929
- }
7930
-
7931
- // ../../node_modules/hast-util-to-html/lib/omission/omission.js
7700
+ // ../../node_modules/zwitch/index.js
7932
7701
  var own2 = {}.hasOwnProperty;
7933
- function omission(handlers2) {
7934
- return omit;
7935
- function omit(node, index2, parent) {
7936
- return own2.call(handlers2, node.tagName) && handlers2[node.tagName](node, index2, parent);
7937
- }
7938
- }
7939
-
7940
- // ../../node_modules/hast-util-to-html/lib/omission/closing.js
7941
- var closing = omission({
7942
- html: html3,
7943
- head: headOrColgroupOrCaption,
7944
- body,
7945
- p,
7946
- li,
7947
- dt,
7948
- dd,
7949
- rt: rubyElement,
7950
- rp: rubyElement,
7951
- optgroup,
7952
- option,
7953
- menuitem,
7954
- colgroup: headOrColgroupOrCaption,
7955
- caption: headOrColgroupOrCaption,
7956
- thead,
7957
- tbody,
7958
- tfoot,
7959
- tr,
7960
- td: cells,
7961
- th: cells
7962
- });
7963
- function headOrColgroupOrCaption(_2, index2, parent) {
7964
- const next = siblingAfter(parent, index2, true);
7965
- return !next || !comment(next) && !whitespaceStart(next);
7966
- }
7967
- function html3(_2, index2, parent) {
7968
- const next = siblingAfter(parent, index2);
7969
- return !next || !comment(next);
7970
- }
7971
- function body(_2, index2, parent) {
7972
- const next = siblingAfter(parent, index2);
7973
- return !next || !comment(next);
7974
- }
7975
- function p(_2, index2, parent) {
7976
- const next = siblingAfter(parent, index2);
7977
- return next ? isElement(next, [
7978
- "address",
7979
- "article",
7980
- "aside",
7981
- "blockquote",
7982
- "details",
7983
- "div",
7984
- "dl",
7985
- "fieldset",
7986
- "figcaption",
7987
- "figure",
7988
- "footer",
7989
- "form",
7990
- "h1",
7991
- "h2",
7992
- "h3",
7993
- "h4",
7994
- "h5",
7995
- "h6",
7996
- "header",
7997
- "hgroup",
7998
- "hr",
7999
- "main",
8000
- "menu",
8001
- "nav",
8002
- "ol",
8003
- "p",
8004
- "pre",
8005
- "section",
8006
- "table",
8007
- "ul"
8008
- ]) : !parent || // Confusing parent.
8009
- !isElement(parent, [
8010
- "a",
8011
- "audio",
8012
- "del",
8013
- "ins",
8014
- "map",
8015
- "noscript",
8016
- "video"
8017
- ]);
8018
- }
8019
- function li(_2, index2, parent) {
8020
- const next = siblingAfter(parent, index2);
8021
- return !next || isElement(next, "li");
8022
- }
8023
- function dt(_2, index2, parent) {
8024
- const next = siblingAfter(parent, index2);
8025
- return next && isElement(next, ["dt", "dd"]);
8026
- }
8027
- function dd(_2, index2, parent) {
8028
- const next = siblingAfter(parent, index2);
8029
- return !next || isElement(next, ["dt", "dd"]);
8030
- }
8031
- function rubyElement(_2, index2, parent) {
8032
- const next = siblingAfter(parent, index2);
8033
- return !next || isElement(next, ["rp", "rt"]);
8034
- }
8035
- function optgroup(_2, index2, parent) {
8036
- const next = siblingAfter(parent, index2);
8037
- return !next || isElement(next, "optgroup");
8038
- }
8039
- function option(_2, index2, parent) {
8040
- const next = siblingAfter(parent, index2);
8041
- return !next || isElement(next, ["option", "optgroup"]);
8042
- }
8043
- function menuitem(_2, index2, parent) {
8044
- const next = siblingAfter(parent, index2);
8045
- return !next || isElement(next, ["menuitem", "hr", "menu"]);
8046
- }
8047
- function thead(_2, index2, parent) {
8048
- const next = siblingAfter(parent, index2);
8049
- return next && isElement(next, ["tbody", "tfoot"]);
8050
- }
8051
- function tbody(_2, index2, parent) {
8052
- const next = siblingAfter(parent, index2);
8053
- return !next || isElement(next, ["tbody", "tfoot"]);
8054
- }
8055
- function tfoot(_2, index2, parent) {
8056
- return !siblingAfter(parent, index2);
8057
- }
8058
- function tr(_2, index2, parent) {
8059
- const next = siblingAfter(parent, index2);
8060
- return !next || isElement(next, "tr");
8061
- }
8062
- function cells(_2, index2, parent) {
8063
- const next = siblingAfter(parent, index2);
8064
- return !next || isElement(next, ["td", "th"]);
8065
- }
8066
-
8067
- // ../../node_modules/hast-util-to-html/lib/omission/opening.js
8068
- var opening = omission({
8069
- html: html4,
8070
- head,
8071
- body: body2,
8072
- colgroup,
8073
- tbody: tbody2
8074
- });
8075
- function html4(node) {
8076
- const head2 = siblingAfter(node, -1);
8077
- return !head2 || !comment(head2);
8078
- }
8079
- function head(node) {
8080
- const children = node.children;
8081
- const seen = [];
8082
- let index2 = -1;
8083
- let child;
8084
- while (++index2 < children.length) {
8085
- child = children[index2];
8086
- if (isElement(child, ["title", "base"])) {
8087
- if (seen.includes(child.tagName))
8088
- return false;
8089
- seen.push(child.tagName);
8090
- }
8091
- }
8092
- return children.length > 0;
8093
- }
8094
- function body2(node) {
8095
- const head2 = siblingAfter(node, -1, true);
8096
- return !head2 || !comment(head2) && !whitespaceStart(head2) && !isElement(head2, ["meta", "link", "script", "style", "template"]);
8097
- }
8098
- function colgroup(node, index2, parent) {
8099
- const previous = siblingBefore(parent, index2);
8100
- const head2 = siblingAfter(node, -1, true);
8101
- if (isElement(previous, "colgroup") && closing(previous, parent.children.indexOf(previous), parent)) {
8102
- return false;
8103
- }
8104
- return head2 && isElement(head2, "col");
8105
- }
8106
- function tbody2(node, index2, parent) {
8107
- const previous = siblingBefore(parent, index2);
8108
- const head2 = siblingAfter(node, -1);
8109
- if (isElement(previous, ["thead", "tbody"]) && closing(previous, parent.children.indexOf(previous), parent)) {
8110
- return false;
8111
- }
8112
- return head2 && isElement(head2, "tr");
8113
- }
8114
-
8115
- // ../../node_modules/hast-util-to-html/lib/omission/index.js
8116
- var omission2 = { opening, closing };
8117
-
8118
- // ../../node_modules/space-separated-tokens/index.js
8119
- function parse(value) {
8120
- const input = String(value || "").trim();
8121
- return input ? input.split(/[ \t\n\r\f]+/g) : [];
8122
- }
8123
- function stringify(values) {
8124
- return values.join(" ").trim();
8125
- }
8126
-
8127
- // ../../node_modules/comma-separated-tokens/index.js
8128
- function parse2(value) {
8129
- const tokens = [];
8130
- const input = String(value || "");
8131
- let index2 = input.indexOf(",");
8132
- let start = 0;
8133
- let end = false;
8134
- while (!end) {
8135
- if (index2 === -1) {
8136
- index2 = input.length;
8137
- end = true;
7702
+ function zwitch(key2, options) {
7703
+ const settings = options || {};
7704
+ function one3(value, ...parameters) {
7705
+ let fn = one3.invalid;
7706
+ const handlers = one3.handlers;
7707
+ if (value && own2.call(value, key2)) {
7708
+ const id = String(value[key2]);
7709
+ fn = own2.call(handlers, id) ? handlers[id] : one3.unknown;
8138
7710
  }
8139
- const token = input.slice(start, index2).trim();
8140
- if (token || !end) {
8141
- tokens.push(token);
7711
+ if (fn) {
7712
+ return fn.call(this, value, ...parameters);
8142
7713
  }
8143
- start = index2 + 1;
8144
- index2 = input.indexOf(",", start);
8145
7714
  }
8146
- return tokens;
8147
- }
8148
- function stringify2(values, options) {
8149
- const settings = options || {};
8150
- const input = values[values.length - 1] === "" ? [...values, ""] : values;
8151
- return input.join(
8152
- (settings.padRight ? " " : "") + "," + (settings.padLeft === false ? "" : " ")
8153
- ).trim();
7715
+ one3.handlers = settings.handlers || {};
7716
+ one3.invalid = settings.invalid;
7717
+ one3.unknown = settings.unknown;
7718
+ return one3;
8154
7719
  }
8155
7720
 
8156
7721
  // ../../node_modules/stringify-entities/lib/core.js
@@ -8167,17 +7732,17 @@ function core(value, options) {
8167
7732
  /[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,
8168
7733
  basic2
8169
7734
  );
8170
- function surrogate(pair, index2, all2) {
7735
+ function surrogate(pair, index2, all3) {
8171
7736
  return options.format(
8172
7737
  (pair.charCodeAt(0) - 55296) * 1024 + pair.charCodeAt(1) - 56320 + 65536,
8173
- all2.charCodeAt(index2 + 2),
7738
+ all3.charCodeAt(index2 + 2),
8174
7739
  options
8175
7740
  );
8176
7741
  }
8177
- function basic2(character, index2, all2) {
7742
+ function basic2(character, index2, all3) {
8178
7743
  return options.format(
8179
7744
  character.charCodeAt(0),
8180
- all2.charCodeAt(index2 + 1),
7745
+ all3.charCodeAt(index2 + 1),
8181
7746
  options
8182
7747
  );
8183
7748
  }
@@ -8590,61 +8155,295 @@ for (key in characterEntitiesHtml4) {
8590
8155
  characters[characterEntitiesHtml4[key]] = key;
8591
8156
  }
8592
8157
  }
8593
- function toNamed(code, next, omit, attribute) {
8594
- const character = String.fromCharCode(code);
8595
- if (own3.call(characters, character)) {
8596
- const name = characters[character];
8597
- const value = "&" + name;
8598
- if (omit && characterEntitiesLegacy.includes(name) && !dangerous.includes(name) && (!attribute || next && next !== 61 && /[^\da-z]/i.test(String.fromCharCode(next)))) {
8599
- return value;
8600
- }
8601
- return value + ";";
8602
- }
8603
- return "";
8158
+ function toNamed(code, next, omit, attribute) {
8159
+ const character = String.fromCharCode(code);
8160
+ if (own3.call(characters, character)) {
8161
+ const name = characters[character];
8162
+ const value = "&" + name;
8163
+ if (omit && characterEntitiesLegacy.includes(name) && !dangerous.includes(name) && (!attribute || next && next !== 61 && /[^\da-z]/i.test(String.fromCharCode(next)))) {
8164
+ return value;
8165
+ }
8166
+ return value + ";";
8167
+ }
8168
+ return "";
8169
+ }
8170
+
8171
+ // ../../node_modules/stringify-entities/lib/util/format-smart.js
8172
+ function formatSmart(code, next, options) {
8173
+ let numeric = toHexadecimal(code, next, options.omitOptionalSemicolons);
8174
+ let named;
8175
+ if (options.useNamedReferences || options.useShortestReferences) {
8176
+ named = toNamed(
8177
+ code,
8178
+ next,
8179
+ options.omitOptionalSemicolons,
8180
+ options.attribute
8181
+ );
8182
+ }
8183
+ if ((options.useShortestReferences || !named) && options.useShortestReferences) {
8184
+ const decimal = toDecimal(code, next, options.omitOptionalSemicolons);
8185
+ if (decimal.length < numeric.length) {
8186
+ numeric = decimal;
8187
+ }
8188
+ }
8189
+ return named && (!options.useShortestReferences || named.length < numeric.length) ? named : numeric;
8190
+ }
8191
+
8192
+ // ../../node_modules/stringify-entities/lib/index.js
8193
+ function stringifyEntities(value, options) {
8194
+ return core(value, Object.assign({ format: formatSmart }, options));
8195
+ }
8196
+
8197
+ // ../../node_modules/hast-util-to-html/lib/handle/comment.js
8198
+ function comment(node, _1, _2, state) {
8199
+ return state.settings.bogusComments ? "<?" + stringifyEntities(
8200
+ node.value,
8201
+ Object.assign({}, state.settings.characterReferences, { subset: [">"] })
8202
+ ) + ">" : "<!--" + node.value.replace(/^>|^->|<!--|-->|--!>|<!-$/g, encode2) + "-->";
8203
+ function encode2($0) {
8204
+ return stringifyEntities(
8205
+ $0,
8206
+ Object.assign({}, state.settings.characterReferences, {
8207
+ subset: ["<", ">"]
8208
+ })
8209
+ );
8210
+ }
8211
+ }
8212
+
8213
+ // ../../node_modules/hast-util-to-html/lib/handle/doctype.js
8214
+ function doctype(_1, _2, _3, state) {
8215
+ return "<!" + (state.settings.upperDoctype ? "DOCTYPE" : "doctype") + (state.settings.tightDoctype ? "" : " ") + "html>";
8216
+ }
8217
+
8218
+ // ../../node_modules/ccount/index.js
8219
+ function ccount(value, character) {
8220
+ const source = String(value);
8221
+ if (typeof character !== "string") {
8222
+ throw new TypeError("Expected character");
8223
+ }
8224
+ let count = 0;
8225
+ let index2 = source.indexOf(character);
8226
+ while (index2 !== -1) {
8227
+ count++;
8228
+ index2 = source.indexOf(character, index2 + character.length);
8229
+ }
8230
+ return count;
8231
+ }
8232
+
8233
+ // ../../node_modules/comma-separated-tokens/index.js
8234
+ function parse(value) {
8235
+ const tokens = [];
8236
+ const input = String(value || "");
8237
+ let index2 = input.indexOf(",");
8238
+ let start = 0;
8239
+ let end = false;
8240
+ while (!end) {
8241
+ if (index2 === -1) {
8242
+ index2 = input.length;
8243
+ end = true;
8244
+ }
8245
+ const token = input.slice(start, index2).trim();
8246
+ if (token || !end) {
8247
+ tokens.push(token);
8248
+ }
8249
+ start = index2 + 1;
8250
+ index2 = input.indexOf(",", start);
8251
+ }
8252
+ return tokens;
8253
+ }
8254
+ function stringify(values, options) {
8255
+ const settings = options || {};
8256
+ const input = values[values.length - 1] === "" ? [...values, ""] : values;
8257
+ return input.join(
8258
+ (settings.padRight ? " " : "") + "," + (settings.padLeft === false ? "" : " ")
8259
+ ).trim();
8260
+ }
8261
+
8262
+ // ../../node_modules/space-separated-tokens/index.js
8263
+ function parse2(value) {
8264
+ const input = String(value || "").trim();
8265
+ return input ? input.split(/[ \t\n\r\f]+/g) : [];
8266
+ }
8267
+ function stringify2(values) {
8268
+ return values.join(" ").trim();
8269
+ }
8270
+
8271
+ // ../../node_modules/hast-util-whitespace/index.js
8272
+ function whitespace(thing) {
8273
+ const value = (
8274
+ // @ts-expect-error looks like a node.
8275
+ thing && typeof thing === "object" && thing.type === "text" ? (
8276
+ // @ts-expect-error looks like a text.
8277
+ thing.value || ""
8278
+ ) : thing
8279
+ );
8280
+ return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
8281
+ }
8282
+
8283
+ // ../../node_modules/hast-util-to-html/lib/omission/util/siblings.js
8284
+ var siblingAfter = siblings(1);
8285
+ var siblingBefore = siblings(-1);
8286
+ function siblings(increment2) {
8287
+ return sibling;
8288
+ function sibling(parent, index2, includeWhitespace) {
8289
+ const siblings2 = parent ? parent.children : [];
8290
+ let offset = (index2 || 0) + increment2;
8291
+ let next = siblings2 && siblings2[offset];
8292
+ if (!includeWhitespace) {
8293
+ while (next && whitespace(next)) {
8294
+ offset += increment2;
8295
+ next = siblings2[offset];
8296
+ }
8297
+ }
8298
+ return next;
8299
+ }
8300
+ }
8301
+
8302
+ // ../../node_modules/hast-util-to-html/lib/omission/omission.js
8303
+ var own4 = {}.hasOwnProperty;
8304
+ function omission(handlers) {
8305
+ return omit;
8306
+ function omit(node, index2, parent) {
8307
+ return own4.call(handlers, node.tagName) && handlers[node.tagName](node, index2, parent);
8308
+ }
8309
+ }
8310
+
8311
+ // ../../node_modules/hast-util-to-html/lib/omission/closing.js
8312
+ var closing = omission({
8313
+ html: html3,
8314
+ head: headOrColgroupOrCaption,
8315
+ body,
8316
+ p,
8317
+ li,
8318
+ dt,
8319
+ dd,
8320
+ rt: rubyElement,
8321
+ rp: rubyElement,
8322
+ optgroup,
8323
+ option,
8324
+ menuitem,
8325
+ colgroup: headOrColgroupOrCaption,
8326
+ caption: headOrColgroupOrCaption,
8327
+ thead,
8328
+ tbody,
8329
+ tfoot,
8330
+ tr,
8331
+ td: cells,
8332
+ th: cells
8333
+ });
8334
+ function headOrColgroupOrCaption(_2, index2, parent) {
8335
+ const next = siblingAfter(parent, index2, true);
8336
+ return !next || next.type !== "comment" && !(next.type === "text" && whitespace(next.value.charAt(0)));
8337
+ }
8338
+ function html3(_2, index2, parent) {
8339
+ const next = siblingAfter(parent, index2);
8340
+ return !next || next.type !== "comment";
8341
+ }
8342
+ function body(_2, index2, parent) {
8343
+ const next = siblingAfter(parent, index2);
8344
+ return !next || next.type !== "comment";
8345
+ }
8346
+ function p(_2, index2, parent) {
8347
+ const next = siblingAfter(parent, index2);
8348
+ return next ? next.type === "element" && (next.tagName === "address" || next.tagName === "article" || next.tagName === "aside" || next.tagName === "blockquote" || next.tagName === "details" || next.tagName === "div" || next.tagName === "dl" || next.tagName === "fieldset" || next.tagName === "figcaption" || next.tagName === "figure" || next.tagName === "footer" || next.tagName === "form" || next.tagName === "h1" || next.tagName === "h2" || next.tagName === "h3" || next.tagName === "h4" || next.tagName === "h5" || next.tagName === "h6" || next.tagName === "header" || next.tagName === "hgroup" || next.tagName === "hr" || next.tagName === "main" || next.tagName === "menu" || next.tagName === "nav" || next.tagName === "ol" || next.tagName === "p" || next.tagName === "pre" || next.tagName === "section" || next.tagName === "table" || next.tagName === "ul") : !parent || // Confusing parent.
8349
+ !(parent.type === "element" && (parent.tagName === "a" || parent.tagName === "audio" || parent.tagName === "del" || parent.tagName === "ins" || parent.tagName === "map" || parent.tagName === "noscript" || parent.tagName === "video"));
8350
+ }
8351
+ function li(_2, index2, parent) {
8352
+ const next = siblingAfter(parent, index2);
8353
+ return !next || next.type === "element" && next.tagName === "li";
8354
+ }
8355
+ function dt(_2, index2, parent) {
8356
+ const next = siblingAfter(parent, index2);
8357
+ return next && next.type === "element" && (next.tagName === "dt" || next.tagName === "dd");
8358
+ }
8359
+ function dd(_2, index2, parent) {
8360
+ const next = siblingAfter(parent, index2);
8361
+ return !next || next.type === "element" && (next.tagName === "dt" || next.tagName === "dd");
8362
+ }
8363
+ function rubyElement(_2, index2, parent) {
8364
+ const next = siblingAfter(parent, index2);
8365
+ return !next || next.type === "element" && (next.tagName === "rp" || next.tagName === "rt");
8366
+ }
8367
+ function optgroup(_2, index2, parent) {
8368
+ const next = siblingAfter(parent, index2);
8369
+ return !next || next.type === "element" && next.tagName === "optgroup";
8370
+ }
8371
+ function option(_2, index2, parent) {
8372
+ const next = siblingAfter(parent, index2);
8373
+ return !next || next.type === "element" && (next.tagName === "option" || next.tagName === "optgroup");
8374
+ }
8375
+ function menuitem(_2, index2, parent) {
8376
+ const next = siblingAfter(parent, index2);
8377
+ return !next || next.type === "element" && (next.tagName === "menuitem" || next.tagName === "hr" || next.tagName === "menu");
8378
+ }
8379
+ function thead(_2, index2, parent) {
8380
+ const next = siblingAfter(parent, index2);
8381
+ return next && next.type === "element" && (next.tagName === "tbody" || next.tagName === "tfoot");
8382
+ }
8383
+ function tbody(_2, index2, parent) {
8384
+ const next = siblingAfter(parent, index2);
8385
+ return !next || next.type === "element" && (next.tagName === "tbody" || next.tagName === "tfoot");
8386
+ }
8387
+ function tfoot(_2, index2, parent) {
8388
+ return !siblingAfter(parent, index2);
8389
+ }
8390
+ function tr(_2, index2, parent) {
8391
+ const next = siblingAfter(parent, index2);
8392
+ return !next || next.type === "element" && next.tagName === "tr";
8393
+ }
8394
+ function cells(_2, index2, parent) {
8395
+ const next = siblingAfter(parent, index2);
8396
+ return !next || next.type === "element" && (next.tagName === "td" || next.tagName === "th");
8604
8397
  }
8605
8398
 
8606
- // ../../node_modules/stringify-entities/lib/util/format-smart.js
8607
- function formatSmart(code, next, options) {
8608
- let numeric = toHexadecimal(code, next, options.omitOptionalSemicolons);
8609
- let named;
8610
- if (options.useNamedReferences || options.useShortestReferences) {
8611
- named = toNamed(
8612
- code,
8613
- next,
8614
- options.omitOptionalSemicolons,
8615
- options.attribute
8616
- );
8617
- }
8618
- if ((options.useShortestReferences || !named) && options.useShortestReferences) {
8619
- const decimal = toDecimal(code, next, options.omitOptionalSemicolons);
8620
- if (decimal.length < numeric.length) {
8621
- numeric = decimal;
8399
+ // ../../node_modules/hast-util-to-html/lib/omission/opening.js
8400
+ var opening = omission({
8401
+ html: html4,
8402
+ head,
8403
+ body: body2,
8404
+ colgroup,
8405
+ tbody: tbody2
8406
+ });
8407
+ function html4(node) {
8408
+ const head2 = siblingAfter(node, -1);
8409
+ return !head2 || head2.type !== "comment";
8410
+ }
8411
+ function head(node) {
8412
+ const children = node.children;
8413
+ const seen = [];
8414
+ let index2 = -1;
8415
+ while (++index2 < children.length) {
8416
+ const child = children[index2];
8417
+ if (child.type === "element" && (child.tagName === "title" || child.tagName === "base")) {
8418
+ if (seen.includes(child.tagName))
8419
+ return false;
8420
+ seen.push(child.tagName);
8622
8421
  }
8623
8422
  }
8624
- return named && (!options.useShortestReferences || named.length < numeric.length) ? named : numeric;
8423
+ return children.length > 0;
8625
8424
  }
8626
-
8627
- // ../../node_modules/stringify-entities/lib/index.js
8628
- function stringifyEntities(value, options) {
8629
- return core(value, Object.assign({ format: formatSmart }, options));
8425
+ function body2(node) {
8426
+ const head2 = siblingAfter(node, -1, true);
8427
+ return !head2 || head2.type !== "comment" && !(head2.type === "text" && whitespace(head2.value.charAt(0))) && !(head2.type === "element" && (head2.tagName === "meta" || head2.tagName === "link" || head2.tagName === "script" || head2.tagName === "style" || head2.tagName === "template"));
8630
8428
  }
8631
-
8632
- // ../../node_modules/ccount/index.js
8633
- function ccount(value, character) {
8634
- const source = String(value);
8635
- if (typeof character !== "string") {
8636
- throw new TypeError("Expected character");
8429
+ function colgroup(node, index2, parent) {
8430
+ const previous = siblingBefore(parent, index2);
8431
+ const head2 = siblingAfter(node, -1, true);
8432
+ if (parent && previous && previous.type === "element" && previous.tagName === "colgroup" && closing(previous, parent.children.indexOf(previous), parent)) {
8433
+ return false;
8637
8434
  }
8638
- let count = 0;
8639
- let index2 = source.indexOf(character);
8640
- while (index2 !== -1) {
8641
- count++;
8642
- index2 = source.indexOf(character, index2 + character.length);
8435
+ return head2 && head2.type === "element" && head2.tagName === "col";
8436
+ }
8437
+ function tbody2(node, index2, parent) {
8438
+ const previous = siblingBefore(parent, index2);
8439
+ const head2 = siblingAfter(node, -1);
8440
+ if (parent && previous && previous.type === "element" && (previous.tagName === "thead" || previous.tagName === "tbody") && closing(previous, parent.children.indexOf(previous), parent)) {
8441
+ return false;
8643
8442
  }
8644
- return count;
8443
+ return head2 && head2.type === "element" && head2.tagName === "tr";
8645
8444
  }
8646
8445
 
8647
- // ../../node_modules/hast-util-to-html/lib/constants.js
8446
+ // ../../node_modules/hast-util-to-html/lib/handle/element.js
8648
8447
  var constants = {
8649
8448
  // See: <https://html.spec.whatwg.org/#attribute-name-state>.
8650
8449
  name: [
@@ -8668,92 +8467,27 @@ var constants = {
8668
8467
  ['\0"&'.split(""), "\0\"&'`".split("")]
8669
8468
  ]
8670
8469
  };
8671
-
8672
- // ../../node_modules/hast-util-to-html/lib/comment.js
8673
- function comment2(ctx, node) {
8674
- return ctx.bogusComments ? "<?" + stringifyEntities(
8675
- node.value,
8676
- Object.assign({}, ctx.entities, { subset: [">"] })
8677
- ) + ">" : "<!--" + node.value.replace(/^>|^->|<!--|-->|--!>|<!-$/g, encode2) + "-->";
8678
- function encode2($0) {
8679
- return stringifyEntities(
8680
- $0,
8681
- Object.assign({}, ctx.entities, { subset: ["<", ">"] })
8682
- );
8683
- }
8684
- }
8685
-
8686
- // ../../node_modules/hast-util-to-html/lib/doctype.js
8687
- function doctype(ctx) {
8688
- return "<!" + (ctx.upperDoctype ? "DOCTYPE" : "doctype") + (ctx.tightDoctype ? "" : " ") + "html>";
8689
- }
8690
-
8691
- // ../../node_modules/hast-util-to-html/lib/text.js
8692
- function text(ctx, node, _2, parent) {
8693
- return parent && parent.type === "element" && // @ts-expect-error: hush.
8694
- (parent.tagName === "script" || parent.tagName === "style") ? node.value : stringifyEntities(
8695
- node.value,
8696
- Object.assign({}, ctx.entities, { subset: ["<", "&"] })
8697
- );
8698
- }
8699
-
8700
- // ../../node_modules/hast-util-to-html/lib/raw.js
8701
- function raw(ctx, node, index2, parent) {
8702
- return ctx.dangerous ? node.value : text(ctx, node, index2, parent);
8703
- }
8704
-
8705
- // ../../node_modules/hast-util-to-html/lib/tree.js
8706
- var handlers = {
8707
- comment: comment2,
8708
- doctype,
8709
- element: element2,
8710
- // @ts-ignore `raw` is nonstandard
8711
- raw,
8712
- // @ts-ignore `root` is a parent.
8713
- root: all,
8714
- text
8715
- };
8716
- var own4 = {}.hasOwnProperty;
8717
- function one(ctx, node, index2, parent) {
8718
- if (!node || !node.type) {
8719
- throw new Error("Expected node, not `" + node + "`");
8720
- }
8721
- if (!own4.call(handlers, node.type)) {
8722
- throw new Error("Cannot compile unknown node `" + node.type + "`");
8723
- }
8724
- return handlers[node.type](ctx, node, index2, parent);
8725
- }
8726
- function all(ctx, parent) {
8727
- const results = [];
8728
- const children = parent && parent.children || [];
8729
- let index2 = -1;
8730
- while (++index2 < children.length) {
8731
- results[index2] = one(ctx, children[index2], index2, parent);
8732
- }
8733
- return results.join("");
8734
- }
8735
- function element2(ctx, node, index2, parent) {
8736
- const schema = ctx.schema;
8737
- const omit = schema.space === "svg" ? void 0 : ctx.omit;
8738
- let selfClosing = schema.space === "svg" ? ctx.closeEmpty : ctx.voids.includes(node.tagName.toLowerCase());
8470
+ function element(node, index2, parent, state) {
8471
+ const schema = state.schema;
8472
+ const omit = schema.space === "svg" ? false : state.settings.omitOptionalTags;
8473
+ let selfClosing = schema.space === "svg" ? state.settings.closeEmptyElements : state.settings.voids.includes(node.tagName.toLowerCase());
8739
8474
  const parts = [];
8740
8475
  let last;
8741
8476
  if (schema.space === "html" && node.tagName === "svg") {
8742
- ctx.schema = svg2;
8477
+ state.schema = svg2;
8743
8478
  }
8744
- const attrs = serializeAttributes(ctx, node.properties);
8745
- const content = all(
8746
- ctx,
8479
+ const attrs = serializeAttributes(state, node.properties);
8480
+ const content = state.all(
8747
8481
  schema.space === "html" && node.tagName === "template" ? node.content : node
8748
8482
  );
8749
- ctx.schema = schema;
8483
+ state.schema = schema;
8750
8484
  if (content)
8751
8485
  selfClosing = false;
8752
- if (attrs || !omit || !omit.opening(node, index2, parent)) {
8486
+ if (attrs || !omit || !opening(node, index2, parent)) {
8753
8487
  parts.push("<", node.tagName, attrs ? " " + attrs : "");
8754
- if (selfClosing && (schema.space === "svg" || ctx.close)) {
8488
+ if (selfClosing && (schema.space === "svg" || state.settings.closeSelfClosing)) {
8755
8489
  last = attrs.charAt(attrs.length - 1);
8756
- if (!ctx.tightClose || last === "/" || last && last !== '"' && last !== "'") {
8490
+ if (!state.settings.tightSelfClosing || last === "/" || last && last !== '"' && last !== "'") {
8757
8491
  parts.push(" ");
8758
8492
  }
8759
8493
  parts.push("/");
@@ -8761,35 +8495,37 @@ function element2(ctx, node, index2, parent) {
8761
8495
  parts.push(">");
8762
8496
  }
8763
8497
  parts.push(content);
8764
- if (!selfClosing && (!omit || !omit.closing(node, index2, parent))) {
8498
+ if (!selfClosing && (!omit || !closing(node, index2, parent))) {
8765
8499
  parts.push("</" + node.tagName + ">");
8766
8500
  }
8767
8501
  return parts.join("");
8768
8502
  }
8769
- function serializeAttributes(ctx, props) {
8503
+ function serializeAttributes(state, props) {
8770
8504
  const values = [];
8771
8505
  let index2 = -1;
8772
8506
  let key2;
8773
- let value;
8774
- let last;
8775
- for (key2 in props) {
8776
- if (props[key2] !== void 0 && props[key2] !== null) {
8777
- value = serializeAttribute(ctx, key2, props[key2]);
8778
- if (value)
8779
- values.push(value);
8507
+ if (props) {
8508
+ for (key2 in props) {
8509
+ if (props[key2] !== void 0 && props[key2] !== null) {
8510
+ const value = serializeAttribute(state, key2, props[key2]);
8511
+ if (value)
8512
+ values.push(value);
8513
+ }
8780
8514
  }
8781
8515
  }
8782
8516
  while (++index2 < values.length) {
8783
- last = ctx.tight ? values[index2].charAt(values[index2].length - 1) : null;
8517
+ const last = state.settings.tightAttributes ? values[index2].charAt(values[index2].length - 1) : null;
8784
8518
  if (index2 !== values.length - 1 && last !== '"' && last !== "'") {
8785
8519
  values[index2] += " ";
8786
8520
  }
8787
8521
  }
8788
8522
  return values.join("");
8789
8523
  }
8790
- function serializeAttribute(ctx, key2, value) {
8791
- const info = find(ctx.schema, key2);
8792
- let quote = ctx.quote;
8524
+ function serializeAttribute(state, key2, value) {
8525
+ const info = find(state.schema, key2);
8526
+ const x = state.settings.allowParseErrors && state.schema.space === "html" ? 0 : 1;
8527
+ const y = state.settings.allowDangerousCharacters ? 0 : 1;
8528
+ let quote = state.quote;
8793
8529
  let result;
8794
8530
  if (info.overloadedBoolean && (value === info.attribute || value === "")) {
8795
8531
  value = true;
@@ -8801,40 +8537,36 @@ function serializeAttribute(ctx, key2, value) {
8801
8537
  }
8802
8538
  const name = stringifyEntities(
8803
8539
  info.attribute,
8804
- Object.assign({}, ctx.entities, {
8540
+ Object.assign({}, state.settings.characterReferences, {
8805
8541
  // Always encode without parse errors in non-HTML.
8806
- subset: constants.name[ctx.schema.space === "html" ? ctx.valid : 1][ctx.safe]
8542
+ subset: constants.name[x][y]
8807
8543
  })
8808
8544
  );
8809
8545
  if (value === true)
8810
8546
  return name;
8811
- value = typeof value === "object" && "length" in value ? (
8812
- // `spaces` doesn’t accept a second argument, but it’s given here just to
8813
- // keep the code cleaner.
8814
- (info.commaSeparated ? stringify2 : stringify)(value, {
8815
- padLeft: !ctx.tightLists
8816
- })
8817
- ) : String(value);
8818
- if (ctx.collapseEmpty && !value)
8547
+ value = Array.isArray(value) ? (info.commaSeparated ? stringify : stringify2)(value, {
8548
+ padLeft: !state.settings.tightCommaSeparatedLists
8549
+ }) : String(value);
8550
+ if (state.settings.collapseEmptyAttributes && !value)
8819
8551
  return name;
8820
- if (ctx.unquoted) {
8552
+ if (state.settings.preferUnquoted) {
8821
8553
  result = stringifyEntities(
8822
8554
  value,
8823
- Object.assign({}, ctx.entities, {
8824
- subset: constants.unquoted[ctx.valid][ctx.safe],
8555
+ Object.assign({}, state.settings.characterReferences, {
8556
+ subset: constants.unquoted[x][y],
8825
8557
  attribute: true
8826
8558
  })
8827
8559
  );
8828
8560
  }
8829
8561
  if (result !== value) {
8830
- if (ctx.smart && ccount(value, quote) > ccount(value, ctx.alternative)) {
8831
- quote = ctx.alternative;
8562
+ if (state.settings.quoteSmart && ccount(value, quote) > ccount(value, state.alternative)) {
8563
+ quote = state.alternative;
8832
8564
  }
8833
8565
  result = quote + stringifyEntities(
8834
8566
  value,
8835
- Object.assign({}, ctx.entities, {
8567
+ Object.assign({}, state.settings.characterReferences, {
8836
8568
  // Always encode without parse errors in non-HTML.
8837
- subset: (quote === "'" ? constants.single : constants.double)[ctx.schema.space === "html" ? ctx.valid : 1][ctx.safe],
8569
+ subset: (quote === "'" ? constants.single : constants.double)[x][y],
8838
8570
  attribute: true
8839
8571
  })
8840
8572
  ) + quote;
@@ -8842,43 +8574,91 @@ function serializeAttribute(ctx, key2, value) {
8842
8574
  return name + (result ? "=" + result : result);
8843
8575
  }
8844
8576
 
8577
+ // ../../node_modules/hast-util-to-html/lib/handle/text.js
8578
+ function text(node, _2, parent, state) {
8579
+ return parent && parent.type === "element" && (parent.tagName === "script" || parent.tagName === "style") ? node.value : stringifyEntities(
8580
+ node.value,
8581
+ Object.assign({}, state.settings.characterReferences, {
8582
+ subset: ["<", "&"]
8583
+ })
8584
+ );
8585
+ }
8586
+
8587
+ // ../../node_modules/hast-util-to-html/lib/handle/raw.js
8588
+ function raw(node, index2, parent, state) {
8589
+ return state.settings.allowDangerousHtml ? node.value : text(node, index2, parent, state);
8590
+ }
8591
+
8592
+ // ../../node_modules/hast-util-to-html/lib/handle/root.js
8593
+ function root(node, _1, _2, state) {
8594
+ return state.all(node);
8595
+ }
8596
+
8597
+ // ../../node_modules/hast-util-to-html/lib/handle/index.js
8598
+ var handle = zwitch("type", {
8599
+ invalid,
8600
+ unknown,
8601
+ handlers: { comment, doctype, element, raw, root, text }
8602
+ });
8603
+ function invalid(node) {
8604
+ throw new Error("Expected node, not `" + node + "`");
8605
+ }
8606
+ function unknown(node) {
8607
+ throw new Error("Cannot compile unknown node `" + node.type + "`");
8608
+ }
8609
+
8845
8610
  // ../../node_modules/hast-util-to-html/lib/index.js
8846
- function toHtml(node, options = {}) {
8847
- const quote = options.quote || '"';
8611
+ function toHtml(tree, options) {
8612
+ const options_ = options || {};
8613
+ const quote = options_.quote || '"';
8848
8614
  const alternative = quote === '"' ? "'" : '"';
8849
8615
  if (quote !== '"' && quote !== "'") {
8850
8616
  throw new Error("Invalid quote `" + quote + "`, expected `'` or `\"`");
8851
8617
  }
8852
- const context = {
8853
- valid: options.allowParseErrors ? 0 : 1,
8854
- safe: options.allowDangerousCharacters ? 0 : 1,
8855
- schema: options.space === "svg" ? svg2 : html2,
8856
- omit: options.omitOptionalTags ? omission2 : void 0,
8618
+ const state = {
8619
+ one,
8620
+ all,
8621
+ settings: {
8622
+ omitOptionalTags: options_.omitOptionalTags || false,
8623
+ allowParseErrors: options_.allowParseErrors || false,
8624
+ allowDangerousCharacters: options_.allowDangerousCharacters || false,
8625
+ quoteSmart: options_.quoteSmart || false,
8626
+ preferUnquoted: options_.preferUnquoted || false,
8627
+ tightAttributes: options_.tightAttributes || false,
8628
+ upperDoctype: options_.upperDoctype || false,
8629
+ tightDoctype: options_.tightDoctype || false,
8630
+ bogusComments: options_.bogusComments || false,
8631
+ tightCommaSeparatedLists: options_.tightCommaSeparatedLists || false,
8632
+ tightSelfClosing: options_.tightSelfClosing || false,
8633
+ collapseEmptyAttributes: options_.collapseEmptyAttributes || false,
8634
+ allowDangerousHtml: options_.allowDangerousHtml || false,
8635
+ voids: options_.voids || htmlVoidElements,
8636
+ characterReferences: options_.characterReferences || options_.entities || {},
8637
+ closeSelfClosing: options_.closeSelfClosing || false,
8638
+ closeEmptyElements: options_.closeEmptyElements || false
8639
+ },
8640
+ schema: options_.space === "svg" ? svg2 : html2,
8857
8641
  quote,
8858
- alternative,
8859
- smart: options.quoteSmart,
8860
- unquoted: options.preferUnquoted,
8861
- tight: options.tightAttributes,
8862
- upperDoctype: options.upperDoctype,
8863
- tightDoctype: options.tightDoctype,
8864
- bogusComments: options.bogusComments,
8865
- tightLists: options.tightCommaSeparatedLists,
8866
- tightClose: options.tightSelfClosing,
8867
- collapseEmpty: options.collapseEmptyAttributes,
8868
- dangerous: options.allowDangerousHtml,
8869
- voids: options.voids || htmlVoidElements.concat(),
8870
- entities: options.entities || {},
8871
- close: options.closeSelfClosing,
8872
- closeEmpty: options.closeEmptyElements
8642
+ alternative
8873
8643
  };
8874
- return one(
8875
- context,
8876
- // @ts-ignore Assume `node` does not contain a root.
8877
- Array.isArray(node) ? { type: "root", children: node } : node,
8878
- null,
8879
- null
8644
+ return state.one(
8645
+ Array.isArray(tree) ? { type: "root", children: tree } : tree,
8646
+ void 0,
8647
+ void 0
8880
8648
  );
8881
8649
  }
8650
+ function one(node, index2, parent) {
8651
+ return handle(node, index2, parent, this);
8652
+ }
8653
+ function all(parent) {
8654
+ const results = [];
8655
+ const children = parent && parent.children || [];
8656
+ let index2 = -1;
8657
+ while (++index2 < children.length) {
8658
+ results[index2] = this.one(children[index2], index2, parent);
8659
+ }
8660
+ return results.join("");
8661
+ }
8882
8662
 
8883
8663
  // src/index.ts
8884
8664
  var import_parse_numeric_range = __toESM(require_parse_numeric_range());
@@ -11217,11 +10997,7 @@ function markdown(Prism2) {
11217
10997
  });
11218
10998
  }
11219
10999
  } else {
11220
- env.content = Prism3.highlight(
11221
- textContent(env.content.value),
11222
- grammar,
11223
- codeLang
11224
- );
11000
+ env.content = Prism3.highlight(env.content.value, grammar, codeLang);
11225
11001
  }
11226
11002
  });
11227
11003
  var tagPattern = RegExp(Prism3.languages.markup.tag.pattern.source, "gi");
@@ -11233,8 +11009,8 @@ function markdown(Prism2) {
11233
11009
  };
11234
11010
  var fromCodePoint = String.fromCodePoint || String.fromCharCode;
11235
11011
  function textContent(html5) {
11236
- var text3 = html5.replace(tagPattern, "");
11237
- text3 = text3.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function(m, code) {
11012
+ var text2 = html5.replace(tagPattern, "");
11013
+ text2 = text2.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function(m, code) {
11238
11014
  code = code.toLowerCase();
11239
11015
  if (code[0] === "#") {
11240
11016
  var value;
@@ -11252,7 +11028,7 @@ function markdown(Prism2) {
11252
11028
  return m;
11253
11029
  }
11254
11030
  });
11255
- return text3;
11031
+ return text2;
11256
11032
  }
11257
11033
  Prism3.languages.md = Prism3.languages.markdown;
11258
11034
  })(Prism2);
@@ -11524,7 +11300,7 @@ php.aliases = [];
11524
11300
  function php(Prism2) {
11525
11301
  Prism2.register(markupTemplating);
11526
11302
  (function(Prism3) {
11527
- var comment4 = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
11303
+ var comment2 = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
11528
11304
  var constant = [
11529
11305
  {
11530
11306
  pattern: /\b(?:false|true)\b/i,
@@ -11551,7 +11327,7 @@ function php(Prism2) {
11551
11327
  pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
11552
11328
  alias: "important"
11553
11329
  },
11554
- comment: comment4,
11330
+ comment: comment2,
11555
11331
  variable: /\$+(?:\w+\b|(?=\{))/,
11556
11332
  package: {
11557
11333
  pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
@@ -11804,7 +11580,7 @@ function php(Prism2) {
11804
11580
  lookbehind: true,
11805
11581
  // inside can appear subset of php
11806
11582
  inside: {
11807
- comment: comment4,
11583
+ comment: comment2,
11808
11584
  string,
11809
11585
  "attribute-class-name": [
11810
11586
  {
@@ -12697,55 +12473,43 @@ function vbnet(Prism2) {
12697
12473
  });
12698
12474
  }
12699
12475
 
12700
- // ../../node_modules/hast-util-parse-selector/index.js
12476
+ // ../../node_modules/hast-util-parse-selector/lib/index.js
12701
12477
  var search = /[#.]/g;
12702
- var parseSelector = (
12703
- /**
12704
- * @type {(
12705
- * <Selector extends string, DefaultTagName extends string = 'div'>(selector?: Selector, defaultTagName?: DefaultTagName) => Element & {tagName: import('./extract.js').ExtractTagName<Selector, DefaultTagName>}
12706
- * )}
12707
- */
12708
- /**
12709
- * @param {string} [selector]
12710
- * @param {string} [defaultTagName='div']
12711
- * @returns {Element}
12712
- */
12713
- function(selector, defaultTagName = "div") {
12714
- var value = selector || "";
12715
- var props = {};
12716
- var start = 0;
12717
- var subvalue;
12718
- var previous;
12719
- var match;
12720
- while (start < value.length) {
12721
- search.lastIndex = start;
12722
- match = search.exec(value);
12723
- subvalue = value.slice(start, match ? match.index : value.length);
12724
- if (subvalue) {
12725
- if (!previous) {
12726
- defaultTagName = subvalue;
12727
- } else if (previous === "#") {
12728
- props.id = subvalue;
12729
- } else if (Array.isArray(props.className)) {
12730
- props.className.push(subvalue);
12731
- } else {
12732
- props.className = [subvalue];
12733
- }
12734
- start += subvalue.length;
12735
- }
12736
- if (match) {
12737
- previous = match[0];
12738
- start++;
12478
+ function parseSelector(selector, defaultTagName) {
12479
+ const value = selector || "";
12480
+ const props = {};
12481
+ let start = 0;
12482
+ let previous;
12483
+ let tagName;
12484
+ while (start < value.length) {
12485
+ search.lastIndex = start;
12486
+ const match = search.exec(value);
12487
+ const subvalue = value.slice(start, match ? match.index : value.length);
12488
+ if (subvalue) {
12489
+ if (!previous) {
12490
+ tagName = subvalue;
12491
+ } else if (previous === "#") {
12492
+ props.id = subvalue;
12493
+ } else if (Array.isArray(props.className)) {
12494
+ props.className.push(subvalue);
12495
+ } else {
12496
+ props.className = [subvalue];
12739
12497
  }
12498
+ start += subvalue.length;
12499
+ }
12500
+ if (match) {
12501
+ previous = match[0];
12502
+ start++;
12740
12503
  }
12741
- return {
12742
- type: "element",
12743
- tagName: defaultTagName,
12744
- properties: props,
12745
- children: []
12746
- };
12747
12504
  }
12748
- );
12505
+ return {
12506
+ type: "element",
12507
+ // @ts-expect-error: fine.
12508
+ tagName: tagName || defaultTagName || "div",
12509
+ properties: props,
12510
+ children: []
12511
+ };
12512
+ }
12749
12513
 
12750
12514
  // ../../node_modules/hastscript/lib/core.js
12751
12515
  var buttonTypes = /* @__PURE__ */ new Set(["menu", "submit", "reset", "button"]);
@@ -12756,7 +12520,7 @@ function core2(schema, defaultTagName, caseSensitive) {
12756
12520
  /**
12757
12521
  * @type {{
12758
12522
  * (): Root
12759
- * (selector: null|undefined, ...children: Array<HChild>): Root
12523
+ * (selector: null | undefined, ...children: Array<HChild>): Root
12760
12524
  * (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
12761
12525
  * (selector: string, ...children: Array<HChild>): Element
12762
12526
  * }}
@@ -12764,8 +12528,8 @@ function core2(schema, defaultTagName, caseSensitive) {
12764
12528
  /**
12765
12529
  * Hyperscript compatible DSL for creating virtual hast trees.
12766
12530
  *
12767
- * @param {string|null} [selector]
12768
- * @param {HProperties|HChild} [properties]
12531
+ * @param {string | null} [selector]
12532
+ * @param {HProperties | HChild} [properties]
12769
12533
  * @param {Array<HChild>} children
12770
12534
  * @returns {HResult}
12771
12535
  */
@@ -12833,11 +12597,11 @@ function addProperty(schema, properties, key2, value) {
12833
12597
  result = value;
12834
12598
  } else if (typeof value === "string") {
12835
12599
  if (info.spaceSeparated) {
12836
- result = parse(value);
12837
- } else if (info.commaSeparated) {
12838
12600
  result = parse2(value);
12601
+ } else if (info.commaSeparated) {
12602
+ result = parse(value);
12839
12603
  } else if (info.commaOrSpaceSeparated) {
12840
- result = parse(parse2(value).join(" "));
12604
+ result = parse2(parse(value).join(" "));
12841
12605
  } else {
12842
12606
  result = parsePrimitive(info, info.property, value);
12843
12607
  }
@@ -12858,20 +12622,20 @@ function addProperty(schema, properties, key2, value) {
12858
12622
  }
12859
12623
  properties[info.property] = result;
12860
12624
  }
12861
- function addChild(nodes2, value) {
12625
+ function addChild(nodes, value) {
12862
12626
  let index2 = -1;
12863
12627
  if (value === void 0 || value === null) {
12864
12628
  } else if (typeof value === "string" || typeof value === "number") {
12865
- nodes2.push({ type: "text", value: String(value) });
12629
+ nodes.push({ type: "text", value: String(value) });
12866
12630
  } else if (Array.isArray(value)) {
12867
12631
  while (++index2 < value.length) {
12868
- addChild(nodes2, value[index2]);
12632
+ addChild(nodes, value[index2]);
12869
12633
  }
12870
12634
  } else if (typeof value === "object" && "type" in value) {
12871
12635
  if (value.type === "root") {
12872
- addChild(nodes2, value.children);
12636
+ addChild(nodes, value.children);
12873
12637
  } else {
12874
- nodes2.push(value);
12638
+ nodes.push(value);
12875
12639
  }
12876
12640
  } else {
12877
12641
  throw new Error("Expected node, nodes, or string, got `" + value + "`");
@@ -15672,9 +15436,9 @@ var _ = {
15672
15436
  * @example
15673
15437
  * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
15674
15438
  */
15675
- highlight: function(text3, grammar, language) {
15439
+ highlight: function(text2, grammar, language) {
15676
15440
  var env = {
15677
- code: text3,
15441
+ code: text2,
15678
15442
  grammar,
15679
15443
  language
15680
15444
  };
@@ -15710,7 +15474,7 @@ var _ = {
15710
15474
  * }
15711
15475
  * });
15712
15476
  */
15713
- tokenize: function(text3, grammar) {
15477
+ tokenize: function(text2, grammar) {
15714
15478
  var rest = grammar.rest;
15715
15479
  if (rest) {
15716
15480
  for (var token in rest) {
@@ -15719,8 +15483,8 @@ var _ = {
15719
15483
  delete grammar.rest;
15720
15484
  }
15721
15485
  var tokenList = new LinkedList();
15722
- addAfter(tokenList, tokenList.head, text3);
15723
- matchGrammar(text3, tokenList, grammar, tokenList.head, 0);
15486
+ addAfter(tokenList, tokenList.head, text2);
15487
+ matchGrammar(text2, tokenList, grammar, tokenList.head, 0);
15724
15488
  return toArray(tokenList);
15725
15489
  },
15726
15490
  /**
@@ -15774,9 +15538,9 @@ function Token(type, content, alias2, matchedStr) {
15774
15538
  this.alias = alias2;
15775
15539
  this.length = (matchedStr || "").length | 0;
15776
15540
  }
15777
- function matchPattern(pattern, pos, text3, lookbehind) {
15541
+ function matchPattern(pattern, pos, text2, lookbehind) {
15778
15542
  pattern.lastIndex = pos;
15779
- var match = pattern.exec(text3);
15543
+ var match = pattern.exec(text2);
15780
15544
  if (match && lookbehind && match[1]) {
15781
15545
  var lookbehindLength = match[1].length;
15782
15546
  match.index += lookbehindLength;
@@ -15784,7 +15548,7 @@ function matchPattern(pattern, pos, text3, lookbehind) {
15784
15548
  }
15785
15549
  return match;
15786
15550
  }
15787
- function matchGrammar(text3, tokenList, grammar, startNode, startPos, rematch) {
15551
+ function matchGrammar(text2, tokenList, grammar, startNode, startPos, rematch) {
15788
15552
  for (var token in grammar) {
15789
15553
  if (!grammar.hasOwnProperty(token) || !grammar[token]) {
15790
15554
  continue;
@@ -15810,7 +15574,7 @@ function matchGrammar(text3, tokenList, grammar, startNode, startPos, rematch) {
15810
15574
  break;
15811
15575
  }
15812
15576
  var str = currentNode.value;
15813
- if (tokenList.length > text3.length) {
15577
+ if (tokenList.length > text2.length) {
15814
15578
  return;
15815
15579
  }
15816
15580
  if (str instanceof Token) {
@@ -15819,8 +15583,8 @@ function matchGrammar(text3, tokenList, grammar, startNode, startPos, rematch) {
15819
15583
  var removeCount = 1;
15820
15584
  var match;
15821
15585
  if (greedy) {
15822
- match = matchPattern(pattern, pos, text3, lookbehind);
15823
- if (!match || match.index >= text3.length) {
15586
+ match = matchPattern(pattern, pos, text2, lookbehind);
15587
+ if (!match || match.index >= text2.length) {
15824
15588
  break;
15825
15589
  }
15826
15590
  var from = match.index;
@@ -15841,7 +15605,7 @@ function matchGrammar(text3, tokenList, grammar, startNode, startPos, rematch) {
15841
15605
  p2 += k.value.length;
15842
15606
  }
15843
15607
  removeCount--;
15844
- str = text3.slice(pos, p2);
15608
+ str = text2.slice(pos, p2);
15845
15609
  match.index -= pos;
15846
15610
  } else {
15847
15611
  match = matchPattern(pattern, 0, str, lookbehind);
@@ -15879,7 +15643,7 @@ function matchGrammar(text3, tokenList, grammar, startNode, startPos, rematch) {
15879
15643
  reach
15880
15644
  };
15881
15645
  matchGrammar(
15882
- text3,
15646
+ text2,
15883
15647
  tokenList,
15884
15648
  grammar,
15885
15649
  currentNode.prev,
@@ -15978,18 +15742,18 @@ function register(syntax) {
15978
15742
  }
15979
15743
  function alias(language, alias2) {
15980
15744
  const languages = refractor.languages;
15981
- let map2 = {};
15745
+ let map = {};
15982
15746
  if (typeof language === "string") {
15983
15747
  if (alias2) {
15984
- map2[language] = alias2;
15748
+ map[language] = alias2;
15985
15749
  }
15986
15750
  } else {
15987
- map2 = language;
15751
+ map = language;
15988
15752
  }
15989
15753
  let key2;
15990
- for (key2 in map2) {
15991
- if (own7.call(map2, key2)) {
15992
- const value = map2[key2];
15754
+ for (key2 in map) {
15755
+ if (own7.call(map, key2)) {
15756
+ const value = map[key2];
15993
15757
  const list = typeof value === "string" ? [value] : value;
15994
15758
  let index2 = -1;
15995
15759
  while (++index2 < list.length) {
@@ -16259,24 +16023,24 @@ function tsx(Prism2) {
16259
16023
  // ../../node_modules/rehype-parse/lib/index.js
16260
16024
  var import_parser = __toESM(require_parser(), 1);
16261
16025
 
16262
- // ../../node_modules/vfile-location/index.js
16026
+ // ../../node_modules/vfile-location/lib/index.js
16263
16027
  function location(file) {
16264
- var value = String(file);
16265
- var indices = [];
16266
- var search2 = /\r?\n|\r/g;
16028
+ const value = String(file);
16029
+ const indices = [];
16030
+ const search2 = /\r?\n|\r/g;
16267
16031
  while (search2.test(value)) {
16268
16032
  indices.push(search2.lastIndex);
16269
16033
  }
16270
16034
  indices.push(value.length + 1);
16271
16035
  return { toPoint, toOffset };
16272
16036
  function toPoint(offset) {
16273
- var index2 = -1;
16274
- if (offset > -1 && offset < indices[indices.length - 1]) {
16037
+ let index2 = -1;
16038
+ if (typeof offset === "number" && offset > -1 && offset < indices[indices.length - 1]) {
16275
16039
  while (++index2 < indices.length) {
16276
16040
  if (indices[index2] > offset) {
16277
16041
  return {
16278
16042
  line: index2 + 1,
16279
- column: offset - (indices[index2 - 1] || 0) + 1,
16043
+ column: offset - (index2 > 0 ? indices[index2 - 1] : 0) + 1,
16280
16044
  offset
16281
16045
  };
16282
16046
  }
@@ -16285,13 +16049,15 @@ function location(file) {
16285
16049
  return { line: void 0, column: void 0, offset: void 0 };
16286
16050
  }
16287
16051
  function toOffset(point3) {
16288
- var line = point3 && point3.line;
16289
- var column = point3 && point3.column;
16290
- var offset;
16052
+ const line = point3 && point3.line;
16053
+ const column = point3 && point3.column;
16291
16054
  if (typeof line === "number" && typeof column === "number" && !Number.isNaN(line) && !Number.isNaN(column) && line - 1 in indices) {
16292
- offset = (indices[line - 2] || 0) + column - 1 || 0;
16055
+ const offset = (indices[line - 2] || 0) + column - 1 || 0;
16056
+ if (offset > -1 && offset < indices[indices.length - 1]) {
16057
+ return offset;
16058
+ }
16293
16059
  }
16294
- return offset > -1 && offset < indices[indices.length - 1] ? offset : -1;
16060
+ return -1;
16295
16061
  }
16296
16062
  }
16297
16063
 
@@ -16307,125 +16073,160 @@ var webNamespaces = {
16307
16073
 
16308
16074
  // ../../node_modules/hast-util-from-parse5/lib/index.js
16309
16075
  var own8 = {}.hasOwnProperty;
16310
- var map = {
16311
- "#document": root,
16312
- "#document-fragment": root,
16313
- "#text": text2,
16314
- "#comment": comment3,
16315
- "#documentType": doctype2
16316
- };
16317
- function fromParse5(ast, options = {}) {
16076
+ var proto = Object.prototype;
16077
+ function fromParse5(tree, options) {
16078
+ const options_ = options || {};
16318
16079
  let settings;
16319
16080
  let file;
16320
- if (isFile(options)) {
16321
- file = options;
16081
+ if (isFile(options_)) {
16082
+ file = options_;
16322
16083
  settings = {};
16323
16084
  } else {
16324
- file = options.file;
16325
- settings = options;
16085
+ file = options_.file || void 0;
16086
+ settings = options_;
16326
16087
  }
16327
- return transform(
16088
+ return one2(
16328
16089
  {
16329
16090
  schema: settings.space === "svg" ? svg2 : html2,
16330
16091
  file,
16331
16092
  verbose: settings.verbose,
16332
16093
  location: false
16333
16094
  },
16334
- ast
16095
+ tree
16335
16096
  );
16336
16097
  }
16337
- function transform(ctx, ast) {
16338
- const schema = ctx.schema;
16339
- const fn = own8.call(map, ast.nodeName) ? map[ast.nodeName] : element3;
16340
- let children;
16341
- if ("tagName" in ast) {
16342
- ctx.schema = ast.namespaceURI === webNamespaces.svg ? svg2 : html2;
16343
- }
16344
- if ("childNodes" in ast) {
16345
- children = nodes(ctx, ast.childNodes);
16346
- }
16347
- const result = fn(ctx, ast, children);
16348
- if ("sourceCodeLocation" in ast && ast.sourceCodeLocation && ctx.file) {
16349
- const position3 = createLocation(ctx, result, ast.sourceCodeLocation);
16350
- if (position3) {
16351
- ctx.location = true;
16352
- result.position = position3;
16098
+ function one2(state, node) {
16099
+ let result;
16100
+ switch (node.nodeName) {
16101
+ case "#comment": {
16102
+ const reference = (
16103
+ /** @type {P5Comment} */
16104
+ node
16105
+ );
16106
+ result = { type: "comment", value: reference.data };
16107
+ patch(state, reference, result);
16108
+ return result;
16109
+ }
16110
+ case "#document":
16111
+ case "#document-fragment": {
16112
+ const reference = (
16113
+ /** @type {P5Document | P5DocumentFragment} */
16114
+ node
16115
+ );
16116
+ const quirksMode = "mode" in reference ? reference.mode === "quirks" || reference.mode === "limited-quirks" : false;
16117
+ result = {
16118
+ type: "root",
16119
+ children: all2(state, node.childNodes),
16120
+ data: { quirksMode }
16121
+ };
16122
+ if (state.file && state.location) {
16123
+ const doc = String(state.file);
16124
+ const loc = location(doc);
16125
+ const start = loc.toPoint(0);
16126
+ const end = loc.toPoint(doc.length);
16127
+ result.position = { start, end };
16128
+ }
16129
+ return result;
16130
+ }
16131
+ case "#documentType": {
16132
+ const reference = (
16133
+ /** @type {P5DocumentType} */
16134
+ node
16135
+ );
16136
+ result = { type: "doctype" };
16137
+ patch(state, reference, result);
16138
+ return result;
16139
+ }
16140
+ case "#text": {
16141
+ const reference = (
16142
+ /** @type {P5Text} */
16143
+ node
16144
+ );
16145
+ result = { type: "text", value: reference.value };
16146
+ patch(state, reference, result);
16147
+ return result;
16148
+ }
16149
+ default: {
16150
+ const reference = (
16151
+ /** @type {P5Element} */
16152
+ node
16153
+ );
16154
+ result = element2(state, reference);
16155
+ return result;
16353
16156
  }
16354
16157
  }
16355
- ctx.schema = schema;
16356
- return result;
16357
16158
  }
16358
- function nodes(ctx, children) {
16159
+ function all2(state, nodes) {
16359
16160
  let index2 = -1;
16360
16161
  const result = [];
16361
- while (++index2 < children.length) {
16362
- result[index2] = transform(ctx, children[index2]);
16162
+ while (++index2 < nodes.length) {
16163
+ result[index2] = one2(state, nodes[index2]);
16363
16164
  }
16364
16165
  return result;
16365
16166
  }
16366
- function root(ctx, ast, children) {
16367
- const result = {
16368
- type: "root",
16369
- children,
16370
- data: { quirksMode: ast.mode === "quirks" || ast.mode === "limited-quirks" }
16371
- };
16372
- if (ctx.file && ctx.location) {
16373
- const doc = String(ctx.file);
16374
- const loc = location(doc);
16375
- result.position = {
16376
- start: loc.toPoint(0),
16377
- end: loc.toPoint(doc.length)
16378
- };
16379
- }
16380
- return result;
16381
- }
16382
- function doctype2() {
16383
- return { type: "doctype" };
16384
- }
16385
- function text2(_2, ast) {
16386
- return { type: "text", value: ast.value };
16387
- }
16388
- function comment3(_2, ast) {
16389
- return { type: "comment", value: ast.data };
16390
- }
16391
- function element3(ctx, ast, children) {
16392
- const fn = ctx.schema.space === "svg" ? s : h;
16167
+ function element2(state, node) {
16168
+ const schema = state.schema;
16169
+ state.schema = node.namespaceURI === webNamespaces.svg ? svg2 : html2;
16393
16170
  let index2 = -1;
16394
16171
  const props = {};
16395
- while (++index2 < ast.attrs.length) {
16396
- const attribute = ast.attrs[index2];
16397
- props[(attribute.prefix ? attribute.prefix + ":" : "") + attribute.name] = attribute.value;
16172
+ while (++index2 < node.attrs.length) {
16173
+ const attribute = node.attrs[index2];
16174
+ const name = (attribute.prefix ? attribute.prefix + ":" : "") + attribute.name;
16175
+ if (!own8.call(proto, name)) {
16176
+ props[name] = attribute.value;
16177
+ }
16398
16178
  }
16399
- const result = fn(ast.tagName, props, children);
16400
- if (result.tagName === "template" && "content" in ast) {
16401
- const pos = ast.sourceCodeLocation;
16179
+ const fn = state.schema.space === "svg" ? s : h;
16180
+ const result = fn(node.tagName, props, all2(state, node.childNodes));
16181
+ patch(state, node, result);
16182
+ if (result.tagName === "template") {
16183
+ const reference = (
16184
+ /** @type {P5Template} */
16185
+ node
16186
+ );
16187
+ const pos = reference.sourceCodeLocation;
16402
16188
  const startTag = pos && pos.startTag && position(pos.startTag);
16403
16189
  const endTag = pos && pos.endTag && position(pos.endTag);
16404
- const content = transform(ctx, ast.content);
16405
- if (startTag && endTag && ctx.file) {
16190
+ const content = one2(state, reference.content);
16191
+ if (startTag && endTag && state.file) {
16406
16192
  content.position = { start: startTag.end, end: endTag.start };
16407
16193
  }
16408
16194
  result.content = content;
16409
16195
  }
16196
+ state.schema = schema;
16410
16197
  return result;
16411
16198
  }
16412
- function createLocation(ctx, node, location2) {
16199
+ function patch(state, from, to) {
16200
+ if ("sourceCodeLocation" in from && from.sourceCodeLocation && state.file) {
16201
+ const position3 = createLocation(state, to, from.sourceCodeLocation);
16202
+ if (position3) {
16203
+ state.location = true;
16204
+ to.position = position3;
16205
+ }
16206
+ }
16207
+ }
16208
+ function createLocation(state, node, location2) {
16413
16209
  const result = position(location2);
16414
16210
  if (node.type === "element") {
16415
16211
  const tail = node.children[node.children.length - 1];
16416
16212
  if (result && !location2.endTag && tail && tail.position && tail.position.end) {
16417
16213
  result.end = Object.assign({}, tail.position.end);
16418
16214
  }
16419
- if (ctx.verbose) {
16215
+ if (state.verbose) {
16420
16216
  const props = {};
16421
16217
  let key2;
16422
- for (key2 in location2.attrs) {
16423
- if (own8.call(location2.attrs, key2)) {
16424
- props[find(ctx.schema, key2).property] = position(location2.attrs[key2]);
16218
+ if (location2.attrs) {
16219
+ for (key2 in location2.attrs) {
16220
+ if (own8.call(location2.attrs, key2)) {
16221
+ props[find(state.schema, key2).property] = position(
16222
+ location2.attrs[key2]
16223
+ );
16224
+ }
16425
16225
  }
16426
16226
  }
16427
16227
  node.data = {
16428
16228
  position: {
16229
+ // @ts-expect-error: assume not `undefined`.
16429
16230
  opening: position(location2.startTag),
16430
16231
  closing: location2.endTag ? position(location2.endTag) : null,
16431
16232
  properties: props
@@ -16446,10 +16247,10 @@ function position(loc) {
16446
16247
  column: loc.endCol,
16447
16248
  offset: loc.endOffset
16448
16249
  });
16449
- return start || end ? { start, end } : null;
16250
+ return start || end ? { start, end } : void 0;
16450
16251
  }
16451
16252
  function point(point3) {
16452
- return point3.line && point3.column ? point3 : null;
16253
+ return point3.line && point3.column ? point3 : void 0;
16453
16254
  }
16454
16255
  function isFile(value) {
16455
16256
  return "messages" in value;
@@ -16882,7 +16683,7 @@ function wrap(middleware, callback) {
16882
16683
  // ../../node_modules/vfile/lib/index.js
16883
16684
  var import_is_buffer = __toESM(require_is_buffer2(), 1);
16884
16685
 
16885
- // ../../node_modules/unist-util-stringify-position/index.js
16686
+ // ../../node_modules/unist-util-stringify-position/lib/index.js
16886
16687
  function stringifyPosition(value) {
16887
16688
  if (!value || typeof value !== "object") {
16888
16689
  return "";
@@ -16908,21 +16709,26 @@ function index(value) {
16908
16709
  return value && typeof value === "number" ? value : 1;
16909
16710
  }
16910
16711
 
16911
- // ../../node_modules/vfile-message/index.js
16712
+ // ../../node_modules/vfile-message/lib/index.js
16912
16713
  var VFileMessage = class extends Error {
16913
16714
  /**
16914
16715
  * Create a message for `reason` at `place` from `origin`.
16915
16716
  *
16916
16717
  * When an error is passed in as `reason`, the `stack` is copied.
16917
16718
  *
16918
- * @param {string|Error|VFileMessage} reason
16919
- * Reason for message.
16920
- * Uses the stack and message of the error if given.
16921
- * @param {Node|NodeLike|Position|Point} [place]
16922
- * Place at which the message occurred in a file.
16923
- * @param {string} [origin]
16924
- * Place in code the message originates from (example `'my-package:my-rule-name'`)
16719
+ * @param {string | Error | VFileMessage} reason
16720
+ * Reason for message, uses the stack and message of the error if given.
16721
+ *
16722
+ * > πŸ‘‰ **Note**: you should use markdown.
16723
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
16724
+ * Place in file where the message occurred.
16725
+ * @param {string | null | undefined} [origin]
16726
+ * Place in code where the message originates (example:
16727
+ * `'my-package:my-rule'` or `'my-rule'`).
16728
+ * @returns
16729
+ * Instance of `VFileMessage`.
16925
16730
  */
16731
+ // To do: next major: expose `undefined` everywhere instead of `null`.
16926
16732
  constructor(reason, place, origin) {
16927
16733
  const parts = [null, null];
16928
16734
  let position3 = {
@@ -16998,10 +16804,10 @@ import { default as default3 } from "process";
16998
16804
  import { fileURLToPath } from "url";
16999
16805
 
17000
16806
  // ../../node_modules/vfile/lib/minurl.shared.js
17001
- function isUrl(fileURLOrPath) {
17002
- return fileURLOrPath !== null && typeof fileURLOrPath === "object" && // @ts-expect-error: indexable.
17003
- fileURLOrPath.href && // @ts-expect-error: indexable.
17004
- fileURLOrPath.origin;
16807
+ function isUrl(fileUrlOrPath) {
16808
+ return fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && // @ts-expect-error: indexable.
16809
+ fileUrlOrPath.href && // @ts-expect-error: indexable.
16810
+ fileUrlOrPath.origin;
17005
16811
  }
17006
16812
 
17007
16813
  // ../../node_modules/vfile/lib/index.js
@@ -17010,25 +16816,30 @@ var VFile = class {
17010
16816
  /**
17011
16817
  * Create a new virtual file.
17012
16818
  *
17013
- * If `options` is `string` or `Buffer`, it’s treated as `{value: options}`.
17014
- * If `options` is a `URL`, it’s treated as `{path: options}`.
17015
- * If `options` is a `VFile`, shallow copies its data over to the new file.
17016
- * All fields in `options` are set on the newly created `VFile`.
16819
+ * `options` is treated as:
16820
+ *
16821
+ * * `string` or `Buffer` β€” `{value: options}`
16822
+ * * `URL` β€” `{path: options}`
16823
+ * * `VFile` β€” shallow copies its data over to the new file
16824
+ * * `object` β€” all fields are shallow copied over to the new file
17017
16825
  *
17018
16826
  * Path related fields are set in the following order (least specific to
17019
16827
  * most specific): `history`, `path`, `basename`, `stem`, `extname`,
17020
16828
  * `dirname`.
17021
16829
  *
17022
- * It’s not possible to set either `dirname` or `extname` without setting
17023
- * either `history`, `path`, `basename`, or `stem` as well.
16830
+ * You cannot set `dirname` or `extname` without setting either `history`,
16831
+ * `path`, `basename`, or `stem` too.
17024
16832
  *
17025
- * @param {Compatible} [value]
16833
+ * @param {Compatible | null | undefined} [value]
16834
+ * File value.
16835
+ * @returns
16836
+ * New instance.
17026
16837
  */
17027
16838
  constructor(value) {
17028
16839
  let options;
17029
16840
  if (!value) {
17030
16841
  options = {};
17031
- } else if (typeof value === "string" || (0, import_is_buffer.default)(value)) {
16842
+ } else if (typeof value === "string" || buffer(value)) {
17032
16843
  options = { value };
17033
16844
  } else if (isUrl(value)) {
17034
16845
  options = { path: value };
@@ -17046,18 +16857,20 @@ var VFile = class {
17046
16857
  let index2 = -1;
17047
16858
  while (++index2 < order.length) {
17048
16859
  const prop2 = order[index2];
17049
- if (prop2 in options && options[prop2] !== void 0) {
16860
+ if (prop2 in options && options[prop2] !== void 0 && options[prop2] !== null) {
17050
16861
  this[prop2] = prop2 === "history" ? [...options[prop2]] : options[prop2];
17051
16862
  }
17052
16863
  }
17053
16864
  let prop;
17054
16865
  for (prop in options) {
17055
- if (!order.includes(prop))
16866
+ if (!order.includes(prop)) {
17056
16867
  this[prop] = options[prop];
16868
+ }
17057
16869
  }
17058
16870
  }
17059
16871
  /**
17060
16872
  * Get the full path (example: `'~/index.min.js'`).
16873
+ *
17061
16874
  * @returns {string}
17062
16875
  */
17063
16876
  get path() {
@@ -17065,10 +16878,12 @@ var VFile = class {
17065
16878
  }
17066
16879
  /**
17067
16880
  * Set the full path (example: `'~/index.min.js'`).
16881
+ *
17068
16882
  * Cannot be nullified.
17069
16883
  * You can set a file URL (a `URL` object with a `file:` protocol) which will
17070
16884
  * be turned into a path with `url.fileURLToPath`.
17071
- * @param {string|URL} path
16885
+ *
16886
+ * @param {string | URL} path
17072
16887
  */
17073
16888
  set path(path) {
17074
16889
  if (isUrl(path)) {
@@ -17087,6 +16902,7 @@ var VFile = class {
17087
16902
  }
17088
16903
  /**
17089
16904
  * Set the parent path (example: `'~'`).
16905
+ *
17090
16906
  * Cannot be set if there’s no `path` yet.
17091
16907
  */
17092
16908
  set dirname(dirname) {
@@ -17101,6 +16917,7 @@ var VFile = class {
17101
16917
  }
17102
16918
  /**
17103
16919
  * Set basename (including extname) (`'index.min.js'`).
16920
+ *
17104
16921
  * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
17105
16922
  * on windows).
17106
16923
  * Cannot be nullified (use `file.path = file.dirname` instead).
@@ -17118,6 +16935,7 @@ var VFile = class {
17118
16935
  }
17119
16936
  /**
17120
16937
  * Set the extname (including dot) (example: `'.js'`).
16938
+ *
17121
16939
  * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
17122
16940
  * on windows).
17123
16941
  * Cannot be set if there’s no `path` yet.
@@ -17143,6 +16961,7 @@ var VFile = class {
17143
16961
  }
17144
16962
  /**
17145
16963
  * Set the stem (basename w/o extname) (example: `'index.min'`).
16964
+ *
17146
16965
  * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
17147
16966
  * on windows).
17148
16967
  * Cannot be nullified (use `file.path = file.dirname` instead).
@@ -17155,26 +16974,28 @@ var VFile = class {
17155
16974
  /**
17156
16975
  * Serialize the file.
17157
16976
  *
17158
- * @param {BufferEncoding} [encoding='utf8']
17159
- * When `value` is a `Buffer`, `encoding` is a character encoding to
17160
- * understand it as (default: `'utf8'`).
16977
+ * @param {BufferEncoding | null | undefined} [encoding='utf8']
16978
+ * Character encoding to understand `value` as when it’s a `Buffer`
16979
+ * (default: `'utf8'`).
17161
16980
  * @returns {string}
17162
16981
  * Serialized file.
17163
16982
  */
17164
16983
  toString(encoding) {
17165
- return (this.value || "").toString(encoding);
16984
+ return (this.value || "").toString(encoding || void 0);
17166
16985
  }
17167
16986
  /**
17168
- * Constructs a new `VFileMessage`, where `fatal` is set to `false`, and
17169
- * associates it with the file by adding it to `vfile.messages` and setting
17170
- * `message.file` to the current filepath.
16987
+ * Create a warning message associated with the file.
16988
+ *
16989
+ * Its `fatal` is set to `false` and `file` is set to the current file path.
16990
+ * Its added to `file.messages`.
17171
16991
  *
17172
- * @param {string|Error|VFileMessage} reason
17173
- * Human readable reason for the message, uses the stack and message of the error if given.
17174
- * @param {Node|NodeLike|Position|Point} [place]
17175
- * Place where the message occurred in the file.
17176
- * @param {string} [origin]
17177
- * Computer readable reason for the message
16992
+ * @param {string | Error | VFileMessage} reason
16993
+ * Reason for message, uses the stack and message of the error if given.
16994
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
16995
+ * Place in file where the message occurred.
16996
+ * @param {string | null | undefined} [origin]
16997
+ * Place in code where the message originates (example:
16998
+ * `'my-package:my-rule'` or `'my-rule'`).
17178
16999
  * @returns {VFileMessage}
17179
17000
  * Message.
17180
17001
  */
@@ -17189,15 +17010,18 @@ var VFile = class {
17189
17010
  return message;
17190
17011
  }
17191
17012
  /**
17192
- * Like `VFile#message()`, but associates an informational message where
17193
- * `fatal` is set to `null`.
17013
+ * Create an info message associated with the file.
17194
17014
  *
17195
- * @param {string|Error|VFileMessage} reason
17196
- * Human readable reason for the message, uses the stack and message of the error if given.
17197
- * @param {Node|NodeLike|Position|Point} [place]
17198
- * Place where the message occurred in the file.
17199
- * @param {string} [origin]
17200
- * Computer readable reason for the message
17015
+ * Its `fatal` is set to `null` and `file` is set to the current file path.
17016
+ * Its added to `file.messages`.
17017
+ *
17018
+ * @param {string | Error | VFileMessage} reason
17019
+ * Reason for message, uses the stack and message of the error if given.
17020
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
17021
+ * Place in file where the message occurred.
17022
+ * @param {string | null | undefined} [origin]
17023
+ * Place in code where the message originates (example:
17024
+ * `'my-package:my-rule'` or `'my-rule'`).
17201
17025
  * @returns {VFileMessage}
17202
17026
  * Message.
17203
17027
  */
@@ -17207,19 +17031,24 @@ var VFile = class {
17207
17031
  return message;
17208
17032
  }
17209
17033
  /**
17210
- * Like `VFile#message()`, but associates a fatal message where `fatal` is
17211
- * set to `true`, and then immediately throws it.
17034
+ * Create a fatal error associated with the file.
17035
+ *
17036
+ * Its `fatal` is set to `true` and `file` is set to the current file path.
17037
+ * Its added to `file.messages`.
17212
17038
  *
17213
17039
  * > πŸ‘‰ **Note**: a fatal error means that a file is no longer processable.
17214
17040
  *
17215
- * @param {string|Error|VFileMessage} reason
17216
- * Human readable reason for the message, uses the stack and message of the error if given.
17217
- * @param {Node|NodeLike|Position|Point} [place]
17218
- * Place where the message occurred in the file.
17219
- * @param {string} [origin]
17220
- * Computer readable reason for the message
17041
+ * @param {string | Error | VFileMessage} reason
17042
+ * Reason for message, uses the stack and message of the error if given.
17043
+ * @param {Node | NodeLike | Position | Point | null | undefined} [place]
17044
+ * Place in file where the message occurred.
17045
+ * @param {string | null | undefined} [origin]
17046
+ * Place in code where the message originates (example:
17047
+ * `'my-package:my-rule'` or `'my-rule'`).
17221
17048
  * @returns {never}
17222
17049
  * Message.
17050
+ * @throws {VFileMessage}
17051
+ * Message.
17223
17052
  */
17224
17053
  fail(reason, place, origin) {
17225
17054
  const message = this.message(reason, place, origin);
@@ -17244,6 +17073,9 @@ function assertPath(path, name) {
17244
17073
  throw new Error("Setting `" + name + "` requires `path` to be set too");
17245
17074
  }
17246
17075
  }
17076
+ function buffer(value) {
17077
+ return (0, import_is_buffer.default)(value);
17078
+ }
17247
17079
 
17248
17080
  // ../../node_modules/unified/lib/index.js
17249
17081
  var unified = base2().freeze();
@@ -17595,12 +17427,12 @@ var wrapLines = function wrapLines2(ast, linesToHighlight) {
17595
17427
  const highlightAll = linesToHighlight.length === 1 && linesToHighlight[0] === 0;
17596
17428
  const allLines = Array.from(new Set(ast.map((x) => x.lineNumber)));
17597
17429
  let i = 0;
17598
- const wrapped = allLines.reduce((nodes2, marker) => {
17430
+ const wrapped = allLines.reduce((nodes, marker) => {
17599
17431
  const line = marker;
17600
17432
  const children = [];
17601
17433
  for (; i < ast.length; i++) {
17602
17434
  if (ast[i].lineNumber < line) {
17603
- nodes2.push(ast[i]);
17435
+ nodes.push(ast[i]);
17604
17436
  continue;
17605
17437
  }
17606
17438
  if (ast[i].lineNumber === line) {
@@ -17611,7 +17443,7 @@ var wrapLines = function wrapLines2(ast, linesToHighlight) {
17611
17443
  break;
17612
17444
  }
17613
17445
  }
17614
- nodes2.push({
17446
+ nodes.push({
17615
17447
  type: "element",
17616
17448
  tagName: "div",
17617
17449
  properties: {
@@ -17622,7 +17454,7 @@ var wrapLines = function wrapLines2(ast, linesToHighlight) {
17622
17454
  children,
17623
17455
  lineNumber: line
17624
17456
  });
17625
- return nodes2;
17457
+ return nodes;
17626
17458
  }, []);
17627
17459
  return wrapped;
17628
17460
  };
@@ -17649,7 +17481,7 @@ function highlightWord(code) {
17649
17481
  const html5 = toHtml(code);
17650
17482
  const result = html5.replace(
17651
17483
  CALLOUT,
17652
- (_2, text3) => `<span class="highlight-word">${text3}</span>`
17484
+ (_2, text2) => `<span class="highlight-word">${text2}</span>`
17653
17485
  );
17654
17486
  const hast = unified().use(rehypeParse, { emitParseErrors: true, fragment: true }).parse(result);
17655
17487
  return hast.children;