@seeqdev/qomponents 0.0.109 → 0.0.111

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 (220) hide show
  1. package/dist/InputGroup/InputGroup.types.d.ts +19 -4
  2. package/dist/ProgressBar/ProgressBar.d.ts +4 -0
  3. package/dist/ProgressBar/ProgressBar.js +16 -0
  4. package/dist/ProgressBar/ProgressBar.js.map +1 -0
  5. package/dist/ProgressBar/ProgressBar.stories.d.ts +5 -0
  6. package/dist/ProgressBar/ProgressBar.stories.js +42 -0
  7. package/dist/ProgressBar/ProgressBar.stories.js.map +1 -0
  8. package/dist/ProgressBar/ProgressBar.test.d.ts +1 -0
  9. package/dist/ProgressBar/ProgressBar.test.js +32 -0
  10. package/dist/ProgressBar/ProgressBar.test.js.map +1 -0
  11. package/dist/ProgressBar/ProgressBar.types.d.ts +10 -0
  12. package/dist/ProgressBar/ProgressBar.types.js +2 -0
  13. package/dist/ProgressBar/ProgressBar.types.js.map +1 -0
  14. package/dist/ProgressBar/index.d.ts +1 -0
  15. package/dist/ProgressBar/index.js +2 -0
  16. package/dist/ProgressBar/index.js.map +1 -0
  17. package/dist/Slider/Slider.d.ts +6 -0
  18. package/dist/Slider/Slider.js +13 -0
  19. package/dist/Slider/Slider.js.map +1 -0
  20. package/dist/Slider/Slider.stories.d.ts +5 -0
  21. package/dist/Slider/Slider.stories.js +58 -0
  22. package/dist/Slider/Slider.stories.js.map +1 -0
  23. package/dist/Slider/Slider.test.d.ts +1 -0
  24. package/dist/Slider/Slider.test.js +38 -0
  25. package/dist/Slider/Slider.test.js.map +1 -0
  26. package/dist/Slider/Slider.types.d.ts +13 -0
  27. package/dist/Slider/Slider.types.js +2 -0
  28. package/dist/Slider/Slider.types.js.map +1 -0
  29. package/dist/Slider/index.d.ts +1 -0
  30. package/dist/Slider/index.js +2 -0
  31. package/dist/Slider/index.js.map +1 -0
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.esm.js +1706 -1759
  34. package/dist/index.esm.js.map +1 -1
  35. package/dist/index.js +1706 -1758
  36. package/dist/index.js.map +1 -1
  37. package/dist/styles.css +50 -4
  38. package/package.json +5 -4
  39. package/dist/Accordion/Accordion.js +0 -9
  40. package/dist/Accordion/Accordion.js.map +0 -1
  41. package/dist/Accordion/Accordion.stories.js +0 -115
  42. package/dist/Accordion/Accordion.stories.js.map +0 -1
  43. package/dist/Accordion/Accordion.test.js +0 -55
  44. package/dist/Accordion/Accordion.test.js.map +0 -1
  45. package/dist/Accordion/Accordion.types.js +0 -2
  46. package/dist/Accordion/Accordion.types.js.map +0 -1
  47. package/dist/Accordion/index.js +0 -2
  48. package/dist/Accordion/index.js.map +0 -1
  49. package/dist/Alert/Alert.js +0 -32
  50. package/dist/Alert/Alert.js.map +0 -1
  51. package/dist/Alert/Alert.stories.js +0 -45
  52. package/dist/Alert/Alert.stories.js.map +0 -1
  53. package/dist/Alert/Alert.test.js +0 -51
  54. package/dist/Alert/Alert.test.js.map +0 -1
  55. package/dist/Alert/Alert.types.js +0 -2
  56. package/dist/Alert/Alert.types.js.map +0 -1
  57. package/dist/Alert/index.js +0 -2
  58. package/dist/Alert/index.js.map +0 -1
  59. package/dist/Button/Button.js +0 -92
  60. package/dist/Button/Button.js.map +0 -1
  61. package/dist/Button/Button.stories.js +0 -98
  62. package/dist/Button/Button.stories.js.map +0 -1
  63. package/dist/Button/Button.test.js +0 -49
  64. package/dist/Button/Button.test.js.map +0 -1
  65. package/dist/Button/Button.types.js +0 -5
  66. package/dist/Button/Button.types.js.map +0 -1
  67. package/dist/Button/index.js +0 -2
  68. package/dist/Button/index.js.map +0 -1
  69. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +0 -67
  70. package/dist/ButtonWithDropdown/ButtonWithDropdown.js.map +0 -1
  71. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +0 -98
  72. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js.map +0 -1
  73. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +0 -85
  74. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js.map +0 -1
  75. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +0 -2
  76. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js.map +0 -1
  77. package/dist/ButtonWithDropdown/index.js +0 -2
  78. package/dist/ButtonWithDropdown/index.js.map +0 -1
  79. package/dist/ButtonWithPopover/ButtonWithPopover.js +0 -53
  80. package/dist/ButtonWithPopover/ButtonWithPopover.js.map +0 -1
  81. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +0 -75
  82. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js.map +0 -1
  83. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +0 -82
  84. package/dist/ButtonWithPopover/ButtonWithPopover.test.js.map +0 -1
  85. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +0 -2
  86. package/dist/ButtonWithPopover/ButtonWithPopover.types.js.map +0 -1
  87. package/dist/ButtonWithPopover/index.js +0 -2
  88. package/dist/ButtonWithPopover/index.js.map +0 -1
  89. package/dist/Checkbox/Checkbox.js +0 -26
  90. package/dist/Checkbox/Checkbox.js.map +0 -1
  91. package/dist/Checkbox/Checkbox.stories.js +0 -34
  92. package/dist/Checkbox/Checkbox.stories.js.map +0 -1
  93. package/dist/Checkbox/Checkbox.test.js +0 -94
  94. package/dist/Checkbox/Checkbox.test.js.map +0 -1
  95. package/dist/Checkbox/Checkbox.types.js +0 -2
  96. package/dist/Checkbox/Checkbox.types.js.map +0 -1
  97. package/dist/Checkbox/index.js +0 -2
  98. package/dist/Checkbox/index.js.map +0 -1
  99. package/dist/Icon/Icon.js +0 -55
  100. package/dist/Icon/Icon.js.map +0 -1
  101. package/dist/Icon/Icon.stories.js +0 -45
  102. package/dist/Icon/Icon.stories.js.map +0 -1
  103. package/dist/Icon/Icon.test.js +0 -55
  104. package/dist/Icon/Icon.test.js.map +0 -1
  105. package/dist/Icon/Icon.types.js +0 -16
  106. package/dist/Icon/Icon.types.js.map +0 -1
  107. package/dist/Icon/index.js +0 -2
  108. package/dist/Icon/index.js.map +0 -1
  109. package/dist/InputGroup/InputGroup.js +0 -26
  110. package/dist/InputGroup/InputGroup.js.map +0 -1
  111. package/dist/InputGroup/InputGroup.stories.js +0 -142
  112. package/dist/InputGroup/InputGroup.stories.js.map +0 -1
  113. package/dist/InputGroup/InputGroup.test.js +0 -43
  114. package/dist/InputGroup/InputGroup.test.js.map +0 -1
  115. package/dist/InputGroup/InputGroup.types.js +0 -2
  116. package/dist/InputGroup/InputGroup.types.js.map +0 -1
  117. package/dist/InputGroup/index.js +0 -2
  118. package/dist/InputGroup/index.js.map +0 -1
  119. package/dist/Modal/Modal.js +0 -100
  120. package/dist/Modal/Modal.js.map +0 -1
  121. package/dist/Modal/Modal.stories.js +0 -127
  122. package/dist/Modal/Modal.stories.js.map +0 -1
  123. package/dist/Modal/Modal.test.js +0 -108
  124. package/dist/Modal/Modal.test.js.map +0 -1
  125. package/dist/Modal/Modal.types.js +0 -2
  126. package/dist/Modal/Modal.types.js.map +0 -1
  127. package/dist/Modal/index.js +0 -2
  128. package/dist/Modal/index.js.map +0 -1
  129. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +0 -48
  130. package/dist/SeeqActionDropdown/SeeqActionDropdown.js.map +0 -1
  131. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +0 -80
  132. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js.map +0 -1
  133. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +0 -73
  134. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js.map +0 -1
  135. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +0 -2
  136. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js.map +0 -1
  137. package/dist/SeeqActionDropdown/index.js +0 -2
  138. package/dist/SeeqActionDropdown/index.js.map +0 -1
  139. package/dist/SeeqActionDropdown/variants.js +0 -23
  140. package/dist/SeeqActionDropdown/variants.js.map +0 -1
  141. package/dist/Select/Select.js +0 -174
  142. package/dist/Select/Select.js.map +0 -1
  143. package/dist/Select/Select.stories.js +0 -80
  144. package/dist/Select/Select.stories.js.map +0 -1
  145. package/dist/Select/Select.test.js +0 -182
  146. package/dist/Select/Select.test.js.map +0 -1
  147. package/dist/Select/Select.types.js +0 -2
  148. package/dist/Select/Select.types.js.map +0 -1
  149. package/dist/Select/index.js +0 -3
  150. package/dist/Select/index.js.map +0 -1
  151. package/dist/Tabs/Tabs.js +0 -22
  152. package/dist/Tabs/Tabs.js.map +0 -1
  153. package/dist/Tabs/Tabs.stories.js +0 -91
  154. package/dist/Tabs/Tabs.stories.js.map +0 -1
  155. package/dist/Tabs/Tabs.test.js +0 -91
  156. package/dist/Tabs/Tabs.test.js.map +0 -1
  157. package/dist/Tabs/Tabs.types.js +0 -2
  158. package/dist/Tabs/Tabs.types.js.map +0 -1
  159. package/dist/Tabs/index.js +0 -2
  160. package/dist/Tabs/index.js.map +0 -1
  161. package/dist/TextArea/TextArea.js +0 -25
  162. package/dist/TextArea/TextArea.js.map +0 -1
  163. package/dist/TextArea/TextArea.stories.js +0 -46
  164. package/dist/TextArea/TextArea.stories.js.map +0 -1
  165. package/dist/TextArea/TextArea.test.js +0 -68
  166. package/dist/TextArea/TextArea.test.js.map +0 -1
  167. package/dist/TextArea/TextArea.types.js +0 -2
  168. package/dist/TextArea/TextArea.types.js.map +0 -1
  169. package/dist/TextArea/index.js +0 -2
  170. package/dist/TextArea/index.js.map +0 -1
  171. package/dist/TextField/TextField.js +0 -79
  172. package/dist/TextField/TextField.js.map +0 -1
  173. package/dist/TextField/TextField.stories.js +0 -70
  174. package/dist/TextField/TextField.stories.js.map +0 -1
  175. package/dist/TextField/TextField.test.js +0 -39
  176. package/dist/TextField/TextField.test.js.map +0 -1
  177. package/dist/TextField/TextField.types.js +0 -2
  178. package/dist/TextField/TextField.types.js.map +0 -1
  179. package/dist/TextField/index.js +0 -2
  180. package/dist/TextField/index.js.map +0 -1
  181. package/dist/ToolbarButton/ToolbarButton.js +0 -75
  182. package/dist/ToolbarButton/ToolbarButton.js.map +0 -1
  183. package/dist/ToolbarButton/ToolbarButton.stories.js +0 -94
  184. package/dist/ToolbarButton/ToolbarButton.stories.js.map +0 -1
  185. package/dist/ToolbarButton/ToolbarButton.test.js +0 -93
  186. package/dist/ToolbarButton/ToolbarButton.test.js.map +0 -1
  187. package/dist/ToolbarButton/ToolbarButton.types.js +0 -2
  188. package/dist/ToolbarButton/ToolbarButton.types.js.map +0 -1
  189. package/dist/ToolbarButton/index.js +0 -2
  190. package/dist/ToolbarButton/index.js.map +0 -1
  191. package/dist/Tooltip/QTip.stories.js +0 -45
  192. package/dist/Tooltip/QTip.stories.js.map +0 -1
  193. package/dist/Tooltip/QTip.types.js +0 -2
  194. package/dist/Tooltip/QTip.types.js.map +0 -1
  195. package/dist/Tooltip/QTipPerformance.stories.js +0 -30
  196. package/dist/Tooltip/QTipPerformance.stories.js.map +0 -1
  197. package/dist/Tooltip/Qtip.js +0 -155
  198. package/dist/Tooltip/Qtip.js.map +0 -1
  199. package/dist/Tooltip/Tooltip.js +0 -36
  200. package/dist/Tooltip/Tooltip.js.map +0 -1
  201. package/dist/Tooltip/Tooltip.stories.js +0 -32
  202. package/dist/Tooltip/Tooltip.stories.js.map +0 -1
  203. package/dist/Tooltip/Tooltip.types.js +0 -3
  204. package/dist/Tooltip/Tooltip.types.js.map +0 -1
  205. package/dist/Tooltip/TooltipPerformance.stories.js +0 -30
  206. package/dist/Tooltip/TooltipPerformance.stories.js.map +0 -1
  207. package/dist/Tooltip/index.js +0 -3
  208. package/dist/Tooltip/index.js.map +0 -1
  209. package/dist/Tooltip/qTip.utilities.js +0 -11
  210. package/dist/Tooltip/qTip.utilities.js.map +0 -1
  211. package/dist/types.js +0 -2
  212. package/dist/types.js.map +0 -1
  213. package/dist/utils/browserId.js +0 -29
  214. package/dist/utils/browserId.js.map +0 -1
  215. package/dist/utils/svg.js +0 -20
  216. package/dist/utils/svg.js.map +0 -1
  217. package/dist/utils/validateStyleDimension.js +0 -14
  218. package/dist/utils/validateStyleDimension.js.map +0 -1
  219. package/dist/utils/validateStyleDimension.test.js +0 -20
  220. package/dist/utils/validateStyleDimension.test.js.map +0 -1
package/dist/index.esm.js CHANGED
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { useCallback, createContext, useMemo, createElement, useContext, forwardRef, Children, isValidElement, cloneElement, Fragment, useEffect, useRef, useState, useLayoutEffect, useReducer, Component } from 'react';
3
3
  import * as ReactDOM from 'react-dom';
4
4
  import ReactDOM__default, { flushSync, createPortal } from 'react-dom';
5
+ import { jsx as jsx$1, Fragment as Fragment$1 } from 'react/jsx-runtime';
5
6
 
6
7
  /**
7
8
  * @exports the browser id (i.e., 'IE 11' 'Chrome 90')
@@ -1064,14 +1065,8 @@ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
1064
1065
  */
1065
1066
 
1066
1067
  const sides = ['top', 'right', 'bottom', 'left'];
