@knime/kds-components 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/index.css +10 -10
  3. package/dist/index.js +2403 -5
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/buttons/KdsMenuButton/KdsMenuButton.vue.d.ts +6 -0
  6. package/dist/src/buttons/KdsMenuButton/KdsMenuButton.vue.d.ts.map +1 -1
  7. package/dist/src/buttons/KdsSplitButton/KdsSplitButton.vue.d.ts +6 -0
  8. package/dist/src/buttons/KdsSplitButton/KdsSplitButton.vue.d.ts.map +1 -1
  9. package/dist/src/buttons/ResponsiveButtonGroup/KdsResponsiveButtonGroup.vue.d.ts +6 -0
  10. package/dist/src/buttons/ResponsiveButtonGroup/KdsResponsiveButtonGroup.vue.d.ts.map +1 -1
  11. package/dist/src/buttons/ResponsiveButtonGroup/mapping.d.ts +1 -1
  12. package/dist/src/containers/FileExplorer/FileExplorerItem.vue.d.ts +12 -0
  13. package/dist/src/containers/FileExplorer/FileExplorerItem.vue.d.ts.map +1 -1
  14. package/dist/src/containers/FileExplorer/KdsFileExplorer.vue.d.ts +24 -0
  15. package/dist/src/containers/FileExplorer/KdsFileExplorer.vue.d.ts.map +1 -1
  16. package/dist/src/containers/Menu/KdsMenu.vue.d.ts +12 -0
  17. package/dist/src/containers/Menu/KdsMenu.vue.d.ts.map +1 -1
  18. package/dist/src/forms/_helper/InfoPopover/KdsInfoToggleButton.vue.d.ts +12 -0
  19. package/dist/src/forms/_helper/InfoPopover/KdsInfoToggleButton.vue.d.ts.map +1 -1
  20. package/dist/src/forms/_helper/VariablePopover/KdsVariableToggleButton.vue.d.ts +12 -0
  21. package/dist/src/forms/_helper/VariablePopover/KdsVariableToggleButton.vue.d.ts.map +1 -1
  22. package/dist/src/forms/inputs/ColorInput/KdsColorInput.vue.d.ts +6 -0
  23. package/dist/src/forms/inputs/ColorInput/KdsColorInput.vue.d.ts.map +1 -1
  24. package/dist/src/forms/inputs/DateInput/KdsDateInput.vue.d.ts +6 -0
  25. package/dist/src/forms/inputs/DateInput/KdsDateInput.vue.d.ts.map +1 -1
  26. package/dist/src/forms/inputs/DateInput/enums.d.ts +1 -1
  27. package/dist/src/forms/inputs/DateTimeFormatInput/KdsDateTimeFormatInput.vue.d.ts +6 -0
  28. package/dist/src/forms/inputs/DateTimeFormatInput/KdsDateTimeFormatInput.vue.d.ts.map +1 -1
  29. package/dist/src/forms/inputs/DateTimeInput/KdsDateTimeInput.vue.d.ts +12 -0
  30. package/dist/src/forms/inputs/DateTimeInput/KdsDateTimeInput.vue.d.ts.map +1 -1
  31. package/dist/src/forms/inputs/IntervalInput/KdsIntervalInput.vue.d.ts +6 -0
  32. package/dist/src/forms/inputs/IntervalInput/KdsIntervalInput.vue.d.ts.map +1 -1
  33. package/dist/src/forms/inputs/SearchInput/KdsSearchInput.vue.d.ts +6 -0
  34. package/dist/src/forms/inputs/SearchInput/KdsSearchInput.vue.d.ts.map +1 -1
  35. package/dist/src/forms/inputs/TextInput/KdsTextInput.vue.d.ts +6 -0
  36. package/dist/src/forms/inputs/TextInput/KdsTextInput.vue.d.ts.map +1 -1
  37. package/dist/src/forms/inputs/TimeInput/KdsTimeInput.vue.d.ts +6 -0
  38. package/dist/src/forms/inputs/TimeInput/KdsTimeInput.vue.d.ts.map +1 -1
  39. package/dist/src/forms/inputs/ZonedDateTimeInput/KdsZonedDateTimeInput.vue.d.ts +12 -0
  40. package/dist/src/forms/inputs/ZonedDateTimeInput/KdsZonedDateTimeInput.vue.d.ts.map +1 -1
  41. package/dist/src/forms/selects/Dropdown/KdsDropdown.vue.d.ts +6 -0
  42. package/dist/src/forms/selects/Dropdown/KdsDropdown.vue.d.ts.map +1 -1
  43. package/dist/src/forms/selects/Dropdown/KdsMultiSelectDropdown.vue.d.ts +6 -0
  44. package/dist/src/forms/selects/Dropdown/KdsMultiSelectDropdown.vue.d.ts.map +1 -1
  45. package/dist/src/overlays/Popover/KdsPopover.vue.d.ts +4 -0
  46. package/dist/src/overlays/Popover/KdsPopover.vue.d.ts.map +1 -1
  47. package/dist/src/overlays/Popover/types.d.ts +11 -0
  48. package/dist/src/overlays/Popover/types.d.ts.map +1 -1
  49. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -938,7 +938,2367 @@ const _sfc_main$1J = /* @__PURE__ */ defineComponent({
938
938
 
939
939
  const KdsBadge = /* @__PURE__ */ _export_sfc(_sfc_main$1J, [["__scopeId", "data-v-df64f7cf"]]);
940
940
 
941
+ /*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */
942
+
943
+ function _arrayLikeToArray(r, a) {
944
+ (null == a || a > r.length) && (a = r.length);
945
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
946
+ return n;
947
+ }
948
+ function _arrayWithHoles(r) {
949
+ if (Array.isArray(r)) return r;
950
+ }
951
+ function _iterableToArrayLimit(r, l) {
952
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
953
+ if (null != t) {
954
+ var e,
955
+ n,
956
+ i,
957
+ u,
958
+ a = [],
959
+ f = true,
960
+ o = false;
961
+ try {
962
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
963
+ } catch (r) {
964
+ o = true, n = r;
965
+ } finally {
966
+ try {
967
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
968
+ } finally {
969
+ if (o) throw n;
970
+ }
971
+ }
972
+ return a;
973
+ }
974
+ }
975
+ function _nonIterableRest() {
976
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
977
+ }
978
+ function _slicedToArray(r, e) {
979
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
980
+ }
981
+ function _unsupportedIterableToArray(r, a) {
982
+ if (r) {
983
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
984
+ var t = {}.toString.call(r).slice(8, -1);
985
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
986
+ }
987
+ }
988
+
989
+ const entries = Object.entries,
990
+ setPrototypeOf = Object.setPrototypeOf,
991
+ isFrozen = Object.isFrozen,
992
+ getPrototypeOf = Object.getPrototypeOf,
993
+ getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
994
+ let freeze = Object.freeze,
995
+ seal = Object.seal,
996
+ create$1 = Object.create; // eslint-disable-line import/no-mutable-exports
997
+ let _ref = typeof Reflect !== 'undefined' && Reflect,
998
+ apply = _ref.apply,
999
+ construct = _ref.construct;
1000
+ if (!freeze) {
1001
+ freeze = function freeze(x) {
1002
+ return x;
1003
+ };
1004
+ }
1005
+ if (!seal) {
1006
+ seal = function seal(x) {
1007
+ return x;
1008
+ };
1009
+ }
1010
+ if (!apply) {
1011
+ apply = function apply(func, thisArg) {
1012
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1013
+ args[_key - 2] = arguments[_key];
1014
+ }
1015
+ return func.apply(thisArg, args);
1016
+ };
1017
+ }
1018
+ if (!construct) {
1019
+ construct = function construct(Func) {
1020
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1021
+ args[_key2 - 1] = arguments[_key2];
1022
+ }
1023
+ return new Func(...args);
1024
+ };
1025
+ }
1026
+ const arrayForEach = unapply(Array.prototype.forEach);
1027
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
1028
+ const arrayPop = unapply(Array.prototype.pop);
1029
+ const arrayPush = unapply(Array.prototype.push);
1030
+ const arraySplice = unapply(Array.prototype.splice);
1031
+ const arrayIsArray = Array.isArray;
1032
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
1033
+ const stringToString = unapply(String.prototype.toString);
1034
+ const stringMatch = unapply(String.prototype.match);
1035
+ const stringReplace = unapply(String.prototype.replace);
1036
+ const stringIndexOf = unapply(String.prototype.indexOf);
1037
+ const stringTrim = unapply(String.prototype.trim);
1038
+ const numberToString = unapply(Number.prototype.toString);
1039
+ const booleanToString = unapply(Boolean.prototype.toString);
1040
+ const bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);
1041
+ const symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);
1042
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
1043
+ const objectToString = unapply(Object.prototype.toString);
1044
+ const regExpTest = unapply(RegExp.prototype.test);
1045
+ const typeErrorCreate = unconstruct(TypeError);
1046
+ /**
1047
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
1048
+ *
1049
+ * @param func - The function to be wrapped and called.
1050
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
1051
+ */
1052
+ function unapply(func) {
1053
+ return function (thisArg) {
1054
+ if (thisArg instanceof RegExp) {
1055
+ thisArg.lastIndex = 0;
1056
+ }
1057
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
1058
+ args[_key3 - 1] = arguments[_key3];
1059
+ }
1060
+ return apply(func, thisArg, args);
1061
+ };
1062
+ }
1063
+ /**
1064
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
1065
+ *
1066
+ * @param func - The constructor function to be wrapped and called.
1067
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
1068
+ */
1069
+ function unconstruct(Func) {
1070
+ return function () {
1071
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1072
+ args[_key4] = arguments[_key4];
1073
+ }
1074
+ return construct(Func, args);
1075
+ };
1076
+ }
1077
+ /**
1078
+ * Add properties to a lookup table
1079
+ *
1080
+ * @param set - The set to which elements will be added.
1081
+ * @param array - The array containing elements to be added to the set.
1082
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
1083
+ * @returns The modified set with added elements.
1084
+ */
1085
+ function addToSet(set, array) {
1086
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
1087
+ if (setPrototypeOf) {
1088
+ // Make 'in' and truthy checks like Boolean(set.constructor)
1089
+ // independent of any properties defined on Object.prototype.
1090
+ // Prevent prototype setters from intercepting set as a this value.
1091
+ setPrototypeOf(set, null);
1092
+ }
1093
+ if (!arrayIsArray(array)) {
1094
+ return set;
1095
+ }
1096
+ let l = array.length;
1097
+ while (l--) {
1098
+ let element = array[l];
1099
+ if (typeof element === 'string') {
1100
+ const lcElement = transformCaseFunc(element);
1101
+ if (lcElement !== element) {
1102
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
1103
+ if (!isFrozen(array)) {
1104
+ array[l] = lcElement;
1105
+ }
1106
+ element = lcElement;
1107
+ }
1108
+ }
1109
+ set[element] = true;
1110
+ }
1111
+ return set;
1112
+ }
1113
+ /**
1114
+ * Clean up an array to harden against CSPP
1115
+ *
1116
+ * @param array - The array to be cleaned.
1117
+ * @returns The cleaned version of the array
1118
+ */
1119
+ function cleanArray(array) {
1120
+ for (let index = 0; index < array.length; index++) {
1121
+ const isPropertyExist = objectHasOwnProperty(array, index);
1122
+ if (!isPropertyExist) {
1123
+ array[index] = null;
1124
+ }
1125
+ }
1126
+ return array;
1127
+ }
1128
+ /**
1129
+ * Shallow clone an object
1130
+ *
1131
+ * @param object - The object to be cloned.
1132
+ * @returns A new object that copies the original.
1133
+ */
1134
+ function clone(object) {
1135
+ const newObject = create$1(null);
1136
+ for (const _ref2 of entries(object)) {
1137
+ var _ref3 = _slicedToArray(_ref2, 2);
1138
+ const property = _ref3[0];
1139
+ const value = _ref3[1];
1140
+ const isPropertyExist = objectHasOwnProperty(object, property);
1141
+ if (isPropertyExist) {
1142
+ if (arrayIsArray(value)) {
1143
+ newObject[property] = cleanArray(value);
1144
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
1145
+ newObject[property] = clone(value);
1146
+ } else {
1147
+ newObject[property] = value;
1148
+ }
1149
+ }
1150
+ }
1151
+ return newObject;
1152
+ }
1153
+ /**
1154
+ * Convert non-node values into strings without depending on direct property access.
1155
+ *
1156
+ * @param value - The value to stringify.
1157
+ * @returns A string representation of the provided value.
1158
+ */
1159
+ function stringifyValue(value) {
1160
+ switch (typeof value) {
1161
+ case 'string':
1162
+ {
1163
+ return value;
1164
+ }
1165
+ case 'number':
1166
+ {
1167
+ return numberToString(value);
1168
+ }
1169
+ case 'boolean':
1170
+ {
1171
+ return booleanToString(value);
1172
+ }
1173
+ case 'bigint':
1174
+ {
1175
+ return bigintToString ? bigintToString(value) : '0';
1176
+ }
1177
+ case 'symbol':
1178
+ {
1179
+ return symbolToString ? symbolToString(value) : 'Symbol()';
1180
+ }
1181
+ case 'undefined':
1182
+ {
1183
+ return objectToString(value);
1184
+ }
1185
+ case 'function':
1186
+ case 'object':
1187
+ {
1188
+ if (value === null) {
1189
+ return objectToString(value);
1190
+ }
1191
+ const valueAsRecord = value;
1192
+ const valueToString = lookupGetter(valueAsRecord, 'toString');
1193
+ if (typeof valueToString === 'function') {
1194
+ const stringified = valueToString(valueAsRecord);
1195
+ return typeof stringified === 'string' ? stringified : objectToString(stringified);
1196
+ }
1197
+ return objectToString(value);
1198
+ }
1199
+ default:
1200
+ {
1201
+ return objectToString(value);
1202
+ }
1203
+ }
1204
+ }
1205
+ /**
1206
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
1207
+ *
1208
+ * @param object - The object to look up the getter function in its prototype chain.
1209
+ * @param prop - The property name for which to find the getter function.
1210
+ * @returns The getter function found in the prototype chain or a fallback function.
1211
+ */
1212
+ function lookupGetter(object, prop) {
1213
+ while (object !== null) {
1214
+ const desc = getOwnPropertyDescriptor(object, prop);
1215
+ if (desc) {
1216
+ if (desc.get) {
1217
+ return unapply(desc.get);
1218
+ }
1219
+ if (typeof desc.value === 'function') {
1220
+ return unapply(desc.value);
1221
+ }
1222
+ }
1223
+ object = getPrototypeOf(object);
1224
+ }
1225
+ function fallbackValue() {
1226
+ return null;
1227
+ }
1228
+ return fallbackValue;
1229
+ }
1230
+ function isRegex(value) {
1231
+ try {
1232
+ regExpTest(value, '');
1233
+ return true;
1234
+ } catch (_unused) {
1235
+ return false;
1236
+ }
1237
+ }
1238
+
1239
+ 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', 'search', 'section', 'select', 'shadow', 'slot', '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']);
1240
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
1241
+ 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']);
1242
+ // List of SVG elements that are disallowed by default.
1243
+ // We still need to know them so that we can do namespace
1244
+ // checks properly in case one wants to add them to
1245
+ // allow-list.
1246
+ 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']);
1247
+ 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']);
1248
+ // Similarly to SVG, we want to know all MathML elements,
1249
+ // even those that we disallow by default.
1250
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
1251
+ const text = freeze(['#text']);
1252
+
1253
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', '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', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);
1254
+ 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', 'mask-type', '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']);
1255
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', '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']);
1256
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
1257
+
1258
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
1259
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
1260
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
1261
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
1262
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
1263
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
1264
+ );
1265
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
1266
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
1267
+ );
1268
+ const DOCTYPE_NAME = seal(/^html$/i);
1269
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
1270
+ // Markup-significant character probes used by _sanitizeElements.
1271
+ // Shared module-level instances are safe despite the sticky /g flags:
1272
+ // unapply() resets lastIndex for RegExp receivers before every call.
1273
+ const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
1274
+ const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
1275
+ const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
1276
+ const SELF_CLOSING_TAG = seal(/\/>/i);
1277
+
1278
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
1279
+ const NODE_TYPE = {
1280
+ element: 1,
1281
+ attribute: 2,
1282
+ text: 3,
1283
+ cdataSection: 4,
1284
+ entityReference: 5,
1285
+ // Deprecated
1286
+ entityNode: 6,
1287
+ // Deprecated
1288
+ processingInstruction: 7,
1289
+ comment: 8,
1290
+ document: 9,
1291
+ documentType: 10,
1292
+ documentFragment: 11,
1293
+ notation: 12 // Deprecated
1294
+ };
1295
+ const getGlobal = function getGlobal() {
1296
+ return typeof window === 'undefined' ? null : window;
1297
+ };
1298
+ /**
1299
+ * Creates a no-op policy for internal use only.
1300
+ * Don't export this function outside this module!
1301
+ * @param trustedTypes The policy factory.
1302
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
1303
+ * @return The policy created (or null, if Trusted Types
1304
+ * are not supported or creating the policy failed).
1305
+ */
1306
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
1307
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
1308
+ return null;
1309
+ }
1310
+ // Allow the callers to control the unique policy name
1311
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
1312
+ // Policy creation with duplicate names throws in Trusted Types.
1313
+ let suffix = null;
1314
+ const ATTR_NAME = 'data-tt-policy-suffix';
1315
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
1316
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
1317
+ }
1318
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
1319
+ try {
1320
+ return trustedTypes.createPolicy(policyName, {
1321
+ createHTML(html) {
1322
+ return html;
1323
+ },
1324
+ createScriptURL(scriptUrl) {
1325
+ return scriptUrl;
1326
+ }
1327
+ });
1328
+ } catch (_) {
1329
+ // Policy creation failed (most likely another DOMPurify script has
1330
+ // already run). Skip creating the policy, as this will only cause errors
1331
+ // if TT are enforced.
1332
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
1333
+ return null;
1334
+ }
1335
+ };
1336
+ const _createHooksMap = function _createHooksMap() {
1337
+ return {
1338
+ afterSanitizeAttributes: [],
1339
+ afterSanitizeElements: [],
1340
+ afterSanitizeShadowDOM: [],
1341
+ beforeSanitizeAttributes: [],
1342
+ beforeSanitizeElements: [],
1343
+ beforeSanitizeShadowDOM: [],
1344
+ uponSanitizeAttribute: [],
1345
+ uponSanitizeElement: [],
1346
+ uponSanitizeShadowNode: []
1347
+ };
1348
+ };
1349
+ /**
1350
+ * Resolve a set-valued configuration option: a fresh set built from
1351
+ * cfg[key] when it is an own array property (seeded with a clone of
1352
+ * options.base when given, case-normalized via options.transform),
1353
+ * the fallback set otherwise.
1354
+ *
1355
+ * @param cfg the cloned, prototype-free configuration object
1356
+ * @param key the configuration property to read
1357
+ * @param fallback the set to use when the option is absent or not an array
1358
+ * @param options transform and optional base set to merge into
1359
+ * @returns the resolved set
1360
+ */
1361
+ const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
1362
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
1363
+ };
1364
+ function createDOMPurify() {
1365
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
1366
+ const DOMPurify = root => createDOMPurify(root);
1367
+ DOMPurify.version = '3.4.11';
1368
+ DOMPurify.removed = [];
1369
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
1370
+ // Not running in a browser, provide a factory function
1371
+ // so that you can pass your own Window
1372
+ DOMPurify.isSupported = false;
1373
+ return DOMPurify;
1374
+ }
1375
+ let document = window.document;
1376
+ const originalDocument = document;
1377
+ const currentScript = originalDocument.currentScript;
1378
+ window.DocumentFragment;
1379
+ const HTMLTemplateElement = window.HTMLTemplateElement,
1380
+ Node = window.Node,
1381
+ Element = window.Element,
1382
+ NodeFilter = window.NodeFilter,
1383
+ _window$NamedNodeMap = window.NamedNodeMap;
1384
+ _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;
1385
+ window.HTMLFormElement;
1386
+ const DOMParser = window.DOMParser,
1387
+ trustedTypes = window.trustedTypes;
1388
+ const ElementPrototype = Element.prototype;
1389
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
1390
+ const remove = lookupGetter(ElementPrototype, 'remove');
1391
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
1392
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
1393
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
1394
+ const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');
1395
+ const getAttributes = lookupGetter(ElementPrototype, 'attributes');
1396
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;
1397
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;
1398
+ // As per issue #47, the web-components registry is inherited by a
1399
+ // new document created via createHTMLDocument. As per the spec
1400
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
1401
+ // a new empty registry is used when creating a template contents owner
1402
+ // document, so we use that as our parent document to ensure nothing
1403
+ // is inherited.
1404
+ if (typeof HTMLTemplateElement === 'function') {
1405
+ const template = document.createElement('template');
1406
+ if (template.content && template.content.ownerDocument) {
1407
+ document = template.content.ownerDocument;
1408
+ }
1409
+ }
1410
+ let trustedTypesPolicy;
1411
+ let emptyHTML = '';
1412
+ // The instance's own internal Trusted Types policy. Unlike a caller-supplied
1413
+ // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws
1414
+ // on duplicate policy names — and is the only policy allowed to persist
1415
+ // across configurations and survive `clearConfig()`.
1416
+ let defaultTrustedTypesPolicy;
1417
+ let defaultTrustedTypesPolicyResolved = false;
1418
+ // Tracks whether we are already inside a call to the configured Trusted Types
1419
+ // policy (`createHTML` or `createScriptURL`). If a supplied policy callback
1420
+ // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would
1421
+ // re-enter the policy and recurse until the stack overflows. We detect that
1422
+ // re-entry and throw a clear, actionable error instead. The guard is shared
1423
+ // across both callbacks, because either one re-entering `sanitize` triggers
1424
+ // the same unbounded recursion.
1425
+ let IN_TRUSTED_TYPES_POLICY = 0;
1426
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
1427
+ if (IN_TRUSTED_TYPES_POLICY > 0) {
1428
+ throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or ' + 'createScriptURL) must not call DOMPurify.sanitize, as that causes ' + 'infinite recursion. Do not pass a policy whose callbacks wrap ' + 'DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted ' + 'Types" section of the README.');
1429
+ }
1430
+ };
1431
+ const _createTrustedHTML = function _createTrustedHTML(html) {
1432
+ _assertNotInTrustedTypesPolicy();
1433
+ IN_TRUSTED_TYPES_POLICY++;
1434
+ try {
1435
+ return trustedTypesPolicy.createHTML(html);
1436
+ } finally {
1437
+ IN_TRUSTED_TYPES_POLICY--;
1438
+ }
1439
+ };
1440
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
1441
+ _assertNotInTrustedTypesPolicy();
1442
+ IN_TRUSTED_TYPES_POLICY++;
1443
+ try {
1444
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
1445
+ } finally {
1446
+ IN_TRUSTED_TYPES_POLICY--;
1447
+ }
1448
+ };
1449
+ // Lazily resolve (and cache) the instance's internal default policy.
1450
+ // Resolution is attempted at most once: a successful `createPolicy` cannot be
1451
+ // repeated (Trusted Types throws on duplicate names), and a failed or
1452
+ // unsupported attempt must not be retried on every parse.
1453
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
1454
+ if (!defaultTrustedTypesPolicyResolved) {
1455
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1456
+ defaultTrustedTypesPolicyResolved = true;
1457
+ }
1458
+ return defaultTrustedTypesPolicy;
1459
+ };
1460
+ const _document = document,
1461
+ implementation = _document.implementation,
1462
+ createNodeIterator = _document.createNodeIterator,
1463
+ createDocumentFragment = _document.createDocumentFragment,
1464
+ getElementsByTagName = _document.getElementsByTagName;
1465
+ const importNode = originalDocument.importNode;
1466
+ let hooks = _createHooksMap();
1467
+ /**
1468
+ * Expose whether this browser supports running the full DOMPurify.
1469
+ */
1470
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
1471
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,
1472
+ ERB_EXPR$1 = ERB_EXPR,
1473
+ TMPLIT_EXPR$1 = TMPLIT_EXPR,
1474
+ DATA_ATTR$1 = DATA_ATTR,
1475
+ ARIA_ATTR$1 = ARIA_ATTR,
1476
+ IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,
1477
+ ATTR_WHITESPACE$1 = ATTR_WHITESPACE,
1478
+ CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
1479
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
1480
+ /**
1481
+ * We consider the elements and attributes below to be safe. Ideally
1482
+ * don't add any new ones but feel free to remove unwanted ones.
1483
+ */
1484
+ /* allowed element names */
1485
+ let ALLOWED_TAGS = null;
1486
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
1487
+ /* Allowed attribute names */
1488
+ let ALLOWED_ATTR = null;
1489
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
1490
+ /*
1491
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
1492
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
1493
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
1494
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
1495
+ */
1496
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create$1(null, {
1497
+ tagNameCheck: {
1498
+ writable: true,
1499
+ configurable: false,
1500
+ enumerable: true,
1501
+ value: null
1502
+ },
1503
+ attributeNameCheck: {
1504
+ writable: true,
1505
+ configurable: false,
1506
+ enumerable: true,
1507
+ value: null
1508
+ },
1509
+ allowCustomizedBuiltInElements: {
1510
+ writable: true,
1511
+ configurable: false,
1512
+ enumerable: true,
1513
+ value: false
1514
+ }
1515
+ }));
1516
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
1517
+ let FORBID_TAGS = null;
1518
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
1519
+ let FORBID_ATTR = null;
1520
+ /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */
1521
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create$1(null, {
1522
+ tagCheck: {
1523
+ writable: true,
1524
+ configurable: false,
1525
+ enumerable: true,
1526
+ value: null
1527
+ },
1528
+ attributeCheck: {
1529
+ writable: true,
1530
+ configurable: false,
1531
+ enumerable: true,
1532
+ value: null
1533
+ }
1534
+ }));
1535
+ /* Decide if ARIA attributes are okay */
1536
+ let ALLOW_ARIA_ATTR = true;
1537
+ /* Decide if custom data attributes are okay */
1538
+ let ALLOW_DATA_ATTR = true;
1539
+ /* Decide if unknown protocols are okay */
1540
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
1541
+ /* Decide if self-closing tags in attributes are allowed.
1542
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
1543
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
1544
+ /* Output should be safe for common template engines.
1545
+ * This means, DOMPurify removes data attributes, mustaches and ERB
1546
+ */
1547
+ let SAFE_FOR_TEMPLATES = false;
1548
+ /* Output should be safe even for XML used within HTML and alike.
1549
+ * This means, DOMPurify removes comments when containing risky content.
1550
+ */
1551
+ let SAFE_FOR_XML = true;
1552
+ /* Decide if document with <html>... should be returned */
1553
+ let WHOLE_DOCUMENT = false;
1554
+ /* Track whether config is already set on this instance of DOMPurify. */
1555
+ let SET_CONFIG = false;
1556
+ /* Pristine allowlist bindings captured at setConfig() time. On the
1557
+ * persistent-config path sanitize() restores the sets from these before
1558
+ * the per-walk hook clone-guard, so a hook's in-call widening cannot
1559
+ * carry across calls. Null until setConfig() is called; reset by
1560
+ * clearConfig(). */
1561
+ let SET_CONFIG_ALLOWED_TAGS = null;
1562
+ let SET_CONFIG_ALLOWED_ATTR = null;
1563
+ /* Decide if all elements (e.g. style, script) must be children of
1564
+ * document.body. By default, browsers might move them to document.head */
1565
+ let FORCE_BODY = false;
1566
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
1567
+ * string (or a TrustedHTML object if Trusted Types are supported).
1568
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
1569
+ */
1570
+ let RETURN_DOM = false;
1571
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
1572
+ * string (or a TrustedHTML object if Trusted Types are supported) */
1573
+ let RETURN_DOM_FRAGMENT = false;
1574
+ /* Try to return a Trusted Type object instead of a string, return a string in
1575
+ * case Trusted Types are not supported */
1576
+ let RETURN_TRUSTED_TYPE = false;
1577
+ /* Output should be free from DOM clobbering attacks?
1578
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
1579
+ */
1580
+ let SANITIZE_DOM = true;
1581
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
1582
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
1583
+ *
1584
+ * HTML/DOM spec rules that enable DOM Clobbering:
1585
+ * - Named Access on Window (§7.3.3)
1586
+ * - DOM Tree Accessors (§3.1.5)
1587
+ * - Form Element Parent-Child Relations (§4.10.3)
1588
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
1589
+ * - HTMLCollection (§4.2.10.2)
1590
+ *
1591
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
1592
+ * with a constant string, i.e., `user-content-`
1593
+ */
1594
+ let SANITIZE_NAMED_PROPS = false;
1595
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
1596
+ /* Keep element content when removing element? */
1597
+ let KEEP_CONTENT = true;
1598
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
1599
+ * of importing it into a new Document and returning a sanitized copy */
1600
+ let IN_PLACE = false;
1601
+ /* Allow usage of profiles like html, svg and mathMl */
1602
+ let USE_PROFILES = {};
1603
+ /* Tags to ignore content of when KEEP_CONTENT is true */
1604
+ let FORBID_CONTENTS = null;
1605
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',
1606
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
1607
+ // the UA (customizable <select>) — including any on* handlers — and the
1608
+ // engine re-mirrors synchronously whenever a removal changes which
1609
+ // option/selectedcontent is current, even inside DOMPurify's inert
1610
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
1611
+ // mirror target ahead of the walk, which the engine refills, looping
1612
+ // forever (DoS) and amplifying output. Dropping its content on removal
1613
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
1614
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
1615
+ 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
1616
+ /* Tags that are safe for data: URIs */
1617
+ let DATA_URI_TAGS = null;
1618
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
1619
+ /* Attributes safe for values like "javascript:" */
1620
+ let URI_SAFE_ATTRIBUTES = null;
1621
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
1622
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
1623
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
1624
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
1625
+ /* Document namespace */
1626
+ let NAMESPACE = HTML_NAMESPACE;
1627
+ let IS_EMPTY_INPUT = false;
1628
+ /* Allowed XHTML+XML namespaces */
1629
+ let ALLOWED_NAMESPACES = null;
1630
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1631
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);
1632
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1633
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);
1634
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1635
+ // Certain elements are allowed in both SVG and HTML
1636
+ // namespace. We need to specify them explicitly
1637
+ // so that they don't get erroneously deleted from
1638
+ // HTML namespace.
1639
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1640
+ /* Parsing of strict XHTML documents */
1641
+ let PARSER_MEDIA_TYPE = null;
1642
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
1643
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
1644
+ let transformCaseFunc = null;
1645
+ /* Keep a reference to config to pass to hooks */
1646
+ let CONFIG = null;
1647
+ /* Ideally, do not touch anything below this line */
1648
+ /* ______________________________________________ */
1649
+ const formElement = document.createElement('form');
1650
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1651
+ return testValue instanceof RegExp || testValue instanceof Function;
1652
+ };
1653
+ /**
1654
+ * _parseConfig
1655
+ *
1656
+ * @param cfg optional config literal
1657
+ */
1658
+ // eslint-disable-next-line complexity
1659
+ const _parseConfig = function _parseConfig() {
1660
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1661
+ if (CONFIG && CONFIG === cfg) {
1662
+ return;
1663
+ }
1664
+ /* Shield configuration object from tampering */
1665
+ if (!cfg || typeof cfg !== 'object') {
1666
+ cfg = {};
1667
+ }
1668
+ /* Shield configuration object from prototype pollution */
1669
+ cfg = clone(cfg);
1670
+ PARSER_MEDIA_TYPE =
1671
+ // eslint-disable-next-line unicorn/prefer-includes
1672
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1673
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
1674
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
1675
+ /* Set configuration parameters */
1676
+ ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {
1677
+ transform: transformCaseFunc
1678
+ });
1679
+ ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {
1680
+ transform: transformCaseFunc
1681
+ });
1682
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {
1683
+ transform: stringToString
1684
+ });
1685
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {
1686
+ transform: transformCaseFunc,
1687
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
1688
+ });
1689
+ DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {
1690
+ transform: transformCaseFunc,
1691
+ base: DEFAULT_DATA_URI_TAGS
1692
+ });
1693
+ FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {
1694
+ transform: transformCaseFunc
1695
+ });
1696
+ FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {
1697
+ transform: transformCaseFunc
1698
+ });
1699
+ FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {
1700
+ transform: transformCaseFunc
1701
+ });
1702
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
1703
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
1704
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
1705
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
1706
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
1707
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
1708
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
1709
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
1710
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
1711
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
1712
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
1713
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
1714
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
1715
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
1716
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
1717
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
1718
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp
1719
+ NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace
1720
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'MATHML_TEXT_INTEGRATION_POINTS') && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === 'object' ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS); // Default built-in map
1721
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, 'HTML_INTEGRATION_POINTS') && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === 'object' ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS); // Default built-in map
1722
+ const customElementHandling = objectHasOwnProperty(cfg, 'CUSTOM_ELEMENT_HANDLING') && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === 'object' ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create$1(null);
1723
+ CUSTOM_ELEMENT_HANDLING = create$1(null);
1724
+ if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {
1725
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined
1726
+ }
1727
+ if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
1728
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined
1729
+ }
1730
+ if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {
1731
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined
1732
+ }
1733
+ seal(CUSTOM_ELEMENT_HANDLING);
1734
+ if (SAFE_FOR_TEMPLATES) {
1735
+ ALLOW_DATA_ATTR = false;
1736
+ }
1737
+ if (RETURN_DOM_FRAGMENT) {
1738
+ RETURN_DOM = true;
1739
+ }
1740
+ /* Parse profile info */
1741
+ if (USE_PROFILES) {
1742
+ ALLOWED_TAGS = addToSet({}, text);
1743
+ ALLOWED_ATTR = create$1(null);
1744
+ if (USE_PROFILES.html === true) {
1745
+ addToSet(ALLOWED_TAGS, html$1);
1746
+ addToSet(ALLOWED_ATTR, html);
1747
+ }
1748
+ if (USE_PROFILES.svg === true) {
1749
+ addToSet(ALLOWED_TAGS, svg$1);
1750
+ addToSet(ALLOWED_ATTR, svg);
1751
+ addToSet(ALLOWED_ATTR, xml);
1752
+ }
1753
+ if (USE_PROFILES.svgFilters === true) {
1754
+ addToSet(ALLOWED_TAGS, svgFilters);
1755
+ addToSet(ALLOWED_ATTR, svg);
1756
+ addToSet(ALLOWED_ATTR, xml);
1757
+ }
1758
+ if (USE_PROFILES.mathMl === true) {
1759
+ addToSet(ALLOWED_TAGS, mathMl$1);
1760
+ addToSet(ALLOWED_ATTR, mathMl);
1761
+ addToSet(ALLOWED_ATTR, xml);
1762
+ }
1763
+ }
1764
+ /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent
1765
+ * leaking across calls when switching from function to array config */
1766
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
1767
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
1768
+ /* Merge configuration parameters */
1769
+ if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {
1770
+ if (typeof cfg.ADD_TAGS === 'function') {
1771
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
1772
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
1773
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
1774
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
1775
+ }
1776
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1777
+ }
1778
+ }
1779
+ if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {
1780
+ if (typeof cfg.ADD_ATTR === 'function') {
1781
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
1782
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
1783
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
1784
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
1785
+ }
1786
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1787
+ }
1788
+ }
1789
+ if (objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
1790
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
1791
+ }
1792
+ if (objectHasOwnProperty(cfg, 'FORBID_CONTENTS') && arrayIsArray(cfg.FORBID_CONTENTS)) {
1793
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1794
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1795
+ }
1796
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
1797
+ }
1798
+ if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
1799
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
1800
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
1801
+ }
1802
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
1803
+ }
1804
+ /* Add #text in case KEEP_CONTENT is set to true */
1805
+ if (KEEP_CONTENT) {
1806
+ ALLOWED_TAGS['#text'] = true;
1807
+ }
1808
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
1809
+ if (WHOLE_DOCUMENT) {
1810
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1811
+ }
1812
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1813
+ if (ALLOWED_TAGS.table) {
1814
+ addToSet(ALLOWED_TAGS, ['tbody']);
1815
+ delete FORBID_TAGS.tbody;
1816
+ }
1817
+ // Re-derive the active Trusted Types policy from this configuration on
1818
+ // every parse. The active policy must never be sticky closure state that
1819
+ // outlives the config that set it: a caller-supplied policy left in place
1820
+ // after `clearConfig()` — or after a later call that supplied none, or
1821
+ // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent "default"
1822
+ // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.
1823
+ // See GHSA-vxr8-fq34-vvx9.
1824
+ if (cfg.TRUSTED_TYPES_POLICY) {
1825
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1826
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1827
+ }
1828
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1829
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1830
+ }
1831
+ // A caller-supplied policy applies to this configuration only.
1832
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
1833
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1834
+ // Sign local variables required by `sanitize`. If the supplied policy's
1835
+ // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this
1836
+ // throws via the re-entrancy guard. Restore the previous policy first so
1837
+ // the instance is not left in a poisoned state. See #1422.
1838
+ try {
1839
+ emptyHTML = _createTrustedHTML('');
1840
+ } catch (error) {
1841
+ trustedTypesPolicy = previousTrustedTypesPolicy;
1842
+ throw error;
1843
+ }
1844
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
1845
+ // Explicit opt-out for this call: perform no Trusted Types signing and
1846
+ // create nothing (so a strict `trusted-types` CSP that disallows a
1847
+ // `dompurify` policy can still call `sanitize` from inside its own
1848
+ // policy — see #1422). Resetting to `undefined` rather than a sticky
1849
+ // `null` also drops any previously retained caller policy, so it cannot
1850
+ // resurface on a later call, while still allowing the next config-less
1851
+ // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.
1852
+ trustedTypesPolicy = undefined;
1853
+ emptyHTML = '';
1854
+ } else {
1855
+ // No policy supplied: keep the currently active policy if one is set — a
1856
+ // previously supplied policy is intentionally sticky across config-less
1857
+ // calls — otherwise fall back to the instance's own internal policy,
1858
+ // created at most once. (A policy supplied for a *single* call still
1859
+ // lingers by design; what must not linger is a policy whose configuration
1860
+ // has been torn down via `clearConfig()`, which restores the default.)
1861
+ if (trustedTypesPolicy === undefined) {
1862
+ trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
1863
+ }
1864
+ // Sign internal variables only when a policy is active. A falsy policy
1865
+ // (Trusted Types unsupported, creation failed, or an explicit opt-out)
1866
+ // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on
1867
+ // a non-policy and throw. See #1422.
1868
+ if (trustedTypesPolicy && typeof emptyHTML === 'string') {
1869
+ emptyHTML = _createTrustedHTML('');
1870
+ }
1871
+ }
1872
+ // Prevent further manipulation of configuration.
1873
+ // Not available in IE8, Safari 5, etc.
1874
+ if (freeze) {
1875
+ freeze(cfg);
1876
+ }
1877
+ CONFIG = cfg;
1878
+ };
1879
+ /* Keep track of all possible SVG and MathML tags
1880
+ * so that we can perform the namespace checks
1881
+ * correctly. */
1882
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1883
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1884
+ /**
1885
+ * Namespace rules for an element in the SVG namespace.
1886
+ *
1887
+ * @param tagName the element's lowercase tag name
1888
+ * @param parent the (possibly simulated) parent node
1889
+ * @param parentTagName the parent's lowercase tag name
1890
+ * @returns true if a spec-compliant parser could produce this element
1891
+ */
1892
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
1893
+ // The only way to switch from HTML namespace to SVG
1894
+ // is via <svg>. If it happens via any other tag, then
1895
+ // it should be killed.
1896
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1897
+ return tagName === 'svg';
1898
+ }
1899
+ // The only way to switch from MathML to SVG is via <svg>
1900
+ // if the parent is either <annotation-xml> or a MathML
1901
+ // text integration point.
1902
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1903
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1904
+ }
1905
+ // We only allow elements that are defined in SVG
1906
+ // spec. All others are disallowed in SVG namespace.
1907
+ return Boolean(ALL_SVG_TAGS[tagName]);
1908
+ };
1909
+ /**
1910
+ * Namespace rules for an element in the MathML namespace.
1911
+ *
1912
+ * @param tagName the element's lowercase tag name
1913
+ * @param parent the (possibly simulated) parent node
1914
+ * @param parentTagName the parent's lowercase tag name
1915
+ * @returns true if a spec-compliant parser could produce this element
1916
+ */
1917
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
1918
+ // The only way to switch from HTML namespace to MathML
1919
+ // is via <math>. If it happens via any other tag, then
1920
+ // it should be killed.
1921
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1922
+ return tagName === 'math';
1923
+ }
1924
+ // The only way to switch from SVG to MathML is via
1925
+ // <math> and HTML integration points
1926
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1927
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1928
+ }
1929
+ // We only allow elements that are defined in MathML
1930
+ // spec. All others are disallowed in MathML namespace.
1931
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1932
+ };
1933
+ /**
1934
+ * Namespace rules for an element in the HTML namespace.
1935
+ *
1936
+ * @param tagName the element's lowercase tag name
1937
+ * @param parent the (possibly simulated) parent node
1938
+ * @param parentTagName the parent's lowercase tag name
1939
+ * @returns true if a spec-compliant parser could produce this element
1940
+ */
1941
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
1942
+ // The only way to switch from SVG to HTML is via
1943
+ // HTML integration points, and from MathML to HTML
1944
+ // is via MathML text integration points
1945
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1946
+ return false;
1947
+ }
1948
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1949
+ return false;
1950
+ }
1951
+ // We disallow tags that are specific for MathML
1952
+ // or SVG and should never appear in HTML namespace
1953
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1954
+ };
1955
+ /**
1956
+ * @param element a DOM element whose namespace is being checked
1957
+ * @returns Return false if the element has a
1958
+ * namespace that a spec-compliant parser would never
1959
+ * return. Return true otherwise.
1960
+ */
1961
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1962
+ let parent = getParentNode(element);
1963
+ // In JSDOM, if we're inside shadow DOM, then parentNode
1964
+ // can be null. We just simulate parent in this case.
1965
+ if (!parent || !parent.tagName) {
1966
+ parent = {
1967
+ namespaceURI: NAMESPACE,
1968
+ tagName: 'template'
1969
+ };
1970
+ }
1971
+ const tagName = stringToLowerCase(element.tagName);
1972
+ const parentTagName = stringToLowerCase(parent.tagName);
1973
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1974
+ return false;
1975
+ }
1976
+ if (element.namespaceURI === SVG_NAMESPACE) {
1977
+ return _checkSvgNamespace(tagName, parent, parentTagName);
1978
+ }
1979
+ if (element.namespaceURI === MATHML_NAMESPACE) {
1980
+ return _checkMathMlNamespace(tagName, parent, parentTagName);
1981
+ }
1982
+ if (element.namespaceURI === HTML_NAMESPACE) {
1983
+ return _checkHtmlNamespace(tagName, parent, parentTagName);
1984
+ }
1985
+ // For XHTML and XML documents that support custom namespaces
1986
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1987
+ return true;
1988
+ }
1989
+ // The code should never reach this place (this means
1990
+ // that the element somehow got namespace that is not
1991
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1992
+ // Return false just in case.
1993
+ return false;
1994
+ };
1995
+ /**
1996
+ * _forceRemove
1997
+ *
1998
+ * @param node a DOM node
1999
+ */
2000
+ const _forceRemove = function _forceRemove(node) {
2001
+ arrayPush(DOMPurify.removed, {
2002
+ element: node
2003
+ });
2004
+ try {
2005
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
2006
+ getParentNode(node).removeChild(node);
2007
+ } catch (_) {
2008
+ /* The normal detach failed — this is reached for a parentless node
2009
+ (getParentNode() is null, so .removeChild throws). Element.prototype
2010
+ .remove() is itself a spec no-op on a parentless node, so a recorded
2011
+ "removal" would otherwise hand the caller back an intact,
2012
+ payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or
2013
+ the style-with-element-child rule decided to kill). Fail closed by
2014
+ throwing — exactly as a clobbered root does at the IN_PLACE entry —
2015
+ rather than trying to "neutralize" the node via its own methods.
2016
+ Neutralizing would mean calling getAttributeNames()/removeAttribute()
2017
+ on the node, both of which a <form> root can clobber via a named child
2018
+ (and _isClobbered does not even probe getAttributeNames), so the
2019
+ neutralize step could itself be silently defeated, leaving the payload
2020
+ intact. A throw touches only the cached, clobber-safe remove() and
2021
+ getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)
2022
+ to every root-kill reason. REPORT-3.
2023
+ This lives inside the catch, so it never fires for a normally-removed
2024
+ in-tree node: those have a parent, removeChild() succeeds, and the
2025
+ catch is not entered. Only a kept (parentless) root reaches here. */
2026
+ remove(node);
2027
+ if (!getParentNode(node)) {
2028
+ throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');
2029
+ }
2030
+ }
2031
+ };
2032
+ /**
2033
+ * _neutralizeRoot
2034
+ *
2035
+ * Fail-closed teardown of an in-place root after the sanitize walk aborts
2036
+ * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered
2037
+ * custom element's reaction detaches a node so `_forceRemove`'s deliberate
2038
+ * parentless guard throws, or any other re-entrant engine mutation — would
2039
+ * otherwise leave the caller's *live* tree half-sanitized, with everything
2040
+ * after the abort point still carrying its handlers. There is no safe way
2041
+ * to resume the walk (the tree mutated under us), so we strip the root bare:
2042
+ * remove every child and every attribute, then let the caller's catch see
2043
+ * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`
2044
+ * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).
2045
+ *
2046
+ * @param root the in-place root to empty
2047
+ */
2048
+ const _neutralizeRoot = function _neutralizeRoot(root) {
2049
+ const childNodes = getChildNodes(root);
2050
+ if (childNodes) {
2051
+ const snapshot = [];
2052
+ arrayForEach(childNodes, child => {
2053
+ arrayPush(snapshot, child);
2054
+ });
2055
+ arrayForEach(snapshot, child => {
2056
+ try {
2057
+ remove(child);
2058
+ } catch (_) {
2059
+ /* Best-effort teardown; a still-attached child is handled below */
2060
+ }
2061
+ });
2062
+ }
2063
+ const attributes = getAttributes(root);
2064
+ if (attributes) {
2065
+ for (let i = attributes.length - 1; i >= 0; --i) {
2066
+ const attribute = attributes[i];
2067
+ const name = attribute && attribute.name;
2068
+ if (typeof name === 'string') {
2069
+ try {
2070
+ root.removeAttribute(name);
2071
+ } catch (_) {
2072
+ /* Clobbered removeAttribute — ignore (fail-closed best effort) */
2073
+ }
2074
+ }
2075
+ }
2076
+ }
2077
+ };
2078
+ /**
2079
+ * _removeAttribute
2080
+ *
2081
+ * @param name an Attribute name
2082
+ * @param element a DOM node
2083
+ */
2084
+ const _removeAttribute = function _removeAttribute(name, element) {
2085
+ try {
2086
+ arrayPush(DOMPurify.removed, {
2087
+ attribute: element.getAttributeNode(name),
2088
+ from: element
2089
+ });
2090
+ } catch (_) {
2091
+ arrayPush(DOMPurify.removed, {
2092
+ attribute: null,
2093
+ from: element
2094
+ });
2095
+ }
2096
+ element.removeAttribute(name);
2097
+ // We void attribute values for unremovable "is" attributes
2098
+ if (name === 'is') {
2099
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
2100
+ try {
2101
+ _forceRemove(element);
2102
+ } catch (_) {}
2103
+ } else {
2104
+ try {
2105
+ element.setAttribute(name, '');
2106
+ } catch (_) {}
2107
+ }
2108
+ }
2109
+ };
2110
+ /**
2111
+ * _stripDisallowedAttributes
2112
+ *
2113
+ * Removes every attribute the active configuration does not allow from a
2114
+ * single element, using the same allowlist as the main attribute pass (so
2115
+ * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to
2116
+ * neutralise nodes that are being discarded from an in-place tree.
2117
+ *
2118
+ * @param element the element to strip
2119
+ */
2120
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
2121
+ const attributes = getAttributes(element);
2122
+ if (!attributes) {
2123
+ return;
2124
+ }
2125
+ for (let i = attributes.length - 1; i >= 0; --i) {
2126
+ const attribute = attributes[i];
2127
+ const name = attribute && attribute.name;
2128
+ if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {
2129
+ continue;
2130
+ }
2131
+ try {
2132
+ element.removeAttribute(name);
2133
+ } catch (_) {
2134
+ /* Clobbered removeAttribute on a doomed node — ignore */
2135
+ }
2136
+ }
2137
+ };
2138
+ /**
2139
+ * _neutralizeSubtree
2140
+ *
2141
+ * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT
2142
+ * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,
2143
+ * namespace, comment, processing-instruction and KEEP_CONTENT:false removals
2144
+ * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path
2145
+ * those dropped nodes are detached from the caller's LIVE tree but a
2146
+ * handler-bearing original among them (an `<img onerror>`/`<video>` that was
2147
+ * loading) keeps its queued resource event, which fires in page scope after
2148
+ * sanitize returns. This walks a removed subtree and strips every attribute
2149
+ * the active configuration does not allow — so `on*` handlers are cancelled
2150
+ * through the SAME allowlist that governs kept nodes, not a separate `/^on/`
2151
+ * blocklist. Run synchronously before sanitize returns, i.e. before any
2152
+ * queued event can fire. Hook-free by design: these nodes leave the output,
2153
+ * so firing attribute hooks for them would be surprising. Clobber-safe reads;
2154
+ * a doomed clobbered node may shadow `removeAttribute` (its own attributes are
2155
+ * irrelevant — it is discarded — while its non-clobbered descendants, e.g.
2156
+ * the `<img>`, are reached and scrubbed).
2157
+ *
2158
+ * @param root the root of a removed subtree to neutralise
2159
+ */
2160
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
2161
+ const stack = [root];
2162
+ while (stack.length > 0) {
2163
+ const node = stack.pop();
2164
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
2165
+ if (nodeType === NODE_TYPE.element) {
2166
+ _stripDisallowedAttributes(node);
2167
+ }
2168
+ const childNodes = getChildNodes(node);
2169
+ if (childNodes) {
2170
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2171
+ stack.push(childNodes[i]);
2172
+ }
2173
+ }
2174
+ }
2175
+ };
2176
+ /**
2177
+ * _initDocument
2178
+ *
2179
+ * @param dirty - a string of dirty markup
2180
+ * @return a DOM, filled with the dirty markup
2181
+ */
2182
+ const _initDocument = function _initDocument(dirty) {
2183
+ /* Create a HTML document */
2184
+ let doc = null;
2185
+ let leadingWhitespace = null;
2186
+ if (FORCE_BODY) {
2187
+ dirty = '<remove></remove>' + dirty;
2188
+ } else {
2189
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
2190
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
2191
+ leadingWhitespace = matches && matches[0];
2192
+ }
2193
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
2194
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
2195
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
2196
+ }
2197
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
2198
+ /*
2199
+ * Use the DOMParser API by default, fallback later if needs be
2200
+ * DOMParser not work for svg when has multiple root element.
2201
+ */
2202
+ if (NAMESPACE === HTML_NAMESPACE) {
2203
+ try {
2204
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
2205
+ } catch (_) {}
2206
+ }
2207
+ /* Use createHTMLDocument in case DOMParser is not available */
2208
+ if (!doc || !doc.documentElement) {
2209
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
2210
+ try {
2211
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
2212
+ } catch (_) {
2213
+ // Syntax error if dirtyPayload is invalid xml
2214
+ }
2215
+ }
2216
+ const body = doc.body || doc.documentElement;
2217
+ if (dirty && leadingWhitespace) {
2218
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
2219
+ }
2220
+ /* Work on whole document or just its body */
2221
+ if (NAMESPACE === HTML_NAMESPACE) {
2222
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
2223
+ }
2224
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
2225
+ };
2226
+ /**
2227
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
2228
+ *
2229
+ * @param root The root element or node to start traversing on.
2230
+ * @return The created NodeIterator
2231
+ */
2232
+ const _createNodeIterator = function _createNodeIterator(root) {
2233
+ return createNodeIterator.call(root.ownerDocument || root, root,
2234
+ // eslint-disable-next-line no-bitwise
2235
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
2236
+ };
2237
+ /**
2238
+ * Replace template expression syntax (mustache, ERB, template
2239
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
2240
+ * sites. Order matters: mustache, then ERB, then template literal.
2241
+ *
2242
+ * @param value the string to scrub
2243
+ * @returns the scrubbed string
2244
+ */
2245
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
2246
+ value = stringReplace(value, MUSTACHE_EXPR$1, ' ');
2247
+ value = stringReplace(value, ERB_EXPR$1, ' ');
2248
+ value = stringReplace(value, TMPLIT_EXPR$1, ' ');
2249
+ return value;
2250
+ };
2251
+ /**
2252
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
2253
+ * character data of an element subtree. Used as the final safety net for
2254
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
2255
+ * which only form after text-node normalization (e.g. fragments split across
2256
+ * stripped elements) cannot survive into a template-evaluating framework.
2257
+ *
2258
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
2259
+ * in place rather than round-tripping through innerHTML. This preserves
2260
+ * descendant node references (important for IN_PLACE callers), avoids a
2261
+ * serialize/reparse cycle, and reads literal character data — which means
2262
+ * `<%...%>` in text content matches the ERB regex against its real bytes
2263
+ * instead of the HTML-entity-escaped form innerHTML would produce.
2264
+ *
2265
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
2266
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
2267
+ *
2268
+ * @param node The root element whose character data should be scrubbed.
2269
+ */
2270
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
2271
+ var _node$querySelectorAl;
2272
+ node.normalize();
2273
+ const walker = createNodeIterator.call(node.ownerDocument || node, node,
2274
+ // eslint-disable-next-line no-bitwise
2275
+ NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
2276
+ let currentNode = walker.nextNode();
2277
+ while (currentNode) {
2278
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
2279
+ currentNode = walker.nextNode();
2280
+ }
2281
+ // NodeIterator does not descend into <template>.content per the DOM spec,
2282
+ // so we must explicitly recurse into each template's content fragment,
2283
+ // mirroring the approach used by _sanitizeShadowDOM.
2284
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');
2285
+ if (templates) {
2286
+ arrayForEach(templates, tmpl => {
2287
+ if (_isDocumentFragment(tmpl.content)) {
2288
+ _scrubTemplateExpressions2(tmpl.content);
2289
+ }
2290
+ });
2291
+ }
2292
+ };
2293
+ /**
2294
+ * _isClobbered
2295
+ *
2296
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
2297
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
2298
+ * `name` attribute matching a prototype property shadows that property
2299
+ * on direct reads. We use this check at the IN_PLACE entry-point and
2300
+ * during attribute sanitization to refuse clobbered forms.
2301
+ *
2302
+ * @param element element to check for clobbering attacks
2303
+ * @return true if clobbered, false if safe
2304
+ */
2305
+ const _isClobbered = function _isClobbered(element) {
2306
+ // Realm-independent tag-name probe. If we can't determine the tag
2307
+ // name at all, we can't reason about clobbering — return false
2308
+ // (the caller's other defences still apply).
2309
+ const realTagName = getNodeName ? getNodeName(element) : null;
2310
+ if (typeof realTagName !== 'string') {
2311
+ return false;
2312
+ }
2313
+ if (transformCaseFunc(realTagName) !== 'form') {
2314
+ return false;
2315
+ }
2316
+ return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||
2317
+ // Realm-safe NamedNodeMap detection: equality against the cached
2318
+ // prototype getter. Clobbered .attributes (e.g. <input name="attributes">)
2319
+ // makes the direct read diverge from the cached read; a clean form
2320
+ // (same-realm OR foreign-realm) has both reads pointing at the same
2321
+ // canonical NamedNodeMap.
2322
+ element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||
2323
+ // NodeType clobbering probe. Cached Node.prototype.nodeType getter
2324
+ // returns the integer 1 for any Element regardless of realm; direct
2325
+ // read on a clobbered form (e.g. <input name="nodeType">) returns
2326
+ // the named child element. Cheap addition — nodeType is read from
2327
+ // an internal slot, no serialization cost — and removes a residual
2328
+ // clobbering surface used by several mXSS / PI / comment branches
2329
+ // in _sanitizeElements that compare currentNode.nodeType directly.
2330
+ element.nodeType !== getNodeType(element) ||
2331
+ // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named
2332
+ // "childNodes" shadows the prototype getter. Direct reads of
2333
+ // form.childNodes from a clobbered form return the named child
2334
+ // instead of the real NodeList, so any walk that reads it directly
2335
+ // skips the form's real children. Compare the direct read to the
2336
+ // cached Node.prototype getter — when the form's named-property
2337
+ // getter intercepts the read, the two values differ and we flag
2338
+ // the form. This catches every clobbering child type (input,
2339
+ // select, etc.) regardless of whether the named child happens to
2340
+ // carry a numeric .length, which a typeof-based probe would miss
2341
+ // (e.g. HTMLSelectElement.length is a defined unsigned-long).
2342
+ element.childNodes !== getChildNodes(element);
2343
+ };
2344
+ /**
2345
+ * Checks whether the given value is a DocumentFragment from any realm.
2346
+ *
2347
+ * The realm-independent replacement reads `nodeType` through the cached
2348
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
2349
+ * constant (11). nodeType is a numeric value resolved from the node's
2350
+ * internal slot, identical across realms for the same kind of node.
2351
+ *
2352
+ * @param value object to check
2353
+ * @return true if value is a DocumentFragment-shaped node from any realm
2354
+ */
2355
+ const _isDocumentFragment = function _isDocumentFragment(value) {
2356
+ if (!getNodeType || typeof value !== 'object' || value === null) {
2357
+ return false;
2358
+ }
2359
+ try {
2360
+ return getNodeType(value) === NODE_TYPE.documentFragment;
2361
+ } catch (_) {
2362
+ return false;
2363
+ }
2364
+ };
2365
+ /**
2366
+ * Checks whether the given object is a DOM node, including nodes that
2367
+ * originate from a different window/realm (e.g. an iframe's
2368
+ * contentDocument). The previous `value instanceof Node` check was
2369
+ * realm-bound: nodes from a different window failed it, causing
2370
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
2371
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
2372
+ *
2373
+ * @param value object to check whether it's a DOM node
2374
+ * @return true if value is a DOM node from any realm
2375
+ */
2376
+ const _isNode = function _isNode(value) {
2377
+ if (!getNodeType || typeof value !== 'object' || value === null) {
2378
+ return false;
2379
+ }
2380
+ try {
2381
+ return typeof getNodeType(value) === 'number';
2382
+ } catch (_) {
2383
+ return false;
2384
+ }
2385
+ };
2386
+ function _executeHooks(hooks, currentNode, data) {
2387
+ if (hooks.length === 0) {
2388
+ return;
2389
+ }
2390
+ arrayForEach(hooks, hook => {
2391
+ hook.call(DOMPurify, currentNode, data, CONFIG);
2392
+ });
2393
+ }
2394
+ /**
2395
+ * Structural-threat checks that condemn a node regardless of the
2396
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
2397
+ * processing instructions, markup-bearing comments. Pure predicate;
2398
+ * the caller removes. Check order is load-bearing.
2399
+ *
2400
+ * @param currentNode the node to inspect
2401
+ * @param tagName the node's transformCaseFunc'd tag name
2402
+ * @return true if the node must be removed
2403
+ */
2404
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
2405
+ /* Detect mXSS attempts abusing namespace confusion */
2406
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
2407
+ return true;
2408
+ }
2409
+ /* Remove risky CSS construction leading to mXSS */
2410
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === 'style' && _isNode(currentNode.firstElementChild)) {
2411
+ return true;
2412
+ }
2413
+ /* Remove any occurrence of processing instructions */
2414
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
2415
+ return true;
2416
+ }
2417
+ /* Remove any kind of possibly harmful comments */
2418
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
2419
+ return true;
2420
+ }
2421
+ return false;
2422
+ };
2423
+ /**
2424
+ * Handle a node whose tag is forbidden or not allowlisted: keep
2425
+ * allowed custom elements (false return exits _sanitizeElements
2426
+ * early - namespace/fallback checks and the afterSanitizeElements
2427
+ * hook are intentionally skipped for kept custom elements), else
2428
+ * hoist content per KEEP_CONTENT and remove.
2429
+ *
2430
+ * @param currentNode the disallowed node
2431
+ * @param tagName the node's transformCaseFunc'd tag name
2432
+ * @return true if the node was removed, false if kept
2433
+ */
2434
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName) {
2435
+ /* Check if we have a custom element to handle */
2436
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
2437
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
2438
+ return false;
2439
+ }
2440
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
2441
+ return false;
2442
+ }
2443
+ }
2444
+ /* Keep content except for bad-listed elements.
2445
+ Use the cached prototype getters exclusively — the previous code
2446
+ had `|| currentNode.parentNode` / `|| currentNode.childNodes`
2447
+ fallbacks, but the cached getters always return the canonical
2448
+ value (or null for a real parent-less node), so the fallback
2449
+ path was dead in safe cases and a clobbering surface in unsafe
2450
+ ones. Falsy cached results stay falsy; the `if (childNodes &&
2451
+ parentNode)` check already gates correctly. */
2452
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2453
+ const parentNode = getParentNode(currentNode);
2454
+ const childNodes = getChildNodes(currentNode);
2455
+ if (childNodes && parentNode) {
2456
+ const childCount = childNodes.length;
2457
+ /* In-place: hoist the *original* children so the iterator visits
2458
+ and sanitises them through the same allowlist pass as every other
2459
+ node. The caller built the tree in the live document, so the
2460
+ originals carry already-queued resource events (`<img onerror>`,
2461
+ `<video>`/`<audio>` error, lazy/`onload`, …); cloning would leave
2462
+ those originals detached but still armed, firing in page scope
2463
+ while the returned tree looked clean. Moving is safe in-place: the
2464
+ root is pre-validated as an allowed tag and so is never the node
2465
+ being removed, which keeps `parentNode` inside the iterator root
2466
+ and the relocated child inside the serialised tree.
2467
+ Otherwise (string / DOM-copy paths): clone. The iterator is rooted
2468
+ at — and the result serialised from — `body`, so a restrictive
2469
+ ALLOWED_TAGS that removes `body` itself must leave its content in
2470
+ place, which only cloning does; and those paths parse into an
2471
+ inert document, so their discarded originals never had a queued
2472
+ event to neutralise.
2473
+ `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`
2474
+ valid whether we move (drops the trailing entry) or clone (leaves
2475
+ the list intact). */
2476
+ for (let i = childCount - 1; i >= 0; --i) {
2477
+ const hoisted = IN_PLACE ? childNodes[i] : cloneNode(childNodes[i], true);
2478
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
2479
+ }
2480
+ }
2481
+ }
2482
+ _forceRemove(currentNode);
2483
+ return true;
2484
+ };
2485
+ /**
2486
+ * _sanitizeElements
2487
+ *
2488
+ * @protect nodeName
2489
+ * @protect textContent
2490
+ * @protect removeChild
2491
+ * @param currentNode to check for permission to exist
2492
+ * @return true if node was killed, false if left alive
2493
+ */
2494
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
2495
+ /* Execute a hook if present */
2496
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2497
+ /* Check if element is clobbered or can clobber */
2498
+ if (_isClobbered(currentNode)) {
2499
+ _forceRemove(currentNode);
2500
+ return true;
2501
+ }
2502
+ /* Now let's check the element's type and name */
2503
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
2504
+ /* Execute a hook if present */
2505
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
2506
+ tagName,
2507
+ allowedTags: ALLOWED_TAGS
2508
+ });
2509
+ /* Remove mXSS vectors, processing instructions and risky comments */
2510
+ if (_isUnsafeNode(currentNode, tagName)) {
2511
+ _forceRemove(currentNode);
2512
+ return true;
2513
+ }
2514
+ /* Remove element if anything forbids its presence */
2515
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
2516
+ return _sanitizeDisallowedNode(currentNode, tagName);
2517
+ }
2518
+ /* Check whether element has a valid namespace.
2519
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype
2520
+ nodeType getter rather than `instanceof Element`, which is realm-
2521
+ bound and short-circuits to false for any node minted in a different
2522
+ realm — letting a foreign-realm element with a forbidden namespace
2523
+ slip past the namespace check entirely. */
2524
+ const nt = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
2525
+ if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
2526
+ _forceRemove(currentNode);
2527
+ return true;
2528
+ }
2529
+ /* Make sure that older browsers don't get fallback-tag mXSS */
2530
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
2531
+ _forceRemove(currentNode);
2532
+ return true;
2533
+ }
2534
+ /* Sanitize element content to be template-safe */
2535
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
2536
+ /* Get the element's text content */
2537
+ const content = _stripTemplateExpressions(currentNode.textContent);
2538
+ if (currentNode.textContent !== content) {
2539
+ arrayPush(DOMPurify.removed, {
2540
+ element: currentNode.cloneNode()
2541
+ });
2542
+ currentNode.textContent = content;
2543
+ }
2544
+ }
2545
+ /* Execute a hook if present */
2546
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2547
+ return false;
2548
+ };
2549
+ /**
2550
+ * _isValidAttribute
2551
+ *
2552
+ * @param lcTag Lowercase tag name of containing element.
2553
+ * @param lcName Lowercase attribute name.
2554
+ * @param value Attribute value.
2555
+ * @return Returns true if `value` is valid, otherwise false.
2556
+ */
2557
+ // eslint-disable-next-line complexity
2558
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
2559
+ /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */
2560
+ if (FORBID_ATTR[lcName]) {
2561
+ return false;
2562
+ }
2563
+ /* Make sure attribute cannot clobber */
2564
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
2565
+ return false;
2566
+ }
2567
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
2568
+ /* Allow valid data-* attributes: At least one character after "-"
2569
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
2570
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
2571
+ We don't need to check the value; it's always URI safe. */
2572
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ; else if (!nameIsPermitted) {
2573
+ if (
2574
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
2575
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2576
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
2577
+ _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, lcTag)) ||
2578
+ // Alternative, second condition checks if it's an `is`-attribute, AND
2579
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
2580
+ 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 {
2581
+ return false;
2582
+ }
2583
+ /* Check value is safe. First, is attr inert? If so, is safe */
2584
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; 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$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) ; else if (value) {
2585
+ return false;
2586
+ } else ;
2587
+ return true;
2588
+ };
2589
+ /* Names the HTML spec reserves from valid-custom-element-name; these must
2590
+ * never be treated as basic custom elements even when a permissive
2591
+ * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */
2592
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);
2593
+ /**
2594
+ * _isBasicCustomElement
2595
+ * checks if at least one dash is included in tagName, and it's not the first char
2596
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
2597
+ *
2598
+ * @param tagName name of the tag of the node to sanitize
2599
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
2600
+ */
2601
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
2602
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
2603
+ };
2604
+ /**
2605
+ * Wrap an attribute value in the matching Trusted Types object when
2606
+ * the active policy requires it. Namespaced attributes pass through
2607
+ * unchanged (no TT support yet, see
2608
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
2609
+ *
2610
+ * @param lcTag lowercase tag name of the containing element
2611
+ * @param lcName lowercase attribute name
2612
+ * @param namespaceURI the attribute's namespace, if any
2613
+ * @param value the attribute value to wrap
2614
+ * @return the value, wrapped when Trusted Types demand it
2615
+ */
2616
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
2617
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {
2618
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2619
+ case 'TrustedHTML':
2620
+ {
2621
+ return _createTrustedHTML(value);
2622
+ }
2623
+ case 'TrustedScriptURL':
2624
+ {
2625
+ return _createTrustedScriptURL(value);
2626
+ }
2627
+ }
2628
+ }
2629
+ return value;
2630
+ };
2631
+ /**
2632
+ * Write a modified attribute value back onto the element. On
2633
+ * success, re-probe for clobbering introduced by the new value and
2634
+ * remove the element when found; otherwise pop the removal entry
2635
+ * recorded by the earlier _removeAttribute (long-standing pairing
2636
+ * with the SANITIZE_NAMED_PROPS path - do not "fix" casually). On
2637
+ * failure, remove the attribute instead.
2638
+ *
2639
+ * @param currentNode the element carrying the attribute
2640
+ * @param name the attribute name as present on the element
2641
+ * @param namespaceURI the attribute's namespace, if any
2642
+ * @param value the new attribute value
2643
+ */
2644
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
2645
+ try {
2646
+ if (namespaceURI) {
2647
+ currentNode.setAttributeNS(namespaceURI, name, value);
2648
+ } else {
2649
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
2650
+ currentNode.setAttribute(name, value);
2651
+ }
2652
+ if (_isClobbered(currentNode)) {
2653
+ _forceRemove(currentNode);
2654
+ } else {
2655
+ arrayPop(DOMPurify.removed);
2656
+ }
2657
+ } catch (_) {
2658
+ _removeAttribute(name, currentNode);
2659
+ }
2660
+ };
2661
+ /**
2662
+ * _sanitizeAttributes
2663
+ *
2664
+ * @protect attributes
2665
+ * @protect nodeName
2666
+ * @protect removeAttribute
2667
+ * @protect setAttribute
2668
+ *
2669
+ * @param currentNode to sanitize
2670
+ */
2671
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
2672
+ /* Execute a hook if present */
2673
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2674
+ const attributes = currentNode.attributes;
2675
+ /* Check if we have attributes; if not we might have a text node */
2676
+ if (!attributes || _isClobbered(currentNode)) {
2677
+ return;
2678
+ }
2679
+ const hookEvent = {
2680
+ attrName: '',
2681
+ attrValue: '',
2682
+ keepAttr: true,
2683
+ allowedAttributes: ALLOWED_ATTR,
2684
+ forceKeepAttr: undefined
2685
+ };
2686
+ let l = attributes.length;
2687
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2688
+ /* Go backwards over all attributes; safely remove bad ones */
2689
+ while (l--) {
2690
+ const attr = attributes[l];
2691
+ const name = attr.name,
2692
+ namespaceURI = attr.namespaceURI,
2693
+ attrValue = attr.value;
2694
+ const lcName = transformCaseFunc(name);
2695
+ const initValue = attrValue;
2696
+ let value = name === 'value' ? initValue : stringTrim(initValue);
2697
+ /* Execute a hook if present */
2698
+ hookEvent.attrName = lcName;
2699
+ hookEvent.attrValue = value;
2700
+ hookEvent.keepAttr = true;
2701
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
2702
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2703
+ value = hookEvent.attrValue;
2704
+ /* Full DOM Clobbering protection via namespace isolation,
2705
+ * Prefix id and name attributes with `user-content-`
2706
+ */
2707
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
2708
+ // Remove the attribute with this value
2709
+ _removeAttribute(name, currentNode);
2710
+ // Prefix the value and later re-create the attribute with the sanitized value
2711
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
2712
+ }
2713
+ // Else: already prefixed, leave the attribute alone — the prefix is
2714
+ // itself the clobbering protection, and re-applying it is incorrect.
2715
+ /* Work around a security issue with comments inside attributes */
2716
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
2717
+ _removeAttribute(name, currentNode);
2718
+ continue;
2719
+ }
2720
+ /* Make sure we cannot easily use animated hrefs, even if animations are allowed */
2721
+ if (lcName === 'attributename' && stringMatch(value, 'href')) {
2722
+ _removeAttribute(name, currentNode);
2723
+ continue;
2724
+ }
2725
+ /* Did the hooks force-keep the attribute? */
2726
+ if (hookEvent.forceKeepAttr) {
2727
+ continue;
2728
+ }
2729
+ /* Did the hooks approve of the attribute? */
2730
+ if (!hookEvent.keepAttr) {
2731
+ _removeAttribute(name, currentNode);
2732
+ continue;
2733
+ }
2734
+ /* Work around a security issue in jQuery 3.0 */
2735
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
2736
+ _removeAttribute(name, currentNode);
2737
+ continue;
2738
+ }
2739
+ /* Sanitize attribute content to be template-safe */
2740
+ if (SAFE_FOR_TEMPLATES) {
2741
+ value = _stripTemplateExpressions(value);
2742
+ }
2743
+ /* Is `value` valid for this attribute? */
2744
+ if (!_isValidAttribute(lcTag, lcName, value)) {
2745
+ _removeAttribute(name, currentNode);
2746
+ continue;
2747
+ }
2748
+ /* Handle attributes that require Trusted Types */
2749
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
2750
+ /* Handle invalid data-* attribute set by try-catching it */
2751
+ if (value !== initValue) {
2752
+ _setAttributeValue(currentNode, name, namespaceURI, value);
2753
+ }
2754
+ }
2755
+ /* Execute a hook if present */
2756
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
2757
+ };
2758
+ /**
2759
+ * _sanitizeShadowDOM
2760
+ *
2761
+ * @param fragment to iterate over recursively
2762
+ */
2763
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
2764
+ let shadowNode = null;
2765
+ const shadowIterator = _createNodeIterator(fragment);
2766
+ /* Execute a hook if present */
2767
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
2768
+ while (shadowNode = shadowIterator.nextNode()) {
2769
+ /* Execute a hook if present */
2770
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
2771
+ /* Sanitize tags and elements */
2772
+ _sanitizeElements(shadowNode);
2773
+ /* Check attributes next */
2774
+ _sanitizeAttributes(shadowNode);
2775
+ /* Deep shadow DOM detected.
2776
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the
2777
+ DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we
2778
+ recurse into <template>.content from foreign realms too. */
2779
+ if (_isDocumentFragment(shadowNode.content)) {
2780
+ _sanitizeShadowDOM2(shadowNode.content);
2781
+ }
2782
+ /* An element iterated here may itself host an attached
2783
+ shadow root. The default NodeIterator does not enter shadow
2784
+ trees, so a shadow root nested inside template.content was
2785
+ previously reached by no walk at all (the pre-pass at
2786
+ _sanitizeAttachedShadowRoots descends via childNodes, which
2787
+ doesn't enter template.content; the template-content recursion
2788
+ above iterates the content but never inspected shadowRoot).
2789
+ Walk it explicitly. The nodeType guard avoids reading
2790
+ shadowRoot off text / comment / CDATA / PI nodes that the
2791
+ iterator also surfaces. */
2792
+ const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
2793
+ if (shadowNodeType === NODE_TYPE.element) {
2794
+ const innerSr = getShadowRoot(shadowNode);
2795
+ if (_isDocumentFragment(innerSr)) {
2796
+ _sanitizeAttachedShadowRoots(innerSr);
2797
+ _sanitizeShadowDOM2(innerSr);
2798
+ }
2799
+ }
2800
+ }
2801
+ /* Execute a hook if present */
2802
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2803
+ };
2804
+ /**
2805
+ * _sanitizeAttachedShadowRoots
2806
+ *
2807
+ * Walks `root` and feeds every attached shadow root we encounter into
2808
+ * the existing _sanitizeShadowDOM pipeline. The default node iterator
2809
+ * does not descend into shadow trees, so nodes inside an attached
2810
+ * shadow root would otherwise be skipped entirely.
2811
+ *
2812
+ * Two real input paths put attached shadow roots in front of us:
2813
+ * 1. IN_PLACE on a DOM node that already has shadow roots attached.
2814
+ * 2. DOM-node input where importNode(dirty, true) deep-clones the
2815
+ * shadow root because it was created with `clonable: true`.
2816
+ *
2817
+ * This pass runs once, up front, so the main iteration loop (and the
2818
+ * existing _sanitizeShadowDOM template-content recursion) stay
2819
+ * untouched — string-input paths are not affected.
2820
+ *
2821
+ * @param root the subtree root to walk for attached shadow roots
2822
+ */
2823
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
2824
+ /* Iterative (explicit stack) rather than per-child recursion. DOM APIs
2825
+ impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data
2826
+ built straight into the DOM — the IN_PLACE surface) deeper than the JS
2827
+ call-stack budget would otherwise overflow native recursion here and
2828
+ throw at the IN_PLACE entry pre-pass, before a single node is
2829
+ sanitized, leaving the caller's live tree untouched (fail-open). See
2830
+ campaign-3 F4. A heap stack keeps depth off the call stack.
2831
+ Each work item is either a node to descend into, or a deferred
2832
+ `_sanitizeShadowDOM` for an already-walked shadow root. The deferred
2833
+ form preserves the original post-order discipline: a shadow root's
2834
+ nested shadow roots are discovered before the outer shadow is
2835
+ sanitized (which may remove hosts). Pushes are in reverse of the
2836
+ desired processing order (LIFO): template content, then children, then
2837
+ the shadow-sanitize, then the shadow walk — so the order matches the
2838
+ previous recursion exactly. */
2839
+ const stack = [{
2840
+ node: root,
2841
+ shadow: null
2842
+ }];
2843
+ while (stack.length > 0) {
2844
+ const item = stack.pop();
2845
+ /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */
2846
+ if (item.shadow) {
2847
+ _sanitizeShadowDOM2(item.shadow);
2848
+ continue;
2849
+ }
2850
+ const node = item.node;
2851
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
2852
+ const isElement = nodeType === NODE_TYPE.element;
2853
+ /* (pushed last → processed first) Children, snapshotted in reverse so
2854
+ the first child is processed first. Snapshotting matters because a
2855
+ hook may detach siblings mid-walk. */
2856
+ const childNodes = getChildNodes(node);
2857
+ if (childNodes) {
2858
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2859
+ stack.push({
2860
+ node: childNodes[i],
2861
+ shadow: null
2862
+ });
2863
+ }
2864
+ }
2865
+ /* (pushed before children → processed after them, matching the old
2866
+ "template content last" order) When the node is a <template>,
2867
+ descend into its content. */
2868
+ if (isElement) {
2869
+ const rootName = getNodeName ? getNodeName(node) : null;
2870
+ if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {
2871
+ const content = node.content;
2872
+ if (_isDocumentFragment(content)) {
2873
+ stack.push({
2874
+ node: content,
2875
+ shadow: null
2876
+ });
2877
+ }
2878
+ }
2879
+ }
2880
+ /* Shadow root (processed first): walk its subtree, then sanitise it.
2881
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
2882
+ rather than `instanceof DocumentFragment`, which is realm-bound and
2883
+ silently skipped foreign-realm shadow roots (e.g.
2884
+ iframe.contentDocument attachShadow). */
2885
+ if (isElement) {
2886
+ const sr = getShadowRoot(node);
2887
+ if (_isDocumentFragment(sr)) {
2888
+ /* Push the deferred sanitise first so it pops after the shadow
2889
+ walk we push next, i.e. nested shadow roots are discovered
2890
+ before this one is sanitised. */
2891
+ stack.push({
2892
+ node: null,
2893
+ shadow: sr
2894
+ }, {
2895
+ node: sr,
2896
+ shadow: null
2897
+ });
2898
+ }
2899
+ }
2900
+ }
2901
+ };
2902
+ // eslint-disable-next-line complexity
2903
+ DOMPurify.sanitize = function (dirty) {
2904
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2905
+ let body = null;
2906
+ let importedNode = null;
2907
+ let currentNode = null;
2908
+ let returnNode = null;
2909
+ /* Make sure we have a string to sanitize.
2910
+ DO NOT return early, as this will return the wrong type if
2911
+ the user has requested a DOM object rather than a string */
2912
+ IS_EMPTY_INPUT = !dirty;
2913
+ if (IS_EMPTY_INPUT) {
2914
+ dirty = '<!-->';
2915
+ }
2916
+ /* Stringify, in case dirty is an object */
2917
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
2918
+ dirty = stringifyValue(dirty);
2919
+ if (typeof dirty !== 'string') {
2920
+ throw typeErrorCreate('dirty is not a string, aborting');
2921
+ }
2922
+ }
2923
+ /* Return dirty HTML if DOMPurify cannot run */
2924
+ if (!DOMPurify.isSupported) {
2925
+ return dirty;
2926
+ }
2927
+ /* Assign config vars */
2928
+ if (SET_CONFIG) {
2929
+ /* Persistent setConfig() path: _parseConfig is skipped, so the sets are
2930
+ * not re-derived per call. Restore them from the pristine bindings
2931
+ * captured at setConfig() time so a previous call's hook clone (mutated
2932
+ * below) does not carry over. */
2933
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
2934
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
2935
+ } else {
2936
+ _parseConfig(cfg);
2937
+ }
2938
+ /* Clone the hook-mutable allowlists before the walk whenever an
2939
+ * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS
2940
+ * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so
2941
+ * a hook that widens them would otherwise mutate the shared set
2942
+ * permanently: across later calls and across every element. Cloning per
2943
+ * walk keeps documented in-call widening working while scoping it to the
2944
+ * call. A single guard for both config paths - the per-call path rebinds
2945
+ * the sets in _parseConfig each call, the persistent path restores them
2946
+ * from the captured bindings just above - so the two cannot diverge. */
2947
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
2948
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
2949
+ }
2950
+ if (hooks.uponSanitizeAttribute.length > 0) {
2951
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
2952
+ }
2953
+ /* Clean up removed elements */
2954
+ DOMPurify.removed = [];
2955
+ /* Resolve IN_PLACE for this call without mutating persistent config.
2956
+ Writing the IN_PLACE closure variable here leaks under setConfig(),
2957
+ where _parseConfig is skipped on later calls: a single string call would
2958
+ disable in-place mode for every subsequent node call, returning a
2959
+ sanitized copy while leaving the caller's node — which in-place callers
2960
+ keep using and whose return value they ignore — unsanitized. REPORT-2. */
2961
+ const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);
2962
+ if (inPlace) {
2963
+ /* Do some early pre-sanitization to avoid unsafe root nodes.
2964
+ Read nodeName through the cached prototype getter — a clobbering
2965
+ child named "nodeName" on the form root would otherwise shadow
2966
+ the property and let this check skip the root-allowlist
2967
+ validation entirely. */
2968
+ const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2969
+ if (typeof nn === 'string') {
2970
+ const tagName = transformCaseFunc(nn);
2971
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2972
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
2973
+ }
2974
+ }
2975
+ /* Pre-flight the root through _isClobbered. The iterator-driven
2976
+ removal path can not detach a parent-less root: _forceRemove
2977
+ falls through to Element.prototype.remove(), which per spec
2978
+ is a no-op on a node with no parent. A clobbered root would
2979
+ then survive the main loop with its attributes uninspected,
2980
+ because _sanitizeAttributes early-returns on _isClobbered. The
2981
+ result would be an attacker-controlled form, complete with any
2982
+ event-handler attributes the caller passed in, handed back to
2983
+ the application unsanitized. Refuse to sanitize such a root
2984
+ the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */
2985
+ if (_isClobbered(dirty)) {
2986
+ throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');
2987
+ }
2988
+ /* Sanitize attached shadow roots before the main iterator runs.
2989
+ The iterator does not descend into shadow trees. Same fail-closed
2990
+ barrier as the main walk (campaign-3 F2): a custom-element reaction
2991
+ inside a shadow root could abort this pre-pass before the walk runs,
2992
+ which would otherwise leave the entire live tree unsanitized. */
2993
+ try {
2994
+ _sanitizeAttachedShadowRoots(dirty);
2995
+ } catch (error) {
2996
+ _neutralizeRoot(dirty);
2997
+ throw error;
2998
+ }
2999
+ } else if (_isNode(dirty)) {
3000
+ /* If dirty is a DOM element, append to an empty document to avoid
3001
+ elements being stripped by the parser */
3002
+ body = _initDocument('<!---->');
3003
+ importedNode = body.ownerDocument.importNode(dirty, true);
3004
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
3005
+ /* Node is already a body, use as is */
3006
+ body = importedNode;
3007
+ } else if (importedNode.nodeName === 'HTML') {
3008
+ body = importedNode;
3009
+ } else {
3010
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
3011
+ body.appendChild(importedNode);
3012
+ }
3013
+ /* Clonable shadow roots are deep-cloned by importNode(); sanitize
3014
+ them before the main iterator runs, since the iterator does not
3015
+ descend into shadow trees. The walk routes every read through a
3016
+ cached prototype getter so clobbering descendants on a form root
3017
+ cannot hide a shadow host from this pass. */
3018
+ _sanitizeAttachedShadowRoots(importedNode);
3019
+ } else {
3020
+ /* Exit directly if we have nothing to do */
3021
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
3022
+ // eslint-disable-next-line unicorn/prefer-includes
3023
+ dirty.indexOf('<') === -1) {
3024
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
3025
+ }
3026
+ /* Initialize the document to work on */
3027
+ body = _initDocument(dirty);
3028
+ /* Check we have a DOM node from the data */
3029
+ if (!body) {
3030
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
3031
+ }
3032
+ }
3033
+ /* Remove first element node (ours) if FORCE_BODY is set */
3034
+ if (body && FORCE_BODY) {
3035
+ _forceRemove(body.firstChild);
3036
+ }
3037
+ /* Get node iterator */
3038
+ const nodeIterator = _createNodeIterator(inPlace ? dirty : body);
3039
+ /* Now start iterating over the created document.
3040
+ The walk runs inside an exception barrier (campaign-3 F2): a re-entrant
3041
+ engine/custom-element mutation can detach a node mid-walk so
3042
+ `_forceRemove`'s parentless guard throws, aborting the loop. Without the
3043
+ barrier the caller's in-place tree would be left half-sanitized with the
3044
+ unvisited tail still armed. On any throw we fail closed — strip the
3045
+ in-place root bare — then rethrow so the existing throw contract is
3046
+ preserved. (String/DOM-copy paths never return the partial body, so the
3047
+ propagating throw is already fail-closed there.) */
3048
+ try {
3049
+ while (currentNode = nodeIterator.nextNode()) {
3050
+ /* Sanitize tags and elements */
3051
+ _sanitizeElements(currentNode);
3052
+ /* Check attributes next */
3053
+ _sanitizeAttributes(currentNode);
3054
+ /* Shadow DOM detected, sanitize it.
3055
+ Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection
3056
+ instead of instanceof, so foreign-realm <template>.content is
3057
+ walked correctly. */
3058
+ if (_isDocumentFragment(currentNode.content)) {
3059
+ _sanitizeShadowDOM2(currentNode.content);
3060
+ }
3061
+ }
3062
+ } catch (error) {
3063
+ if (inPlace) {
3064
+ _neutralizeRoot(dirty);
3065
+ }
3066
+ throw error;
3067
+ }
3068
+ /* If we sanitized `dirty` in-place, return it. */
3069
+ if (inPlace) {
3070
+ /* Fail-closed completion of the audit-5 F1 fix: every node removed from
3071
+ the caller's live tree is detached but may still hold a queued
3072
+ resource-event handler that fires in page scope after we return. The
3073
+ move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the
3074
+ non-allow-listed attributes off every other removed subtree (clobber,
3075
+ mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are
3076
+ cancelled before any event can fire. Runs synchronously, pre-return. */
3077
+ arrayForEach(DOMPurify.removed, entry => {
3078
+ if (entry.element) {
3079
+ _neutralizeSubtree(entry.element);
3080
+ }
3081
+ });
3082
+ if (SAFE_FOR_TEMPLATES) {
3083
+ _scrubTemplateExpressions2(dirty);
3084
+ }
3085
+ return dirty;
3086
+ }
3087
+ /* Return sanitized string or DOM */
3088
+ if (RETURN_DOM) {
3089
+ if (SAFE_FOR_TEMPLATES) {
3090
+ _scrubTemplateExpressions2(body);
3091
+ }
3092
+ if (RETURN_DOM_FRAGMENT) {
3093
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3094
+ while (body.firstChild) {
3095
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
3096
+ returnNode.appendChild(body.firstChild);
3097
+ }
3098
+ } else {
3099
+ returnNode = body;
3100
+ }
3101
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3102
+ /*
3103
+ AdoptNode() is not used because internal state is not reset
3104
+ (e.g. the past names map of a HTMLFormElement), this is safe
3105
+ in theory but we would rather not risk another attack vector.
3106
+ The state that is cloned by importNode() is explicitly defined
3107
+ by the specs.
3108
+ */
3109
+ returnNode = importNode.call(originalDocument, returnNode, true);
3110
+ }
3111
+ return returnNode;
3112
+ }
3113
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3114
+ /* Serialize doctype if allowed */
3115
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3116
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
3117
+ }
3118
+ /* Sanitize final string template-safe */
3119
+ if (SAFE_FOR_TEMPLATES) {
3120
+ serializedHTML = _stripTemplateExpressions(serializedHTML);
3121
+ }
3122
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
3123
+ };
3124
+ DOMPurify.setConfig = function () {
3125
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3126
+ _parseConfig(cfg);
3127
+ SET_CONFIG = true;
3128
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
3129
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
3130
+ };
3131
+ DOMPurify.clearConfig = function () {
3132
+ CONFIG = null;
3133
+ SET_CONFIG = false;
3134
+ SET_CONFIG_ALLOWED_TAGS = null;
3135
+ SET_CONFIG_ALLOWED_ATTR = null;
3136
+ // Drop any caller-supplied Trusted Types policy so it cannot poison later
3137
+ // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and
3138
+ // never recreated — Trusted Types throws on duplicate names) is restored by
3139
+ // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.
3140
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
3141
+ emptyHTML = '';
3142
+ };
3143
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
3144
+ /* Initialize shared config vars if necessary. */
3145
+ if (!CONFIG) {
3146
+ _parseConfig({});
3147
+ }
3148
+ const lcTag = transformCaseFunc(tag);
3149
+ const lcName = transformCaseFunc(attr);
3150
+ return _isValidAttribute(lcTag, lcName, value);
3151
+ };
3152
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
3153
+ if (typeof hookFunction !== 'function') {
3154
+ return;
3155
+ }
3156
+ /* Reject unknown entry points. Without this, a non-hook key (e.g.
3157
+ * '__proto__') indexes off the prototype chain rather than a real
3158
+ * hook array, and arrayPush then writes to Object.prototype. Guard
3159
+ * with an own-property check against the known hook names. */
3160
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3161
+ return;
3162
+ }
3163
+ arrayPush(hooks[entryPoint], hookFunction);
3164
+ };
3165
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
3166
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3167
+ return undefined;
3168
+ }
3169
+ if (hookFunction !== undefined) {
3170
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3171
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
3172
+ }
3173
+ return arrayPop(hooks[entryPoint]);
3174
+ };
3175
+ DOMPurify.removeHooks = function (entryPoint) {
3176
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
3177
+ return;
3178
+ }
3179
+ hooks[entryPoint] = [];
3180
+ };
3181
+ DOMPurify.removeAllHooks = function () {
3182
+ hooks = _createHooksMap();
3183
+ };
3184
+ return DOMPurify;
3185
+ }
3186
+ createDOMPurify();
3187
+
3188
+ const modeDefinitions = [
3189
+ {
3190
+ id: "search",
3191
+ normalize(searchTerm, caseSensitiveSearch) {
3192
+ return caseSensitiveSearch ? searchTerm : searchTerm.toLowerCase();
3193
+ },
3194
+ test(text, normalizedSearchTerm, caseSensitiveSearch, inverseSearch) {
3195
+ const testText = caseSensitiveSearch ? text : text.toLowerCase();
3196
+ const matches = testText.includes(normalizedSearchTerm);
3197
+ return inverseSearch ? !matches : matches;
3198
+ }
3199
+ },
3200
+ {
3201
+ id: "wildcard",
3202
+ normalize(searchTerm, caseSensitiveSearch) {
3203
+ if (searchTerm.length > 0) {
3204
+ const escapedSearchTerm = searchTerm.replace(
3205
+ /[-[\]{}()+.,\\^$|#\s]/g,
3206
+ "\\$&"
3207
+ );
3208
+ const wildcardSearchTerm = escapedSearchTerm.replace(/\*/g, ".*").replace(/\?/g, ".?");
3209
+ searchTerm = `^${wildcardSearchTerm}$`;
3210
+ } else {
3211
+ return { test: () => false };
3212
+ }
3213
+ try {
3214
+ const flags = caseSensitiveSearch ? "" : "i";
3215
+ return new RegExp(searchTerm, flags);
3216
+ } catch (_error) {
3217
+ return /$^/;
3218
+ }
3219
+ },
3220
+ test(text, normalizedSearchTerm, caseSensitiveSearch, inverseSearch) {
3221
+ const matches = normalizedSearchTerm.test(text);
3222
+ return inverseSearch ? !matches : matches;
3223
+ }
3224
+ },
3225
+ {
3226
+ id: "regex",
3227
+ normalize(searchTerm, caseSensitiveSearch) {
3228
+ try {
3229
+ const flags = caseSensitiveSearch ? "" : "i";
3230
+ return new RegExp(`^(${searchTerm})$`, flags);
3231
+ } catch (_error) {
3232
+ return /$^/;
3233
+ }
3234
+ },
3235
+ test(text, normalizedSearchTerm, caseSensitiveSearch, inverseSearch) {
3236
+ const matches = normalizedSearchTerm.test(text);
3237
+ return inverseSearch ? !matches : matches;
3238
+ }
3239
+ },
3240
+ {
3241
+ id: "type",
3242
+ normalize(selectedTypes) {
3243
+ return { test: (type) => selectedTypes.includes(type) };
3244
+ },
3245
+ test(type, normalizedSearchTerm) {
3246
+ if (typeof type === "undefined") {
3247
+ return false;
3248
+ }
3249
+ return normalizedSearchTerm.test(type);
3250
+ }
3251
+ }
3252
+ ];
3253
+ Object.assign({}, ...modeDefinitions.map((obj) => ({ [obj.id]: obj })));
3254
+
941
3255
  const isMac = () => navigator?.userAgent?.toLowerCase()?.includes("mac");
3256
+ const yearsPart$1 = "(\\d+)\\s*y(?:ears?)?";
3257
+ const monthsPart$1 = "(\\d+)\\s*m(?:o(?:nths?)?)?";
3258
+ const weeksPart$1 = "(\\d+)\\s*w(?:eeks?)?";
3259
+ const daysPart$1 = "(\\d+)\\s*d(?:ays?)?";
3260
+ const hoursPart$1 = "(\\d+)\\s*h(?:ours?)?";
3261
+ const minutesPart$1 = "(\\d+)\\s*m(?:in(?:s|utes?)?)?";
3262
+ const secondsPart$1 = "(\\d+)(?:[,.](\\d{1,3}))?\\s*s(?:ec(?:s|onds?)?)?";
3263
+ const humanReadablePeriodRegex$1 = new RegExp(
3264
+ `^(?:${yearsPart$1})?\\s*(?:${monthsPart$1})?\\s*(?:${weeksPart$1})?\\s*(?:${daysPart$1})?\\s*$`,
3265
+ "i"
3266
+ );
3267
+ const humanReadableDurationRegex$1 = new RegExp(
3268
+ `^(?:${hoursPart$1})?\\s*(?:${minutesPart$1})?\\s*(?:${secondsPart$1})?$`,
3269
+ "i"
3270
+ );
3271
+ new RegExp(
3272
+ `^\\s*-\\s*\\(\\s*${humanReadablePeriodRegex$1.source.replace(/[$^]/g, "")}\\s*\\)\\s*$`,
3273
+ "i"
3274
+ );
3275
+ new RegExp(
3276
+ `^\\s*-\\s*\\(\\s*${humanReadableDurationRegex$1.source.replace(/[$^]/g, "")}\\s*\\)\\s*$`,
3277
+ "i"
3278
+ );
3279
+
3280
+ class AbortError extends Error {
3281
+ }
3282
+ const createAbortablePromise = () => {
3283
+ const abortController = new AbortController();
3284
+ const runAbortablePromise = (request) => {
3285
+ return new Promise((resolve, reject) => {
3286
+ const abortListener = ({ target }) => {
3287
+ abortController.signal.removeEventListener("abort", abortListener);
3288
+ const reason = target.reason;
3289
+ reject(reason instanceof AbortError ? reason : new AbortError(reason));
3290
+ };
3291
+ request().then(resolve).catch((error) => {
3292
+ if (error instanceof AbortError) {
3293
+ return;
3294
+ }
3295
+ reject(error);
3296
+ });
3297
+ abortController.signal.addEventListener("abort", abortListener);
3298
+ });
3299
+ };
3300
+ return { abortController, runAbortablePromise };
3301
+ };
942
3302
 
943
3303
  const createUnwrappedPromise = () => {
944
3304
  let resolve = () => {
@@ -956,6 +3316,42 @@ function sleep(ms) {
956
3316
  return new Promise((resolve) => setTimeout(resolve, ms));
957
3317
  }
958
3318
 
3319
+ const DEFAULT_RETRY_DELAY_MS = 0;
3320
+ const DEFAULT_RETRY_COUNT = 5;
3321
+ async function retryPromise({
3322
+ fn,
3323
+ retryCount = DEFAULT_RETRY_COUNT,
3324
+ retryDelayMS = DEFAULT_RETRY_DELAY_MS,
3325
+ excludeError
3326
+ }) {
3327
+ try {
3328
+ return await fn();
3329
+ } catch (error) {
3330
+ if (excludeError?.(error)) {
3331
+ throw error;
3332
+ }
3333
+ if (retryCount > 0) {
3334
+ await sleep(retryDelayMS);
3335
+ return await retryPromise({
3336
+ fn,
3337
+ retryCount: retryCount - 1,
3338
+ retryDelayMS,
3339
+ excludeError
3340
+ });
3341
+ }
3342
+ throw error;
3343
+ }
3344
+ }
3345
+
3346
+ const index = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
3347
+ __proto__: null,
3348
+ AbortError,
3349
+ DEFAULT_RETRY_COUNT,
3350
+ DEFAULT_RETRY_DELAY_MS,
3351
+ createAbortablePromise,
3352
+ createUnwrappedPromise,
3353
+ retryPromise
3354
+ }, Symbol.toStringTag, { value: 'Module' }));
959
3355
  const getMetaOrCtrlKey = () => {
960
3356
  return isMac() ? "metaKey" : "ctrlKey";
961
3357
  };
