@vaadin/bundles 24.9.20 → 24.9.21

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.
@@ -0,0 +1,2557 @@
1
+ (self["webpackChunk_vaadin_bundles"] = self["webpackChunk_vaadin_bundles"] || []).push([["vendors-node_modules_vaadin_markdown_node_modules_dompurify_dist_purify_es_mjs"],{
2
+
3
+ /***/ "./node_modules/@vaadin/markdown/node_modules/dompurify/dist/purify.es.mjs":
4
+ /*!*********************************************************************************!*\
5
+ !*** ./node_modules/@vaadin/markdown/node_modules/dompurify/dist/purify.es.mjs ***!
6
+ \*********************************************************************************/
7
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
8
+
9
+ __webpack_require__.r(__webpack_exports__);
10
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11
+ /* harmony export */ "default": () => (/* binding */ purify_default)
12
+ /* harmony export */ });
13
+ /*! @license DOMPurify 3.4.17 | (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.17/LICENSE */
14
+ function _OverloadYield(e, d) {
15
+ this.v = e, this.k = d;
16
+ }
17
+ function _arrayLikeToArray(r, a) {
18
+ (null == a || a > r.length) && (a = r.length);
19
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
20
+ return n;
21
+ }
22
+ function _arrayWithHoles(r) {
23
+ if (Array.isArray(r)) return r;
24
+ }
25
+ function _iterableToArrayLimit(r, l) {
26
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
27
+ if (null != t) {
28
+ var e, n, i, u, a = [], f = !0, o = !1;
29
+ try {
30
+ if (i = (t = t.call(r)).next, 0 === l) {
31
+ if (Object(t) !== t) return;
32
+ f = !1;
33
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
34
+ } catch (r) {
35
+ o = !0, n = r;
36
+ } finally {
37
+ try {
38
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
39
+ } finally {
40
+ if (o) throw n;
41
+ }
42
+ }
43
+ return a;
44
+ }
45
+ }
46
+ function _nonIterableRest() {
47
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48
+ }
49
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
50
+ function _slicedToArray(r, e) {
51
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
52
+ }
53
+ function _unsupportedIterableToArray(r, a) {
54
+ if (r) {
55
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
56
+ var t = {}.toString.call(r).slice(8, -1);
57
+ 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;
58
+ }
59
+ }
60
+ function AsyncGenerator(e) {
61
+ var t, n;
62
+ function resume(t, n) {
63
+ try {
64
+ var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
65
+ Promise.resolve(u ? o.v : o).then(function(n) {
66
+ if (u) {
67
+ var i = "return" === t && o.k ? t : "next";
68
+ if (!o.k || n.done) return resume(i, n);
69
+ n = e[i](n).value;
70
+ }
71
+ settle(!!r.done, n);
72
+ }, function(e) {
73
+ resume("throw", e);
74
+ });
75
+ } catch (e) {
76
+ settle(2, e);
77
+ }
78
+ }
79
+ function settle(e, r) {
80
+ 2 === e ? t.reject(r) : t.resolve({
81
+ value: r,
82
+ done: e
83
+ }), (t = t.next) ? resume(t.key, t.arg) : n = null;
84
+ }
85
+ this._invoke = function(e, r) {
86
+ return new Promise(function(o, u) {
87
+ var i = {
88
+ key: e,
89
+ arg: r,
90
+ resolve: o,
91
+ reject: u,
92
+ next: null
93
+ };
94
+ n ? n = n.next = i : (t = n = i, resume(e, r));
95
+ });
96
+ }, "function" != typeof e.return && (this.return = void 0);
97
+ }
98
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
99
+ return this;
100
+ }, AsyncGenerator.prototype.next = function(e) {
101
+ return this._invoke("next", e);
102
+ }, AsyncGenerator.prototype.throw = function(e) {
103
+ return this._invoke("throw", e);
104
+ }, AsyncGenerator.prototype.return = function(e) {
105
+ return this._invoke("return", e);
106
+ };
107
+ const entries = Object.entries;
108
+ const setPrototypeOf = Object.setPrototypeOf;
109
+ const isFrozen = Object.isFrozen;
110
+ const getPrototypeOf = Object.getPrototypeOf;
111
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
112
+ let freeze = Object.freeze;
113
+ let seal = Object.seal;
114
+ let create = Object.create;
115
+ let _ref = typeof Reflect !== "undefined" && Reflect;
116
+ let apply = _ref.apply;
117
+ let construct = _ref.construct;
118
+ if (!freeze) freeze = function freeze(x) {
119
+ return x;
120
+ };
121
+ if (!seal) seal = function seal(x) {
122
+ return x;
123
+ };
124
+ if (!apply) apply = function apply(func, thisArg) {
125
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
126
+ return func.apply(thisArg, args);
127
+ };
128
+ if (!construct) construct = function construct(Func) {
129
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
130
+ return new Func(...args);
131
+ };
132
+ const arrayForEach = unapply(Array.prototype.forEach);
133
+ Array.prototype.indexOf;
134
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
135
+ const arrayPop = unapply(Array.prototype.pop);
136
+ const arrayPush = unapply(Array.prototype.push);
137
+ const arraySlice = unapply(Array.prototype.slice);
138
+ const arraySplice = unapply(Array.prototype.splice);
139
+ const arrayIsArray = Array.isArray;
140
+ const setCreate = unconstruct(Set);
141
+ const setAdd = unapply(Set.prototype.add);
142
+ const setHas = unapply(Set.prototype.has);
143
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
144
+ const stringToString = unapply(String.prototype.toString);
145
+ const stringMatch = unapply(String.prototype.match);
146
+ const stringReplace = unapply(String.prototype.replace);
147
+ const stringIndexOf = unapply(String.prototype.indexOf);
148
+ const stringTrim = unapply(String.prototype.trim);
149
+ const numberToString = unapply(Number.prototype.toString);
150
+ const booleanToString = unapply(Boolean.prototype.toString);
151
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
152
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
153
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
154
+ const objectToString = unapply(Object.prototype.toString);
155
+ const regExpTest = unapply(RegExp.prototype.test);
156
+ const typeErrorCreate = unconstruct(TypeError);
157
+ /**
158
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
159
+ *
160
+ * @param func - The function to be wrapped and called.
161
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
162
+ */
163
+ function unapply(func) {
164
+ return function(thisArg) {
165
+ if (thisArg instanceof RegExp) thisArg.lastIndex = 0;
166
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) args[_key3 - 1] = arguments[_key3];
167
+ return apply(func, thisArg, args);
168
+ };
169
+ }
170
+ /**
171
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
172
+ *
173
+ * @param func - The constructor function to be wrapped and called.
174
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
175
+ */
176
+ function unconstruct(Func) {
177
+ return function() {
178
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
179
+ return construct(Func, args);
180
+ };
181
+ }
182
+ /**
183
+ * Add properties to a lookup table
184
+ *
185
+ * @param set - The set to which elements will be added.
186
+ * @param array - The array containing elements to be added to the set.
187
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
188
+ * @returns The modified set with added elements.
189
+ */
190
+ function addToSet(set, array) {
191
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
192
+ if (setPrototypeOf) setPrototypeOf(set, null);
193
+ if (!arrayIsArray(array)) return set;
194
+ let l = array.length;
195
+ while (l--) {
196
+ let element = array[l];
197
+ if (typeof element === "string") {
198
+ const lcElement = transformCaseFunc(element);
199
+ if (lcElement !== element) {
200
+ if (!isFrozen(array)) array[l] = lcElement;
201
+ element = lcElement;
202
+ }
203
+ }
204
+ set[element] = true;
205
+ }
206
+ return set;
207
+ }
208
+ /**
209
+ * Clean up an array to harden against CSPP
210
+ *
211
+ * @param array - The array to be cleaned.
212
+ * @returns The cleaned version of the array
213
+ */
214
+ function cleanArray(array) {
215
+ for (let index = 0; index < array.length; index++) if (!objectHasOwnProperty(array, index)) array[index] = null;
216
+ return array;
217
+ }
218
+ /**
219
+ * Shallow clone an object
220
+ *
221
+ * @param object - The object to be cloned.
222
+ * @returns A new object that copies the original.
223
+ */
224
+ function clone(object) {
225
+ const newObject = create(null);
226
+ for (const _ref2 of entries(object)) {
227
+ var _ref3 = _slicedToArray(_ref2, 2);
228
+ const property = _ref3[0];
229
+ const value = _ref3[1];
230
+ if (objectHasOwnProperty(object, property)) {
231
+ if (arrayIsArray(value)) newObject[property] = cleanArray(value);
232
+ else if (value && typeof value === "object" && value.constructor === Object) newObject[property] = clone(value);
233
+ else newObject[property] = value;
234
+ }
235
+ }
236
+ return newObject;
237
+ }
238
+ /**
239
+ * Convert non-node values into strings without depending on direct property access.
240
+ *
241
+ * @param value - The value to stringify.
242
+ * @returns A string representation of the provided value.
243
+ */
244
+ function stringifyValue(value) {
245
+ switch (typeof value) {
246
+ case "string": return value;
247
+ case "number": return numberToString(value);
248
+ case "boolean": return booleanToString(value);
249
+ case "bigint": return bigintToString ? bigintToString(value) : "0";
250
+ case "symbol": return symbolToString ? symbolToString(value) : "Symbol()";
251
+ case "undefined": return objectToString(value);
252
+ case "function":
253
+ case "object": {
254
+ if (value === null) return objectToString(value);
255
+ const valueAsRecord = value;
256
+ const valueToString = lookupGetter(valueAsRecord, "toString");
257
+ if (typeof valueToString === "function") {
258
+ const stringified = valueToString(valueAsRecord);
259
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
260
+ }
261
+ return objectToString(value);
262
+ }
263
+ default: return objectToString(value);
264
+ }
265
+ }
266
+ /**
267
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
268
+ *
269
+ * @param object - The object to look up the getter function in its prototype chain.
270
+ * @param prop - The property name for which to find the getter function.
271
+ * @returns The getter function found in the prototype chain or a fallback function.
272
+ */
273
+ function lookupGetter(object, prop) {
274
+ while (object !== null) {
275
+ const desc = getOwnPropertyDescriptor(object, prop);
276
+ if (desc) {
277
+ if (desc.get) return unapply(desc.get);
278
+ if (typeof desc.value === "function") return unapply(desc.value);
279
+ }
280
+ object = getPrototypeOf(object);
281
+ }
282
+ function fallbackValue() {
283
+ return null;
284
+ }
285
+ return fallbackValue;
286
+ }
287
+ /**
288
+ * Like lookupGetter, but for accessor properties only, and returns null
289
+ * instead of a null-returning fallback when no getter exists on the chain.
290
+ * Lets a caller fall back to a direct property read in environments that
291
+ * lack the getter, where a fallback returning null would be indistinguishable
292
+ * from a legitimate null value (e.g. namespaceURI of a no-namespace element).
293
+ *
294
+ * @param object - The object (usually a prototype) to start the lookup at.
295
+ * @param prop - The accessor property name.
296
+ * @returns The unapplied getter, or null if none was found.
297
+ */
298
+ function lookupAccessor(object, prop) {
299
+ while (object !== null) {
300
+ const desc = getOwnPropertyDescriptor(object, prop);
301
+ if (desc) return desc.get ? unapply(desc.get) : null;
302
+ object = getPrototypeOf(object);
303
+ }
304
+ return null;
305
+ }
306
+ function isRegex(value) {
307
+ try {
308
+ regExpTest(value, "");
309
+ return true;
310
+ } catch (_unused) {
311
+ return false;
312
+ }
313
+ }
314
+ const html$1 = freeze([
315
+ "a",
316
+ "abbr",
317
+ "acronym",
318
+ "address",
319
+ "area",
320
+ "article",
321
+ "aside",
322
+ "audio",
323
+ "b",
324
+ "bdi",
325
+ "bdo",
326
+ "big",
327
+ "blink",
328
+ "blockquote",
329
+ "body",
330
+ "br",
331
+ "button",
332
+ "canvas",
333
+ "caption",
334
+ "center",
335
+ "cite",
336
+ "code",
337
+ "col",
338
+ "colgroup",
339
+ "content",
340
+ "data",
341
+ "datalist",
342
+ "dd",
343
+ "decorator",
344
+ "del",
345
+ "details",
346
+ "dfn",
347
+ "dialog",
348
+ "dir",
349
+ "div",
350
+ "dl",
351
+ "dt",
352
+ "element",
353
+ "em",
354
+ "fieldset",
355
+ "figcaption",
356
+ "figure",
357
+ "font",
358
+ "footer",
359
+ "form",
360
+ "h1",
361
+ "h2",
362
+ "h3",
363
+ "h4",
364
+ "h5",
365
+ "h6",
366
+ "head",
367
+ "header",
368
+ "hgroup",
369
+ "hr",
370
+ "html",
371
+ "i",
372
+ "img",
373
+ "input",
374
+ "ins",
375
+ "kbd",
376
+ "label",
377
+ "legend",
378
+ "li",
379
+ "main",
380
+ "map",
381
+ "mark",
382
+ "marquee",
383
+ "menu",
384
+ "menuitem",
385
+ "meter",
386
+ "nav",
387
+ "nobr",
388
+ "ol",
389
+ "optgroup",
390
+ "option",
391
+ "output",
392
+ "p",
393
+ "picture",
394
+ "pre",
395
+ "progress",
396
+ "q",
397
+ "rp",
398
+ "rt",
399
+ "ruby",
400
+ "s",
401
+ "samp",
402
+ "search",
403
+ "section",
404
+ "select",
405
+ "shadow",
406
+ "slot",
407
+ "small",
408
+ "source",
409
+ "spacer",
410
+ "span",
411
+ "strike",
412
+ "strong",
413
+ "style",
414
+ "sub",
415
+ "summary",
416
+ "sup",
417
+ "table",
418
+ "tbody",
419
+ "td",
420
+ "template",
421
+ "textarea",
422
+ "tfoot",
423
+ "th",
424
+ "thead",
425
+ "time",
426
+ "tr",
427
+ "track",
428
+ "tt",
429
+ "u",
430
+ "ul",
431
+ "var",
432
+ "video",
433
+ "wbr"
434
+ ]);
435
+ const svg$1 = freeze([
436
+ "svg",
437
+ "a",
438
+ "altglyph",
439
+ "altglyphdef",
440
+ "altglyphitem",
441
+ "animatecolor",
442
+ "animatemotion",
443
+ "animatetransform",
444
+ "circle",
445
+ "clippath",
446
+ "defs",
447
+ "desc",
448
+ "ellipse",
449
+ "enterkeyhint",
450
+ "exportparts",
451
+ "filter",
452
+ "font",
453
+ "g",
454
+ "glyph",
455
+ "glyphref",
456
+ "hkern",
457
+ "image",
458
+ "inputmode",
459
+ "line",
460
+ "lineargradient",
461
+ "marker",
462
+ "mask",
463
+ "metadata",
464
+ "mpath",
465
+ "part",
466
+ "path",
467
+ "pattern",
468
+ "polygon",
469
+ "polyline",
470
+ "radialgradient",
471
+ "rect",
472
+ "stop",
473
+ "style",
474
+ "switch",
475
+ "symbol",
476
+ "text",
477
+ "textpath",
478
+ "title",
479
+ "tref",
480
+ "tspan",
481
+ "view",
482
+ "vkern"
483
+ ]);
484
+ const svgFilters = freeze([
485
+ "feBlend",
486
+ "feColorMatrix",
487
+ "feComponentTransfer",
488
+ "feComposite",
489
+ "feConvolveMatrix",
490
+ "feDiffuseLighting",
491
+ "feDisplacementMap",
492
+ "feDistantLight",
493
+ "feDropShadow",
494
+ "feFlood",
495
+ "feFuncA",
496
+ "feFuncB",
497
+ "feFuncG",
498
+ "feFuncR",
499
+ "feGaussianBlur",
500
+ "feImage",
501
+ "feMerge",
502
+ "feMergeNode",
503
+ "feMorphology",
504
+ "feOffset",
505
+ "fePointLight",
506
+ "feSpecularLighting",
507
+ "feSpotLight",
508
+ "feTile",
509
+ "feTurbulence"
510
+ ]);
511
+ const svgDisallowed = freeze([
512
+ "animate",
513
+ "color-profile",
514
+ "cursor",
515
+ "discard",
516
+ "font-face",
517
+ "font-face-format",
518
+ "font-face-name",
519
+ "font-face-src",
520
+ "font-face-uri",
521
+ "foreignobject",
522
+ "hatch",
523
+ "hatchpath",
524
+ "mesh",
525
+ "meshgradient",
526
+ "meshpatch",
527
+ "meshrow",
528
+ "missing-glyph",
529
+ "script",
530
+ "set",
531
+ "solidcolor",
532
+ "unknown",
533
+ "use"
534
+ ]);
535
+ const mathMl$1 = freeze([
536
+ "math",
537
+ "menclose",
538
+ "merror",
539
+ "mfenced",
540
+ "mfrac",
541
+ "mglyph",
542
+ "mi",
543
+ "mlabeledtr",
544
+ "mmultiscripts",
545
+ "mn",
546
+ "mo",
547
+ "mover",
548
+ "mpadded",
549
+ "mphantom",
550
+ "mroot",
551
+ "mrow",
552
+ "ms",
553
+ "mspace",
554
+ "msqrt",
555
+ "mstyle",
556
+ "msub",
557
+ "msup",
558
+ "msubsup",
559
+ "mtable",
560
+ "mtd",
561
+ "mtext",
562
+ "mtr",
563
+ "munder",
564
+ "munderover",
565
+ "mprescripts"
566
+ ]);
567
+ const mathMlDisallowed = freeze([
568
+ "maction",
569
+ "maligngroup",
570
+ "malignmark",
571
+ "mlongdiv",
572
+ "mscarries",
573
+ "mscarry",
574
+ "msgroup",
575
+ "mstack",
576
+ "msline",
577
+ "msrow",
578
+ "semantics",
579
+ "annotation",
580
+ "annotation-xml",
581
+ "mprescripts",
582
+ "none"
583
+ ]);
584
+ const text = freeze(["#text"]);
585
+ const html = freeze([
586
+ "accept",
587
+ "action",
588
+ "align",
589
+ "alt",
590
+ "autocapitalize",
591
+ "autocomplete",
592
+ "autopictureinpicture",
593
+ "autoplay",
594
+ "background",
595
+ "bgcolor",
596
+ "border",
597
+ "capture",
598
+ "cellpadding",
599
+ "cellspacing",
600
+ "checked",
601
+ "cite",
602
+ "class",
603
+ "clear",
604
+ "color",
605
+ "cols",
606
+ "colspan",
607
+ "command",
608
+ "commandfor",
609
+ "controls",
610
+ "controlslist",
611
+ "coords",
612
+ "crossorigin",
613
+ "datetime",
614
+ "decoding",
615
+ "default",
616
+ "dir",
617
+ "disabled",
618
+ "disablepictureinpicture",
619
+ "disableremoteplayback",
620
+ "download",
621
+ "draggable",
622
+ "enctype",
623
+ "enterkeyhint",
624
+ "exportparts",
625
+ "face",
626
+ "for",
627
+ "headers",
628
+ "height",
629
+ "hidden",
630
+ "high",
631
+ "href",
632
+ "hreflang",
633
+ "id",
634
+ "inert",
635
+ "inputmode",
636
+ "integrity",
637
+ "ismap",
638
+ "kind",
639
+ "label",
640
+ "lang",
641
+ "list",
642
+ "loading",
643
+ "loop",
644
+ "low",
645
+ "max",
646
+ "maxlength",
647
+ "media",
648
+ "method",
649
+ "min",
650
+ "minlength",
651
+ "multiple",
652
+ "muted",
653
+ "name",
654
+ "nonce",
655
+ "noshade",
656
+ "novalidate",
657
+ "nowrap",
658
+ "open",
659
+ "optimum",
660
+ "part",
661
+ "pattern",
662
+ "placeholder",
663
+ "playsinline",
664
+ "popover",
665
+ "popovertarget",
666
+ "popovertargetaction",
667
+ "poster",
668
+ "preload",
669
+ "pubdate",
670
+ "radiogroup",
671
+ "readonly",
672
+ "rel",
673
+ "required",
674
+ "rev",
675
+ "reversed",
676
+ "role",
677
+ "rows",
678
+ "rowspan",
679
+ "spellcheck",
680
+ "scope",
681
+ "selected",
682
+ "shape",
683
+ "size",
684
+ "sizes",
685
+ "slot",
686
+ "span",
687
+ "srclang",
688
+ "start",
689
+ "src",
690
+ "srcset",
691
+ "step",
692
+ "style",
693
+ "summary",
694
+ "tabindex",
695
+ "title",
696
+ "translate",
697
+ "type",
698
+ "usemap",
699
+ "valign",
700
+ "value",
701
+ "width",
702
+ "wrap",
703
+ "xmlns"
704
+ ]);
705
+ const svg = freeze([
706
+ "accent-height",
707
+ "accumulate",
708
+ "additive",
709
+ "alignment-baseline",
710
+ "amplitude",
711
+ "ascent",
712
+ "attributename",
713
+ "attributetype",
714
+ "azimuth",
715
+ "basefrequency",
716
+ "baseline-shift",
717
+ "begin",
718
+ "bias",
719
+ "by",
720
+ "class",
721
+ "clip",
722
+ "clippathunits",
723
+ "clip-path",
724
+ "clip-rule",
725
+ "color",
726
+ "color-interpolation",
727
+ "color-interpolation-filters",
728
+ "color-profile",
729
+ "color-rendering",
730
+ "cx",
731
+ "cy",
732
+ "d",
733
+ "dx",
734
+ "dy",
735
+ "diffuseconstant",
736
+ "direction",
737
+ "display",
738
+ "divisor",
739
+ "dominant-baseline",
740
+ "dur",
741
+ "edgemode",
742
+ "elevation",
743
+ "end",
744
+ "exponent",
745
+ "fill",
746
+ "fill-opacity",
747
+ "fill-rule",
748
+ "filter",
749
+ "filterunits",
750
+ "flood-color",
751
+ "flood-opacity",
752
+ "font-family",
753
+ "font-size",
754
+ "font-size-adjust",
755
+ "font-stretch",
756
+ "font-style",
757
+ "font-variant",
758
+ "font-weight",
759
+ "fx",
760
+ "fy",
761
+ "g1",
762
+ "g2",
763
+ "glyph-name",
764
+ "glyphref",
765
+ "gradientunits",
766
+ "gradienttransform",
767
+ "height",
768
+ "href",
769
+ "id",
770
+ "image-rendering",
771
+ "in",
772
+ "in2",
773
+ "intercept",
774
+ "k",
775
+ "k1",
776
+ "k2",
777
+ "k3",
778
+ "k4",
779
+ "kerning",
780
+ "keypoints",
781
+ "keysplines",
782
+ "keytimes",
783
+ "lang",
784
+ "lengthadjust",
785
+ "letter-spacing",
786
+ "kernelmatrix",
787
+ "kernelunitlength",
788
+ "lighting-color",
789
+ "local",
790
+ "marker-end",
791
+ "marker-mid",
792
+ "marker-start",
793
+ "markerheight",
794
+ "markerunits",
795
+ "markerwidth",
796
+ "maskcontentunits",
797
+ "maskunits",
798
+ "max",
799
+ "mask",
800
+ "mask-type",
801
+ "media",
802
+ "method",
803
+ "mode",
804
+ "min",
805
+ "name",
806
+ "numoctaves",
807
+ "offset",
808
+ "operator",
809
+ "opacity",
810
+ "order",
811
+ "orient",
812
+ "orientation",
813
+ "origin",
814
+ "overflow",
815
+ "paint-order",
816
+ "path",
817
+ "pathlength",
818
+ "patterncontentunits",
819
+ "patterntransform",
820
+ "patternunits",
821
+ "pointer-events",
822
+ "points",
823
+ "preservealpha",
824
+ "preserveaspectratio",
825
+ "primitiveunits",
826
+ "r",
827
+ "rx",
828
+ "ry",
829
+ "radius",
830
+ "refx",
831
+ "refy",
832
+ "repeatcount",
833
+ "repeatdur",
834
+ "restart",
835
+ "result",
836
+ "rotate",
837
+ "scale",
838
+ "seed",
839
+ "shape-rendering",
840
+ "slope",
841
+ "specularconstant",
842
+ "specularexponent",
843
+ "spreadmethod",
844
+ "startoffset",
845
+ "stddeviation",
846
+ "stitchtiles",
847
+ "stop-color",
848
+ "stop-opacity",
849
+ "stroke-dasharray",
850
+ "stroke-dashoffset",
851
+ "stroke-linecap",
852
+ "stroke-linejoin",
853
+ "stroke-miterlimit",
854
+ "stroke-opacity",
855
+ "stroke",
856
+ "stroke-width",
857
+ "style",
858
+ "surfacescale",
859
+ "systemlanguage",
860
+ "tabindex",
861
+ "tablevalues",
862
+ "targetx",
863
+ "targety",
864
+ "transform",
865
+ "transform-origin",
866
+ "text-anchor",
867
+ "text-decoration",
868
+ "text-orientation",
869
+ "text-rendering",
870
+ "textlength",
871
+ "type",
872
+ "u1",
873
+ "u2",
874
+ "unicode",
875
+ "values",
876
+ "vector-effect",
877
+ "viewbox",
878
+ "visibility",
879
+ "version",
880
+ "vert-adv-y",
881
+ "vert-origin-x",
882
+ "vert-origin-y",
883
+ "width",
884
+ "word-spacing",
885
+ "wrap",
886
+ "writing-mode",
887
+ "xchannelselector",
888
+ "ychannelselector",
889
+ "x",
890
+ "x1",
891
+ "x2",
892
+ "xmlns",
893
+ "y",
894
+ "y1",
895
+ "y2",
896
+ "z",
897
+ "zoomandpan"
898
+ ]);
899
+ const mathMl = freeze([
900
+ "accent",
901
+ "accentunder",
902
+ "align",
903
+ "bevelled",
904
+ "close",
905
+ "columnalign",
906
+ "columnlines",
907
+ "columnspacing",
908
+ "columnspan",
909
+ "denomalign",
910
+ "depth",
911
+ "dir",
912
+ "display",
913
+ "displaystyle",
914
+ "encoding",
915
+ "fence",
916
+ "frame",
917
+ "height",
918
+ "href",
919
+ "id",
920
+ "largeop",
921
+ "length",
922
+ "linethickness",
923
+ "lquote",
924
+ "lspace",
925
+ "mathbackground",
926
+ "mathcolor",
927
+ "mathsize",
928
+ "mathvariant",
929
+ "maxsize",
930
+ "minsize",
931
+ "movablelimits",
932
+ "notation",
933
+ "numalign",
934
+ "open",
935
+ "rowalign",
936
+ "rowlines",
937
+ "rowspacing",
938
+ "rowspan",
939
+ "rspace",
940
+ "rquote",
941
+ "scriptlevel",
942
+ "scriptminsize",
943
+ "scriptsizemultiplier",
944
+ "selection",
945
+ "separator",
946
+ "separators",
947
+ "stretchy",
948
+ "subscriptshift",
949
+ "supscriptshift",
950
+ "symmetric",
951
+ "voffset",
952
+ "width",
953
+ "xmlns"
954
+ ]);
955
+ const xml = freeze([
956
+ "xlink:href",
957
+ "xml:id",
958
+ "xlink:title",
959
+ "xml:space",
960
+ "xmlns:xlink"
961
+ ]);
962
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
963
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
964
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
965
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
966
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
967
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
968
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
969
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
970
+ const DOCTYPE_NAME = seal(/^html$/i);
971
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
972
+ const ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
973
+ const COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
974
+ const FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
975
+ const SELF_CLOSING_TAG = seal(/\/>/i);
976
+ const NODE_TYPE = {
977
+ element: 1,
978
+ attribute: 2,
979
+ text: 3,
980
+ cdataSection: 4,
981
+ entityReference: 5,
982
+ entityNode: 6,
983
+ processingInstruction: 7,
984
+ comment: 8,
985
+ document: 9,
986
+ documentType: 10,
987
+ documentFragment: 11,
988
+ notation: 12
989
+ };
990
+ const LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, [
991
+ "style",
992
+ "script",
993
+ "xmp",
994
+ "iframe",
995
+ "noembed",
996
+ "noframes",
997
+ "plaintext",
998
+ "noscript"
999
+ ]));
1000
+ const getGlobal = function getGlobal() {
1001
+ return typeof window === "undefined" ? null : window;
1002
+ };
1003
+ /**
1004
+ * Creates a no-op policy for internal use only.
1005
+ * Don't export this function outside this module!
1006
+ * @param trustedTypes The policy factory.
1007
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
1008
+ * @return The policy created (or null, if Trusted Types
1009
+ * are not supported or creating the policy failed).
1010
+ */
1011
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
1012
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") return null;
1013
+ let suffix = null;
1014
+ const ATTR_NAME = "data-tt-policy-suffix";
1015
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) suffix = purifyHostElement.getAttribute(ATTR_NAME);
1016
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
1017
+ try {
1018
+ return trustedTypes.createPolicy(policyName, {
1019
+ createHTML(html) {
1020
+ return html;
1021
+ },
1022
+ createScriptURL(scriptUrl) {
1023
+ return scriptUrl;
1024
+ }
1025
+ });
1026
+ } catch (_) {
1027
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
1028
+ return null;
1029
+ }
1030
+ };
1031
+ const _createHooksMap = function _createHooksMap() {
1032
+ return {
1033
+ afterSanitizeAttributes: [],
1034
+ afterSanitizeElements: [],
1035
+ afterSanitizeShadowDOM: [],
1036
+ beforeSanitizeAttributes: [],
1037
+ beforeSanitizeElements: [],
1038
+ beforeSanitizeShadowDOM: [],
1039
+ uponSanitizeAttribute: [],
1040
+ uponSanitizeElement: [],
1041
+ uponSanitizeShadowNode: []
1042
+ };
1043
+ };
1044
+ /**
1045
+ * Resolve a set-valued configuration option: a fresh set built from
1046
+ * cfg[key] when it is an own array property (seeded with a clone of
1047
+ * options.base when given, case-normalized via options.transform),
1048
+ * the fallback set otherwise.
1049
+ *
1050
+ * @param cfg the cloned, prototype-free configuration object
1051
+ * @param key the configuration property to read
1052
+ * @param fallback the set to use when the option is absent or not an array
1053
+ * @param options transform and optional base set to merge into
1054
+ * @returns the resolved set
1055
+ */
1056
+ const _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
1057
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
1058
+ };
1059
+ /**
1060
+ * Resolve an object-valued configuration option: a prototype-free clone
1061
+ * of cfg[key] when it is an own, truthy object property, else a fresh
1062
+ * fallback built by makeFallback (fresh on every parse, so a previous
1063
+ * parse can never leak state into the next one).
1064
+ *
1065
+ * @param cfg the cloned, prototype-free configuration object
1066
+ * @param key the configuration property to read
1067
+ * @param makeFallback builds the fallback value when the option is absent
1068
+ * @returns the resolved object
1069
+ */
1070
+ const _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback) {
1071
+ const value = objectHasOwnProperty(cfg, key) ? cfg[key] : void 0;
1072
+ return value && typeof value === "object" ? clone(value) : makeFallback();
1073
+ };
1074
+ function createDOMPurify() {
1075
+ let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
1076
+ const DOMPurify = (root) => createDOMPurify(root);
1077
+ DOMPurify.version = "3.4.17";
1078
+ DOMPurify.removed = [];
1079
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
1080
+ DOMPurify.isSupported = false;
1081
+ return DOMPurify;
1082
+ }
1083
+ let document = window.document;
1084
+ const originalDocument = document;
1085
+ const currentScript = originalDocument.currentScript;
1086
+ window.DocumentFragment;
1087
+ const HTMLTemplateElement = window.HTMLTemplateElement, Node = window.Node, Element = window.Element, NodeFilter = window.NodeFilter;
1088
+ window.NamedNodeMap === void 0 && (window.NamedNodeMap || window.MozNamedAttrMap);
1089
+ window.HTMLFormElement;
1090
+ const DOMParser = window.DOMParser, trustedTypes = window.trustedTypes;
1091
+ const ElementPrototype = Element.prototype;
1092
+ const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
1093
+ const remove = lookupGetter(ElementPrototype, "remove");
1094
+ const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
1095
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
1096
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
1097
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
1098
+ const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
1099
+ const getAttributes = lookupGetter(ElementPrototype, "attributes");
1100
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
1101
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
1102
+ const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
1103
+ const _readNodeType = function _readNodeType(node) {
1104
+ return getNodeType ? getNodeType(node) : node.nodeType;
1105
+ };
1106
+ const _readNodeName = function _readNodeName(node) {
1107
+ return getNodeName ? getNodeName(node) : node.nodeName;
1108
+ };
1109
+ const getNamespaceURI = lookupAccessor(ElementPrototype, "namespaceURI");
1110
+ const _readNamespaceURI = function _readNamespaceURI(element) {
1111
+ return getNamespaceURI ? getNamespaceURI(element) : element.namespaceURI;
1112
+ };
1113
+ if (typeof HTMLTemplateElement === "function") {
1114
+ const template = document.createElement("template");
1115
+ if (template.content && template.content.ownerDocument) document = template.content.ownerDocument;
1116
+ }
1117
+ let trustedTypesPolicy;
1118
+ let emptyHTML = "";
1119
+ let defaultTrustedTypesPolicy;
1120
+ let defaultTrustedTypesPolicyResolved = false;
1121
+ let IN_TRUSTED_TYPES_POLICY = 0;
1122
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
1123
+ if (IN_TRUSTED_TYPES_POLICY > 0) 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.");
1124
+ };
1125
+ const _createTrustedHTML = function _createTrustedHTML(html) {
1126
+ _assertNotInTrustedTypesPolicy();
1127
+ IN_TRUSTED_TYPES_POLICY++;
1128
+ try {
1129
+ return trustedTypesPolicy.createHTML(html);
1130
+ } finally {
1131
+ IN_TRUSTED_TYPES_POLICY--;
1132
+ }
1133
+ };
1134
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
1135
+ _assertNotInTrustedTypesPolicy();
1136
+ IN_TRUSTED_TYPES_POLICY++;
1137
+ try {
1138
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
1139
+ } finally {
1140
+ IN_TRUSTED_TYPES_POLICY--;
1141
+ }
1142
+ };
1143
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
1144
+ if (!defaultTrustedTypesPolicyResolved) {
1145
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1146
+ defaultTrustedTypesPolicyResolved = true;
1147
+ }
1148
+ return defaultTrustedTypesPolicy;
1149
+ };
1150
+ const _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
1151
+ const importNode = originalDocument.importNode;
1152
+ let hooks = _createHooksMap();
1153
+ /**
1154
+ * Expose whether this browser supports running the full DOMPurify.
1155
+ */
1156
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
1157
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
1158
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
1159
+ /**
1160
+ * We consider the elements and attributes below to be safe. Ideally
1161
+ * don't add any new ones but feel free to remove unwanted ones.
1162
+ */
1163
+ let ALLOWED_TAGS = null;
1164
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [
1165
+ ...html$1,
1166
+ ...svg$1,
1167
+ ...svgFilters,
1168
+ ...mathMl$1,
1169
+ ...text
1170
+ ]);
1171
+ let ALLOWED_ATTR = null;
1172
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [
1173
+ ...html,
1174
+ ...svg,
1175
+ ...mathMl,
1176
+ ...xml
1177
+ ]);
1178
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
1179
+ tagNameCheck: {
1180
+ writable: true,
1181
+ configurable: false,
1182
+ enumerable: true,
1183
+ value: null
1184
+ },
1185
+ attributeNameCheck: {
1186
+ writable: true,
1187
+ configurable: false,
1188
+ enumerable: true,
1189
+ value: null
1190
+ },
1191
+ allowCustomizedBuiltInElements: {
1192
+ writable: true,
1193
+ configurable: false,
1194
+ enumerable: true,
1195
+ value: false
1196
+ }
1197
+ }));
1198
+ let FORBID_TAGS = null;
1199
+ let FORBID_ATTR = null;
1200
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
1201
+ tagCheck: {
1202
+ writable: true,
1203
+ configurable: false,
1204
+ enumerable: true,
1205
+ value: null
1206
+ },
1207
+ attributeCheck: {
1208
+ writable: true,
1209
+ configurable: false,
1210
+ enumerable: true,
1211
+ value: null
1212
+ }
1213
+ }));
1214
+ let ALLOW_ARIA_ATTR = true;
1215
+ let ALLOW_DATA_ATTR = true;
1216
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
1217
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
1218
+ let SAFE_FOR_TEMPLATES = false;
1219
+ let SAFE_FOR_XML = true;
1220
+ let WHOLE_DOCUMENT = false;
1221
+ let SET_CONFIG = false;
1222
+ let SET_CONFIG_ALLOWED_TAGS = null;
1223
+ let SET_CONFIG_ALLOWED_ATTR = null;
1224
+ let FORCE_BODY = false;
1225
+ let RETURN_DOM = false;
1226
+ let RETURN_DOM_FRAGMENT = false;
1227
+ let RETURN_TRUSTED_TYPE = false;
1228
+ let SANITIZE_DOM = true;
1229
+ let SANITIZE_NAMED_PROPS = false;
1230
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
1231
+ let KEEP_CONTENT = true;
1232
+ let IN_PLACE = false;
1233
+ let IN_PLACE_VISITED = null;
1234
+ let USE_PROFILES = {};
1235
+ let FORBID_CONTENTS = null;
1236
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, [
1237
+ "annotation-xml",
1238
+ "audio",
1239
+ "colgroup",
1240
+ "desc",
1241
+ "foreignobject",
1242
+ "head",
1243
+ "iframe",
1244
+ "math",
1245
+ "mi",
1246
+ "mn",
1247
+ "mo",
1248
+ "ms",
1249
+ "mtext",
1250
+ "noembed",
1251
+ "noframes",
1252
+ "noscript",
1253
+ "plaintext",
1254
+ "script",
1255
+ "selectedcontent",
1256
+ "style",
1257
+ "svg",
1258
+ "template",
1259
+ "thead",
1260
+ "title",
1261
+ "video",
1262
+ "xmp"
1263
+ ]);
1264
+ let DATA_URI_TAGS = null;
1265
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, [
1266
+ "audio",
1267
+ "video",
1268
+ "img",
1269
+ "source",
1270
+ "image",
1271
+ "track"
1272
+ ]);
1273
+ let URI_SAFE_ATTRIBUTES = null;
1274
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
1275
+ "alt",
1276
+ "class",
1277
+ "for",
1278
+ "id",
1279
+ "label",
1280
+ "name",
1281
+ "pattern",
1282
+ "placeholder",
1283
+ "role",
1284
+ "summary",
1285
+ "title",
1286
+ "value",
1287
+ "style",
1288
+ "xmlns"
1289
+ ]);
1290
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
1291
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
1292
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
1293
+ let NAMESPACE = HTML_NAMESPACE;
1294
+ let IS_EMPTY_INPUT = false;
1295
+ let ALLOWED_NAMESPACES = null;
1296
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
1297
+ MATHML_NAMESPACE,
1298
+ SVG_NAMESPACE,
1299
+ HTML_NAMESPACE
1300
+ ], stringToString);
1301
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze([
1302
+ "mi",
1303
+ "mo",
1304
+ "mn",
1305
+ "ms",
1306
+ "mtext"
1307
+ ]);
1308
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1309
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
1310
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1311
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
1312
+ "title",
1313
+ "style",
1314
+ "font",
1315
+ "a",
1316
+ "script"
1317
+ ]);
1318
+ let PARSER_MEDIA_TYPE = null;
1319
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
1320
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
1321
+ let transformCaseFunc = null;
1322
+ let CONFIG = null;
1323
+ const formElement = document.createElement("form");
1324
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
1325
+ return testValue instanceof RegExp || testValue instanceof Function;
1326
+ };
1327
+ /**
1328
+ * _parseConfig
1329
+ *
1330
+ * @param cfg optional config literal
1331
+ */
1332
+ const _parseConfig = function _parseConfig() {
1333
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1334
+ if (CONFIG && CONFIG === cfg) return;
1335
+ if (!cfg || typeof cfg !== "object") cfg = {};
1336
+ cfg = clone(cfg);
1337
+ PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1338
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
1339
+ ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, { transform: transformCaseFunc });
1340
+ ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, { transform: transformCaseFunc });
1341
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, { transform: stringToString });
1342
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
1343
+ transform: transformCaseFunc,
1344
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
1345
+ });
1346
+ DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
1347
+ transform: transformCaseFunc,
1348
+ base: DEFAULT_DATA_URI_TAGS
1349
+ });
1350
+ FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, { transform: transformCaseFunc });
1351
+ FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), { transform: transformCaseFunc });
1352
+ FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), { transform: transformCaseFunc });
1353
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
1354
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
1355
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
1356
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
1357
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
1358
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
1359
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
1360
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
1361
+ RETURN_DOM = cfg.RETURN_DOM || false;
1362
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
1363
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
1364
+ FORCE_BODY = cfg.FORCE_BODY || false;
1365
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
1366
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
1367
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
1368
+ IN_PLACE = cfg.IN_PLACE || false;
1369
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
1370
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
1371
+ MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS));
1372
+ HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS));
1373
+ const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
1374
+ CUSTOM_ELEMENT_HANDLING = create(null);
1375
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
1376
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
1377
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
1378
+ seal(CUSTOM_ELEMENT_HANDLING);
1379
+ if (SAFE_FOR_TEMPLATES) ALLOW_DATA_ATTR = false;
1380
+ if (RETURN_DOM_FRAGMENT) RETURN_DOM = true;
1381
+ if (USE_PROFILES) {
1382
+ ALLOWED_TAGS = addToSet({}, text);
1383
+ ALLOWED_ATTR = create(null);
1384
+ if (USE_PROFILES.html === true) {
1385
+ addToSet(ALLOWED_TAGS, html$1);
1386
+ addToSet(ALLOWED_ATTR, html);
1387
+ }
1388
+ if (USE_PROFILES.svg === true) {
1389
+ addToSet(ALLOWED_TAGS, svg$1);
1390
+ addToSet(ALLOWED_ATTR, svg);
1391
+ addToSet(ALLOWED_ATTR, xml);
1392
+ }
1393
+ if (USE_PROFILES.svgFilters === true) {
1394
+ addToSet(ALLOWED_TAGS, svgFilters);
1395
+ addToSet(ALLOWED_ATTR, svg);
1396
+ addToSet(ALLOWED_ATTR, xml);
1397
+ }
1398
+ if (USE_PROFILES.mathMl === true) {
1399
+ addToSet(ALLOWED_TAGS, mathMl$1);
1400
+ addToSet(ALLOWED_ATTR, mathMl);
1401
+ addToSet(ALLOWED_ATTR, xml);
1402
+ }
1403
+ }
1404
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
1405
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
1406
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
1407
+ if (typeof cfg.ADD_TAGS === "function") EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
1408
+ else if (arrayIsArray(cfg.ADD_TAGS)) {
1409
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS = clone(ALLOWED_TAGS);
1410
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
1411
+ }
1412
+ }
1413
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
1414
+ if (typeof cfg.ADD_ATTR === "function") EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
1415
+ else if (arrayIsArray(cfg.ADD_ATTR)) {
1416
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) ALLOWED_ATTR = clone(ALLOWED_ATTR);
1417
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
1418
+ }
1419
+ }
1420
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
1421
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
1422
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
1423
+ }
1424
+ if (KEEP_CONTENT) ALLOWED_TAGS["#text"] = true;
1425
+ if (WHOLE_DOCUMENT) addToSet(ALLOWED_TAGS, [
1426
+ "html",
1427
+ "head",
1428
+ "body"
1429
+ ]);
1430
+ if (ALLOWED_TAGS.table) {
1431
+ addToSet(ALLOWED_TAGS, ["tbody"]);
1432
+ delete FORBID_TAGS.tbody;
1433
+ }
1434
+ if (cfg.TRUSTED_TYPES_POLICY) {
1435
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
1436
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
1437
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
1438
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1439
+ try {
1440
+ emptyHTML = _createTrustedHTML("");
1441
+ } catch (error) {
1442
+ trustedTypesPolicy = previousTrustedTypesPolicy;
1443
+ throw error;
1444
+ }
1445
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
1446
+ trustedTypesPolicy = void 0;
1447
+ emptyHTML = "";
1448
+ } else {
1449
+ if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
1450
+ if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
1451
+ }
1452
+ if (freeze) freeze(cfg);
1453
+ CONFIG = cfg;
1454
+ };
1455
+ const ALL_SVG_TAGS = addToSet({}, [
1456
+ ...svg$1,
1457
+ ...svgFilters,
1458
+ ...svgDisallowed
1459
+ ]);
1460
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1461
+ /**
1462
+ * Namespace rules for an element in the SVG namespace.
1463
+ *
1464
+ * @param tagName the element's lowercase tag name
1465
+ * @param parent the (possibly simulated) parent node
1466
+ * @param parentTagName the parent's lowercase tag name
1467
+ * @returns true if a spec-compliant parser could produce this element
1468
+ */
1469
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
1470
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "svg";
1471
+ if (parent.namespaceURI === MATHML_NAMESPACE) return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1472
+ return Boolean(ALL_SVG_TAGS[tagName]);
1473
+ };
1474
+ /**
1475
+ * Namespace rules for an element in the MathML namespace.
1476
+ *
1477
+ * @param tagName the element's lowercase tag name
1478
+ * @param parent the (possibly simulated) parent node
1479
+ * @param parentTagName the parent's lowercase tag name
1480
+ * @returns true if a spec-compliant parser could produce this element
1481
+ */
1482
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
1483
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "math";
1484
+ if (parent.namespaceURI === SVG_NAMESPACE) return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
1485
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1486
+ };
1487
+ /**
1488
+ * Namespace rules for an element in the HTML namespace.
1489
+ *
1490
+ * @param tagName the element's lowercase tag name
1491
+ * @param parent the (possibly simulated) parent node
1492
+ * @param parentTagName the parent's lowercase tag name
1493
+ * @returns true if a spec-compliant parser could produce this element
1494
+ */
1495
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
1496
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) return false;
1497
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) return false;
1498
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1499
+ };
1500
+ /**
1501
+ * @param element a DOM element whose namespace is being checked
1502
+ * @returns Return false if the element has a
1503
+ * namespace that a spec-compliant parser would never
1504
+ * return. Return true otherwise.
1505
+ */
1506
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1507
+ const elementNamespace = _readNamespaceURI(element);
1508
+ const tagName = stringToLowerCase(_readNodeName(element));
1509
+ const parentNode = getParentNode(element);
1510
+ let parent;
1511
+ let parentTagName;
1512
+ if (parentNode && _readNodeType(parentNode) === NODE_TYPE.element) {
1513
+ parent = { namespaceURI: _readNamespaceURI(parentNode) };
1514
+ parentTagName = stringToLowerCase(_readNodeName(parentNode));
1515
+ } else {
1516
+ parent = { namespaceURI: NAMESPACE };
1517
+ parentTagName = "template";
1518
+ }
1519
+ if (!ALLOWED_NAMESPACES[elementNamespace]) return false;
1520
+ if (elementNamespace === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
1521
+ if (elementNamespace === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
1522
+ if (elementNamespace === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
1523
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[elementNamespace]) return true;
1524
+ return false;
1525
+ };
1526
+ /**
1527
+ * _forceRemove
1528
+ *
1529
+ * @param node a DOM node
1530
+ */
1531
+ const _forceRemove = function _forceRemove(node) {
1532
+ arrayPush(DOMPurify.removed, { element: node });
1533
+ try {
1534
+ getParentNode(node).removeChild(node);
1535
+ } catch (_) {
1536
+ remove(node);
1537
+ if (!getParentNode(node)) throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
1538
+ }
1539
+ };
1540
+ /**
1541
+ * _stripAttributeNode
1542
+ *
1543
+ * Remove a single Attr node case/namespace-exactly on an attribute-teardown
1544
+ * path. Name-based removeAttribute() ASCII-lowercases its lookup key for an
1545
+ * HTML element in an HTML document and so silently misses a case-preserved
1546
+ * handler (e.g. `ONERROR` off an XML/XHTML import) - the same defect
1547
+ * _removeAttribute() was fixed for, which a name-based call would reintroduce
1548
+ * on these IN_PLACE teardown paths. Unlike _removeAttribute this does not
1549
+ * record into DOMPurify.removed: the neutralize passes intentionally do not
1550
+ * book-keep. A clobbered/detached node falls back to best-effort name-based
1551
+ * removal.
1552
+ *
1553
+ * @param element the element to strip the attribute from
1554
+ * @param attribute the Attr node to remove
1555
+ * @param name the attribute's name, for the fallback path
1556
+ */
1557
+ const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
1558
+ try {
1559
+ removeAttributeNode(element, attribute);
1560
+ } catch (_) {
1561
+ try {
1562
+ element.removeAttribute(name);
1563
+ } catch (_) {}
1564
+ }
1565
+ };
1566
+ /**
1567
+ * Fail-closed teardown of an in-place root: strip every disallowed attribute
1568
+ * in the subtree first, so nothing armed is left behind, then remove all
1569
+ * children and the root's own attributes.
1570
+ *
1571
+ * @param root the in-place root to empty
1572
+ */
1573
+ const _neutralizeRoot = function _neutralizeRoot(root) {
1574
+ _neutralizeSubtree(root);
1575
+ const childNodes = getChildNodes(root);
1576
+ if (childNodes) arrayForEach(arraySlice(childNodes), (child) => {
1577
+ try {
1578
+ remove(child);
1579
+ } catch (_) {}
1580
+ });
1581
+ const attributes = _readNodeType(root) === NODE_TYPE.element ? getAttributes(root) : null;
1582
+ if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
1583
+ const attribute = attributes[i];
1584
+ const name = attribute && attribute.name;
1585
+ if (typeof name === "string") _stripAttributeNode(root, attribute, name);
1586
+ }
1587
+ };
1588
+ /**
1589
+ * Removes an attribute, preferably as its exact Attr node: name-based
1590
+ * removal lowercases the name in HTML documents and misses case-preserved
1591
+ * names, e.g. from imported XHTML.
1592
+ *
1593
+ * @param name an Attribute name
1594
+ * @param element a DOM node
1595
+ * @param attr the exact Attr node to remove, when the caller has it
1596
+ */
1597
+ const _removeAttribute = function _removeAttribute(name, element, attr) {
1598
+ if (!attr) try {
1599
+ attr = element.getAttributeNode(name);
1600
+ } catch (_) {
1601
+ attr = null;
1602
+ }
1603
+ arrayPush(DOMPurify.removed, {
1604
+ attribute: attr || null,
1605
+ from: element
1606
+ });
1607
+ try {
1608
+ if (attr) removeAttributeNode(element, attr);
1609
+ else element.removeAttribute(name);
1610
+ } catch (_) {
1611
+ try {
1612
+ element.removeAttribute(name);
1613
+ } catch (_) {}
1614
+ }
1615
+ if (name === "is") {
1616
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) try {
1617
+ _forceRemove(element);
1618
+ } catch (_) {}
1619
+ else try {
1620
+ element.setAttribute(name, "");
1621
+ } catch (_) {}
1622
+ }
1623
+ };
1624
+ /**
1625
+ * Removes every attribute the configuration does not allow. Used to
1626
+ * neutralize nodes discarded from an in-place tree.
1627
+ *
1628
+ * @param element the element to strip
1629
+ */
1630
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
1631
+ const attributes = getAttributes(element);
1632
+ if (!attributes) return;
1633
+ for (let i = attributes.length - 1; i >= 0; --i) {
1634
+ const attribute = attributes[i];
1635
+ const name = attribute && attribute.name;
1636
+ if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) continue;
1637
+ _stripAttributeNode(element, attribute, name);
1638
+ }
1639
+ };
1640
+ /**
1641
+ * Iterative depth-first walk, so deep trees cannot overflow the call stack,
1642
+ * reading through the cached getters, so clobbering cannot hide children.
1643
+ * When `visit` returns false, the node's children are skipped. With
1644
+ * `intoShadow`, open shadow roots are walked after their host's children.
1645
+ *
1646
+ * @param root where to start
1647
+ * @param visit called for every node
1648
+ * @param intoShadow whether to enter open shadow roots
1649
+ */
1650
+ const _walkTree = function _walkTree(root, visit) {
1651
+ let intoShadow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
1652
+ const stack = [root];
1653
+ while (stack.length > 0) {
1654
+ const node = stack.pop();
1655
+ if (visit(node) === false) continue;
1656
+ if (intoShadow && _readNodeType(node) === NODE_TYPE.element) {
1657
+ const shadowRoot = getShadowRoot(node);
1658
+ if (_isDocumentFragment(shadowRoot)) stack.push(shadowRoot);
1659
+ }
1660
+ const childNodes = getChildNodes(node);
1661
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
1662
+ }
1663
+ };
1664
+ /**
1665
+ * Strips disallowed attributes from every element of a discarded subtree,
1666
+ * so a handler that is already queued (a loading image) cannot fire.
1667
+ *
1668
+ * @param root the root of a removed subtree
1669
+ */
1670
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
1671
+ _walkTree(root, (node) => {
1672
+ if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
1673
+ });
1674
+ };
1675
+ /**
1676
+ * All nodes under `root`, root first, including open shadow roots. Template
1677
+ * content is not entered, it is inert.
1678
+ *
1679
+ * @param root the in-place root
1680
+ * @return the nodes
1681
+ */
1682
+ const _collectLiveNodes = function _collectLiveNodes(root) {
1683
+ const nodes = [];
1684
+ _walkTree(root, (node) => {
1685
+ nodes.push(node);
1686
+ }, true);
1687
+ return nodes;
1688
+ };
1689
+ /**
1690
+ * Strips disallowed attributes from every element that was under the
1691
+ * in-place root when the call started and no longer is, whatever removed
1692
+ * or moved it.
1693
+ *
1694
+ * @param root the in-place root
1695
+ * @param before the root's nodes, collected before the walk
1696
+ */
1697
+ const _neutralizeEscapedElements = function _neutralizeEscapedElements(root, before) {
1698
+ const reachable = setCreate();
1699
+ arrayForEach(_collectLiveNodes(root), (node) => {
1700
+ if (_readNodeType(node) === NODE_TYPE.element) setAdd(reachable, node);
1701
+ });
1702
+ arrayForEach(before, (node) => {
1703
+ if (_readNodeType(node) === NODE_TYPE.element && !setHas(reachable, node)) _stripDisallowedAttributes(node);
1704
+ });
1705
+ };
1706
+ /**
1707
+ * Neutralizes everything that left the in-place tree during the call: what
1708
+ * DOMPurify removed, and what hooks or custom elements removed or moved out.
1709
+ *
1710
+ * @param root the in-place root
1711
+ * @param before the root's nodes, collected before the walk
1712
+ * @return true if the root itself was removed
1713
+ */
1714
+ const _neutralizeDiscarded = function _neutralizeDiscarded(root, before) {
1715
+ let rootRemoved = false;
1716
+ arrayForEach(DOMPurify.removed, (entry) => {
1717
+ if (entry.element) {
1718
+ rootRemoved = rootRemoved || entry.element === root;
1719
+ _neutralizeSubtree(entry.element);
1720
+ }
1721
+ });
1722
+ _neutralizeEscapedElements(root, before);
1723
+ return rootRemoved;
1724
+ };
1725
+ const MAX_UNVISITED_ROUNDS = 8;
1726
+ /**
1727
+ * The walk only moves forward, so a node moved to a position it already
1728
+ * passed is never visited. Give every original node that is still in the
1729
+ * tree but unvisited the normal treatment, hooks included. Nodes created
1730
+ * during the call are left alone. Fails closed if the tree keeps changing.
1731
+ *
1732
+ * @param root the in-place root
1733
+ * @param before the root's nodes, collected before the walk
1734
+ */
1735
+ const _sanitizeUnvisitedNodes = function _sanitizeUnvisitedNodes(root, before) {
1736
+ const visited = IN_PLACE_VISITED;
1737
+ let original = null;
1738
+ const getOriginal = () => {
1739
+ if (!original) {
1740
+ original = setCreate();
1741
+ arrayForEach(before, (beforeNode) => {
1742
+ setAdd(original, beforeNode);
1743
+ });
1744
+ }
1745
+ return original;
1746
+ };
1747
+ for (let round = 0;; round++) {
1748
+ const live = _collectLiveNodes(root);
1749
+ const containers = [root];
1750
+ let pending = false;
1751
+ arrayForEach(live, (node) => {
1752
+ if (_readNodeType(node) === NODE_TYPE.documentFragment) arrayPush(containers, node);
1753
+ else if (!pending && !setHas(visited, node)) pending = setHas(getOriginal(), node);
1754
+ });
1755
+ if (!pending) return;
1756
+ if (round >= MAX_UNVISITED_ROUNDS) throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
1757
+ arrayForEach(containers, (container, index) => {
1758
+ _sanitizeUnvisitedIn(container, index > 0, root, getOriginal());
1759
+ });
1760
+ }
1761
+ };
1762
+ /**
1763
+ * One _sanitizeUnvisitedNodes pass over the root or an open shadow root.
1764
+ *
1765
+ * @param container the root or an open shadow root
1766
+ * @param inShadow whether container is a shadow root
1767
+ * @param root the in-place root
1768
+ * @param original the root's nodes collected before the walk, as a set
1769
+ */
1770
+ const _sanitizeUnvisitedIn = function _sanitizeUnvisitedIn(container, inShadow, root, original) {
1771
+ const iterator = _createNodeIterator(container);
1772
+ let node;
1773
+ while (node = iterator.nextNode()) {
1774
+ if (!setHas(original, node) || setHas(IN_PLACE_VISITED, node)) continue;
1775
+ if (inShadow) _executeHooks(hooks.uponSanitizeShadowNode, node, null);
1776
+ _sanitizeElements(node, root);
1777
+ _sanitizeAttributes(node, root);
1778
+ if (_isDocumentFragment(node.content)) _sanitizeShadowDOM2(node.content);
1779
+ }
1780
+ };
1781
+ /**
1782
+ * Records that _sanitizeElements processed `node`. No-op outside IN_PLACE.
1783
+ *
1784
+ * @param node the node being processed
1785
+ */
1786
+ const _markVisited = function _markVisited(node) {
1787
+ if (IN_PLACE_VISITED) setAdd(IN_PLACE_VISITED, node);
1788
+ };
1789
+ /**
1790
+ * Patch-linkage attributes (declarative partial updates): `patchsrc`
1791
+ * always, `for` everywhere except on <label> and <output>. Gated on
1792
+ * SAFE_FOR_XML. Shared by the IN_PLACE pre-pass and _isValidAttribute.
1793
+ *
1794
+ * @param lcName the transformCaseFunc'd attribute name
1795
+ * @param lcTag the transformCaseFunc'd tag name of the carrying element
1796
+ * @return true if the attribute is patch linkage and must be dropped
1797
+ */
1798
+ const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {
1799
+ if (!SAFE_FOR_XML) return false;
1800
+ if (lcName === "patchsrc") return true;
1801
+ return lcName === "for" && lcTag !== "label" && lcTag !== "output";
1802
+ };
1803
+ /**
1804
+ * IN_PLACE pre-pass: sever all patch linkage before the walk, so no patch
1805
+ * can fire mid-walk into a part of the tree the walker already passed.
1806
+ * Removes range markers (processing instructions, comments with markup)
1807
+ * and strips linkage attributes. It cannot undo a patch that already fired.
1808
+ *
1809
+ * TODO: if the shipped feature can patch through `for` on <label>/<output>,
1810
+ * drop that pair here too (see test/declarative-patch-probe.html).
1811
+ *
1812
+ * @param root the in-place root to sweep
1813
+ */
1814
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
1815
+ if (!SAFE_FOR_XML) return;
1816
+ _walkTree(root, (node) => {
1817
+ const nodeType = _readNodeType(node);
1818
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
1819
+ try {
1820
+ remove(node);
1821
+ } catch (_) {}
1822
+ return false;
1823
+ }
1824
+ if (nodeType === NODE_TYPE.element) {
1825
+ const element = node;
1826
+ const lcTag = transformCaseFunc(_readNodeName(node));
1827
+ try {
1828
+ if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
1829
+ if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
1830
+ } catch (_) {}
1831
+ }
1832
+ return true;
1833
+ });
1834
+ };
1835
+ /**
1836
+ * _initDocument
1837
+ *
1838
+ * @param dirty - a string of dirty markup
1839
+ * @return a DOM, filled with the dirty markup
1840
+ */
1841
+ const _initDocument = function _initDocument(dirty) {
1842
+ let doc = null;
1843
+ let leadingWhitespace = null;
1844
+ if (FORCE_BODY) dirty = "<remove></remove>" + dirty;
1845
+ else {
1846
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1847
+ leadingWhitespace = matches && matches[0];
1848
+ }
1849
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) dirty = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + dirty + "</body></html>";
1850
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
1851
+ if (NAMESPACE === HTML_NAMESPACE) try {
1852
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1853
+ } catch (_) {}
1854
+ if (!doc || !doc.documentElement) {
1855
+ doc = implementation.createDocument(NAMESPACE, "template", null);
1856
+ try {
1857
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1858
+ } catch (_) {}
1859
+ }
1860
+ const body = doc.body || doc.documentElement;
1861
+ if (dirty && leadingWhitespace) body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1862
+ if (NAMESPACE === HTML_NAMESPACE) return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
1863
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1864
+ };
1865
+ /**
1866
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
1867
+ *
1868
+ * @param root The root element or node to start traversing on.
1869
+ * @return The created NodeIterator
1870
+ */
1871
+ const _createNodeIterator = function _createNodeIterator(root) {
1872
+ const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
1873
+ return createNodeIterator.call(doc || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
1874
+ };
1875
+ /**
1876
+ * Replace template expression syntax (mustache, ERB, template
1877
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
1878
+ * sites. Order matters: mustache, then ERB, then template literal.
1879
+ *
1880
+ * @param value the string to scrub
1881
+ * @returns the scrubbed string
1882
+ */
1883
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
1884
+ value = stringReplace(value, MUSTACHE_EXPR$1, " ");
1885
+ value = stringReplace(value, ERB_EXPR$1, " ");
1886
+ value = stringReplace(value, TMPLIT_EXPR$1, " ");
1887
+ return value;
1888
+ };
1889
+ /**
1890
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
1891
+ * character data of an element subtree. Used as the final safety net for
1892
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
1893
+ * which only form after text-node normalization (e.g. fragments split across
1894
+ * stripped elements) cannot survive into a template-evaluating framework.
1895
+ *
1896
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
1897
+ * in place rather than round-tripping through innerHTML. This preserves
1898
+ * descendant node references (important for IN_PLACE callers), avoids a
1899
+ * serialize/reparse cycle, and reads literal character data — which means
1900
+ * `<%...%>` in text content matches the ERB regex against its real bytes
1901
+ * instead of the HTML-entity-escaped form innerHTML would produce.
1902
+ *
1903
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
1904
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
1905
+ *
1906
+ * @param node The root element whose character data should be scrubbed.
1907
+ */
1908
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
1909
+ var _node$querySelectorAl;
1910
+ _scrubOwnCharacterData(node);
1911
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
1912
+ if (templates) arrayForEach(templates, (tmpl) => {
1913
+ if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
1914
+ });
1915
+ };
1916
+ /**
1917
+ * _scrubOwnCharacterData
1918
+ *
1919
+ * Non-recursive core of _scrubTemplateExpressions: normalize `node` and
1920
+ * strip template expressions from its own character data only. Does not
1921
+ * enter <template>.content or attached shadow roots (NodeIterator never
1922
+ * does). Used by _sanitizeShadowDOM, where every nested template content
1923
+ * and shadow root is already walked - and therefore scrubbed - by its own
1924
+ * recursive _sanitizeShadowDOM call; recursing here as well would rescrub
1925
+ * each nested fragment once per ancestor, which is quadratic in nesting
1926
+ * depth.
1927
+ *
1928
+ * @param node The root whose own character data should be scrubbed.
1929
+ */
1930
+ const _scrubOwnCharacterData = function _scrubOwnCharacterData(node) {
1931
+ node.normalize();
1932
+ const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
1933
+ const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
1934
+ let currentNode = walker.nextNode();
1935
+ while (currentNode) {
1936
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
1937
+ currentNode = walker.nextNode();
1938
+ }
1939
+ };
1940
+ /**
1941
+ * _isClobbered
1942
+ *
1943
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
1944
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
1945
+ * `name` attribute matching a prototype property shadows that property
1946
+ * on direct reads. We use this check at the IN_PLACE entry-point and
1947
+ * during attribute sanitization to refuse clobbered forms.
1948
+ *
1949
+ * @param element element to check for clobbering attacks
1950
+ * @return true if clobbered, false if safe
1951
+ */
1952
+ const _isClobbered = function _isClobbered(element) {
1953
+ const realTagName = getNodeName ? getNodeName(element) : null;
1954
+ if (typeof realTagName !== "string") return false;
1955
+ if (transformCaseFunc(realTagName) !== "form") return false;
1956
+ return typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || element.attributes !== getAttributes(element) || typeof element.removeAttribute !== "function" || typeof element.removeAttributeNode !== "function" || typeof element.getAttributeNode !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function" || element.nodeType !== getNodeType(element) || element.childNodes !== getChildNodes(element);
1957
+ };
1958
+ /**
1959
+ * Checks whether the given value is a DocumentFragment from any realm.
1960
+ *
1961
+ * The realm-independent replacement reads `nodeType` through the cached
1962
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
1963
+ * constant (11). nodeType is a numeric value resolved from the node's
1964
+ * internal slot, identical across realms for the same kind of node.
1965
+ *
1966
+ * @param value object to check
1967
+ * @return true if value is a DocumentFragment-shaped node from any realm
1968
+ */
1969
+ const _isDocumentFragment = function _isDocumentFragment(value) {
1970
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
1971
+ try {
1972
+ return getNodeType(value) === NODE_TYPE.documentFragment;
1973
+ } catch (_) {
1974
+ return false;
1975
+ }
1976
+ };
1977
+ /**
1978
+ * Checks whether the given object is a DOM node, including nodes that
1979
+ * originate from a different window/realm (e.g. an iframe's
1980
+ * contentDocument). The previous `value instanceof Node` check was
1981
+ * realm-bound: nodes from a different window failed it, causing
1982
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
1983
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
1984
+ *
1985
+ * @param value object to check whether it's a DOM node
1986
+ * @return true if value is a DOM node from any realm
1987
+ */
1988
+ const _isNode = function _isNode(value) {
1989
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
1990
+ try {
1991
+ return typeof getNodeType(value) === "number";
1992
+ } catch (_) {
1993
+ return false;
1994
+ }
1995
+ };
1996
+ function _executeHooks(hooks, currentNode, data) {
1997
+ if (hooks.length === 0) return;
1998
+ arrayForEach(hooks, (hook) => {
1999
+ hook.call(DOMPurify, currentNode, data, CONFIG);
2000
+ });
2001
+ }
2002
+ /**
2003
+ * Structural-threat checks that condemn a node regardless of the
2004
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
2005
+ * processing instructions, markup-bearing comments. Pure predicate;
2006
+ * the caller removes. Check order is load-bearing.
2007
+ *
2008
+ * @param currentNode the node to inspect
2009
+ * @param tagName the node's transformCaseFunc'd tag name
2010
+ * @return true if the node must be removed
2011
+ */
2012
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
2013
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
2014
+ if (SAFE_FOR_XML && LITERAL_TEXT_ELEMENTS[tagName] && _readNodeType(currentNode) === NODE_TYPE.element && _readNamespaceURI(currentNode) === HTML_NAMESPACE && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === "string" && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent))) return true;
2015
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
2016
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
2017
+ return false;
2018
+ };
2019
+ /**
2020
+ * Evaluate a CUSTOM_ELEMENT_HANDLING check (a RegExp or a predicate
2021
+ * function, per the validation in _parseConfig) against a name.
2022
+ * Additional arguments are forwarded to predicate functions - the
2023
+ * attributeNameCheck predicate receives the tag name as its second
2024
+ * argument. A null/absent check never matches.
2025
+ *
2026
+ * @param check the configured tagNameCheck / attributeNameCheck value
2027
+ * @param name the name to test
2028
+ * @param args extra arguments forwarded to a predicate function
2029
+ * @return true if the check matches the name
2030
+ */
2031
+ const _matchesNameCheck = function _matchesNameCheck(check, name) {
2032
+ if (check instanceof RegExp) return regExpTest(check, name);
2033
+ if (check instanceof Function) {
2034
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
2035
+ return Boolean(check(name, ...args));
2036
+ }
2037
+ return false;
2038
+ };
2039
+ /**
2040
+ * Handle a node whose tag is forbidden or not allowlisted: keep
2041
+ * allowed custom elements (false return exits _sanitizeElements
2042
+ * early - the namespace and fallback-tag removal checks are
2043
+ * intentionally skipped for kept custom elements), else hoist
2044
+ * content per KEEP_CONTENT and remove.
2045
+ *
2046
+ * A kept custom element is the ONLY case in which this function
2047
+ * returns false, so the caller uses that return value to run the
2048
+ * afterSanitizeElements hook on the kept element and keep the
2049
+ * element-hook lifecycle consistent with normal allowlisted
2050
+ * elements (GHSA-c2j3-45gr-mqc4).
2051
+ *
2052
+ * @param currentNode the disallowed node
2053
+ * @param tagName the node's transformCaseFunc'd tag name
2054
+ * @return true if the node was removed, false if kept
2055
+ */
2056
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
2057
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
2058
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
2059
+ const parentNode = getParentNode(currentNode);
2060
+ const childNodes = getChildNodes(currentNode);
2061
+ if (childNodes && parentNode) {
2062
+ const childCount = childNodes.length;
2063
+ for (let i = childCount - 1; i >= 0; --i) {
2064
+ const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
2065
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
2066
+ }
2067
+ }
2068
+ }
2069
+ _forceRemove(currentNode);
2070
+ return true;
2071
+ };
2072
+ /**
2073
+ * Fork a hook-mutable allowlist off its shared binding the first time a
2074
+ * (possibly lazily-installed) uponSanitize* hook is about to see it, so the
2075
+ * hook cannot widen the per-instance default or the setConfig binding by
2076
+ * reference and leak past the call. Returns the set unchanged once it is
2077
+ * already call-local, so repeated calls across elements are idempotent.
2078
+ *
2079
+ * @param hookList the uponSanitize* hook array for this event
2080
+ * @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
2081
+ * @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
2082
+ * @param setConfigSet the captured setConfig() binding, or null
2083
+ * @return a call-local clone if a hook is present and set is still shared,
2084
+ * else set unchanged
2085
+ */
2086
+ const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
2087
+ if (hookList.length === 0) return set;
2088
+ return set === defaultSet || set === setConfigSet ? clone(set) : set;
2089
+ };
2090
+ /**
2091
+ * A hook may have detached the node it was called for. If so, treat it as
2092
+ * removed and stop processing it; the walk root is exempt. On the IN_PLACE
2093
+ * path the detached subtree is neutralized right away.
2094
+ *
2095
+ * @param currentNode the node a hook may have detached
2096
+ * @param root the current walk root
2097
+ * @return true if the node was detached
2098
+ */
2099
+ const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
2100
+ if (currentNode === root || getParentNode(currentNode) !== null) return false;
2101
+ if (IN_PLACE) _neutralizeSubtree(currentNode);
2102
+ return true;
2103
+ };
2104
+ /**
2105
+ * _sanitizeElements
2106
+ *
2107
+ * @protect nodeName
2108
+ * @protect textContent
2109
+ * @protect removeChild
2110
+ * @param currentNode to check for permission to exist
2111
+ * @return true if node was killed, false if left alive
2112
+ */
2113
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
2114
+ _markVisited(currentNode);
2115
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2116
+ if (_handleHookDetachedNode(currentNode, root)) return true;
2117
+ if (_isClobbered(currentNode)) {
2118
+ _forceRemove(currentNode);
2119
+ return true;
2120
+ }
2121
+ const tagName = transformCaseFunc(_readNodeName(currentNode));
2122
+ ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
2123
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
2124
+ tagName,
2125
+ allowedTags: ALLOWED_TAGS
2126
+ });
2127
+ if (_handleHookDetachedNode(currentNode, root)) return true;
2128
+ if (_isUnsafeNode(currentNode, tagName)) {
2129
+ _forceRemove(currentNode);
2130
+ return true;
2131
+ }
2132
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
2133
+ const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
2134
+ if (removed === false) {
2135
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2136
+ if (_handleHookDetachedNode(currentNode, root)) return true;
2137
+ }
2138
+ return removed;
2139
+ }
2140
+ if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
2141
+ _forceRemove(currentNode);
2142
+ return true;
2143
+ }
2144
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
2145
+ _forceRemove(currentNode);
2146
+ return true;
2147
+ }
2148
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
2149
+ const content = _stripTemplateExpressions(currentNode.textContent);
2150
+ if (currentNode.textContent !== content) {
2151
+ arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
2152
+ currentNode.textContent = content;
2153
+ }
2154
+ }
2155
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2156
+ return _handleHookDetachedNode(currentNode, root);
2157
+ };
2158
+ /**
2159
+ * _isValidAttribute
2160
+ *
2161
+ * @param lcTag Lowercase tag name of containing element.
2162
+ * @param lcName Lowercase attribute name.
2163
+ * @param value Attribute value.
2164
+ * @return Returns true if `value` is valid, otherwise false.
2165
+ */
2166
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
2167
+ if (FORBID_ATTR[lcName]) return false;
2168
+ if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
2169
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) return false;
2170
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
2171
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
2172
+ if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
2173
+ if (!nameIsPermitted) return _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) || lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value);
2174
+ if (URI_SAFE_ATTRIBUTES[lcName]) return true;
2175
+ if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
2176
+ if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
2177
+ if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
2178
+ return !value;
2179
+ };
2180
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
2181
+ "annotation-xml",
2182
+ "color-profile",
2183
+ "font-face",
2184
+ "font-face-format",
2185
+ "font-face-name",
2186
+ "font-face-src",
2187
+ "font-face-uri",
2188
+ "missing-glyph"
2189
+ ]);
2190
+ /**
2191
+ * _isBasicCustomElement
2192
+ * checks if at least one dash is included in tagName, and it's not the first char
2193
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
2194
+ *
2195
+ * @param tagName name of the tag of the node to sanitize
2196
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
2197
+ */
2198
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
2199
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
2200
+ };
2201
+ /**
2202
+ * Wrap an attribute value in the matching Trusted Types object when
2203
+ * the active policy requires it. Namespaced attributes pass through
2204
+ * unchanged (no TT support yet, see
2205
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
2206
+ *
2207
+ * @param lcTag lowercase tag name of the containing element
2208
+ * @param lcName lowercase attribute name
2209
+ * @param namespaceURI the attribute's namespace, if any
2210
+ * @param value the attribute value to wrap
2211
+ * @return the value, wrapped when Trusted Types demand it
2212
+ */
2213
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
2214
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2215
+ case "TrustedHTML": return _createTrustedHTML(value);
2216
+ case "TrustedScriptURL": return _createTrustedScriptURL(value);
2217
+ }
2218
+ return value;
2219
+ };
2220
+ /**
2221
+ * Write a modified attribute value back onto the element. On
2222
+ * success, re-probe for clobbering introduced by the new value and
2223
+ * remove the element when found; otherwise, when this writeback is the
2224
+ * recreate half of the SANITIZE_NAMED_PROPS remove-and-recreate, pop the
2225
+ * removal entry that path recorded so it does not show as removed. On
2226
+ * failure, remove the attribute instead.
2227
+ *
2228
+ * Returns true only on a clean write (the value was set and the new value
2229
+ * introduced no clobbering). The caller uses that, together with its own
2230
+ * knowledge of whether this attribute pushed a DOMPurify.removed record, to
2231
+ * decide whether to pop that record. The pop must happen ONLY for the
2232
+ * named-prop remove-and-recreate; popping on any other value change (trim,
2233
+ * template scrubbing, Trusted Types) would consume an unrelated _forceRemove
2234
+ * subtree-cleanup record and let that detached subtree keep a live event
2235
+ * handler through the IN_PLACE neutralization pass (SO-001).
2236
+ *
2237
+ * @param currentNode the element carrying the attribute
2238
+ * @param name the attribute name as present on the element
2239
+ * @param namespaceURI the attribute's namespace, if any
2240
+ * @param value the new attribute value
2241
+ * @return true if the value was written without introducing clobbering
2242
+ */
2243
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
2244
+ try {
2245
+ if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
2246
+ else currentNode.setAttribute(name, value);
2247
+ if (_isClobbered(currentNode)) {
2248
+ _forceRemove(currentNode);
2249
+ return false;
2250
+ }
2251
+ return true;
2252
+ } catch (_) {
2253
+ _removeAttribute(name, currentNode);
2254
+ return false;
2255
+ }
2256
+ };
2257
+ /**
2258
+ * _isUnsafeAttributeValue
2259
+ *
2260
+ * Value-based attribute checks that the attribute walk applies before any
2261
+ * hook can force-keep an attribute, shared with the public
2262
+ * isValidAttribute() so that it never approves a value sanitize() would
2263
+ * strip.
2264
+ *
2265
+ * @param name the attribute name as found on the node (case preserved)
2266
+ * @param value the attribute value
2267
+ * @returns true if the attribute must be removed because of its value
2268
+ */
2269
+ const _isUnsafeAttributeValue = function _isUnsafeAttributeValue(name, value) {
2270
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) return true;
2271
+ return stringToLowerCase(name) === "attributename" && stringMatch(value, "href") !== null;
2272
+ };
2273
+ /**
2274
+ * _sanitizeAttributes
2275
+ *
2276
+ * @protect attributes
2277
+ * @protect nodeName
2278
+ * @protect removeAttribute
2279
+ * @protect setAttribute
2280
+ *
2281
+ * @param currentNode to sanitize
2282
+ * @param root the current walk root
2283
+ */
2284
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode, root) {
2285
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2286
+ if (_handleHookDetachedNode(currentNode, root)) return;
2287
+ const attributes = currentNode.attributes;
2288
+ if (!attributes || _isClobbered(currentNode)) return;
2289
+ ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
2290
+ const hookEvent = {
2291
+ attrName: "",
2292
+ attrValue: "",
2293
+ keepAttr: true,
2294
+ allowedAttributes: ALLOWED_ATTR,
2295
+ forceKeepAttr: void 0
2296
+ };
2297
+ let l = attributes.length;
2298
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2299
+ while (l--) {
2300
+ const attr = attributes[l];
2301
+ const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
2302
+ const lcName = transformCaseFunc(name);
2303
+ const initValue = attrValue;
2304
+ let value = name === "value" ? initValue : stringTrim(initValue);
2305
+ let recreatedNamedProp = false;
2306
+ hookEvent.attrName = lcName;
2307
+ hookEvent.attrValue = value;
2308
+ hookEvent.keepAttr = true;
2309
+ hookEvent.forceKeepAttr = void 0;
2310
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
2311
+ value = hookEvent.attrValue;
2312
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
2313
+ _removeAttribute(name, currentNode, attr);
2314
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
2315
+ recreatedNamedProp = true;
2316
+ }
2317
+ if (_isUnsafeAttributeValue(name, value)) {
2318
+ _removeAttribute(name, currentNode, attr);
2319
+ continue;
2320
+ }
2321
+ if (hookEvent.forceKeepAttr) continue;
2322
+ if (!hookEvent.keepAttr) {
2323
+ _removeAttribute(name, currentNode, attr);
2324
+ continue;
2325
+ }
2326
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
2327
+ _removeAttribute(name, currentNode, attr);
2328
+ continue;
2329
+ }
2330
+ if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
2331
+ if (!_isValidAttribute(lcTag, lcName, value)) {
2332
+ _removeAttribute(name, currentNode, attr);
2333
+ continue;
2334
+ }
2335
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
2336
+ if (value !== initValue) {
2337
+ if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
2338
+ }
2339
+ }
2340
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
2341
+ _handleHookDetachedNode(currentNode, root);
2342
+ };
2343
+ /**
2344
+ * _sanitizeShadowDOM
2345
+ *
2346
+ * @param fragment to iterate over recursively
2347
+ */
2348
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
2349
+ let shadowNode = null;
2350
+ const shadowIterator = _createNodeIterator(fragment);
2351
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
2352
+ while (shadowNode = shadowIterator.nextNode()) {
2353
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
2354
+ _sanitizeElements(shadowNode, fragment);
2355
+ _sanitizeAttributes(shadowNode, fragment);
2356
+ if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
2357
+ if (_readNodeType(shadowNode) === NODE_TYPE.element) {
2358
+ const innerSr = getShadowRoot(shadowNode);
2359
+ if (_isDocumentFragment(innerSr)) {
2360
+ _sanitizeAttachedShadowRoots(innerSr);
2361
+ _sanitizeShadowDOM2(innerSr);
2362
+ }
2363
+ }
2364
+ }
2365
+ if (SAFE_FOR_TEMPLATES) _scrubOwnCharacterData(fragment);
2366
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2367
+ };
2368
+ /**
2369
+ * Sanitizes every attached shadow root under `root`, since the node
2370
+ * iterator does not enter shadow trees. Needed for IN_PLACE input and for
2371
+ * DOM input whose clonable shadow roots were copied by importNode().
2372
+ *
2373
+ * @param root the subtree root to walk for attached shadow roots
2374
+ */
2375
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
2376
+ const stack = [{
2377
+ node: root,
2378
+ shadow: null
2379
+ }];
2380
+ while (stack.length > 0) {
2381
+ const item = stack.pop();
2382
+ if (item.shadow) {
2383
+ _sanitizeShadowDOM2(item.shadow);
2384
+ continue;
2385
+ }
2386
+ const node = item.node;
2387
+ const isElement = _readNodeType(node) === NODE_TYPE.element;
2388
+ const childNodes = getChildNodes(node);
2389
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
2390
+ node: childNodes[i],
2391
+ shadow: null
2392
+ });
2393
+ if (isElement) {
2394
+ const rootName = getNodeName ? getNodeName(node) : null;
2395
+ if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
2396
+ const content = node.content;
2397
+ if (_isDocumentFragment(content)) stack.push({
2398
+ node: content,
2399
+ shadow: null
2400
+ });
2401
+ }
2402
+ }
2403
+ if (isElement) {
2404
+ const sr = getShadowRoot(node);
2405
+ if (_isDocumentFragment(sr)) stack.push({
2406
+ node: null,
2407
+ shadow: sr
2408
+ }, {
2409
+ node: sr,
2410
+ shadow: null
2411
+ });
2412
+ }
2413
+ }
2414
+ };
2415
+ DOMPurify.sanitize = function(dirty) {
2416
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2417
+ let body = null;
2418
+ let importedNode = null;
2419
+ let currentNode = null;
2420
+ let returnNode = null;
2421
+ IS_EMPTY_INPUT = !dirty;
2422
+ if (IS_EMPTY_INPUT) dirty = "<!-->";
2423
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
2424
+ dirty = stringifyValue(dirty);
2425
+ if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
2426
+ }
2427
+ if (!DOMPurify.isSupported) return dirty;
2428
+ if (SET_CONFIG) {
2429
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
2430
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
2431
+ } else _parseConfig(cfg);
2432
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
2433
+ if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
2434
+ DOMPurify.removed = [];
2435
+ const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
2436
+ let inPlaceNodes = [];
2437
+ const outerVisited = IN_PLACE_VISITED;
2438
+ if (inPlace) {
2439
+ _neutralizePatchLinkage(dirty);
2440
+ const nn = _readNodeName(dirty);
2441
+ if (typeof nn === "string") {
2442
+ const tagName = transformCaseFunc(nn);
2443
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
2444
+ _neutralizeRoot(dirty);
2445
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
2446
+ }
2447
+ }
2448
+ if (_isClobbered(dirty)) {
2449
+ _neutralizeRoot(dirty);
2450
+ throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
2451
+ }
2452
+ inPlaceNodes = _collectLiveNodes(dirty);
2453
+ IN_PLACE_VISITED = setCreate();
2454
+ } else if (_isNode(dirty)) {
2455
+ body = _initDocument("<!---->");
2456
+ importedNode = body.ownerDocument.importNode(dirty, true);
2457
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
2458
+ else if (importedNode.nodeName === "HTML") body = importedNode;
2459
+ else body.appendChild(importedNode);
2460
+ _sanitizeAttachedShadowRoots(body);
2461
+ } else {
2462
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
2463
+ body = _initDocument(dirty);
2464
+ if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
2465
+ }
2466
+ if (body && FORCE_BODY) _forceRemove(body.firstChild);
2467
+ const walkRoot = inPlace ? dirty : body;
2468
+ try {
2469
+ if (inPlace) _sanitizeAttachedShadowRoots(dirty);
2470
+ const nodeIterator = _createNodeIterator(walkRoot);
2471
+ while (currentNode = nodeIterator.nextNode()) {
2472
+ _sanitizeElements(currentNode, walkRoot);
2473
+ _sanitizeAttributes(currentNode, walkRoot);
2474
+ if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
2475
+ }
2476
+ if (inPlace) _sanitizeUnvisitedNodes(dirty, inPlaceNodes);
2477
+ } catch (error) {
2478
+ if (inPlace) {
2479
+ _neutralizeRoot(dirty);
2480
+ _neutralizeDiscarded(dirty, inPlaceNodes);
2481
+ }
2482
+ throw error;
2483
+ } finally {
2484
+ IN_PLACE_VISITED = outerVisited;
2485
+ }
2486
+ if (inPlace) {
2487
+ if (_neutralizeDiscarded(dirty, inPlaceNodes)) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
2488
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
2489
+ return dirty;
2490
+ }
2491
+ if (RETURN_DOM) {
2492
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
2493
+ if (RETURN_DOM_FRAGMENT) {
2494
+ returnNode = createDocumentFragment.call(body.ownerDocument);
2495
+ while (body.firstChild) returnNode.appendChild(body.firstChild);
2496
+ } else returnNode = body;
2497
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
2498
+ return returnNode;
2499
+ }
2500
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
2501
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
2502
+ if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
2503
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
2504
+ };
2505
+ DOMPurify.setConfig = function() {
2506
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2507
+ _parseConfig(cfg);
2508
+ SET_CONFIG = true;
2509
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
2510
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
2511
+ };
2512
+ DOMPurify.clearConfig = function() {
2513
+ CONFIG = null;
2514
+ SET_CONFIG = false;
2515
+ SET_CONFIG_ALLOWED_TAGS = null;
2516
+ SET_CONFIG_ALLOWED_ATTR = null;
2517
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
2518
+ emptyHTML = "";
2519
+ };
2520
+ DOMPurify.isValidAttribute = function(tag, attr, value) {
2521
+ if (!CONFIG) _parseConfig({});
2522
+ const lcTag = transformCaseFunc(tag);
2523
+ const lcName = transformCaseFunc(attr);
2524
+ if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value))) return false;
2525
+ return _isValidAttribute(lcTag, lcName, value);
2526
+ };
2527
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
2528
+ if (typeof hookFunction !== "function") return;
2529
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
2530
+ arrayPush(hooks[entryPoint], hookFunction);
2531
+ };
2532
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
2533
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
2534
+ if (hookFunction !== void 0) {
2535
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
2536
+ return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
2537
+ }
2538
+ return arrayPop(hooks[entryPoint]);
2539
+ };
2540
+ DOMPurify.removeHooks = function(entryPoint) {
2541
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
2542
+ hooks[entryPoint] = [];
2543
+ };
2544
+ DOMPurify.removeAllHooks = function() {
2545
+ hooks = _createHooksMap();
2546
+ };
2547
+ return DOMPurify;
2548
+ }
2549
+ var purify_default = createDOMPurify();
2550
+
2551
+
2552
+ //# sourceMappingURL=purify.es.mjs.map
2553
+
2554
+ /***/ })
2555
+
2556
+ }])
2557
+ //# sourceMappingURL=vendors-node_modules_vaadin_markdown_node_modules_dompurify_dist_purify_es_mjs.js.map