1067
- const min = Math.min;
1068
- const max = Math.max;
1069
- const round = Math.round;
1070
- const floor = Math.floor;
1071
- const createCoords = v => ({
1072
- x: v,
1073
- y: v
1074
- });
1068
+ const min$1 = Math.min;
1069
+ const max$1 = Math.max;
1075
1070
  const oppositeSideMap = {
1076
1071
  left: 'right',
1077
1072
  right: 'left',
@@ -1083,7 +1078,7 @@ const oppositeAlignmentMap = {
1083
1078
  end: 'start'
1084
1079
  };
1085
1080
  function clamp(start, value, end) {
1086
- return max(start, min(value, end));
1081
+ return max$1(start, min$1(value, end));
1087
1082
  }
1088
1083
  function evaluate(value, param) {
1089
1084
  return typeof value === 'function' ? value(param) : value;
@@ -1400,7 +1395,7 @@ async function detectOverflow(state, options) {
1400
1395
  * appears centered to the reference element.
1401
1396
  * @see https://floating-ui.com/docs/arrow
1402
1397
  */
1403
- const arrow$2 = options => ({
1398
+ const arrow$1 = options => ({
1404
1399
  name: 'arrow',
1405
1400
  options,
1406
1401
  async fn(state) {
@@ -1447,22 +1442,22 @@ const arrow$2 = options => ({
1447
1442
  // If the padding is large enough that it causes the arrow to no longer be
1448
1443
  // centered, modify the padding so that it is centered.
1449
1444
  const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1450
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1451
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1445
+ const minPadding = min$1(paddingObject[minProp], largestPossiblePadding);
1446
+ const maxPadding = min$1(paddingObject[maxProp], largestPossiblePadding);
1452
1447
 
1453
1448
  // Make sure the arrow doesn't overflow the floating element if the center
1454
1449
  // point is outside the floating element's bounds.
1455
- const min$1 = minPadding;
1450
+ const min$1$1 = minPadding;
1456
1451
  const max = clientSize - arrowDimensions[length] - maxPadding;
1457
1452
  const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1458
- const offset = clamp(min$1, center, max);
1453
+ const offset = clamp(min$1$1, center, max);
1459
1454
 
1460
1455
  // If the reference is small enough that the arrow's padding causes it to
1461
1456
  // to point to nothing for an aligned placement, adjust the offset of the
1462
1457
  // floating element itself. To ensure `shift()` continues to take action,
1463
1458
  // a single reset is performed when this is true.
1464
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1465
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1459
+ const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1460
+ const alignmentOffset = shouldAddOffset ? center < min$1$1 ? center - min$1$1 : center - max : 0;
1466
1461
  return {
1467
1462
  [axis]: coords[axis] + alignmentOffset,
1468
1463
  data: {
@@ -1483,7 +1478,7 @@ const arrow$2 = options => ({
1483
1478
  * clipping boundary. Alternative to `autoPlacement`.
1484
1479
  * @see https://floating-ui.com/docs/flip
1485
1480
  */
1486
- const flip$1 = function (options) {
1481
+ const flip = function (options) {
1487
1482
  if (options === void 0) {
1488
1483
  options = {};
1489
1484
  }
@@ -1608,7 +1603,7 @@ function isAnySideFullyClipped(overflow) {
1608
1603
  * when it is not in the same clipping context as the reference element.
1609
1604
  * @see https://floating-ui.com/docs/hide
1610
1605
  */
1611
- const hide$1 = function (options) {
1606
+ const hide = function (options) {
1612
1607
  if (options === void 0) {
1613
1608
  options = {};
1614
1609
  }
@@ -1751,7 +1746,7 @@ const offset = function (options) {
1751
1746
  * keep it in view when it will overflow the clipping boundary.
1752
1747
  * @see https://floating-ui.com/docs/shift
1753
1748
  */
1754
- const shift$1 = function (options) {
1749
+ const shift = function (options) {
1755
1750
  if (options === void 0) {
1756
1751
  options = {};
1757
1752
  }
@@ -1822,7 +1817,7 @@ const shift$1 = function (options) {
1822
1817
  /**
1823
1818
  * Built-in `limiter` that will stop `shift()` at a certain point.
1824
1819
  */
1825
- const limitShift$1 = function (options) {
1820
+ const limitShift = function (options) {
1826
1821
  if (options === void 0) {
1827
1822
  options = {};
1828
1823
  }
@@ -1894,7 +1889,7 @@ const limitShift$1 = function (options) {
1894
1889
  * width of the reference element.
1895
1890
  * @see https://floating-ui.com/docs/size
1896
1891
  */
1897
- const size$1 = function (options) {
1892
+ const size = function (options) {
1898
1893
  if (options === void 0) {
1899
1894
  options = {};
1900
1895
  }
@@ -1936,20 +1931,20 @@ const size$1 = function (options) {
1936
1931
  let availableWidth = overflowAvailableWidth;
1937
1932
  if (isYAxis) {
1938
1933
  const maximumClippingWidth = width - overflow.left - overflow.right;
1939
- availableWidth = alignment || noShift ? min(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
1934
+ availableWidth = alignment || noShift ? min$1(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
1940
1935
  } else {
1941
1936
  const maximumClippingHeight = height - overflow.top - overflow.bottom;
1942
- availableHeight = alignment || noShift ? min(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
1937
+ availableHeight = alignment || noShift ? min$1(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
1943
1938
  }
1944
1939
  if (noShift && !alignment) {
1945
- const xMin = max(overflow.left, 0);
1946
- const xMax = max(overflow.right, 0);
1947
- const yMin = max(overflow.top, 0);
1948
- const yMax = max(overflow.bottom, 0);
1940
+ const xMin = max$1(overflow.left, 0);
1941
+ const xMax = max$1(overflow.right, 0);
1942
+ const yMin = max$1(overflow.top, 0);
1943
+ const yMax = max$1(overflow.bottom, 0);
1949
1944
  if (isYAxis) {
1950
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
1945
+ availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right));
1951
1946
  } else {
1952
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
1947
+ availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max$1(overflow.top, overflow.bottom));
1953
1948
  }
1954
1949
  }
1955
1950
  await apply({
@@ -1970,6 +1965,15 @@ const size$1 = function (options) {
1970
1965
  };
1971
1966
  };
1972
1967
 
1968
+ const min = Math.min;
1969
+ const max = Math.max;
1970
+ const round = Math.round;
1971
+ const floor = Math.floor;
1972
+ const createCoords = v => ({
1973
+ x: v,
1974
+ y: v
1975
+ });
1976
+
1973
1977
  function getNodeName(node) {
1974
1978
  if (isNode(node)) {
1975
1979
  return (node.nodeName || '').toLowerCase();
@@ -1981,7 +1985,7 @@ function getNodeName(node) {
1981
1985
  }
1982
1986
  function getWindow(node) {
1983
1987
  var _node$ownerDocument;
1984
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1988
+ return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
1985
1989
  }
1986
1990
  function getDocumentElement(node) {
1987
1991
  var _ref;
@@ -2365,7 +2369,7 @@ function getClippingElementAncestors(element, cache) {
2365
2369
  if (cachedResult) {
2366
2370
  return cachedResult;
2367
2371
  }
2368
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
2372
+ let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
2369
2373
  let currentContainingBlockComputedStyle = null;
2370
2374
  const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
2371
2375
  let currentNode = elementIsFixed ? getParentNode(element) : element;
@@ -2420,14 +2424,7 @@ function getClippingRect(_ref) {
2420
2424
  }
2421
2425
 
2422
2426
  function getDimensions(element) {
2423
- const {
2424
- width,
2425
- height
2426
- } = getCssDimensions(element);
2427
- return {
2428
- width,
2429
- height
2430
- };
2427
+ return getCssDimensions(element);
2431
2428
  }
2432
2429
 
2433
2430
  function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
@@ -2673,51 +2670,10 @@ function autoUpdate(reference, floating, update, options) {
2673
2670
  };
2674
2671
  }
2675
2672
 
2676
- /**
2677
- * Optimizes the visibility of the floating element by shifting it in order to
2678
- * keep it in view when it will overflow the clipping boundary.
2679
- * @see https://floating-ui.com/docs/shift
2680
- */
2681
- const shift = shift$1;
2682
-
2683
- /**
2684
- * Optimizes the visibility of the floating element by flipping the `placement`
2685
- * in order to keep it in view when the preferred placement(s) will overflow the
2686
- * clipping boundary. Alternative to `autoPlacement`.
2687
- * @see https://floating-ui.com/docs/flip
2688
- */
2689
- const flip = flip$1;
2690
-
2691
- /**
2692
- * Provides data that allows you to change the size of the floating element —
2693
- * for instance, prevent it from overflowing the clipping boundary or match the
2694
- * width of the reference element.
2695
- * @see https://floating-ui.com/docs/size
2696
- */
2697
- const size = size$1;
2698
-
2699
- /**
2700
- * Provides data to hide the floating element in applicable situations, such as
2701
- * when it is not in the same clipping context as the reference element.
2702
- * @see https://floating-ui.com/docs/hide
2703
- */
2704
- const hide = hide$1;
2705
-
2706
- /**
2707
- * Provides data to position an inner element of the floating element so that it
2708
- * appears centered to the reference element.
2709
- * @see https://floating-ui.com/docs/arrow
2710
- */
2711
- const arrow$1 = arrow$2;
2712
-
2713
- /**
2714
- * Built-in `limiter` that will stop `shift()` at a certain point.
2715
- */
2716
- const limitShift = limitShift$1;
2717
-
2718
2673
  /**
2719
2674
  * Computes the `x` and `y` coordinates that will place the floating element
2720
- * next to a given reference element.
2675
+ * next to a reference element when it is given a certain CSS positioning
2676
+ * strategy.
2721
2677
  */
2722
2678
  const computePosition = (reference, floating, options) => {
2723
2679
  // This caches the expensive `getClippingElementAncestors` function so that
@@ -4667,8 +4623,8 @@ const setValidInputDimension = (width, height) => {
4667
4623
  return inputStyle;
4668
4624
  };
4669
4625
 
4670
- const errorClasses$3 = 'tw-border-sq-danger-color';
4671
- const borderColorClasses$3 = [
4626
+ const errorClasses$4 = 'tw-border-sq-danger-color';
4627
+ const borderColorClasses$4 = [
4672
4628
  'tw-border-sq-disabled-gray',
4673
4629
  'dark:tw-border-sq-dark-disabled-gray',
4674
4630
  'dark:focus:tw-border-sq-color-dark-dark',
@@ -4680,8 +4636,8 @@ const baseClasses$5 = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-
4680
4636
  ' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
4681
4637
  ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
4682
4638
  ' dark:tw-placeholder-sq-dark-text-lighter specTextField';
4683
- const darkTheme$2 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
4684
- const lightTheme$2 = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
4639
+ const darkTheme$3 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
4640
+ const lightTheme$3 = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
4685
4641
  const sizeClasses = {
4686
4642
  sm: 'tw-text-sm',
4687
4643
  lg: 'tw-text-xl',
@@ -4726,7 +4682,7 @@ const TextField = React__default.forwardRef((props, ref) => {
4726
4682
  else if (inputGroup === 'right') {
4727
4683
  borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
4728
4684
  }
4729
- const appliedClasses = `${baseClasses$5} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$2} ${darkTheme$2} ${borderRadius} ${showError ? errorClasses$3 : borderColorClasses$3} `;
4685
+ const appliedClasses = `${baseClasses$5} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$3} ${darkTheme$3} ${borderRadius} ${showError ? errorClasses$4 : borderColorClasses$4} `;
4730
4686
  const inputProp = setValidInputDimension(inputWidth, inputHeight)
4731
4687
  ? {
4732
4688
  style: setValidInputDimension(inputWidth, inputHeight),
@@ -4768,11 +4724,11 @@ const Checkbox = (props) => {
4768
4724
  const baseClasses$3 = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm tw-w-full' +
4769
4725
  ' disabled:tw-pointer-events-none disabled:tw-bg-sq-light-gray disabled:dark:tw-bg-sq-dark-disabled-gray' +
4770
4726
  ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-text-sm';
4771
- const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' +
4727
+ const darkTheme$2 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' +
4772
4728
  'dark:tw-placeholder-sq-dark-text-lighter disabled:dark:tw-text-sq-dark-text-lighter';
4773
- const lightTheme$1 = 'tw-text-sq-text-color tw-placeholder-gray-400 disabled:tw-text-sq-darkish-gray';
4774
- const errorClasses$2 = 'tw-border-sq-danger-color';
4775
- const borderColorClasses$2 = [
4729
+ const lightTheme$2 = 'tw-text-sq-text-color tw-placeholder-gray-400 disabled:tw-text-sq-darkish-gray';
4730
+ const errorClasses$3 = 'tw-border-sq-danger-color';
4731
+ const borderColorClasses$3 = [
4776
4732
  'tw-border-sq-disabled-gray',
4777
4733
  'dark:tw-border-sq-dark-disabled-gray',
4778
4734
  'dark:focus:tw-border-sq-color-dark-dark',
@@ -4784,7 +4740,7 @@ const borderColorClasses$2 = [
4784
4740
  * TextArea.
4785
4741
  */
4786
4742
  const TextArea = ({ readonly = false, disabled = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, id, name, rows = 3, cols = undefined, value, placeholder, showError, extraClassNames, testId, autoFocus = false, }) => {
4787
- const appliedClasses = `${baseClasses$3} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${showError ? errorClasses$2 : borderColorClasses$2}`;
4743
+ const appliedClasses = `${baseClasses$3} ${extraClassNames} ${lightTheme$2} ${darkTheme$2} ${showError ? errorClasses$3 : borderColorClasses$3}`;
4788
4744
  return (React__default.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: disabled, readOnly: readonly, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autoFocus }));
4789
4745
  };
4790
4746
 
@@ -4821,1648 +4777,1335 @@ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP
4821
4777
  tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
4822
4778
  };
4823
4779
 
4824
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4825
-
4826
- var purifyExports = {};
4827
- var purify = {
4828
- get exports(){ return purifyExports; },
4829
- set exports(v){ purifyExports = v; },
4830
- };
4831
-
4832
- /*! @license DOMPurify 3.0.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.5/LICENSE */
4833
-
4834
- (function (module, exports) {
4835
- (function (global, factory) {
4836
- module.exports = factory() ;
4837
- })(commonjsGlobal, (function () {
4838
- const {
4839
- entries,
4840
- setPrototypeOf,
4841
- isFrozen,
4842
- getPrototypeOf,
4843
- getOwnPropertyDescriptor
4844
- } = Object;
4845
- let {
4846
- freeze,
4847
- seal,
4848
- create
4849
- } = Object; // eslint-disable-line import/no-mutable-exports
4850
-
4851
- let {
4852
- apply,
4853
- construct
4854
- } = typeof Reflect !== 'undefined' && Reflect;
4855
-
4856
- if (!apply) {
4857
- apply = function apply(fun, thisValue, args) {
4858
- return fun.apply(thisValue, args);
4859
- };
4860
- }
4861
-
4862
- if (!freeze) {
4863
- freeze = function freeze(x) {
4864
- return x;
4865
- };
4866
- }
4867
-
4868
- if (!seal) {
4869
- seal = function seal(x) {
4870
- return x;
4871
- };
4872
- }
4873
-
4874
- if (!construct) {
4875
- construct = function construct(Func, args) {
4876
- return new Func(...args);
4877
- };
4878
- }
4879
-
4880
- const arrayForEach = unapply(Array.prototype.forEach);
4881
- const arrayPop = unapply(Array.prototype.pop);
4882
- const arrayPush = unapply(Array.prototype.push);
4883
- const stringToLowerCase = unapply(String.prototype.toLowerCase);
4884
- const stringToString = unapply(String.prototype.toString);
4885
- const stringMatch = unapply(String.prototype.match);
4886
- const stringReplace = unapply(String.prototype.replace);
4887
- const stringIndexOf = unapply(String.prototype.indexOf);
4888
- const stringTrim = unapply(String.prototype.trim);
4889
- const regExpTest = unapply(RegExp.prototype.test);
4890
- const typeErrorCreate = unconstruct(TypeError);
4891
- function unapply(func) {
4892
- return function (thisArg) {
4893
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
4894
- args[_key - 1] = arguments[_key];
4895
- }
4896
-
4897
- return apply(func, thisArg, args);
4898
- };
4899
- }
4900
- function unconstruct(func) {
4901
- return function () {
4902
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
4903
- args[_key2] = arguments[_key2];
4904
- }
4905
-
4906
- return construct(func, args);
4907
- };
4908
- }
4909
- /* Add properties to a lookup table */
4910
-
4911
- function addToSet(set, array, transformCaseFunc) {
4912
- var _transformCaseFunc;
4913
-
4914
- transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
4915
-
4916
- if (setPrototypeOf) {
4917
- // Make 'in' and truthy checks like Boolean(set.constructor)
4918
- // independent of any properties defined on Object.prototype.
4919
- // Prevent prototype setters from intercepting set as a this value.
4920
- setPrototypeOf(set, null);
4921
- }
4922
-
4923
- let l = array.length;
4924
-
4925
- while (l--) {
4926
- let element = array[l];
4927
-
4928
- if (typeof element === 'string') {
4929
- const lcElement = transformCaseFunc(element);
4930
-
4931
- if (lcElement !== element) {
4932
- // Config presets (e.g. tags.js, attrs.js) are immutable.
4933
- if (!isFrozen(array)) {
4934
- array[l] = lcElement;
4935
- }
4936
-
4937
- element = lcElement;
4938
- }
4939
- }
4940
-
4941
- set[element] = true;
4942
- }
4943
-
4944
- return set;
4945
- }
4946
- /* Shallow clone an object */
4947
-
4948
- function clone(object) {
4949
- const newObject = create(null);
4950
-
4951
- for (const [property, value] of entries(object)) {
4952
- newObject[property] = value;
4953
- }
4954
-
4955
- return newObject;
4956
- }
4957
- /* This method automatically checks if the prop is function
4958
- * or getter and behaves accordingly. */
4959
-
4960
- function lookupGetter(object, prop) {
4961
- while (object !== null) {
4962
- const desc = getOwnPropertyDescriptor(object, prop);
4963
-
4964
- if (desc) {
4965
- if (desc.get) {
4966
- return unapply(desc.get);
4967
- }
4968
-
4969
- if (typeof desc.value === 'function') {
4970
- return unapply(desc.value);
4971
- }
4972
- }
4973
-
4974
- object = getPrototypeOf(object);
4975
- }
4976
-
4977
- function fallbackValue(element) {
4978
- console.warn('fallback value for', element);
4979
- return null;
4980
- }
4981
-
4982
- return fallbackValue;
4983
- }
4984
-
4985
- const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); // SVG
4986
-
4987
- const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
4988
- const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default.
4989
- // We still need to know them so that we can do namespace
4990
- // checks properly in case one wants to add them to
4991
- // allow-list.
4992
-
4993
- const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
4994
- const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements,
4995
- // even those that we disallow by default.
4996
-
4997
- const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
4998
- const text = freeze(['#text']);
4999
-
5000
- const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
5001
- const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
5002
- const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
5003
- const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
5004
-
5005
- const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
5006
-
5007
- const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
5008
- const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
5009
- const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
5010
-
5011
- const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
5012
-
5013
- const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
5014
- );
5015
- const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
5016
- const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
5017
- );
5018
- const DOCTYPE_NAME = seal(/^html$/i);
5019
-
5020
- var EXPRESSIONS = /*#__PURE__*/Object.freeze({
5021
- __proto__: null,
5022
- MUSTACHE_EXPR: MUSTACHE_EXPR,
5023
- ERB_EXPR: ERB_EXPR,
5024
- TMPLIT_EXPR: TMPLIT_EXPR,
5025
- DATA_ATTR: DATA_ATTR,
5026
- ARIA_ATTR: ARIA_ATTR,
5027
- IS_ALLOWED_URI: IS_ALLOWED_URI,
5028
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
5029
- ATTR_WHITESPACE: ATTR_WHITESPACE,
5030
- DOCTYPE_NAME: DOCTYPE_NAME
5031
- });
5032
-
5033
- const getGlobal = () => typeof window === 'undefined' ? null : window;
5034
- /**
5035
- * Creates a no-op policy for internal use only.
5036
- * Don't export this function outside this module!
5037
- * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
5038
- * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
5039
- * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
5040
- * are not supported or creating the policy failed).
5041
- */
5042
-
5043
-
5044
- const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
5045
- if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
5046
- return null;
5047
- } // Allow the callers to control the unique policy name
5048
- // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
5049
- // Policy creation with duplicate names throws in Trusted Types.
5050
-
5051
-
5052
- let suffix = null;
5053
- const ATTR_NAME = 'data-tt-policy-suffix';
5054
-
5055
- if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
5056
- suffix = purifyHostElement.getAttribute(ATTR_NAME);
5057
- }
5058
-
5059
- const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
5060
-
5061
- try {
5062
- return trustedTypes.createPolicy(policyName, {
5063
- createHTML(html) {
5064
- return html;
5065
- },
5066
-
5067
- createScriptURL(scriptUrl) {
5068
- return scriptUrl;
5069
- }
5070
-
5071
- });
5072
- } catch (_) {
5073
- // Policy creation failed (most likely another DOMPurify script has
5074
- // already run). Skip creating the policy, as this will only cause errors
5075
- // if TT are enforced.
5076
- console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
5077
- return null;
5078
- }
5079
- };
5080
-
5081
- function createDOMPurify() {
5082
- let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
5083
-
5084
- const DOMPurify = root => createDOMPurify(root);
5085
- /**
5086
- * Version label, exposed for easier checks
5087
- * if DOMPurify is up to date or not
5088
- */
5089
-
5090
-
5091
- DOMPurify.version = '3.0.5';
5092
- /**
5093
- * Array of elements that DOMPurify removed during sanitation.
5094
- * Empty if nothing was removed.
5095
- */
5096
-
5097
- DOMPurify.removed = [];
5098
-
5099
- if (!window || !window.document || window.document.nodeType !== 9) {
5100
- // Not running in a browser, provide a factory function
5101
- // so that you can pass your own Window
5102
- DOMPurify.isSupported = false;
5103
- return DOMPurify;
5104
- }
5105
-
5106
- const originalDocument = window.document;
5107
- const currentScript = originalDocument.currentScript;
5108
- let {
5109
- document
5110
- } = window;
5111
- const {
5112
- DocumentFragment,
5113
- HTMLTemplateElement,
5114
- Node,
5115
- Element,
5116
- NodeFilter,
5117
- NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
5118
- HTMLFormElement,
5119
- DOMParser,
5120
- trustedTypes
5121
- } = window;
5122
- const ElementPrototype = Element.prototype;
5123
- const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
5124
- const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
5125
- const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
5126
- const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
5127
- // new document created via createHTMLDocument. As per the spec
5128
- // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
5129
- // a new empty registry is used when creating a template contents owner
5130
- // document, so we use that as our parent document to ensure nothing
5131
- // is inherited.
5132
-
5133
- if (typeof HTMLTemplateElement === 'function') {
5134
- const template = document.createElement('template');
5135
-
5136
- if (template.content && template.content.ownerDocument) {
5137
- document = template.content.ownerDocument;
5138
- }
5139
- }
5140
-
5141
- let trustedTypesPolicy;
5142
- let emptyHTML = '';
5143
- const {
5144
- implementation,
5145
- createNodeIterator,
5146
- createDocumentFragment,
5147
- getElementsByTagName
5148
- } = document;
5149
- const {
5150
- importNode
5151
- } = originalDocument;
5152
- let hooks = {};
5153
- /**
5154
- * Expose whether this browser supports running the full DOMPurify.
5155
- */
5156
-
5157
- DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
5158
- const {
5159
- MUSTACHE_EXPR,
5160
- ERB_EXPR,
5161
- TMPLIT_EXPR,
5162
- DATA_ATTR,
5163
- ARIA_ATTR,
5164
- IS_SCRIPT_OR_DATA,
5165
- ATTR_WHITESPACE
5166
- } = EXPRESSIONS;
5167
- let {
5168
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
5169
- } = EXPRESSIONS;
5170
- /**
5171
- * We consider the elements and attributes below to be safe. Ideally
5172
- * don't add any new ones but feel free to remove unwanted ones.
5173
- */
5174
-
5175
- /* allowed element names */
5176
-
5177
- let ALLOWED_TAGS = null;
5178
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
5179
- /* Allowed attribute names */
5180
-
5181
- let ALLOWED_ATTR = null;
5182
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
5183
- /*
5184
- * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
5185
- * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
5186
- * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
5187
- * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
5188
- */
5189
-
5190
- let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
5191
- tagNameCheck: {
5192
- writable: true,
5193
- configurable: false,
5194
- enumerable: true,
5195
- value: null
5196
- },
5197
- attributeNameCheck: {
5198
- writable: true,
5199
- configurable: false,
5200
- enumerable: true,
5201
- value: null
5202
- },
5203
- allowCustomizedBuiltInElements: {
5204
- writable: true,
5205
- configurable: false,
5206
- enumerable: true,
5207
- value: false
5208
- }
5209
- }));
5210
- /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
5211
-
5212
- let FORBID_TAGS = null;
5213
- /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
5214
-
5215
- let FORBID_ATTR = null;
5216
- /* Decide if ARIA attributes are okay */
5217
-
5218
- let ALLOW_ARIA_ATTR = true;
5219
- /* Decide if custom data attributes are okay */
5220
-
5221
- let ALLOW_DATA_ATTR = true;
5222
- /* Decide if unknown protocols are okay */
5223
-
5224
- let ALLOW_UNKNOWN_PROTOCOLS = false;
5225
- /* Decide if self-closing tags in attributes are allowed.
5226
- * Usually removed due to a mXSS issue in jQuery 3.0 */
5227
-
5228
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
5229
- /* Output should be safe for common template engines.
5230
- * This means, DOMPurify removes data attributes, mustaches and ERB
5231
- */
5232
-
5233
- let SAFE_FOR_TEMPLATES = false;
5234
- /* Decide if document with <html>... should be returned */
5235
-
5236
- let WHOLE_DOCUMENT = false;
5237
- /* Track whether config is already set on this instance of DOMPurify. */
5238
-
5239
- let SET_CONFIG = false;
5240
- /* Decide if all elements (e.g. style, script) must be children of
5241
- * document.body. By default, browsers might move them to document.head */
5242
-
5243
- let FORCE_BODY = false;
5244
- /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
5245
- * string (or a TrustedHTML object if Trusted Types are supported).
5246
- * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
5247
- */
5248
-
5249
- let RETURN_DOM = false;
5250
- /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
5251
- * string (or a TrustedHTML object if Trusted Types are supported) */
5252
-
5253
- let RETURN_DOM_FRAGMENT = false;
5254
- /* Try to return a Trusted Type object instead of a string, return a string in
5255
- * case Trusted Types are not supported */
5256
-
5257
- let RETURN_TRUSTED_TYPE = false;
5258
- /* Output should be free from DOM clobbering attacks?
5259
- * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
5260
- */
5261
-
5262
- let SANITIZE_DOM = true;
5263
- /* Achieve full DOM Clobbering protection by isolating the namespace of named
5264
- * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
5265
- *
5266
- * HTML/DOM spec rules that enable DOM Clobbering:
5267
- * - Named Access on Window (§7.3.3)
5268
- * - DOM Tree Accessors (§3.1.5)
5269
- * - Form Element Parent-Child Relations (§4.10.3)
5270
- * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
5271
- * - HTMLCollection (§4.2.10.2)
5272
- *
5273
- * Namespace isolation is implemented by prefixing `id` and `name` attributes
5274
- * with a constant string, i.e., `user-content-`
5275
- */
5276
-
5277
- let SANITIZE_NAMED_PROPS = false;
5278
- const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
5279
- /* Keep element content when removing element? */
5280
-
5281
- let KEEP_CONTENT = true;
5282
- /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
5283
- * of importing it into a new Document and returning a sanitized copy */
5284
-
5285
- let IN_PLACE = false;
5286
- /* Allow usage of profiles like html, svg and mathMl */
5287
-
5288
- let USE_PROFILES = {};
5289
- /* Tags to ignore content of when KEEP_CONTENT is true */
5290
-
5291
- let FORBID_CONTENTS = null;
5292
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
5293
- /* Tags that are safe for data: URIs */
5294
-
5295
- let DATA_URI_TAGS = null;
5296
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
5297
- /* Attributes safe for values like "javascript:" */
5298
-
5299
- let URI_SAFE_ATTRIBUTES = null;
5300
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
5301
- const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
5302
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
5303
- const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
5304
- /* Document namespace */
5305
-
5306
- let NAMESPACE = HTML_NAMESPACE;
5307
- let IS_EMPTY_INPUT = false;
5308
- /* Allowed XHTML+XML namespaces */
5309
-
5310
- let ALLOWED_NAMESPACES = null;
5311
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
5312
- /* Parsing of strict XHTML documents */
5313
-
5314
- let PARSER_MEDIA_TYPE;
5315
- const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
5316
- const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
5317
- let transformCaseFunc;
5318
- /* Keep a reference to config to pass to hooks */
5319
-
5320
- let CONFIG = null;
5321
- /* Ideally, do not touch anything below this line */
5322
-
5323
- /* ______________________________________________ */
5324
-
5325
- const formElement = document.createElement('form');
5326
-
5327
- const isRegexOrFunction = function isRegexOrFunction(testValue) {
5328
- return testValue instanceof RegExp || testValue instanceof Function;
5329
- };
5330
- /**
5331
- * _parseConfig
5332
- *
5333
- * @param {Object} cfg optional config literal
5334
- */
5335
- // eslint-disable-next-line complexity
5336
-
5337
-
5338
- const _parseConfig = function _parseConfig(cfg) {
5339
- if (CONFIG && CONFIG === cfg) {
5340
- return;
5341
- }
5342
- /* Shield configuration object from tampering */
5343
-
5344
-
5345
- if (!cfg || typeof cfg !== 'object') {
5346
- cfg = {};
5347
- }
5348
- /* Shield configuration object from prototype pollution */
5349
-
5350
-
5351
- cfg = clone(cfg);
5352
- PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
5353
- SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
5354
-
5355
- transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
5356
- /* Set configuration parameters */
5357
-
5358
- ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
5359
- ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
5360
- ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
5361
- URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
5362
- cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
5363
- transformCaseFunc // eslint-disable-line indent
5364
- ) // eslint-disable-line indent
5365
- : DEFAULT_URI_SAFE_ATTRIBUTES;
5366
- DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
5367
- cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
5368
- transformCaseFunc // eslint-disable-line indent
5369
- ) // eslint-disable-line indent
5370
- : DEFAULT_DATA_URI_TAGS;
5371
- FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
5372
- FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
5373
- FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
5374
- USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
5375
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
5376
-
5377
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
5378
-
5379
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
5380
-
5381
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
5382
-
5383
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
5384
-
5385
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
5386
-
5387
- RETURN_DOM = cfg.RETURN_DOM || false; // Default false
5388
-
5389
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
5390
-
5391
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
5392
-
5393
- FORCE_BODY = cfg.FORCE_BODY || false; // Default false
5394
-
5395
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
5396
-
5397
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
5398
-
5399
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
5400
-
5401
- IN_PLACE = cfg.IN_PLACE || false; // Default false
5402
-
5403
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
5404
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
5405
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
5406
-
5407
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
5408
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
5409
- }
5410
-
5411
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
5412
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
5413
- }
5414
-
5415
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
5416
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
5417
- }
5418
-
5419
- if (SAFE_FOR_TEMPLATES) {
5420
- ALLOW_DATA_ATTR = false;
5421
- }
5422
-
5423
- if (RETURN_DOM_FRAGMENT) {
5424
- RETURN_DOM = true;
5425
- }
5426
- /* Parse profile info */
5427
-
5428
-
5429
- if (USE_PROFILES) {
5430
- ALLOWED_TAGS = addToSet({}, [...text]);
5431
- ALLOWED_ATTR = [];
5432
-
5433
- if (USE_PROFILES.html === true) {
5434
- addToSet(ALLOWED_TAGS, html$1);
5435
- addToSet(ALLOWED_ATTR, html);
5436
- }
5437
-
5438
- if (USE_PROFILES.svg === true) {
5439
- addToSet(ALLOWED_TAGS, svg$1);
5440
- addToSet(ALLOWED_ATTR, svg);
5441
- addToSet(ALLOWED_ATTR, xml);
5442
- }
5443
-
5444
- if (USE_PROFILES.svgFilters === true) {
5445
- addToSet(ALLOWED_TAGS, svgFilters);
5446
- addToSet(ALLOWED_ATTR, svg);
5447
- addToSet(ALLOWED_ATTR, xml);
5448
- }
5449
-
5450
- if (USE_PROFILES.mathMl === true) {
5451
- addToSet(ALLOWED_TAGS, mathMl$1);
5452
- addToSet(ALLOWED_ATTR, mathMl);
5453
- addToSet(ALLOWED_ATTR, xml);
5454
- }
5455
- }
5456
- /* Merge configuration parameters */
5457
-
5458
-
5459
- if (cfg.ADD_TAGS) {
5460
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
5461
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
5462
- }
5463
-
5464
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
5465
- }
5466
-
5467
- if (cfg.ADD_ATTR) {
5468
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
5469
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
5470
- }
5471
-
5472
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
5473
- }
5474
-
5475
- if (cfg.ADD_URI_SAFE_ATTR) {
5476
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
5477
- }
5478
-
5479
- if (cfg.FORBID_CONTENTS) {
5480
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
5481
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
5482
- }
5483
-
5484
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
5485
- }
5486
- /* Add #text in case KEEP_CONTENT is set to true */
5487
-
5488
-
5489
- if (KEEP_CONTENT) {
5490
- ALLOWED_TAGS['#text'] = true;
5491
- }
5492
- /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
5493
-
5494
-
5495
- if (WHOLE_DOCUMENT) {
5496
- addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
5497
- }
5498
- /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
5499
-
5500
-
5501
- if (ALLOWED_TAGS.table) {
5502
- addToSet(ALLOWED_TAGS, ['tbody']);
5503
- delete FORBID_TAGS.tbody;
5504
- }
5505
-
5506
- if (cfg.TRUSTED_TYPES_POLICY) {
5507
- if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
5508
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
5509
- }
5510
-
5511
- if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
5512
- throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
5513
- } // Overwrite existing TrustedTypes policy.
5514
-
5515
-
5516
- trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`.
5517
-
5518
- emptyHTML = trustedTypesPolicy.createHTML('');
5519
- } else {
5520
- // Uninitialized policy, attempt to initialize the internal dompurify policy.
5521
- if (trustedTypesPolicy === undefined) {
5522
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
5523
- } // If creating the internal policy succeeded sign internal variables.
5524
-
5525
-
5526
- if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
5527
- emptyHTML = trustedTypesPolicy.createHTML('');
5528
- }
5529
- } // Prevent further manipulation of configuration.
5530
- // Not available in IE8, Safari 5, etc.
5531
-
5532
-
5533
- if (freeze) {
5534
- freeze(cfg);
5535
- }
5536
-
5537
- CONFIG = cfg;
5538
- };
5539
-
5540
- const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
5541
- const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
5542
- // namespace. We need to specify them explicitly
5543
- // so that they don't get erroneously deleted from
5544
- // HTML namespace.
5545
-
5546
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
5547
- /* Keep track of all possible SVG and MathML tags
5548
- * so that we can perform the namespace checks
5549
- * correctly. */
5550
-
5551
- const ALL_SVG_TAGS = addToSet({}, svg$1);
5552
- addToSet(ALL_SVG_TAGS, svgFilters);
5553
- addToSet(ALL_SVG_TAGS, svgDisallowed);
5554
- const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
5555
- addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
5556
- /**
5557
- *
5558
- *
5559
- * @param {Element} element a DOM element whose namespace is being checked
5560
- * @returns {boolean} Return false if the element has a
5561
- * namespace that a spec-compliant parser would never
5562
- * return. Return true otherwise.
5563
- */
5564
-
5565
- const _checkValidNamespace = function _checkValidNamespace(element) {
5566
- let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
5567
- // can be null. We just simulate parent in this case.
5568
-
5569
- if (!parent || !parent.tagName) {
5570
- parent = {
5571
- namespaceURI: NAMESPACE,
5572
- tagName: 'template'
5573
- };
5574
- }
5575
-
5576
- const tagName = stringToLowerCase(element.tagName);
5577
- const parentTagName = stringToLowerCase(parent.tagName);
5578
-
5579
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
5580
- return false;
5581
- }
5582
-
5583
- if (element.namespaceURI === SVG_NAMESPACE) {
5584
- // The only way to switch from HTML namespace to SVG
5585
- // is via <svg>. If it happens via any other tag, then
5586
- // it should be killed.
5587
- if (parent.namespaceURI === HTML_NAMESPACE) {
5588
- return tagName === 'svg';
5589
- } // The only way to switch from MathML to SVG is via`
5590
- // svg if parent is either <annotation-xml> or MathML
5591
- // text integration points.
5592
-
5593
-
5594
- if (parent.namespaceURI === MATHML_NAMESPACE) {
5595
- return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
5596
- } // We only allow elements that are defined in SVG
5597
- // spec. All others are disallowed in SVG namespace.
5598
-
5599
-
5600
- return Boolean(ALL_SVG_TAGS[tagName]);
5601
- }
5602
-
5603
- if (element.namespaceURI === MATHML_NAMESPACE) {
5604
- // The only way to switch from HTML namespace to MathML
5605
- // is via <math>. If it happens via any other tag, then
5606
- // it should be killed.
5607
- if (parent.namespaceURI === HTML_NAMESPACE) {
5608
- return tagName === 'math';
5609
- } // The only way to switch from SVG to MathML is via
5610
- // <math> and HTML integration points
5611
-
5612
-
5613
- if (parent.namespaceURI === SVG_NAMESPACE) {
5614
- return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
5615
- } // We only allow elements that are defined in MathML
5616
- // spec. All others are disallowed in MathML namespace.
5617
-
5618
-
5619
- return Boolean(ALL_MATHML_TAGS[tagName]);
5620
- }
5621
-
5622
- if (element.namespaceURI === HTML_NAMESPACE) {
5623
- // The only way to switch from SVG to HTML is via
5624
- // HTML integration points, and from MathML to HTML
5625
- // is via MathML text integration points
5626
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
5627
- return false;
5628
- }
5629
-
5630
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
5631
- return false;
5632
- } // We disallow tags that are specific for MathML
5633
- // or SVG and should never appear in HTML namespace
5634
-
5635
-
5636
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
5637
- } // For XHTML and XML documents that support custom namespaces
5638
-
5639
-
5640
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
5641
- return true;
5642
- } // The code should never reach this place (this means
5643
- // that the element somehow got namespace that is not
5644
- // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
5645
- // Return false just in case.
5646
-
5647
-
5648
- return false;
5649
- };
5650
- /**
5651
- * _forceRemove
5652
- *
5653
- * @param {Node} node a DOM node
5654
- */
5655
-
5656
-
5657
- const _forceRemove = function _forceRemove(node) {
5658
- arrayPush(DOMPurify.removed, {
5659
- element: node
5660
- });
5661
-
5662
- try {
5663
- // eslint-disable-next-line unicorn/prefer-dom-node-remove
5664
- node.parentNode.removeChild(node);
5665
- } catch (_) {
5666
- node.remove();
5667
- }
5668
- };
5669
- /**
5670
- * _removeAttribute
5671
- *
5672
- * @param {String} name an Attribute name
5673
- * @param {Node} node a DOM node
5674
- */
5675
-
5676
-
5677
- const _removeAttribute = function _removeAttribute(name, node) {
5678
- try {
5679
- arrayPush(DOMPurify.removed, {
5680
- attribute: node.getAttributeNode(name),
5681
- from: node
5682
- });
5683
- } catch (_) {
5684
- arrayPush(DOMPurify.removed, {
5685
- attribute: null,
5686
- from: node
5687
- });
5688
- }
5689
-
5690
- node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
5691
-
5692
- if (name === 'is' && !ALLOWED_ATTR[name]) {
5693
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
5694
- try {
5695
- _forceRemove(node);
5696
- } catch (_) {}
5697
- } else {
5698
- try {
5699
- node.setAttribute(name, '');
5700
- } catch (_) {}
5701
- }
5702
- }
5703
- };
5704
- /**
5705
- * _initDocument
5706
- *
5707
- * @param {String} dirty a string of dirty markup
5708
- * @return {Document} a DOM, filled with the dirty markup
5709
- */
5710
-
5711
-
5712
- const _initDocument = function _initDocument(dirty) {
5713
- /* Create a HTML document */
5714
- let doc;
5715
- let leadingWhitespace;
5716
-
5717
- if (FORCE_BODY) {
5718
- dirty = '<remove></remove>' + dirty;
5719
- } else {
5720
- /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
5721
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
5722
- leadingWhitespace = matches && matches[0];
5723
- }
5724
-
5725
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
5726
- // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
5727
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
5728
- }
5729
-
5730
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
5731
- /*
5732
- * Use the DOMParser API by default, fallback later if needs be
5733
- * DOMParser not work for svg when has multiple root element.
5734
- */
5735
-
5736
- if (NAMESPACE === HTML_NAMESPACE) {
5737
- try {
5738
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
5739
- } catch (_) {}
5740
- }
5741
- /* Use createHTMLDocument in case DOMParser is not available */
5742
-
5743
-
5744
- if (!doc || !doc.documentElement) {
5745
- doc = implementation.createDocument(NAMESPACE, 'template', null);
5746
-
5747
- try {
5748
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
5749
- } catch (_) {// Syntax error if dirtyPayload is invalid xml
5750
- }
5751
- }
5752
-
5753
- const body = doc.body || doc.documentElement;
5754
-
5755
- if (dirty && leadingWhitespace) {
5756
- body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
5757
- }
5758
- /* Work on whole document or just its body */
5759
-
5760
-
5761
- if (NAMESPACE === HTML_NAMESPACE) {
5762
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
5763
- }
5764
-
5765
- return WHOLE_DOCUMENT ? doc.documentElement : body;
5766
- };
5767
- /**
5768
- * _createIterator
5769
- *
5770
- * @param {Document} root document/fragment to create iterator for
5771
- * @return {Iterator} iterator instance
5772
- */
5773
-
5774
-
5775
- const _createIterator = function _createIterator(root) {
5776
- return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
5777
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
5778
- };
5779
- /**
5780
- * _isClobbered
5781
- *
5782
- * @param {Node} elm element to check for clobbering attacks
5783
- * @return {Boolean} true if clobbered, false if safe
5784
- */
5785
-
5786
-
5787
- const _isClobbered = function _isClobbered(elm) {
5788
- return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
5789
- };
5790
- /**
5791
- * _isNode
5792
- *
5793
- * @param {Node} obj object to check whether it's a DOM node
5794
- * @return {Boolean} true is object is a DOM node
5795
- */
5796
-
5797
-
5798
- const _isNode = function _isNode(object) {
5799
- return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
5800
- };
5801
- /**
5802
- * _executeHook
5803
- * Execute user configurable hooks
5804
- *
5805
- * @param {String} entryPoint Name of the hook's entry point
5806
- * @param {Node} currentNode node to work on with the hook
5807
- * @param {Object} data additional hook parameters
5808
- */
5809
-
5810
-
5811
- const _executeHook = function _executeHook(entryPoint, currentNode, data) {
5812
- if (!hooks[entryPoint]) {
5813
- return;
5814
- }
5815
-
5816
- arrayForEach(hooks[entryPoint], hook => {
5817
- hook.call(DOMPurify, currentNode, data, CONFIG);
5818
- });
5819
- };
5820
- /**
5821
- * _sanitizeElements
5822
- *
5823
- * @protect nodeName
5824
- * @protect textContent
5825
- * @protect removeChild
5826
- *
5827
- * @param {Node} currentNode to check for permission to exist
5828
- * @return {Boolean} true if node was killed, false if left alive
5829
- */
5830
-
5831
-
5832
- const _sanitizeElements = function _sanitizeElements(currentNode) {
5833
- let content;
5834
- /* Execute a hook if present */
5835
-
5836
- _executeHook('beforeSanitizeElements', currentNode, null);
5837
- /* Check if element is clobbered or can clobber */
5838
-
5839
-
5840
- if (_isClobbered(currentNode)) {
5841
- _forceRemove(currentNode);
5842
-
5843
- return true;
5844
- }
5845
- /* Now let's check the element's type and name */
5846
-
5847
-
5848
- const tagName = transformCaseFunc(currentNode.nodeName);
5849
- /* Execute a hook if present */
5850
-
5851
- _executeHook('uponSanitizeElement', currentNode, {
5852
- tagName,
5853
- allowedTags: ALLOWED_TAGS
5854
- });
5855
- /* Detect mXSS attempts abusing namespace confusion */
5856
-
5857
-
5858
- if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
5859
- _forceRemove(currentNode);
5860
-
5861
- return true;
5862
- }
5863
- /* Remove element if anything forbids its presence */
5864
-
5865
-
5866
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
5867
- /* Check if we have a custom element to handle */
5868
- if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
5869
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
5870
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
5871
- }
5872
- /* Keep content except for bad-listed elements */
5873
-
5874
-
5875
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
5876
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
5877
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
5878
-
5879
- if (childNodes && parentNode) {
5880
- const childCount = childNodes.length;
5881
-
5882
- for (let i = childCount - 1; i >= 0; --i) {
5883
- parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
5884
- }
5885
- }
5886
- }
5887
-
5888
- _forceRemove(currentNode);
5889
-
5890
- return true;
5891
- }
5892
- /* Check whether element has a valid namespace */
5893
-
5894
-
5895
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
5896
- _forceRemove(currentNode);
5897
-
5898
- return true;
5899
- }
5900
- /* Make sure that older browsers don't get fallback-tag mXSS */
5901
-
5902
-
5903
- if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
5904
- _forceRemove(currentNode);
5905
-
5906
- return true;
5907
- }
5908
- /* Sanitize element content to be template-safe */
5909
-
5910
-
5911
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
5912
- /* Get the element's text content */
5913
- content = currentNode.textContent;
5914
- content = stringReplace(content, MUSTACHE_EXPR, ' ');
5915
- content = stringReplace(content, ERB_EXPR, ' ');
5916
- content = stringReplace(content, TMPLIT_EXPR, ' ');
5917
-
5918
- if (currentNode.textContent !== content) {
5919
- arrayPush(DOMPurify.removed, {
5920
- element: currentNode.cloneNode()
5921
- });
5922
- currentNode.textContent = content;
5923
- }
5924
- }
5925
- /* Execute a hook if present */
5926
-
5927
-
5928
- _executeHook('afterSanitizeElements', currentNode, null);
5929
-
5930
- return false;
5931
- };
5932
- /**
5933
- * _isValidAttribute
5934
- *
5935
- * @param {string} lcTag Lowercase tag name of containing element.
5936
- * @param {string} lcName Lowercase attribute name.
5937
- * @param {string} value Attribute value.
5938
- * @return {Boolean} Returns true if `value` is valid, otherwise false.
5939
- */
5940
- // eslint-disable-next-line complexity
5941
-
5942
-
5943
- const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
5944
- /* Make sure attribute cannot clobber */
5945
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
5946
- return false;
5947
- }
5948
- /* Allow valid data-* attributes: At least one character after "-"
5949
- (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
5950
- XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
5951
- We don't need to check the value; it's always URI safe. */
5952
-
5953
-
5954
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
5955
- if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
5956
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
5957
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
5958
- _basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
5959
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
5960
- lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
5961
- return false;
5962
- }
5963
- /* Check value is safe. First, is attr inert? If so, is safe */
5964
-
5965
- } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
5966
- return false;
5967
- } else ;
5968
-
5969
- return true;
5970
- };
5971
- /**
5972
- * _basicCustomElementCheck
5973
- * checks if at least one dash is included in tagName, and it's not the first char
5974
- * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
5975
- * @param {string} tagName name of the tag of the node to sanitize
5976
- */
5977
-
5978
-
5979
- const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
5980
- return tagName.indexOf('-') > 0;
5981
- };
5982
- /**
5983
- * _sanitizeAttributes
5984
- *
5985
- * @protect attributes
5986
- * @protect nodeName
5987
- * @protect removeAttribute
5988
- * @protect setAttribute
5989
- *
5990
- * @param {Node} currentNode to sanitize
5991
- */
5992
-
5993
-
5994
- const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
5995
- let attr;
5996
- let value;
5997
- let lcName;
5998
- let l;
5999
- /* Execute a hook if present */
6000
-
6001
- _executeHook('beforeSanitizeAttributes', currentNode, null);
6002
-
6003
- const {
6004
- attributes
6005
- } = currentNode;
6006
- /* Check if we have attributes; if not we might have a text node */
6007
-
6008
- if (!attributes) {
6009
- return;
6010
- }
6011
-
6012
- const hookEvent = {
6013
- attrName: '',
6014
- attrValue: '',
6015
- keepAttr: true,
6016
- allowedAttributes: ALLOWED_ATTR
6017
- };
6018
- l = attributes.length;
6019
- /* Go backwards over all attributes; safely remove bad ones */
6020
-
6021
- while (l--) {
6022
- attr = attributes[l];
6023
- const {
6024
- name,
6025
- namespaceURI
6026
- } = attr;
6027
- value = name === 'value' ? attr.value : stringTrim(attr.value);
6028
- lcName = transformCaseFunc(name);
6029
- /* Execute a hook if present */
6030
-
6031
- hookEvent.attrName = lcName;
6032
- hookEvent.attrValue = value;
6033
- hookEvent.keepAttr = true;
6034
- hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
6035
-
6036
- _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
6037
-
6038
- value = hookEvent.attrValue;
6039
- /* Did the hooks approve of the attribute? */
6040
-
6041
- if (hookEvent.forceKeepAttr) {
6042
- continue;
6043
- }
6044
- /* Remove attribute */
6045
-
6046
-
6047
- _removeAttribute(name, currentNode);
6048
- /* Did the hooks approve of the attribute? */
6049
-
6050
-
6051
- if (!hookEvent.keepAttr) {
6052
- continue;
6053
- }
6054
- /* Work around a security issue in jQuery 3.0 */
6055
-
6056
-
6057
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
6058
- _removeAttribute(name, currentNode);
6059
-
6060
- continue;
6061
- }
6062
- /* Sanitize attribute content to be template-safe */
6063
-
6064
-
6065
- if (SAFE_FOR_TEMPLATES) {
6066
- value = stringReplace(value, MUSTACHE_EXPR, ' ');
6067
- value = stringReplace(value, ERB_EXPR, ' ');
6068
- value = stringReplace(value, TMPLIT_EXPR, ' ');
6069
- }
6070
- /* Is `value` valid for this attribute? */
6071
-
6072
-
6073
- const lcTag = transformCaseFunc(currentNode.nodeName);
6074
-
6075
- if (!_isValidAttribute(lcTag, lcName, value)) {
6076
- continue;
6077
- }
6078
- /* Full DOM Clobbering protection via namespace isolation,
6079
- * Prefix id and name attributes with `user-content-`
6080
- */
6081
-
6082
-
6083
- if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
6084
- // Remove the attribute with this value
6085
- _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
6086
-
6087
-
6088
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
6089
- }
6090
- /* Handle attributes that require Trusted Types */
6091
-
6092
-
6093
- if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
6094
- if (namespaceURI) ; else {
6095
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
6096
- case 'TrustedHTML':
6097
- {
6098
- value = trustedTypesPolicy.createHTML(value);
6099
- break;
6100
- }
6101
-
6102
- case 'TrustedScriptURL':
6103
- {
6104
- value = trustedTypesPolicy.createScriptURL(value);
6105
- break;
6106
- }
6107
- }
6108
- }
6109
- }
6110
- /* Handle invalid data-* attribute set by try-catching it */
6111
-
6112
-
6113
- try {
6114
- if (namespaceURI) {
6115
- currentNode.setAttributeNS(namespaceURI, name, value);
6116
- } else {
6117
- /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
6118
- currentNode.setAttribute(name, value);
6119
- }
6120
-
6121
- arrayPop(DOMPurify.removed);
6122
- } catch (_) {}
6123
- }
6124
- /* Execute a hook if present */
6125
-
6126
-
6127
- _executeHook('afterSanitizeAttributes', currentNode, null);
6128
- };
6129
- /**
6130
- * _sanitizeShadowDOM
6131
- *
6132
- * @param {DocumentFragment} fragment to iterate over recursively
6133
- */
6134
-
6135
-
6136
- const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
6137
- let shadowNode;
6138
-
6139
- const shadowIterator = _createIterator(fragment);
6140
- /* Execute a hook if present */
6141
-
6142
-
6143
- _executeHook('beforeSanitizeShadowDOM', fragment, null);
6144
-
6145
- while (shadowNode = shadowIterator.nextNode()) {
6146
- /* Execute a hook if present */
6147
- _executeHook('uponSanitizeShadowNode', shadowNode, null);
6148
- /* Sanitize tags and elements */
6149
-
6150
-
6151
- if (_sanitizeElements(shadowNode)) {
6152
- continue;
6153
- }
6154
- /* Deep shadow DOM detected */
6155
-
6156
-
6157
- if (shadowNode.content instanceof DocumentFragment) {
6158
- _sanitizeShadowDOM(shadowNode.content);
6159
- }
6160
- /* Check attributes, sanitize if necessary */
6161
-
6162
-
6163
- _sanitizeAttributes(shadowNode);
6164
- }
6165
- /* Execute a hook if present */
6166
-
6167
-
6168
- _executeHook('afterSanitizeShadowDOM', fragment, null);
6169
- };
6170
- /**
6171
- * Sanitize
6172
- * Public method providing core sanitation functionality
6173
- *
6174
- * @param {String|Node} dirty string or DOM node
6175
- * @param {Object} configuration object
6176
- */
6177
- // eslint-disable-next-line complexity
6178
-
6179
-
6180
- DOMPurify.sanitize = function (dirty) {
6181
- let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6182
- let body;
6183
- let importedNode;
6184
- let currentNode;
6185
- let returnNode;
6186
- /* Make sure we have a string to sanitize.
6187
- DO NOT return early, as this will return the wrong type if
6188
- the user has requested a DOM object rather than a string */
6189
-
6190
- IS_EMPTY_INPUT = !dirty;
6191
-
6192
- if (IS_EMPTY_INPUT) {
6193
- dirty = '<!-->';
6194
- }
6195
- /* Stringify, in case dirty is an object */
6196
-
6197
-
6198
- if (typeof dirty !== 'string' && !_isNode(dirty)) {
6199
- if (typeof dirty.toString === 'function') {
6200
- dirty = dirty.toString();
6201
-
6202
- if (typeof dirty !== 'string') {
6203
- throw typeErrorCreate('dirty is not a string, aborting');
6204
- }
6205
- } else {
6206
- throw typeErrorCreate('toString is not a function');
6207
- }
6208
- }
6209
- /* Return dirty HTML if DOMPurify cannot run */
6210
-
6211
-
6212
- if (!DOMPurify.isSupported) {
6213
- return dirty;
6214
- }
6215
- /* Assign config vars */
6216
-
6217
-
6218
- if (!SET_CONFIG) {
6219
- _parseConfig(cfg);
6220
- }
6221
- /* Clean up removed elements */
6222
-
6223
-
6224
- DOMPurify.removed = [];
6225
- /* Check if dirty is correctly typed for IN_PLACE */
6226
-
6227
- if (typeof dirty === 'string') {
6228
- IN_PLACE = false;
6229
- }
6230
-
6231
- if (IN_PLACE) {
6232
- /* Do some early pre-sanitization to avoid unsafe root nodes */
6233
- if (dirty.nodeName) {
6234
- const tagName = transformCaseFunc(dirty.nodeName);
6235
-
6236
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
6237
- throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
6238
- }
6239
- }
6240
- } else if (dirty instanceof Node) {
6241
- /* If dirty is a DOM element, append to an empty document to avoid
6242
- elements being stripped by the parser */
6243
- body = _initDocument('<!---->');
6244
- importedNode = body.ownerDocument.importNode(dirty, true);
6245
-
6246
- if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
6247
- /* Node is already a body, use as is */
6248
- body = importedNode;
6249
- } else if (importedNode.nodeName === 'HTML') {
6250
- body = importedNode;
6251
- } else {
6252
- // eslint-disable-next-line unicorn/prefer-dom-node-append
6253
- body.appendChild(importedNode);
6254
- }
6255
- } else {
6256
- /* Exit directly if we have nothing to do */
6257
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
6258
- dirty.indexOf('<') === -1) {
6259
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
6260
- }
6261
- /* Initialize the document to work on */
6262
-
6263
-
6264
- body = _initDocument(dirty);
6265
- /* Check we have a DOM node from the data */
6266
-
6267
- if (!body) {
6268
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
6269
- }
6270
- }
6271
- /* Remove first element node (ours) if FORCE_BODY is set */
6272
-
6273
-
6274
- if (body && FORCE_BODY) {
6275
- _forceRemove(body.firstChild);
6276
- }
6277
- /* Get node iterator */
6278
-
6279
-
6280
- const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
6281
- /* Now start iterating over the created document */
6282
-
6283
-
6284
- while (currentNode = nodeIterator.nextNode()) {
6285
- /* Sanitize tags and elements */
6286
- if (_sanitizeElements(currentNode)) {
6287
- continue;
6288
- }
6289
- /* Shadow DOM detected, sanitize it */
6290
-
6291
-
6292
- if (currentNode.content instanceof DocumentFragment) {
6293
- _sanitizeShadowDOM(currentNode.content);
6294
- }
6295
- /* Check attributes, sanitize if necessary */
6296
-
6297
-
6298
- _sanitizeAttributes(currentNode);
6299
- }
6300
- /* If we sanitized `dirty` in-place, return it. */
6301
-
6302
-
6303
- if (IN_PLACE) {
6304
- return dirty;
6305
- }
6306
- /* Return sanitized string or DOM */
6307
-
6308
-
6309
- if (RETURN_DOM) {
6310
- if (RETURN_DOM_FRAGMENT) {
6311
- returnNode = createDocumentFragment.call(body.ownerDocument);
6312
-
6313
- while (body.firstChild) {
6314
- // eslint-disable-next-line unicorn/prefer-dom-node-append
6315
- returnNode.appendChild(body.firstChild);
6316
- }
6317
- } else {
6318
- returnNode = body;
6319
- }
6320
-
6321
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
6322
- /*
6323
- AdoptNode() is not used because internal state is not reset
6324
- (e.g. the past names map of a HTMLFormElement), this is safe
6325
- in theory but we would rather not risk another attack vector.
6326
- The state that is cloned by importNode() is explicitly defined
6327
- by the specs.
6328
- */
6329
- returnNode = importNode.call(originalDocument, returnNode, true);
6330
- }
6331
-
6332
- return returnNode;
6333
- }
6334
-
6335
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
6336
- /* Serialize doctype if allowed */
6337
-
6338
- if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
6339
- serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
6340
- }
6341
- /* Sanitize final string template-safe */
6342
-
6343
-
6344
- if (SAFE_FOR_TEMPLATES) {
6345
- serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
6346
- serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
6347
- serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
6348
- }
6349
-
6350
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
6351
- };
6352
- /**
6353
- * Public method to set the configuration once
6354
- * setConfig
6355
- *
6356
- * @param {Object} cfg configuration object
6357
- */
6358
-
6359
-
6360
- DOMPurify.setConfig = function (cfg) {
6361
- _parseConfig(cfg);
6362
-
6363
- SET_CONFIG = true;
6364
- };
6365
- /**
6366
- * Public method to remove the configuration
6367
- * clearConfig
6368
- *
6369
- */
6370
-
6371
-
6372
- DOMPurify.clearConfig = function () {
6373
- CONFIG = null;
6374
- SET_CONFIG = false;
6375
- };
6376
- /**
6377
- * Public method to check if an attribute value is valid.
6378
- * Uses last set config, if any. Otherwise, uses config defaults.
6379
- * isValidAttribute
6380
- *
6381
- * @param {string} tag Tag name of containing element.
6382
- * @param {string} attr Attribute name.
6383
- * @param {string} value Attribute value.
6384
- * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
6385
- */
6386
-
6387
-
6388
- DOMPurify.isValidAttribute = function (tag, attr, value) {
6389
- /* Initialize shared config vars if necessary. */
6390
- if (!CONFIG) {
6391
- _parseConfig({});
6392
- }
6393
-
6394
- const lcTag = transformCaseFunc(tag);
6395
- const lcName = transformCaseFunc(attr);
6396
- return _isValidAttribute(lcTag, lcName, value);
6397
- };
6398
- /**
6399
- * AddHook
6400
- * Public method to add DOMPurify hooks
6401
- *
6402
- * @param {String} entryPoint entry point for the hook to add
6403
- * @param {Function} hookFunction function to execute
6404
- */
6405
-
6406
-
6407
- DOMPurify.addHook = function (entryPoint, hookFunction) {
6408
- if (typeof hookFunction !== 'function') {
6409
- return;
6410
- }
6411
-
6412
- hooks[entryPoint] = hooks[entryPoint] || [];
6413
- arrayPush(hooks[entryPoint], hookFunction);
6414
- };
6415
- /**
6416
- * RemoveHook
6417
- * Public method to remove a DOMPurify hook at a given entryPoint
6418
- * (pops it from the stack of hooks if more are present)
6419
- *
6420
- * @param {String} entryPoint entry point for the hook to remove
6421
- * @return {Function} removed(popped) hook
6422
- */
6423
-
6424
-
6425
- DOMPurify.removeHook = function (entryPoint) {
6426
- if (hooks[entryPoint]) {
6427
- return arrayPop(hooks[entryPoint]);
6428
- }
6429
- };
6430
- /**
6431
- * RemoveHooks
6432
- * Public method to remove all DOMPurify hooks at a given entryPoint
6433
- *
6434
- * @param {String} entryPoint entry point for the hooks to remove
6435
- */
6436
-
6437
-
6438
- DOMPurify.removeHooks = function (entryPoint) {
6439
- if (hooks[entryPoint]) {
6440
- hooks[entryPoint] = [];
6441
- }
6442
- };
6443
- /**
6444
- * RemoveAllHooks
6445
- * Public method to remove all DOMPurify hooks
6446
- *
6447
- */
6448
-
6449
-
6450
- DOMPurify.removeAllHooks = function () {
6451
- hooks = {};
6452
- };
6453
-
6454
- return DOMPurify;
6455
- }
6456
-
6457
- var purify = createDOMPurify();
6458
-
6459
- return purify;
6460
-
6461
- }));
6462
-
6463
- } (purify));
4780
+ /*! @license DOMPurify 3.2.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.3/LICENSE */
4781
+
4782
+ const {
4783
+ entries,
4784
+ setPrototypeOf,
4785
+ isFrozen,
4786
+ getPrototypeOf,
4787
+ getOwnPropertyDescriptor
4788
+ } = Object;
4789
+ let {
4790
+ freeze,
4791
+ seal,
4792
+ create
4793
+ } = Object; // eslint-disable-line import/no-mutable-exports
4794
+ let {
4795
+ apply,
4796
+ construct
4797
+ } = typeof Reflect !== 'undefined' && Reflect;
4798
+ if (!freeze) {
4799
+ freeze = function freeze(x) {
4800
+ return x;
4801
+ };
4802
+ }
4803
+ if (!seal) {
4804
+ seal = function seal(x) {
4805
+ return x;
4806
+ };
4807
+ }
4808
+ if (!apply) {
4809
+ apply = function apply(fun, thisValue, args) {
4810
+ return fun.apply(thisValue, args);
4811
+ };
4812
+ }
4813
+ if (!construct) {
4814
+ construct = function construct(Func, args) {
4815
+ return new Func(...args);
4816
+ };
4817
+ }
4818
+ const arrayForEach = unapply(Array.prototype.forEach);
4819
+ const arrayPop = unapply(Array.prototype.pop);
4820
+ const arrayPush = unapply(Array.prototype.push);
4821
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
4822
+ const stringToString = unapply(String.prototype.toString);
4823
+ const stringMatch = unapply(String.prototype.match);
4824
+ const stringReplace = unapply(String.prototype.replace);
4825
+ const stringIndexOf = unapply(String.prototype.indexOf);
4826
+ const stringTrim = unapply(String.prototype.trim);
4827
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
4828
+ const regExpTest = unapply(RegExp.prototype.test);
4829
+ const typeErrorCreate = unconstruct(TypeError);
4830
+ /**
4831
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
4832
+ *
4833
+ * @param func - The function to be wrapped and called.
4834
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
4835
+ */
4836
+ function unapply(func) {
4837
+ return function (thisArg) {
4838
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
4839
+ args[_key - 1] = arguments[_key];
4840
+ }
4841
+ return apply(func, thisArg, args);
4842
+ };
4843
+ }
4844
+ /**
4845
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
4846
+ *
4847
+ * @param func - The constructor function to be wrapped and called.
4848
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
4849
+ */
4850
+ function unconstruct(func) {
4851
+ return function () {
4852
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
4853
+ args[_key2] = arguments[_key2];
4854
+ }
4855
+ return construct(func, args);
4856
+ };
4857
+ }
4858
+ /**
4859
+ * Add properties to a lookup table
4860
+ *
4861
+ * @param set - The set to which elements will be added.
4862
+ * @param array - The array containing elements to be added to the set.
4863
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
4864
+ * @returns The modified set with added elements.
4865
+ */
4866
+ function addToSet(set, array) {
4867
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
4868
+ if (setPrototypeOf) {
4869
+ // Make 'in' and truthy checks like Boolean(set.constructor)
4870
+ // independent of any properties defined on Object.prototype.
4871
+ // Prevent prototype setters from intercepting set as a this value.
4872
+ setPrototypeOf(set, null);
4873
+ }
4874
+ let l = array.length;
4875
+ while (l--) {
4876
+ let element = array[l];
4877
+ if (typeof element === 'string') {
4878
+ const lcElement = transformCaseFunc(element);
4879
+ if (lcElement !== element) {
4880
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
4881
+ if (!isFrozen(array)) {
4882
+ array[l] = lcElement;
4883
+ }
4884
+ element = lcElement;
4885
+ }
4886
+ }
4887
+ set[element] = true;
4888
+ }
4889
+ return set;
4890
+ }
4891
+ /**
4892
+ * Clean up an array to harden against CSPP
4893
+ *
4894
+ * @param array - The array to be cleaned.
4895
+ * @returns The cleaned version of the array
4896
+ */
4897
+ function cleanArray(array) {
4898
+ for (let index = 0; index < array.length; index++) {
4899
+ const isPropertyExist = objectHasOwnProperty(array, index);
4900
+ if (!isPropertyExist) {
4901
+ array[index] = null;
4902
+ }
4903
+ }
4904
+ return array;
4905
+ }
4906
+ /**
4907
+ * Shallow clone an object
4908
+ *
4909
+ * @param object - The object to be cloned.
4910
+ * @returns A new object that copies the original.
4911
+ */
4912
+ function clone(object) {
4913
+ const newObject = create(null);
4914
+ for (const [property, value] of entries(object)) {
4915
+ const isPropertyExist = objectHasOwnProperty(object, property);
4916
+ if (isPropertyExist) {
4917
+ if (Array.isArray(value)) {
4918
+ newObject[property] = cleanArray(value);
4919
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
4920
+ newObject[property] = clone(value);
4921
+ } else {
4922
+ newObject[property] = value;
4923
+ }
4924
+ }
4925
+ }
4926
+ return newObject;
4927
+ }
4928
+ /**
4929
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
4930
+ *
4931
+ * @param object - The object to look up the getter function in its prototype chain.
4932
+ * @param prop - The property name for which to find the getter function.
4933
+ * @returns The getter function found in the prototype chain or a fallback function.
4934
+ */
4935
+ function lookupGetter(object, prop) {
4936
+ while (object !== null) {
4937
+ const desc = getOwnPropertyDescriptor(object, prop);
4938
+ if (desc) {
4939
+ if (desc.get) {
4940
+ return unapply(desc.get);
4941
+ }
4942
+ if (typeof desc.value === 'function') {
4943
+ return unapply(desc.value);
4944
+ }
4945
+ }
4946
+ object = getPrototypeOf(object);
4947
+ }
4948
+ function fallbackValue() {
4949
+ return null;
4950
+ }
4951
+ return fallbackValue;
4952
+ }
4953
+
4954
+ const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
4955
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
4956
+ const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);
4957
+ // List of SVG elements that are disallowed by default.
4958
+ // We still need to know them so that we can do namespace
4959
+ // checks properly in case one wants to add them to
4960
+ // allow-list.
4961
+ const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
4962
+ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);
4963
+ // Similarly to SVG, we want to know all MathML elements,
4964
+ // even those that we disallow by default.
4965
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
4966
+ const text = freeze(['#text']);
4967
+
4968
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
4969
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
4970
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
4971
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
4972
+
4973
+ // eslint-disable-next-line unicorn/better-regex
4974
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
4975
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
4976
+ const TMPLIT_EXPR = seal(/\$\{[\w\W]*}/gm); // eslint-disable-line unicorn/better-regex
4977
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
4978
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
4979
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
4980
+ );
4981
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
4982
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
4983
+ );
4984
+ const DOCTYPE_NAME = seal(/^html$/i);
4985
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
4986
+
4987
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
4988
+ __proto__: null,
4989
+ ARIA_ATTR: ARIA_ATTR,
4990
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
4991
+ CUSTOM_ELEMENT: CUSTOM_ELEMENT,
4992
+ DATA_ATTR: DATA_ATTR,
4993
+ DOCTYPE_NAME: DOCTYPE_NAME,
4994
+ ERB_EXPR: ERB_EXPR,
4995
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
4996
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
4997
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
4998
+ TMPLIT_EXPR: TMPLIT_EXPR
4999
+ });
6464
5000
 
