@helpdice/ui 1.4.9 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1340,17 +1340,17 @@ var hasUserCustomTheme = function hasUserCustomTheme() {
1340
1340
  return isAvailableThemeType(item.type);
1341
1341
  });
1342
1342
  };
1343
- var create = function create(base, custom) {
1343
+ var create$1 = function create(base, custom) {
1344
1344
  if (!isAvailableThemeType(custom.type)) {
1345
1345
  throw new Error('Duplicate or unavailable theme type');
1346
1346
  }
1347
1347
  return _deepDuplicable(base, custom);
1348
1348
  };
1349
1349
  var createFromDark = function createFromDark(custom) {
1350
- return create(themes, custom);
1350
+ return create$1(themes, custom);
1351
1351
  };
1352
1352
  var createFromLight = function createFromLight(custom) {
1353
- return create(themes$1, custom);
1353
+ return create$1(themes$1, custom);
1354
1354
  };
1355
1355
  var Themes = {
1356
1356
  isPresetTheme: isPresetTheme,
@@ -1358,7 +1358,7 @@ var Themes = {
1358
1358
  hasUserCustomTheme: hasUserCustomTheme,
1359
1359
  getPresets: getPresets,
1360
1360
  getPresetStaticTheme: getPresetStaticTheme,
1361
- create: create,
1361
+ create: create$1,
1362
1362
  createFromDark: createFromDark,
1363
1363
  createFromLight: createFromLight
1364
1364
  };
@@ -13563,7 +13563,7 @@ var ButtonComponent = /*#__PURE__*/React$1.forwardRef(function (btnProps, ref) {
13563
13563
  ButtonComponent.displayName = 'Button';
13564
13564
  var Button = withScale(ButtonComponent);
13565
13565
 
13566
- function CompactButton(_ref) {
13566
+ var CompactButton = function CompactButton(_ref) {
13567
13567
  var _ref$to = _ref.to,
13568
13568
  to = _ref$to === undefined ? '/' : _ref$to,
13569
13569
  children = _ref.children,
@@ -13638,7 +13638,8 @@ function CompactButton(_ref) {
13638
13638
  px: 0.6,
13639
13639
  iconRight: iconRight
13640
13640
  }, children);
13641
- }
13641
+ };
13642
+ var button_compact = /*#__PURE__*/React$1.memo(CompactButton);
13642
13643
 
13643
13644
  /* "use client" */
13644
13645
 
@@ -20119,7 +20120,7 @@ function requireClone () {
20119
20120
  }
20120
20121
 
20121
20122
  var cloneExports = requireClone();
20122
- var clone = /*@__PURE__*/getDefaultExportFromCjs(cloneExports);
20123
+ var clone$1 = /*@__PURE__*/getDefaultExportFromCjs(cloneExports);
20123
20124
 
20124
20125
  /**
20125
20126
  * A specialized version of `_.map` for arrays without support for iteratee
@@ -20608,7 +20609,7 @@ function getIn(obj, key, def) {
20608
20609
  * @see https://github.com/jaredpalmer/formik/pull/123
20609
20610
  */
20610
20611
  function setIn(obj, path, value) {
20611
- var res = clone(obj); // this keeps inheritance when obj is a class
20612
+ var res = clone$1(obj); // this keeps inheritance when obj is a class
20612
20613
  var resVal = res;
20613
20614
  var i = 0;
20614
20615
  var pathArray = toPath(path);
@@ -20616,7 +20617,7 @@ function setIn(obj, path, value) {
20616
20617
  var currentPath = pathArray[i];
20617
20618
  var currentObj = getIn(obj, pathArray.slice(0, i + 1));
20618
20619
  if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) {
20619
- resVal = resVal[currentPath] = clone(currentObj);
20620
+ resVal = resVal[currentPath] = clone$1(currentObj);
20620
20621
  } else {
20621
20622
  var nextPath = pathArray[i + 1];
20622
20623
  resVal = resVal[currentPath] = isInteger(nextPath) && Number(nextPath) >= 0 ? [] : {};
@@ -22227,6 +22228,1352 @@ var GridContainer = withScale(GridContainerComponent);
22227
22228
 
22228
22229
  Grid.Container = GridContainer;
22229
22230
 
22231
+ /*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */
22232
+
22233
+ const {
22234
+ entries,
22235
+ setPrototypeOf,
22236
+ isFrozen,
22237
+ getPrototypeOf,
22238
+ getOwnPropertyDescriptor
22239
+ } = Object;
22240
+ let {
22241
+ freeze,
22242
+ seal,
22243
+ create
22244
+ } = Object; // eslint-disable-line import/no-mutable-exports
22245
+ let {
22246
+ apply,
22247
+ construct
22248
+ } = typeof Reflect !== 'undefined' && Reflect;
22249
+ if (!freeze) {
22250
+ freeze = function freeze(x) {
22251
+ return x;
22252
+ };
22253
+ }
22254
+ if (!seal) {
22255
+ seal = function seal(x) {
22256
+ return x;
22257
+ };
22258
+ }
22259
+ if (!apply) {
22260
+ apply = function apply(fun, thisValue, args) {
22261
+ return fun.apply(thisValue, args);
22262
+ };
22263
+ }
22264
+ if (!construct) {
22265
+ construct = function construct(Func, args) {
22266
+ return new Func(...args);
22267
+ };
22268
+ }
22269
+ const arrayForEach = unapply(Array.prototype.forEach);
22270
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
22271
+ const arrayPop = unapply(Array.prototype.pop);
22272
+ const arrayPush = unapply(Array.prototype.push);
22273
+ const arraySplice = unapply(Array.prototype.splice);
22274
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
22275
+ const stringToString = unapply(String.prototype.toString);
22276
+ const stringMatch = unapply(String.prototype.match);
22277
+ const stringReplace = unapply(String.prototype.replace);
22278
+ const stringIndexOf = unapply(String.prototype.indexOf);
22279
+ const stringTrim = unapply(String.prototype.trim);
22280
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
22281
+ const regExpTest = unapply(RegExp.prototype.test);
22282
+ const typeErrorCreate = unconstruct(TypeError);
22283
+ /**
22284
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
22285
+ *
22286
+ * @param func - The function to be wrapped and called.
22287
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
22288
+ */
22289
+ function unapply(func) {
22290
+ return function (thisArg) {
22291
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
22292
+ args[_key - 1] = arguments[_key];
22293
+ }
22294
+ return apply(func, thisArg, args);
22295
+ };
22296
+ }
22297
+ /**
22298
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
22299
+ *
22300
+ * @param func - The constructor function to be wrapped and called.
22301
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
22302
+ */
22303
+ function unconstruct(func) {
22304
+ return function () {
22305
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
22306
+ args[_key2] = arguments[_key2];
22307
+ }
22308
+ return construct(func, args);
22309
+ };
22310
+ }
22311
+ /**
22312
+ * Add properties to a lookup table
22313
+ *
22314
+ * @param set - The set to which elements will be added.
22315
+ * @param array - The array containing elements to be added to the set.
22316
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
22317
+ * @returns The modified set with added elements.
22318
+ */
22319
+ function addToSet(set, array) {
22320
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;
22321
+ if (setPrototypeOf) {
22322
+ // Make 'in' and truthy checks like Boolean(set.constructor)
22323
+ // independent of any properties defined on Object.prototype.
22324
+ // Prevent prototype setters from intercepting set as a this value.
22325
+ setPrototypeOf(set, null);
22326
+ }
22327
+ let l = array.length;
22328
+ while (l--) {
22329
+ let element = array[l];
22330
+ if (typeof element === 'string') {
22331
+ const lcElement = transformCaseFunc(element);
22332
+ if (lcElement !== element) {
22333
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
22334
+ if (!isFrozen(array)) {
22335
+ array[l] = lcElement;
22336
+ }
22337
+ element = lcElement;
22338
+ }
22339
+ }
22340
+ set[element] = true;
22341
+ }
22342
+ return set;
22343
+ }
22344
+ /**
22345
+ * Clean up an array to harden against CSPP
22346
+ *
22347
+ * @param array - The array to be cleaned.
22348
+ * @returns The cleaned version of the array
22349
+ */
22350
+ function cleanArray(array) {
22351
+ for (let index = 0; index < array.length; index++) {
22352
+ const isPropertyExist = objectHasOwnProperty(array, index);
22353
+ if (!isPropertyExist) {
22354
+ array[index] = null;
22355
+ }
22356
+ }
22357
+ return array;
22358
+ }
22359
+ /**
22360
+ * Shallow clone an object
22361
+ *
22362
+ * @param object - The object to be cloned.
22363
+ * @returns A new object that copies the original.
22364
+ */
22365
+ function clone(object) {
22366
+ const newObject = create(null);
22367
+ for (const [property, value] of entries(object)) {
22368
+ const isPropertyExist = objectHasOwnProperty(object, property);
22369
+ if (isPropertyExist) {
22370
+ if (Array.isArray(value)) {
22371
+ newObject[property] = cleanArray(value);
22372
+ } else if (value && typeof value === 'object' && value.constructor === Object) {
22373
+ newObject[property] = clone(value);
22374
+ } else {
22375
+ newObject[property] = value;
22376
+ }
22377
+ }
22378
+ }
22379
+ return newObject;
22380
+ }
22381
+ /**
22382
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
22383
+ *
22384
+ * @param object - The object to look up the getter function in its prototype chain.
22385
+ * @param prop - The property name for which to find the getter function.
22386
+ * @returns The getter function found in the prototype chain or a fallback function.
22387
+ */
22388
+ function lookupGetter(object, prop) {
22389
+ while (object !== null) {
22390
+ const desc = getOwnPropertyDescriptor(object, prop);
22391
+ if (desc) {
22392
+ if (desc.get) {
22393
+ return unapply(desc.get);
22394
+ }
22395
+ if (typeof desc.value === 'function') {
22396
+ return unapply(desc.value);
22397
+ }
22398
+ }
22399
+ object = getPrototypeOf(object);
22400
+ }
22401
+ function fallbackValue() {
22402
+ return null;
22403
+ }
22404
+ return fallbackValue;
22405
+ }
22406
+
22407
+ const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);
22408
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
22409
+ 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']);
22410
+ // List of SVG elements that are disallowed by default.
22411
+ // We still need to know them so that we can do namespace
22412
+ // checks properly in case one wants to add them to
22413
+ // allow-list.
22414
+ 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']);
22415
+ 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']);
22416
+ // Similarly to SVG, we want to know all MathML elements,
22417
+ // even those that we disallow by default.
22418
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
22419
+ const text = freeze(['#text']);
22420
+
22421
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);
22422
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
22423
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
22424
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
22425
+
22426
+ // eslint-disable-next-line unicorn/better-regex
22427
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
22428
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
22429
+ const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex
22430
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape
22431
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
22432
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
22433
+ );
22434
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
22435
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
22436
+ );
22437
+ const DOCTYPE_NAME = seal(/^html$/i);
22438
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
22439
+
22440
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
22441
+ __proto__: null,
22442
+ ARIA_ATTR: ARIA_ATTR,
22443
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
22444
+ CUSTOM_ELEMENT: CUSTOM_ELEMENT,
22445
+ DATA_ATTR: DATA_ATTR,
22446
+ DOCTYPE_NAME: DOCTYPE_NAME,
22447
+ ERB_EXPR: ERB_EXPR,
22448
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
22449
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
22450
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
22451
+ TMPLIT_EXPR: TMPLIT_EXPR
22452
+ });
22453
+
22454
+ /* eslint-disable @typescript-eslint/indent */
22455
+ // https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
22456
+ const NODE_TYPE = {
22457
+ element: 1,
22458
+ attribute: 2,
22459
+ text: 3,
22460
+ cdataSection: 4,
22461
+ entityReference: 5,
22462
+ // Deprecated
22463
+ entityNode: 6,
22464
+ // Deprecated
22465
+ progressingInstruction: 7,
22466
+ comment: 8,
22467
+ document: 9,
22468
+ documentType: 10,
22469
+ documentFragment: 11,
22470
+ notation: 12 // Deprecated
22471
+ };
22472
+ const getGlobal = function getGlobal() {
22473
+ return typeof window === 'undefined' ? null : window;
22474
+ };
22475
+ /**
22476
+ * Creates a no-op policy for internal use only.
22477
+ * Don't export this function outside this module!
22478
+ * @param trustedTypes The policy factory.
22479
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
22480
+ * @return The policy created (or null, if Trusted Types
22481
+ * are not supported or creating the policy failed).
22482
+ */
22483
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
22484
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
22485
+ return null;
22486
+ }
22487
+ // Allow the callers to control the unique policy name
22488
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
22489
+ // Policy creation with duplicate names throws in Trusted Types.
22490
+ let suffix = null;
22491
+ const ATTR_NAME = 'data-tt-policy-suffix';
22492
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
22493
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
22494
+ }
22495
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
22496
+ try {
22497
+ return trustedTypes.createPolicy(policyName, {
22498
+ createHTML(html) {
22499
+ return html;
22500
+ },
22501
+ createScriptURL(scriptUrl) {
22502
+ return scriptUrl;
22503
+ }
22504
+ });
22505
+ } catch (_) {
22506
+ // Policy creation failed (most likely another DOMPurify script has
22507
+ // already run). Skip creating the policy, as this will only cause errors
22508
+ // if TT are enforced.
22509
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
22510
+ return null;
22511
+ }
22512
+ };
22513
+ const _createHooksMap = function _createHooksMap() {
22514
+ return {
22515
+ afterSanitizeAttributes: [],
22516
+ afterSanitizeElements: [],
22517
+ afterSanitizeShadowDOM: [],
22518
+ beforeSanitizeAttributes: [],
22519
+ beforeSanitizeElements: [],
22520
+ beforeSanitizeShadowDOM: [],
22521
+ uponSanitizeAttribute: [],
22522
+ uponSanitizeElement: [],
22523
+ uponSanitizeShadowNode: []
22524
+ };
22525
+ };
22526
+ function createDOMPurify() {
22527
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
22528
+ const DOMPurify = root => createDOMPurify(root);
22529
+ DOMPurify.version = '3.2.4';
22530
+ DOMPurify.removed = [];
22531
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
22532
+ // Not running in a browser, provide a factory function
22533
+ // so that you can pass your own Window
22534
+ DOMPurify.isSupported = false;
22535
+ return DOMPurify;
22536
+ }
22537
+ let {
22538
+ document
22539
+ } = window;
22540
+ const originalDocument = document;
22541
+ const currentScript = originalDocument.currentScript;
22542
+ const {
22543
+ DocumentFragment,
22544
+ HTMLTemplateElement,
22545
+ Node,
22546
+ Element,
22547
+ NodeFilter,
22548
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
22549
+ HTMLFormElement,
22550
+ DOMParser,
22551
+ trustedTypes
22552
+ } = window;
22553
+ const ElementPrototype = Element.prototype;
22554
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
22555
+ const remove = lookupGetter(ElementPrototype, 'remove');
22556
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
22557
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
22558
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode');
22559
+ // As per issue #47, the web-components registry is inherited by a
22560
+ // new document created via createHTMLDocument. As per the spec
22561
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
22562
+ // a new empty registry is used when creating a template contents owner
22563
+ // document, so we use that as our parent document to ensure nothing
22564
+ // is inherited.
22565
+ if (typeof HTMLTemplateElement === 'function') {
22566
+ const template = document.createElement('template');
22567
+ if (template.content && template.content.ownerDocument) {
22568
+ document = template.content.ownerDocument;
22569
+ }
22570
+ }
22571
+ let trustedTypesPolicy;
22572
+ let emptyHTML = '';
22573
+ const {
22574
+ implementation,
22575
+ createNodeIterator,
22576
+ createDocumentFragment,
22577
+ getElementsByTagName
22578
+ } = document;
22579
+ const {
22580
+ importNode
22581
+ } = originalDocument;
22582
+ let hooks = _createHooksMap();
22583
+ /**
22584
+ * Expose whether this browser supports running the full DOMPurify.
22585
+ */
22586
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
22587
+ const {
22588
+ MUSTACHE_EXPR,
22589
+ ERB_EXPR,
22590
+ TMPLIT_EXPR,
22591
+ DATA_ATTR,
22592
+ ARIA_ATTR,
22593
+ IS_SCRIPT_OR_DATA,
22594
+ ATTR_WHITESPACE,
22595
+ CUSTOM_ELEMENT
22596
+ } = EXPRESSIONS;
22597
+ let {
22598
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
22599
+ } = EXPRESSIONS;
22600
+ /**
22601
+ * We consider the elements and attributes below to be safe. Ideally
22602
+ * don't add any new ones but feel free to remove unwanted ones.
22603
+ */
22604
+ /* allowed element names */
22605
+ let ALLOWED_TAGS = null;
22606
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
22607
+ /* Allowed attribute names */
22608
+ let ALLOWED_ATTR = null;
22609
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
22610
+ /*
22611
+ * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.
22612
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
22613
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
22614
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
22615
+ */
22616
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
22617
+ tagNameCheck: {
22618
+ writable: true,
22619
+ configurable: false,
22620
+ enumerable: true,
22621
+ value: null
22622
+ },
22623
+ attributeNameCheck: {
22624
+ writable: true,
22625
+ configurable: false,
22626
+ enumerable: true,
22627
+ value: null
22628
+ },
22629
+ allowCustomizedBuiltInElements: {
22630
+ writable: true,
22631
+ configurable: false,
22632
+ enumerable: true,
22633
+ value: false
22634
+ }
22635
+ }));
22636
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
22637
+ let FORBID_TAGS = null;
22638
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
22639
+ let FORBID_ATTR = null;
22640
+ /* Decide if ARIA attributes are okay */
22641
+ let ALLOW_ARIA_ATTR = true;
22642
+ /* Decide if custom data attributes are okay */
22643
+ let ALLOW_DATA_ATTR = true;
22644
+ /* Decide if unknown protocols are okay */
22645
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
22646
+ /* Decide if self-closing tags in attributes are allowed.
22647
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
22648
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
22649
+ /* Output should be safe for common template engines.
22650
+ * This means, DOMPurify removes data attributes, mustaches and ERB
22651
+ */
22652
+ let SAFE_FOR_TEMPLATES = false;
22653
+ /* Output should be safe even for XML used within HTML and alike.
22654
+ * This means, DOMPurify removes comments when containing risky content.
22655
+ */
22656
+ let SAFE_FOR_XML = true;
22657
+ /* Decide if document with <html>... should be returned */
22658
+ let WHOLE_DOCUMENT = false;
22659
+ /* Track whether config is already set on this instance of DOMPurify. */
22660
+ let SET_CONFIG = false;
22661
+ /* Decide if all elements (e.g. style, script) must be children of
22662
+ * document.body. By default, browsers might move them to document.head */
22663
+ let FORCE_BODY = false;
22664
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
22665
+ * string (or a TrustedHTML object if Trusted Types are supported).
22666
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
22667
+ */
22668
+ let RETURN_DOM = false;
22669
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
22670
+ * string (or a TrustedHTML object if Trusted Types are supported) */
22671
+ let RETURN_DOM_FRAGMENT = false;
22672
+ /* Try to return a Trusted Type object instead of a string, return a string in
22673
+ * case Trusted Types are not supported */
22674
+ let RETURN_TRUSTED_TYPE = false;
22675
+ /* Output should be free from DOM clobbering attacks?
22676
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
22677
+ */
22678
+ let SANITIZE_DOM = true;
22679
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
22680
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
22681
+ *
22682
+ * HTML/DOM spec rules that enable DOM Clobbering:
22683
+ * - Named Access on Window (§7.3.3)
22684
+ * - DOM Tree Accessors (§3.1.5)
22685
+ * - Form Element Parent-Child Relations (§4.10.3)
22686
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
22687
+ * - HTMLCollection (§4.2.10.2)
22688
+ *
22689
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
22690
+ * with a constant string, i.e., `user-content-`
22691
+ */
22692
+ let SANITIZE_NAMED_PROPS = false;
22693
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
22694
+ /* Keep element content when removing element? */
22695
+ let KEEP_CONTENT = true;
22696
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
22697
+ * of importing it into a new Document and returning a sanitized copy */
22698
+ let IN_PLACE = false;
22699
+ /* Allow usage of profiles like html, svg and mathMl */
22700
+ let USE_PROFILES = {};
22701
+ /* Tags to ignore content of when KEEP_CONTENT is true */
22702
+ let FORBID_CONTENTS = null;
22703
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
22704
+ /* Tags that are safe for data: URIs */
22705
+ let DATA_URI_TAGS = null;
22706
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
22707
+ /* Attributes safe for values like "javascript:" */
22708
+ let URI_SAFE_ATTRIBUTES = null;
22709
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
22710
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
22711
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
22712
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
22713
+ /* Document namespace */
22714
+ let NAMESPACE = HTML_NAMESPACE;
22715
+ let IS_EMPTY_INPUT = false;
22716
+ /* Allowed XHTML+XML namespaces */
22717
+ let ALLOWED_NAMESPACES = null;
22718
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
22719
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
22720
+ let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);
22721
+ // Certain elements are allowed in both SVG and HTML
22722
+ // namespace. We need to specify them explicitly
22723
+ // so that they don't get erroneously deleted from
22724
+ // HTML namespace.
22725
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
22726
+ /* Parsing of strict XHTML documents */
22727
+ let PARSER_MEDIA_TYPE = null;
22728
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
22729
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
22730
+ let transformCaseFunc = null;
22731
+ /* Keep a reference to config to pass to hooks */
22732
+ let CONFIG = null;
22733
+ /* Ideally, do not touch anything below this line */
22734
+ /* ______________________________________________ */
22735
+ const formElement = document.createElement('form');
22736
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
22737
+ return testValue instanceof RegExp || testValue instanceof Function;
22738
+ };
22739
+ /**
22740
+ * _parseConfig
22741
+ *
22742
+ * @param cfg optional config literal
22743
+ */
22744
+ // eslint-disable-next-line complexity
22745
+ const _parseConfig = function _parseConfig() {
22746
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
22747
+ if (CONFIG && CONFIG === cfg) {
22748
+ return;
22749
+ }
22750
+ /* Shield configuration object from tampering */
22751
+ if (!cfg || typeof cfg !== 'object') {
22752
+ cfg = {};
22753
+ }
22754
+ /* Shield configuration object from prototype pollution */
22755
+ cfg = clone(cfg);
22756
+ PARSER_MEDIA_TYPE =
22757
+ // eslint-disable-next-line unicorn/prefer-includes
22758
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
22759
+ // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
22760
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
22761
+ /* Set configuration parameters */
22762
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
22763
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
22764
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
22765
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
22766
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
22767
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
22768
+ FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
22769
+ FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
22770
+ USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;
22771
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
22772
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
22773
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
22774
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
22775
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
22776
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true
22777
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
22778
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
22779
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
22780
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
22781
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
22782
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
22783
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
22784
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
22785
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
22786
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
22787
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
22788
+ MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;
22789
+ HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;
22790
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
22791
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
22792
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
22793
+ }
22794
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
22795
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
22796
+ }
22797
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
22798
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
22799
+ }
22800
+ if (SAFE_FOR_TEMPLATES) {
22801
+ ALLOW_DATA_ATTR = false;
22802
+ }
22803
+ if (RETURN_DOM_FRAGMENT) {
22804
+ RETURN_DOM = true;
22805
+ }
22806
+ /* Parse profile info */
22807
+ if (USE_PROFILES) {
22808
+ ALLOWED_TAGS = addToSet({}, text);
22809
+ ALLOWED_ATTR = [];
22810
+ if (USE_PROFILES.html === true) {
22811
+ addToSet(ALLOWED_TAGS, html$1);
22812
+ addToSet(ALLOWED_ATTR, html);
22813
+ }
22814
+ if (USE_PROFILES.svg === true) {
22815
+ addToSet(ALLOWED_TAGS, svg$1);
22816
+ addToSet(ALLOWED_ATTR, svg);
22817
+ addToSet(ALLOWED_ATTR, xml);
22818
+ }
22819
+ if (USE_PROFILES.svgFilters === true) {
22820
+ addToSet(ALLOWED_TAGS, svgFilters);
22821
+ addToSet(ALLOWED_ATTR, svg);
22822
+ addToSet(ALLOWED_ATTR, xml);
22823
+ }
22824
+ if (USE_PROFILES.mathMl === true) {
22825
+ addToSet(ALLOWED_TAGS, mathMl$1);
22826
+ addToSet(ALLOWED_ATTR, mathMl);
22827
+ addToSet(ALLOWED_ATTR, xml);
22828
+ }
22829
+ }
22830
+ /* Merge configuration parameters */
22831
+ if (cfg.ADD_TAGS) {
22832
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
22833
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
22834
+ }
22835
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
22836
+ }
22837
+ if (cfg.ADD_ATTR) {
22838
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
22839
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
22840
+ }
22841
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
22842
+ }
22843
+ if (cfg.ADD_URI_SAFE_ATTR) {
22844
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
22845
+ }
22846
+ if (cfg.FORBID_CONTENTS) {
22847
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
22848
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
22849
+ }
22850
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
22851
+ }
22852
+ /* Add #text in case KEEP_CONTENT is set to true */
22853
+ if (KEEP_CONTENT) {
22854
+ ALLOWED_TAGS['#text'] = true;
22855
+ }
22856
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
22857
+ if (WHOLE_DOCUMENT) {
22858
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
22859
+ }
22860
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
22861
+ if (ALLOWED_TAGS.table) {
22862
+ addToSet(ALLOWED_TAGS, ['tbody']);
22863
+ delete FORBID_TAGS.tbody;
22864
+ }
22865
+ if (cfg.TRUSTED_TYPES_POLICY) {
22866
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
22867
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
22868
+ }
22869
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
22870
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
22871
+ }
22872
+ // Overwrite existing TrustedTypes policy.
22873
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
22874
+ // Sign local variables required by `sanitize`.
22875
+ emptyHTML = trustedTypesPolicy.createHTML('');
22876
+ } else {
22877
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
22878
+ if (trustedTypesPolicy === undefined) {
22879
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
22880
+ }
22881
+ // If creating the internal policy succeeded sign internal variables.
22882
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
22883
+ emptyHTML = trustedTypesPolicy.createHTML('');
22884
+ }
22885
+ }
22886
+ // Prevent further manipulation of configuration.
22887
+ // Not available in IE8, Safari 5, etc.
22888
+ if (freeze) {
22889
+ freeze(cfg);
22890
+ }
22891
+ CONFIG = cfg;
22892
+ };
22893
+ /* Keep track of all possible SVG and MathML tags
22894
+ * so that we can perform the namespace checks
22895
+ * correctly. */
22896
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
22897
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
22898
+ /**
22899
+ * @param element a DOM element whose namespace is being checked
22900
+ * @returns Return false if the element has a
22901
+ * namespace that a spec-compliant parser would never
22902
+ * return. Return true otherwise.
22903
+ */
22904
+ const _checkValidNamespace = function _checkValidNamespace(element) {
22905
+ let parent = getParentNode(element);
22906
+ // In JSDOM, if we're inside shadow DOM, then parentNode
22907
+ // can be null. We just simulate parent in this case.
22908
+ if (!parent || !parent.tagName) {
22909
+ parent = {
22910
+ namespaceURI: NAMESPACE,
22911
+ tagName: 'template'
22912
+ };
22913
+ }
22914
+ const tagName = stringToLowerCase(element.tagName);
22915
+ const parentTagName = stringToLowerCase(parent.tagName);
22916
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
22917
+ return false;
22918
+ }
22919
+ if (element.namespaceURI === SVG_NAMESPACE) {
22920
+ // The only way to switch from HTML namespace to SVG
22921
+ // is via <svg>. If it happens via any other tag, then
22922
+ // it should be killed.
22923
+ if (parent.namespaceURI === HTML_NAMESPACE) {
22924
+ return tagName === 'svg';
22925
+ }
22926
+ // The only way to switch from MathML to SVG is via`
22927
+ // svg if parent is either <annotation-xml> or MathML
22928
+ // text integration points.
22929
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
22930
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
22931
+ }
22932
+ // We only allow elements that are defined in SVG
22933
+ // spec. All others are disallowed in SVG namespace.
22934
+ return Boolean(ALL_SVG_TAGS[tagName]);
22935
+ }
22936
+ if (element.namespaceURI === MATHML_NAMESPACE) {
22937
+ // The only way to switch from HTML namespace to MathML
22938
+ // is via <math>. If it happens via any other tag, then
22939
+ // it should be killed.
22940
+ if (parent.namespaceURI === HTML_NAMESPACE) {
22941
+ return tagName === 'math';
22942
+ }
22943
+ // The only way to switch from SVG to MathML is via
22944
+ // <math> and HTML integration points
22945
+ if (parent.namespaceURI === SVG_NAMESPACE) {
22946
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
22947
+ }
22948
+ // We only allow elements that are defined in MathML
22949
+ // spec. All others are disallowed in MathML namespace.
22950
+ return Boolean(ALL_MATHML_TAGS[tagName]);
22951
+ }
22952
+ if (element.namespaceURI === HTML_NAMESPACE) {
22953
+ // The only way to switch from SVG to HTML is via
22954
+ // HTML integration points, and from MathML to HTML
22955
+ // is via MathML text integration points
22956
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
22957
+ return false;
22958
+ }
22959
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
22960
+ return false;
22961
+ }
22962
+ // We disallow tags that are specific for MathML
22963
+ // or SVG and should never appear in HTML namespace
22964
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
22965
+ }
22966
+ // For XHTML and XML documents that support custom namespaces
22967
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
22968
+ return true;
22969
+ }
22970
+ // The code should never reach this place (this means
22971
+ // that the element somehow got namespace that is not
22972
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
22973
+ // Return false just in case.
22974
+ return false;
22975
+ };
22976
+ /**
22977
+ * _forceRemove
22978
+ *
22979
+ * @param node a DOM node
22980
+ */
22981
+ const _forceRemove = function _forceRemove(node) {
22982
+ arrayPush(DOMPurify.removed, {
22983
+ element: node
22984
+ });
22985
+ try {
22986
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
22987
+ getParentNode(node).removeChild(node);
22988
+ } catch (_) {
22989
+ remove(node);
22990
+ }
22991
+ };
22992
+ /**
22993
+ * _removeAttribute
22994
+ *
22995
+ * @param name an Attribute name
22996
+ * @param element a DOM node
22997
+ */
22998
+ const _removeAttribute = function _removeAttribute(name, element) {
22999
+ try {
23000
+ arrayPush(DOMPurify.removed, {
23001
+ attribute: element.getAttributeNode(name),
23002
+ from: element
23003
+ });
23004
+ } catch (_) {
23005
+ arrayPush(DOMPurify.removed, {
23006
+ attribute: null,
23007
+ from: element
23008
+ });
23009
+ }
23010
+ element.removeAttribute(name);
23011
+ // We void attribute values for unremovable "is" attributes
23012
+ if (name === 'is') {
23013
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
23014
+ try {
23015
+ _forceRemove(element);
23016
+ } catch (_) {}
23017
+ } else {
23018
+ try {
23019
+ element.setAttribute(name, '');
23020
+ } catch (_) {}
23021
+ }
23022
+ }
23023
+ };
23024
+ /**
23025
+ * _initDocument
23026
+ *
23027
+ * @param dirty - a string of dirty markup
23028
+ * @return a DOM, filled with the dirty markup
23029
+ */
23030
+ const _initDocument = function _initDocument(dirty) {
23031
+ /* Create a HTML document */
23032
+ let doc = null;
23033
+ let leadingWhitespace = null;
23034
+ if (FORCE_BODY) {
23035
+ dirty = '<remove></remove>' + dirty;
23036
+ } else {
23037
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
23038
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
23039
+ leadingWhitespace = matches && matches[0];
23040
+ }
23041
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
23042
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
23043
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
23044
+ }
23045
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
23046
+ /*
23047
+ * Use the DOMParser API by default, fallback later if needs be
23048
+ * DOMParser not work for svg when has multiple root element.
23049
+ */
23050
+ if (NAMESPACE === HTML_NAMESPACE) {
23051
+ try {
23052
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
23053
+ } catch (_) {}
23054
+ }
23055
+ /* Use createHTMLDocument in case DOMParser is not available */
23056
+ if (!doc || !doc.documentElement) {
23057
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
23058
+ try {
23059
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
23060
+ } catch (_) {
23061
+ // Syntax error if dirtyPayload is invalid xml
23062
+ }
23063
+ }
23064
+ const body = doc.body || doc.documentElement;
23065
+ if (dirty && leadingWhitespace) {
23066
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
23067
+ }
23068
+ /* Work on whole document or just its body */
23069
+ if (NAMESPACE === HTML_NAMESPACE) {
23070
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
23071
+ }
23072
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
23073
+ };
23074
+ /**
23075
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
23076
+ *
23077
+ * @param root The root element or node to start traversing on.
23078
+ * @return The created NodeIterator
23079
+ */
23080
+ const _createNodeIterator = function _createNodeIterator(root) {
23081
+ return createNodeIterator.call(root.ownerDocument || root, root,
23082
+ // eslint-disable-next-line no-bitwise
23083
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
23084
+ };
23085
+ /**
23086
+ * _isClobbered
23087
+ *
23088
+ * @param element element to check for clobbering attacks
23089
+ * @return true if clobbered, false if safe
23090
+ */
23091
+ const _isClobbered = function _isClobbered(element) {
23092
+ return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');
23093
+ };
23094
+ /**
23095
+ * Checks whether the given object is a DOM node.
23096
+ *
23097
+ * @param value object to check whether it's a DOM node
23098
+ * @return true is object is a DOM node
23099
+ */
23100
+ const _isNode = function _isNode(value) {
23101
+ return typeof Node === 'function' && value instanceof Node;
23102
+ };
23103
+ function _executeHooks(hooks, currentNode, data) {
23104
+ arrayForEach(hooks, hook => {
23105
+ hook.call(DOMPurify, currentNode, data, CONFIG);
23106
+ });
23107
+ }
23108
+ /**
23109
+ * _sanitizeElements
23110
+ *
23111
+ * @protect nodeName
23112
+ * @protect textContent
23113
+ * @protect removeChild
23114
+ * @param currentNode to check for permission to exist
23115
+ * @return true if node was killed, false if left alive
23116
+ */
23117
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
23118
+ let content = null;
23119
+ /* Execute a hook if present */
23120
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
23121
+ /* Check if element is clobbered or can clobber */
23122
+ if (_isClobbered(currentNode)) {
23123
+ _forceRemove(currentNode);
23124
+ return true;
23125
+ }
23126
+ /* Now let's check the element's type and name */
23127
+ const tagName = transformCaseFunc(currentNode.nodeName);
23128
+ /* Execute a hook if present */
23129
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
23130
+ tagName,
23131
+ allowedTags: ALLOWED_TAGS
23132
+ });
23133
+ /* Detect mXSS attempts abusing namespace confusion */
23134
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
23135
+ _forceRemove(currentNode);
23136
+ return true;
23137
+ }
23138
+ /* Remove any occurrence of processing instructions */
23139
+ if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
23140
+ _forceRemove(currentNode);
23141
+ return true;
23142
+ }
23143
+ /* Remove any kind of possibly harmful comments */
23144
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
23145
+ _forceRemove(currentNode);
23146
+ return true;
23147
+ }
23148
+ /* Remove element if anything forbids its presence */
23149
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
23150
+ /* Check if we have a custom element to handle */
23151
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
23152
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
23153
+ return false;
23154
+ }
23155
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
23156
+ return false;
23157
+ }
23158
+ }
23159
+ /* Keep content except for bad-listed elements */
23160
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
23161
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
23162
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
23163
+ if (childNodes && parentNode) {
23164
+ const childCount = childNodes.length;
23165
+ for (let i = childCount - 1; i >= 0; --i) {
23166
+ const childClone = cloneNode(childNodes[i], true);
23167
+ childClone.__removalCount = (currentNode.__removalCount || 0) + 1;
23168
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
23169
+ }
23170
+ }
23171
+ }
23172
+ _forceRemove(currentNode);
23173
+ return true;
23174
+ }
23175
+ /* Check whether element has a valid namespace */
23176
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
23177
+ _forceRemove(currentNode);
23178
+ return true;
23179
+ }
23180
+ /* Make sure that older browsers don't get fallback-tag mXSS */
23181
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
23182
+ _forceRemove(currentNode);
23183
+ return true;
23184
+ }
23185
+ /* Sanitize element content to be template-safe */
23186
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
23187
+ /* Get the element's text content */
23188
+ content = currentNode.textContent;
23189
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
23190
+ content = stringReplace(content, expr, ' ');
23191
+ });
23192
+ if (currentNode.textContent !== content) {
23193
+ arrayPush(DOMPurify.removed, {
23194
+ element: currentNode.cloneNode()
23195
+ });
23196
+ currentNode.textContent = content;
23197
+ }
23198
+ }
23199
+ /* Execute a hook if present */
23200
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
23201
+ return false;
23202
+ };
23203
+ /**
23204
+ * _isValidAttribute
23205
+ *
23206
+ * @param lcTag Lowercase tag name of containing element.
23207
+ * @param lcName Lowercase attribute name.
23208
+ * @param value Attribute value.
23209
+ * @return Returns true if `value` is valid, otherwise false.
23210
+ */
23211
+ // eslint-disable-next-line complexity
23212
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
23213
+ /* Make sure attribute cannot clobber */
23214
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
23215
+ return false;
23216
+ }
23217
+ /* Allow valid data-* attributes: At least one character after "-"
23218
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
23219
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
23220
+ We don't need to check the value; it's always URI safe. */
23221
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
23222
+ if (
23223
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
23224
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
23225
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
23226
+ _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)) ||
23227
+ // Alternative, second condition checks if it's an `is`-attribute, AND
23228
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
23229
+ 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 {
23230
+ return false;
23231
+ }
23232
+ /* Check value is safe. First, is attr inert? If so, is safe */
23233
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
23234
+ return false;
23235
+ } else ;
23236
+ return true;
23237
+ };
23238
+ /**
23239
+ * _isBasicCustomElement
23240
+ * checks if at least one dash is included in tagName, and it's not the first char
23241
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
23242
+ *
23243
+ * @param tagName name of the tag of the node to sanitize
23244
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
23245
+ */
23246
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
23247
+ return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);
23248
+ };
23249
+ /**
23250
+ * _sanitizeAttributes
23251
+ *
23252
+ * @protect attributes
23253
+ * @protect nodeName
23254
+ * @protect removeAttribute
23255
+ * @protect setAttribute
23256
+ *
23257
+ * @param currentNode to sanitize
23258
+ */
23259
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
23260
+ /* Execute a hook if present */
23261
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
23262
+ const {
23263
+ attributes
23264
+ } = currentNode;
23265
+ /* Check if we have attributes; if not we might have a text node */
23266
+ if (!attributes || _isClobbered(currentNode)) {
23267
+ return;
23268
+ }
23269
+ const hookEvent = {
23270
+ attrName: '',
23271
+ attrValue: '',
23272
+ keepAttr: true,
23273
+ allowedAttributes: ALLOWED_ATTR,
23274
+ forceKeepAttr: undefined
23275
+ };
23276
+ let l = attributes.length;
23277
+ /* Go backwards over all attributes; safely remove bad ones */
23278
+ while (l--) {
23279
+ const attr = attributes[l];
23280
+ const {
23281
+ name,
23282
+ namespaceURI,
23283
+ value: attrValue
23284
+ } = attr;
23285
+ const lcName = transformCaseFunc(name);
23286
+ let value = name === 'value' ? attrValue : stringTrim(attrValue);
23287
+ /* Execute a hook if present */
23288
+ hookEvent.attrName = lcName;
23289
+ hookEvent.attrValue = value;
23290
+ hookEvent.keepAttr = true;
23291
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
23292
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
23293
+ value = hookEvent.attrValue;
23294
+ /* Full DOM Clobbering protection via namespace isolation,
23295
+ * Prefix id and name attributes with `user-content-`
23296
+ */
23297
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
23298
+ // Remove the attribute with this value
23299
+ _removeAttribute(name, currentNode);
23300
+ // Prefix the value and later re-create the attribute with the sanitized value
23301
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
23302
+ }
23303
+ /* Work around a security issue with comments inside attributes */
23304
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title)/i, value)) {
23305
+ _removeAttribute(name, currentNode);
23306
+ continue;
23307
+ }
23308
+ /* Did the hooks approve of the attribute? */
23309
+ if (hookEvent.forceKeepAttr) {
23310
+ continue;
23311
+ }
23312
+ /* Remove attribute */
23313
+ _removeAttribute(name, currentNode);
23314
+ /* Did the hooks approve of the attribute? */
23315
+ if (!hookEvent.keepAttr) {
23316
+ continue;
23317
+ }
23318
+ /* Work around a security issue in jQuery 3.0 */
23319
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
23320
+ _removeAttribute(name, currentNode);
23321
+ continue;
23322
+ }
23323
+ /* Sanitize attribute content to be template-safe */
23324
+ if (SAFE_FOR_TEMPLATES) {
23325
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
23326
+ value = stringReplace(value, expr, ' ');
23327
+ });
23328
+ }
23329
+ /* Is `value` valid for this attribute? */
23330
+ const lcTag = transformCaseFunc(currentNode.nodeName);
23331
+ if (!_isValidAttribute(lcTag, lcName, value)) {
23332
+ continue;
23333
+ }
23334
+ /* Handle attributes that require Trusted Types */
23335
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
23336
+ if (namespaceURI) ; else {
23337
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
23338
+ case 'TrustedHTML':
23339
+ {
23340
+ value = trustedTypesPolicy.createHTML(value);
23341
+ break;
23342
+ }
23343
+ case 'TrustedScriptURL':
23344
+ {
23345
+ value = trustedTypesPolicy.createScriptURL(value);
23346
+ break;
23347
+ }
23348
+ }
23349
+ }
23350
+ }
23351
+ /* Handle invalid data-* attribute set by try-catching it */
23352
+ try {
23353
+ if (namespaceURI) {
23354
+ currentNode.setAttributeNS(namespaceURI, name, value);
23355
+ } else {
23356
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
23357
+ currentNode.setAttribute(name, value);
23358
+ }
23359
+ if (_isClobbered(currentNode)) {
23360
+ _forceRemove(currentNode);
23361
+ } else {
23362
+ arrayPop(DOMPurify.removed);
23363
+ }
23364
+ } catch (_) {}
23365
+ }
23366
+ /* Execute a hook if present */
23367
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
23368
+ };
23369
+ /**
23370
+ * _sanitizeShadowDOM
23371
+ *
23372
+ * @param fragment to iterate over recursively
23373
+ */
23374
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
23375
+ let shadowNode = null;
23376
+ const shadowIterator = _createNodeIterator(fragment);
23377
+ /* Execute a hook if present */
23378
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
23379
+ while (shadowNode = shadowIterator.nextNode()) {
23380
+ /* Execute a hook if present */
23381
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
23382
+ /* Sanitize tags and elements */
23383
+ _sanitizeElements(shadowNode);
23384
+ /* Check attributes next */
23385
+ _sanitizeAttributes(shadowNode);
23386
+ /* Deep shadow DOM detected */
23387
+ if (shadowNode.content instanceof DocumentFragment) {
23388
+ _sanitizeShadowDOM(shadowNode.content);
23389
+ }
23390
+ }
23391
+ /* Execute a hook if present */
23392
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
23393
+ };
23394
+ // eslint-disable-next-line complexity
23395
+ DOMPurify.sanitize = function (dirty) {
23396
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23397
+ let body = null;
23398
+ let importedNode = null;
23399
+ let currentNode = null;
23400
+ let returnNode = null;
23401
+ /* Make sure we have a string to sanitize.
23402
+ DO NOT return early, as this will return the wrong type if
23403
+ the user has requested a DOM object rather than a string */
23404
+ IS_EMPTY_INPUT = !dirty;
23405
+ if (IS_EMPTY_INPUT) {
23406
+ dirty = '<!-->';
23407
+ }
23408
+ /* Stringify, in case dirty is an object */
23409
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
23410
+ if (typeof dirty.toString === 'function') {
23411
+ dirty = dirty.toString();
23412
+ if (typeof dirty !== 'string') {
23413
+ throw typeErrorCreate('dirty is not a string, aborting');
23414
+ }
23415
+ } else {
23416
+ throw typeErrorCreate('toString is not a function');
23417
+ }
23418
+ }
23419
+ /* Return dirty HTML if DOMPurify cannot run */
23420
+ if (!DOMPurify.isSupported) {
23421
+ return dirty;
23422
+ }
23423
+ /* Assign config vars */
23424
+ if (!SET_CONFIG) {
23425
+ _parseConfig(cfg);
23426
+ }
23427
+ /* Clean up removed elements */
23428
+ DOMPurify.removed = [];
23429
+ /* Check if dirty is correctly typed for IN_PLACE */
23430
+ if (typeof dirty === 'string') {
23431
+ IN_PLACE = false;
23432
+ }
23433
+ if (IN_PLACE) {
23434
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
23435
+ if (dirty.nodeName) {
23436
+ const tagName = transformCaseFunc(dirty.nodeName);
23437
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
23438
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
23439
+ }
23440
+ }
23441
+ } else if (dirty instanceof Node) {
23442
+ /* If dirty is a DOM element, append to an empty document to avoid
23443
+ elements being stripped by the parser */
23444
+ body = _initDocument('<!---->');
23445
+ importedNode = body.ownerDocument.importNode(dirty, true);
23446
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {
23447
+ /* Node is already a body, use as is */
23448
+ body = importedNode;
23449
+ } else if (importedNode.nodeName === 'HTML') {
23450
+ body = importedNode;
23451
+ } else {
23452
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
23453
+ body.appendChild(importedNode);
23454
+ }
23455
+ } else {
23456
+ /* Exit directly if we have nothing to do */
23457
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&
23458
+ // eslint-disable-next-line unicorn/prefer-includes
23459
+ dirty.indexOf('<') === -1) {
23460
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
23461
+ }
23462
+ /* Initialize the document to work on */
23463
+ body = _initDocument(dirty);
23464
+ /* Check we have a DOM node from the data */
23465
+ if (!body) {
23466
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
23467
+ }
23468
+ }
23469
+ /* Remove first element node (ours) if FORCE_BODY is set */
23470
+ if (body && FORCE_BODY) {
23471
+ _forceRemove(body.firstChild);
23472
+ }
23473
+ /* Get node iterator */
23474
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
23475
+ /* Now start iterating over the created document */
23476
+ while (currentNode = nodeIterator.nextNode()) {
23477
+ /* Sanitize tags and elements */
23478
+ _sanitizeElements(currentNode);
23479
+ /* Check attributes next */
23480
+ _sanitizeAttributes(currentNode);
23481
+ /* Shadow DOM detected, sanitize it */
23482
+ if (currentNode.content instanceof DocumentFragment) {
23483
+ _sanitizeShadowDOM(currentNode.content);
23484
+ }
23485
+ }
23486
+ /* If we sanitized `dirty` in-place, return it. */
23487
+ if (IN_PLACE) {
23488
+ return dirty;
23489
+ }
23490
+ /* Return sanitized string or DOM */
23491
+ if (RETURN_DOM) {
23492
+ if (RETURN_DOM_FRAGMENT) {
23493
+ returnNode = createDocumentFragment.call(body.ownerDocument);
23494
+ while (body.firstChild) {
23495
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
23496
+ returnNode.appendChild(body.firstChild);
23497
+ }
23498
+ } else {
23499
+ returnNode = body;
23500
+ }
23501
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
23502
+ /*
23503
+ AdoptNode() is not used because internal state is not reset
23504
+ (e.g. the past names map of a HTMLFormElement), this is safe
23505
+ in theory but we would rather not risk another attack vector.
23506
+ The state that is cloned by importNode() is explicitly defined
23507
+ by the specs.
23508
+ */
23509
+ returnNode = importNode.call(originalDocument, returnNode, true);
23510
+ }
23511
+ return returnNode;
23512
+ }
23513
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
23514
+ /* Serialize doctype if allowed */
23515
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
23516
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
23517
+ }
23518
+ /* Sanitize final string template-safe */
23519
+ if (SAFE_FOR_TEMPLATES) {
23520
+ arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {
23521
+ serializedHTML = stringReplace(serializedHTML, expr, ' ');
23522
+ });
23523
+ }
23524
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
23525
+ };
23526
+ DOMPurify.setConfig = function () {
23527
+ let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23528
+ _parseConfig(cfg);
23529
+ SET_CONFIG = true;
23530
+ };
23531
+ DOMPurify.clearConfig = function () {
23532
+ CONFIG = null;
23533
+ SET_CONFIG = false;
23534
+ };
23535
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
23536
+ /* Initialize shared config vars if necessary. */
23537
+ if (!CONFIG) {
23538
+ _parseConfig({});
23539
+ }
23540
+ const lcTag = transformCaseFunc(tag);
23541
+ const lcName = transformCaseFunc(attr);
23542
+ return _isValidAttribute(lcTag, lcName, value);
23543
+ };
23544
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
23545
+ if (typeof hookFunction !== 'function') {
23546
+ return;
23547
+ }
23548
+ arrayPush(hooks[entryPoint], hookFunction);
23549
+ };
23550
+ DOMPurify.removeHook = function (entryPoint, hookFunction) {
23551
+ if (hookFunction !== undefined) {
23552
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
23553
+ return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];
23554
+ }
23555
+ return arrayPop(hooks[entryPoint]);
23556
+ };
23557
+ DOMPurify.removeHooks = function (entryPoint) {
23558
+ hooks[entryPoint] = [];
23559
+ };
23560
+ DOMPurify.removeAllHooks = function () {
23561
+ hooks = _createHooksMap();
23562
+ };
23563
+ return DOMPurify;
23564
+ }
23565
+ var purify = createDOMPurify();
23566
+
23567
+ var HtmlRenderer = function HtmlRenderer(_ref) {
23568
+ var htmlString = _ref.htmlString;
23569
+ var sanitizedHTML = purify.sanitize(htmlString);
23570
+ return /*#__PURE__*/React$1.createElement("div", {
23571
+ dangerouslySetInnerHTML: {
23572
+ __html: sanitizedHTML
23573
+ }
23574
+ });
23575
+ };
23576
+
22230
23577
  var _excluded$C = ["command", "shift", "option", "ctrl", "children", "className"];
22231
23578
  var KeyboardComponent = function KeyboardComponent(_ref) {
22232
23579
  var _ref$command = _ref.command,
@@ -46713,13 +48060,14 @@ exports.FormikContext = FormikContext;
46713
48060
  exports.FormikProvider = FormikProvider;
46714
48061
  exports.Grid = Grid;
46715
48062
  exports.Highlight = Highlight;
48063
+ exports.HtmlRenderer = HtmlRenderer;
46716
48064
  exports.Image = Image;
46717
48065
  exports.Input = Input;
46718
48066
  exports.KeyCode = KeyCode;
46719
48067
  exports.KeyMod = KeyMod;
46720
48068
  exports.Keyboard = Keyboard;
46721
48069
  exports.Link = Link;
46722
- exports.LinkButton = CompactButton;
48070
+ exports.LinkButton = button_compact;
46723
48071
  exports.Loading = Loading;
46724
48072
  exports.LoginWithApple = index$1;
46725
48073
  exports.LoginWithFacebook = index$9;