@uiw/react-md-editor 3.19.0 → 3.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/mdeditor.js +1559 -1578
  2. package/dist/mdeditor.min.js +1 -1
  3. package/esm/Context.js.map +1 -1
  4. package/esm/Editor.js +43 -67
  5. package/esm/Editor.js.map +1 -1
  6. package/esm/commands/bold.js +4 -4
  7. package/esm/commands/bold.js.map +1 -1
  8. package/esm/commands/code.js +4 -6
  9. package/esm/commands/code.js.map +1 -1
  10. package/esm/commands/comment.js +4 -4
  11. package/esm/commands/comment.js.map +1 -1
  12. package/esm/commands/divider.js.map +1 -1
  13. package/esm/commands/fullscreen.js +3 -4
  14. package/esm/commands/fullscreen.js.map +2 -2
  15. package/esm/commands/group.js +2 -4
  16. package/esm/commands/group.js.map +1 -1
  17. package/esm/commands/hr.js.map +1 -1
  18. package/esm/commands/image.js +4 -4
  19. package/esm/commands/image.js.map +1 -1
  20. package/esm/commands/index.d.ts +2 -2
  21. package/esm/commands/index.js +6 -17
  22. package/esm/commands/index.js.map +3 -2
  23. package/esm/commands/italic.js +4 -4
  24. package/esm/commands/italic.js.map +1 -1
  25. package/esm/commands/link.js +4 -4
  26. package/esm/commands/link.js.map +1 -1
  27. package/esm/commands/list.js +4 -4
  28. package/esm/commands/list.js.map +1 -1
  29. package/esm/commands/preview.js +21 -3
  30. package/esm/commands/preview.js.map +7 -2
  31. package/esm/commands/quote.js +2 -1
  32. package/esm/commands/quote.js.map +1 -1
  33. package/esm/commands/strikeThrough.js +4 -4
  34. package/esm/commands/strikeThrough.js.map +1 -1
  35. package/esm/commands/title.js.map +1 -1
  36. package/esm/commands/title1.js.map +1 -1
  37. package/esm/commands/title2.js.map +1 -1
  38. package/esm/commands/title3.js.map +1 -1
  39. package/esm/commands/title4.js.map +1 -1
  40. package/esm/commands/title5.js.map +1 -1
  41. package/esm/commands/title6.js.map +1 -1
  42. package/esm/components/DragBar/index.js +2 -9
  43. package/esm/components/DragBar/index.js.map +1 -1
  44. package/esm/components/TextArea/Markdown.js +2 -7
  45. package/esm/components/TextArea/Markdown.js.map +1 -1
  46. package/esm/components/TextArea/Textarea.js +8 -11
  47. package/esm/components/TextArea/Textarea.js.map +1 -1
  48. package/esm/components/TextArea/handleKeyDown.js +2 -16
  49. package/esm/components/TextArea/handleKeyDown.js.map +1 -1
  50. package/esm/components/TextArea/index.js +11 -15
  51. package/esm/components/TextArea/index.js.map +1 -1
  52. package/esm/components/TextArea/shortcuts.js +1 -17
  53. package/esm/components/TextArea/shortcuts.js.map +2 -2
  54. package/esm/components/Toolbar/Child.js +2 -1
  55. package/esm/components/Toolbar/Child.js.map +1 -1
  56. package/esm/components/Toolbar/index.js +2 -12
  57. package/esm/components/Toolbar/index.js.map +1 -1
  58. package/esm/index.js.map +1 -1
  59. package/esm/utils/InsertTextAtPosition.js +28 -34
  60. package/esm/utils/InsertTextAtPosition.js.map +1 -1
  61. package/esm/utils/markdownUtils.js +14 -23
  62. package/esm/utils/markdownUtils.js.map +1 -1
  63. package/lib/Context.js +0 -6
  64. package/lib/Context.js.map +1 -1
  65. package/lib/Editor.js +74 -114
  66. package/lib/Editor.js.map +1 -1
  67. package/lib/commands/bold.js +4 -9
  68. package/lib/commands/bold.js.map +1 -1
  69. package/lib/commands/code.js +4 -11
  70. package/lib/commands/code.js.map +1 -1
  71. package/lib/commands/comment.js +4 -7
  72. package/lib/commands/comment.js.map +1 -1
  73. package/lib/commands/divider.js.map +1 -1
  74. package/lib/commands/fullscreen.js +3 -8
  75. package/lib/commands/fullscreen.js.map +2 -2
  76. package/lib/commands/group.js +2 -10
  77. package/lib/commands/group.js.map +1 -1
  78. package/lib/commands/hr.js +0 -4
  79. package/lib/commands/hr.js.map +1 -1
  80. package/lib/commands/image.js +4 -9
  81. package/lib/commands/image.js.map +1 -1
  82. package/lib/commands/index.d.ts +2 -2
  83. package/lib/commands/index.js +4 -41
  84. package/lib/commands/index.js.map +3 -2
  85. package/lib/commands/italic.js +4 -9
  86. package/lib/commands/italic.js.map +1 -1
  87. package/lib/commands/link.js +4 -9
  88. package/lib/commands/link.js.map +1 -1
  89. package/lib/commands/list.js +4 -10
  90. package/lib/commands/list.js.map +1 -1
  91. package/lib/commands/preview.js +21 -7
  92. package/lib/commands/preview.js.map +7 -2
  93. package/lib/commands/quote.js +2 -6
  94. package/lib/commands/quote.js.map +1 -1
  95. package/lib/commands/strikeThrough.js +4 -9
  96. package/lib/commands/strikeThrough.js.map +1 -1
  97. package/lib/commands/title.js +0 -6
  98. package/lib/commands/title.js.map +1 -1
  99. package/lib/commands/title1.js +0 -5
  100. package/lib/commands/title1.js.map +1 -1
  101. package/lib/commands/title2.js +0 -5
  102. package/lib/commands/title2.js.map +1 -1
  103. package/lib/commands/title3.js +0 -5
  104. package/lib/commands/title3.js.map +1 -1
  105. package/lib/commands/title4.js +0 -5
  106. package/lib/commands/title4.js.map +1 -1
  107. package/lib/commands/title5.js +0 -5
  108. package/lib/commands/title5.js.map +1 -1
  109. package/lib/commands/title6.js +0 -5
  110. package/lib/commands/title6.js.map +1 -1
  111. package/lib/components/DragBar/index.js +4 -15
  112. package/lib/components/DragBar/index.js.map +1 -1
  113. package/lib/components/TextArea/Markdown.js +6 -22
  114. package/lib/components/TextArea/Markdown.js.map +1 -1
  115. package/lib/components/TextArea/Textarea.js +15 -36
  116. package/lib/components/TextArea/Textarea.js.map +1 -1
  117. package/lib/components/TextArea/handleKeyDown.js +1 -18
  118. package/lib/components/TextArea/handleKeyDown.js.map +1 -1
  119. package/lib/components/TextArea/index.js +15 -37
  120. package/lib/components/TextArea/index.js.map +1 -1
  121. package/lib/components/TextArea/shortcuts.js +1 -17
  122. package/lib/components/TextArea/shortcuts.js.map +2 -2
  123. package/lib/components/Toolbar/Child.js +8 -18
  124. package/lib/components/Toolbar/Child.js.map +1 -1
  125. package/lib/components/Toolbar/index.js +14 -36
  126. package/lib/components/Toolbar/index.js.map +1 -1
  127. package/lib/index.js +0 -9
  128. package/lib/index.js.map +1 -1
  129. package/lib/utils/InsertTextAtPosition.js +28 -37
  130. package/lib/utils/InsertTextAtPosition.js.map +1 -1
  131. package/lib/utils/markdownUtils.js +17 -28
  132. package/lib/utils/markdownUtils.js.map +1 -1
  133. package/package.json +1 -1
  134. package/src/commands/fullscreen.tsx +3 -2
  135. package/src/commands/index.ts +3 -1
  136. package/src/commands/preview.tsx +35 -4
  137. package/src/components/TextArea/shortcuts.ts +2 -2
package/dist/mdeditor.js CHANGED
@@ -9651,25 +9651,20 @@ function _defineProperty(obj, key, value) {
9651
9651
  } else {
9652
9652
  obj[key] = value;
9653
9653
  }
9654
-
9655
9654
  return obj;
9656
9655
  }
9657
9656
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectSpread2.js
9658
9657
 
9659
-
9660
9658
  function ownKeys(object, enumerableOnly) {
9661
9659
  var keys = Object.keys(object);
9662
-
9663
9660
  if (Object.getOwnPropertySymbols) {
9664
9661
  var symbols = Object.getOwnPropertySymbols(object);
9665
9662
  enumerableOnly && (symbols = symbols.filter(function (sym) {
9666
9663
  return Object.getOwnPropertyDescriptor(object, sym).enumerable;
9667
9664
  })), keys.push.apply(keys, symbols);
9668
9665
  }
9669
-
9670
9666
  return keys;
9671
9667
  }
9672
-
9673
9668
  function _objectSpread2(target) {
9674
9669
  for (var i = 1; i < arguments.length; i++) {
9675
9670
  var source = null != arguments[i] ? arguments[i] : {};
@@ -9679,7 +9674,6 @@ function _objectSpread2(target) {
9679
9674
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
9680
9675
  });
9681
9676
  }
9682
-
9683
9677
  return target;
9684
9678
  }
9685
9679
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
@@ -9689,18 +9683,14 @@ function _arrayWithHoles(arr) {
9689
9683
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
9690
9684
  function _iterableToArrayLimit(arr, i) {
9691
9685
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
9692
-
9693
9686
  if (_i == null) return;
9694
9687
  var _arr = [];
9695
9688
  var _n = true;
9696
9689
  var _d = false;
9697
-
9698
9690
  var _s, _e;
9699
-
9700
9691
  try {
9701
9692
  for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
9702
9693
  _arr.push(_s.value);
9703
-
9704
9694
  if (i && _arr.length === i) break;
9705
9695
  }
9706
9696
  } catch (err) {
@@ -9713,17 +9703,14 @@ function _iterableToArrayLimit(arr, i) {
9713
9703
  if (_d) throw _e;
9714
9704
  }
9715
9705
  }
9716
-
9717
9706
  return _arr;
9718
9707
  }
9719
9708
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
9720
9709
  function _arrayLikeToArray(arr, len) {
9721
9710
  if (len == null || len > arr.length) len = arr.length;
9722
-
9723
9711
  for (var i = 0, arr2 = new Array(len); i < len; i++) {
9724
9712
  arr2[i] = arr[i];
9725
9713
  }
9726
-
9727
9714
  return arr2;
9728
9715
  }
9729
9716
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
@@ -9754,13 +9741,11 @@ function _objectWithoutPropertiesLoose(source, excluded) {
9754
9741
  var target = {};
9755
9742
  var sourceKeys = Object.keys(source);
9756
9743
  var key, i;
9757
-
9758
9744
  for (i = 0; i < sourceKeys.length; i++) {
9759
9745
  key = sourceKeys[i];
9760
9746
  if (excluded.indexOf(key) >= 0) continue;
9761
9747
  target[key] = source[key];
9762
9748
  }
9763
-
9764
9749
  return target;
9765
9750
  }
9766
9751
  ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