6465
- var DOMPurify = purifyExports;
5001
+ /* eslint-disable @typescript-eslint/indent */
5002
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
5003
+ const NODE_TYPE = {
5004
+ element: 1,
5005
+ attribute: 2,
5006
+ text: 3,
5007
+ cdataSection: 4,
5008
+ entityReference: 5,
5009
+ // Deprecated
5010
+ entityNode: 6,
5011
+ // Deprecated
5012
+ progressingInstruction: 7,
5013
+ comment: 8,
5014
+ document: 9,
5015
+ documentType: 10,
5016
+ documentFragment: 11,
5017
+ notation: 12 // Deprecated
5018
+ };
5019
+ const getGlobal = function getGlobal() {
5020
+ return typeof window === 'undefined' ? null : window;
5021
+ };
5022
+ /**
5023
+ * Creates a no-op policy for internal use only.
5024
+ * Don't export this function outside this module!
5025
+ * @param trustedTypes The policy factory.
5026
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
5027
+ * @return The policy created (or null, if Trusted Types
5028
+ * are not supported or creating the policy failed).
5029
+ */
5030
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
5031
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
5032
+ return null;
5033
+ }
5034
+ // Allow the callers to control the unique policy name
5035
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
5036
+ // Policy creation with duplicate names throws in Trusted Types.
5037
+ let suffix = null;
5038
+ const ATTR_NAME = 'data-tt-policy-suffix';
5039
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
5040
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
5041
+ }
5042
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
5043
+ try {
5044
+ return trustedTypes.createPolicy(policyName, {
5045
+ createHTML(html) {
5046
+ return html;
5047
+ },
5048
+ createScriptURL(scriptUrl) {
5049
+ return scriptUrl;
5050
+ }
5051
+ });
5052
+ } catch (_) {
5053
+ // Policy creation failed (most likely another DOMPurify script has
5054
+ // already run). Skip creating the policy, as this will only cause errors
5055
+ // if TT are enforced.
5056
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
5057
+ return null;
5058
+ }
5059
+ };
5060
+ const _createHooksMap = function _createHooksMap() {
5061
+ return {
5062
+ afterSanitizeAttributes: [],
5063
+ afterSanitizeElements: [],
5064
+ afterSanitizeShadowDOM: [],
5065
+ beforeSanitizeAttributes: [],
5066
+ beforeSanitizeElements: [],
5067
+ beforeSanitizeShadowDOM: [],
5068
+ uponSanitizeAttribute: [],
5069
+ uponSanitizeElement: [],
5070
+ uponSanitizeShadowNode: []
5071
+ };
5072
+ };
5073
+ function createDOMPurify() {
5074
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
5075
+ const DOMPurify = root => createDOMPurify(root);
5076
+ DOMPurify.version = '3.2.3';
5077
+ DOMPurify.removed = [];
5078
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document) {
5079
+ // Not running in a browser, provide a factory function
5080
+ // so that you can pass your own Window
5081
+ DOMPurify.isSupported = false;
5082
+ return DOMPurify;
5083
+ }
5084
+ let {
5085
+ document
5086
+ } = window;
5087
+ const originalDocument = document;
5088
+ const currentScript = originalDocument.currentScript;
5089
+ const {
5090
+ DocumentFragment,
5091
+ HTMLTemplateElement,
5092
+ Node,
5093
+ Element,
5094
+ NodeFilter,
5095
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
5096
+ HTMLFormElement,
5097
+ DOMParser,
5098
+ trustedTypes
5099
+ } = window;
5100
+ const ElementPrototype = Element.prototype;
5101
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
5102
+ const remove = lookupGetter(ElementPrototype, 'remove');
5103
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
5104
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
5105
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
5106
+ // As per issue #47, the web-components registry is inherited by a
5107
+ // new document created via createHTMLDocument. As per the spec
5108
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
5109
+ // a new empty registry is used when creating a template contents owner
5110
+ // document, so we use that as our parent document to ensure nothing
5111
+ // is inherited.
5112
+ if (typeof HTMLTemplateElement === 'function') {
5113
+ const template = document.createElement('template');
5114
+ if (template.content && template.content.ownerDocument) {
5115
+ document = template.content.ownerDocument;
5116
+ }
5117
+ }
5118
+ let trustedTypesPolicy;
5119
+ let emptyHTML = '';
5120
+ const {
5121
+ implementation,
5122
+ createNodeIterator,
5123
+ createDocumentFragment,
5124
+ getElementsByTagName
5125
+ } = document;
5126
+ const {
5127
+ importNode
5128
+ } = originalDocument;
5129
+ let hooks = _createHooksMap();
5130
+ /**
5131
+ * Expose whether this browser supports running the full DOMPurify.
5132
+ */
5133
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
5134
+ const {
5135
+ MUSTACHE_EXPR,
5136
+ ERB_EXPR,
5137
+ TMPLIT_EXPR,
5138
+ DATA_ATTR,
5139
+ ARIA_ATTR,
5140
+ IS_SCRIPT_OR_DATA,
5141
+ ATTR_WHITESPACE,
5142
+ CUSTOM_ELEMENT
5143
+ } = EXPRESSIONS;
5144
+ let {
5145
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
5146
+ } = EXPRESSIONS;
5147
+ /**
5148
+ * We consider the elements and attributes below to be safe. Ideally
5149
+ * don't add any new ones but feel free to remove unwanted ones.
5150
+ */
5151
+ /* allowed element names */
5152
+ let ALLOWED_TAGS = null;
5153
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
5154
+ /* Allowed attribute names */
5155
+ let ALLOWED_ATTR = null;
5156
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
5157
+ /*
5158
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
5159
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
5160
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
5161
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
5162
+ */
5163
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
5164
+ tagNameCheck: {
5165
+ writable: true,
5166
+ configurable: false,
5167
+ enumerable: true,
5168
+ value: null
5169
+ },
5170
+ attributeNameCheck: {
5171
+ writable: true,
5172
+ configurable: false,
5173
+ enumerable: true,
5174
+ value: null
5175
+ },
5176
+ allowCustomizedBuiltInElements: {
5177
+ writable: true,
5178
+ configurable: false,
5179
+ enumerable: true,
5180
+ value: false
5181
+ }
5182
+ }));
5183
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
5184
+ let FORBID_TAGS = null;
5185
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
5186
+ let FORBID_ATTR = null;
5187
+ /* Decide if ARIA attributes are okay */
5188
+ let ALLOW_ARIA_ATTR = true;
5189
+ /* Decide if custom data attributes are okay */
5190
+ let ALLOW_DATA_ATTR = true;
5191
+ /* Decide if unknown protocols are okay */
5192
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
5193
+ /* Decide if self-closing tags in attributes are allowed.
5194
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
5195
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
5196
+ /* Output should be safe for common template engines.
5197
+ * This means, DOMPurify removes data attributes, mustaches and ERB
5198
+ */
5199
+ let SAFE_FOR_TEMPLATES = false;
5200
+ /* Output should be safe even for XML used within HTML and alike.
5201
+ * This means, DOMPurify removes comments when containing risky content.
5202
+ */
5203
+ let SAFE_FOR_XML = true;
5204
+ /* Decide if document with <html>... should be returned */
5205
+ let WHOLE_DOCUMENT = false;
5206
+ /* Track whether config is already set on this instance of DOMPurify. */
5207
+ let SET_CONFIG = false;
5208
+ /* Decide if all elements (e.g. style, script) must be children of
5209
+ * document.body. By default, browsers might move them to document.head */
5210
+ let FORCE_BODY = false;
5211
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
5212
+ * string (or a TrustedHTML object if Trusted Types are supported).
5213
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
5214
+ */
5215
+ let RETURN_DOM = false;
5216
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
5217
+ * string (or a TrustedHTML object if Trusted Types are supported) */
5218
+ let RETURN_DOM_FRAGMENT = false;
5219
+ /* Try to return a Trusted Type object instead of a string, return a string in
5220
+ * case Trusted Types are not supported */
5221
+ let RETURN_TRUSTED_TYPE = false;
5222
+ /* Output should be free from DOM clobbering attacks?
5223
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
5224
+ */
5225
+ let SANITIZE_DOM = true;
5226
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
5227
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
5228
+ *
5229
+ * HTML/DOM spec rules that enable DOM Clobbering:
5230
+ * - Named Access on Window (§7.3.3)
5231
+ * - DOM Tree Accessors (§3.1.5)
5232
+ * - Form Element Parent-Child Relations (§4.10.3)
5233
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
5234
+ * - HTMLCollection (§4.2.10.2)
5235
+ *
5236
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
5237
+ * with a constant string, i.e., `user-content-`
5238
+ */
5239
+ let SANITIZE_NAMED_PROPS = false;
5240
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
5241
+ /* Keep element content when removing element? */
5242
+ let KEEP_CONTENT = true;
5243
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
5244
+ * of importing it into a new Document and returning a sanitized copy */
5245
+ let IN_PLACE = false;
5246
+ /* Allow usage of profiles like html, svg and mathMl */
5247
+ let USE_PROFILES = {};
5248
+ /* Tags to ignore content of when KEEP_CONTENT is true */
5249
+ let FORBID_CONTENTS = null;
5250
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
5251
+ /* Tags that are safe for data: URIs */
5252
+ let DATA_URI_TAGS = null;
5253
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
5254
+ /* Attributes safe for values like "javascript:" */
5255
+ let URI_SAFE_ATTRIBUTES = null;
5256
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
5257
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
5258
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
5259
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
5260
+ /* Document namespace */
5261
+ let NAMESPACE = HTML_NAMESPACE;
5262
+ let IS_EMPTY_INPUT = false;
5263
+ /* Allowed XHTML+XML namespaces */
5264
+ let ALLOWED_NAMESPACES = null;
5265
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
5266
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
5267
+ let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
5268
+ // Certain elements are allowed in both SVG and HTML
5269
+ // namespace. We need to specify them explicitly
5270
+ // so that they don't get erroneously deleted from
5271
+ // HTML namespace.
5272
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
5273
+ /* Parsing of strict XHTML documents */
5274
+ let PARSER_MEDIA_TYPE = null;
5275
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
5276
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
5277
+ let transformCaseFunc = null;
5278
+ /* Keep a reference to config to pass to hooks */
5279
+ let CONFIG = null;
5280
+ /* Ideally, do not touch anything below this line */
5281
+ /* ______________________________________________ */
5282
+ const formElement = document.createElement('form');
5283
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
5284
+ return testValue instanceof RegExp || testValue instanceof Function;
5285
+ };
5286
+ /**
5287
+ * _parseConfig
5288
+ *
5289
+ * @param cfg optional config literal
5290
+ */
5291
+ // eslint-disable-next-line complexity
5292
+ const _parseConfig = function _parseConfig() {
5293
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
5294
+ if (CONFIG && CONFIG === cfg) {
5295
+ return;
5296
+ }
5297
+ /* Shield configuration object from tampering */
5298
+ if (!cfg || typeof cfg !== 'object') {
5299
+ cfg = {};
5300
+ }
5301
+ /* Shield configuration object from prototype pollution */
5302
+ cfg = clone(cfg);
5303
+ PARSER_MEDIA_TYPE =
5304
+ // eslint-disable-next-line unicorn/prefer-includes
5305
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
5306
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
5307
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
5308
+ /* Set configuration parameters */
5309
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
5310
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
5311
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
5312
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
5313
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
5314
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
5315
+ FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
5316
+ FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
5317
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
5318
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
5319
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
5320
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
5321
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
5322
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
5323
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
5324
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
5325
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
5326
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
5327
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
5328
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
5329
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
5330
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
5331
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
5332
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
5333
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
5334
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
5335
+ MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
5336
+ HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
5337
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
5338
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
5339
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
5340
+ }
5341
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
5342
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
5343
+ }
5344
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
5345
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
5346
+ }
5347
+ if (SAFE_FOR_TEMPLATES) {
5348
+ ALLOW_DATA_ATTR = false;
5349
+ }
5350
+ if (RETURN_DOM_FRAGMENT) {
5351
+ RETURN_DOM = true;
5352
+ }
5353
+ /* Parse profile info */
5354
+ if (USE_PROFILES) {
5355
+ ALLOWED_TAGS = addToSet({}, text);
5356
+ ALLOWED_ATTR = [];
5357
+ if (USE_PROFILES.html === true) {
5358
+ addToSet(ALLOWED_TAGS, html$1);
5359
+ addToSet(ALLOWED_ATTR, html);
5360
+ }
5361
+ if (USE_PROFILES.svg === true) {
5362
+ addToSet(ALLOWED_TAGS, svg$1);
5363
+ addToSet(ALLOWED_ATTR, svg);
5364
+ addToSet(ALLOWED_ATTR, xml);
5365
+ }
5366
+ if (USE_PROFILES.svgFilters === true) {
5367
+ addToSet(ALLOWED_TAGS, svgFilters);
5368
+ addToSet(ALLOWED_ATTR, svg);
5369
+ addToSet(ALLOWED_ATTR, xml);
5370
+ }
5371
+ if (USE_PROFILES.mathMl === true) {
5372
+ addToSet(ALLOWED_TAGS, mathMl$1);
5373
+ addToSet(ALLOWED_ATTR, mathMl);
5374
+ addToSet(ALLOWED_ATTR, xml);
5375
+ }
5376
+ }
5377
+ /* Merge configuration parameters */
5378
+ if (cfg.ADD_TAGS) {
5379
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
5380
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
5381
+ }
5382
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
5383
+ }
5384
+ if (cfg.ADD_ATTR) {
5385
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
5386
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
5387
+ }
5388
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
5389
+ }
5390
+ if (cfg.ADD_URI_SAFE_ATTR) {
5391
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
5392
+ }
5393
+ if (cfg.FORBID_CONTENTS) {
5394
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
5395
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
5396
+ }
5397
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
5398
+ }
5399
+ /* Add #text in case KEEP_CONTENT is set to true */
5400
+ if (KEEP_CONTENT) {
5401
+ ALLOWED_TAGS['#text'] = true;
5402
+ }
5403
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
5404
+ if (WHOLE_DOCUMENT) {
5405
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
5406
+ }
5407
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
5408
+ if (ALLOWED_TAGS.table) {
5409
+ addToSet(ALLOWED_TAGS, ['tbody']);
5410
+ delete FORBID_TAGS.tbody;
5411
+ }
5412
+ if (cfg.TRUSTED_TYPES_POLICY) {
5413
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
5414
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
5415
+ }
5416
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
5417
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
5418
+ }
5419
+ // Overwrite existing TrustedTypes policy.
5420
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
5421
+ // Sign local variables required by `sanitize`.
5422
+ emptyHTML = trustedTypesPolicy.createHTML('');
5423
+ } else {
5424
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
5425
+ if (trustedTypesPolicy === undefined) {
5426
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
5427
+ }
5428
+ // If creating the internal policy succeeded sign internal variables.
5429
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
5430
+ emptyHTML = trustedTypesPolicy.createHTML('');
5431
+ }
5432
+ }
5433
+ // Prevent further manipulation of configuration.
5434
+ // Not available in IE8, Safari 5, etc.
5435
+ if (freeze) {
5436
+ freeze(cfg);
5437
+ }
5438
+ CONFIG = cfg;
5439
+ };
5440
+ /* Keep track of all possible SVG and MathML tags
5441
+ * so that we can perform the namespace checks
5442
+ * correctly. */
5443
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
5444
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
5445
+ /**
5446
+ * @param element a DOM element whose namespace is being checked
5447
+ * @returns Return false if the element has a
5448
+ * namespace that a spec-compliant parser would never
5449
+ * return. Return true otherwise.
5450
+ */
5451
+ const _checkValidNamespace = function _checkValidNamespace(element) {
5452
+ let parent = getParentNode(element);
5453
+ // In JSDOM, if we're inside shadow DOM, then parentNode
5454
+ // can be null. We just simulate parent in this case.
5455
+ if (!parent || !parent.tagName) {
5456
+ parent = {
5457
+ namespaceURI: NAMESPACE,
5458
+ tagName: 'template'
5459
+ };
5460
+ }
5461
+ const tagName = stringToLowerCase(element.tagName);
5462
+ const parentTagName = stringToLowerCase(parent.tagName);
5463
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
5464
+ return false;
5465
+ }
5466
+ if (element.namespaceURI === SVG_NAMESPACE) {
5467
+ // The only way to switch from HTML namespace to SVG
5468
+ // is via <svg>. If it happens via any other tag, then
5469
+ // it should be killed.
5470
+ if (parent.namespaceURI === HTML_NAMESPACE) {
5471
+ return tagName === 'svg';
5472
+ }
5473
+ // The only way to switch from MathML to SVG is via`
5474
+ // svg if parent is either <annotation-xml> or MathML
5475
+ // text integration points.
5476
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
5477
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
5478
+ }
5479
+ // We only allow elements that are defined in SVG
5480
+ // spec. All others are disallowed in SVG namespace.
5481
+ return Boolean(ALL_SVG_TAGS[tagName]);
5482
+ }
5483
+ if (element.namespaceURI === MATHML_NAMESPACE) {
5484
+ // The only way to switch from HTML namespace to MathML
5485
+ // is via <math>. If it happens via any other tag, then
5486
+ // it should be killed.
5487
+ if (parent.namespaceURI === HTML_NAMESPACE) {
5488
+ return tagName === 'math';
5489
+ }
5490
+ // The only way to switch from SVG to MathML is via
5491
+ // <math> and HTML integration points
5492
+ if (parent.namespaceURI === SVG_NAMESPACE) {
5493
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
5494
+ }
5495
+ // We only allow elements that are defined in MathML
5496
+ // spec. All others are disallowed in MathML namespace.
5497
+ return Boolean(ALL_MATHML_TAGS[tagName]);
5498
+ }
5499
+ if (element.namespaceURI === HTML_NAMESPACE) {
5500
+ // The only way to switch from SVG to HTML is via
5501
+ // HTML integration points, and from MathML to HTML
5502
+ // is via MathML text integration points
5503
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
5504
+ return false;
5505
+ }
5506
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
5507
+ return false;
5508
+ }
5509
+ // We disallow tags that are specific for MathML
5510
+ // or SVG and should never appear in HTML namespace
5511
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
5512
+ }
5513
+ // For XHTML and XML documents that support custom namespaces
5514
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
5515
+ return true;
5516
+ }
5517
+ // The code should never reach this place (this means
5518
+ // that the element somehow got namespace that is not
5519
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
5520
+ // Return false just in case.
5521
+ return false;
5522
+ };
5523
+ /**
5524
+ * _forceRemove
5525
+ *
5526
+ * @param node a DOM node
5527
+ */
5528
+ const _forceRemove = function _forceRemove(node) {
5529
+ arrayPush(DOMPurify.removed, {
5530
+ element: node
5531
+ });
5532
+ try {
5533
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
5534
+ getParentNode(node).removeChild(node);
5535
+ } catch (_) {
5536
+ remove(node);
5537
+ }
5538
+ };
5539
+ /**
5540
+ * _removeAttribute
5541
+ *
5542
+ * @param name an Attribute name
5543
+ * @param element a DOM node
5544
+ */
5545
+ const _removeAttribute = function _removeAttribute(name, element) {
5546
+ try {
5547
+ arrayPush(DOMPurify.removed, {
5548
+ attribute: element.getAttributeNode(name),
5549
+ from: element
5550
+ });
5551
+ } catch (_) {
5552
+ arrayPush(DOMPurify.removed, {
5553
+ attribute: null,
5554
+ from: element
5555
+ });
5556
+ }
5557
+ element.removeAttribute(name);
5558
+ // We void attribute values for unremovable "is" attributes
5559
+ if (name === 'is') {
5560
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
5561
+ try {
5562
+ _forceRemove(element);
5563
+ } catch (_) {}
5564
+ } else {
5565
+ try {
5566
+ element.setAttribute(name, '');
5567
+ } catch (_) {}
5568
+ }
5569
+ }
5570
+ };
5571
+ /**
5572
+ * _initDocument
5573
+ *
5574
+ * @param dirty - a string of dirty markup
5575
+ * @return a DOM, filled with the dirty markup
5576
+ */
5577
+ const _initDocument = function _initDocument(dirty) {
5578
+ /* Create a HTML document */
5579
+ let doc = null;
5580
+ let leadingWhitespace = null;
5581
+ if (FORCE_BODY) {
5582
+ dirty = '<remove></remove>' + dirty;
5583
+ } else {
5584
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
5585
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
5586
+ leadingWhitespace = matches && matches[0];
5587
+ }
5588
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
5589
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
5590
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
5591
+ }
5592
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
5593
+ /*
5594
+ * Use the DOMParser API by default, fallback later if needs be
5595
+ * DOMParser not work for svg when has multiple root element.
5596
+ */
5597
+ if (NAMESPACE === HTML_NAMESPACE) {
5598
+ try {
5599
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
5600
+ } catch (_) {}
5601
+ }
5602
+ /* Use createHTMLDocument in case DOMParser is not available */
5603
+ if (!doc || !doc.documentElement) {
5604
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
5605
+ try {
5606
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
5607
+ } catch (_) {
5608
+ // Syntax error if dirtyPayload is invalid xml
5609
+ }
5610
+ }
5611
+ const body = doc.body || doc.documentElement;
5612
+ if (dirty && leadingWhitespace) {
5613
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
5614
+ }
5615
+ /* Work on whole document or just its body */
5616
+ if (NAMESPACE === HTML_NAMESPACE) {
5617
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
5618
+ }
5619
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
5620
+ };
5621
+ /**
5622
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
5623
+ *
5624
+ * @param root The root element or node to start traversing on.
5625
+ * @return The created NodeIterator
5626
+ */
5627
+ const _createNodeIterator = function _createNodeIterator(root) {
5628
+ return createNodeIterator.call(root.ownerDocument || root, root,
5629
+ // eslint-disable-next-line no-bitwise
5630
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
5631
+ };
5632
+ /**
5633
+ * _isClobbered
5634
+ *
5635
+ * @param element element to check for clobbering attacks
5636
+ * @return true if clobbered, false if safe
5637
+ */
5638
+ const _isClobbered = function _isClobbered(element) {
5639
+ return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
5640
+ };
5641
+ /**
5642
+ * Checks whether the given object is a DOM node.
5643
+ *
5644
+ * @param value object to check whether it's a DOM node
5645
+ * @return true is object is a DOM node
5646
+ */
5647
+ const _isNode = function _isNode(value) {
5648
+ return typeof Node === 'function' && value instanceof Node;
5649
+ };
5650
+ function _executeHooks(hooks, currentNode, data) {
5651
+ arrayForEach(hooks, hook => {
5652
+ hook.call(DOMPurify, currentNode, data, CONFIG);
5653
+ });
5654
+ }
5655
+ /**
5656
+ * _sanitizeElements
5657
+ *
5658
+ * @protect nodeName
5659
+ * @protect textContent
5660
+ * @protect removeChild
5661
+ * @param currentNode to check for permission to exist
5662
+ * @return true if node was killed, false if left alive
5663
+ */
5664
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
5665
+ let content = null;
5666
+ /* Execute a hook if present */
5667
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
5668
+ /* Check if element is clobbered or can clobber */
5669
+ if (_isClobbered(currentNode)) {
5670
+ _forceRemove(currentNode);
5671
+ return true;
5672
+ }
5673
+ /* Now let's check the element's type and name */
5674
+ const tagName = transformCaseFunc(currentNode.nodeName);
5675
+ /* Execute a hook if present */
5676
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
5677
+ tagName,
5678
+ allowedTags: ALLOWED_TAGS
5679
+ });
5680
+ /* Detect mXSS attempts abusing namespace confusion */
5681
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
5682
+ _forceRemove(currentNode);
5683
+ return true;
5684
+ }
5685
+ /* Remove any occurrence of processing instructions */
5686
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
5687
+ _forceRemove(currentNode);
5688
+ return true;
5689
+ }
5690
+ /* Remove any kind of possibly harmful comments */
5691
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
5692
+ _forceRemove(currentNode);
5693
+ return true;
5694
+ }
5695
+ /* Remove element if anything forbids its presence */
5696
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
5697
+ /* Check if we have a custom element to handle */
5698
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
5699
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
5700
+ return false;
5701
+ }
5702
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
5703
+ return false;
5704
+ }
5705
+ }
5706
+ /* Keep content except for bad-listed elements */
5707
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
5708
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
5709
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
5710
+ if (childNodes && parentNode) {
5711
+ const childCount = childNodes.length;
5712
+ for (let i = childCount - 1; i >= 0; --i) {
5713
+ const childClone = cloneNode(childNodes[i], true);
5714
+ childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
5715
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
5716
+ }
5717
+ }
5718
+ }
5719
+ _forceRemove(currentNode);
5720
+ return true;
5721
+ }
5722
+ /* Check whether element has a valid namespace */
5723
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
5724
+ _forceRemove(currentNode);
5725
+ return true;
5726
+ }
5727
+ /* Make sure that older browsers don't get fallback-tag mXSS */
5728
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
5729
+ _forceRemove(currentNode);
5730
+ return true;
5731
+ }
5732
+ /* Sanitize element content to be template-safe */
5733
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
5734
+ /* Get the element's text content */
5735
+ content = currentNode.textContent;
5736
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
5737
+ content = stringReplace(content, expr, ' ');
5738
+ });
5739
+ if (currentNode.textContent !== content) {
5740
+ arrayPush(DOMPurify.removed, {
5741
+ element: currentNode.cloneNode()
5742
+ });
5743
+ currentNode.textContent = content;
5744
+ }
5745
+ }
5746
+ /* Execute a hook if present */
5747
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
5748
+ return false;
5749
+ };
5750
+ /**
5751
+ * _isValidAttribute
5752
+ *
5753
+ * @param lcTag Lowercase tag name of containing element.
5754
+ * @param lcName Lowercase attribute name.
5755
+ * @param value Attribute value.
5756
+ * @return Returns true if `value` is valid, otherwise false.
5757
+ */
5758
+ // eslint-disable-next-line complexity
5759
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
5760
+ /* Make sure attribute cannot clobber */
5761
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
5762
+ return false;
5763
+ }
5764
+ /* Allow valid data-* attributes: At least one character after "-"
5765
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
5766
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
5767
+ We don't need to check the value; it's always URI safe. */
5768
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
5769
+ if (
5770
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
5771
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
5772
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
5773
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) ||
5774
+ // Alternative, second condition checks if it's an `is`-attribute, AND
5775
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
5776
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
5777
+ return false;
5778
+ }
5779
+ /* Check value is safe. First, is attr inert? If so, is safe */
5780
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
5781
+ return false;
5782
+ } else ;
5783
+ return true;
5784
+ };
5785
+ /**
5786
+ * _isBasicCustomElement
5787
+ * checks if at least one dash is included in tagName, and it's not the first char
5788
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
5789
+ *
5790
+ * @param tagName name of the tag of the node to sanitize
5791
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
5792
+ */
5793
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
5794
+ return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
5795
+ };
5796
+ /**
5797
+ * _sanitizeAttributes
5798
+ *
5799
+ * @protect attributes
5800
+ * @protect nodeName
5801
+ * @protect removeAttribute
5802
+ * @protect setAttribute
5803
+ *
5804
+ * @param currentNode to sanitize
5805
+ */
5806
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
5807
+ /* Execute a hook if present */
5808
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
5809
+ const {
5810
+ attributes
5811
+ } = currentNode;
5812
+ /* Check if we have attributes; if not we might have a text node */
5813
+ if (!attributes || _isClobbered(currentNode)) {
5814
+ return;
5815
+ }
5816
+ const hookEvent = {
5817
+ attrName: '',
5818
+ attrValue: '',
5819
+ keepAttr: true,
5820
+ allowedAttributes: ALLOWED_ATTR,
5821
+ forceKeepAttr: undefined
5822
+ };
5823
+ let l = attributes.length;
5824
+ /* Go backwards over all attributes; safely remove bad ones */
5825
+ while (l--) {
5826
+ const attr = attributes[l];
5827
+ const {
5828
+ name,
5829
+ namespaceURI,
5830
+ value: attrValue
5831
+ } = attr;
5832
+ const lcName = transformCaseFunc(name);
5833
+ let value = name === 'value' ? attrValue : stringTrim(attrValue);
5834
+ /* Execute a hook if present */
5835
+ hookEvent.attrName = lcName;
5836
+ hookEvent.attrValue = value;
5837
+ hookEvent.keepAttr = true;
5838
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
5839
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
5840
+ value = hookEvent.attrValue;
5841
+ /* Full DOM Clobbering protection via namespace isolation,
5842
+ * Prefix id and name attributes with `user-content-`
5843
+ */
5844
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
5845
+ // Remove the attribute with this value
5846
+ _removeAttribute(name, currentNode);
5847
+ // Prefix the value and later re-create the attribute with the sanitized value
5848
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
5849
+ }
5850
+ /* Work around a security issue with comments inside attributes */
5851
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
5852
+ _removeAttribute(name, currentNode);
5853
+ continue;
5854
+ }
5855
+ /* Did the hooks approve of the attribute? */
5856
+ if (hookEvent.forceKeepAttr) {
5857
+ continue;
5858
+ }
5859
+ /* Remove attribute */
5860
+ _removeAttribute(name, currentNode);
5861
+ /* Did the hooks approve of the attribute? */
5862
+ if (!hookEvent.keepAttr) {
5863
+ continue;
5864
+ }
5865
+ /* Work around a security issue in jQuery 3.0 */
5866
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
5867
+ _removeAttribute(name, currentNode);
5868
+ continue;
5869
+ }
5870
+ /* Sanitize attribute content to be template-safe */
5871
+ if (SAFE_FOR_TEMPLATES) {
5872
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
5873
+ value = stringReplace(value, expr, ' ');
5874
+ });
5875
+ }
5876
+ /* Is `value` valid for this attribute? */
5877
+ const lcTag = transformCaseFunc(currentNode.nodeName);
5878
+ if (!_isValidAttribute(lcTag, lcName, value)) {
5879
+ continue;
5880
+ }
5881
+ /* Handle attributes that require Trusted Types */
5882
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
5883
+ if (namespaceURI) ; else {
5884
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
5885
+ case 'TrustedHTML':
5886
+ {
5887
+ value = trustedTypesPolicy.createHTML(value);
5888
+ break;
5889
+ }
5890
+ case 'TrustedScriptURL':
5891
+ {
5892
+ value = trustedTypesPolicy.createScriptURL(value);
5893
+ break;
5894
+ }
5895
+ }
5896
+ }
5897
+ }
5898
+ /* Handle invalid data-* attribute set by try-catching it */
5899
+ try {
5900
+ if (namespaceURI) {
5901
+ currentNode.setAttributeNS(namespaceURI, name, value);
5902
+ } else {
5903
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
5904
+ currentNode.setAttribute(name, value);
5905
+ }
5906
+ if (_isClobbered(currentNode)) {
5907
+ _forceRemove(currentNode);
5908
+ } else {
5909
+ arrayPop(DOMPurify.removed);
5910
+ }
5911
+ } catch (_) {}
5912
+ }
5913
+ /* Execute a hook if present */
5914
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
5915
+ };
5916
+ /**
5917
+ * _sanitizeShadowDOM
5918
+ *
5919
+ * @param fragment to iterate over recursively
5920
+ */
5921
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
5922
+ let shadowNode = null;
5923
+ const shadowIterator = _createNodeIterator(fragment);
5924
+ /* Execute a hook if present */
5925
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
5926
+ while (shadowNode = shadowIterator.nextNode()) {
5927
+ /* Execute a hook if present */
5928
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
5929
+ /* Sanitize tags and elements */
5930
+ _sanitizeElements(shadowNode);
5931
+ /* Check attributes next */
5932
+ _sanitizeAttributes(shadowNode);
5933
+ /* Deep shadow DOM detected */
5934
+ if (shadowNode.content instanceof DocumentFragment) {
5935
+ _sanitizeShadowDOM(shadowNode.content);
5936
+ }
5937
+ }
5938
+ /* Execute a hook if present */
5939
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
5940
+ };
5941
+ // eslint-disable-next-line complexity
5942
+ DOMPurify.sanitize = function (dirty) {
5943
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5944
+ let body = null;
5945
+ let importedNode = null;
5946
+ let currentNode = null;
5947
+ let returnNode = null;
5948
+ /* Make sure we have a string to sanitize.
5949
+ DO NOT return early, as this will return the wrong type if
5950
+ the user has requested a DOM object rather than a string */
5951
+ IS_EMPTY_INPUT = !dirty;
5952
+ if (IS_EMPTY_INPUT) {
5953
+ dirty = '<!-->';
5954
+ }
5955
+ /* Stringify, in case dirty is an object */
5956
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
5957
+ if (typeof dirty.toString === 'function') {
5958
+ dirty = dirty.toString();
5959
+ if (typeof dirty !== 'string') {
5960
+ throw typeErrorCreate('dirty is not a string, aborting');
5961
+ }
5962
+ } else {
5963
+ throw typeErrorCreate('toString is not a function');
5964
+ }
5965
+ }
5966
+ /* Return dirty HTML if DOMPurify cannot run */
5967
+ if (!DOMPurify.isSupported) {
5968
+ return dirty;
5969
+ }
5970
+ /* Assign config vars */
5971
+ if (!SET_CONFIG) {
5972
+ _parseConfig(cfg);
5973
+ }
5974
+ /* Clean up removed elements */
5975
+ DOMPurify.removed = [];
5976
+ /* Check if dirty is correctly typed for IN_PLACE */
5977
+ if (typeof dirty === 'string') {
5978
+ IN_PLACE = false;
5979
+ }
5980
+ if (IN_PLACE) {
5981
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
5982
+ if (dirty.nodeName) {
5983
+ const tagName = transformCaseFunc(dirty.nodeName);
5984
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
5985
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
5986
+ }
5987
+ }
5988
+ } else if (dirty instanceof Node) {
5989
+ /* If dirty is a DOM element, append to an empty document to avoid
5990
+ elements being stripped by the parser */
5991
+ body = _initDocument('<!---->');
5992
+ importedNode = body.ownerDocument.importNode(dirty, true);
5993
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
5994
+ /* Node is already a body, use as is */
5995
+ body = importedNode;
5996
+ } else if (importedNode.nodeName === 'HTML') {
5997
+ body = importedNode;
5998
+ } else {
5999
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
6000
+ body.appendChild(importedNode);
6001
+ }
6002
+ } else {
6003
+ /* Exit directly if we have nothing to do */
6004
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
6005
+ // eslint-disable-next-line unicorn/prefer-includes
6006
+ dirty.indexOf('<') === -1) {
6007
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
6008
+ }
6009
+ /* Initialize the document to work on */
6010
+ body = _initDocument(dirty);
6011
+ /* Check we have a DOM node from the data */
6012
+ if (!body) {
6013
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
6014
+ }
6015
+ }
6016
+ /* Remove first element node (ours) if FORCE_BODY is set */
6017
+ if (body && FORCE_BODY) {
6018
+ _forceRemove(body.firstChild);
6019
+ }
6020
+ /* Get node iterator */
6021
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
6022
+ /* Now start iterating over the created document */
6023
+ while (currentNode = nodeIterator.nextNode()) {
6024
+ /* Sanitize tags and elements */
6025
+ _sanitizeElements(currentNode);
6026
+ /* Check attributes next */
6027
+ _sanitizeAttributes(currentNode);
6028
+ /* Shadow DOM detected, sanitize it */
6029
+ if (currentNode.content instanceof DocumentFragment) {
6030
+ _sanitizeShadowDOM(currentNode.content);
6031
+ }
6032
+ }
6033
+ /* If we sanitized `dirty` in-place, return it. */
6034
+ if (IN_PLACE) {
6035
+ return dirty;
6036
+ }
6037
+ /* Return sanitized string or DOM */
6038
+ if (RETURN_DOM) {
6039
+ if (RETURN_DOM_FRAGMENT) {
6040
+ returnNode = createDocumentFragment.call(body.ownerDocument);
6041
+ while (body.firstChild) {
6042
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
6043
+ returnNode.appendChild(body.firstChild);
6044
+ }
6045
+ } else {
6046
+ returnNode = body;
6047
+ }
6048
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
6049
+ /*
6050
+ AdoptNode() is not used because internal state is not reset
6051
+ (e.g. the past names map of a HTMLFormElement), this is safe
6052
+ in theory but we would rather not risk another attack vector.
6053
+ The state that is cloned by importNode() is explicitly defined
6054
+ by the specs.
6055
+ */
6056
+ returnNode = importNode.call(originalDocument, returnNode, true);
6057
+ }
6058
+ return returnNode;
6059
+ }
6060
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
6061
+ /* Serialize doctype if allowed */
6062
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
6063
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
6064
+ }
6065
+ /* Sanitize final string template-safe */
6066
+ if (SAFE_FOR_TEMPLATES) {
6067
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
6068
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
6069
+ });
6070
+ }
6071
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
6072
+ };
6073
+ DOMPurify.setConfig = function () {
6074
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6075
+ _parseConfig(cfg);
6076
+ SET_CONFIG = true;
6077
+ };
6078
+ DOMPurify.clearConfig = function () {
6079
+ CONFIG = null;
6080
+ SET_CONFIG = false;
6081
+ };
6082
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
6083
+ /* Initialize shared config vars if necessary. */
6084
+ if (!CONFIG) {
6085
+ _parseConfig({});
6086
+ }
6087
+ const lcTag = transformCaseFunc(tag);
6088
+ const lcName = transformCaseFunc(attr);
6089
+ return _isValidAttribute(lcTag, lcName, value);
6090
+ };
6091
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
6092
+ if (typeof hookFunction !== 'function') {
6093
+ return;
6094
+ }
6095
+ arrayPush(hooks[entryPoint], hookFunction);
6096
+ };
6097
+ DOMPurify.removeHook = function (entryPoint) {
6098
+ return arrayPop(hooks[entryPoint]);
6099
+ };
6100
+ DOMPurify.removeHooks = function (entryPoint) {
6101
+ hooks[entryPoint] = [];
6102
+ };
6103
+ DOMPurify.removeAllHooks = function () {
6104
+ hooks = _createHooksMap();
6105
+ };
6106
+ return DOMPurify;
6107
+ }
6108
+ var purify = createDOMPurify();
6466
6109
 