@@ -1499,10 +3895,10 @@ const defaultConfirmButton = {
1499
3895
  };
1500
3896
  const isActive = ref(false);
1501
3897
  const activeModalConfig = ref(null);
1502
- const unwrappedPromise = ref(createUnwrappedPromise());
3898
+ const unwrappedPromise = ref(index.createUnwrappedPromise());
1503
3899
  const resetInternalState = () => {
1504
3900
  isActive.value = false;
1505
- unwrappedPromise.value = createUnwrappedPromise();
3901
+ unwrappedPromise.value = index.createUnwrappedPromise();
1506
3902
  };
1507
3903
  const onClosed = () => {
1508
3904
  activeModalConfig.value = null;
@@ -1714,6 +4110,7 @@ const _sfc_main$1z = /* @__PURE__ */ defineComponent({
1714
4110
  popoverType: { default: "auto" },
1715
4111
  fullWidth: { type: Boolean, default: false },
1716
4112
  maxInlineSize: { default: () => void 0 },
4113
+ stretchInline: { type: Boolean, default: false },
1717
4114
  content: {},
1718
4115
  placement: { default: "bottom-left" },
1719
4116
  customPlacementPosition: {}
@@ -1723,7 +4120,7 @@ const _sfc_main$1z = /* @__PURE__ */ defineComponent({
1723
4120
  }),
1724
4121
  emits: ["update:modelValue"],
1725
4122
  setup(__props, { expose: __expose }) {
1726
- const props = createPropsRestProxy(__props, ["placement", "popoverType", "fullWidth", "maxInlineSize"]);
4123
+ const props = createPropsRestProxy(__props, ["placement", "popoverType", "fullWidth", "maxInlineSize", "stretchInline"]);
1727
4124
  const open = useModel(__props, "modelValue");
1728
4125
  const popoverEl = useTemplateRef("popoverEl");
1729
4126
  const popoverId = useId();
@@ -1750,7 +4147,8 @@ const _sfc_main$1z = /* @__PURE__ */ defineComponent({
1750
4147
  }
1751
4148
  return {
1752
4149
  "position-anchor": anchorName,
1753
- "max-inline-size": __props.maxInlineSize
4150
+ "max-inline-size": __props.maxInlineSize,
4151
+ ...__props.stretchInline && { "inset-inline-end": "0", "inline-size": "auto" }
1754
4152
  };
1755
4153
  });
1756
4154
  return (_ctx, _cache) => {
@@ -1772,7 +4170,7 @@ const _sfc_main$1z = /* @__PURE__ */ defineComponent({
1772
4170
  }
1773
4171
  });
1774
4172
 
1775
- const KdsPopover = /* @__PURE__ */ _export_sfc(_sfc_main$1z, [["__scopeId", "data-v-9efaee93"]]);
4173
+ const KdsPopover = /* @__PURE__ */ _export_sfc(_sfc_main$1z, [["__scopeId", "data-v-b0b887fb"]]);
1776
4174
 
1777
4175
  const KdsPopover$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
1778
4176
  __proto__: null,