@@ -9769,10 +9754,8 @@ function _objectWithoutProperties(source, excluded) {
9769
9754
  if (source == null) return {};
9770
9755
  var target = _objectWithoutPropertiesLoose(source, excluded);
9771
9756
  var key, i;
9772
-
9773
9757
  if (Object.getOwnPropertySymbols) {
9774
9758
  var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
9775
-
9776
9759
  for (i = 0; i < sourceSymbolKeys.length; i++) {
9777
9760
  key = sourceSymbolKeys[i];
9778
9761
  if (excluded.indexOf(key) >= 0) continue;
@@ -9780,7 +9763,6 @@ function _objectWithoutProperties(source, excluded) {
9780
9763
  target[key] = source[key];
9781
9764
  }
9782
9765
  }
9783
-
9784
9766
  return target;
9785
9767
  }
9786
9768
  // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
@@ -9791,14 +9773,12 @@ function _extends() {
9791
9773
  _extends = Object.assign ? Object.assign.bind() : function (target) {
9792
9774
  for (var i = 1; i < arguments.length; i++) {
9793
9775
  var source = arguments[i];
9794
-
9795
9776
  for (var key in source) {
9796
9777
  if (Object.prototype.hasOwnProperty.call(source, key)) {
9797
9778
  target[key] = source[key];
9798
9779
  }
9799
9780
  }
9800
9781
  }
9801
-
9802
9782
  return target;
9803
9783
  };
9804
9784
  return _extends.apply(this, arguments);
@@ -28460,448 +28440,590 @@ function remarkGfm(options = {}) {
28460
28440
  }
28461
28441
  }
28462
28442
 
28463
- // EXTERNAL MODULE: ../node_modules/github-slugger/index.js
28464
- var github_slugger = __webpack_require__(449);
28465
- ;// CONCATENATED MODULE: ../node_modules/hast-util-has-property/index.js
28466
- var hast_util_has_property_own = {}.hasOwnProperty
28467
-
28443
+ // EXTERNAL MODULE: ../node_modules/parse5/lib/parser/index.js
28444
+ var lib_parser = __webpack_require__(695);
28445
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-parse-selector/index.js
28468
28446
  /**
28469
- * Check if `node` has a set `name` property.
28470
- *
28471
- * @param {unknown} node
28472
- * @param {string} name
28473
- * @returns {boolean}
28447
+ * @typedef {import('hast').Properties} Properties
28448
+ * @typedef {import('hast').Element} Element
28474
28449
  */
28475
- function hasProperty(node, name) {
28476
- /** @type {unknown} */
28477
- var value =
28478
- name &&
28479
- node &&
28480
- typeof node === 'object' &&
28481
- // @ts-ignore Looks like a node.
28482
- node.type === 'element' &&
28483
- // @ts-ignore Looks like an element.
28484
- node.properties &&
28485
- // @ts-ignore Looks like an element.
28486
- hast_util_has_property_own.call(node.properties, name) &&
28487
- // @ts-ignore Looks like an element.
28488
- node.properties[name]
28489
-
28490
- return value !== null && value !== undefined && value !== false
28491
- }
28492
28450
 
28493
- ;// CONCATENATED MODULE: ../node_modules/hast-util-heading-rank/index.js
28494
- /**
28495
- * @typedef {import('hast').Parent} Parent
28496
- * @typedef {import('hast').Root} Root
28497
- * @typedef {Root|Parent['children'][number]} Node
28498
- */
28451
+ var hast_util_parse_selector_search = /[#.]/g
28499
28452
 
28500
28453
  /**
28501
- * Rank of a heading: H1 -> 1, H2 -> 2, etc.
28454
+ * Create a hast element from a simple CSS selector.
28502
28455
  *
28503
- * @param {Node} node
28504
- * @returns {number|null}
28456
+ * @param selector A simple CSS selector.
28457
+ * Can contain a tag-name (`foo`), classes (`.bar`), and an ID (`#baz`).
28458
+ * Multiple classes are allowed.
28459
+ * Uses the last ID if multiple IDs are found.
28460
+ * @param [defaultTagName='div'] Tag name to use if `selector` does not specify one.
28505
28461
  */
28506
- function headingRank(node) {
28507
- var name =
28508
- (node && node.type === 'element' && node.tagName.toLowerCase()) || ''
28509
- var code =
28510
- name.length === 2 && name.charCodeAt(0) === 104 /* `h` */
28511
- ? name.charCodeAt(1)
28512
- : 0
28513
- return code > 48 /* `0` */ && code < 55 /* `7` */ ? code - 48 /* `0` */ : null
28514
- }
28462
+ const parseSelector =
28463
+ /**
28464
+ * @type {(
28465
+ * <Selector extends string, DefaultTagName extends string = 'div'>(selector?: Selector, defaultTagName?: DefaultTagName) => Element & {tagName: import('./extract.js').ExtractTagName<Selector, DefaultTagName>}
28466
+ * )}
28467
+ */
28468
+ (
28469
+ /**
28470
+ * @param {string} [selector]
28471
+ * @param {string} [defaultTagName='div']
28472
+ * @returns {Element}
28473
+ */
28474
+ function (selector, defaultTagName = 'div') {
28475
+ var value = selector || ''
28476
+ /** @type {Properties} */
28477
+ var props = {}
28478
+ var start = 0
28479
+ /** @type {string} */
28480
+ var subvalue
28481
+ /** @type {string} */
28482
+ var previous
28483
+ /** @type {RegExpMatchArray} */
28484
+ var match
28515
28485
 
28516
- ;// CONCATENATED MODULE: ../node_modules/hast-util-to-string/index.js
28517
- /**
28518
- * @fileoverview
28519
- * Get the plain-text value of a hast node.
28520
- * @longdescription
28521
- * ## Use
28522
- *
28523
- * ```js
28524
- * import {h} from 'hastscript'
28525
- * import {toString} from 'hast-util-to-string'
28526
- *
28527
- * toString(h('p', 'Alpha'))
28528
- * //=> 'Alpha'
28529
- * toString(h('div', [h('b', 'Bold'), ' and ', h('i', 'italic'), '.']))
28530
- * //=> 'Bold and italic.'
28531
- * ```
28532
- *
28533
- * ## API
28534
- *
28535
- * ### `toString(node)`
28536
- *
28537
- * Transform a node to a string.
28538
- */
28486
+ while (start < value.length) {
28487
+ hast_util_parse_selector_search.lastIndex = start
28488
+ match = hast_util_parse_selector_search.exec(value)
28489
+ subvalue = value.slice(start, match ? match.index : value.length)
28490
+
28491
+ if (subvalue) {
28492
+ if (!previous) {
28493
+ defaultTagName = subvalue
28494
+ } else if (previous === '#') {
28495
+ props.id = subvalue
28496
+ } else if (Array.isArray(props.className)) {
28497
+ props.className.push(subvalue)
28498
+ } else {
28499
+ props.className = [subvalue]
28500
+ }
28501
+
28502
+ start += subvalue.length
28503
+ }
28504
+
28505
+ if (match) {
28506
+ previous = match[0]
28507
+ start++
28508
+ }
28509
+ }
28510
+
28511
+ return {
28512
+ type: 'element',
28513
+ tagName: defaultTagName,
28514
+ properties: props,
28515
+ children: []
28516
+ }
28517
+ }
28518
+ )
28539
28519
 
28520
+ ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/core.js
28540
28521
  /**
28541
28522
  * @typedef {import('hast').Root} Root
28542
28523
  * @typedef {import('hast').Element} Element
28543
- * @typedef {Root|Root['children'][number]} Node
28524
+ * @typedef {import('hast').Properties} Properties
28525
+ * @typedef {Root['children'][number]} Child
28526
+ * @typedef {Child|Root} Node
28527
+ * @typedef {import('property-information').Info} Info
28528
+ * @typedef {import('property-information').Schema} Schema
28529
+ *
28530
+ * @typedef {Root|Element} HResult
28531
+ * @typedef {string|number} HStyleValue
28532
+ * @typedef {Record<string, HStyleValue>} HStyle
28533
+ * @typedef {string|number|boolean|null|undefined} HPrimitiveValue
28534
+ * @typedef {Array<string|number>} HArrayValue
28535
+ * @typedef {HPrimitiveValue|HArrayValue} HPropertyValue
28536
+ * @typedef {{[property: string]: HPropertyValue|HStyle}} HProperties
28537
+ * Acceptable properties value.
28538
+ *
28539
+ * @typedef {string|number|null|undefined} HPrimitiveChild
28540
+ * @typedef {Array<Node|HPrimitiveChild>} HArrayChild
28541
+ * @typedef {Node|HPrimitiveChild|HArrayChild} HChild
28542
+ * Acceptable child value
28544
28543
  */
28545
28544
 
28545
+
28546
+
28547
+
28548
+
28549
+
28550
+ const buttonTypes = new Set(['menu', 'submit', 'reset', 'button'])
28551
+
28552
+ const core_own = {}.hasOwnProperty
28553
+
28546
28554
  /**
28547
- * Get the plain-text value of a hast node.
28548
- *
28549
- * @param {Node} node
28550
- * @returns {string}
28555
+ * @param {Schema} schema
28556
+ * @param {string} defaultTagName
28557
+ * @param {Array<string>} [caseSensitive]
28551
28558
  */
28552
- function hast_util_to_string_toString(node) {
28553
- // “The concatenation of data of all the Text node descendants of the context
28554
- // object, in tree order.”
28555
- if ('children' in node) {
28556
- return hast_util_to_string_all(node)
28557
- }
28559
+ function core_core(schema, defaultTagName, caseSensitive) {
28560
+ const adjust = caseSensitive && createAdjustMap(caseSensitive)
28558
28561
 
28559
- // “Context object’s data.”
28560
- return 'value' in node ? node.value : ''
28562
+ const h =
28563
+ /**
28564
+ * @type {{
28565
+ * (): Root
28566
+ * (selector: null|undefined, ...children: Array<HChild>): Root
28567
+ * (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
28568
+ * (selector: string, ...children: Array<HChild>): Element
28569
+ * }}
28570
+ */
28571
+ (
28572
+ /**
28573
+ * Hyperscript compatible DSL for creating virtual hast trees.
28574
+ *
28575
+ * @param {string|null} [selector]
28576
+ * @param {HProperties|HChild} [properties]
28577
+ * @param {Array<HChild>} children
28578
+ * @returns {HResult}
28579
+ */
28580
+ function (selector, properties, ...children) {
28581
+ let index = -1
28582
+ /** @type {HResult} */
28583
+ let node
28584
+
28585
+ if (selector === undefined || selector === null) {
28586
+ node = {type: 'root', children: []}
28587
+ // @ts-expect-error Properties are not supported for roots.
28588
+ children.unshift(properties)
28589
+ } else {
28590
+ node = parseSelector(selector, defaultTagName)
28591
+ // Normalize the name.
28592
+ node.tagName = node.tagName.toLowerCase()
28593
+ if (adjust && core_own.call(adjust, node.tagName)) {
28594
+ node.tagName = adjust[node.tagName]
28595
+ }
28596
+
28597
+ // Handle props.
28598
+ if (isProperties(properties, node.tagName)) {
28599
+ /** @type {string} */
28600
+ let key
28601
+
28602
+ for (key in properties) {
28603
+ if (core_own.call(properties, key)) {
28604
+ // @ts-expect-error `node.properties` is set.
28605
+ core_addProperty(schema, node.properties, key, properties[key])
28606
+ }
28607
+ }
28608
+ } else {
28609
+ children.unshift(properties)
28610
+ }
28611
+ }
28612
+
28613
+ // Handle children.
28614
+ while (++index < children.length) {
28615
+ addChild(node.children, children[index])
28616
+ }
28617
+
28618
+ if (node.type === 'element' && node.tagName === 'template') {
28619
+ node.content = {type: 'root', children: node.children}
28620
+ node.children = []
28621
+ }
28622
+
28623
+ return node
28624
+ }
28625
+ )
28626
+
28627
+ return h
28561
28628
  }
28562
28629
 
28563
28630
  /**
28564
- * @param {Node} node
28565
- * @returns {string}
28631
+ * @param {HProperties|HChild} value
28632
+ * @param {string} name
28633
+ * @returns {value is HProperties}
28566
28634
  */
28567
- function hast_util_to_string_one(node) {
28568
- if (node.type === 'text') {
28569
- return node.value
28635
+ function isProperties(value, name) {
28636
+ if (
28637
+ value === null ||
28638
+ value === undefined ||
28639
+ typeof value !== 'object' ||
28640
+ Array.isArray(value)
28641
+ ) {
28642
+ return false
28570
28643
  }
28571
28644
 
28572
- return 'children' in node ? hast_util_to_string_all(node) : ''
28573
- }
28645
+ if (name === 'input' || !value.type || typeof value.type !== 'string') {
28646
+ return true
28647
+ }
28574
28648
 
28575
- /**
28576
- * @param {Root|Element} node
28577
- * @returns {string}
28578
- */
28579
- function hast_util_to_string_all(node) {
28580
- let index = -1
28581
- /** @type {string[]} */
28582
- const result = []
28649
+ if ('children' in value && Array.isArray(value.children)) {
28650
+ return false
28651
+ }
28583
28652
 
28584
- while (++index < node.children.length) {
28585
- result[index] = hast_util_to_string_one(node.children[index])
28653
+ if (name === 'button') {
28654
+ return buttonTypes.has(value.type.toLowerCase())
28586
28655
  }
28587
28656
 
28588
- return result.join('')
28657
+ return !('value' in value)
28589
28658
  }
28590
28659
 
28591
- ;// CONCATENATED MODULE: ../node_modules/rehype-slug/index.js
28592
28660
  /**
28593
- * @typedef {import('hast').Root} Root
28661
+ * @param {Schema} schema
28662
+ * @param {Properties} properties
28663
+ * @param {string} key
28664
+ * @param {HStyle|HPropertyValue} value
28665
+ * @returns {void}
28594
28666
  */
28667
+ function core_addProperty(schema, properties, key, value) {
28668
+ const info = find(schema, key)
28669
+ let index = -1
28670
+ /** @type {HPropertyValue} */
28671
+ let result
28672
+
28673
+ // Ignore nullish and NaN values.
28674
+ if (value === undefined || value === null) return
28595
28675
 
28676
+ if (typeof value === 'number') {
28677
+ // Ignore NaN.
28678
+ if (Number.isNaN(value)) return
28596
28679
 
28680
+ result = value
28681
+ }
28682
+ // Booleans.
28683
+ else if (typeof value === 'boolean') {
28684
+ result = value
28685
+ }
28686
+ // Handle list values.
28687
+ else if (typeof value === 'string') {
28688
+ if (info.spaceSeparated) {
28689
+ result = space_separated_tokens_parse(value)
28690
+ } else if (info.commaSeparated) {
28691
+ result = comma_separated_tokens_parse(value)
28692
+ } else if (info.commaOrSpaceSeparated) {
28693
+ result = space_separated_tokens_parse(comma_separated_tokens_parse(value).join(' '))
28694
+ } else {
28695
+ result = parsePrimitive(info, info.property, value)
28696
+ }
28697
+ } else if (Array.isArray(value)) {
28698
+ result = value.concat()
28699
+ } else {
28700
+ result = info.property === 'style' ? style(value) : String(value)
28701
+ }
28597
28702
 
28703
+ if (Array.isArray(result)) {
28704
+ /** @type {Array<string|number>} */
28705
+ const finalResult = []
28598
28706
 
28707
+ while (++index < result.length) {
28708
+ // @ts-expect-error Assume no booleans in array.
28709
+ finalResult[index] = parsePrimitive(info, info.property, result[index])
28710
+ }
28599
28711
 
28712
+ result = finalResult
28713
+ }
28600
28714
 
28715
+ // Class names (which can be added both on the `selector` and here).
28716
+ if (info.property === 'className' && Array.isArray(properties.className)) {
28717
+ // @ts-expect-error Assume no booleans in `className`.
28718
+ result = properties.className.concat(result)
28719
+ }
28601
28720
 
28602
- const slugs = new github_slugger()
28721
+ properties[info.property] = result
28722
+ }
28603
28723
 
28604
28724
  /**
28605
- * Plugin to add `id`s to headings.
28606
- *
28607
- * @type {import('unified').Plugin<Array<void>, Root>}
28725
+ * @param {Array<Child>} nodes
28726
+ * @param {HChild} value
28727
+ * @returns {void}
28608
28728
  */
28609
- function rehypeSlug() {
28610
- return (tree) => {
28611
- slugs.reset()
28729
+ function addChild(nodes, value) {
28730
+ let index = -1
28612
28731
 
28613
- visit(tree, 'element', (node) => {
28614
- if (headingRank(node) && node.properties && !hasProperty(node, 'id')) {
28615
- node.properties.id = slugs.slug(hast_util_to_string_toString(node))
28616
- }
28617
- })
28732
+ if (value === undefined || value === null) {
28733
+ // Empty.
28734
+ } else if (typeof value === 'string' || typeof value === 'number') {
28735
+ nodes.push({type: 'text', value: String(value)})
28736
+ } else if (Array.isArray(value)) {
28737
+ while (++index < value.length) {
28738
+ addChild(nodes, value[index])
28739
+ }
28740
+ } else if (typeof value === 'object' && 'type' in value) {
28741
+ if (value.type === 'root') {
28742
+ addChild(nodes, value.children)
28743
+ } else {
28744
+ nodes.push(value)
28745
+ }
28746
+ } else {
28747
+ throw new Error('Expected node, nodes, or string, got `' + value + '`')
28618
28748
  }
28619
28749
  }
28620
28750
 
28621
- ;// CONCATENATED MODULE: ../node_modules/hast-util-is-element/index.js
28622
28751
  /**
28623
- * @typedef {import('unist').Node} Node
28624
- * @typedef {import('unist').Parent} Parent
28625
- * @typedef {import('hast').Element} Element
28752
+ * Parse a single primitives.
28626
28753
  *
28627
- * @typedef {string} TagName
28628
- * @typedef {null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>} Test
28754
+ * @param {Info} info
28755
+ * @param {string} name
28756
+ * @param {HPrimitiveValue} value
28757
+ * @returns {HPrimitiveValue}
28629
28758
  */
28759
+ function parsePrimitive(info, name, value) {
28760
+ if (typeof value === 'string') {
28761
+ if (info.number && value && !Number.isNaN(Number(value))) {
28762
+ return Number(value)
28763
+ }
28630
28764
 
28631
- /**
28632
- * @template {Element} T
28633
- * @typedef {null|undefined|T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>} PredicateTest
28634
- */
28765
+ if (
28766
+ (info.boolean || info.overloadedBoolean) &&
28767
+ (value === '' || normalize_normalize(value) === normalize_normalize(name))
28768
+ ) {
28769
+ return true
28770
+ }
28771
+ }
28635
28772
 
28636
- /**
28637
- * Check if an element passes a test
28638
- *
28639
- * @callback TestFunctionAnything
28640
- * @param {Element} element
28641
- * @param {number|null|undefined} [index]
28642
- * @param {Parent|null|undefined} [parent]
28643
- * @returns {boolean|void}
28644
- */
28773
+ return value
28774
+ }
28645
28775
 
28646
28776
  /**
28647
- * Check if an element passes a certain node test
28648
- *
28649
- * @template {Element} X
28650
- * @callback TestFunctionPredicate
28651
- * @param {Element} element
28652
- * @param {number|null|undefined} [index]
28653
- * @param {Parent|null|undefined} [parent]
28654
- * @returns {element is X}
28777
+ * @param {HStyle} value
28778
+ * @returns {string}
28655
28779
  */
28780
+ function style(value) {
28781
+ /** @type {Array<string>} */
28782
+ const result = []
28783
+ /** @type {string} */
28784
+ let key
28656
28785
 
28657
- /**
28658
- * Check if a node is an element and passes a certain node test
28659
- *
28660
- * @callback AssertAnything
28661
- * @param {unknown} [node]
28662
- * @param {number|null|undefined} [index]
28663
- * @param {Parent|null|undefined} [parent]
28664
- * @returns {boolean}
28665
- */
28786
+ for (key in value) {
28787
+ if (core_own.call(value, key)) {
28788
+ result.push([key, value[key]].join(': '))
28789
+ }
28790
+ }
28791
+
28792
+ return result.join('; ')
28793
+ }
28666
28794
 
28667
28795
  /**
28668
- * Check if a node is an element and passes a certain node test
28669
- *
28670
- * @template {Element} Y
28671
- * @callback AssertPredicate
28672
- * @param {unknown} [node]
28673
- * @param {number|null|undefined} [index]
28674
- * @param {Parent|null|undefined} [parent]
28675
- * @returns {node is Y}
28796
+ * @param {Array<string>} values
28797
+ * @returns {Record<string, string>}
28676
28798
  */
28799
+ function createAdjustMap(values) {
28800
+ /** @type {Record<string, string>} */
28801
+ const result = {}
28802
+ let index = -1
28677
28803
 
28678
- // Check if `node` is an `element` and whether it passes the given test.
28679
- const isElement =
28680
- /**
28681
- * Check if a node is an element and passes a test.
28682
- * When a `parent` node is known the `index` of node should also be given.
28683
- *
28684
- * @type {(
28685
- * (() => false) &
28686
- * (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) &
28687
- * ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
28688
- * )}
28689
- */
28690
- (
28691
- /**
28692
- * Check if a node passes a test.
28693
- * When a `parent` node is known the `index` of node should also be given.
28694
- *
28695
- * @param {unknown} [node] Node to check
28696
- * @param {Test} [test] When nullish, checks if `node` is a `Node`.
28697
- * When `string`, works like passing `function (node) {return node.type === test}`.
28698
- * When `function` checks if function passed the node is true.
28699
- * When `array`, checks any one of the subtests pass.
28700
- * @param {number} [index] Position of `node` in `parent`
28701
- * @param {Parent} [parent] Parent of `node`
28702
- * @param {unknown} [context] Context object to invoke `test` with
28703
- * @returns {boolean} Whether test passed and `node` is an `Element` (object with `type` set to `element` and `tagName` set to a non-empty string).
28704
- */
28705
- // eslint-disable-next-line max-params
28706
- function (node, test, index, parent, context) {
28707
- const check = convertElement(test)
28804
+ while (++index < values.length) {
28805
+ result[values[index].toLowerCase()] = values[index]
28806
+ }
28708
28807
 
28709
- if (
28710
- index !== undefined &&
28711
- index !== null &&
28712
- (typeof index !== 'number' ||
28713
- index < 0 ||
28714
- index === Number.POSITIVE_INFINITY)
28715
- ) {
28716
- throw new Error('Expected positive finite index for child node')
28717
- }
28808
+ return result
28809
+ }
28718
28810
 
28719
- if (
28720
- parent !== undefined &&
28721
- parent !== null &&
28722
- (!parent.type || !parent.children)
28723
- ) {
28724
- throw new Error('Expected parent node')
28725
- }
28811
+ ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
28812
+ const svgCaseSensitiveTagNames = [
28813
+ 'altGlyph',
28814
+ 'altGlyphDef',
28815
+ 'altGlyphItem',
28816
+ 'animateColor',
28817
+ 'animateMotion',
28818
+ 'animateTransform',
28819
+ 'clipPath',
28820
+ 'feBlend',
28821
+ 'feColorMatrix',
28822
+ 'feComponentTransfer',
28823
+ 'feComposite',
28824
+ 'feConvolveMatrix',
28825
+ 'feDiffuseLighting',
28826
+ 'feDisplacementMap',
28827
+ 'feDistantLight',
28828
+ 'feDropShadow',
28829
+ 'feFlood',
28830
+ 'feFuncA',
28831
+ 'feFuncB',
28832
+ 'feFuncG',
28833
+ 'feFuncR',
28834
+ 'feGaussianBlur',
28835
+ 'feImage',
28836
+ 'feMerge',
28837
+ 'feMergeNode',
28838
+ 'feMorphology',
28839
+ 'feOffset',
28840
+ 'fePointLight',
28841
+ 'feSpecularLighting',
28842
+ 'feSpotLight',
28843
+ 'feTile',
28844
+ 'feTurbulence',
28845
+ 'foreignObject',
28846
+ 'glyphRef',
28847
+ 'linearGradient',
28848
+ 'radialGradient',
28849
+ 'solidColor',
28850
+ 'textArea',
28851
+ 'textPath'
28852
+ ]
28726
28853
 
28727
- // @ts-expect-error Looks like a node.
28728
- if (!node || !node.type || typeof node.type !== 'string') {
28729
- return false
28730
- }
28854
+ ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/svg.js
28855
+ /**
28856
+ * @typedef {import('./core.js').HChild} Child
28857
+ * @typedef {import('./core.js').HProperties} Properties
28858
+ *
28859
+ * @typedef {import('./jsx-classic').Element} s.JSX.Element
28860
+ * @typedef {import('./jsx-classic').IntrinsicAttributes} s.JSX.IntrinsicAttributes
28861
+ * @typedef {import('./jsx-classic').IntrinsicElements} s.JSX.IntrinsicElements
28862
+ * @typedef {import('./jsx-classic').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
28863
+ */
28731
28864
 
28732
- if (
28733
- (parent === undefined || parent === null) !==
28734
- (index === undefined || index === null)
28735
- ) {
28736
- throw new Error('Expected both parent and index')
28737
- }
28738
28865
 
28739
- return check.call(context, node, index, parent)
28740
- }
28741
- )
28742
28866
 
28743
- const convertElement =
28744
- /**
28745
- * @type {(
28746
- * (<T extends Element>(test: T['tagName']|TestFunctionPredicate<T>) => AssertPredicate<T>) &
28747
- * ((test?: Test) => AssertAnything)
28748
- * )}
28749
- */
28750
- (
28751
- /**
28752
- * Generate an assertion from a check.
28753
- * @param {Test} [test]
28754
- * When nullish, checks if `node` is a `Node`.
28755
- * When `string`, works like passing `function (node) {return node.type === test}`.
28756
- * When `function` checks if function passed the node is true.
28757
- * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
28758
- * When `array`, checks any one of the subtests pass.
28759
- * @returns {AssertAnything}
28760
- */
28761
- function (test) {
28762
- if (test === undefined || test === null) {
28763
- return hast_util_is_element_element
28764
- }
28765
28867
 
28766
- if (typeof test === 'string') {
28767
- return tagNameFactory(test)
28768
- }
28769
28868
 
28770
- if (typeof test === 'object') {
28771
- return hast_util_is_element_anyFactory(test)
28772
- }
28869
+ const s = core_core(property_information_svg, 'g', svgCaseSensitiveTagNames)
28870
+
28871
+ ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/html.js
28872
+ /**
28873
+ * @typedef {import('./core.js').HChild} Child Acceptable child value
28874
+ * @typedef {import('./core.js').HProperties} Properties Acceptable properties value.
28875
+ *
28876
+ * @typedef {import('./jsx-classic').Element} h.JSX.Element
28877
+ * @typedef {import('./jsx-classic').IntrinsicAttributes} h.JSX.IntrinsicAttributes
28878
+ * @typedef {import('./jsx-classic').IntrinsicElements} h.JSX.IntrinsicElements
28879
+ * @typedef {import('./jsx-classic').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
28880
+ */
28881
+
28773
28882
 
28774
- if (typeof test === 'function') {
28775
- return hast_util_is_element_castFactory(test)
28776
- }
28777
28883
 
28778
- throw new Error('Expected function, string, or array as test')
28779
- }
28780
- )
28781
28884
 
28885
+ const h = core_core(property_information_html, 'div')
28886
+
28887
+ ;// CONCATENATED MODULE: ../node_modules/vfile-location/index.js
28782
28888
  /**
28783
- * @param {Array.<TagName|TestFunctionAnything>} tests
28784
- * @returns {AssertAnything}
28889
+ * @typedef {import('unist').Point} Point
28890
+ * @typedef {import('vfile').VFile} VFile
28891
+ *
28892
+ * @typedef {Pick<Point, 'line'|'column'>} PositionalPoint
28893
+ * @typedef {Required<Point>} FullPoint
28894
+ * @typedef {NonNullable<Point['offset']>} Offset
28785
28895
  */
28786
- function hast_util_is_element_anyFactory(tests) {
28787
- /** @type {Array.<AssertAnything>} */
28788
- const checks = []
28789
- let index = -1
28790
28896
 
28791
- while (++index < tests.length) {
28792
- checks[index] = convertElement(tests[index])
28897
+ /**
28898
+ * Get transform functions for the given `document`.
28899
+ *
28900
+ * @param {string|Uint8Array|VFile} file
28901
+ */
28902
+ function vfile_location_location(file) {
28903
+ var value = String(file)
28904
+ /** @type {Array.<number>} */
28905
+ var indices = []
28906
+ var search = /\r?\n|\r/g
28907
+
28908
+ while (search.test(value)) {
28909
+ indices.push(search.lastIndex)
28793
28910
  }
28794
28911
 
28795
- return hast_util_is_element_castFactory(any)
28912
+ indices.push(value.length + 1)
28913
+
28914
+ return {toPoint, toOffset}
28796
28915
 
28797
28916
  /**
28798
- * @this {unknown}
28799
- * @param {unknown[]} parameters
28800
- * @returns {boolean}
28917
+ * Get the line and column-based `point` for `offset` in the bound indices.
28918
+ * Returns a point with `undefined` values when given invalid or out of bounds
28919
+ * input.
28920
+ *
28921
+ * @param {Offset} offset
28922
+ * @returns {FullPoint}
28801
28923
  */
28802
- function any(...parameters) {
28803
- let index = -1
28924
+ function toPoint(offset) {
28925
+ var index = -1
28804
28926
 
28805
- while (++index < checks.length) {
28806
- if (checks[index].call(this, ...parameters)) {
28807
- return true
28927
+ if (offset > -1 && offset < indices[indices.length - 1]) {
28928
+ while (++index < indices.length) {
28929
+ if (indices[index] > offset) {
28930
+ return {
28931
+ line: index + 1,
28932
+ column: offset - (indices[index - 1] || 0) + 1,
28933
+ offset
28934
+ }
28935
+ }
28808
28936
  }
28809
28937
  }
28810
28938
 
28811
- return false
28939
+ return {line: undefined, column: undefined, offset: undefined}
28812
28940
  }
28813
- }
28814
-
28815
- /**
28816
- * Utility to convert a string into a function which checks a given node’s tag
28817
- * name for said string.
28818
- *
28819
- * @param {TagName} check
28820
- * @returns {AssertAnything}
28821
- */
28822
- function tagNameFactory(check) {
28823
- return tagName
28824
28941
 
28825
28942
  /**
28826
- * @param {unknown} node
28827
- * @returns {boolean}
28943
+ * Get the `offset` for a line and column-based `point` in the bound indices.
28944
+ * Returns `-1` when given invalid or out of bounds input.
28945
+ *
28946
+ * @param {PositionalPoint} point
28947
+ * @returns {Offset}
28828
28948
  */
28829
- function tagName(node) {
28830
- return hast_util_is_element_element(node) && node.tagName === check
28831
- }
28832
- }
28949
+ function toOffset(point) {
28950
+ var line = point && point.line
28951
+ var column = point && point.column
28952
+ /** @type {number} */
28953
+ var offset
28833
28954
 
28834
- /**
28835
- * @param {TestFunctionAnything} check
28836
- * @returns {AssertAnything}
28837
- */
28838
- function hast_util_is_element_castFactory(check) {
28839
- return assertion
28955
+ if (
28956
+ typeof line === 'number' &&
28957
+ typeof column === 'number' &&
28958
+ !Number.isNaN(line) &&
28959
+ !Number.isNaN(column) &&
28960
+ line - 1 in indices
28961
+ ) {
28962
+ offset = (indices[line - 2] || 0) + column - 1 || 0
28963
+ }
28840
28964
 
28841
- /**
28842
- * @this {unknown}
28843
- * @param {unknown} node
28844
- * @param {Array.<unknown>} parameters
28845
- * @returns {boolean}
28846
- */
28847
- function assertion(node, ...parameters) {
28848
- // @ts-expect-error: fine.
28849
- return hast_util_is_element_element(node) && Boolean(check.call(this, node, ...parameters))
28965
+ return offset > -1 && offset < indices[indices.length - 1] ? offset : -1
28850
28966
  }
28851
28967
  }
28852
28968
 
28969
+ ;// CONCATENATED MODULE: ../node_modules/web-namespaces/index.js
28853
28970
  /**
28854
- * Utility to return true if this is an element.
28855
- * @param {unknown} node
28856
- * @returns {node is Element}
28971
+ * Map of web namespaces.
28972
+ *
28973
+ * @type {Record<string, string>}
28857
28974
  */
28858
- function hast_util_is_element_element(node) {
28859
- return Boolean(
28860
- node &&
28861
- typeof node === 'object' &&
28862
- // @ts-expect-error Looks like a node.
28863
- node.type === 'element' &&
28864
- // @ts-expect-error Looks like an element.
28865
- typeof node.tagName === 'string'
28866
- )
28975
+ const webNamespaces = {
28976
+ html: 'http://www.w3.org/1999/xhtml',
28977
+ mathml: 'http://www.w3.org/1998/Math/MathML',
28978
+ svg: 'http://www.w3.org/2000/svg',
28979
+ xlink: 'http://www.w3.org/1999/xlink',
28980
+ xml: 'http://www.w3.org/XML/1998/namespace',
28981
+ xmlns: 'http://www.w3.org/2000/xmlns/'
28867
28982
  }
28868
28983
 
28869
- ;// CONCATENATED MODULE: ../node_modules/rehype-autolink-headings/lib/index.js
28984
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-from-parse5/lib/index.js
28870
28985
  /**
28871
- * @typedef {import('hast').Root} Root
28986
+ * @typedef {import('vfile').VFile} VFile
28987
+ * @typedef {import('property-information').Schema} Schema
28988
+ * @typedef {import('unist').Position} Position
28989
+ * @typedef {import('unist').Point} Point
28872
28990
  * @typedef {import('hast').Parent} Parent
28873
28991
  * @typedef {import('hast').Element} Element
28992
+ * @typedef {import('hast').Root} Root
28993
+ * @typedef {import('hast').Text} Text
28994
+ * @typedef {import('hast').Comment} Comment
28995
+ * @typedef {import('hast').DocType} Doctype
28996
+ * @typedef {Parent['children'][number]} Child
28874
28997
  * @typedef {Element['children'][number]} ElementChild
28875
- * @typedef {import('hast').Properties} Properties
28876
- * @typedef {import('hast-util-is-element').Test} Test
28998
+ * @typedef {Child|Root} Node
28999
+ * @typedef {import('parse5').Document} P5Document
29000
+ * @typedef {import('parse5').DocumentType} P5Doctype
29001
+ * @typedef {import('parse5').CommentNode} P5Comment
29002
+ * @typedef {import('parse5').TextNode} P5Text
29003
+ * @typedef {import('parse5').Element} P5Element
29004
+ * @typedef {import('parse5').ElementLocation} P5ElementLocation
29005
+ * @typedef {import('parse5').Location} P5Location
29006
+ * @typedef {import('parse5').Attribute} P5Attribute
29007
+ * @typedef {import('parse5').Node} P5Node
28877
29008
  *
28878
- * @typedef {'prepend'|'append'|'wrap'|'before'|'after'} Behavior
29009
+ * @typedef {'html'|'svg'} Space
28879
29010
  *
28880
- * @callback Build
28881
- * @param {Element} node
28882
- * @returns {ElementChild|ElementChild[]}
29011
+ * @callback Handler
29012
+ * @param {Context} ctx
29013
+ * @param {P5Node} node
29014
+ * @param {Array.<Child>} [children]
29015
+ * @returns {Node}
28883
29016
  *
28884
29017
  * @typedef Options
28885
- * Configuration.
28886
- * @property {Behavior} [behavior='prepend']
28887
- * How to create links.
28888
- * @property {Behavior} [behaviour]
28889
- * Please use `behavior` instead
28890
- * @property {Properties} [properties]
28891
- * Extra properties to set on the link when injecting.
28892
- * Defaults to `{ariaHidden: true, tabIndex: -1}` when `'prepend'` or
28893
- * `'append'`.
28894
- * @property {ElementChild|ElementChild[]|Build} [content={type: 'element', tagName: 'span', properties: {className: ['icon', 'icon-link']}, children: []}]
28895
- * hast nodes to insert in the link.
28896
- * @property {ElementChild|ElementChild[]|Build} [group]
28897
- * hast node to wrap the heading and link with, if `behavior` is `'before'` or
28898
- * `'after'`.
28899
- * There is no default.
28900
- * @property {Test} [test]
28901
- * Test to define which heading elements are linked.
28902
- * Any test that can be given to `hast-util-is-element` is supported.
28903
- * The default (no test) is to link all headings.
28904
- * Can be used to link only h1-h3, or for example all except h1.
29018
+ * @property {Space} [space='html'] Whether the root of the tree is in the `'html'` or `'svg'` space. If an element in with the SVG namespace is found in `ast`, `fromParse5` automatically switches to the SVG space when entering the element, and switches back when leaving
29019
+ * @property {VFile} [file] `VFile`, used to add positional information to nodes. If given, the file should have the original HTML source as its contents
29020
+ * @property {boolean} [verbose=false] Whether to add extra positional information about starting tags, closing tags, and attributes to elements. Note: not used without `file`
29021
+ *
29022
+ * @typedef Context
29023
+ * @property {Schema} schema
29024
+ * @property {VFile|undefined} file
29025
+ * @property {boolean|undefined} verbose
29026
+ * @property {boolean} location
28905
29027
  */
28906
29028
 
28907
29029
 
@@ -28909,1058 +29031,339 @@ function hast_util_is_element_element(node) {
28909
29031
 
28910
29032
 
28911
29033
 
29034
+ const hast_util_from_parse5_lib_own = {}.hasOwnProperty
28912
29035
 
28913
- /** @type {Element} */
28914
- const contentDefaults = {
28915
- type: 'element',
28916
- tagName: 'span',
28917
- properties: {className: ['icon', 'icon-link']},
28918
- children: []
29036
+ // Handlers.
29037
+ const map = {
29038
+ '#document': lib_root,
29039
+ '#document-fragment': lib_root,
29040
+ '#text': lib_text,
29041
+ '#comment': comment,
29042
+ '#documentType': doctype
28919
29043
  }
28920
29044
 
28921
29045
  /**
28922
- * Plugin to automatically add links to headings (h1-h6).
29046
+ * Transform Parse5’s AST to a hast tree.
28923
29047
  *
28924
- * @type {import('unified').Plugin<[Options?]|void[], Root>}
29048
+ * @param {P5Node} ast
29049
+ * @param {Options|VFile} [options]
28925
29050
  */
28926
- function rehypeAutolinkHeadings(options = {}) {
28927
- let props = options.properties
28928
- const behavior = options.behaviour || options.behavior || 'prepend'
28929
- const content = options.content || contentDefaults
28930
- const group = options.group
28931
- const is = convertElement(options.test)
28932
-
28933
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
28934
- let method
29051
+ function fromParse5(ast, options = {}) {
29052
+ /** @type {Options} */
29053
+ let settings
29054
+ /** @type {VFile|undefined} */
29055
+ let file
28935
29056
 
28936
- if (behavior === 'wrap') {
28937
- method = wrap
28938
- } else if (behavior === 'before' || behavior === 'after') {
28939
- method = around
29057
+ if (isFile(options)) {
29058
+ file = options
29059
+ settings = {}
28940
29060
  } else {
28941
- if (!props) {
28942
- props = {ariaHidden: 'true', tabIndex: -1}
28943
- }
28944
-
28945
- method = inject
29061
+ file = options.file
29062
+ settings = options
28946
29063
  }
28947
29064
 
28948
- return (tree) => {
28949
- visit(tree, 'element', (node, index, parent) => {
28950
- if (
28951
- headingRank(node) &&
28952
- hasProperty(node, 'id') &&
28953
- is(node, index, parent)
28954
- ) {
28955
- return method(node, index, parent)
28956
- }
28957
- })
28958
- }
29065
+ return transform(
29066
+ {
29067
+ schema: settings.space === 'svg' ? property_information_svg : property_information_html,
29068
+ file,
29069
+ verbose: settings.verbose,
29070
+ location: false
29071
+ },
29072
+ ast
29073
+ )
29074
+ }
28959
29075
 
28960
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
28961
- function inject(node) {
28962
- node.children[behavior === 'prepend' ? 'unshift' : 'push'](
28963
- create(node, extend(true, {}, props), toChildren(content, node))
28964
- )
29076
+ /**
29077
+ * Transform children.
29078
+ *
29079
+ * @param {Context} ctx
29080
+ * @param {P5Node} ast
29081
+ * @returns {Node}
29082
+ */
29083
+ function transform(ctx, ast) {
29084
+ const schema = ctx.schema
29085
+ /** @type {Handler} */
29086
+ // @ts-expect-error: index is fine.
29087
+ const fn = hast_util_from_parse5_lib_own.call(map, ast.nodeName) ? map[ast.nodeName] : lib_element
29088
+ /** @type {Array.<Child>|undefined} */
29089
+ let children
28965
29090
 
28966
- return [SKIP]
29091
+ // Element.
29092
+ if ('tagName' in ast) {
29093
+ ctx.schema = ast.namespaceURI === webNamespaces.svg ? property_information_svg : property_information_html
28967
29094
  }
28968
29095
 
28969
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
28970
- function around(node, index, parent) {
28971
- // Uncommon.
28972
- /* c8 ignore next */
28973
- if (typeof index !== 'number' || !parent) return
29096
+ if ('childNodes' in ast) {
29097
+ children = nodes(ctx, ast.childNodes)
29098
+ }
28974
29099
 
28975
- const link = create(
28976
- node,
28977
- extend(true, {}, props),
28978
- toChildren(content, node)
28979
- )
28980
- let nodes = behavior === 'before' ? [link, node] : [node, link]
29100
+ const result = fn(ctx, ast, children)
28981
29101
 
28982
- if (group) {
28983
- const grouping = toNode(group, node)
29102
+ if ('sourceCodeLocation' in ast && ast.sourceCodeLocation && ctx.file) {
29103
+ // @ts-expect-error It’s fine.
29104
+ const position = createLocation(ctx, result, ast.sourceCodeLocation)
28984
29105
 
28985
- if (grouping && !Array.isArray(grouping) && grouping.type === 'element') {
28986
- grouping.children = nodes
28987
- nodes = [grouping]
28988
- }
29106
+ if (position) {
29107
+ ctx.location = true
29108
+ result.position = position
28989
29109
  }
28990
-
28991
- parent.children.splice(index, 1, ...nodes)
28992
-
28993
- return [SKIP, index + nodes.length]
28994
- }
28995
-
28996
- /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
28997
- function wrap(node) {
28998
- node.children = [create(node, extend(true, {}, props), node.children)]
28999
- return [SKIP]
29000
- }
29001
-
29002
- /**
29003
- * @param {ElementChild|ElementChild[]|Build} value
29004
- * @param {Element} node
29005
- * @returns {ElementChild[]}
29006
- */
29007
- function toChildren(value, node) {
29008
- const result = toNode(value, node)
29009
- return Array.isArray(result) ? result : [result]
29010
29110
  }
29011
29111
 
29012
- /**
29013
- * @param {ElementChild|ElementChild[]|Build} value
29014
- * @param {Element} node
29015
- * @returns {ElementChild|ElementChild[]}
29016
- */
29017
- function toNode(value, node) {
29018
- if (typeof value === 'function') return value(node)
29019
- return extend(true, Array.isArray(value) ? [] : {}, value)
29020
- }
29112
+ ctx.schema = schema
29021
29113
 
29022
- /**
29023
- * @param {Element} node
29024
- * @param {Properties} props
29025
- * @param {ElementChild[]} children
29026
- * @returns {Element}
29027
- */
29028
- function create(node, props, children) {
29029
- return {
29030
- type: 'element',
29031
- tagName: 'a',
29032
- properties: Object.assign({}, props, {
29033
- // Fix hast types and make them required.
29034
- /* c8 ignore next */
29035
- href: '#' + (node.properties || {}).id
29036
- }),
29037
- children
29038
- }
29039
- }
29114
+ return result
29040
29115
  }
29041
29116
 
29042
- // EXTERNAL MODULE: ../node_modules/parse5/lib/parser/index.js
29043
- var lib_parser = __webpack_require__(695);
29044
- ;// CONCATENATED MODULE: ../node_modules/hast-util-parse-selector/index.js
29045
29117
  /**
29046
- * @typedef {import('hast').Properties} Properties
29047
- * @typedef {import('hast').Element} Element
29118
+ * Transform children.
29119
+ *
29120
+ * @param {Context} ctx
29121
+ * @param {Array.<P5Node>} children
29122
+ * @returns {Array.<Child>}
29048
29123
  */
29124
+ function nodes(ctx, children) {
29125
+ let index = -1
29126
+ /** @type {Array.<Child>} */
29127
+ const result = []
29049
29128
 
29050
- var hast_util_parse_selector_search = /[#.]/g
29129
+ while (++index < children.length) {
29130
+ // @ts-expect-error Assume no roots in children.
29131
+ result[index] = transform(ctx, children[index])
29132
+ }
29133
+
29134
+ return result
29135
+ }
29051
29136
 
29052
29137
  /**
29053
- * Create a hast element from a simple CSS selector.
29138
+ * Transform a document.
29139
+ * Stores `ast.quirksMode` in `node.data.quirksMode`.
29054
29140
  *
29055
- * @param selector A simple CSS selector.
29056
- * Can contain a tag-name (`foo`), classes (`.bar`), and an ID (`#baz`).
29057
- * Multiple classes are allowed.
29058
- * Uses the last ID if multiple IDs are found.
29059
- * @param [defaultTagName='div'] Tag name to use if `selector` does not specify one.
29141
+ * @type {Handler}
29142
+ * @param {P5Document} ast
29143
+ * @param {Array.<Child>} children
29144
+ * @returns {Root}
29060
29145
  */
29061
- const parseSelector =
29062
- /**
29063
- * @type {(
29064
- * <Selector extends string, DefaultTagName extends string = 'div'>(selector?: Selector, defaultTagName?: DefaultTagName) => Element & {tagName: import('./extract.js').ExtractTagName<Selector, DefaultTagName>}
29065
- * )}
29066
- */
29067
- (
29068
- /**
29069
- * @param {string} [selector]
29070
- * @param {string} [defaultTagName='div']
29071
- * @returns {Element}
29072
- */
29073
- function (selector, defaultTagName = 'div') {
29074
- var value = selector || ''
29075
- /** @type {Properties} */
29076
- var props = {}
29077
- var start = 0
29078
- /** @type {string} */
29079
- var subvalue
29080
- /** @type {string} */
29081
- var previous
29082
- /** @type {RegExpMatchArray} */
29083
- var match
29084
-
29085
- while (start < value.length) {
29086
- hast_util_parse_selector_search.lastIndex = start
29087
- match = hast_util_parse_selector_search.exec(value)
29088
- subvalue = value.slice(start, match ? match.index : value.length)
29089
-
29090
- if (subvalue) {
29091
- if (!previous) {
29092
- defaultTagName = subvalue
29093
- } else if (previous === '#') {
29094
- props.id = subvalue
29095
- } else if (Array.isArray(props.className)) {
29096
- props.className.push(subvalue)
29097
- } else {
29098
- props.className = [subvalue]
29099
- }
29100
-
29101
- start += subvalue.length
29102
- }
29103
-
29104
- if (match) {
29105
- previous = match[0]
29106
- start++
29107
- }
29108
- }
29146
+ function lib_root(ctx, ast, children) {
29147
+ /** @type {Root} */
29148
+ const result = {
29149
+ type: 'root',
29150
+ children,
29151
+ data: {quirksMode: ast.mode === 'quirks' || ast.mode === 'limited-quirks'}
29152
+ }
29109
29153
 
29110
- return {
29111
- type: 'element',
29112
- tagName: defaultTagName,
29113
- properties: props,
29114
- children: []
29115
- }
29154
+ if (ctx.file && ctx.location) {
29155
+ const doc = String(ctx.file)
29156
+ const loc = vfile_location_location(doc)
29157
+ result.position = {
29158
+ start: loc.toPoint(0),
29159
+ end: loc.toPoint(doc.length)
29116
29160
  }
29117
- )
29161
+ }
29162
+
29163
+ return result
29164
+ }
29118
29165
 
29119
- ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/core.js
29120
29166
  /**
29121
- * @typedef {import('hast').Root} Root
29122
- * @typedef {import('hast').Element} Element
29123
- * @typedef {import('hast').Properties} Properties
29124
- * @typedef {Root['children'][number]} Child
29125
- * @typedef {Child|Root} Node
29126
- * @typedef {import('property-information').Info} Info
29127
- * @typedef {import('property-information').Schema} Schema
29128
- *
29129
- * @typedef {Root|Element} HResult
29130
- * @typedef {string|number} HStyleValue
29131
- * @typedef {Object.<string, HStyleValue>} HStyle
29132
- * @typedef {string|number|boolean|null|undefined} HPrimitiveValue
29133
- * @typedef {Array.<string|number>} HArrayValue
29134
- * @typedef {HPrimitiveValue|HArrayValue} HPropertyValue
29135
- * @typedef {{[property: string]: HPropertyValue|HStyle}} HProperties
29167
+ * Transform a doctype.
29136
29168
  *
29137
- * @typedef {string|number|null|undefined} HPrimitiveChild
29138
- * @typedef {Array.<Node|HPrimitiveChild>} HArrayChild
29139
- * @typedef {Node|HPrimitiveChild|HArrayChild} HChild
29169
+ * @type {Handler}
29170
+ * @returns {Doctype}
29140
29171
  */
29141
-
29142
-
29143
-
29144
-
29145
-
29146
-
29147
- const buttonTypes = new Set(['menu', 'submit', 'reset', 'button'])
29148
-
29149
- const core_own = {}.hasOwnProperty
29172
+ function doctype() {
29173
+ // @ts-expect-error Types are out of date.
29174
+ return {type: 'doctype'}
29175
+ }
29150
29176
 
29151
29177
  /**
29152
- * @param {Schema} schema
29153
- * @param {string} defaultTagName
29154
- * @param {Array.<string>} [caseSensitive]
29178
+ * Transform a text.
29179
+ *
29180
+ * @type {Handler}
29181
+ * @param {P5Text} ast
29182
+ * @returns {Text}
29155
29183
  */
29156
- function core_core(schema, defaultTagName, caseSensitive) {
29157
- const adjust = caseSensitive && createAdjustMap(caseSensitive)
29158
-
29159
- const h =
29160
- /**
29161
- * @type {{
29162
- * (): Root
29163
- * (selector: null|undefined, ...children: HChild[]): Root
29164
- * (selector: string, properties?: HProperties, ...children: HChild[]): Element
29165
- * (selector: string, ...children: HChild[]): Element
29166
- * }}
29167
- */
29168
- (
29169
- /**
29170
- * Hyperscript compatible DSL for creating virtual hast trees.
29171
- *
29172
- * @param {string|null} [selector]
29173
- * @param {HProperties|HChild} [properties]
29174
- * @param {HChild[]} children
29175
- * @returns {HResult}
29176
- */
29177
- function (selector, properties, ...children) {
29178
- let index = -1
29179
- /** @type {HResult} */
29180
- let node
29181
-
29182
- if (selector === undefined || selector === null) {
29183
- node = {type: 'root', children: []}
29184
- // @ts-expect-error Properties are not supported for roots.
29185
- children.unshift(properties)
29186
- } else {
29187
- node = parseSelector(selector, defaultTagName)
29188
- // Normalize the name.
29189
- node.tagName = node.tagName.toLowerCase()
29190
- if (adjust && core_own.call(adjust, node.tagName)) {
29191
- node.tagName = adjust[node.tagName]
29192
- }
29193
-
29194
- // Handle props.
29195
- if (isProperties(properties, node.tagName)) {
29196
- /** @type {string} */
29197
- let key
29198
-
29199
- for (key in properties) {
29200
- if (core_own.call(properties, key)) {
29201
- // @ts-expect-error `node.properties` is set.
29202
- core_addProperty(schema, node.properties, key, properties[key])
29203
- }
29204
- }
29205
- } else {
29206
- children.unshift(properties)
29207
- }
29208
- }
29209
-
29210
- // Handle children.
29211
- while (++index < children.length) {
29212
- addChild(node.children, children[index])
29213
- }
29214
-
29215
- if (node.type === 'element' && node.tagName === 'template') {
29216
- node.content = {type: 'root', children: node.children}
29217
- node.children = []
29218
- }
29219
-
29220
- return node
29221
- }
29222
- )
29223
-
29224
- return h
29184
+ function lib_text(_, ast) {
29185
+ return {type: 'text', value: ast.value}
29225
29186
  }
29226
29187
 
29227
29188
  /**
29228
- * @param {HProperties|HChild} value
29229
- * @param {string} name
29230
- * @returns {value is HProperties}
29189
+ * Transform a comment.
29190
+ *
29191
+ * @type {Handler}
29192
+ * @param {P5Comment} ast
29193
+ * @returns {Comment}
29231
29194
  */
29232
- function isProperties(value, name) {
29233
- if (
29234
- value === null ||
29235
- value === undefined ||
29236
- typeof value !== 'object' ||
29237
- Array.isArray(value)
29238
- ) {
29239
- return false
29240
- }
29241
-
29242
- if (name === 'input' || !value.type || typeof value.type !== 'string') {
29243
- return true
29244
- }
29245
-
29246
- if ('children' in value && Array.isArray(value.children)) {
29247
- return false
29248
- }
29249
-
29250
- if (name === 'button') {
29251
- return buttonTypes.has(value.type.toLowerCase())
29252
- }
29253
-
29254
- return !('value' in value)
29195
+ function comment(_, ast) {
29196
+ return {type: 'comment', value: ast.data}
29255
29197
  }
29256
29198
 
29257
29199
  /**
29258
- * @param {Schema} schema
29259
- * @param {Properties} properties
29260
- * @param {string} key
29261
- * @param {HStyle|HPropertyValue} value
29262
- * @returns {void}
29200
+ * Transform an element.
29201
+ *
29202
+ * @type {Handler}
29203
+ * @param {P5Element} ast
29204
+ * @param {Array.<ElementChild>} children
29205
+ * @returns {Element}
29263
29206
  */
29264
- function core_addProperty(schema, properties, key, value) {
29265
- const info = find(schema, key)
29207
+ function lib_element(ctx, ast, children) {
29208
+ const fn = ctx.schema.space === 'svg' ? s : h
29266
29209
  let index = -1
29267
- /** @type {HPropertyValue} */
29268
- let result
29210
+ /** @type {Object.<string, string>} */
29211
+ const props = {}
29269
29212
 
29270
- // Ignore nullish and NaN values.
29271
- if (value === undefined || value === null) return
29213
+ while (++index < ast.attrs.length) {
29214
+ const attribute = ast.attrs[index]
29215
+ props[(attribute.prefix ? attribute.prefix + ':' : '') + attribute.name] =
29216
+ attribute.value
29217
+ }
29272
29218
 
29273
- if (typeof value === 'number') {
29274
- // Ignore NaN.
29275
- if (Number.isNaN(value)) return
29219
+ const result = fn(ast.tagName, props, children)
29276
29220
 
29277
- result = value
29278
- }
29279
- // Booleans.
29280
- else if (typeof value === 'boolean') {
29281
- result = value
29282
- }
29283
- // Handle list values.
29284
- else if (typeof value === 'string') {
29285
- if (info.spaceSeparated) {
29286
- result = space_separated_tokens_parse(value)
29287
- } else if (info.commaSeparated) {
29288
- result = comma_separated_tokens_parse(value)
29289
- } else if (info.commaOrSpaceSeparated) {
29290
- result = space_separated_tokens_parse(comma_separated_tokens_parse(value).join(' '))
29291
- } else {
29292
- result = parsePrimitive(info, info.property, value)
29293
- }
29294
- } else if (Array.isArray(value)) {
29295
- result = value.concat()
29296
- } else {
29297
- result = info.property === 'style' ? style(value) : String(value)
29298
- }
29221
+ if (result.tagName === 'template' && 'content' in ast) {
29222
+ const pos = ast.sourceCodeLocation
29223
+ const startTag = pos && pos.startTag && lib_position(pos.startTag)
29224
+ const endTag = pos && pos.endTag && lib_position(pos.endTag)
29299
29225
 
29300
- if (Array.isArray(result)) {
29301
- /** @type {Array.<string|number>} */
29302
- const finalResult = []
29226
+ /** @type {Root} */
29227
+ // @ts-expect-error Types are wrong.
29228
+ const content = transform(ctx, ast.content)
29303
29229
 
29304
- while (++index < result.length) {
29305
- // @ts-expect-error Assume no booleans in array.
29306
- finalResult[index] = parsePrimitive(info, info.property, result[index])
29230
+ if (startTag && endTag && ctx.file) {
29231
+ content.position = {start: startTag.end, end: endTag.start}
29307
29232
  }
29308
29233
 
29309
- result = finalResult
29310
- }
29311
-
29312
- // Class names (which can be added both on the `selector` and here).
29313
- if (info.property === 'className' && Array.isArray(properties.className)) {
29314
- // @ts-expect-error Assume no booleans in `className`.
29315
- result = properties.className.concat(result)
29234
+ result.content = content
29316
29235
  }
29317
29236
 
29318
- properties[info.property] = result
29319
- }
29320
-
29321
- /**
29322
- * @param {Array.<Child>} nodes
29323
- * @param {HChild} value
29324
- * @returns {void}
29325
- */
29326
- function addChild(nodes, value) {
29327
- let index = -1
29328
-
29329
- if (value === undefined || value === null) {
29330
- // Empty.
29331
- } else if (typeof value === 'string' || typeof value === 'number') {
29332
- nodes.push({type: 'text', value: String(value)})
29333
- } else if (Array.isArray(value)) {
29334
- while (++index < value.length) {
29335
- addChild(nodes, value[index])
29336
- }
29337
- } else if (typeof value === 'object' && 'type' in value) {
29338
- if (value.type === 'root') {
29339
- addChild(nodes, value.children)
29340
- } else {
29341
- nodes.push(value)
29342
- }
29343
- } else {
29344
- throw new Error('Expected node, nodes, or string, got `' + value + '`')
29345
- }
29237
+ return result
29346
29238
  }
29347
29239
 
29348
29240
  /**
29349
- * Parse a single primitives.
29241
+ * Create clean positional information.
29350
29242
  *
29351
- * @param {Info} info
29352
- * @param {string} name
29353
- * @param {HPrimitiveValue} value
29354
- * @returns {HPrimitiveValue}
29243
+ * @param {Context} ctx
29244
+ * @param {Node} node
29245
+ * @param {P5ElementLocation} location
29246
+ * @returns {Position|null}
29355
29247
  */
29356
- function parsePrimitive(info, name, value) {
29357
- if (typeof value === 'string') {
29358
- if (info.number && value && !Number.isNaN(Number(value))) {
29359
- return Number(value)
29360
- }
29248
+ function createLocation(ctx, node, location) {
29249
+ const result = lib_position(location)
29250
+
29251
+ if (node.type === 'element') {
29252
+ const tail = node.children[node.children.length - 1]
29361
29253
 
29254
+ // Bug for unclosed with children.
29255
+ // See: <https://github.com/inikulin/parse5/issues/109>.
29362
29256
  if (
29363
- (info.boolean || info.overloadedBoolean) &&
29364
- (value === '' || normalize_normalize(value) === normalize_normalize(name))
29257
+ result &&
29258
+ !location.endTag &&
29259
+ tail &&
29260
+ tail.position &&
29261
+ tail.position.end
29365
29262
  ) {
29366
- return true
29263
+ result.end = Object.assign({}, tail.position.end)
29367
29264
  }
29368
- }
29369
29265
 
29370
- return value
29371
- }
29266
+ if (ctx.verbose) {
29267
+ /** @type {Object.<string, Position|null>} */
29268
+ const props = {}
29269
+ /** @type {string} */
29270
+ let key
29372
29271
 
29373
- /**
29374
- * @param {HStyle} value
29375
- * @returns {string}
29376
- */
29377
- function style(value) {
29378
- /** @type {Array.<string>} */
29379
- const result = []
29380
- /** @type {string} */
29381
- let key
29272
+ for (key in location.attrs) {
29273
+ if (hast_util_from_parse5_lib_own.call(location.attrs, key)) {
29274
+ props[find(ctx.schema, key).property] = lib_position(location.attrs[key])
29275
+ }
29276
+ }
29382
29277
 
29383
- for (key in value) {
29384
- if (core_own.call(value, key)) {
29385
- result.push([key, value[key]].join(': '))
29278
+ node.data = {
29279
+ position: {
29280
+ opening: lib_position(location.startTag),
29281
+ closing: location.endTag ? lib_position(location.endTag) : null,
29282
+ properties: props
29283
+ }
29284
+ }
29386
29285
  }
29387
29286
  }
29388
29287
 
29389
- return result.join('; ')
29288
+ return result
29390
29289
  }
29391
29290
 
29392
29291
  /**
29393
- * @param {Array.<string>} values
29394
- * @returns {Object.<string, string>}
29292
+ * @param {P5Location} loc
29293
+ * @returns {Position|null}
29395
29294
  */
29396
- function createAdjustMap(values) {
29397
- /** @type {Object.<string, string>} */
29398
- const result = {}
29399
- let index = -1
29400
-
29401
- while (++index < values.length) {
29402
- result[values[index].toLowerCase()] = values[index]
29403
- }
29295
+ function lib_position(loc) {
29296
+ const start = lib_point({
29297
+ line: loc.startLine,
29298
+ column: loc.startCol,
29299
+ offset: loc.startOffset
29300
+ })
29301
+ const end = lib_point({
29302
+ line: loc.endLine,
29303
+ column: loc.endCol,
29304
+ offset: loc.endOffset
29305
+ })
29306
+ // @ts-expect-error `null` is fine.
29307
+ return start || end ? {start, end} : null
29308
+ }
29404
29309
 
29405
- return result
29310
+ /**
29311
+ * @param {Point} point
29312
+ * @returns {Point|null}
29313
+ */
29314
+ function lib_point(point) {
29315
+ return point.line && point.column ? point : null
29406
29316
  }
29407
29317
 
29408
- ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/svg-case-sensitive-tag-names.js
29409
- const svgCaseSensitiveTagNames = [
29410
- 'altGlyph',
29411
- 'altGlyphDef',
29412
- 'altGlyphItem',
29413
- 'animateColor',
29414
- 'animateMotion',
29415
- 'animateTransform',
29416
- 'clipPath',
29417
- 'feBlend',
29418
- 'feColorMatrix',
29419
- 'feComponentTransfer',
29420
- 'feComposite',
29421
- 'feConvolveMatrix',
29422
- 'feDiffuseLighting',
29423
- 'feDisplacementMap',
29424
- 'feDistantLight',
29425
- 'feDropShadow',
29426
- 'feFlood',
29427
- 'feFuncA',
29428
- 'feFuncB',
29429
- 'feFuncG',
29430
- 'feFuncR',
29431
- 'feGaussianBlur',
29432
- 'feImage',
29433
- 'feMerge',
29434
- 'feMergeNode',
29435
- 'feMorphology',
29436
- 'feOffset',
29437
- 'fePointLight',
29438
- 'feSpecularLighting',
29439
- 'feSpotLight',
29440
- 'feTile',
29441
- 'feTurbulence',
29442
- 'foreignObject',
29443
- 'glyphRef',
29444
- 'linearGradient',
29445
- 'radialGradient',
29446
- 'solidColor',
29447
- 'textArea',
29448
- 'textPath'
29449
- ]
29318
+ /**
29319
+ * @param {VFile|Options} value
29320
+ * @returns {value is VFile}
29321
+ */
29322
+ function isFile(value) {
29323
+ return 'messages' in value
29324
+ }
29450
29325
 
29451
- ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/svg.js
29326
+ ;// CONCATENATED MODULE: ../node_modules/hast-to-hyperscript/index.js
29452
29327
  /**
29453
- * @typedef {import('./core.js').HChild} Child Acceptable child value
29454
- * @typedef {import('./core.js').HProperties} Properties Acceptable properties value.
29328
+ * @typedef {import('hast').Element} Element
29329
+ * @typedef {import('hast').Root} Root
29330
+ * @typedef {import('hast').Text} Text
29455
29331
  *
29456
- * @typedef {import('./jsx-classic').Element} s.JSX.Element
29457
- * @typedef {import('./jsx-classic').IntrinsicAttributes} s.JSX.IntrinsicAttributes
29458
- * @typedef {import('./jsx-classic').IntrinsicElements} s.JSX.IntrinsicElements
29459
- * @typedef {import('./jsx-classic').ElementChildrenAttribute} s.JSX.ElementChildrenAttribute
29332
+ * @typedef {import('unist-util-is').AssertPredicate<Element>} AssertElement
29333
+ * @typedef {import('unist-util-is').AssertPredicate<Text>} AssertText
29334
+ * @typedef {import('unist-util-is').AssertPredicate<Root>} AssertRoot
29335
+ *
29336
+ * @callback CreateElementLike
29337
+ * @param {string} name
29338
+ * @param {any} attributes
29339
+ * @param {Array.<string|any>} [children]
29340
+ * @returns {any}
29341
+ *
29342
+ * @typedef Context
29343
+ * @property {html|svg} schema
29344
+ * @property {string|null} prefix
29345
+ * @property {number} key
29346
+ * @property {boolean} react
29347
+ * @property {boolean} vue
29348
+ * @property {boolean} vdom
29349
+ * @property {boolean} hyperscript
29350
+ *
29351
+ * @typedef Options
29352
+ * @property {string|null} [prefix]
29353
+ * @property {'html'|'svg'} [space]
29460
29354
  */
29461
29355
 
29462
29356
 
29463
29357
 
29464
29358
 
29465
29359
 
29466
- const s = core_core(property_information_svg, 'g', svgCaseSensitiveTagNames)
29467
-
29468
- ;// CONCATENATED MODULE: ../node_modules/hastscript/lib/html.js
29469
- /**
29470
- * @typedef {import('./core.js').HChild} Child Acceptable child value
29471
- * @typedef {import('./core.js').HProperties} Properties Acceptable properties value.
29472
- *
29473
- * @typedef {import('./jsx-classic').Element} h.JSX.Element
29474
- * @typedef {import('./jsx-classic').IntrinsicAttributes} h.JSX.IntrinsicAttributes
29475
- * @typedef {import('./jsx-classic').IntrinsicElements} h.JSX.IntrinsicElements
29476
- * @typedef {import('./jsx-classic').ElementChildrenAttribute} h.JSX.ElementChildrenAttribute
29477
- */
29478
29360
 
29479
29361
 
29480
29362
 
29363
+ const ns = /** @type {Record<string, string>} */ (webNamespaces)
29364
+ const hast_to_hyperscript_toReact = /** @type {Record<string, string>} */ (hastToReact)
29481
29365
 
29482
- const h = core_core(property_information_html, 'div')
29483
-
29484
- ;// CONCATENATED MODULE: ../node_modules/vfile-location/index.js
29485
- /**
29486
- * @typedef {import('unist').Point} Point
29487
- * @typedef {import('vfile').VFile} VFile
29488
- *
29489
- * @typedef {Pick<Point, 'line'|'column'>} PositionalPoint
29490
- * @typedef {Required<Point>} FullPoint
29491
- * @typedef {NonNullable<Point['offset']>} Offset
29492
- */
29493
-
29494
- /**
29495
- * Get transform functions for the given `document`.
29496
- *
29497
- * @param {string|Uint8Array|VFile} file
29498
- */
29499
- function vfile_location_location(file) {
29500
- var value = String(file)
29501
- /** @type {Array.<number>} */
29502
- var indices = []
29503
- var search = /\r?\n|\r/g
29504
-
29505
- while (search.test(value)) {
29506
- indices.push(search.lastIndex)
29507
- }
29508
-
29509
- indices.push(value.length + 1)
29510
-
29511
- return {toPoint, toOffset}
29512
-
29513
- /**
29514
- * Get the line and column-based `point` for `offset` in the bound indices.
29515
- * Returns a point with `undefined` values when given invalid or out of bounds
29516
- * input.
29517
- *
29518
- * @param {Offset} offset
29519
- * @returns {FullPoint}
29520
- */
29521
- function toPoint(offset) {
29522
- var index = -1
29523
-
29524
- if (offset > -1 && offset < indices[indices.length - 1]) {
29525
- while (++index < indices.length) {
29526
- if (indices[index] > offset) {
29527
- return {
29528
- line: index + 1,
29529
- column: offset - (indices[index - 1] || 0) + 1,
29530
- offset
29531
- }
29532
- }
29533
- }
29534
- }
29535
-
29536
- return {line: undefined, column: undefined, offset: undefined}
29537
- }
29538
-
29539
- /**
29540
- * Get the `offset` for a line and column-based `point` in the bound indices.
29541
- * Returns `-1` when given invalid or out of bounds input.
29542
- *
29543
- * @param {PositionalPoint} point
29544
- * @returns {Offset}
29545
- */
29546
- function toOffset(point) {
29547
- var line = point && point.line
29548
- var column = point && point.column
29549
- /** @type {number} */
29550
- var offset
29551
-
29552
- if (
29553
- typeof line === 'number' &&
29554
- typeof column === 'number' &&
29555
- !Number.isNaN(line) &&
29556
- !Number.isNaN(column) &&
29557
- line - 1 in indices
29558
- ) {
29559
- offset = (indices[line - 2] || 0) + column - 1 || 0
29560
- }
29561
-
29562
- return offset > -1 && offset < indices[indices.length - 1] ? offset : -1
29563
- }
29564
- }
29565
-
29566
- ;// CONCATENATED MODULE: ../node_modules/web-namespaces/index.js
29567
- /**
29568
- * Map of web namespaces.
29569
- *
29570
- * @type {Record<string, string>}
29571
- */
29572
- const webNamespaces = {
29573
- html: 'http://www.w3.org/1999/xhtml',
29574
- mathml: 'http://www.w3.org/1998/Math/MathML',
29575
- svg: 'http://www.w3.org/2000/svg',
29576
- xlink: 'http://www.w3.org/1999/xlink',
29577
- xml: 'http://www.w3.org/XML/1998/namespace',
29578
- xmlns: 'http://www.w3.org/2000/xmlns/'
29579
- }
29580
-
29581
- ;// CONCATENATED MODULE: ../node_modules/hast-util-from-parse5/lib/index.js
29582
- /**
29583
- * @typedef {import('vfile').VFile} VFile
29584
- * @typedef {import('property-information').Schema} Schema
29585
- * @typedef {import('unist').Position} Position
29586
- * @typedef {import('unist').Point} Point
29587
- * @typedef {import('hast').Parent} Parent
29588
- * @typedef {import('hast').Element} Element
29589
- * @typedef {import('hast').Root} Root
29590
- * @typedef {import('hast').Text} Text
29591
- * @typedef {import('hast').Comment} Comment
29592
- * @typedef {import('hast').DocType} Doctype
29593
- * @typedef {Parent['children'][number]} Child
29594
- * @typedef {Element['children'][number]} ElementChild
29595
- * @typedef {Child|Root} Node
29596
- * @typedef {import('parse5').Document} P5Document
29597
- * @typedef {import('parse5').DocumentType} P5Doctype
29598
- * @typedef {import('parse5').CommentNode} P5Comment
29599
- * @typedef {import('parse5').TextNode} P5Text
29600
- * @typedef {import('parse5').Element} P5Element
29601
- * @typedef {import('parse5').ElementLocation} P5ElementLocation
29602
- * @typedef {import('parse5').Location} P5Location
29603
- * @typedef {import('parse5').Attribute} P5Attribute
29604
- * @typedef {import('parse5').Node} P5Node
29605
- *
29606
- * @typedef {'html'|'svg'} Space
29607
- *
29608
- * @callback Handler
29609
- * @param {Context} ctx
29610
- * @param {P5Node} node
29611
- * @param {Array.<Child>} [children]
29612
- * @returns {Node}
29613
- *
29614
- * @typedef Options
29615
- * @property {Space} [space='html'] Whether the root of the tree is in the `'html'` or `'svg'` space. If an element in with the SVG namespace is found in `ast`, `fromParse5` automatically switches to the SVG space when entering the element, and switches back when leaving
29616
- * @property {VFile} [file] `VFile`, used to add positional information to nodes. If given, the file should have the original HTML source as its contents
29617
- * @property {boolean} [verbose=false] Whether to add extra positional information about starting tags, closing tags, and attributes to elements. Note: not used without `file`
29618
- *
29619
- * @typedef Context
29620
- * @property {Schema} schema
29621
- * @property {VFile|undefined} file
29622
- * @property {boolean|undefined} verbose
29623
- * @property {boolean} location
29624
- */
29625
-
29626
-
29627
-
29628
-
29629
-
29630
-
29631
- const hast_util_from_parse5_lib_own = {}.hasOwnProperty
29632
-
29633
- // Handlers.
29634
- const map = {
29635
- '#document': lib_root,
29636
- '#document-fragment': lib_root,
29637
- '#text': lib_text,
29638
- '#comment': comment,
29639
- '#documentType': doctype
29640
- }
29641
-
29642
- /**
29643
- * Transform Parse5’s AST to a hast tree.
29644
- *
29645
- * @param {P5Node} ast
29646
- * @param {Options|VFile} [options]
29647
- */
29648
- function fromParse5(ast, options = {}) {
29649
- /** @type {Options} */
29650
- let settings
29651
- /** @type {VFile|undefined} */
29652
- let file
29653
-
29654
- if (isFile(options)) {
29655
- file = options
29656
- settings = {}
29657
- } else {
29658
- file = options.file
29659
- settings = options
29660
- }
29661
-
29662
- return transform(
29663
- {
29664
- schema: settings.space === 'svg' ? property_information_svg : property_information_html,
29665
- file,
29666
- verbose: settings.verbose,
29667
- location: false
29668
- },
29669
- ast
29670
- )
29671
- }
29672
-
29673
- /**
29674
- * Transform children.
29675
- *
29676
- * @param {Context} ctx
29677
- * @param {P5Node} ast
29678
- * @returns {Node}
29679
- */
29680
- function transform(ctx, ast) {
29681
- const schema = ctx.schema
29682
- /** @type {Handler} */
29683
- // @ts-expect-error: index is fine.
29684
- const fn = hast_util_from_parse5_lib_own.call(map, ast.nodeName) ? map[ast.nodeName] : lib_element
29685
- /** @type {Array.<Child>|undefined} */
29686
- let children
29687
-
29688
- // Element.
29689
- if ('tagName' in ast) {
29690
- ctx.schema = ast.namespaceURI === webNamespaces.svg ? property_information_svg : property_information_html
29691
- }
29692
-
29693
- if ('childNodes' in ast) {
29694
- children = nodes(ctx, ast.childNodes)
29695
- }
29696
-
29697
- const result = fn(ctx, ast, children)
29698
-
29699
- if ('sourceCodeLocation' in ast && ast.sourceCodeLocation && ctx.file) {
29700
- // @ts-expect-error It’s fine.
29701
- const position = createLocation(ctx, result, ast.sourceCodeLocation)
29702
-
29703
- if (position) {
29704
- ctx.location = true
29705
- result.position = position
29706
- }
29707
- }
29708
-
29709
- ctx.schema = schema
29710
-
29711
- return result
29712
- }
29713
-
29714
- /**
29715
- * Transform children.
29716
- *
29717
- * @param {Context} ctx
29718
- * @param {Array.<P5Node>} children
29719
- * @returns {Array.<Child>}
29720
- */
29721
- function nodes(ctx, children) {
29722
- let index = -1
29723
- /** @type {Array.<Child>} */
29724
- const result = []
29725
-
29726
- while (++index < children.length) {
29727
- // @ts-expect-error Assume no roots in children.
29728
- result[index] = transform(ctx, children[index])
29729
- }
29730
-
29731
- return result
29732
- }
29733
-
29734
- /**
29735
- * Transform a document.
29736
- * Stores `ast.quirksMode` in `node.data.quirksMode`.
29737
- *
29738
- * @type {Handler}
29739
- * @param {P5Document} ast
29740
- * @param {Array.<Child>} children
29741
- * @returns {Root}
29742
- */
29743
- function lib_root(ctx, ast, children) {
29744
- /** @type {Root} */
29745
- const result = {
29746
- type: 'root',
29747
- children,
29748
- data: {quirksMode: ast.mode === 'quirks' || ast.mode === 'limited-quirks'}
29749
- }
29750
-
29751
- if (ctx.file && ctx.location) {
29752
- const doc = String(ctx.file)
29753
- const loc = vfile_location_location(doc)
29754
- result.position = {
29755
- start: loc.toPoint(0),
29756
- end: loc.toPoint(doc.length)
29757
- }
29758
- }
29759
-
29760
- return result
29761
- }
29762
-
29763
- /**
29764
- * Transform a doctype.
29765
- *
29766
- * @type {Handler}
29767
- * @returns {Doctype}
29768
- */
29769
- function doctype() {
29770
- // @ts-expect-error Types are out of date.
29771
- return {type: 'doctype'}
29772
- }
29773
-
29774
- /**
29775
- * Transform a text.
29776
- *
29777
- * @type {Handler}
29778
- * @param {P5Text} ast
29779
- * @returns {Text}
29780
- */
29781
- function lib_text(_, ast) {
29782
- return {type: 'text', value: ast.value}
29783
- }
29784
-
29785
- /**
29786
- * Transform a comment.
29787
- *
29788
- * @type {Handler}
29789
- * @param {P5Comment} ast
29790
- * @returns {Comment}
29791
- */
29792
- function comment(_, ast) {
29793
- return {type: 'comment', value: ast.data}
29794
- }
29795
-
29796
- /**
29797
- * Transform an element.
29798
- *
29799
- * @type {Handler}
29800
- * @param {P5Element} ast
29801
- * @param {Array.<ElementChild>} children
29802
- * @returns {Element}
29803
- */
29804
- function lib_element(ctx, ast, children) {
29805
- const fn = ctx.schema.space === 'svg' ? s : h
29806
- let index = -1
29807
- /** @type {Object.<string, string>} */
29808
- const props = {}
29809
-
29810
- while (++index < ast.attrs.length) {
29811
- const attribute = ast.attrs[index]
29812
- props[(attribute.prefix ? attribute.prefix + ':' : '') + attribute.name] =
29813
- attribute.value
29814
- }
29815
-
29816
- const result = fn(ast.tagName, props, children)
29817
-
29818
- if (result.tagName === 'template' && 'content' in ast) {
29819
- const pos = ast.sourceCodeLocation
29820
- const startTag = pos && pos.startTag && lib_position(pos.startTag)
29821
- const endTag = pos && pos.endTag && lib_position(pos.endTag)
29822
-
29823
- /** @type {Root} */
29824
- // @ts-expect-error Types are wrong.
29825
- const content = transform(ctx, ast.content)
29826
-
29827
- if (startTag && endTag && ctx.file) {
29828
- content.position = {start: startTag.end, end: endTag.start}
29829
- }
29830
-
29831
- result.content = content
29832
- }
29833
-
29834
- return result
29835
- }
29836
-
29837
- /**
29838
- * Create clean positional information.
29839
- *
29840
- * @param {Context} ctx
29841
- * @param {Node} node
29842
- * @param {P5ElementLocation} location
29843
- * @returns {Position|null}
29844
- */
29845
- function createLocation(ctx, node, location) {
29846
- const result = lib_position(location)
29847
-
29848
- if (node.type === 'element') {
29849
- const tail = node.children[node.children.length - 1]
29850
-
29851
- // Bug for unclosed with children.
29852
- // See: <https://github.com/inikulin/parse5/issues/109>.
29853
- if (
29854
- result &&
29855
- !location.endTag &&
29856
- tail &&
29857
- tail.position &&
29858
- tail.position.end
29859
- ) {
29860
- result.end = Object.assign({}, tail.position.end)
29861
- }
29862
-
29863
- if (ctx.verbose) {
29864
- /** @type {Object.<string, Position|null>} */
29865
- const props = {}
29866
- /** @type {string} */
29867
- let key
29868
-
29869
- for (key in location.attrs) {
29870
- if (hast_util_from_parse5_lib_own.call(location.attrs, key)) {
29871
- props[find(ctx.schema, key).property] = lib_position(location.attrs[key])
29872
- }
29873
- }
29874
-
29875
- node.data = {
29876
- position: {
29877
- opening: lib_position(location.startTag),
29878
- closing: location.endTag ? lib_position(location.endTag) : null,
29879
- properties: props
29880
- }
29881
- }
29882
- }
29883
- }
29884
-
29885
- return result
29886
- }
29887
-
29888
- /**
29889
- * @param {P5Location} loc
29890
- * @returns {Position|null}
29891
- */
29892
- function lib_position(loc) {
29893
- const start = lib_point({
29894
- line: loc.startLine,
29895
- column: loc.startCol,
29896
- offset: loc.startOffset
29897
- })
29898
- const end = lib_point({
29899
- line: loc.endLine,
29900
- column: loc.endCol,
29901
- offset: loc.endOffset
29902
- })
29903
- // @ts-expect-error `null` is fine.
29904
- return start || end ? {start, end} : null
29905
- }
29906
-
29907
- /**
29908
- * @param {Point} point
29909
- * @returns {Point|null}
29910
- */
29911
- function lib_point(point) {
29912
- return point.line && point.column ? point : null
29913
- }
29914
-
29915
- /**
29916
- * @param {VFile|Options} value
29917
- * @returns {value is VFile}
29918
- */
29919
- function isFile(value) {
29920
- return 'messages' in value
29921
- }
29922
-
29923
- ;// CONCATENATED MODULE: ../node_modules/hast-to-hyperscript/index.js
29924
- /**
29925
- * @typedef {import('hast').Element} Element
29926
- * @typedef {import('hast').Root} Root
29927
- * @typedef {import('hast').Text} Text
29928
- *
29929
- * @typedef {import('unist-util-is').AssertPredicate<Element>} AssertElement
29930
- * @typedef {import('unist-util-is').AssertPredicate<Text>} AssertText
29931
- * @typedef {import('unist-util-is').AssertPredicate<Root>} AssertRoot
29932
- *
29933
- * @callback CreateElementLike
29934
- * @param {string} name
29935
- * @param {any} attributes
29936
- * @param {Array.<string|any>} [children]
29937
- * @returns {any}
29938
- *
29939
- * @typedef Context
29940
- * @property {html|svg} schema
29941
- * @property {string|null} prefix
29942
- * @property {number} key
29943
- * @property {boolean} react
29944
- * @property {boolean} vue
29945
- * @property {boolean} vdom
29946
- * @property {boolean} hyperscript
29947
- *
29948
- * @typedef Options
29949
- * @property {string|null} [prefix]
29950
- * @property {'html'|'svg'} [space]
29951
- */
29952
-
29953
-
29954
-
29955
-
29956
-
29957
-
29958
-
29959
-
29960
- const ns = /** @type {Record<string, string>} */ (webNamespaces)
29961
- const hast_to_hyperscript_toReact = /** @type {Record<string, string>} */ (hastToReact)
29962
-
29963
- const hast_to_hyperscript_own = {}.hasOwnProperty
29366
+ const hast_to_hyperscript_own = {}.hasOwnProperty
29964
29367
 
29965
29368
  /** @type {AssertRoot} */
29966
29369
  // @ts-expect-error it’s correct.
@@ -30906,283 +30309,862 @@ const raw =
30906
30309
  })
30907
30310
  }
30908
30311
 
30909
- /**
30910
- * @param {Doctype} node
30911
- * @returns {void}
30912
- */
30913
- function doctype(node) {
30914
- resetTokenizer()
30915
- parser._processToken({
30916
- type: doctypeToken,
30917
- name: 'html',
30918
- forceQuirks: false,
30919
- publicId: '',
30920
- systemId: '',
30921
- location: createParse5Location(node)
30922
- })
30312
+ /**
30313
+ * @param {Doctype} node
30314
+ * @returns {void}
30315
+ */
30316
+ function doctype(node) {
30317
+ resetTokenizer()
30318
+ parser._processToken({
30319
+ type: doctypeToken,
30320
+ name: 'html',
30321
+ forceQuirks: false,
30322
+ publicId: '',
30323
+ systemId: '',
30324
+ location: createParse5Location(node)
30325
+ })
30326
+ }
30327
+
30328
+ /**
30329
+ * @param {Comment|Stitch} node
30330
+ * @returns {void}
30331
+ */
30332
+ function comment(node) {
30333
+ resetTokenizer()
30334
+ parser._processToken({
30335
+ type: commentToken,
30336
+ data: node.value,
30337
+ location: createParse5Location(node)
30338
+ })
30339
+ }
30340
+
30341
+ /**
30342
+ * @param {Raw} node
30343
+ * @returns {void}
30344
+ */
30345
+ function handleRaw(node) {
30346
+ const start = pointStart(node)
30347
+ const line = start.line || 1
30348
+ const column = start.column || 1
30349
+ const offset = start.offset || 0
30350
+
30351
+ /* c8 ignore next 4 */
30352
+ if (!preprocessor) throw new Error('Expected `preprocessor`')
30353
+ if (!tokenizer) throw new Error('Expected `tokenizer`')
30354
+ if (!posTracker) throw new Error('Expected `posTracker`')
30355
+ if (!locationTracker) throw new Error('Expected `locationTracker`')
30356
+
30357
+ // Reset preprocessor:
30358
+ // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/tokenizer/preprocessor.js#L17>.
30359
+ preprocessor.html = undefined
30360
+ preprocessor.pos = -1
30361
+ preprocessor.lastGapPos = -1
30362
+ preprocessor.lastCharPos = -1
30363
+ preprocessor.gapStack = []
30364
+ preprocessor.skipNextNewLine = false
30365
+ preprocessor.lastChunkWritten = false
30366
+ preprocessor.endOfChunkHit = false
30367
+
30368
+ // Reset preprocessor mixin:
30369
+ // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/position-tracking/preprocessor-mixin.js>.
30370
+ posTracker.isEol = false
30371
+ posTracker.lineStartPos = -column + 1 // Looks weird, but ensures we get correct positional info.
30372
+ posTracker.droppedBufferSize = offset
30373
+ posTracker.offset = 0
30374
+ posTracker.col = 1
30375
+ posTracker.line = line
30376
+
30377
+ // Reset location tracker:
30378
+ // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js>.
30379
+ locationTracker.currentAttrLocation = undefined
30380
+ locationTracker.ctLoc = createParse5Location(node)
30381
+
30382
+ // See the code for `parse` and `parseFragment`:
30383
+ // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/parser/index.js#L371>.
30384
+ tokenizer.write(node.value)
30385
+ parser._runParsingLoop(null)
30386
+
30387
+ // Character references hang, so if we ended there, we need to flush
30388
+ // those too.
30389
+ // We reset the preprocessor as if the document ends here.
30390
+ // Then one single call to the relevant state does the trick, parse5
30391
+ // consumes the whole token.
30392
+ if (
30393
+ tokenizer.state === 'NAMED_CHARACTER_REFERENCE_STATE' ||
30394
+ tokenizer.state === 'NUMERIC_CHARACTER_REFERENCE_END_STATE'
30395
+ ) {
30396
+ preprocessor.lastChunkWritten = true
30397
+ tokenizer[tokenizer.state](tokenizer._consume())
30398
+ }
30399
+ }
30400
+
30401
+ /**
30402
+ * @param {Node} node
30403
+ */
30404
+ function stitch(node) {
30405
+ stitches = true
30406
+
30407
+ /** @type {Node} */
30408
+ let clone
30409
+
30410
+ // Recurse, because to somewhat handle `[<x>]</x>` (where `[]` denotes the
30411
+ // passed through node).
30412
+ if ('children' in node) {
30413
+ clone = {
30414
+ ...node,
30415
+ children: raw(
30416
+ {type: 'root', children: node.children},
30417
+ file,
30418
+ options
30419
+ // @ts-expect-error Assume a given parent yields a parent.
30420
+ ).children
30421
+ }
30422
+ } else {
30423
+ clone = {...node}
30424
+ }
30425
+
30426
+ // Hack: `value` is supposed to be a string, but as none of the tools
30427
+ // (`parse5` or `hast-util-from-parse5`) looks at it, we can pass nodes
30428
+ // through.
30429
+ comment({type: 'comment', value: {stitch: clone}})
30430
+ }
30431
+
30432
+ function resetTokenizer() {
30433
+ /* c8 ignore next 2 */
30434
+ if (!tokenizer) throw new Error('Expected `tokenizer`')
30435
+ if (!posTracker) throw new Error('Expected `posTracker`')
30436
+
30437
+ // Process final characters if they’re still there after hibernating.
30438
+ // Similar to:
30439
+ // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js#L95>.
30440
+ const token = tokenizer.currentCharacterToken
30441
+
30442
+ if (token) {
30443
+ token.location.endLine = posTracker.line
30444
+ token.location.endCol = posTracker.col + 1
30445
+ token.location.endOffset = posTracker.offset + 1
30446
+ parser._processToken(token)
30447
+ }
30448
+
30449
+ // Reset tokenizer:
30450
+ // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/tokenizer/index.js#L218-L234>.
30451
+ // Especially putting it back in the `data` state is useful: some elements,
30452
+ // like textareas and iframes, change the state.
30453
+ // See GH-7.
30454
+ // But also if broken HTML is in `raw`, and then a correct element is given.
30455
+ // See GH-11.
30456
+ tokenizer.tokenQueue = []
30457
+ tokenizer.state = dataState
30458
+ tokenizer.returnState = ''
30459
+ tokenizer.charRefCode = -1
30460
+ tokenizer.tempBuff = []
30461
+ tokenizer.lastStartTagName = ''
30462
+ tokenizer.consumedAfterSnapshot = -1
30463
+ tokenizer.active = false
30464
+ tokenizer.currentCharacterToken = undefined
30465
+ tokenizer.currentToken = undefined
30466
+ tokenizer.currentAttr = undefined
30467
+ }
30468
+ }
30469
+ )
30470
+ /**
30471
+ * @param {Element} node
30472
+ * @returns {HiddenToken}
30473
+ */
30474
+ function startTag(node) {
30475
+ /** @type {P5Location} */
30476
+ const location = Object.assign(createParse5Location(node))
30477
+ // @ts-expect-error extra positional info.
30478
+ location.startTag = Object.assign({}, location)
30479
+
30480
+ // Untyped token.
30481
+ return {
30482
+ type: startTagToken,
30483
+ tagName: node.tagName,
30484
+ selfClosing: false,
30485
+ attrs: attributes(node),
30486
+ location
30487
+ }
30488
+ }
30489
+
30490
+ /**
30491
+ * @param {Element} node
30492
+ * @returns {Array<P5Attribute>}
30493
+ */
30494
+ function attributes(node) {
30495
+ return toParse5({
30496
+ tagName: node.tagName,
30497
+ type: 'element',
30498
+ properties: node.properties,
30499
+ children: []
30500
+ // @ts-expect-error Assume element.
30501
+ }).attrs
30502
+ }
30503
+
30504
+ /**
30505
+ * @param {Element} node
30506
+ * @returns {HiddenToken}
30507
+ */
30508
+ function endTag(node) {
30509
+ /** @type {P5Location} */
30510
+ const location = Object.assign(createParse5Location(node))
30511
+ // @ts-expect-error extra positional info.
30512
+ location.startTag = Object.assign({}, location)
30513
+
30514
+ // Untyped token.
30515
+ return {
30516
+ type: endTagToken,
30517
+ tagName: node.tagName,
30518
+ attrs: [],
30519
+ location
30520
+ }
30521
+ }
30522
+
30523
+ /**
30524
+ * @param {Node} node
30525
+ */
30526
+ function lib_unknown(node) {
30527
+ throw new Error('Cannot compile `' + node.type + '` node')
30528
+ }
30529
+
30530
+ /**
30531
+ * @param {Node} node
30532
+ * @returns {boolean}
30533
+ */
30534
+ function documentMode(node) {
30535
+ const head = node.type === 'root' ? node.children[0] : node
30536
+ return Boolean(
30537
+ head &&
30538
+ (head.type === 'doctype' ||
30539
+ (head.type === 'element' && head.tagName === 'html'))
30540
+ )
30541
+ }
30542
+
30543
+ /**
30544
+ * @param {Node|Stitch} node
30545
+ * @returns {P5Location}
30546
+ */
30547
+ function createParse5Location(node) {
30548
+ const start = pointStart(node)
30549
+ const end = pointEnd(node)
30550
+
30551
+ return {
30552
+ startLine: start.line,
30553
+ startCol: start.column,
30554
+ startOffset: start.offset,
30555
+ endLine: end.line,
30556
+ endCol: end.column,
30557
+ endOffset: end.offset
30558
+ }
30559
+ }
30560
+
30561
+ /**
30562
+ * @param {VFile|Options|undefined} value
30563
+ * @return {value is Options}
30564
+ */
30565
+ function isOptions(value) {
30566
+ return Boolean(value && !('message' in value && 'messages' in value))
30567
+ }
30568
+
30569
+ ;// CONCATENATED MODULE: ../node_modules/rehype-raw/index.js
30570
+ /**
30571
+ * @typedef {import('hast').Root} Root
30572
+ * @typedef {import('hast-util-raw').Options} Options
30573
+ * @typedef {import('hast-util-raw')} DoNotTouchAsThisImportIncludesRawInTree
30574
+ */
30575
+
30576
+
30577
+
30578
+ /**
30579
+ * Plugin to parse the tree again (and raw nodes).
30580
+ * Keeping positional info OK. 🙌
30581
+ *
30582
+ * @type {import('unified').Plugin<[Options?] | Array<void>, Root>}
30583
+ */
30584
+ function rehypeRaw(options = {}) {
30585
+ return (tree, file) => {
30586
+ // Assume that when a root was given, it’s also returned.
30587
+ const result = /** @type {Root} */ (raw(tree, file, options))
30588
+ return result
30589
+ }
30590
+ }
30591
+
30592
+ // EXTERNAL MODULE: ../node_modules/github-slugger/index.js
30593
+ var github_slugger = __webpack_require__(449);
30594
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-has-property/index.js
30595
+ var hast_util_has_property_own = {}.hasOwnProperty
30596
+
30597
+ /**
30598
+ * Check if `node` has a set `name` property.
30599
+ *
30600
+ * @param {unknown} node
30601
+ * @param {string} name
30602
+ * @returns {boolean}
30603
+ */
30604
+ function hasProperty(node, name) {
30605
+ /** @type {unknown} */
30606
+ var value =
30607
+ name &&
30608
+ node &&
30609
+ typeof node === 'object' &&
30610
+ // @ts-ignore Looks like a node.
30611
+ node.type === 'element' &&
30612
+ // @ts-ignore Looks like an element.
30613
+ node.properties &&
30614
+ // @ts-ignore Looks like an element.
30615
+ hast_util_has_property_own.call(node.properties, name) &&
30616
+ // @ts-ignore Looks like an element.
30617
+ node.properties[name]
30618
+
30619
+ return value !== null && value !== undefined && value !== false
30620
+ }
30621
+
30622
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-heading-rank/index.js
30623
+ /**
30624
+ * @typedef {import('hast').Parent} Parent
30625
+ * @typedef {import('hast').Root} Root
30626
+ * @typedef {Root|Parent['children'][number]} Node
30627
+ */
30628
+
30629
+ /**
30630
+ * Rank of a heading: H1 -> 1, H2 -> 2, etc.
30631
+ *
30632
+ * @param {Node} node
30633
+ * @returns {number|null}
30634
+ */
30635
+ function headingRank(node) {
30636
+ var name =
30637
+ (node && node.type === 'element' && node.tagName.toLowerCase()) || ''
30638
+ var code =
30639
+ name.length === 2 && name.charCodeAt(0) === 104 /* `h` */
30640
+ ? name.charCodeAt(1)
30641
+ : 0
30642
+ return code > 48 /* `0` */ && code < 55 /* `7` */ ? code - 48 /* `0` */ : null
30643
+ }
30644
+
30645
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-to-string/index.js
30646
+ /**
30647
+ * @fileoverview
30648
+ * Get the plain-text value of a hast node.
30649
+ * @longdescription
30650
+ * ## Use
30651
+ *
30652
+ * ```js
30653
+ * import {h} from 'hastscript'
30654
+ * import {toString} from 'hast-util-to-string'
30655
+ *
30656
+ * toString(h('p', 'Alpha'))
30657
+ * //=> 'Alpha'
30658
+ * toString(h('div', [h('b', 'Bold'), ' and ', h('i', 'italic'), '.']))
30659
+ * //=> 'Bold and italic.'
30660
+ * ```
30661
+ *
30662
+ * ## API
30663
+ *
30664
+ * ### `toString(node)`
30665
+ *
30666
+ * Transform a node to a string.
30667
+ */
30668
+
30669
+ /**
30670
+ * @typedef {import('hast').Root} Root
30671
+ * @typedef {import('hast').Element} Element
30672
+ * @typedef {Root|Root['children'][number]} Node
30673
+ */
30674
+
30675
+ /**
30676
+ * Get the plain-text value of a hast node.
30677
+ *
30678
+ * @param {Node} node
30679
+ * @returns {string}
30680
+ */
30681
+ function hast_util_to_string_toString(node) {
30682
+ // “The concatenation of data of all the Text node descendants of the context
30683
+ // object, in tree order.”
30684
+ if ('children' in node) {
30685
+ return hast_util_to_string_all(node)
30686
+ }
30687
+
30688
+ // “Context object’s data.”
30689
+ return 'value' in node ? node.value : ''
30690
+ }
30691
+
30692
+ /**
30693
+ * @param {Node} node
30694
+ * @returns {string}
30695
+ */
30696
+ function hast_util_to_string_one(node) {
30697
+ if (node.type === 'text') {
30698
+ return node.value
30699
+ }
30700
+
30701
+ return 'children' in node ? hast_util_to_string_all(node) : ''
30702
+ }
30703
+
30704
+ /**
30705
+ * @param {Root|Element} node
30706
+ * @returns {string}
30707
+ */
30708
+ function hast_util_to_string_all(node) {
30709
+ let index = -1
30710
+ /** @type {string[]} */
30711
+ const result = []
30712
+
30713
+ while (++index < node.children.length) {
30714
+ result[index] = hast_util_to_string_one(node.children[index])
30715
+ }
30716
+
30717
+ return result.join('')
30718
+ }
30719
+
30720
+ ;// CONCATENATED MODULE: ../node_modules/rehype-slug/index.js
30721
+ /**
30722
+ * @typedef {import('hast').Root} Root
30723
+ */
30724
+
30725
+
30726
+
30727
+
30728
+
30729
+
30730
+
30731
+ const slugs = new github_slugger()
30732
+
30733
+ /**
30734
+ * Plugin to add `id`s to headings.
30735
+ *
30736
+ * @type {import('unified').Plugin<Array<void>, Root>}
30737
+ */
30738
+ function rehypeSlug() {
30739
+ return (tree) => {
30740
+ slugs.reset()
30741
+
30742
+ visit(tree, 'element', (node) => {
30743
+ if (headingRank(node) && node.properties && !hasProperty(node, 'id')) {
30744
+ node.properties.id = slugs.slug(hast_util_to_string_toString(node))
30745
+ }
30746
+ })
30747
+ }
30748
+ }
30749
+
30750
+ ;// CONCATENATED MODULE: ../node_modules/hast-util-is-element/index.js
30751
+ /**
30752
+ * @typedef {import('unist').Node} Node
30753
+ * @typedef {import('unist').Parent} Parent
30754
+ * @typedef {import('hast').Element} Element
30755
+ *
30756
+ * @typedef {string} TagName
30757
+ * @typedef {null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>} Test
30758
+ */
30759
+
30760
+ /**
30761
+ * @template {Element} T
30762
+ * @typedef {null|undefined|T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>} PredicateTest
30763
+ */
30764
+
30765
+ /**
30766
+ * Check if an element passes a test
30767
+ *
30768
+ * @callback TestFunctionAnything
30769
+ * @param {Element} element
30770
+ * @param {number|null|undefined} [index]
30771
+ * @param {Parent|null|undefined} [parent]
30772
+ * @returns {boolean|void}
30773
+ */
30774
+
30775
+ /**
30776
+ * Check if an element passes a certain node test
30777
+ *
30778
+ * @template {Element} X
30779
+ * @callback TestFunctionPredicate
30780
+ * @param {Element} element
30781
+ * @param {number|null|undefined} [index]
30782
+ * @param {Parent|null|undefined} [parent]
30783
+ * @returns {element is X}
30784
+ */
30785
+
30786
+ /**
30787
+ * Check if a node is an element and passes a certain node test
30788
+ *
30789
+ * @callback AssertAnything
30790
+ * @param {unknown} [node]
30791
+ * @param {number|null|undefined} [index]
30792
+ * @param {Parent|null|undefined} [parent]
30793
+ * @returns {boolean}
30794
+ */
30795
+
30796
+ /**
30797
+ * Check if a node is an element and passes a certain node test
30798
+ *
30799
+ * @template {Element} Y
30800
+ * @callback AssertPredicate
30801
+ * @param {unknown} [node]
30802
+ * @param {number|null|undefined} [index]
30803
+ * @param {Parent|null|undefined} [parent]
30804
+ * @returns {node is Y}
30805
+ */
30806
+
30807
+ // Check if `node` is an `element` and whether it passes the given test.
30808
+ const isElement =
30809
+ /**
30810
+ * Check if a node is an element and passes a test.
30811
+ * When a `parent` node is known the `index` of node should also be given.
30812
+ *
30813
+ * @type {(
30814
+ * (() => false) &
30815
+ * (<T extends Element = Element>(node: unknown, test?: PredicateTest<T>, index?: number, parent?: Parent, context?: unknown) => node is T) &
30816
+ * ((node: unknown, test: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
30817
+ * )}
30818
+ */
30819
+ (
30820
+ /**
30821
+ * Check if a node passes a test.
30822
+ * When a `parent` node is known the `index` of node should also be given.
30823
+ *
30824
+ * @param {unknown} [node] Node to check
30825
+ * @param {Test} [test] When nullish, checks if `node` is a `Node`.
30826
+ * When `string`, works like passing `function (node) {return node.type === test}`.
30827
+ * When `function` checks if function passed the node is true.
30828
+ * When `array`, checks any one of the subtests pass.
30829
+ * @param {number} [index] Position of `node` in `parent`
30830
+ * @param {Parent} [parent] Parent of `node`
30831
+ * @param {unknown} [context] Context object to invoke `test` with
30832
+ * @returns {boolean} Whether test passed and `node` is an `Element` (object with `type` set to `element` and `tagName` set to a non-empty string).
30833
+ */
30834
+ // eslint-disable-next-line max-params
30835
+ function (node, test, index, parent, context) {
30836
+ const check = convertElement(test)
30837
+
30838
+ if (
30839
+ index !== undefined &&
30840
+ index !== null &&
30841
+ (typeof index !== 'number' ||
30842
+ index < 0 ||
30843
+ index === Number.POSITIVE_INFINITY)
30844
+ ) {
30845
+ throw new Error('Expected positive finite index for child node')
30846
+ }
30847
+
30848
+ if (
30849
+ parent !== undefined &&
30850
+ parent !== null &&
30851
+ (!parent.type || !parent.children)
30852
+ ) {
30853
+ throw new Error('Expected parent node')
30923
30854
  }
30924
30855
 
30925
- /**
30926
- * @param {Comment|Stitch} node
30927
- * @returns {void}
30928
- */
30929
- function comment(node) {
30930
- resetTokenizer()
30931
- parser._processToken({
30932
- type: commentToken,
30933
- data: node.value,
30934
- location: createParse5Location(node)
30935
- })
30856
+ // @ts-expect-error Looks like a node.
30857
+ if (!node || !node.type || typeof node.type !== 'string') {
30858
+ return false
30936
30859
  }
30937
30860
 
30938
- /**
30939
- * @param {Raw} node
30940
- * @returns {void}
30941
- */
30942
- function handleRaw(node) {
30943
- const start = pointStart(node)
30944
- const line = start.line || 1
30945
- const column = start.column || 1
30946
- const offset = start.offset || 0
30947
-
30948
- /* c8 ignore next 4 */
30949
- if (!preprocessor) throw new Error('Expected `preprocessor`')
30950
- if (!tokenizer) throw new Error('Expected `tokenizer`')
30951
- if (!posTracker) throw new Error('Expected `posTracker`')
30952
- if (!locationTracker) throw new Error('Expected `locationTracker`')
30953
-
30954
- // Reset preprocessor:
30955
- // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/tokenizer/preprocessor.js#L17>.
30956
- preprocessor.html = undefined
30957
- preprocessor.pos = -1
30958
- preprocessor.lastGapPos = -1
30959
- preprocessor.lastCharPos = -1
30960
- preprocessor.gapStack = []
30961
- preprocessor.skipNextNewLine = false
30962
- preprocessor.lastChunkWritten = false
30963
- preprocessor.endOfChunkHit = false
30964
-
30965
- // Reset preprocessor mixin:
30966
- // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/position-tracking/preprocessor-mixin.js>.
30967
- posTracker.isEol = false
30968
- posTracker.lineStartPos = -column + 1 // Looks weird, but ensures we get correct positional info.
30969
- posTracker.droppedBufferSize = offset
30970
- posTracker.offset = 0
30971
- posTracker.col = 1
30972
- posTracker.line = line
30861
+ if (
30862
+ (parent === undefined || parent === null) !==
30863
+ (index === undefined || index === null)
30864
+ ) {
30865
+ throw new Error('Expected both parent and index')
30866
+ }
30973
30867
 
30974
- // Reset location tracker:
30975
- // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js>.
30976
- locationTracker.currentAttrLocation = undefined
30977
- locationTracker.ctLoc = createParse5Location(node)
30868
+ return check.call(context, node, index, parent)
30869
+ }
30870
+ )
30978
30871
 
30979
- // See the code for `parse` and `parseFragment`:
30980
- // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/parser/index.js#L371>.
30981
- tokenizer.write(node.value)
30982
- parser._runParsingLoop(null)
30872
+ const convertElement =
30873
+ /**
30874
+ * @type {(
30875
+ * (<T extends Element>(test: T['tagName']|TestFunctionPredicate<T>) => AssertPredicate<T>) &
30876
+ * ((test?: Test) => AssertAnything)
30877
+ * )}
30878
+ */
30879
+ (
30880
+ /**
30881
+ * Generate an assertion from a check.
30882
+ * @param {Test} [test]
30883
+ * When nullish, checks if `node` is a `Node`.
30884
+ * When `string`, works like passing `function (node) {return node.type === test}`.
30885
+ * When `function` checks if function passed the node is true.
30886
+ * When `object`, checks that all keys in test are in node, and that they have (strictly) equal values.
30887
+ * When `array`, checks any one of the subtests pass.
30888
+ * @returns {AssertAnything}
30889
+ */
30890
+ function (test) {
30891
+ if (test === undefined || test === null) {
30892
+ return hast_util_is_element_element
30893
+ }
30983
30894
 
30984
- // Character references hang, so if we ended there, we need to flush
30985
- // those too.
30986
- // We reset the preprocessor as if the document ends here.
30987
- // Then one single call to the relevant state does the trick, parse5
30988
- // consumes the whole token.
30989
- if (
30990
- tokenizer.state === 'NAMED_CHARACTER_REFERENCE_STATE' ||
30991
- tokenizer.state === 'NUMERIC_CHARACTER_REFERENCE_END_STATE'
30992
- ) {
30993
- preprocessor.lastChunkWritten = true
30994
- tokenizer[tokenizer.state](tokenizer._consume())
30995
- }
30895
+ if (typeof test === 'string') {
30896
+ return tagNameFactory(test)
30996
30897
  }
30997
30898
 
30998
- /**
30999
- * @param {Node} node
31000
- */
31001
- function stitch(node) {
31002
- stitches = true
30899
+ if (typeof test === 'object') {
30900
+ return hast_util_is_element_anyFactory(test)
30901
+ }
31003
30902
 
31004
- /** @type {Node} */
31005
- let clone
30903
+ if (typeof test === 'function') {
30904
+ return hast_util_is_element_castFactory(test)
30905
+ }
31006
30906
 
31007
- // Recurse, because to somewhat handle `[<x>]</x>` (where `[]` denotes the
31008
- // passed through node).
31009
- if ('children' in node) {
31010
- clone = {
31011
- ...node,
31012
- children: raw(
31013
- {type: 'root', children: node.children},
31014
- file,
31015
- options
31016
- // @ts-expect-error Assume a given parent yields a parent.
31017
- ).children
31018
- }
31019
- } else {
31020
- clone = {...node}
31021
- }
30907
+ throw new Error('Expected function, string, or array as test')
30908
+ }
30909
+ )
31022
30910
 
31023
- // Hack: `value` is supposed to be a string, but as none of the tools
31024
- // (`parse5` or `hast-util-from-parse5`) looks at it, we can pass nodes
31025
- // through.
31026
- comment({type: 'comment', value: {stitch: clone}})
31027
- }
30911
+ /**
30912
+ * @param {Array.<TagName|TestFunctionAnything>} tests
30913
+ * @returns {AssertAnything}
30914
+ */
30915
+ function hast_util_is_element_anyFactory(tests) {
30916
+ /** @type {Array.<AssertAnything>} */
30917
+ const checks = []
30918
+ let index = -1
31028
30919
 
31029
- function resetTokenizer() {
31030
- /* c8 ignore next 2 */
31031
- if (!tokenizer) throw new Error('Expected `tokenizer`')
31032
- if (!posTracker) throw new Error('Expected `posTracker`')
30920
+ while (++index < tests.length) {
30921
+ checks[index] = convertElement(tests[index])
30922
+ }
31033
30923
 
31034
- // Process final characters if they’re still there after hibernating.
31035
- // Similar to:
31036
- // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js#L95>.
31037
- const token = tokenizer.currentCharacterToken
30924
+ return hast_util_is_element_castFactory(any)
31038
30925
 
31039
- if (token) {
31040
- token.location.endLine = posTracker.line
31041
- token.location.endCol = posTracker.col + 1
31042
- token.location.endOffset = posTracker.offset + 1
31043
- parser._processToken(token)
31044
- }
30926
+ /**
30927
+ * @this {unknown}
30928
+ * @param {unknown[]} parameters
30929
+ * @returns {boolean}
30930
+ */
30931
+ function any(...parameters) {
30932
+ let index = -1
31045
30933
 
31046
- // Reset tokenizer:
31047
- // See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/tokenizer/index.js#L218-L234>.
31048
- // Especially putting it back in the `data` state is useful: some elements,
31049
- // like textareas and iframes, change the state.
31050
- // See GH-7.
31051
- // But also if broken HTML is in `raw`, and then a correct element is given.
31052
- // See GH-11.
31053
- tokenizer.tokenQueue = []
31054
- tokenizer.state = dataState
31055
- tokenizer.returnState = ''
31056
- tokenizer.charRefCode = -1
31057
- tokenizer.tempBuff = []
31058
- tokenizer.lastStartTagName = ''
31059
- tokenizer.consumedAfterSnapshot = -1
31060
- tokenizer.active = false
31061
- tokenizer.currentCharacterToken = undefined
31062
- tokenizer.currentToken = undefined
31063
- tokenizer.currentAttr = undefined
30934
+ while (++index < checks.length) {
30935
+ if (checks[index].call(this, ...parameters)) {
30936
+ return true
31064
30937
  }
31065
30938
  }
31066
- )
31067
- /**
31068
- * @param {Element} node
31069
- * @returns {HiddenToken}
31070
- */
31071
- function startTag(node) {
31072
- /** @type {P5Location} */
31073
- const location = Object.assign(createParse5Location(node))
31074
- // @ts-expect-error extra positional info.
31075
- location.startTag = Object.assign({}, location)
31076
30939
 
31077
- // Untyped token.
31078
- return {
31079
- type: startTagToken,
31080
- tagName: node.tagName,
31081
- selfClosing: false,
31082
- attrs: attributes(node),
31083
- location
30940
+ return false
31084
30941
  }
31085
30942
  }
31086
30943
 
31087
30944
  /**
31088
- * @param {Element} node
31089
- * @returns {Array<P5Attribute>}
31090
- */
31091
- function attributes(node) {
31092
- return toParse5({
31093
- tagName: node.tagName,
31094
- type: 'element',
31095
- properties: node.properties,
31096
- children: []
31097
- // @ts-expect-error Assume element.
31098
- }).attrs
31099
- }
31100
-
31101
- /**
31102
- * @param {Element} node
31103
- * @returns {HiddenToken}
30945
+ * Utility to convert a string into a function which checks a given node’s tag
30946
+ * name for said string.
30947
+ *
30948
+ * @param {TagName} check
30949
+ * @returns {AssertAnything}
31104
30950
  */
31105
- function endTag(node) {
31106
- /** @type {P5Location} */
31107
- const location = Object.assign(createParse5Location(node))
31108
- // @ts-expect-error extra positional info.
31109
- location.startTag = Object.assign({}, location)
30951
+ function tagNameFactory(check) {
30952
+ return tagName
31110
30953
 
31111
- // Untyped token.
31112
- return {
31113
- type: endTagToken,
31114
- tagName: node.tagName,
31115
- attrs: [],
31116
- location
30954
+ /**
30955
+ * @param {unknown} node
30956
+ * @returns {boolean}
30957
+ */
30958
+ function tagName(node) {
30959
+ return hast_util_is_element_element(node) && node.tagName === check
31117
30960
  }
31118
30961
  }
31119
30962
 
31120
30963
  /**
31121
- * @param {Node} node
30964
+ * @param {TestFunctionAnything} check
30965
+ * @returns {AssertAnything}
31122
30966
  */
31123
- function lib_unknown(node) {
31124
- throw new Error('Cannot compile `' + node.type + '` node')
30967
+ function hast_util_is_element_castFactory(check) {
30968
+ return assertion
30969
+
30970
+ /**
30971
+ * @this {unknown}
30972
+ * @param {unknown} node
30973
+ * @param {Array.<unknown>} parameters
30974
+ * @returns {boolean}
30975
+ */
30976
+ function assertion(node, ...parameters) {
30977
+ // @ts-expect-error: fine.
30978
+ return hast_util_is_element_element(node) && Boolean(check.call(this, node, ...parameters))
30979
+ }
31125
30980
  }
31126
30981
 
31127
30982
  /**
31128
- * @param {Node} node
31129
- * @returns {boolean}
30983
+ * Utility to return true if this is an element.
30984
+ * @param {unknown} node
30985
+ * @returns {node is Element}
31130
30986
  */
31131
- function documentMode(node) {
31132
- const head = node.type === 'root' ? node.children[0] : node
30987
+ function hast_util_is_element_element(node) {
31133
30988
  return Boolean(
31134
- head &&
31135
- (head.type === 'doctype' ||
31136
- (head.type === 'element' && head.tagName === 'html'))
30989
+ node &&
30990
+ typeof node === 'object' &&
30991
+ // @ts-expect-error Looks like a node.
30992
+ node.type === 'element' &&
30993
+ // @ts-expect-error Looks like an element.
30994
+ typeof node.tagName === 'string'
31137
30995
  )
31138
30996
  }
31139
30997
 
30998
+ ;// CONCATENATED MODULE: ../node_modules/rehype-autolink-headings/lib/index.js
31140
30999
  /**
31141
- * @param {Node|Stitch} node
31142
- * @returns {P5Location}
31000
+ * @typedef {import('hast').Root} Root
31001
+ * @typedef {import('hast').Parent} Parent
31002
+ * @typedef {import('hast').Element} Element
31003
+ * @typedef {Element['children'][number]} ElementChild
31004
+ * @typedef {import('hast').Properties} Properties
31005
+ * @typedef {import('hast-util-is-element').Test} Test
31006
+ *
31007
+ * @typedef {'prepend'|'append'|'wrap'|'before'|'after'} Behavior
31008
+ *
31009
+ * @callback Build
31010
+ * @param {Element} node
31011
+ * @returns {ElementChild|ElementChild[]}
31012
+ *
31013
+ * @typedef Options
31014
+ * Configuration.
31015
+ * @property {Behavior} [behavior='prepend']
31016
+ * How to create links.
31017
+ * @property {Behavior} [behaviour]
31018
+ * Please use `behavior` instead
31019
+ * @property {Properties} [properties]
31020
+ * Extra properties to set on the link when injecting.
31021
+ * Defaults to `{ariaHidden: true, tabIndex: -1}` when `'prepend'` or
31022
+ * `'append'`.
31023
+ * @property {ElementChild|ElementChild[]|Build} [content={type: 'element', tagName: 'span', properties: {className: ['icon', 'icon-link']}, children: []}]
31024
+ * hast nodes to insert in the link.
31025
+ * @property {ElementChild|ElementChild[]|Build} [group]
31026
+ * hast node to wrap the heading and link with, if `behavior` is `'before'` or
31027
+ * `'after'`.
31028
+ * There is no default.
31029
+ * @property {Test} [test]
31030
+ * Test to define which heading elements are linked.
31031
+ * Any test that can be given to `hast-util-is-element` is supported.
31032
+ * The default (no test) is to link all headings.
31033
+ * Can be used to link only h1-h3, or for example all except h1.
31143
31034
  */
31144
- function createParse5Location(node) {
31145
- const start = pointStart(node)
31146
- const end = pointEnd(node)
31147
31035
 
31148
- return {
31149
- startLine: start.line,
31150
- startCol: start.column,
31151
- startOffset: start.offset,
31152
- endLine: end.line,
31153
- endCol: end.column,
31154
- endOffset: end.offset
31155
- }
31156
- }
31157
31036
 
31158
- /**
31159
- * @param {VFile|Options|undefined} value
31160
- * @return {value is Options}
31161
- */
31162
- function isOptions(value) {
31163
- return Boolean(value && !('message' in value && 'messages' in value))
31164
- }
31165
31037
 
31166
- ;// CONCATENATED MODULE: ../node_modules/rehype-raw/index.js
31167
- /**
31168
- * @typedef {import('hast').Root} Root
31169
- * @typedef {import('hast-util-raw').Options} Options
31170
- * @typedef {import('hast-util-raw')} DoNotTouchAsThisImportIncludesRawInTree
31171
- */
31172
31038
 
31173
31039
 
31174
31040
 
31041
+
31042
+ /** @type {Element} */
31043
+ const contentDefaults = {
31044
+ type: 'element',
31045
+ tagName: 'span',
31046
+ properties: {className: ['icon', 'icon-link']},
31047
+ children: []
31048
+ }
31049
+
31175
31050
  /**
31176
- * Plugin to parse the tree again (and raw nodes).
31177
- * Keeping positional info OK. 🙌
31051
+ * Plugin to automatically add links to headings (h1-h6).
31178
31052
  *
31179
- * @type {import('unified').Plugin<[Options?] | Array<void>, Root>}
31053
+ * @type {import('unified').Plugin<[Options?]|void[], Root>}
31180
31054
  */
31181
- function rehypeRaw(options = {}) {
31182
- return (tree, file) => {
31183
- // Assume that when a root was given, it’s also returned.
31184
- const result = /** @type {Root} */ (raw(tree, file, options))
31185
- return result
31055
+ function rehypeAutolinkHeadings(options = {}) {
31056
+ let props = options.properties
31057
+ const behavior = options.behaviour || options.behavior || 'prepend'
31058
+ const content = options.content || contentDefaults
31059
+ const group = options.group
31060
+ const is = convertElement(options.test)
31061
+
31062
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
31063
+ let method
31064
+
31065
+ if (behavior === 'wrap') {
31066
+ method = wrap
31067
+ } else if (behavior === 'before' || behavior === 'after') {
31068
+ method = around
31069
+ } else {
31070
+ if (!props) {
31071
+ props = {ariaHidden: 'true', tabIndex: -1}
31072
+ }
31073
+
31074
+ method = inject
31075
+ }
31076
+
31077
+ return (tree) => {
31078
+ visit(tree, 'element', (node, index, parent) => {
31079
+ if (
31080
+ headingRank(node) &&
31081
+ hasProperty(node, 'id') &&
31082
+ is(node, index, parent)
31083
+ ) {
31084
+ return method(node, index, parent)
31085
+ }
31086
+ })
31087
+ }
31088
+
31089
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
31090
+ function inject(node) {
31091
+ node.children[behavior === 'prepend' ? 'unshift' : 'push'](
31092
+ create(node, extend(true, {}, props), toChildren(content, node))
31093
+ )
31094
+
31095
+ return [SKIP]
31096
+ }
31097
+
31098
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
31099
+ function around(node, index, parent) {
31100
+ // Uncommon.
31101
+ /* c8 ignore next */
31102
+ if (typeof index !== 'number' || !parent) return
31103
+
31104
+ const link = create(
31105
+ node,
31106
+ extend(true, {}, props),
31107
+ toChildren(content, node)
31108
+ )
31109
+ let nodes = behavior === 'before' ? [link, node] : [node, link]
31110
+
31111
+ if (group) {
31112
+ const grouping = toNode(group, node)
31113
+
31114
+ if (grouping && !Array.isArray(grouping) && grouping.type === 'element') {
31115
+ grouping.children = nodes
31116
+ nodes = [grouping]
31117
+ }
31118
+ }
31119
+
31120
+ parent.children.splice(index, 1, ...nodes)
31121
+
31122
+ return [SKIP, index + nodes.length]
31123
+ }
31124
+
31125
+ /** @type {import('unist-util-visit/complex-types').Visitor<Element>} */
31126
+ function wrap(node) {
31127
+ node.children = [create(node, extend(true, {}, props), node.children)]
31128
+ return [SKIP]
31129
+ }
31130
+
31131
+ /**
31132
+ * @param {ElementChild|ElementChild[]|Build} value
31133
+ * @param {Element} node
31134
+ * @returns {ElementChild[]}
31135
+ */
31136
+ function toChildren(value, node) {
31137
+ const result = toNode(value, node)
31138
+ return Array.isArray(result) ? result : [result]
31139
+ }
31140
+
31141
+ /**
31142
+ * @param {ElementChild|ElementChild[]|Build} value
31143
+ * @param {Element} node
31144
+ * @returns {ElementChild|ElementChild[]}
31145
+ */
31146
+ function toNode(value, node) {
31147
+ if (typeof value === 'function') return value(node)
31148
+ return extend(true, Array.isArray(value) ? [] : {}, value)
31149
+ }
31150
+
31151
+ /**
31152
+ * @param {Element} node
31153
+ * @param {Properties} props
31154
+ * @param {ElementChild[]} children
31155
+ * @returns {Element}
31156
+ */
31157
+ function create(node, props, children) {
31158
+ return {
31159
+ type: 'element',
31160
+ tagName: 'a',
31161
+ properties: Object.assign({}, props, {
31162
+ // Fix hast types and make them required.
31163
+ /* c8 ignore next */
31164
+ href: '#' + (node.properties || {}).id
31165
+ }),
31166
+ children
31167
+ }
31186
31168
  }
31187
31169
  }
31188
31170
 
@@ -60383,7 +60365,6 @@ function copyElement(str) {
60383
60365
  if (str === void 0) {
60384
60366
  str = '';
60385
60367
  }
60386
-
60387
60368
  return {
60388
60369
  type: 'element',
60389
60370
  tagName: 'div',
@@ -60463,7 +60444,6 @@ var reservedMeta = function reservedMeta(options) {
60463
60444
  if (options === void 0) {
60464
60445
  options = {};
60465
60446
  }
60466
-
60467
60447
  return tree => {
60468
60448
  visit(tree, node => {
60469
60449
  if (node.type === 'element' && node.tagName === 'code' && node.data && node.data.meta) {
@@ -60480,7 +60460,7 @@ var jsx_runtime = __webpack_require__(605);
60480
60460
  ;// CONCATENATED MODULE: ../node_modules/@uiw/react-markdown-preview/esm/index.js
60481
60461
 
60482
60462
 
60483
- var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "warpperElement"];
60463
+ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "skipHtml", "onScroll", "onMouseOver", "pluginsFilter", "rehypeRewrite", "warpperElement"];
60484
60464
 
60485
60465
 
60486
60466
 
@@ -60498,29 +60478,27 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "on
60498
60478
 
60499
60479
  /* harmony default export */ const esm = (/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().forwardRef((props, ref) => {
60500
60480
  var {
60501
- prefixCls = 'wmde-markdown wmde-markdown-color',
60502
- className,
60503
- source,
60504
- style,
60505
- disableCopy = false,
60506
- onScroll,
60507
- onMouseOver,
60508
- pluginsFilter,
60509
- rehypeRewrite: rewrite,
60510
- warpperElement = {}
60511
- } = props,
60512
- other = _objectWithoutPropertiesLoose(props, _excluded);
60513
-
60481
+ prefixCls = 'wmde-markdown wmde-markdown-color',
60482
+ className,
60483
+ source,
60484
+ style,
60485
+ disableCopy = false,
60486
+ skipHtml = true,
60487
+ onScroll,
60488
+ onMouseOver,
60489
+ pluginsFilter,
60490
+ rehypeRewrite: rewrite,
60491
+ warpperElement = {}
60492
+ } = props,
60493
+ other = _objectWithoutPropertiesLoose(props, _excluded);
60514
60494
  var mdp = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createRef();
60515
60495
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(ref, () => _extends({}, props, {
60516
60496
  mdp
60517
60497
  }), [mdp, props]);
60518
60498
  var cls = (prefixCls || '') + " " + (className || '');
60519
-
60520
60499
  var rehypeRewriteHandle = (node, index, parent) => {
60521
60500
  if (node.type === 'element' && parent && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
60522
60501
  var child = node.children && node.children[0];
60523
-
60524
60502
  if (child && child.properties && child.properties.ariaHidden === 'true') {
60525
60503
  child.properties = _extends({
60526
60504
  class: 'anchor'
@@ -60528,18 +60506,15 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "on
60528
60506
  child.children = [octiconLink];
60529
60507
  }
60530
60508
  }
60531
-
60532
60509
  if (node.type === 'element' && node.tagName === 'pre' && !disableCopy) {
60533
60510
  var code = getCodeString(node.children);
60534
60511
  node.children.push(copyElement(code));
60535
60512
  }
60536
-
60537
60513
  rewrite && rewrite(node, index, parent);
60538
60514
  };
60539
-
60540
60515
  var rehypePlugins = [reservedMeta, [m, {
60541
60516
  ignoreMissing: true
60542
- }], rehypeRaw, rehypeSlug, rehypeAutolinkHeadings, rehype_ignore_lib, [rehype_rewrite_lib, {
60517
+ }], rehypeSlug, rehypeAutolinkHeadings, rehype_ignore_lib, [rehype_rewrite_lib, {
60543
60518
  rewrite: rehypeRewriteHandle
60544
60519
  }], [rehype_attr_lib, {
60545
60520
  properties: 'attr'
@@ -60549,10 +60524,12 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "on
60549
60524
  if (other.allowElement) {
60550
60525
  return other.allowElement(element, index, parent);
60551
60526
  }
60552
-
60553
60527
  return /^[A-Za-z0-9]+$/.test(element.tagName);
60554
60528
  }
60555
60529
  };
60530
+ if (skipHtml) {
60531
+ rehypePlugins.push(rehypeRaw);
60532
+ }
60556
60533
  var remarkPlugins = [...(other.remarkPlugins || []), remarkGfm];
60557
60534
  return /*#__PURE__*/(0,jsx_runtime.jsx)("div", _extends({
60558
60535
  ref: mdp,
@@ -60561,7 +60538,8 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "on
60561
60538
  }, warpperElement, {
60562
60539
  className: cls,
60563
60540
  style: style,
60564
- children: /*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown, _extends({}, other, customProps, {
60541
+ children: /*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown, _extends({}, customProps, other, {
60542
+ skipHtml: skipHtml,
60565
60543
  rehypePlugins: pluginsFilter ? pluginsFilter('rehype', rehypePlugins) : rehypePlugins,
60566
60544
  remarkPlugins: pluginsFilter ? pluginsFilter('remark', remarkPlugins) : remarkPlugins,
60567
60545
  children: source || ''
@@ -60572,7 +60550,7 @@ var _excluded = ["prefixCls", "className", "source", "style", "disableCopy", "on
60572
60550
  ;// CONCATENATED MODULE: ./src/Context.tsx
60573
60551
  function reducer(state,action){return _objectSpread2(_objectSpread2({},state),action);}var EditorContext=/*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createContext({markdown:''});
60574
60552
  ;// CONCATENATED MODULE: ./src/components/TextArea/shortcuts.ts
60575
- function getCommands(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var resulte=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};data.forEach(function(item){if(item.children&&Array.isArray(item.children)){resulte=_objectSpread2(_objectSpread2({},resulte),getCommands(item.children||[]));}else if(item.keyCommand&&item.shortcuts&&item.execute){resulte[item.shortcuts.toLocaleLowerCase()]=item;}});return resulte;}function shortcutsHandle(e){var commands=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var commandOrchestrator=arguments.length>2?arguments[2]:undefined;var dispatch=arguments.length>3?arguments[3]:undefined;var state=arguments.length>4?arguments[4]:undefined;var data=getCommands(commands||[]);var shortcuts=[];if(e.altKey){shortcuts.push('alt');}if(e.shiftKey){shortcuts.push('shift');}if(e.metaKey){shortcuts.push('cmd');}if(e.ctrlKey){shortcuts.push('ctrl');}if(shortcuts.length>0&&!/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())){shortcuts.push(e.key.toLocaleLowerCase());}if(/escape/.test(e.key.toLocaleLowerCase())){shortcuts.push('escape');}if(shortcuts.length<1){return;}var equal=!!data[shortcuts.join('+')];var command=equal?data[shortcuts.join('+')]:undefined;Object.keys(data).forEach(function(item){var isequal=item.split('+').every(function(v){if(/ctrlcmd/.test(v)){return shortcuts.includes('ctrl')||shortcuts.includes('cmd');}return shortcuts.includes(v);});if(isequal){command=data[item];}});if(command&&commandOrchestrator){e.stopPropagation();e.preventDefault();commandOrchestrator.executeCommand(command,dispatch,state);return;}}
60553
+ function getCommands(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var resulte=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};data.forEach(function(item){if(item.children&&Array.isArray(item.children)){resulte=_objectSpread2(_objectSpread2({},resulte),getCommands(item.children||[]));}else if(item.keyCommand&&item.shortcuts&&item.execute){resulte[item.shortcuts.toLocaleLowerCase()]=item;}});return resulte;}function shortcutsHandle(e){var commands=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var commandOrchestrator=arguments.length>2?arguments[2]:undefined;var dispatch=arguments.length>3?arguments[3]:undefined;var state=arguments.length>4?arguments[4]:undefined;var data=getCommands(commands||[]);var shortcuts=[];if(e.altKey){shortcuts.push('alt');}if(e.shiftKey){shortcuts.push('shift');}if(e.metaKey){shortcuts.push('cmd');}if(e.ctrlKey){shortcuts.push('ctrl');}if(shortcuts.length>0&&!/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())){shortcuts.push(e.key.toLocaleLowerCase());}if(/escape/.test(e.key.toLocaleLowerCase())){shortcuts.push('escape');}if(shortcuts.length<1){return;}var equal=!!data[shortcuts.join('+')];var command=equal?data[shortcuts.join('+')]:undefined;Object.keys(data).forEach(function(item){var isequal=item.split('+').every(function(v){if(/ctrlcmd/.test(v)){return shortcuts.includes('ctrl')||shortcuts.includes('cmd');}return shortcuts.includes(v);});if(isequal){command=data[item];}});if(command&&commandOrchestrator){e.stopPropagation();e.preventDefault();commandOrchestrator.executeCommand(command,dispatch,state,shortcuts);return;}}
60576
60554
  ;// CONCATENATED MODULE: ../node_modules/rehype-parse/lib/errors.js
60577
60555
  const errors = {
60578
60556
  abandonedHeadElementChild: {
@@ -62544,7 +62522,6 @@ function _defineProperties(target, props) {
62544
62522
  Object.defineProperty(target, descriptor.key, descriptor);
62545
62523
  }
62546
62524
  }
62547
-
62548
62525
  function _createClass(Constructor, protoProps, staticProps) {
62549
62526
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
62550
62527
  if (staticProps) _defineProperties(Constructor, staticProps);
@@ -62633,9 +62610,13 @@ api.setSelectionRange({start:state2.selection.end-4-state1.selectedText.length,e
62633
62610
  ;// CONCATENATED MODULE: ./src/commands/divider.tsx
62634
62611
  var divider={keyCommand:'divider'};
62635
62612
  ;// CONCATENATED MODULE: ./src/commands/fullscreen.tsx
62636
- var fullscreen={name:'fullscreen',keyCommand:'fullscreen',shortcuts:'ctrlcmd+0',value:'fullscreen',buttonProps:{'aria-label':'Toggle fullscreen (ctrl + 0)',title:'Toggle fullscreen (ctrl+ 0)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M118 171.133334L118 342.200271C118 353.766938 126.675 365.333605 141.133333 365.333605L382.634614 365.333605C394.201281 365.333605 405.767948 356.658605 405.767948 342.200271L405.767948 171.133334C405.767948 159.566667 397.092948 148 382.634614 148L141.133333 148C126.674999 148 117.999999 156.675 118 171.133334zM465.353591 413.444444L370 413.444444 370 471.222222 474.0221 471.222222C500.027624 471.222222 520.254143 451 520.254143 425L520.254143 321 462.464089 321 462.464089 413.444444 465.353591 413.444444zM471.0221 43L367 43 367 100.777778 462.353591 100.777778 462.353591 196.111111 520.143647 196.111111 520.143647 89.2222219C517.254144 63.2222219 497.027624 43 471.0221 43zM57.7900547 100.777778L153.143646 100.777778 153.143646 43 46.2320439 43C20.2265191 43 0 63.2222219 0 89.2222219L0 193.222222 57.7900547 193.222222 57.7900547 100.777778zM57.7900547 321L0 321 0 425C0 451 20.2265191 471.222222 46.2320439 471.222223L150.254143 471.222223 150.254143 413.444445 57.7900547 413.444445 57.7900547 321z"})}),execute:function execute(state,api,dispatch,executeCommandState){api.textArea.focus();if(dispatch&&executeCommandState&&executeCommandState.fullscreen){dispatch({fullscreen:false});}}};
62613
+ var fullscreen={name:'fullscreen',keyCommand:'fullscreen',shortcuts:'ctrlcmd+0',value:'fullscreen',buttonProps:{'aria-label':'Toggle fullscreen (ctrl + 0)',title:'Toggle fullscreen (ctrl+ 0)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M118 171.133334L118 342.200271C118 353.766938 126.675 365.333605 141.133333 365.333605L382.634614 365.333605C394.201281 365.333605 405.767948 356.658605 405.767948 342.200271L405.767948 171.133334C405.767948 159.566667 397.092948 148 382.634614 148L141.133333 148C126.674999 148 117.999999 156.675 118 171.133334zM465.353591 413.444444L370 413.444444 370 471.222222 474.0221 471.222222C500.027624 471.222222 520.254143 451 520.254143 425L520.254143 321 462.464089 321 462.464089 413.444444 465.353591 413.444444zM471.0221 43L367 43 367 100.777778 462.353591 100.777778 462.353591 196.111111 520.143647 196.111111 520.143647 89.2222219C517.254144 63.2222219 497.027624 43 471.0221 43zM57.7900547 100.777778L153.143646 100.777778 153.143646 43 46.2320439 43C20.2265191 43 0 63.2222219 0 89.2222219L0 193.222222 57.7900547 193.222222 57.7900547 100.777778zM57.7900547 321L0 321 0 425C0 451 20.2265191 471.222222 46.2320439 471.222223L150.254143 471.222223 150.254143 413.444445 57.7900547 413.444445 57.7900547 321z"})}),execute:function execute(state,api,dispatch,executeCommandState,shortcuts){api.textArea.focus();if(shortcuts&&dispatch&&executeCommandState){dispatch({fullscreen:!executeCommandState.fullscreen});}}};
62614
+ ;// CONCATENATED MODULE: ../node_modules/@babel/runtime/helpers/esm/objectDestructuringEmpty.js
62615
+ function _objectDestructuringEmpty(obj) {
62616
+ if (obj == null) throw new TypeError("Cannot destructure " + obj);
62617
+ }
62637
62618
  ;// CONCATENATED MODULE: ./src/commands/group.tsx
62638
- var group=function group(arr,options){var data=_objectSpread2(_objectSpread2({children:arr,icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z"})}),execute:function execute(){}},options),{},{keyCommand:'group'});if(Array.isArray(data.children)){data.children=data.children.map(function(_ref){var item=Object.assign({},_ref);item.parent=data;return _objectSpread2({},item);});}return data;};
62619
+ var group=function group(arr,options){var data=_objectSpread2(_objectSpread2({children:arr,icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z"})}),execute:function execute(){}},options),{},{keyCommand:'group'});if(Array.isArray(data.children)){data.children=data.children.map(function(_ref){var item=Object.assign({},(_objectDestructuringEmpty(_ref),_ref));item.parent=data;return _objectSpread2({},item);});}return data;};
62639
62620
  ;// CONCATENATED MODULE: ./src/commands/hr.tsx
62640
62621
  var hr={name:'hr',keyCommand:'hr',shortcuts:'ctrlcmd+h',value:'----------',buttonProps:{'aria-label':'Insert HR (ctrl + h)',title:'Insert HR (ctrl + h)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 175 175",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M0,129 L175,129 L175,154 L0,154 L0,129 Z M3,9 L28.2158203,9 L28.2158203,47.9824219 L55.7695313,47.9824219 L55.7695313,9 L81.0966797,9 L81.0966797,107.185547 L55.7695313,107.185547 L55.7695313,68.0214844 L28.2158203,68.0214844 L28.2158203,107.185547 L3,107.185547 L3,9 Z M93.1855469,100.603516 L93.1855469,19 L135.211914,19 C143.004922,19 148.960917,19.6679621 153.080078,21.0039063 C157.199239,22.3398504 160.520495,24.8168764 163.043945,28.4350586 C165.567395,32.0532407 166.829102,36.459935 166.829102,41.6552734 C166.829102,46.1826398 165.864267,50.0883625 163.93457,53.3725586 C162.004873,56.6567547 159.351579,59.3193257 155.974609,61.3603516 C153.822255,62.6591862 150.872089,63.7353473 147.124023,64.5888672 C150.129898,65.5908253 152.319329,66.5927684 153.692383,67.5947266 C154.620122,68.2626987 155.965323,69.6913953 157.728027,71.8808594 C159.490731,74.0703234 160.668942,75.7587831 161.262695,76.9462891 L173,100.603516 L144.953125,100.603516 L131.482422,75.6660156 C129.775382,72.4374839 128.253913,70.3408251 126.917969,69.3759766 C125.0996,68.1142515 123.040051,67.4833984 120.739258,67.4833984 L118.512695,67.4833984 L118.512695,100.603516 L93.1855469,100.603516 Z M118.512695,52.0644531 L129.144531,52.0644531 C130.294928,52.0644531 132.521468,51.6933631 135.824219,50.9511719 C137.494149,50.6171858 138.857905,49.7636787 139.915527,48.390625 C140.97315,47.0175713 141.501953,45.4404386 141.501953,43.6591797 C141.501953,41.0244009 140.667001,39.0019602 138.99707,37.5917969 C137.32714,36.1816336 134.191429,35.4765625 129.589844,35.4765625 L117.512695,35.4765625 L118.512695,52.0644531 Z",transform:"translate(0 9)"})}),execute:function execute(state,api){api.replaceSelection("".concat(state.selectedText,"\n\n----------\n\n"));}};
62641
62622
  ;// CONCATENATED MODULE: ./src/commands/image.tsx
@@ -62661,7 +62642,7 @@ var newSelectionRange=selectWord({text:state.text,selection:state.selection});va
62661
62642
  var oneLinerOffset=state1.selectedText.indexOf('\n')===-1?modifiedText.insertionLength:0;var selectionStart=state1.selection.start+breaksBeforeCount+oneLinerOffset;var selectionEnd=selectionStart+modifiedText.modifiedText.length-oneLinerOffset;// Adjust the selection to not contain the **
62662
62643
  api.setSelectionRange({start:selectionStart,end:selectionEnd});};var unorderedListCommand={name:'unordered-list',keyCommand:'list',shortcuts:'ctrl+shift+u',value:'- ',buttonProps:{'aria-label':'Add unordered list (ctrl + shift + u)',title:'Add unordered list (ctrl + shift + u)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{"data-name":"unordered-list",width:"12",height:"12",viewBox:"0 0 512 512",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M96 96c0 26.51-21.49 48-48 48S0 122.51 0 96s21.49-48 48-48 48 21.49 48 48zM48 208c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm0 160c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zm96-236h352c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"})}),execute:function execute(state,api){makeList(state,api,'- ');}};var orderedListCommand={name:'ordered-list',keyCommand:'list',shortcuts:'ctrl+shift+o',value:'1. ',buttonProps:{'aria-label':'Add ordered list (ctrl + shift + o)',title:'Add ordered list (ctrl + shift + o)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{"data-name":"ordered-list",width:"12",height:"12",role:"img",viewBox:"0 0 512 512",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M3.263 139.527c0-7.477 3.917-11.572 11.573-11.572h15.131V88.078c0-5.163.534-10.503.534-10.503h-.356s-1.779 2.67-2.848 3.738c-4.451 4.273-10.504 4.451-15.666-1.068l-5.518-6.231c-5.342-5.341-4.984-11.216.534-16.379l21.72-19.938C32.815 33.602 36.732 32 42.785 32H54.89c7.656 0 11.749 3.916 11.749 11.572v84.384h15.488c7.655 0 11.572 4.094 11.572 11.572v8.901c0 7.477-3.917 11.572-11.572 11.572H14.836c-7.656 0-11.573-4.095-11.573-11.572v-8.902zM2.211 304.591c0-47.278 50.955-56.383 50.955-69.165 0-7.18-5.954-8.755-9.28-8.755-3.153 0-6.479 1.051-9.455 3.852-5.079 4.903-10.507 7.004-16.111 2.451l-8.579-6.829c-5.779-4.553-7.18-9.805-2.803-15.409C13.592 201.981 26.025 192 47.387 192c19.437 0 44.476 10.506 44.476 39.573 0 38.347-46.753 46.402-48.679 56.909h39.049c7.529 0 11.557 4.027 11.557 11.382v8.755c0 7.354-4.028 11.382-11.557 11.382h-67.94c-7.005 0-12.083-4.028-12.083-11.382v-4.028zM5.654 454.61l5.603-9.28c3.853-6.654 9.105-7.004 15.584-3.152 4.903 2.101 9.63 3.152 14.359 3.152 10.155 0 14.358-3.502 14.358-8.23 0-6.654-5.604-9.106-15.934-9.106h-4.728c-5.954 0-9.28-2.101-12.258-7.88l-1.05-1.926c-2.451-4.728-1.226-9.806 2.801-14.884l5.604-7.004c6.829-8.405 12.257-13.483 12.257-13.483v-.35s-4.203 1.051-12.608 1.051H16.685c-7.53 0-11.383-4.028-11.383-11.382v-8.755c0-7.53 3.853-11.382 11.383-11.382h58.484c7.529 0 11.382 4.027 11.382 11.382v3.327c0 5.778-1.401 9.806-5.079 14.183l-17.509 20.137c19.611 5.078 28.716 20.487 28.716 34.845 0 21.363-14.358 44.126-48.503 44.126-16.636 0-28.192-4.728-35.896-9.455-5.779-4.202-6.304-9.805-2.626-15.934zM144 132h352c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h352c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H144c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"})}),execute:function execute(state,api){makeList(state,api,function(item,index){return"".concat(index+1,". ");});}};var checkedListCommand={name:'checked-list',keyCommand:'list',shortcuts:'ctrl+shift+c',value:'- [x] ',buttonProps:{'aria-label':'Add checked list (ctrl + shift + c)',title:'Add checked list (ctrl + shift + c)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{"data-name":"checked-list",width:"12",height:"12",role:"img",viewBox:"0 0 512 512",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M208 132h288c8.8 0 16-7.2 16-16V76c0-8.8-7.2-16-16-16H208c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16zm0 160h288c8.8 0 16-7.2 16-16v-40c0-8.8-7.2-16-16-16H208c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16zm0 160h288c8.8 0 16-7.2 16-16v-40c0-8.8-7.2-16-16-16H208c-8.8 0-16 7.2-16 16v40c0 8.8 7.2 16 16 16zM64 368c-26.5 0-48.6 21.5-48.6 48s22.1 48 48.6 48 48-21.5 48-48-21.5-48-48-48zm92.5-299l-72.2 72.2-15.6 15.6c-4.7 4.7-12.9 4.7-17.6 0L3.5 109.4c-4.7-4.7-4.7-12.3 0-17l15.7-15.7c4.7-4.7 12.3-4.7 17 0l22.7 22.1 63.7-63.3c4.7-4.7 12.3-4.7 17 0l17 16.5c4.6 4.7 4.6 12.3-.1 17zm0 159.6l-72.2 72.2-15.7 15.7c-4.7 4.7-12.9 4.7-17.6 0L3.5 269c-4.7-4.7-4.7-12.3 0-17l15.7-15.7c4.7-4.7 12.3-4.7 17 0l22.7 22.1 63.7-63.7c4.7-4.7 12.3-4.7 17 0l17 17c4.6 4.6 4.6 12.2-.1 16.9z"})}),execute:function execute(state,api){makeList(state,api,function(item,index){return"- [ ] ";});}};
62663
62644
  ;// CONCATENATED MODULE: ./src/commands/preview.tsx
62664
- var codePreview={name:'preview',keyCommand:'preview',value:'preview',shortcuts:'ctrlcmd+9',buttonProps:{'aria-label':'Preview code (ctrl + 9)',title:'Preview code (ctrl + 9)'},icon:/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"0 71.293 0 122 38.023 123 38.023 398 0 397 0 449.707 91.023 450.413 91.023 72.293"}),/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"148.023 72.293 520 71.293 520 122 200.023 124 200.023 397 520 396 520 449.707 148.023 450.413"})]}),execute:function execute(){}};var codeEdit={name:'edit',keyCommand:'preview',value:'edit',shortcuts:'ctrlcmd+7',buttonProps:{'aria-label':'Edit code (ctrl + 7)',title:'Edit code (ctrl + 7)'},icon:/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"0 71.293 0 122 319 122 319 397 0 397 0 449.707 372 449.413 372 71.293"}),/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"429 71.293 520 71.293 520 122 481 123 481 396 520 396 520 449.707 429 449.413"})]}),execute:function execute(){}};var codeLive={name:'live',keyCommand:'preview',value:'live',shortcuts:'ctrlcmd+8',buttonProps:{'aria-label':'Live code (ctrl + 8)',title:'Live code (ctrl + 8)'},icon:/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"0 71.293 0 122 179 122 179 397 0 397 0 449.707 232 449.413 232 71.293"}),/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"289 71.293 520 71.293 520 122 341 123 341 396 520 396 520 449.707 289 449.413"})]}),execute:function execute(){}};
62645
+ var codePreview={name:'preview',keyCommand:'preview',value:'preview',shortcuts:'ctrlcmd+9',buttonProps:{'aria-label':'Preview code (ctrl + 9)',title:'Preview code (ctrl + 9)'},icon:/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"0 71.293 0 122 38.023 123 38.023 398 0 397 0 449.707 91.023 450.413 91.023 72.293"}),/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"148.023 72.293 520 71.293 520 122 200.023 124 200.023 397 520 396 520 449.707 148.023 450.413"})]}),execute:function execute(state,api,dispatch,executeCommandState,shortcuts){if(shortcuts&&dispatch&&executeCommandState){dispatch({preview:'preview'});}}};var codeEdit={name:'edit',keyCommand:'preview',value:'edit',shortcuts:'ctrlcmd+7',buttonProps:{'aria-label':'Edit code (ctrl + 7)',title:'Edit code (ctrl + 7)'},icon:/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"0 71.293 0 122 319 122 319 397 0 397 0 449.707 372 449.413 372 71.293"}),/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"429 71.293 520 71.293 520 122 481 123 481 396 520 396 520 449.707 429 449.413"})]}),execute:function execute(state,api,dispatch,executeCommandState,shortcuts){if(shortcuts&&dispatch&&executeCommandState){dispatch({preview:'edit'});}}};var codeLive={name:'live',keyCommand:'preview',value:'live',shortcuts:'ctrlcmd+8',buttonProps:{'aria-label':'Live code (ctrl + 8)',title:'Live code (ctrl + 8)'},icon:/*#__PURE__*/(0,jsx_runtime.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"0 71.293 0 122 179 122 179 397 0 397 0 449.707 232 449.413 232 71.293"}),/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{fill:"currentColor",points:"289 71.293 520 71.293 520 122 341 123 341 396 520 396 520 449.707 289 449.413"})]}),execute:function execute(state,api,dispatch,executeCommandState,shortcuts){if(shortcuts&&dispatch&&executeCommandState){dispatch({preview:'live'});}}};
62665
62646
  ;// CONCATENATED MODULE: ./src/commands/quote.tsx
62666
62647
  var quote={name:'quote',keyCommand:'quote',shortcuts:'ctrlcmd+q',buttonProps:{'aria-label':'Insert a quote (ctrl + q)',title:'Insert a quote (ctrl + q)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 520 520",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M520,95.75 L520,225.75 C520,364.908906 457.127578,437.050625 325.040469,472.443125 C309.577578,476.586875 294.396016,464.889922 294.396016,448.881641 L294.396016,414.457031 C294.396016,404.242891 300.721328,395.025078 310.328125,391.554687 C377.356328,367.342187 414.375,349.711094 414.375,274.5 L341.25,274.5 C314.325781,274.5 292.5,252.674219 292.5,225.75 L292.5,95.75 C292.5,68.8257812 314.325781,47 341.25,47 L471.25,47 C498.174219,47 520,68.8257812 520,95.75 Z M178.75,47 L48.75,47 C21.8257813,47 0,68.8257812 0,95.75 L0,225.75 C0,252.674219 21.8257813,274.5 48.75,274.5 L121.875,274.5 C121.875,349.711094 84.8563281,367.342187 17.828125,391.554687 C8.22132813,395.025078 1.89601563,404.242891 1.89601563,414.457031 L1.89601563,448.881641 C1.89601563,464.889922 17.0775781,476.586875 32.5404687,472.443125 C164.627578,437.050625 227.5,364.908906 227.5,225.75 L227.5,95.75 C227.5,68.8257812 205.674219,47 178.75,47 Z"})}),execute:function execute(state,api){// Adjust the selection to encompass the whole word if the caret is inside one
62667
62648
  var newSelectionRange=selectWord({text:state.text,selection:state.selection});var state1=api.setSelectionRange(newSelectionRange);var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');// Replaces the current selection with the quote mark up
@@ -62693,7 +62674,7 @@ var commands_getCommands=function getCommands(){return[bold,italic,strikeThrough
62693
62674
  */_createClass(TextAreaTextApi,[{key:"replaceSelection",value:function replaceSelection(text){insertTextAtPosition(this.textArea,text);return getStateFromTextArea(this.textArea);}/**
62694
62675
  * Selects the specified text range
62695
62676
  * @param selection
62696
- */},{key:"setSelectionRange",value:function setSelectionRange(selection){this.textArea.focus();this.textArea.selectionStart=selection.start;this.textArea.selectionEnd=selection.end;return getStateFromTextArea(this.textArea);}}]);return TextAreaTextApi;}();var TextAreaCommandOrchestrator=/*#__PURE__*/function(){function TextAreaCommandOrchestrator(textArea){_classCallCheck(this,TextAreaCommandOrchestrator);this.textArea=void 0;this.textApi=void 0;this.textArea=textArea;this.textApi=new TextAreaTextApi(textArea);}_createClass(TextAreaCommandOrchestrator,[{key:"getState",value:function getState(){if(!this.textArea)return false;return getStateFromTextArea(this.textArea);}},{key:"executeCommand",value:function executeCommand(command,dispatch,state){command.execute&&command.execute(getStateFromTextArea(this.textArea),this.textApi,dispatch,state);}}]);return TextAreaCommandOrchestrator;}();
62677
+ */},{key:"setSelectionRange",value:function setSelectionRange(selection){this.textArea.focus();this.textArea.selectionStart=selection.start;this.textArea.selectionEnd=selection.end;return getStateFromTextArea(this.textArea);}}]);return TextAreaTextApi;}();var TextAreaCommandOrchestrator=/*#__PURE__*/function(){function TextAreaCommandOrchestrator(textArea){_classCallCheck(this,TextAreaCommandOrchestrator);this.textArea=void 0;this.textApi=void 0;this.textArea=textArea;this.textApi=new TextAreaTextApi(textArea);}_createClass(TextAreaCommandOrchestrator,[{key:"getState",value:function getState(){if(!this.textArea)return false;return getStateFromTextArea(this.textArea);}},{key:"executeCommand",value:function executeCommand(command,dispatch,state,shortcuts){command.execute&&command.execute(getStateFromTextArea(this.textArea),this.textApi,dispatch,state,shortcuts);}}]);return TextAreaCommandOrchestrator;}();
62697
62678
  ;// CONCATENATED MODULE: ./src/components/TextArea/handleKeyDown.tsx
62698
62679
  /**
62699
62680
  * - `13` - `Enter`