tablefilter 0.7.8 → 0.7.9

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.
@@ -12480,7 +12480,2572 @@ var DateType = class DateType extends Feature {
12480
12480
  }
12481
12481
  };
12482
12482
  //#endregion
12483
+ //#region node_modules/dompurify/dist/purify.es.mjs
12484
+ /*! @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 */
12485
+ function _OverloadYield(e, d) {
12486
+ this.v = e, this.k = d;
12487
+ }
12488
+ function _arrayLikeToArray(r, a) {
12489
+ (null == a || a > r.length) && (a = r.length);
12490
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
12491
+ return n;
12492
+ }
12493
+ function _arrayWithHoles(r) {
12494
+ if (Array.isArray(r)) return r;
12495
+ }
12496
+ function _iterableToArrayLimit(r, l) {
12497
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
12498
+ if (null != t) {
12499
+ var e, n, i, u, a = [], f = !0, o = !1;
12500
+ try {
12501
+ if (i = (t = t.call(r)).next, 0 === l) {
12502
+ if (Object(t) !== t) return;
12503
+ f = !1;
12504
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
12505
+ } catch (r) {
12506
+ o = !0, n = r;
12507
+ } finally {
12508
+ try {
12509
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
12510
+ } finally {
12511
+ if (o) throw n;
12512
+ }
12513
+ }
12514
+ return a;
12515
+ }
12516
+ }
12517
+ function _nonIterableRest() {
12518
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
12519
+ }
12520
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
12521
+ function _slicedToArray(r, e) {
12522
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
12523
+ }
12524
+ function _unsupportedIterableToArray(r, a) {
12525
+ if (r) {
12526
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
12527
+ var t = {}.toString.call(r).slice(8, -1);
12528
+ 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;
12529
+ }
12530
+ }
12531
+ function AsyncGenerator(e) {
12532
+ var t, n;
12533
+ function resume(t, n) {
12534
+ try {
12535
+ var r = e[t](n), o = r.value, u = o instanceof _OverloadYield;
12536
+ Promise.resolve(u ? o.v : o).then(function(n) {
12537
+ if (u) {
12538
+ var i = "return" === t && o.k ? t : "next";
12539
+ if (!o.k || n.done) return resume(i, n);
12540
+ n = e[i](n).value;
12541
+ }
12542
+ settle(!!r.done, n);
12543
+ }, function(e) {
12544
+ resume("throw", e);
12545
+ });
12546
+ } catch (e) {
12547
+ settle(2, e);
12548
+ }
12549
+ }
12550
+ function settle(e, r) {
12551
+ 2 === e ? t.reject(r) : t.resolve({
12552
+ value: r,
12553
+ done: e
12554
+ }), (t = t.next) ? resume(t.key, t.arg) : n = null;
12555
+ }
12556
+ this._invoke = function(e, r) {
12557
+ return new Promise(function(o, u) {
12558
+ var i = {
12559
+ key: e,
12560
+ arg: r,
12561
+ resolve: o,
12562
+ reject: u,
12563
+ next: null
12564
+ };
12565
+ n ? n = n.next = i : (t = n = i, resume(e, r));
12566
+ });
12567
+ }, "function" != typeof e.return && (this.return = void 0);
12568
+ }
12569
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function() {
12570
+ return this;
12571
+ }, AsyncGenerator.prototype.next = function(e) {
12572
+ return this._invoke("next", e);
12573
+ }, AsyncGenerator.prototype.throw = function(e) {
12574
+ return this._invoke("throw", e);
12575
+ }, AsyncGenerator.prototype.return = function(e) {
12576
+ return this._invoke("return", e);
12577
+ };
12578
+ var entries = Object.entries;
12579
+ var setPrototypeOf = Object.setPrototypeOf;
12580
+ var isFrozen = Object.isFrozen;
12581
+ var getPrototypeOf = Object.getPrototypeOf;
12582
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
12583
+ var freeze = Object.freeze;
12584
+ var seal = Object.seal;
12585
+ var create = Object.create;
12586
+ var _ref = typeof Reflect !== "undefined" && Reflect;
12587
+ var apply = _ref.apply;
12588
+ var construct = _ref.construct;
12589
+ if (!freeze) freeze = function freeze(x) {
12590
+ return x;
12591
+ };
12592
+ if (!seal) seal = function seal(x) {
12593
+ return x;
12594
+ };
12595
+ if (!apply) apply = function apply(func, thisArg) {
12596
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
12597
+ return func.apply(thisArg, args);
12598
+ };
12599
+ if (!construct) construct = function construct(Func) {
12600
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) args[_key2 - 1] = arguments[_key2];
12601
+ return new Func(...args);
12602
+ };
12603
+ var arrayForEach = unapply(Array.prototype.forEach);
12604
+ Array.prototype.indexOf;
12605
+ var arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
12606
+ var arrayPop = unapply(Array.prototype.pop);
12607
+ var arrayPush = unapply(Array.prototype.push);
12608
+ var arraySlice = unapply(Array.prototype.slice);
12609
+ var arraySplice = unapply(Array.prototype.splice);
12610
+ var arrayIsArray = Array.isArray;
12611
+ var setCreate = unconstruct(Set);
12612
+ var setAdd = unapply(Set.prototype.add);
12613
+ var setHas = unapply(Set.prototype.has);
12614
+ var stringToLowerCase = unapply(String.prototype.toLowerCase);
12615
+ var stringToString = unapply(String.prototype.toString);
12616
+ var stringMatch = unapply(String.prototype.match);
12617
+ var stringReplace = unapply(String.prototype.replace);
12618
+ var stringIndexOf = unapply(String.prototype.indexOf);
12619
+ var stringTrim = unapply(String.prototype.trim);
12620
+ var numberToString = unapply(Number.prototype.toString);
12621
+ var booleanToString = unapply(Boolean.prototype.toString);
12622
+ var bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
12623
+ var symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
12624
+ var objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
12625
+ var objectToString = unapply(Object.prototype.toString);
12626
+ var regExpTest = unapply(RegExp.prototype.test);
12627
+ var typeErrorCreate = unconstruct(TypeError);
12628
+ /**
12629
+ * Creates a new function that calls the given function with a specified thisArg and arguments.
12630
+ *
12631
+ * @param func - The function to be wrapped and called.
12632
+ * @returns A new function that calls the given function with a specified thisArg and arguments.
12633
+ */
12634
+ function unapply(func) {
12635
+ return function(thisArg) {
12636
+ if (thisArg instanceof RegExp) thisArg.lastIndex = 0;
12637
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) args[_key3 - 1] = arguments[_key3];
12638
+ return apply(func, thisArg, args);
12639
+ };
12640
+ }
12641
+ /**
12642
+ * Creates a new function that constructs an instance of the given constructor function with the provided arguments.
12643
+ *
12644
+ * @param func - The constructor function to be wrapped and called.
12645
+ * @returns A new function that constructs an instance of the given constructor function with the provided arguments.
12646
+ */
12647
+ function unconstruct(Func) {
12648
+ return function() {
12649
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) args[_key4] = arguments[_key4];
12650
+ return construct(Func, args);
12651
+ };
12652
+ }
12653
+ /**
12654
+ * Add properties to a lookup table
12655
+ *
12656
+ * @param set - The set to which elements will be added.
12657
+ * @param array - The array containing elements to be added to the set.
12658
+ * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.
12659
+ * @returns The modified set with added elements.
12660
+ */
12661
+ function addToSet(set, array) {
12662
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
12663
+ if (setPrototypeOf) setPrototypeOf(set, null);
12664
+ if (!arrayIsArray(array)) return set;
12665
+ let l = array.length;
12666
+ while (l--) {
12667
+ let element = array[l];
12668
+ if (typeof element === "string") {
12669
+ const lcElement = transformCaseFunc(element);
12670
+ if (lcElement !== element) {
12671
+ if (!isFrozen(array)) array[l] = lcElement;
12672
+ element = lcElement;
12673
+ }
12674
+ }
12675
+ set[element] = true;
12676
+ }
12677
+ return set;
12678
+ }
12679
+ /**
12680
+ * Clean up an array to harden against CSPP
12681
+ *
12682
+ * @param array - The array to be cleaned.
12683
+ * @returns The cleaned version of the array
12684
+ */
12685
+ function cleanArray(array) {
12686
+ for (let index = 0; index < array.length; index++) if (!objectHasOwnProperty(array, index)) array[index] = null;
12687
+ return array;
12688
+ }
12689
+ /**
12690
+ * Shallow clone an object
12691
+ *
12692
+ * @param object - The object to be cloned.
12693
+ * @returns A new object that copies the original.
12694
+ */
12695
+ function clone(object) {
12696
+ const newObject = create(null);
12697
+ for (const _ref2 of entries(object)) {
12698
+ var _ref3 = _slicedToArray(_ref2, 2);
12699
+ const property = _ref3[0];
12700
+ const value = _ref3[1];
12701
+ if (objectHasOwnProperty(object, property)) {
12702
+ if (arrayIsArray(value)) newObject[property] = cleanArray(value);
12703
+ else if (value && typeof value === "object" && value.constructor === Object) newObject[property] = clone(value);
12704
+ else newObject[property] = value;
12705
+ }
12706
+ }
12707
+ return newObject;
12708
+ }
12709
+ /**
12710
+ * Convert non-node values into strings without depending on direct property access.
12711
+ *
12712
+ * @param value - The value to stringify.
12713
+ * @returns A string representation of the provided value.
12714
+ */
12715
+ function stringifyValue(value) {
12716
+ switch (typeof value) {
12717
+ case "string": return value;
12718
+ case "number": return numberToString(value);
12719
+ case "boolean": return booleanToString(value);
12720
+ case "bigint": return bigintToString ? bigintToString(value) : "0";
12721
+ case "symbol": return symbolToString ? symbolToString(value) : "Symbol()";
12722
+ case "undefined": return objectToString(value);
12723
+ case "function":
12724
+ case "object": {
12725
+ if (value === null) return objectToString(value);
12726
+ const valueAsRecord = value;
12727
+ const valueToString = lookupGetter(valueAsRecord, "toString");
12728
+ if (typeof valueToString === "function") {
12729
+ const stringified = valueToString(valueAsRecord);
12730
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
12731
+ }
12732
+ return objectToString(value);
12733
+ }
12734
+ default: return objectToString(value);
12735
+ }
12736
+ }
12737
+ /**
12738
+ * This method automatically checks if the prop is function or getter and behaves accordingly.
12739
+ *
12740
+ * @param object - The object to look up the getter function in its prototype chain.
12741
+ * @param prop - The property name for which to find the getter function.
12742
+ * @returns The getter function found in the prototype chain or a fallback function.
12743
+ */
12744
+ function lookupGetter(object, prop) {
12745
+ while (object !== null) {
12746
+ const desc = getOwnPropertyDescriptor(object, prop);
12747
+ if (desc) {
12748
+ if (desc.get) return unapply(desc.get);
12749
+ if (typeof desc.value === "function") return unapply(desc.value);
12750
+ }
12751
+ object = getPrototypeOf(object);
12752
+ }
12753
+ function fallbackValue() {
12754
+ return null;
12755
+ }
12756
+ return fallbackValue;
12757
+ }
12758
+ /**
12759
+ * Like lookupGetter, but for accessor properties only, and returns null
12760
+ * instead of a null-returning fallback when no getter exists on the chain.
12761
+ * Lets a caller fall back to a direct property read in environments that
12762
+ * lack the getter, where a fallback returning null would be indistinguishable
12763
+ * from a legitimate null value (e.g. namespaceURI of a no-namespace element).
12764
+ *
12765
+ * @param object - The object (usually a prototype) to start the lookup at.
12766
+ * @param prop - The accessor property name.
12767
+ * @returns The unapplied getter, or null if none was found.
12768
+ */
12769
+ function lookupAccessor(object, prop) {
12770
+ while (object !== null) {
12771
+ const desc = getOwnPropertyDescriptor(object, prop);
12772
+ if (desc) return desc.get ? unapply(desc.get) : null;
12773
+ object = getPrototypeOf(object);
12774
+ }
12775
+ return null;
12776
+ }
12777
+ function isRegex(value) {
12778
+ try {
12779
+ regExpTest(value, "");
12780
+ return true;
12781
+ } catch (_unused) {
12782
+ return false;
12783
+ }
12784
+ }
12785
+ var html$1 = freeze([
12786
+ "a",
12787
+ "abbr",
12788
+ "acronym",
12789
+ "address",
12790
+ "area",
12791
+ "article",
12792
+ "aside",
12793
+ "audio",
12794
+ "b",
12795
+ "bdi",
12796
+ "bdo",
12797
+ "big",
12798
+ "blink",
12799
+ "blockquote",
12800
+ "body",
12801
+ "br",
12802
+ "button",
12803
+ "canvas",
12804
+ "caption",
12805
+ "center",
12806
+ "cite",
12807
+ "code",
12808
+ "col",
12809
+ "colgroup",
12810
+ "content",
12811
+ "data",
12812
+ "datalist",
12813
+ "dd",
12814
+ "decorator",
12815
+ "del",
12816
+ "details",
12817
+ "dfn",
12818
+ "dialog",
12819
+ "dir",
12820
+ "div",
12821
+ "dl",
12822
+ "dt",
12823
+ "element",
12824
+ "em",
12825
+ "fieldset",
12826
+ "figcaption",
12827
+ "figure",
12828
+ "font",
12829
+ "footer",
12830
+ "form",
12831
+ "h1",
12832
+ "h2",
12833
+ "h3",
12834
+ "h4",
12835
+ "h5",
12836
+ "h6",
12837
+ "head",
12838
+ "header",
12839
+ "hgroup",
12840
+ "hr",
12841
+ "html",
12842
+ "i",
12843
+ "img",
12844
+ "input",
12845
+ "ins",
12846
+ "kbd",
12847
+ "label",
12848
+ "legend",
12849
+ "li",
12850
+ "main",
12851
+ "map",
12852
+ "mark",
12853
+ "marquee",
12854
+ "menu",
12855
+ "menuitem",
12856
+ "meter",
12857
+ "nav",
12858
+ "nobr",
12859
+ "ol",
12860
+ "optgroup",
12861
+ "option",
12862
+ "output",
12863
+ "p",
12864
+ "picture",
12865
+ "pre",
12866
+ "progress",
12867
+ "q",
12868
+ "rp",
12869
+ "rt",
12870
+ "ruby",
12871
+ "s",
12872
+ "samp",
12873
+ "search",
12874
+ "section",
12875
+ "select",
12876
+ "shadow",
12877
+ "slot",
12878
+ "small",
12879
+ "source",
12880
+ "spacer",
12881
+ "span",
12882
+ "strike",
12883
+ "strong",
12884
+ "style",
12885
+ "sub",
12886
+ "summary",
12887
+ "sup",
12888
+ "table",
12889
+ "tbody",
12890
+ "td",
12891
+ "template",
12892
+ "textarea",
12893
+ "tfoot",
12894
+ "th",
12895
+ "thead",
12896
+ "time",
12897
+ "tr",
12898
+ "track",
12899
+ "tt",
12900
+ "u",
12901
+ "ul",
12902
+ "var",
12903
+ "video",
12904
+ "wbr"
12905
+ ]);
12906
+ var svg$1 = freeze([
12907
+ "svg",
12908
+ "a",
12909
+ "altglyph",
12910
+ "altglyphdef",
12911
+ "altglyphitem",
12912
+ "animatecolor",
12913
+ "animatemotion",
12914
+ "animatetransform",
12915
+ "circle",
12916
+ "clippath",
12917
+ "defs",
12918
+ "desc",
12919
+ "ellipse",
12920
+ "enterkeyhint",
12921
+ "exportparts",
12922
+ "filter",
12923
+ "font",
12924
+ "g",
12925
+ "glyph",
12926
+ "glyphref",
12927
+ "hkern",
12928
+ "image",
12929
+ "inputmode",
12930
+ "line",
12931
+ "lineargradient",
12932
+ "marker",
12933
+ "mask",
12934
+ "metadata",
12935
+ "mpath",
12936
+ "part",
12937
+ "path",
12938
+ "pattern",
12939
+ "polygon",
12940
+ "polyline",
12941
+ "radialgradient",
12942
+ "rect",
12943
+ "stop",
12944
+ "style",
12945
+ "switch",
12946
+ "symbol",
12947
+ "text",
12948
+ "textpath",
12949
+ "title",
12950
+ "tref",
12951
+ "tspan",
12952
+ "view",
12953
+ "vkern"
12954
+ ]);
12955
+ var svgFilters = freeze([
12956
+ "feBlend",
12957
+ "feColorMatrix",
12958
+ "feComponentTransfer",
12959
+ "feComposite",
12960
+ "feConvolveMatrix",
12961
+ "feDiffuseLighting",
12962
+ "feDisplacementMap",
12963
+ "feDistantLight",
12964
+ "feDropShadow",
12965
+ "feFlood",
12966
+ "feFuncA",
12967
+ "feFuncB",
12968
+ "feFuncG",
12969
+ "feFuncR",
12970
+ "feGaussianBlur",
12971
+ "feImage",
12972
+ "feMerge",
12973
+ "feMergeNode",
12974
+ "feMorphology",
12975
+ "feOffset",
12976
+ "fePointLight",
12977
+ "feSpecularLighting",
12978
+ "feSpotLight",
12979
+ "feTile",
12980
+ "feTurbulence"
12981
+ ]);
12982
+ var svgDisallowed = freeze([
12983
+ "animate",
12984
+ "color-profile",
12985
+ "cursor",
12986
+ "discard",
12987
+ "font-face",
12988
+ "font-face-format",
12989
+ "font-face-name",
12990
+ "font-face-src",
12991
+ "font-face-uri",
12992
+ "foreignobject",
12993
+ "hatch",
12994
+ "hatchpath",
12995
+ "mesh",
12996
+ "meshgradient",
12997
+ "meshpatch",
12998
+ "meshrow",
12999
+ "missing-glyph",
13000
+ "script",
13001
+ "set",
13002
+ "solidcolor",
13003
+ "unknown",
13004
+ "use"
13005
+ ]);
13006
+ var mathMl$1 = freeze([
13007
+ "math",
13008
+ "menclose",
13009
+ "merror",
13010
+ "mfenced",
13011
+ "mfrac",
13012
+ "mglyph",
13013
+ "mi",
13014
+ "mlabeledtr",
13015
+ "mmultiscripts",
13016
+ "mn",
13017
+ "mo",
13018
+ "mover",
13019
+ "mpadded",
13020
+ "mphantom",
13021
+ "mroot",
13022
+ "mrow",
13023
+ "ms",
13024
+ "mspace",
13025
+ "msqrt",
13026
+ "mstyle",
13027
+ "msub",
13028
+ "msup",
13029
+ "msubsup",
13030
+ "mtable",
13031
+ "mtd",
13032
+ "mtext",
13033
+ "mtr",
13034
+ "munder",
13035
+ "munderover",
13036
+ "mprescripts"
13037
+ ]);
13038
+ var mathMlDisallowed = freeze([
13039
+ "maction",
13040
+ "maligngroup",
13041
+ "malignmark",
13042
+ "mlongdiv",
13043
+ "mscarries",
13044
+ "mscarry",
13045
+ "msgroup",
13046
+ "mstack",
13047
+ "msline",
13048
+ "msrow",
13049
+ "semantics",
13050
+ "annotation",
13051
+ "annotation-xml",
13052
+ "mprescripts",
13053
+ "none"
13054
+ ]);
13055
+ var text = freeze(["#text"]);
13056
+ var html = freeze([
13057
+ "accept",
13058
+ "action",
13059
+ "align",
13060
+ "alt",
13061
+ "autocapitalize",
13062
+ "autocomplete",
13063
+ "autopictureinpicture",
13064
+ "autoplay",
13065
+ "background",
13066
+ "bgcolor",
13067
+ "border",
13068
+ "capture",
13069
+ "cellpadding",
13070
+ "cellspacing",
13071
+ "checked",
13072
+ "cite",
13073
+ "class",
13074
+ "clear",
13075
+ "color",
13076
+ "cols",
13077
+ "colspan",
13078
+ "command",
13079
+ "commandfor",
13080
+ "controls",
13081
+ "controlslist",
13082
+ "coords",
13083
+ "crossorigin",
13084
+ "datetime",
13085
+ "decoding",
13086
+ "default",
13087
+ "dir",
13088
+ "disabled",
13089
+ "disablepictureinpicture",
13090
+ "disableremoteplayback",
13091
+ "download",
13092
+ "draggable",
13093
+ "enctype",
13094
+ "enterkeyhint",
13095
+ "exportparts",
13096
+ "face",
13097
+ "for",
13098
+ "headers",
13099
+ "height",
13100
+ "hidden",
13101
+ "high",
13102
+ "href",
13103
+ "hreflang",
13104
+ "id",
13105
+ "inert",
13106
+ "inputmode",
13107
+ "integrity",
13108
+ "ismap",
13109
+ "kind",
13110
+ "label",
13111
+ "lang",
13112
+ "list",
13113
+ "loading",
13114
+ "loop",
13115
+ "low",
13116
+ "max",
13117
+ "maxlength",
13118
+ "media",
13119
+ "method",
13120
+ "min",
13121
+ "minlength",
13122
+ "multiple",
13123
+ "muted",
13124
+ "name",
13125
+ "nonce",
13126
+ "noshade",
13127
+ "novalidate",
13128
+ "nowrap",
13129
+ "open",
13130
+ "optimum",
13131
+ "part",
13132
+ "pattern",
13133
+ "placeholder",
13134
+ "playsinline",
13135
+ "popover",
13136
+ "popovertarget",
13137
+ "popovertargetaction",
13138
+ "poster",
13139
+ "preload",
13140
+ "pubdate",
13141
+ "radiogroup",
13142
+ "readonly",
13143
+ "rel",
13144
+ "required",
13145
+ "rev",
13146
+ "reversed",
13147
+ "role",
13148
+ "rows",
13149
+ "rowspan",
13150
+ "spellcheck",
13151
+ "scope",
13152
+ "selected",
13153
+ "shape",
13154
+ "size",
13155
+ "sizes",
13156
+ "slot",
13157
+ "span",
13158
+ "srclang",
13159
+ "start",
13160
+ "src",
13161
+ "srcset",
13162
+ "step",
13163
+ "style",
13164
+ "summary",
13165
+ "tabindex",
13166
+ "title",
13167
+ "translate",
13168
+ "type",
13169
+ "usemap",
13170
+ "valign",
13171
+ "value",
13172
+ "width",
13173
+ "wrap",
13174
+ "xmlns"
13175
+ ]);
13176
+ var svg = freeze([
13177
+ "accent-height",
13178
+ "accumulate",
13179
+ "additive",
13180
+ "alignment-baseline",
13181
+ "amplitude",
13182
+ "ascent",
13183
+ "attributename",
13184
+ "attributetype",
13185
+ "azimuth",
13186
+ "basefrequency",
13187
+ "baseline-shift",
13188
+ "begin",
13189
+ "bias",
13190
+ "by",
13191
+ "class",
13192
+ "clip",
13193
+ "clippathunits",
13194
+ "clip-path",
13195
+ "clip-rule",
13196
+ "color",
13197
+ "color-interpolation",
13198
+ "color-interpolation-filters",
13199
+ "color-profile",
13200
+ "color-rendering",
13201
+ "cx",
13202
+ "cy",
13203
+ "d",
13204
+ "dx",
13205
+ "dy",
13206
+ "diffuseconstant",
13207
+ "direction",
13208
+ "display",
13209
+ "divisor",
13210
+ "dominant-baseline",
13211
+ "dur",
13212
+ "edgemode",
13213
+ "elevation",
13214
+ "end",
13215
+ "exponent",
13216
+ "fill",
13217
+ "fill-opacity",
13218
+ "fill-rule",
13219
+ "filter",
13220
+ "filterunits",
13221
+ "flood-color",
13222
+ "flood-opacity",
13223
+ "font-family",
13224
+ "font-size",
13225
+ "font-size-adjust",
13226
+ "font-stretch",
13227
+ "font-style",
13228
+ "font-variant",
13229
+ "font-weight",
13230
+ "fx",
13231
+ "fy",
13232
+ "g1",
13233
+ "g2",
13234
+ "glyph-name",
13235
+ "glyphref",
13236
+ "gradientunits",
13237
+ "gradienttransform",
13238
+ "height",
13239
+ "href",
13240
+ "id",
13241
+ "image-rendering",
13242
+ "in",
13243
+ "in2",
13244
+ "intercept",
13245
+ "k",
13246
+ "k1",
13247
+ "k2",
13248
+ "k3",
13249
+ "k4",
13250
+ "kerning",
13251
+ "keypoints",
13252
+ "keysplines",
13253
+ "keytimes",
13254
+ "lang",
13255
+ "lengthadjust",
13256
+ "letter-spacing",
13257
+ "kernelmatrix",
13258
+ "kernelunitlength",
13259
+ "lighting-color",
13260
+ "local",
13261
+ "marker-end",
13262
+ "marker-mid",
13263
+ "marker-start",
13264
+ "markerheight",
13265
+ "markerunits",
13266
+ "markerwidth",
13267
+ "maskcontentunits",
13268
+ "maskunits",
13269
+ "max",
13270
+ "mask",
13271
+ "mask-type",
13272
+ "media",
13273
+ "method",
13274
+ "mode",
13275
+ "min",
13276
+ "name",
13277
+ "numoctaves",
13278
+ "offset",
13279
+ "operator",
13280
+ "opacity",
13281
+ "order",
13282
+ "orient",
13283
+ "orientation",
13284
+ "origin",
13285
+ "overflow",
13286
+ "paint-order",
13287
+ "path",
13288
+ "pathlength",
13289
+ "patterncontentunits",
13290
+ "patterntransform",
13291
+ "patternunits",
13292
+ "pointer-events",
13293
+ "points",
13294
+ "preservealpha",
13295
+ "preserveaspectratio",
13296
+ "primitiveunits",
13297
+ "r",
13298
+ "rx",
13299
+ "ry",
13300
+ "radius",
13301
+ "refx",
13302
+ "refy",
13303
+ "repeatcount",
13304
+ "repeatdur",
13305
+ "restart",
13306
+ "result",
13307
+ "rotate",
13308
+ "scale",
13309
+ "seed",
13310
+ "shape-rendering",
13311
+ "slope",
13312
+ "specularconstant",
13313
+ "specularexponent",
13314
+ "spreadmethod",
13315
+ "startoffset",
13316
+ "stddeviation",
13317
+ "stitchtiles",
13318
+ "stop-color",
13319
+ "stop-opacity",
13320
+ "stroke-dasharray",
13321
+ "stroke-dashoffset",
13322
+ "stroke-linecap",
13323
+ "stroke-linejoin",
13324
+ "stroke-miterlimit",
13325
+ "stroke-opacity",
13326
+ "stroke",
13327
+ "stroke-width",
13328
+ "style",
13329
+ "surfacescale",
13330
+ "systemlanguage",
13331
+ "tabindex",
13332
+ "tablevalues",
13333
+ "targetx",
13334
+ "targety",
13335
+ "transform",
13336
+ "transform-origin",
13337
+ "text-anchor",
13338
+ "text-decoration",
13339
+ "text-orientation",
13340
+ "text-rendering",
13341
+ "textlength",
13342
+ "type",
13343
+ "u1",
13344
+ "u2",
13345
+ "unicode",
13346
+ "values",
13347
+ "vector-effect",
13348
+ "viewbox",
13349
+ "visibility",
13350
+ "version",
13351
+ "vert-adv-y",
13352
+ "vert-origin-x",
13353
+ "vert-origin-y",
13354
+ "width",
13355
+ "word-spacing",
13356
+ "wrap",
13357
+ "writing-mode",
13358
+ "xchannelselector",
13359
+ "ychannelselector",
13360
+ "x",
13361
+ "x1",
13362
+ "x2",
13363
+ "xmlns",
13364
+ "y",
13365
+ "y1",
13366
+ "y2",
13367
+ "z",
13368
+ "zoomandpan"
13369
+ ]);
13370
+ var mathMl = freeze([
13371
+ "accent",
13372
+ "accentunder",
13373
+ "align",
13374
+ "bevelled",
13375
+ "close",
13376
+ "columnalign",
13377
+ "columnlines",
13378
+ "columnspacing",
13379
+ "columnspan",
13380
+ "denomalign",
13381
+ "depth",
13382
+ "dir",
13383
+ "display",
13384
+ "displaystyle",
13385
+ "encoding",
13386
+ "fence",
13387
+ "frame",
13388
+ "height",
13389
+ "href",
13390
+ "id",
13391
+ "largeop",
13392
+ "length",
13393
+ "linethickness",
13394
+ "lquote",
13395
+ "lspace",
13396
+ "mathbackground",
13397
+ "mathcolor",
13398
+ "mathsize",
13399
+ "mathvariant",
13400
+ "maxsize",
13401
+ "minsize",
13402
+ "movablelimits",
13403
+ "notation",
13404
+ "numalign",
13405
+ "open",
13406
+ "rowalign",
13407
+ "rowlines",
13408
+ "rowspacing",
13409
+ "rowspan",
13410
+ "rspace",
13411
+ "rquote",
13412
+ "scriptlevel",
13413
+ "scriptminsize",
13414
+ "scriptsizemultiplier",
13415
+ "selection",
13416
+ "separator",
13417
+ "separators",
13418
+ "stretchy",
13419
+ "subscriptshift",
13420
+ "supscriptshift",
13421
+ "symmetric",
13422
+ "voffset",
13423
+ "width",
13424
+ "xmlns"
13425
+ ]);
13426
+ var xml = freeze([
13427
+ "xlink:href",
13428
+ "xml:id",
13429
+ "xlink:title",
13430
+ "xml:space",
13431
+ "xmlns:xlink"
13432
+ ]);
13433
+ var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
13434
+ var ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
13435
+ var TMPLIT_EXPR = seal(/\${[\w\W]*/g);
13436
+ var DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
13437
+ var ARIA_ATTR = seal(/^aria-[\-\w]+$/);
13438
+ var IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i);
13439
+ var IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
13440
+ var ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g);
13441
+ var DOCTYPE_NAME = seal(/^html$/i);
13442
+ var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
13443
+ var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
13444
+ var COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
13445
+ var FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
13446
+ var SELF_CLOSING_TAG = seal(/\/>/i);
13447
+ var NODE_TYPE = {
13448
+ element: 1,
13449
+ attribute: 2,
13450
+ text: 3,
13451
+ cdataSection: 4,
13452
+ entityReference: 5,
13453
+ entityNode: 6,
13454
+ processingInstruction: 7,
13455
+ comment: 8,
13456
+ document: 9,
13457
+ documentType: 10,
13458
+ documentFragment: 11,
13459
+ notation: 12
13460
+ };
13461
+ var LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, [
13462
+ "style",
13463
+ "script",
13464
+ "xmp",
13465
+ "iframe",
13466
+ "noembed",
13467
+ "noframes",
13468
+ "plaintext",
13469
+ "noscript"
13470
+ ]));
13471
+ var getGlobal = function getGlobal() {
13472
+ return typeof window === "undefined" ? null : window;
13473
+ };
13474
+ /**
13475
+ * Creates a no-op policy for internal use only.
13476
+ * Don't export this function outside this module!
13477
+ * @param trustedTypes The policy factory.
13478
+ * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
13479
+ * @return The policy created (or null, if Trusted Types
13480
+ * are not supported or creating the policy failed).
13481
+ */
13482
+ var _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
13483
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") return null;
13484
+ let suffix = null;
13485
+ const ATTR_NAME = "data-tt-policy-suffix";
13486
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) suffix = purifyHostElement.getAttribute(ATTR_NAME);
13487
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
13488
+ try {
13489
+ return trustedTypes.createPolicy(policyName, {
13490
+ createHTML(html) {
13491
+ return html;
13492
+ },
13493
+ createScriptURL(scriptUrl) {
13494
+ return scriptUrl;
13495
+ }
13496
+ });
13497
+ } catch (_) {
13498
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
13499
+ return null;
13500
+ }
13501
+ };
13502
+ var _createHooksMap = function _createHooksMap() {
13503
+ return {
13504
+ afterSanitizeAttributes: [],
13505
+ afterSanitizeElements: [],
13506
+ afterSanitizeShadowDOM: [],
13507
+ beforeSanitizeAttributes: [],
13508
+ beforeSanitizeElements: [],
13509
+ beforeSanitizeShadowDOM: [],
13510
+ uponSanitizeAttribute: [],
13511
+ uponSanitizeElement: [],
13512
+ uponSanitizeShadowNode: []
13513
+ };
13514
+ };
13515
+ /**
13516
+ * Resolve a set-valued configuration option: a fresh set built from
13517
+ * cfg[key] when it is an own array property (seeded with a clone of
13518
+ * options.base when given, case-normalized via options.transform),
13519
+ * the fallback set otherwise.
13520
+ *
13521
+ * @param cfg the cloned, prototype-free configuration object
13522
+ * @param key the configuration property to read
13523
+ * @param fallback the set to use when the option is absent or not an array
13524
+ * @param options transform and optional base set to merge into
13525
+ * @returns the resolved set
13526
+ */
13527
+ var _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {
13528
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
13529
+ };
13530
+ /**
13531
+ * Resolve an object-valued configuration option: a prototype-free clone
13532
+ * of cfg[key] when it is an own, truthy object property, else a fresh
13533
+ * fallback built by makeFallback (fresh on every parse, so a previous
13534
+ * parse can never leak state into the next one).
13535
+ *
13536
+ * @param cfg the cloned, prototype-free configuration object
13537
+ * @param key the configuration property to read
13538
+ * @param makeFallback builds the fallback value when the option is absent
13539
+ * @returns the resolved object
13540
+ */
13541
+ var _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback) {
13542
+ const value = objectHasOwnProperty(cfg, key) ? cfg[key] : void 0;
13543
+ return value && typeof value === "object" ? clone(value) : makeFallback();
13544
+ };
13545
+ function createDOMPurify() {
13546
+ let window = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
13547
+ const DOMPurify = (root) => createDOMPurify(root);
13548
+ DOMPurify.version = "3.4.17";
13549
+ DOMPurify.removed = [];
13550
+ if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {
13551
+ DOMPurify.isSupported = false;
13552
+ return DOMPurify;
13553
+ }
13554
+ let document = window.document;
13555
+ const originalDocument = document;
13556
+ const currentScript = originalDocument.currentScript;
13557
+ window.DocumentFragment;
13558
+ const HTMLTemplateElement = window.HTMLTemplateElement, Node = window.Node, Element = window.Element, NodeFilter = window.NodeFilter;
13559
+ window.NamedNodeMap === void 0 && (window.NamedNodeMap || window.MozNamedAttrMap);
13560
+ window.HTMLFormElement;
13561
+ const DOMParser = window.DOMParser, trustedTypes = window.trustedTypes;
13562
+ const ElementPrototype = Element.prototype;
13563
+ const cloneNode = lookupGetter(ElementPrototype, "cloneNode");
13564
+ const remove = lookupGetter(ElementPrototype, "remove");
13565
+ const removeAttributeNode = lookupGetter(ElementPrototype, "removeAttributeNode");
13566
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
13567
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
13568
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
13569
+ const getShadowRoot = lookupGetter(ElementPrototype, "shadowRoot");
13570
+ const getAttributes = lookupGetter(ElementPrototype, "attributes");
13571
+ const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeType") : null;
13572
+ const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, "nodeName") : null;
13573
+ const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, "ownerDocument") : null;
13574
+ const _readNodeType = function _readNodeType(node) {
13575
+ return getNodeType ? getNodeType(node) : node.nodeType;
13576
+ };
13577
+ const _readNodeName = function _readNodeName(node) {
13578
+ return getNodeName ? getNodeName(node) : node.nodeName;
13579
+ };
13580
+ const getNamespaceURI = lookupAccessor(ElementPrototype, "namespaceURI");
13581
+ const _readNamespaceURI = function _readNamespaceURI(element) {
13582
+ return getNamespaceURI ? getNamespaceURI(element) : element.namespaceURI;
13583
+ };
13584
+ if (typeof HTMLTemplateElement === "function") {
13585
+ const template = document.createElement("template");
13586
+ if (template.content && template.content.ownerDocument) document = template.content.ownerDocument;
13587
+ }
13588
+ let trustedTypesPolicy;
13589
+ let emptyHTML = "";
13590
+ let defaultTrustedTypesPolicy;
13591
+ let defaultTrustedTypesPolicyResolved = false;
13592
+ let IN_TRUSTED_TYPES_POLICY = 0;
13593
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {
13594
+ 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.");
13595
+ };
13596
+ const _createTrustedHTML = function _createTrustedHTML(html) {
13597
+ _assertNotInTrustedTypesPolicy();
13598
+ IN_TRUSTED_TYPES_POLICY++;
13599
+ try {
13600
+ return trustedTypesPolicy.createHTML(html);
13601
+ } finally {
13602
+ IN_TRUSTED_TYPES_POLICY--;
13603
+ }
13604
+ };
13605
+ const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {
13606
+ _assertNotInTrustedTypesPolicy();
13607
+ IN_TRUSTED_TYPES_POLICY++;
13608
+ try {
13609
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
13610
+ } finally {
13611
+ IN_TRUSTED_TYPES_POLICY--;
13612
+ }
13613
+ };
13614
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {
13615
+ if (!defaultTrustedTypesPolicyResolved) {
13616
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
13617
+ defaultTrustedTypesPolicyResolved = true;
13618
+ }
13619
+ return defaultTrustedTypesPolicy;
13620
+ };
13621
+ const _document = document, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
13622
+ const importNode = originalDocument.importNode;
13623
+ let hooks = _createHooksMap();
13624
+ /**
13625
+ * Expose whether this browser supports running the full DOMPurify.
13626
+ */
13627
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
13628
+ 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;
13629
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
13630
+ /**
13631
+ * We consider the elements and attributes below to be safe. Ideally
13632
+ * don't add any new ones but feel free to remove unwanted ones.
13633
+ */
13634
+ let ALLOWED_TAGS = null;
13635
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [
13636
+ ...html$1,
13637
+ ...svg$1,
13638
+ ...svgFilters,
13639
+ ...mathMl$1,
13640
+ ...text
13641
+ ]);
13642
+ let ALLOWED_ATTR = null;
13643
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [
13644
+ ...html,
13645
+ ...svg,
13646
+ ...mathMl,
13647
+ ...xml
13648
+ ]);
13649
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
13650
+ tagNameCheck: {
13651
+ writable: true,
13652
+ configurable: false,
13653
+ enumerable: true,
13654
+ value: null
13655
+ },
13656
+ attributeNameCheck: {
13657
+ writable: true,
13658
+ configurable: false,
13659
+ enumerable: true,
13660
+ value: null
13661
+ },
13662
+ allowCustomizedBuiltInElements: {
13663
+ writable: true,
13664
+ configurable: false,
13665
+ enumerable: true,
13666
+ value: false
13667
+ }
13668
+ }));
13669
+ let FORBID_TAGS = null;
13670
+ let FORBID_ATTR = null;
13671
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
13672
+ tagCheck: {
13673
+ writable: true,
13674
+ configurable: false,
13675
+ enumerable: true,
13676
+ value: null
13677
+ },
13678
+ attributeCheck: {
13679
+ writable: true,
13680
+ configurable: false,
13681
+ enumerable: true,
13682
+ value: null
13683
+ }
13684
+ }));
13685
+ let ALLOW_ARIA_ATTR = true;
13686
+ let ALLOW_DATA_ATTR = true;
13687
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
13688
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
13689
+ let SAFE_FOR_TEMPLATES = false;
13690
+ let SAFE_FOR_XML = true;
13691
+ let WHOLE_DOCUMENT = false;
13692
+ let SET_CONFIG = false;
13693
+ let SET_CONFIG_ALLOWED_TAGS = null;
13694
+ let SET_CONFIG_ALLOWED_ATTR = null;
13695
+ let FORCE_BODY = false;
13696
+ let RETURN_DOM = false;
13697
+ let RETURN_DOM_FRAGMENT = false;
13698
+ let RETURN_TRUSTED_TYPE = false;
13699
+ let SANITIZE_DOM = true;
13700
+ let SANITIZE_NAMED_PROPS = false;
13701
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
13702
+ let KEEP_CONTENT = true;
13703
+ let IN_PLACE = false;
13704
+ let IN_PLACE_VISITED = null;
13705
+ let USE_PROFILES = {};
13706
+ let FORBID_CONTENTS = null;
13707
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, [
13708
+ "annotation-xml",
13709
+ "audio",
13710
+ "colgroup",
13711
+ "desc",
13712
+ "foreignobject",
13713
+ "head",
13714
+ "iframe",
13715
+ "math",
13716
+ "mi",
13717
+ "mn",
13718
+ "mo",
13719
+ "ms",
13720
+ "mtext",
13721
+ "noembed",
13722
+ "noframes",
13723
+ "noscript",
13724
+ "plaintext",
13725
+ "script",
13726
+ "selectedcontent",
13727
+ "style",
13728
+ "svg",
13729
+ "template",
13730
+ "thead",
13731
+ "title",
13732
+ "video",
13733
+ "xmp"
13734
+ ]);
13735
+ let DATA_URI_TAGS = null;
13736
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, [
13737
+ "audio",
13738
+ "video",
13739
+ "img",
13740
+ "source",
13741
+ "image",
13742
+ "track"
13743
+ ]);
13744
+ let URI_SAFE_ATTRIBUTES = null;
13745
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, [
13746
+ "alt",
13747
+ "class",
13748
+ "for",
13749
+ "id",
13750
+ "label",
13751
+ "name",
13752
+ "pattern",
13753
+ "placeholder",
13754
+ "role",
13755
+ "summary",
13756
+ "title",
13757
+ "value",
13758
+ "style",
13759
+ "xmlns"
13760
+ ]);
13761
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
13762
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
13763
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
13764
+ let NAMESPACE = HTML_NAMESPACE;
13765
+ let IS_EMPTY_INPUT = false;
13766
+ let ALLOWED_NAMESPACES = null;
13767
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [
13768
+ MATHML_NAMESPACE,
13769
+ SVG_NAMESPACE,
13770
+ HTML_NAMESPACE
13771
+ ], stringToString);
13772
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze([
13773
+ "mi",
13774
+ "mo",
13775
+ "mn",
13776
+ "ms",
13777
+ "mtext"
13778
+ ]);
13779
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
13780
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
13781
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
13782
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, [
13783
+ "title",
13784
+ "style",
13785
+ "font",
13786
+ "a",
13787
+ "script"
13788
+ ]);
13789
+ let PARSER_MEDIA_TYPE = null;
13790
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
13791
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
13792
+ let transformCaseFunc = null;
13793
+ let CONFIG = null;
13794
+ const formElement = document.createElement("form");
13795
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
13796
+ return testValue instanceof RegExp || testValue instanceof Function;
13797
+ };
13798
+ /**
13799
+ * _parseConfig
13800
+ *
13801
+ * @param cfg optional config literal
13802
+ */
13803
+ const _parseConfig = function _parseConfig() {
13804
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
13805
+ if (CONFIG && CONFIG === cfg) return;
13806
+ if (!cfg || typeof cfg !== "object") cfg = {};
13807
+ cfg = clone(cfg);
13808
+ PARSER_MEDIA_TYPE = SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
13809
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
13810
+ ALLOWED_TAGS = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, { transform: transformCaseFunc });
13811
+ ALLOWED_ATTR = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, { transform: transformCaseFunc });
13812
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, { transform: stringToString });
13813
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
13814
+ transform: transformCaseFunc,
13815
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
13816
+ });
13817
+ DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
13818
+ transform: transformCaseFunc,
13819
+ base: DEFAULT_DATA_URI_TAGS
13820
+ });
13821
+ FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, { transform: transformCaseFunc });
13822
+ FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), { transform: transformCaseFunc });
13823
+ FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), { transform: transformCaseFunc });
13824
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
13825
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
13826
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
13827
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
13828
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
13829
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
13830
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
13831
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
13832
+ RETURN_DOM = cfg.RETURN_DOM || false;
13833
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
13834
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
13835
+ FORCE_BODY = cfg.FORCE_BODY || false;
13836
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
13837
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
13838
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
13839
+ IN_PLACE = cfg.IN_PLACE || false;
13840
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
13841
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
13842
+ MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, "MATHML_TEXT_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS));
13843
+ HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, "HTML_INTEGRATION_POINTS", () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS));
13844
+ const customElementHandling = _resolveObjectOption(cfg, "CUSTOM_ELEMENT_HANDLING", () => create(null));
13845
+ CUSTOM_ELEMENT_HANDLING = create(null);
13846
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
13847
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
13848
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
13849
+ seal(CUSTOM_ELEMENT_HANDLING);
13850
+ if (SAFE_FOR_TEMPLATES) ALLOW_DATA_ATTR = false;
13851
+ if (RETURN_DOM_FRAGMENT) RETURN_DOM = true;
13852
+ if (USE_PROFILES) {
13853
+ ALLOWED_TAGS = addToSet({}, text);
13854
+ ALLOWED_ATTR = create(null);
13855
+ if (USE_PROFILES.html === true) {
13856
+ addToSet(ALLOWED_TAGS, html$1);
13857
+ addToSet(ALLOWED_ATTR, html);
13858
+ }
13859
+ if (USE_PROFILES.svg === true) {
13860
+ addToSet(ALLOWED_TAGS, svg$1);
13861
+ addToSet(ALLOWED_ATTR, svg);
13862
+ addToSet(ALLOWED_ATTR, xml);
13863
+ }
13864
+ if (USE_PROFILES.svgFilters === true) {
13865
+ addToSet(ALLOWED_TAGS, svgFilters);
13866
+ addToSet(ALLOWED_ATTR, svg);
13867
+ addToSet(ALLOWED_ATTR, xml);
13868
+ }
13869
+ if (USE_PROFILES.mathMl === true) {
13870
+ addToSet(ALLOWED_TAGS, mathMl$1);
13871
+ addToSet(ALLOWED_ATTR, mathMl);
13872
+ addToSet(ALLOWED_ATTR, xml);
13873
+ }
13874
+ }
13875
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
13876
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
13877
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
13878
+ if (typeof cfg.ADD_TAGS === "function") EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
13879
+ else if (arrayIsArray(cfg.ADD_TAGS)) {
13880
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) ALLOWED_TAGS = clone(ALLOWED_TAGS);
13881
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
13882
+ }
13883
+ }
13884
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
13885
+ if (typeof cfg.ADD_ATTR === "function") EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
13886
+ else if (arrayIsArray(cfg.ADD_ATTR)) {
13887
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) ALLOWED_ATTR = clone(ALLOWED_ATTR);
13888
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
13889
+ }
13890
+ }
13891
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
13892
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) FORBID_CONTENTS = clone(FORBID_CONTENTS);
13893
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
13894
+ }
13895
+ if (KEEP_CONTENT) ALLOWED_TAGS["#text"] = true;
13896
+ if (WHOLE_DOCUMENT) addToSet(ALLOWED_TAGS, [
13897
+ "html",
13898
+ "head",
13899
+ "body"
13900
+ ]);
13901
+ if (ALLOWED_TAGS.table) {
13902
+ addToSet(ALLOWED_TAGS, ["tbody"]);
13903
+ delete FORBID_TAGS.tbody;
13904
+ }
13905
+ if (cfg.TRUSTED_TYPES_POLICY) {
13906
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
13907
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") throw typeErrorCreate("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
13908
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
13909
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
13910
+ try {
13911
+ emptyHTML = _createTrustedHTML("");
13912
+ } catch (error) {
13913
+ trustedTypesPolicy = previousTrustedTypesPolicy;
13914
+ throw error;
13915
+ }
13916
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
13917
+ trustedTypesPolicy = void 0;
13918
+ emptyHTML = "";
13919
+ } else {
13920
+ if (trustedTypesPolicy === void 0) trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
13921
+ if (trustedTypesPolicy && typeof emptyHTML === "string") emptyHTML = _createTrustedHTML("");
13922
+ }
13923
+ if (freeze) freeze(cfg);
13924
+ CONFIG = cfg;
13925
+ };
13926
+ const ALL_SVG_TAGS = addToSet({}, [
13927
+ ...svg$1,
13928
+ ...svgFilters,
13929
+ ...svgDisallowed
13930
+ ]);
13931
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
13932
+ /**
13933
+ * Namespace rules for an element in the SVG namespace.
13934
+ *
13935
+ * @param tagName the element's lowercase tag name
13936
+ * @param parent the (possibly simulated) parent node
13937
+ * @param parentTagName the parent's lowercase tag name
13938
+ * @returns true if a spec-compliant parser could produce this element
13939
+ */
13940
+ const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {
13941
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "svg";
13942
+ if (parent.namespaceURI === MATHML_NAMESPACE) return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
13943
+ return Boolean(ALL_SVG_TAGS[tagName]);
13944
+ };
13945
+ /**
13946
+ * Namespace rules for an element in the MathML namespace.
13947
+ *
13948
+ * @param tagName the element's lowercase tag name
13949
+ * @param parent the (possibly simulated) parent node
13950
+ * @param parentTagName the parent's lowercase tag name
13951
+ * @returns true if a spec-compliant parser could produce this element
13952
+ */
13953
+ const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {
13954
+ if (parent.namespaceURI === HTML_NAMESPACE) return tagName === "math";
13955
+ if (parent.namespaceURI === SVG_NAMESPACE) return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
13956
+ return Boolean(ALL_MATHML_TAGS[tagName]);
13957
+ };
13958
+ /**
13959
+ * Namespace rules for an element in the HTML namespace.
13960
+ *
13961
+ * @param tagName the element's lowercase tag name
13962
+ * @param parent the (possibly simulated) parent node
13963
+ * @param parentTagName the parent's lowercase tag name
13964
+ * @returns true if a spec-compliant parser could produce this element
13965
+ */
13966
+ const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {
13967
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) return false;
13968
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) return false;
13969
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
13970
+ };
13971
+ /**
13972
+ * @param element a DOM element whose namespace is being checked
13973
+ * @returns Return false if the element has a
13974
+ * namespace that a spec-compliant parser would never
13975
+ * return. Return true otherwise.
13976
+ */
13977
+ const _checkValidNamespace = function _checkValidNamespace(element) {
13978
+ const elementNamespace = _readNamespaceURI(element);
13979
+ const tagName = stringToLowerCase(_readNodeName(element));
13980
+ const parentNode = getParentNode(element);
13981
+ let parent;
13982
+ let parentTagName;
13983
+ if (parentNode && _readNodeType(parentNode) === NODE_TYPE.element) {
13984
+ parent = { namespaceURI: _readNamespaceURI(parentNode) };
13985
+ parentTagName = stringToLowerCase(_readNodeName(parentNode));
13986
+ } else {
13987
+ parent = { namespaceURI: NAMESPACE };
13988
+ parentTagName = "template";
13989
+ }
13990
+ if (!ALLOWED_NAMESPACES[elementNamespace]) return false;
13991
+ if (elementNamespace === SVG_NAMESPACE) return _checkSvgNamespace(tagName, parent, parentTagName);
13992
+ if (elementNamespace === MATHML_NAMESPACE) return _checkMathMlNamespace(tagName, parent, parentTagName);
13993
+ if (elementNamespace === HTML_NAMESPACE) return _checkHtmlNamespace(tagName, parent, parentTagName);
13994
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[elementNamespace]) return true;
13995
+ return false;
13996
+ };
13997
+ /**
13998
+ * _forceRemove
13999
+ *
14000
+ * @param node a DOM node
14001
+ */
14002
+ const _forceRemove = function _forceRemove(node) {
14003
+ arrayPush(DOMPurify.removed, { element: node });
14004
+ try {
14005
+ getParentNode(node).removeChild(node);
14006
+ } catch (_) {
14007
+ remove(node);
14008
+ 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");
14009
+ }
14010
+ };
14011
+ /**
14012
+ * _stripAttributeNode
14013
+ *
14014
+ * Remove a single Attr node case/namespace-exactly on an attribute-teardown
14015
+ * path. Name-based removeAttribute() ASCII-lowercases its lookup key for an
14016
+ * HTML element in an HTML document and so silently misses a case-preserved
14017
+ * handler (e.g. `ONERROR` off an XML/XHTML import) - the same defect
14018
+ * _removeAttribute() was fixed for, which a name-based call would reintroduce
14019
+ * on these IN_PLACE teardown paths. Unlike _removeAttribute this does not
14020
+ * record into DOMPurify.removed: the neutralize passes intentionally do not
14021
+ * book-keep. A clobbered/detached node falls back to best-effort name-based
14022
+ * removal.
14023
+ *
14024
+ * @param element the element to strip the attribute from
14025
+ * @param attribute the Attr node to remove
14026
+ * @param name the attribute's name, for the fallback path
14027
+ */
14028
+ const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {
14029
+ try {
14030
+ removeAttributeNode(element, attribute);
14031
+ } catch (_) {
14032
+ try {
14033
+ element.removeAttribute(name);
14034
+ } catch (_) {}
14035
+ }
14036
+ };
14037
+ /**
14038
+ * Fail-closed teardown of an in-place root: strip every disallowed attribute
14039
+ * in the subtree first, so nothing armed is left behind, then remove all
14040
+ * children and the root's own attributes.
14041
+ *
14042
+ * @param root the in-place root to empty
14043
+ */
14044
+ const _neutralizeRoot = function _neutralizeRoot(root) {
14045
+ _neutralizeSubtree(root);
14046
+ const childNodes = getChildNodes(root);
14047
+ if (childNodes) arrayForEach(arraySlice(childNodes), (child) => {
14048
+ try {
14049
+ remove(child);
14050
+ } catch (_) {}
14051
+ });
14052
+ const attributes = _readNodeType(root) === NODE_TYPE.element ? getAttributes(root) : null;
14053
+ if (attributes) for (let i = attributes.length - 1; i >= 0; --i) {
14054
+ const attribute = attributes[i];
14055
+ const name = attribute && attribute.name;
14056
+ if (typeof name === "string") _stripAttributeNode(root, attribute, name);
14057
+ }
14058
+ };
14059
+ /**
14060
+ * Removes an attribute, preferably as its exact Attr node: name-based
14061
+ * removal lowercases the name in HTML documents and misses case-preserved
14062
+ * names, e.g. from imported XHTML.
14063
+ *
14064
+ * @param name an Attribute name
14065
+ * @param element a DOM node
14066
+ * @param attr the exact Attr node to remove, when the caller has it
14067
+ */
14068
+ const _removeAttribute = function _removeAttribute(name, element, attr) {
14069
+ if (!attr) try {
14070
+ attr = element.getAttributeNode(name);
14071
+ } catch (_) {
14072
+ attr = null;
14073
+ }
14074
+ arrayPush(DOMPurify.removed, {
14075
+ attribute: attr || null,
14076
+ from: element
14077
+ });
14078
+ try {
14079
+ if (attr) removeAttributeNode(element, attr);
14080
+ else element.removeAttribute(name);
14081
+ } catch (_) {
14082
+ try {
14083
+ element.removeAttribute(name);
14084
+ } catch (_) {}
14085
+ }
14086
+ if (name === "is") {
14087
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) try {
14088
+ _forceRemove(element);
14089
+ } catch (_) {}
14090
+ else try {
14091
+ element.setAttribute(name, "");
14092
+ } catch (_) {}
14093
+ }
14094
+ };
14095
+ /**
14096
+ * Removes every attribute the configuration does not allow. Used to
14097
+ * neutralize nodes discarded from an in-place tree.
14098
+ *
14099
+ * @param element the element to strip
14100
+ */
14101
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {
14102
+ const attributes = getAttributes(element);
14103
+ if (!attributes) return;
14104
+ for (let i = attributes.length - 1; i >= 0; --i) {
14105
+ const attribute = attributes[i];
14106
+ const name = attribute && attribute.name;
14107
+ if (typeof name !== "string" || ALLOWED_ATTR[transformCaseFunc(name)]) continue;
14108
+ _stripAttributeNode(element, attribute, name);
14109
+ }
14110
+ };
14111
+ /**
14112
+ * Iterative depth-first walk, so deep trees cannot overflow the call stack,
14113
+ * reading through the cached getters, so clobbering cannot hide children.
14114
+ * When `visit` returns false, the node's children are skipped. With
14115
+ * `intoShadow`, open shadow roots are walked after their host's children.
14116
+ *
14117
+ * @param root where to start
14118
+ * @param visit called for every node
14119
+ * @param intoShadow whether to enter open shadow roots
14120
+ */
14121
+ const _walkTree = function _walkTree(root, visit) {
14122
+ let intoShadow = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
14123
+ const stack = [root];
14124
+ while (stack.length > 0) {
14125
+ const node = stack.pop();
14126
+ if (visit(node) === false) continue;
14127
+ if (intoShadow && _readNodeType(node) === NODE_TYPE.element) {
14128
+ const shadowRoot = getShadowRoot(node);
14129
+ if (_isDocumentFragment(shadowRoot)) stack.push(shadowRoot);
14130
+ }
14131
+ const childNodes = getChildNodes(node);
14132
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push(childNodes[i]);
14133
+ }
14134
+ };
14135
+ /**
14136
+ * Strips disallowed attributes from every element of a discarded subtree,
14137
+ * so a handler that is already queued (a loading image) cannot fire.
14138
+ *
14139
+ * @param root the root of a removed subtree
14140
+ */
14141
+ const _neutralizeSubtree = function _neutralizeSubtree(root) {
14142
+ _walkTree(root, (node) => {
14143
+ if (_readNodeType(node) === NODE_TYPE.element) _stripDisallowedAttributes(node);
14144
+ });
14145
+ };
14146
+ /**
14147
+ * All nodes under `root`, root first, including open shadow roots. Template
14148
+ * content is not entered, it is inert.
14149
+ *
14150
+ * @param root the in-place root
14151
+ * @return the nodes
14152
+ */
14153
+ const _collectLiveNodes = function _collectLiveNodes(root) {
14154
+ const nodes = [];
14155
+ _walkTree(root, (node) => {
14156
+ nodes.push(node);
14157
+ }, true);
14158
+ return nodes;
14159
+ };
14160
+ /**
14161
+ * Strips disallowed attributes from every element that was under the
14162
+ * in-place root when the call started and no longer is, whatever removed
14163
+ * or moved it.
14164
+ *
14165
+ * @param root the in-place root
14166
+ * @param before the root's nodes, collected before the walk
14167
+ */
14168
+ const _neutralizeEscapedElements = function _neutralizeEscapedElements(root, before) {
14169
+ const reachable = setCreate();
14170
+ arrayForEach(_collectLiveNodes(root), (node) => {
14171
+ if (_readNodeType(node) === NODE_TYPE.element) setAdd(reachable, node);
14172
+ });
14173
+ arrayForEach(before, (node) => {
14174
+ if (_readNodeType(node) === NODE_TYPE.element && !setHas(reachable, node)) _stripDisallowedAttributes(node);
14175
+ });
14176
+ };
14177
+ /**
14178
+ * Neutralizes everything that left the in-place tree during the call: what
14179
+ * DOMPurify removed, and what hooks or custom elements removed or moved out.
14180
+ *
14181
+ * @param root the in-place root
14182
+ * @param before the root's nodes, collected before the walk
14183
+ * @return true if the root itself was removed
14184
+ */
14185
+ const _neutralizeDiscarded = function _neutralizeDiscarded(root, before) {
14186
+ let rootRemoved = false;
14187
+ arrayForEach(DOMPurify.removed, (entry) => {
14188
+ if (entry.element) {
14189
+ rootRemoved = rootRemoved || entry.element === root;
14190
+ _neutralizeSubtree(entry.element);
14191
+ }
14192
+ });
14193
+ _neutralizeEscapedElements(root, before);
14194
+ return rootRemoved;
14195
+ };
14196
+ const MAX_UNVISITED_ROUNDS = 8;
14197
+ /**
14198
+ * The walk only moves forward, so a node moved to a position it already
14199
+ * passed is never visited. Give every original node that is still in the
14200
+ * tree but unvisited the normal treatment, hooks included. Nodes created
14201
+ * during the call are left alone. Fails closed if the tree keeps changing.
14202
+ *
14203
+ * @param root the in-place root
14204
+ * @param before the root's nodes, collected before the walk
14205
+ */
14206
+ const _sanitizeUnvisitedNodes = function _sanitizeUnvisitedNodes(root, before) {
14207
+ const visited = IN_PLACE_VISITED;
14208
+ let original = null;
14209
+ const getOriginal = () => {
14210
+ if (!original) {
14211
+ original = setCreate();
14212
+ arrayForEach(before, (beforeNode) => {
14213
+ setAdd(original, beforeNode);
14214
+ });
14215
+ }
14216
+ return original;
14217
+ };
14218
+ for (let round = 0;; round++) {
14219
+ const live = _collectLiveNodes(root);
14220
+ const containers = [root];
14221
+ let pending = false;
14222
+ arrayForEach(live, (node) => {
14223
+ if (_readNodeType(node) === NODE_TYPE.documentFragment) arrayPush(containers, node);
14224
+ else if (!pending && !setHas(visited, node)) pending = setHas(getOriginal(), node);
14225
+ });
14226
+ if (!pending) return;
14227
+ if (round >= MAX_UNVISITED_ROUNDS) throw typeErrorCreate("the tree kept changing during in-place sanitization; refusing to return it");
14228
+ arrayForEach(containers, (container, index) => {
14229
+ _sanitizeUnvisitedIn(container, index > 0, root, getOriginal());
14230
+ });
14231
+ }
14232
+ };
14233
+ /**
14234
+ * One _sanitizeUnvisitedNodes pass over the root or an open shadow root.
14235
+ *
14236
+ * @param container the root or an open shadow root
14237
+ * @param inShadow whether container is a shadow root
14238
+ * @param root the in-place root
14239
+ * @param original the root's nodes collected before the walk, as a set
14240
+ */
14241
+ const _sanitizeUnvisitedIn = function _sanitizeUnvisitedIn(container, inShadow, root, original) {
14242
+ const iterator = _createNodeIterator(container);
14243
+ let node;
14244
+ while (node = iterator.nextNode()) {
14245
+ if (!setHas(original, node) || setHas(IN_PLACE_VISITED, node)) continue;
14246
+ if (inShadow) _executeHooks(hooks.uponSanitizeShadowNode, node, null);
14247
+ _sanitizeElements(node, root);
14248
+ _sanitizeAttributes(node, root);
14249
+ if (_isDocumentFragment(node.content)) _sanitizeShadowDOM2(node.content);
14250
+ }
14251
+ };
14252
+ /**
14253
+ * Records that _sanitizeElements processed `node`. No-op outside IN_PLACE.
14254
+ *
14255
+ * @param node the node being processed
14256
+ */
14257
+ const _markVisited = function _markVisited(node) {
14258
+ if (IN_PLACE_VISITED) setAdd(IN_PLACE_VISITED, node);
14259
+ };
14260
+ /**
14261
+ * Patch-linkage attributes (declarative partial updates): `patchsrc`
14262
+ * always, `for` everywhere except on <label> and <output>. Gated on
14263
+ * SAFE_FOR_XML. Shared by the IN_PLACE pre-pass and _isValidAttribute.
14264
+ *
14265
+ * @param lcName the transformCaseFunc'd attribute name
14266
+ * @param lcTag the transformCaseFunc'd tag name of the carrying element
14267
+ * @return true if the attribute is patch linkage and must be dropped
14268
+ */
14269
+ const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {
14270
+ if (!SAFE_FOR_XML) return false;
14271
+ if (lcName === "patchsrc") return true;
14272
+ return lcName === "for" && lcTag !== "label" && lcTag !== "output";
14273
+ };
14274
+ /**
14275
+ * IN_PLACE pre-pass: sever all patch linkage before the walk, so no patch
14276
+ * can fire mid-walk into a part of the tree the walker already passed.
14277
+ * Removes range markers (processing instructions, comments with markup)
14278
+ * and strips linkage attributes. It cannot undo a patch that already fired.
14279
+ *
14280
+ * TODO: if the shipped feature can patch through `for` on <label>/<output>,
14281
+ * drop that pair here too (see test/declarative-patch-probe.html).
14282
+ *
14283
+ * @param root the in-place root to sweep
14284
+ */
14285
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {
14286
+ if (!SAFE_FOR_XML) return;
14287
+ _walkTree(root, (node) => {
14288
+ const nodeType = _readNodeType(node);
14289
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
14290
+ try {
14291
+ remove(node);
14292
+ } catch (_) {}
14293
+ return false;
14294
+ }
14295
+ if (nodeType === NODE_TYPE.element) {
14296
+ const element = node;
14297
+ const lcTag = transformCaseFunc(_readNodeName(node));
14298
+ try {
14299
+ if (element.hasAttribute && element.hasAttribute("patchsrc")) element.removeAttribute("patchsrc");
14300
+ if (element.hasAttribute && element.hasAttribute("for") && _isPatchLinkageAttribute("for", lcTag)) element.removeAttribute("for");
14301
+ } catch (_) {}
14302
+ }
14303
+ return true;
14304
+ });
14305
+ };
14306
+ /**
14307
+ * _initDocument
14308
+ *
14309
+ * @param dirty - a string of dirty markup
14310
+ * @return a DOM, filled with the dirty markup
14311
+ */
14312
+ const _initDocument = function _initDocument(dirty) {
14313
+ let doc = null;
14314
+ let leadingWhitespace = null;
14315
+ if (FORCE_BODY) dirty = "<remove></remove>" + dirty;
14316
+ else {
14317
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
14318
+ leadingWhitespace = matches && matches[0];
14319
+ }
14320
+ 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>";
14321
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
14322
+ if (NAMESPACE === HTML_NAMESPACE) try {
14323
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
14324
+ } catch (_) {}
14325
+ if (!doc || !doc.documentElement) {
14326
+ doc = implementation.createDocument(NAMESPACE, "template", null);
14327
+ try {
14328
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
14329
+ } catch (_) {}
14330
+ }
14331
+ const body = doc.body || doc.documentElement;
14332
+ if (dirty && leadingWhitespace) body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
14333
+ if (NAMESPACE === HTML_NAMESPACE) return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
14334
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
14335
+ };
14336
+ /**
14337
+ * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.
14338
+ *
14339
+ * @param root The root element or node to start traversing on.
14340
+ * @return The created NodeIterator
14341
+ */
14342
+ const _createNodeIterator = function _createNodeIterator(root) {
14343
+ const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
14344
+ return createNodeIterator.call(doc || root, root, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);
14345
+ };
14346
+ /**
14347
+ * Replace template expression syntax (mustache, ERB, template
14348
+ * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub
14349
+ * sites. Order matters: mustache, then ERB, then template literal.
14350
+ *
14351
+ * @param value the string to scrub
14352
+ * @returns the scrubbed string
14353
+ */
14354
+ const _stripTemplateExpressions = function _stripTemplateExpressions(value) {
14355
+ value = stringReplace(value, MUSTACHE_EXPR$1, " ");
14356
+ value = stringReplace(value, ERB_EXPR$1, " ");
14357
+ value = stringReplace(value, TMPLIT_EXPR$1, " ");
14358
+ return value;
14359
+ };
14360
+ /**
14361
+ * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the
14362
+ * character data of an element subtree. Used as the final safety net for
14363
+ * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions
14364
+ * which only form after text-node normalization (e.g. fragments split across
14365
+ * stripped elements) cannot survive into a template-evaluating framework.
14366
+ *
14367
+ * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`
14368
+ * in place rather than round-tripping through innerHTML. This preserves
14369
+ * descendant node references (important for IN_PLACE callers), avoids a
14370
+ * serialize/reparse cycle, and reads literal character data — which means
14371
+ * `<%...%>` in text content matches the ERB regex against its real bytes
14372
+ * instead of the HTML-entity-escaped form innerHTML would produce.
14373
+ *
14374
+ * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for
14375
+ * attributes is performed during the per-node `_sanitizeAttributes` pass.
14376
+ *
14377
+ * @param node The root element whose character data should be scrubbed.
14378
+ */
14379
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
14380
+ var _node$querySelectorAl;
14381
+ _scrubOwnCharacterData(node);
14382
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
14383
+ if (templates) arrayForEach(templates, (tmpl) => {
14384
+ if (_isDocumentFragment(tmpl.content)) _scrubTemplateExpressions2(tmpl.content);
14385
+ });
14386
+ };
14387
+ /**
14388
+ * _scrubOwnCharacterData
14389
+ *
14390
+ * Non-recursive core of _scrubTemplateExpressions: normalize `node` and
14391
+ * strip template expressions from its own character data only. Does not
14392
+ * enter <template>.content or attached shadow roots (NodeIterator never
14393
+ * does). Used by _sanitizeShadowDOM, where every nested template content
14394
+ * and shadow root is already walked - and therefore scrubbed - by its own
14395
+ * recursive _sanitizeShadowDOM call; recursing here as well would rescrub
14396
+ * each nested fragment once per ancestor, which is quadratic in nesting
14397
+ * depth.
14398
+ *
14399
+ * @param node The root whose own character data should be scrubbed.
14400
+ */
14401
+ const _scrubOwnCharacterData = function _scrubOwnCharacterData(node) {
14402
+ node.normalize();
14403
+ const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
14404
+ const walker = createNodeIterator.call(doc || node, node, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);
14405
+ let currentNode = walker.nextNode();
14406
+ while (currentNode) {
14407
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
14408
+ currentNode = walker.nextNode();
14409
+ }
14410
+ };
14411
+ /**
14412
+ * _isClobbered
14413
+ *
14414
+ * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML
14415
+ * interface with [LegacyOverrideBuiltIns]; a descendant element with a
14416
+ * `name` attribute matching a prototype property shadows that property
14417
+ * on direct reads. We use this check at the IN_PLACE entry-point and
14418
+ * during attribute sanitization to refuse clobbered forms.
14419
+ *
14420
+ * @param element element to check for clobbering attacks
14421
+ * @return true if clobbered, false if safe
14422
+ */
14423
+ const _isClobbered = function _isClobbered(element) {
14424
+ const realTagName = getNodeName ? getNodeName(element) : null;
14425
+ if (typeof realTagName !== "string") return false;
14426
+ if (transformCaseFunc(realTagName) !== "form") return false;
14427
+ 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);
14428
+ };
14429
+ /**
14430
+ * Checks whether the given value is a DocumentFragment from any realm.
14431
+ *
14432
+ * The realm-independent replacement reads `nodeType` through the cached
14433
+ * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE
14434
+ * constant (11). nodeType is a numeric value resolved from the node's
14435
+ * internal slot, identical across realms for the same kind of node.
14436
+ *
14437
+ * @param value object to check
14438
+ * @return true if value is a DocumentFragment-shaped node from any realm
14439
+ */
14440
+ const _isDocumentFragment = function _isDocumentFragment(value) {
14441
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
14442
+ try {
14443
+ return getNodeType(value) === NODE_TYPE.documentFragment;
14444
+ } catch (_) {
14445
+ return false;
14446
+ }
14447
+ };
14448
+ /**
14449
+ * Checks whether the given object is a DOM node, including nodes that
14450
+ * originate from a different window/realm (e.g. an iframe's
14451
+ * contentDocument). The previous `value instanceof Node` check was
14452
+ * realm-bound: nodes from a different window failed it, causing
14453
+ * sanitize() to silently stringify them and reset IN_PLACE to false,
14454
+ * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.
14455
+ *
14456
+ * @param value object to check whether it's a DOM node
14457
+ * @return true if value is a DOM node from any realm
14458
+ */
14459
+ const _isNode = function _isNode(value) {
14460
+ if (!getNodeType || typeof value !== "object" || value === null) return false;
14461
+ try {
14462
+ return typeof getNodeType(value) === "number";
14463
+ } catch (_) {
14464
+ return false;
14465
+ }
14466
+ };
14467
+ function _executeHooks(hooks, currentNode, data) {
14468
+ if (hooks.length === 0) return;
14469
+ arrayForEach(hooks, (hook) => {
14470
+ hook.call(DOMPurify, currentNode, data, CONFIG);
14471
+ });
14472
+ }
14473
+ /**
14474
+ * Structural-threat checks that condemn a node regardless of the
14475
+ * allowlists: mXSS via namespace confusion, risky CSS construction,
14476
+ * processing instructions, markup-bearing comments. Pure predicate;
14477
+ * the caller removes. Check order is load-bearing.
14478
+ *
14479
+ * @param currentNode the node to inspect
14480
+ * @param tagName the node's transformCaseFunc'd tag name
14481
+ * @return true if the node must be removed
14482
+ */
14483
+ const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {
14484
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) return true;
14485
+ 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;
14486
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) return true;
14487
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) return true;
14488
+ return false;
14489
+ };
14490
+ /**
14491
+ * Evaluate a CUSTOM_ELEMENT_HANDLING check (a RegExp or a predicate
14492
+ * function, per the validation in _parseConfig) against a name.
14493
+ * Additional arguments are forwarded to predicate functions - the
14494
+ * attributeNameCheck predicate receives the tag name as its second
14495
+ * argument. A null/absent check never matches.
14496
+ *
14497
+ * @param check the configured tagNameCheck / attributeNameCheck value
14498
+ * @param name the name to test
14499
+ * @param args extra arguments forwarded to a predicate function
14500
+ * @return true if the check matches the name
14501
+ */
14502
+ const _matchesNameCheck = function _matchesNameCheck(check, name) {
14503
+ if (check instanceof RegExp) return regExpTest(check, name);
14504
+ if (check instanceof Function) {
14505
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) args[_key - 2] = arguments[_key];
14506
+ return Boolean(check(name, ...args));
14507
+ }
14508
+ return false;
14509
+ };
14510
+ /**
14511
+ * Handle a node whose tag is forbidden or not allowlisted: keep
14512
+ * allowed custom elements (false return exits _sanitizeElements
14513
+ * early - the namespace and fallback-tag removal checks are
14514
+ * intentionally skipped for kept custom elements), else hoist
14515
+ * content per KEEP_CONTENT and remove.
14516
+ *
14517
+ * A kept custom element is the ONLY case in which this function
14518
+ * returns false, so the caller uses that return value to run the
14519
+ * afterSanitizeElements hook on the kept element and keep the
14520
+ * element-hook lifecycle consistent with normal allowlisted
14521
+ * elements (GHSA-c2j3-45gr-mqc4).
14522
+ *
14523
+ * @param currentNode the disallowed node
14524
+ * @param tagName the node's transformCaseFunc'd tag name
14525
+ * @return true if the node was removed, false if kept
14526
+ */
14527
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {
14528
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
14529
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName] && !FORBID_CONTENTS[stringToLowerCase(tagName)]) {
14530
+ const parentNode = getParentNode(currentNode);
14531
+ const childNodes = getChildNodes(currentNode);
14532
+ if (childNodes && parentNode) {
14533
+ const childCount = childNodes.length;
14534
+ for (let i = childCount - 1; i >= 0; --i) {
14535
+ const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
14536
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
14537
+ }
14538
+ }
14539
+ }
14540
+ _forceRemove(currentNode);
14541
+ return true;
14542
+ };
14543
+ /**
14544
+ * Fork a hook-mutable allowlist off its shared binding the first time a
14545
+ * (possibly lazily-installed) uponSanitize* hook is about to see it, so the
14546
+ * hook cannot widen the per-instance default or the setConfig binding by
14547
+ * reference and leak past the call. Returns the set unchanged once it is
14548
+ * already call-local, so repeated calls across elements are idempotent.
14549
+ *
14550
+ * @param hookList the uponSanitize* hook array for this event
14551
+ * @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding
14552
+ * @param defaultSet the per-instance DEFAULT_ALLOWED_* constant
14553
+ * @param setConfigSet the captured setConfig() binding, or null
14554
+ * @return a call-local clone if a hook is present and set is still shared,
14555
+ * else set unchanged
14556
+ */
14557
+ const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {
14558
+ if (hookList.length === 0) return set;
14559
+ return set === defaultSet || set === setConfigSet ? clone(set) : set;
14560
+ };
14561
+ /**
14562
+ * A hook may have detached the node it was called for. If so, treat it as
14563
+ * removed and stop processing it; the walk root is exempt. On the IN_PLACE
14564
+ * path the detached subtree is neutralized right away.
14565
+ *
14566
+ * @param currentNode the node a hook may have detached
14567
+ * @param root the current walk root
14568
+ * @return true if the node was detached
14569
+ */
14570
+ const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {
14571
+ if (currentNode === root || getParentNode(currentNode) !== null) return false;
14572
+ if (IN_PLACE) _neutralizeSubtree(currentNode);
14573
+ return true;
14574
+ };
14575
+ /**
14576
+ * _sanitizeElements
14577
+ *
14578
+ * @protect nodeName
14579
+ * @protect textContent
14580
+ * @protect removeChild
14581
+ * @param currentNode to check for permission to exist
14582
+ * @return true if node was killed, false if left alive
14583
+ */
14584
+ const _sanitizeElements = function _sanitizeElements(currentNode, root) {
14585
+ _markVisited(currentNode);
14586
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
14587
+ if (_handleHookDetachedNode(currentNode, root)) return true;
14588
+ if (_isClobbered(currentNode)) {
14589
+ _forceRemove(currentNode);
14590
+ return true;
14591
+ }
14592
+ const tagName = transformCaseFunc(_readNodeName(currentNode));
14593
+ ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
14594
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
14595
+ tagName,
14596
+ allowedTags: ALLOWED_TAGS
14597
+ });
14598
+ if (_handleHookDetachedNode(currentNode, root)) return true;
14599
+ if (_isUnsafeNode(currentNode, tagName)) {
14600
+ _forceRemove(currentNode);
14601
+ return true;
14602
+ }
14603
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
14604
+ const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
14605
+ if (removed === false) {
14606
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
14607
+ if (_handleHookDetachedNode(currentNode, root)) return true;
14608
+ }
14609
+ return removed;
14610
+ }
14611
+ if (_readNodeType(currentNode) === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
14612
+ _forceRemove(currentNode);
14613
+ return true;
14614
+ }
14615
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
14616
+ _forceRemove(currentNode);
14617
+ return true;
14618
+ }
14619
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
14620
+ const content = _stripTemplateExpressions(currentNode.textContent);
14621
+ if (currentNode.textContent !== content) {
14622
+ arrayPush(DOMPurify.removed, { element: currentNode.cloneNode() });
14623
+ currentNode.textContent = content;
14624
+ }
14625
+ }
14626
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
14627
+ return _handleHookDetachedNode(currentNode, root);
14628
+ };
14629
+ /**
14630
+ * _isValidAttribute
14631
+ *
14632
+ * @param lcTag Lowercase tag name of containing element.
14633
+ * @param lcName Lowercase attribute name.
14634
+ * @param value Attribute value.
14635
+ * @return Returns true if `value` is valid, otherwise false.
14636
+ */
14637
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
14638
+ if (FORBID_ATTR[lcName]) return false;
14639
+ if (_isPatchLinkageAttribute(lcName, lcTag)) return false;
14640
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document || value in formElement)) return false;
14641
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
14642
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) return true;
14643
+ if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) return true;
14644
+ 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);
14645
+ if (URI_SAFE_ATTRIBUTES[lcName]) return true;
14646
+ if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
14647
+ if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) return true;
14648
+ if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) return true;
14649
+ return !value;
14650
+ };
14651
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, [
14652
+ "annotation-xml",
14653
+ "color-profile",
14654
+ "font-face",
14655
+ "font-face-format",
14656
+ "font-face-name",
14657
+ "font-face-src",
14658
+ "font-face-uri",
14659
+ "missing-glyph"
14660
+ ]);
14661
+ /**
14662
+ * _isBasicCustomElement
14663
+ * checks if at least one dash is included in tagName, and it's not the first char
14664
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
14665
+ *
14666
+ * @param tagName name of the tag of the node to sanitize
14667
+ * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.
14668
+ */
14669
+ const _isBasicCustomElement = function _isBasicCustomElement(tagName) {
14670
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
14671
+ };
14672
+ /**
14673
+ * Wrap an attribute value in the matching Trusted Types object when
14674
+ * the active policy requires it. Namespaced attributes pass through
14675
+ * unchanged (no TT support yet, see
14676
+ * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).
14677
+ *
14678
+ * @param lcTag lowercase tag name of the containing element
14679
+ * @param lcName lowercase attribute name
14680
+ * @param namespaceURI the attribute's namespace, if any
14681
+ * @param value the attribute value to wrap
14682
+ * @return the value, wrapped when Trusted Types demand it
14683
+ */
14684
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {
14685
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) switch (trustedTypes.getAttributeType(lcTag, lcName)) {
14686
+ case "TrustedHTML": return _createTrustedHTML(value);
14687
+ case "TrustedScriptURL": return _createTrustedScriptURL(value);
14688
+ }
14689
+ return value;
14690
+ };
14691
+ /**
14692
+ * Write a modified attribute value back onto the element. On
14693
+ * success, re-probe for clobbering introduced by the new value and
14694
+ * remove the element when found; otherwise, when this writeback is the
14695
+ * recreate half of the SANITIZE_NAMED_PROPS remove-and-recreate, pop the
14696
+ * removal entry that path recorded so it does not show as removed. On
14697
+ * failure, remove the attribute instead.
14698
+ *
14699
+ * Returns true only on a clean write (the value was set and the new value
14700
+ * introduced no clobbering). The caller uses that, together with its own
14701
+ * knowledge of whether this attribute pushed a DOMPurify.removed record, to
14702
+ * decide whether to pop that record. The pop must happen ONLY for the
14703
+ * named-prop remove-and-recreate; popping on any other value change (trim,
14704
+ * template scrubbing, Trusted Types) would consume an unrelated _forceRemove
14705
+ * subtree-cleanup record and let that detached subtree keep a live event
14706
+ * handler through the IN_PLACE neutralization pass (SO-001).
14707
+ *
14708
+ * @param currentNode the element carrying the attribute
14709
+ * @param name the attribute name as present on the element
14710
+ * @param namespaceURI the attribute's namespace, if any
14711
+ * @param value the new attribute value
14712
+ * @return true if the value was written without introducing clobbering
14713
+ */
14714
+ const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {
14715
+ try {
14716
+ if (namespaceURI) currentNode.setAttributeNS(namespaceURI, name, value);
14717
+ else currentNode.setAttribute(name, value);
14718
+ if (_isClobbered(currentNode)) {
14719
+ _forceRemove(currentNode);
14720
+ return false;
14721
+ }
14722
+ return true;
14723
+ } catch (_) {
14724
+ _removeAttribute(name, currentNode);
14725
+ return false;
14726
+ }
14727
+ };
14728
+ /**
14729
+ * _isUnsafeAttributeValue
14730
+ *
14731
+ * Value-based attribute checks that the attribute walk applies before any
14732
+ * hook can force-keep an attribute, shared with the public
14733
+ * isValidAttribute() so that it never approves a value sanitize() would
14734
+ * strip.
14735
+ *
14736
+ * @param name the attribute name as found on the node (case preserved)
14737
+ * @param value the attribute value
14738
+ * @returns true if the attribute must be removed because of its value
14739
+ */
14740
+ const _isUnsafeAttributeValue = function _isUnsafeAttributeValue(name, value) {
14741
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) return true;
14742
+ return stringToLowerCase(name) === "attributename" && stringMatch(value, "href") !== null;
14743
+ };
14744
+ /**
14745
+ * _sanitizeAttributes
14746
+ *
14747
+ * @protect attributes
14748
+ * @protect nodeName
14749
+ * @protect removeAttribute
14750
+ * @protect setAttribute
14751
+ *
14752
+ * @param currentNode to sanitize
14753
+ * @param root the current walk root
14754
+ */
14755
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode, root) {
14756
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
14757
+ if (_handleHookDetachedNode(currentNode, root)) return;
14758
+ const attributes = currentNode.attributes;
14759
+ if (!attributes || _isClobbered(currentNode)) return;
14760
+ ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
14761
+ const hookEvent = {
14762
+ attrName: "",
14763
+ attrValue: "",
14764
+ keepAttr: true,
14765
+ allowedAttributes: ALLOWED_ATTR,
14766
+ forceKeepAttr: void 0
14767
+ };
14768
+ let l = attributes.length;
14769
+ const lcTag = transformCaseFunc(currentNode.nodeName);
14770
+ while (l--) {
14771
+ const attr = attributes[l];
14772
+ const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
14773
+ const lcName = transformCaseFunc(name);
14774
+ const initValue = attrValue;
14775
+ let value = name === "value" ? initValue : stringTrim(initValue);
14776
+ let recreatedNamedProp = false;
14777
+ hookEvent.attrName = lcName;
14778
+ hookEvent.attrValue = value;
14779
+ hookEvent.keepAttr = true;
14780
+ hookEvent.forceKeepAttr = void 0;
14781
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
14782
+ value = hookEvent.attrValue;
14783
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
14784
+ _removeAttribute(name, currentNode, attr);
14785
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
14786
+ recreatedNamedProp = true;
14787
+ }
14788
+ if (_isUnsafeAttributeValue(name, value)) {
14789
+ _removeAttribute(name, currentNode, attr);
14790
+ continue;
14791
+ }
14792
+ if (hookEvent.forceKeepAttr) continue;
14793
+ if (!hookEvent.keepAttr) {
14794
+ _removeAttribute(name, currentNode, attr);
14795
+ continue;
14796
+ }
14797
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
14798
+ _removeAttribute(name, currentNode, attr);
14799
+ continue;
14800
+ }
14801
+ if (SAFE_FOR_TEMPLATES) value = _stripTemplateExpressions(value);
14802
+ if (!_isValidAttribute(lcTag, lcName, value)) {
14803
+ _removeAttribute(name, currentNode, attr);
14804
+ continue;
14805
+ }
14806
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
14807
+ if (value !== initValue) {
14808
+ if (_setAttributeValue(currentNode, name, namespaceURI, value) && recreatedNamedProp) arrayPop(DOMPurify.removed);
14809
+ }
14810
+ }
14811
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
14812
+ _handleHookDetachedNode(currentNode, root);
14813
+ };
14814
+ /**
14815
+ * _sanitizeShadowDOM
14816
+ *
14817
+ * @param fragment to iterate over recursively
14818
+ */
14819
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
14820
+ let shadowNode = null;
14821
+ const shadowIterator = _createNodeIterator(fragment);
14822
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
14823
+ while (shadowNode = shadowIterator.nextNode()) {
14824
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
14825
+ _sanitizeElements(shadowNode, fragment);
14826
+ _sanitizeAttributes(shadowNode, fragment);
14827
+ if (_isDocumentFragment(shadowNode.content)) _sanitizeShadowDOM2(shadowNode.content);
14828
+ if (_readNodeType(shadowNode) === NODE_TYPE.element) {
14829
+ const innerSr = getShadowRoot(shadowNode);
14830
+ if (_isDocumentFragment(innerSr)) {
14831
+ _sanitizeAttachedShadowRoots(innerSr);
14832
+ _sanitizeShadowDOM2(innerSr);
14833
+ }
14834
+ }
14835
+ }
14836
+ if (SAFE_FOR_TEMPLATES) _scrubOwnCharacterData(fragment);
14837
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
14838
+ };
14839
+ /**
14840
+ * Sanitizes every attached shadow root under `root`, since the node
14841
+ * iterator does not enter shadow trees. Needed for IN_PLACE input and for
14842
+ * DOM input whose clonable shadow roots were copied by importNode().
14843
+ *
14844
+ * @param root the subtree root to walk for attached shadow roots
14845
+ */
14846
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {
14847
+ const stack = [{
14848
+ node: root,
14849
+ shadow: null
14850
+ }];
14851
+ while (stack.length > 0) {
14852
+ const item = stack.pop();
14853
+ if (item.shadow) {
14854
+ _sanitizeShadowDOM2(item.shadow);
14855
+ continue;
14856
+ }
14857
+ const node = item.node;
14858
+ const isElement = _readNodeType(node) === NODE_TYPE.element;
14859
+ const childNodes = getChildNodes(node);
14860
+ if (childNodes) for (let i = childNodes.length - 1; i >= 0; --i) stack.push({
14861
+ node: childNodes[i],
14862
+ shadow: null
14863
+ });
14864
+ if (isElement) {
14865
+ const rootName = getNodeName ? getNodeName(node) : null;
14866
+ if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
14867
+ const content = node.content;
14868
+ if (_isDocumentFragment(content)) stack.push({
14869
+ node: content,
14870
+ shadow: null
14871
+ });
14872
+ }
14873
+ }
14874
+ if (isElement) {
14875
+ const sr = getShadowRoot(node);
14876
+ if (_isDocumentFragment(sr)) stack.push({
14877
+ node: null,
14878
+ shadow: sr
14879
+ }, {
14880
+ node: sr,
14881
+ shadow: null
14882
+ });
14883
+ }
14884
+ }
14885
+ };
14886
+ DOMPurify.sanitize = function(dirty) {
14887
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
14888
+ let body = null;
14889
+ let importedNode = null;
14890
+ let currentNode = null;
14891
+ let returnNode = null;
14892
+ IS_EMPTY_INPUT = !dirty;
14893
+ if (IS_EMPTY_INPUT) dirty = "<!-->";
14894
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
14895
+ dirty = stringifyValue(dirty);
14896
+ if (typeof dirty !== "string") throw typeErrorCreate("dirty is not a string, aborting");
14897
+ }
14898
+ if (!DOMPurify.isSupported) return dirty;
14899
+ if (SET_CONFIG) {
14900
+ ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;
14901
+ ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;
14902
+ } else _parseConfig(cfg);
14903
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) ALLOWED_TAGS = clone(ALLOWED_TAGS);
14904
+ if (hooks.uponSanitizeAttribute.length > 0) ALLOWED_ATTR = clone(ALLOWED_ATTR);
14905
+ DOMPurify.removed = [];
14906
+ const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
14907
+ let inPlaceNodes = [];
14908
+ const outerVisited = IN_PLACE_VISITED;
14909
+ if (inPlace) {
14910
+ _neutralizePatchLinkage(dirty);
14911
+ const nn = _readNodeName(dirty);
14912
+ if (typeof nn === "string") {
14913
+ const tagName = transformCaseFunc(nn);
14914
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
14915
+ _neutralizeRoot(dirty);
14916
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
14917
+ }
14918
+ }
14919
+ if (_isClobbered(dirty)) {
14920
+ _neutralizeRoot(dirty);
14921
+ throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
14922
+ }
14923
+ inPlaceNodes = _collectLiveNodes(dirty);
14924
+ IN_PLACE_VISITED = setCreate();
14925
+ } else if (_isNode(dirty)) {
14926
+ body = _initDocument("<!---->");
14927
+ importedNode = body.ownerDocument.importNode(dirty, true);
14928
+ if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === "BODY") body = importedNode;
14929
+ else if (importedNode.nodeName === "HTML") body = importedNode;
14930
+ else body.appendChild(importedNode);
14931
+ _sanitizeAttachedShadowRoots(body);
14932
+ } else {
14933
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && dirty.indexOf("<") === -1) return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
14934
+ body = _initDocument(dirty);
14935
+ if (!body) return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
14936
+ }
14937
+ if (body && FORCE_BODY) _forceRemove(body.firstChild);
14938
+ const walkRoot = inPlace ? dirty : body;
14939
+ try {
14940
+ if (inPlace) _sanitizeAttachedShadowRoots(dirty);
14941
+ const nodeIterator = _createNodeIterator(walkRoot);
14942
+ while (currentNode = nodeIterator.nextNode()) {
14943
+ _sanitizeElements(currentNode, walkRoot);
14944
+ _sanitizeAttributes(currentNode, walkRoot);
14945
+ if (_isDocumentFragment(currentNode.content)) _sanitizeShadowDOM2(currentNode.content);
14946
+ }
14947
+ if (inPlace) _sanitizeUnvisitedNodes(dirty, inPlaceNodes);
14948
+ } catch (error) {
14949
+ if (inPlace) {
14950
+ _neutralizeRoot(dirty);
14951
+ _neutralizeDiscarded(dirty, inPlaceNodes);
14952
+ }
14953
+ throw error;
14954
+ } finally {
14955
+ IN_PLACE_VISITED = outerVisited;
14956
+ }
14957
+ if (inPlace) {
14958
+ if (_neutralizeDiscarded(dirty, inPlaceNodes)) throw typeErrorCreate("a node selected for removal could not be safely returned; refusing to sanitize in place");
14959
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(dirty);
14960
+ return dirty;
14961
+ }
14962
+ if (RETURN_DOM) {
14963
+ if (SAFE_FOR_TEMPLATES) _scrubTemplateExpressions2(body);
14964
+ if (RETURN_DOM_FRAGMENT) {
14965
+ returnNode = createDocumentFragment.call(body.ownerDocument);
14966
+ while (body.firstChild) returnNode.appendChild(body.firstChild);
14967
+ } else returnNode = body;
14968
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) returnNode = importNode.call(originalDocument, returnNode, true);
14969
+ return returnNode;
14970
+ }
14971
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
14972
+ 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;
14973
+ if (SAFE_FOR_TEMPLATES) serializedHTML = _stripTemplateExpressions(serializedHTML);
14974
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
14975
+ };
14976
+ DOMPurify.setConfig = function() {
14977
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
14978
+ _parseConfig(cfg);
14979
+ SET_CONFIG = true;
14980
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;
14981
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;
14982
+ };
14983
+ DOMPurify.clearConfig = function() {
14984
+ CONFIG = null;
14985
+ SET_CONFIG = false;
14986
+ SET_CONFIG_ALLOWED_TAGS = null;
14987
+ SET_CONFIG_ALLOWED_ATTR = null;
14988
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
14989
+ emptyHTML = "";
14990
+ };
14991
+ DOMPurify.isValidAttribute = function(tag, attr, value) {
14992
+ if (!CONFIG) _parseConfig({});
14993
+ const lcTag = transformCaseFunc(tag);
14994
+ const lcName = transformCaseFunc(attr);
14995
+ if (typeof value === "string" && (_isUnsafeAttributeValue(attr, value) || !ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value))) return false;
14996
+ return _isValidAttribute(lcTag, lcName, value);
14997
+ };
14998
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
14999
+ if (typeof hookFunction !== "function") return;
15000
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
15001
+ arrayPush(hooks[entryPoint], hookFunction);
15002
+ };
15003
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
15004
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
15005
+ if (hookFunction !== void 0) {
15006
+ const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
15007
+ return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
15008
+ }
15009
+ return arrayPop(hooks[entryPoint]);
15010
+ };
15011
+ DOMPurify.removeHooks = function(entryPoint) {
15012
+ if (!objectHasOwnProperty(hooks, entryPoint)) return;
15013
+ hooks[entryPoint] = [];
15014
+ };
15015
+ DOMPurify.removeAllHooks = function() {
15016
+ hooks = _createHooksMap();
15017
+ };
15018
+ return DOMPurify;
15019
+ }
15020
+ var purify_default = createDOMPurify();
15021
+ //#endregion
15022
+ //#region src/sanitize.js
15023
+ /**
15024
+ * HTML sanitising for config-supplied markup.
15025
+ *
15026
+ * TableFilter lets consumers inject markup through config
15027
+ * (`btn_reset.html`, `loader.html`, status messages, …); see
15028
+ * ROADMAP/content-projection-parity.md. That config is integrator-authored
15029
+ * and trusted, but rendering it with `innerHTML` is still an XSS sink waiting
15030
+ * for an accidental untrusted value. Every such injection goes through
15031
+ * `sanitizeHtml()` so the trust boundary is explicit and enforced once.
15032
+ *
15033
+ * DOMPurify is the established sanitiser for this. Its default profile keeps
15034
+ * ordinary markup — `<b>`, `<i>`, `<a>`, `<span>`, `<br>`, `class`, … — and
15035
+ * strips scripts, event-handler attributes and `javascript:` URLs. Config
15036
+ * that relied on those was never doing anything safe, so dropping them is
15037
+ * intended.
15038
+ */
15039
+ /**
15040
+ * Sanitise an HTML string for injection with `innerHTML`.
15041
+ * @param {*} html Markup
15042
+ * @returns {String} Sanitised markup
15043
+ */
15044
+ var sanitizeHtml = (html) => purify_default.sanitize(html == null ? "" : String(html));
15045
+ //#endregion
12483
15046
  //#region src/modules/help.js