6467
6110
  const noop$1 = () => { };
6468
6111
 
@@ -6525,7 +6168,7 @@ const getArrowStyle = (position, x, arrowWidth, tooltipHeight, tooltipWidth) =>
6525
6168
  };
6526
6169
  const HTMLTip = ({ text }) => {
6527
6170
  return React__default.createElement('div', {
6528
- dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(text) },
6171
+ dangerouslySetInnerHTML: { __html: purify.sanitize(text) },
6529
6172
  });
6530
6173
  };
6531
6174
  /** Tooltips can cause SystemTests to be flaky, so we suppress them in Playwright and Protractor */
@@ -11930,7 +11573,7 @@ var colors = {
11930
11573
  neutral80: 'hsl(0, 0%, 20%)',
11931
11574
  neutral90: 'hsl(0, 0%, 10%)'
11932
11575
  };
11933
- var borderRadius = 4;
11576
+ var borderRadius$1 = 4;
11934
11577
  // Used to calculate consistent margin/padding on elements
11935
11578
  var baseUnit = 4;
11936
11579
  // The minimum height of the control
@@ -11943,7 +11586,7 @@ var spacing = {
11943
11586
  menuGutter: menuGutter
11944
11587
  };
11945
11588
  var defaultTheme = {
11946
- borderRadius: borderRadius,
11589
+ borderRadius: borderRadius$1,
11947
11590
  colors: colors,
11948
11591
  spacing: spacing
11949
11592
  };
