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