15047
+ var DEFAULT_INSTR_HTML = "Use the filters above each column to filter and limit table data. Advanced searches can be performed by using the following operators: <br /><b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>=</b>, <b>*</b>, <b>!</b>, <b>{</b>, <b>}</b>, <b>||</b>,<b>&amp;&amp;</b>, <b>[empty]</b>, <b>[nonempty]</b>, <b>rgx:</b><br/><a href=\"https://github.com/koalyptus/TableFilter/wiki/4.-Filter-operators\" target=\"_blank\">Learn more</a><hr/>";
15048
+ var FOCUSABLE_TRIGGER = "button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])";
12484
15049
  /**
12485
15050
  * Help UI component
12486
15051
  */
@@ -12503,10 +15068,10 @@ var Help = class Help extends Feature {
12503
15068
  */
12504
15069
  this.contTgtId = defaultsStr(f.container_target_id, null);
12505
15070
  /**
12506
- * Instructions text (accepts HTML)
15071
+ * Instructions text, rendered with textContent
12507
15072
  * @type {String}
12508
15073
  */
12509
- this.instrText = !isEmpty(f.text) ? f.text : "Use the filters above each column to filter and limit table data. Advanced searches can be performed by using the following operators: <br /><b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>=</b>, <b>*</b>, <b>!</b>, <b>{</b>, <b>}</b>, <b>||</b>,<b>&amp;&amp;</b>, <b>[empty]</b>, <b>[nonempty]</b>, <b>rgx:</b><br/><a href=\"https://github.com/koalyptus/TableFilter/wiki/4.-Filter-operators\" target=\"_blank\">Learn more</a><hr/>";
15074
+ this.instrText = !isEmpty(f.text) ? f.text : null;
12510
15075
  /**
12511
15076
  * Instructions HTML
12512
15077
  * @type {String}
@@ -12523,6 +15088,11 @@ var Help = class Help extends Feature {
12523
15088
  */
12524
15089
  this.btnHtml = defaultsStr(f.btn_html, null);
12525
15090
  /**
15091
+ * Accessible name for the help button
15092
+ * @type {String}
15093
+ */
15094
+ this.label = defaultsStr(f.label, null);
15095
+ /**
12526
15096
  * Css class for help button
12527
15097
  * @type {String}
12528
15098
  */
@@ -12543,6 +15113,12 @@ var Help = class Help extends Feature {
12543
15113
  */
12544
15114
  this.cont = null;
12545
15115
  /**
15116
+ * `<tf-help>` host element
15117
+ * @type {DOMElement}
15118
+ * @private
15119
+ */
15120
+ this.el = null;
15121
+ /**
12546
15122
  * Adjust container left position when table's horizontal scroll is
12547
15123
  * on, typically when `responsive` option is enabled.
12548
15124
  * @type {Number}
@@ -12550,15 +15126,16 @@ var Help = class Help extends Feature {
12550
15126
  */
12551
15127
  this.contAdjustLeftPosition = defaultsNb(f.container_adjust_left_position, 25);
12552
15128
  /**
12553
- * Bound mouseup wrapper
15129
+ * Whether `container_adjust_left_position` is explicitly configured
15130
+ * @type {Boolean}
12554
15131
  * @private
12555
15132
  */
12556
- this.boundMouseup = null;
15133
+ this.hasContAdjustLeftPosition = f.container_adjust_left_position != null;
12557
15134
  /**
12558
- * Default HTML appended to instructions text
12559
- * @type {String}
15135
+ * Bound mouseup wrapper
15136
+ * @private
12560
15137
  */
12561
- this.defaultHtml = "<div class=\"helpFooter\"><h4>TableFilter v" + tf.version + "</h4><a href=\"https://www.tablefilter.com/\" target=\"_blank\">https://www.tablefilter.com/</a><br/><span>&copy;2015-" + tf.year + " Max Guglielmi</span><div align=\"center\" style=\"margin-top:8px;\"><a href=\"javascript:void(0);\" class=\"close\">Close</a></div></div>";
15138
+ this.boundMouseup = null;
12562
15139
  /**
12563
15140
  * Default position in toolbar ('left'|'center'|'right')
12564
15141
  * @type {String}
@@ -12582,45 +15159,173 @@ var Help = class Help extends Feature {
12582
15159
  if (this.initialized) return;
12583
15160
  this.emitter.emit("initializing-feature", this, !isNull(this.tgtId));
12584
15161
  let tf = this.tf;
15162
+ let targetEl = !this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId);
15163
+ if (this.canUseCE()) this.initCE(targetEl);
15164
+ else this.initLegacy(targetEl);
15165
+ /** @inherited */
15166
+ this.initialized = true;
15167
+ this.emitter.emit("feature-initialized", this);
15168
+ }
15169
+ /**
15170
+ * Whether the feature renders through `<tf-help>`.
15171
+ * @returns {Boolean} True when the element is registered and the
15172
+ * configuration has no custom containers, scroll adjustment or CSS
15173
+ * classes
15174
+ * @private
15175
+ */
15176
+ canUseCE() {
15177
+ return typeof customElements !== "undefined" && Boolean(customElements.get("tf-help")) && !this.tgtId && !this.contTgtId && !this.hasContAdjustLeftPosition && this.btnCssClass === "helpBtn" && this.contCssClass === "helpCont";
15178
+ }
15179
+ /**
15180
+ * Footer markup appended after the instructions
15181
+ * @param {Boolean} withCloseLink Whether to include the legacy
15182
+ * close link
15183
+ * @returns {String} Footer HTML
15184
+ * @private
15185
+ */
15186
+ footerMarkup(withCloseLink) {
15187
+ return "<div class=\"helpFooter\"><h4>TableFilter v" + this.tf.version + "</h4><a href=\"https://www.tablefilter.com/\" target=\"_blank\">https://www.tablefilter.com/</a><br/><span>&copy;2015-" + this.tf.year + " Max Guglielmi</span>" + (withCloseLink ? "<div align=\"center\" style=\"margin-top:8px;\"><a href=\"javascript:void(0);\" class=\"close\">Close</a></div>" : "") + "</div>";
15188
+ }
15189
+ /**
15190
+ * Append markup nodes to the target element
15191
+ * @param {DOMElement} target Node to append the markup to
15192
+ * @param {String} markup Markup; passed through `sanitizeHtml()`
15193
+ * @returns {Array} Appended top-level nodes
15194
+ * @private
15195
+ */
15196
+ appendMarkup(target, markup) {
15197
+ const wrapper = createElm("div");
15198
+ wrapper.innerHTML = sanitizeHtml(markup);
15199
+ const nodes = [];
15200
+ while (wrapper.firstChild) nodes.push(target.appendChild(wrapper.firstChild));
15201
+ return nodes;
15202
+ }
15203
+ /**
15204
+ * Initialize using the <tf-help> custom element
15205
+ * @param {DOMElement} targetEl Target container element
15206
+ * @private
15207
+ */
15208
+ initCE(targetEl) {
15209
+ const host = document.createElement("tf-help");
15210
+ host.setAttribute("trigger-text", this.btnText);
15211
+ host.setAttribute("close-text", "Close");
15212
+ if (this.label) host.setAttribute("label", this.label);
15213
+ if (this.btnHtml) {
15214
+ const trigger = createElm("span");
15215
+ trigger.innerHTML = sanitizeHtml(this.btnHtml);
15216
+ if (!trigger.firstChild) {} else if (trigger.querySelector(FOCUSABLE_TRIGGER)) while (trigger.firstChild) {
15217
+ const node = trigger.firstChild;
15218
+ if (node.nodeType === 1) {
15219
+ node.slot = "trigger";
15220
+ this.applyTriggerLabel(node);
15221
+ } else if (node.nodeType === 3 && node.textContent.trim()) {
15222
+ const text = createElm("span");
15223
+ text.slot = "trigger";
15224
+ text.appendChild(node);
15225
+ host.appendChild(text);
15226
+ continue;
15227
+ }
15228
+ host.appendChild(node);
15229
+ }
15230
+ else {
15231
+ const button = createElm("button");
15232
+ button.type = "button";
15233
+ button.slot = "trigger";
15234
+ this.applyTriggerLabel(button);
15235
+ while (trigger.firstChild) button.appendChild(trigger.firstChild);
15236
+ host.appendChild(button);
15237
+ }
15238
+ }
15239
+ const instructions = createElm("div");
15240
+ instructions.slot = "instructions";
15241
+ if (this.instrHtml) instructions.innerHTML = sanitizeHtml(this.instrHtml);
15242
+ else if (this.instrText) instructions.appendChild(createText(this.instrText));
15243
+ else instructions.innerHTML = sanitizeHtml(DEFAULT_INSTR_HTML);
15244
+ this.appendMarkup(instructions, this.footerMarkup(false));
15245
+ host.appendChild(instructions);
15246
+ const clearFeature = this.tf.feature("clearButton");
15247
+ const clearEl = clearFeature && clearFeature.container;
15248
+ if (clearEl && clearEl.parentNode === targetEl) targetEl.insertBefore(host, clearEl);
15249
+ else targetEl.appendChild(host);
15250
+ this.el = host;
15251
+ this.btn = host;
15252
+ this.cont = host;
15253
+ }
15254
+ /**
15255
+ * Apply the configured label to a trigger element, preferring the
15256
+ * focusable control in its subtree and preserving an existing
15257
+ * `aria-label`.
15258
+ * @param {DOMElement} node Trigger element
15259
+ * @private
15260
+ */
15261
+ applyTriggerLabel(node) {
15262
+ if (!this.label) return;
15263
+ const target = node.matches(FOCUSABLE_TRIGGER) ? node : node.querySelector(FOCUSABLE_TRIGGER) || node;
15264
+ if (!target.hasAttribute("aria-label")) target.setAttribute("aria-label", this.label);
15265
+ }
15266
+ /**
15267
+ * Append the default help anchor to the legacy button container
15268
+ * @param {DOMElement} btn Button container
15269
+ * @param {DOMElement} divContainer Container receiving the pop-up
15270
+ * @param {DOMElement} cont Help pop-up container
15271
+ * @private
15272
+ */
15273
+ appendDefaultTrigger(btn, divContainer, cont) {
15274
+ divContainer.appendChild(cont);
15275
+ let helplink = createElm("a", ["href", "javascript:void(0);"]);
15276
+ helplink.className = this.btnCssClass;
15277
+ helplink.appendChild(createText(this.btnText));
15278
+ this.applyTriggerLabel(helplink);
15279
+ btn.appendChild(helplink);
15280
+ addEvt(helplink, "click", () => this.toggle());
15281
+ }
15282
+ /**
15283
+ * Initialize using the legacy span/div structure
15284
+ * @param {DOMElement} targetEl Target container element
15285
+ * @private
15286
+ */
15287
+ initLegacy(targetEl) {
12585
15288
  let btn = createElm("span");
12586
15289
  let cont = createElm("div");
12587
15290
  this.boundMouseup = this.onMouseup.bind(this);
12588
- (!this.tgtId ? tf.feature("toolbar").container(this.toolbarPosition) : elm(this.tgtId)).appendChild(btn);
15291
+ targetEl.appendChild(btn);
12589
15292
  let divContainer = !this.contTgtId ? btn : elm(this.contTgtId);
12590
- if (!this.btnHtml) {
12591
- divContainer.appendChild(cont);
12592
- let helplink = createElm("a", ["href", "javascript:void(0);"]);
12593
- helplink.className = this.btnCssClass;
12594
- helplink.appendChild(createText(this.btnText));
12595
- btn.appendChild(helplink);
12596
- addEvt(helplink, "click", () => this.toggle());
12597
- } else {
12598
- btn.innerHTML = this.btnHtml;
12599
- let helpEl = btn.firstChild;
12600
- addEvt(helpEl, "click", () => this.toggle());
12601
- divContainer.appendChild(cont);
15293
+ if (!this.btnHtml) this.appendDefaultTrigger(btn, divContainer, cont);
15294
+ else {
15295
+ btn.innerHTML = sanitizeHtml(this.btnHtml);
15296
+ if (!btn.firstChild) this.appendDefaultTrigger(btn, divContainer, cont);
15297
+ else {
15298
+ let helpEl = btn.firstChild;
15299
+ if (helpEl.nodeType === 1) this.applyTriggerLabel(helpEl);
15300
+ addEvt(helpEl, "click", () => this.toggle());
15301
+ divContainer.appendChild(cont);
15302
+ }
12602
15303
  }
12603
15304
  if (!this.instrHtml) {
12604
- cont.innerHTML = this.instrText;
15305
+ if (this.instrText) cont.appendChild(createText(this.instrText));
15306
+ else cont.innerHTML = sanitizeHtml(DEFAULT_INSTR_HTML);
12605
15307
  cont.className = this.contCssClass;
12606
15308
  } else {
12607
15309
  if (this.contTgtId) divContainer.appendChild(cont);
12608
- cont.innerHTML = this.instrHtml;
15310
+ cont.innerHTML = sanitizeHtml(this.instrHtml);
12609
15311
  if (!this.contTgtId) cont.className = this.contCssClass;
12610
15312
  }
12611
- cont.innerHTML += this.defaultHtml;
15313
+ const footer = this.appendMarkup(cont, this.footerMarkup(true))[0];
15314
+ const close = footer && footer.querySelector("a.close");
15315
+ if (close) close.setAttribute("href", "javascript:void(0);");
12612
15316
  addEvt(cont, "click", () => this.toggle());
12613
15317
  this.cont = cont;
12614
15318
  this.btn = btn;
12615
- /** @inherited */
12616
- this.initialized = true;
12617
- this.emitter.emit("feature-initialized", this);
12618
15319
  }
12619
15320
  /**
12620
15321
  * Toggle help pop-up
12621
15322
  */
12622
15323
  toggle() {
12623
15324
  if (!this.isEnabled()) return;
15325
+ if (this.el) {
15326
+ this.el.setOpen(!this.el.hasAttribute("open"));
15327
+ return;
15328
+ }
12624
15329
  removeEvt(root, "mouseup", this.boundMouseup);
12625
15330
  let divDisplay = this.cont.style.display;
12626
15331
  if (divDisplay === "" || divDisplay === "none") {
@@ -12633,14 +15338,29 @@ var Help = class Help extends Feature {
12633
15338
  }
12634
15339
  }
12635
15340
  /**
15341
+ * Disable help and reflect the state on the `<tf-help>` host
15342
+ */
15343
+ disable() {
15344
+ super.disable();
15345
+ if (this.el) this.el.setAttribute("disabled", "");
15346
+ }
15347
+ /**
15348
+ * Enable help and reflect the state on the `<tf-help>` host
15349
+ */
15350
+ enable() {
15351
+ super.enable();
15352
+ if (this.el) this.el.removeAttribute("disabled");
15353
+ }
15354
+ /**
12636
15355
  * Remove help UI
12637
15356
  */
12638
15357
  destroy() {
12639
15358
  if (!this.initialized) return;
12640
15359
  removeElm(this.btn);
12641
15360
  this.btn = null;
12642
- removeElm(this.cont);
15361
+ if (this.cont !== this.el) removeElm(this.cont);
12643
15362
  this.cont = null;
15363
+ this.el = null;
12644
15364
  this.boundMouseup = null;
12645
15365
  this.initialized = false;
12646
15366
  }
@@ -15959,7 +18679,7 @@ var TableFilter = class {
15959
18679
  * Current version
15960
18680
  * @type {String}
15961
18681
  */
15962
- this.version = "0.7.8";
18682
+ this.version = "0.7.9";
15963
18683
  /**
15964
18684
  * Current year
15965
18685
  * @type {Number}