@@ -13676,8 +13319,8 @@ var CreatableSelect$1 = CreatableSelect;
13676
13319
 
13677
13320
  const baseClasses$2 = ['focus:tw-ring-0', 'disabled:tw-cursor-not-allowed'].join(' ');
13678
13321
  const containerStyles = ['tw-bg-white', 'dark:tw-bg-sq-dark-background'].join(' ');
13679
- const errorClasses$1 = 'tw-border-sq-danger-color';
13680
- const borderColorClasses$1 = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
13322
+ const errorClasses$2 = 'tw-border-sq-danger-color';
13323
+ const borderColorClasses$2 = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
13681
13324
  const borderStyles$3 = [
13682
13325
  'tw-border-solid',
13683
13326
  'tw-border',
@@ -13815,7 +13458,7 @@ const Select = ({ options, value, placeholder = 'select', noOptionsMessage = 'no
13815
13458
  else if (inputGroup === 'right') {
13816
13459
  border = menuIsOpen ? 'tw-rounded-tr-sm' : 'tw-rounded-r-sm';
13817
13460
  }
13818
- const appliedClasses = `${borderStyles$3} ${border} ${showError ? errorClasses$1 : borderColorClasses$1} ${small ? 'reactSelectMinHeightSmall' : 'reactSelectMinHeight'} `;
13461
+ const appliedClasses = `${borderStyles$3} ${border} ${showError ? errorClasses$2 : borderColorClasses$2} ${small ? 'reactSelectMinHeightSmall' : 'reactSelectMinHeight'} `;
13819
13462
  return `${appliedClasses} ${baseClasses$2} specSelectControl ${isDisabled ? disabledClasses$3 : ''} ${small ? 'tw-pl-2 tw-pr-1' : 'tw-pl-2.5 tw-pr-1.5'}`;
13820
13463
  },
13821
13464
  placeholder: () => placeholderStyles,
@@ -16188,22 +15831,22 @@ const ButtonWithDropdown = ({ dropdownItems, triggerIcon, id, extraClassNames, c
16188
15831
 
16189
15832
  const baseClasses$1 = 'tw-mx-auto tw-p-4 tw-leading-normal tw-outline-none tw-py-2 tw-px-3 tw-rounded-sm tw-w-full' +
16190
15833
  ' tw-border-solid tw-border tw-text-sm tw-flex tw-flex-col tw-justify-center tw-items-center';
16191
- const darkTheme = 'dark:tw-bg-sq-colored-hover-dark dark:tw-text-sq-dark-text';
16192
- const lightTheme = 'tw-text-sq-text-color tw-bg-sq-colored-hover';
16193
- const errorClasses = 'tw-border-sq-danger-color';
16194
- const borderColorClasses = 'tw-border-sq-color-dark';
15834
+ const darkTheme$1 = 'dark:tw-bg-sq-colored-hover-dark dark:tw-text-sq-dark-text';
15835
+ const lightTheme$1 = 'tw-text-sq-text-color tw-bg-sq-colored-hover';
15836
+ const errorClasses$1 = 'tw-border-sq-danger-color';
15837
+ const borderColorClasses$1 = 'tw-border-sq-color-dark';
16195
15838
  /**
16196
15839
  * Alert.
16197
15840
  */
16198
15841
  const Alert = ({ children, dismissible = true, onClose, show = true, variant, testId, id, extraClassNames, }) => {
16199
15842
  const appliedTheme = {
16200
- theme: `${lightTheme} ${darkTheme}`,
15843
+ theme: `${lightTheme$1} ${darkTheme$1}`,
16201
15844
  danger: 'tw-text-sq-text-color tw-bg-sq-danger-color',
16202
15845
  warning: 'tw-bg-sq-bg-warning-color tw-text-sq-text-color',
16203
15846
  };
16204
15847
  const appliedBorderTheme = {
16205
- theme: borderColorClasses,
16206
- danger: errorClasses,
15848
+ theme: borderColorClasses$1,
15849
+ danger: errorClasses$1,
16207
15850
  warning: 'tw-border-none',
16208
15851
  };
16209
15852
  const appliedClasses = `${baseClasses$1} ${appliedTheme[variant]} ${extraClassNames} ${appliedBorderTheme[variant]}`;
@@ -16280,25 +15923,329 @@ const SeeqActionDropdown = ({ seeqActionDropdownItems, trigger, id, extraClassNa
16280
15923
  };
16281
15924
 
16282
15925
  const baseClasses = 'tw-flex tw-outline-none tw-rounded-sm tw-w-full tw-relative tw-flex-wrap tw-items-stretch';
15926
+ const errorClasses = 'tw-border-sq-danger-color';
15927
+ const borderColorClasses = [
15928
+ 'tw-border-sq-disabled-gray',
15929
+ 'dark:tw-border-sq-dark-disabled-gray',
15930
+ 'dark:focus:tw-border-sq-color-dark-dark',
15931
+ 'dark:active:tw-border-sq-color-dark-dark',
15932
+ 'focus:tw-border-sq-color-dark',
15933
+ 'active:tw-border-sq-color-dark',
15934
+ ].join(' ');
15935
+ let borderRadius = 'tw-rounded-sm tw-rounded-r-none';
15936
+ const fieldClasses = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3' + 'tw-p-1 tw-border-solid tw-border';
15937
+ const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text disabled:dark:tw-text-sq-dark-text-lighter';
15938
+ const lightTheme = 'tw-text-sq-text-color disabled:tw-text-sq-darkish-gray';
16283
15939
  /**
16284
15940
  * InputGroup.
16285
15941
  */
16286
- const InputGroup = ({ readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, onClick, name, value, placeholder, append = [], extraClassNames = '', id, testId, showError, required, autoComplete, autoFocus, disabled, type, step, min, max, ...tooltipProps }) => {
15942
+ const InputGroup = ({ readonly = false, onChange, onKeyUp, onFocus, onBlur, onKeyDown, name, value, placeholder, append = [], extraClassNames = '', id, testId, showError, required, autoComplete, autoFocus, disabled, type, step, min, max, field, ...tooltipProps }) => {
16287
15943
  const tooltipData = getQTipData(tooltipProps);
16288
15944
  const appliedClasses = `${baseClasses} ${extraClassNames}`;
16289
- const borderColorClasses = [
16290
- 'tw-border-sq-disabled-gray',
16291
- 'dark:tw-border-sq-dark-disabled-gray',
16292
- 'dark:focus:tw-border-sq-color-dark-dark',
16293
- 'dark:active:tw-border-sq-color-dark-dark',
16294
- 'focus:tw-border-sq-color-dark',
16295
- 'active:tw-border-sq-color-dark',
16296
- ].join(' ');
16297
- const textfield = (React__default.createElement(TextField, { readonly: onClick ? true : readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, extraClassNames: `tw-flex tw-flex-1 tw-rounded-r-none focus:tw-z-30 ${onClick ? 'tw-cursor-pointer' : ''} ${extraClassNames}`, ...tooltipData }));
15945
+ const fieldAppliedClasses = `${fieldClasses} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius} ${showError ? errorClasses : borderColorClasses} `;
16298
15946
  return (React__default.createElement("div", { id: id, "data-testid": testId, className: appliedClasses },
16299
- onClick ? (React__default.createElement("div", { onClick: onClick, className: "tw-flex tw-flex-1 tw-cursor-pointer" }, textfield)) : (textfield),
16300
- append.filter(Boolean).map((item, index) => item.variant === 'button' ? (React__default.createElement(Button, { key: index, extraClassNames: "tw-ml-[-1px] focus:tw-z-40 focus:tw-border tw-rounded-l-none tw-rounded-r-none last:tw-rounded-r-sm", onClick: item.buttonProps.onClick, variant: item.buttonProps.variant, icon: item.buttonProps.icon, iconColor: item.buttonProps.iconColor, testId: item.buttonProps.testId, disabled: item.buttonProps.disabled, label: item.buttonProps.label, iconStyle: item.buttonProps.iconStyle })) : (React__default.createElement("div", { key: index, className: `${borderColorClasses} tw-flex tw-items-center tw-h-inputs tw-justify-center tw-rounded-none tw-ml-[-1px] focus:tw-z-40 focus:tw-border last:tw-border last:tw-rounded-r-sm` }, item.element)))));
15947
+ field ? (React__default.createElement("div", { className: `tw-flex tw-flex-1 tw-cursor-pointer active:tw-z-50 ${fieldAppliedClasses}` }, field)) : (React__default.createElement(TextField, { readonly: readonly, onChange: onChange, onKeyUp: onKeyUp, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, name: name, showError: showError, value: value, required: required, placeholder: placeholder, autoComplete: autoComplete, autoFocus: autoFocus, id: id, type: type, disabled: disabled, step: step, min: min, max: max, extraClassNames: `tw-flex tw-flex-1 tw-rounded-r-none focus:tw-z-30 ${extraClassNames}`, ...tooltipData })),
15948
+ append.filter(Boolean).map((item, index) => item.variant === 'button' ? (React__default.createElement(Button, { key: index, extraClassNames: "tw-ml-[-1px] focus:tw-z-40 focus:tw-border tw-rounded-l-none tw-rounded-r-none last:tw-rounded-r-sm", onClick: item.buttonProps.onClick, variant: item.buttonProps.variant, icon: item.buttonProps.icon, iconColor: item.buttonProps.iconColor, testId: item.buttonProps.testId, disabled: item.buttonProps.disabled, label: item.buttonProps.label, iconStyle: item.buttonProps.iconStyle })) : (React__default.createElement("div", { key: index, className: `${borderColorClasses} tw-flex tw-items-center tw-justify-center tw-rounded-none tw-ml-[-1px] active:tw-z-30 active:tw-border tw-border last:tw-rounded-r-sm` }, item.element)))));
15949
+ };
15950
+
15951
+ // packages/react/context/src/createContext.tsx
15952
+ function createContextScope(scopeName, createContextScopeDeps = []) {
15953
+ let defaultContexts = [];
15954
+ function createContext3(rootComponentName, defaultContext) {
15955
+ const BaseContext = React.createContext(defaultContext);
15956
+ const index = defaultContexts.length;
15957
+ defaultContexts = [...defaultContexts, defaultContext];
15958
+ const Provider = (props) => {
15959
+ const { scope, children, ...context } = props;
15960
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
15961
+ const value = React.useMemo(() => context, Object.values(context));
15962
+ return /* @__PURE__ */ jsx$1(Context.Provider, { value, children });
15963
+ };
15964
+ Provider.displayName = rootComponentName + "Provider";
15965
+ function useContext2(consumerName, scope) {
15966
+ const Context = scope?.[scopeName]?.[index] || BaseContext;
15967
+ const context = React.useContext(Context);
15968
+ if (context) return context;
15969
+ if (defaultContext !== void 0) return defaultContext;
15970
+ throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
15971
+ }
15972
+ return [Provider, useContext2];
15973
+ }
15974
+ const createScope = () => {
15975
+ const scopeContexts = defaultContexts.map((defaultContext) => {
15976
+ return React.createContext(defaultContext);
15977
+ });
15978
+ return function useScope(scope) {
15979
+ const contexts = scope?.[scopeName] || scopeContexts;
15980
+ return React.useMemo(
15981
+ () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
15982
+ [scope, contexts]
15983
+ );
15984
+ };
15985
+ };
15986
+ createScope.scopeName = scopeName;
15987
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
15988
+ }
15989
+ function composeContextScopes(...scopes) {
15990
+ const baseScope = scopes[0];
15991
+ if (scopes.length === 1) return baseScope;
15992
+ const createScope = () => {
15993
+ const scopeHooks = scopes.map((createScope2) => ({
15994
+ useScope: createScope2(),
15995
+ scopeName: createScope2.scopeName
15996
+ }));
15997
+ return function useComposedScopes(overrideScopes) {
15998
+ const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
15999
+ const scopeProps = useScope(overrideScopes);
16000
+ const currentScope = scopeProps[`__scope${scopeName}`];
16001
+ return { ...nextScopes2, ...currentScope };
16002
+ }, {});
16003
+ return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
16004
+ };
16005
+ };
16006
+ createScope.scopeName = baseScope.scopeName;
16007
+ return createScope;
16008
+ }
16009
+
16010
+ // packages/react/compose-refs/src/composeRefs.tsx
16011
+ function setRef(ref, value) {
16012
+ if (typeof ref === "function") {
16013
+ return ref(value);
16014
+ } else if (ref !== null && ref !== void 0) {
16015
+ ref.current = value;
16016
+ }
16017
+ }
16018
+ function composeRefs(...refs) {
16019
+ return (node) => {
16020
+ let hasCleanup = false;
16021
+ const cleanups = refs.map((ref) => {
16022
+ const cleanup = setRef(ref, node);
16023
+ if (!hasCleanup && typeof cleanup == "function") {
16024
+ hasCleanup = true;
16025
+ }
16026
+ return cleanup;
16027
+ });
16028
+ if (hasCleanup) {
16029
+ return () => {
16030
+ for (let i = 0; i < cleanups.length; i++) {
16031
+ const cleanup = cleanups[i];
16032
+ if (typeof cleanup == "function") {
16033
+ cleanup();
16034
+ } else {
16035
+ setRef(refs[i], null);
16036
+ }
16037
+ }
16038
+ };
16039
+ }
16040
+ };
16041
+ }
16042
+
16043
+ // packages/react/slot/src/Slot.tsx
16044
+ var Slot = React.forwardRef((props, forwardedRef) => {
16045
+ const { children, ...slotProps } = props;
16046
+ const childrenArray = React.Children.toArray(children);
16047
+ const slottable = childrenArray.find(isSlottable);
16048
+ if (slottable) {
16049
+ const newElement = slottable.props.children;
16050
+ const newChildren = childrenArray.map((child) => {
16051
+ if (child === slottable) {
16052
+ if (React.Children.count(newElement) > 1) return React.Children.only(null);
16053
+ return React.isValidElement(newElement) ? newElement.props.children : null;
16054
+ } else {
16055
+ return child;
16056
+ }
16057
+ });
16058
+ return /* @__PURE__ */ jsx$1(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
16059
+ }
16060
+ return /* @__PURE__ */ jsx$1(SlotClone, { ...slotProps, ref: forwardedRef, children });
16061
+ });
16062
+ Slot.displayName = "Slot";
16063
+ var SlotClone = React.forwardRef((props, forwardedRef) => {
16064
+ const { children, ...slotProps } = props;
16065
+ if (React.isValidElement(children)) {
16066
+ const childrenRef = getElementRef(children);
16067
+ return React.cloneElement(children, {
16068
+ ...mergeProps(slotProps, children.props),
16069
+ // @ts-ignore
16070
+ ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef
16071
+ });
16072
+ }
16073
+ return React.Children.count(children) > 1 ? React.Children.only(null) : null;
16074
+ });
16075
+ SlotClone.displayName = "SlotClone";
16076
+ var Slottable = ({ children }) => {
16077
+ return /* @__PURE__ */ jsx$1(Fragment$1, { children });
16078
+ };
16079
+ function isSlottable(child) {
16080
+ return React.isValidElement(child) && child.type === Slottable;
16081
+ }
16082
+ function mergeProps(slotProps, childProps) {
16083
+ const overrideProps = { ...childProps };
16084
+ for (const propName in childProps) {
16085
+ const slotPropValue = slotProps[propName];
16086
+ const childPropValue = childProps[propName];
16087
+ const isHandler = /^on[A-Z]/.test(propName);
16088
+ if (isHandler) {
16089
+ if (slotPropValue && childPropValue) {
16090
+ overrideProps[propName] = (...args) => {
16091
+ childPropValue(...args);
16092
+ slotPropValue(...args);
16093
+ };
16094
+ } else if (slotPropValue) {
16095
+ overrideProps[propName] = slotPropValue;
16096
+ }
16097
+ } else if (propName === "style") {
16098
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
16099
+ } else if (propName === "className") {
16100
+ overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
16101
+ }
16102
+ }
16103
+ return { ...slotProps, ...overrideProps };
16104
+ }
16105
+ function getElementRef(element) {
16106
+ let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
16107
+ let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
16108
+ if (mayWarn) {
16109
+ return element.ref;
16110
+ }
16111
+ getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
16112
+ mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
16113
+ if (mayWarn) {
16114
+ return element.props.ref;
16115
+ }
16116
+ return element.props.ref || element.ref;
16117
+ }
16118
+
16119
+ // packages/react/primitive/src/Primitive.tsx
16120
+ var NODES = [
16121
+ "a",
16122
+ "button",
16123
+ "div",
16124
+ "form",
16125
+ "h2",
16126
+ "h3",
16127
+ "img",
16128
+ "input",
16129
+ "label",
16130
+ "li",
16131
+ "nav",
16132
+ "ol",
16133
+ "p",
16134
+ "span",
16135
+ "svg",
16136
+ "ul"
16137
+ ];
16138
+ var Primitive = NODES.reduce((primitive, node) => {
16139
+ const Node = React.forwardRef((props, forwardedRef) => {
16140
+ const { asChild, ...primitiveProps } = props;
16141
+ const Comp = asChild ? Slot : node;
16142
+ if (typeof window !== "undefined") {
16143
+ window[Symbol.for("radix-ui")] = true;
16144
+ }
16145
+ return /* @__PURE__ */ jsx$1(Comp, { ...primitiveProps, ref: forwardedRef });
16146
+ });
16147
+ Node.displayName = `Primitive.${node}`;
16148
+ return { ...primitive, [node]: Node };
16149
+ }, {});
16150
+
16151
+ var PROGRESS_NAME = "Progress";
16152
+ var DEFAULT_MAX = 100;
16153
+ var [createProgressContext, createProgressScope] = createContextScope(PROGRESS_NAME);
16154
+ var [ProgressProvider, useProgressContext] = createProgressContext(PROGRESS_NAME);
16155
+ var Progress = React.forwardRef(
16156
+ (props, forwardedRef) => {
16157
+ const {
16158
+ __scopeProgress,
16159
+ value: valueProp = null,
16160
+ max: maxProp,
16161
+ getValueLabel = defaultGetValueLabel,
16162
+ ...progressProps
16163
+ } = props;
16164
+ if ((maxProp || maxProp === 0) && !isValidMaxNumber(maxProp)) {
16165
+ console.error(getInvalidMaxError(`${maxProp}`, "Progress"));
16166
+ }
16167
+ const max = isValidMaxNumber(maxProp) ? maxProp : DEFAULT_MAX;
16168
+ if (valueProp !== null && !isValidValueNumber(valueProp, max)) {
16169
+ console.error(getInvalidValueError(`${valueProp}`, "Progress"));
16170
+ }
16171
+ const value = isValidValueNumber(valueProp, max) ? valueProp : null;
16172
+ const valueLabel = isNumber(value) ? getValueLabel(value, max) : void 0;
16173
+ return /* @__PURE__ */ jsx$1(ProgressProvider, { scope: __scopeProgress, value, max, children: /* @__PURE__ */ jsx$1(
16174
+ Primitive.div,
16175
+ {
16176
+ "aria-valuemax": max,
16177
+ "aria-valuemin": 0,
16178
+ "aria-valuenow": isNumber(value) ? value : void 0,
16179
+ "aria-valuetext": valueLabel,
16180
+ role: "progressbar",
16181
+ "data-state": getProgressState(value, max),
16182
+ "data-value": value ?? void 0,
16183
+ "data-max": max,
16184
+ ...progressProps,
16185
+ ref: forwardedRef
16186
+ }
16187
+ ) });
16188
+ }
16189
+ );
16190
+ Progress.displayName = PROGRESS_NAME;
16191
+ var INDICATOR_NAME = "ProgressIndicator";
16192
+ var ProgressIndicator = React.forwardRef(
16193
+ (props, forwardedRef) => {
16194
+ const { __scopeProgress, ...indicatorProps } = props;
16195
+ const context = useProgressContext(INDICATOR_NAME, __scopeProgress);
16196
+ return /* @__PURE__ */ jsx$1(
16197
+ Primitive.div,
16198
+ {
16199
+ "data-state": getProgressState(context.value, context.max),
16200
+ "data-value": context.value ?? void 0,
16201
+ "data-max": context.max,
16202
+ ...indicatorProps,
16203
+ ref: forwardedRef
16204
+ }
16205
+ );
16206
+ }
16207
+ );
16208
+ ProgressIndicator.displayName = INDICATOR_NAME;
16209
+ function defaultGetValueLabel(value, max) {
16210
+ return `${Math.round(value / max * 100)}%`;
16211
+ }
16212
+ function getProgressState(value, maxValue) {
16213
+ return value == null ? "indeterminate" : value === maxValue ? "complete" : "loading";
16214
+ }
16215
+ function isNumber(value) {
16216
+ return typeof value === "number";
16217
+ }
16218
+ function isValidMaxNumber(max) {
16219
+ return isNumber(max) && !isNaN(max) && max > 0;
16220
+ }
16221
+ function isValidValueNumber(value, max) {
16222
+ return isNumber(value) && !isNaN(value) && value <= max && value >= 0;
16223
+ }
16224
+ function getInvalidMaxError(propValue, componentName) {
16225
+ return `Invalid prop \`max\` of value \`${propValue}\` supplied to \`${componentName}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${DEFAULT_MAX}\`.`;
16226
+ }
16227
+ function getInvalidValueError(propValue, componentName) {
16228
+ return `Invalid prop \`value\` of value \`${propValue}\` supplied to \`${componentName}\`. The \`value\` prop must be:
16229
+ - a positive number
16230
+ - less than the value passed to \`max\` (or ${DEFAULT_MAX} if no \`max\` prop is set)
16231
+ - \`null\` or \`undefined\` if the progress is indeterminate.
16232
+
16233
+ Defaulting to \`null\`.`;
16234
+ }
16235
+ var Root = Progress;
16236
+ var Indicator = ProgressIndicator;
16237
+
16238
+ const ProgressBar = ({ value, max = 100, label, extraClasses }) => {
16239
+ const tooltipData = getQTipData({ tooltip: label });
16240
+ const [progress, setProgress] = React__default.useState(0);
16241
+ React__default.useEffect(() => {
16242
+ const timer = setTimeout(() => setProgress(value), 500);
16243
+ return () => clearTimeout(timer);
16244
+ }, []);
16245
+ return (React__default.createElement("span", { ...tooltipData },
16246
+ React__default.createElement(Root, { className: "tw-relative tw-h-[18px] tw-w-full tw-overflow-hidden tw-rounded-[2.5px] tw-bg-sq-dark-gray dark:tw-bg-sq-dark-disabled-gray", max: max, value: value },
16247
+ React__default.createElement(Indicator, { className: `tw-ease-[cubic-bezier(0.65, 0, 0.35, 1)] tw-h-full tw-bg-sq-color-dark tw-transition-transform tw-duration-[660ms] ${extraClasses}`, style: { transform: `translateX(-${100 - progress}%)` } }))));
16301
16248
  };
16302
16249
 
16303
- export { Accordion, Alert, Button, ButtonWithDropdown, ButtonWithPopover, Checkbox, Icon, InputGroup, Modal, QTip, SeeqActionDropdown, Select, components as SelectCompoents, Tabs, TextArea, TextField, ToolbarButton, Tooltip };
16250
+ export { Accordion, Alert, Button, ButtonWithDropdown, ButtonWithPopover, Checkbox, Icon, InputGroup, Modal, ProgressBar, QTip, SeeqActionDropdown, Select, components as SelectCompoents, Tabs, TextArea, TextField, ToolbarButton, Tooltip };
16304
16251
  //# sourceMappingURL=index.esm.js.map