@artooi/ag-ui-web-component 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1192,7 +1192,7 @@ function requestQuestion(host, request, options = {}) {
1192
1192
  });
1193
1193
  }
1194
1194
 
1195
- // node_modules/.pnpm/dompurify@3.4.7/node_modules/dompurify/dist/purify.es.mjs
1195
+ // node_modules/.pnpm/dompurify@3.4.13/node_modules/dompurify/dist/purify.es.mjs
1196
1196
  function _arrayLikeToArray(r, a) {
1197
1197
  (null == a || a > r.length) && (a = r.length);
1198
1198
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
@@ -1433,7 +1433,7 @@ var mathMl$1 = freeze(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph
1433
1433
  var mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
1434
1434
  var text = freeze(["#text"]);
1435
1435
  var html = freeze(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "command", "commandfor", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns"]);
1436
- var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
1436
+ var svg = freeze(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dominant-baseline", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "mask-type", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-orientation", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]);
1437
1437
  var mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
1438
1438
  var xml = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
1439
1439
  var MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
@@ -1452,6 +1452,10 @@ var ATTR_WHITESPACE = seal(
1452
1452
  );
1453
1453
  var DOCTYPE_NAME = seal(/^html$/i);
1454
1454
  var CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
1455
+ var ELEMENT_MARKUP_PROBE = seal(/<[/\w!]/g);
1456
+ var COMMENT_MARKUP_PROBE = seal(/<[/\w]/g);
1457
+ var FALLBACK_TAG_CLOSE = seal(/<\/no(script|embed|frames)/i);
1458
+ var SELF_CLOSING_TAG = seal(/\/>/i);
1455
1459
  var NODE_TYPE = {
1456
1460
  element: 1,
1457
1461
  attribute: 2,
@@ -1461,7 +1465,7 @@ var NODE_TYPE = {
1461
1465
  // Deprecated
1462
1466
  entityNode: 6,
1463
1467
  // Deprecated
1464
- progressingInstruction: 7,
1468
+ processingInstruction: 7,
1465
1469
  comment: 8,
1466
1470
  document: 9,
1467
1471
  documentType: 10,
@@ -1509,10 +1513,13 @@ var _createHooksMap = function _createHooksMap2() {
1509
1513
  uponSanitizeShadowNode: []
1510
1514
  };
1511
1515
  };
1516
+ var _resolveSetOption = function _resolveSetOption2(cfg, key, fallback, options) {
1517
+ return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;
1518
+ };
1512
1519
  function createDOMPurify() {
1513
1520
  let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
1514
1521
  const DOMPurify = (root) => createDOMPurify(root);
1515
- DOMPurify.version = "3.4.7";
1522
+ DOMPurify.version = "3.4.13";
1516
1523
  DOMPurify.removed = [];
1517
1524
  if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE.document || !window2.Element) {
1518
1525
  DOMPurify.isSupported = false;
@@ -1536,6 +1543,7 @@ function createDOMPurify() {
1536
1543
  const getAttributes = lookupGetter(ElementPrototype, "attributes");
1537
1544
  const getNodeType = Node2 && Node2.prototype ? lookupGetter(Node2.prototype, "nodeType") : null;
1538
1545
  const getNodeName = Node2 && Node2.prototype ? lookupGetter(Node2.prototype, "nodeName") : null;
1546
+ const getOwnerDocument = Node2 && Node2.prototype ? lookupGetter(Node2.prototype, "ownerDocument") : null;
1539
1547
  if (typeof HTMLTemplateElement === "function") {
1540
1548
  const template = document2.createElement("template");
1541
1549
  if (template.content && template.content.ownerDocument) {
@@ -1544,6 +1552,39 @@ function createDOMPurify() {
1544
1552
  }
1545
1553
  let trustedTypesPolicy;
1546
1554
  let emptyHTML = "";
1555
+ let defaultTrustedTypesPolicy;
1556
+ let defaultTrustedTypesPolicyResolved = false;
1557
+ let IN_TRUSTED_TYPES_POLICY = 0;
1558
+ const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy2() {
1559
+ if (IN_TRUSTED_TYPES_POLICY > 0) {
1560
+ 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.');
1561
+ }
1562
+ };
1563
+ const _createTrustedHTML = function _createTrustedHTML2(html2) {
1564
+ _assertNotInTrustedTypesPolicy();
1565
+ IN_TRUSTED_TYPES_POLICY++;
1566
+ try {
1567
+ return trustedTypesPolicy.createHTML(html2);
1568
+ } finally {
1569
+ IN_TRUSTED_TYPES_POLICY--;
1570
+ }
1571
+ };
1572
+ const _createTrustedScriptURL = function _createTrustedScriptURL2(scriptUrl) {
1573
+ _assertNotInTrustedTypesPolicy();
1574
+ IN_TRUSTED_TYPES_POLICY++;
1575
+ try {
1576
+ return trustedTypesPolicy.createScriptURL(scriptUrl);
1577
+ } finally {
1578
+ IN_TRUSTED_TYPES_POLICY--;
1579
+ }
1580
+ };
1581
+ const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy2() {
1582
+ if (!defaultTrustedTypesPolicyResolved) {
1583
+ defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1584
+ defaultTrustedTypesPolicyResolved = true;
1585
+ }
1586
+ return defaultTrustedTypesPolicy;
1587
+ };
1547
1588
  const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName = _document.getElementsByTagName;
1548
1589
  const importNode = originalDocument.importNode;
1549
1590
  let hooks = _createHooksMap();
@@ -1598,6 +1639,8 @@ function createDOMPurify() {
1598
1639
  let SAFE_FOR_XML = true;
1599
1640
  let WHOLE_DOCUMENT = false;
1600
1641
  let SET_CONFIG = false;
1642
+ let SET_CONFIG_ALLOWED_TAGS = null;
1643
+ let SET_CONFIG_ALLOWED_ATTR = null;
1601
1644
  let FORCE_BODY = false;
1602
1645
  let RETURN_DOM = false;
1603
1646
  let RETURN_DOM_FRAGMENT = false;
@@ -1609,7 +1652,43 @@ function createDOMPurify() {
1609
1652
  let IN_PLACE = false;
1610
1653
  let USE_PROFILES = {};
1611
1654
  let FORBID_CONTENTS = null;
1612
- const DEFAULT_FORBID_CONTENTS = addToSet({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]);
1655
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, [
1656
+ "annotation-xml",
1657
+ "audio",
1658
+ "colgroup",
1659
+ "desc",
1660
+ "foreignobject",
1661
+ "head",
1662
+ "iframe",
1663
+ "math",
1664
+ "mi",
1665
+ "mn",
1666
+ "mo",
1667
+ "ms",
1668
+ "mtext",
1669
+ "noembed",
1670
+ "noframes",
1671
+ "noscript",
1672
+ "plaintext",
1673
+ "script",
1674
+ // <selectedcontent> mirrors the selected <option>'s subtree, cloned by
1675
+ // the UA (customizable <select>) — including any on* handlers — and the
1676
+ // engine re-mirrors synchronously whenever a removal changes which
1677
+ // option/selectedcontent is current, even inside DOMPurify's inert
1678
+ // DOMParser document. Hoisting its children on removal re-inserts a fresh
1679
+ // mirror target ahead of the walk, which the engine refills, looping
1680
+ // forever (DoS) and amplifying output. Dropping its content on removal
1681
+ // (rather than hoisting) breaks that cascade; the content is a duplicate
1682
+ // of the option, which is sanitized on its own. See campaign-3 F1/F6.
1683
+ "selectedcontent",
1684
+ "style",
1685
+ "svg",
1686
+ "template",
1687
+ "thead",
1688
+ "title",
1689
+ "video",
1690
+ "xmp"
1691
+ ]);
1613
1692
  let DATA_URI_TAGS = null;
1614
1693
  const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
1615
1694
  let URI_SAFE_ATTRIBUTES = null;
@@ -1621,8 +1700,10 @@ function createDOMPurify() {
1621
1700
  let IS_EMPTY_INPUT = false;
1622
1701
  let ALLOWED_NAMESPACES = null;
1623
1702
  const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
1624
- let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
1625
- let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
1703
+ const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(["mi", "mo", "mn", "ms", "mtext"]);
1704
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1705
+ const DEFAULT_HTML_INTEGRATION_POINTS = freeze(["annotation-xml"]);
1706
+ let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1626
1707
  const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
1627
1708
  let PARSER_MEDIA_TYPE = null;
1628
1709
  const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
@@ -1645,14 +1726,32 @@ function createDOMPurify() {
1645
1726
  PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
1646
1727
  SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
1647
1728
  transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
1648
- ALLOWED_TAGS2 = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
1649
- ALLOWED_ATTR2 = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
1650
- ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
1651
- URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
1652
- DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
1653
- FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
1654
- FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});
1655
- FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});
1729
+ ALLOWED_TAGS2 = _resolveSetOption(cfg, "ALLOWED_TAGS", DEFAULT_ALLOWED_TAGS, {
1730
+ transform: transformCaseFunc
1731
+ });
1732
+ ALLOWED_ATTR2 = _resolveSetOption(cfg, "ALLOWED_ATTR", DEFAULT_ALLOWED_ATTR, {
1733
+ transform: transformCaseFunc
1734
+ });
1735
+ ALLOWED_NAMESPACES = _resolveSetOption(cfg, "ALLOWED_NAMESPACES", DEFAULT_ALLOWED_NAMESPACES, {
1736
+ transform: stringToString
1737
+ });
1738
+ URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, "ADD_URI_SAFE_ATTR", DEFAULT_URI_SAFE_ATTRIBUTES, {
1739
+ transform: transformCaseFunc,
1740
+ base: DEFAULT_URI_SAFE_ATTRIBUTES
1741
+ });
1742
+ DATA_URI_TAGS = _resolveSetOption(cfg, "ADD_DATA_URI_TAGS", DEFAULT_DATA_URI_TAGS, {
1743
+ transform: transformCaseFunc,
1744
+ base: DEFAULT_DATA_URI_TAGS
1745
+ });
1746
+ FORBID_CONTENTS = _resolveSetOption(cfg, "FORBID_CONTENTS", DEFAULT_FORBID_CONTENTS, {
1747
+ transform: transformCaseFunc
1748
+ });
1749
+ FORBID_TAGS = _resolveSetOption(cfg, "FORBID_TAGS", clone({}), {
1750
+ transform: transformCaseFunc
1751
+ });
1752
+ FORBID_ATTR = _resolveSetOption(cfg, "FORBID_ATTR", clone({}), {
1753
+ transform: transformCaseFunc
1754
+ });
1656
1755
  USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
1657
1756
  ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
1658
1757
  ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
@@ -1671,8 +1770,8 @@ function createDOMPurify() {
1671
1770
  IN_PLACE = cfg.IN_PLACE || false;
1672
1771
  IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
1673
1772
  NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
1674
- MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
1675
- HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ["annotation-xml"]);
1773
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);
1774
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);
1676
1775
  const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
1677
1776
  CUSTOM_ELEMENT_HANDLING = create(null);
1678
1777
  if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
@@ -1684,6 +1783,7 @@ function createDOMPurify() {
1684
1783
  if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
1685
1784
  CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
1686
1785
  }
1786
+ seal(CUSTOM_ELEMENT_HANDLING);
1687
1787
  if (SAFE_FOR_TEMPLATES) {
1688
1788
  ALLOW_DATA_ATTR = false;
1689
1789
  }
@@ -1767,22 +1867,25 @@ function createDOMPurify() {
1767
1867
  if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
1768
1868
  throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1769
1869
  }
1870
+ const previousTrustedTypesPolicy = trustedTypesPolicy;
1770
1871
  trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
1771
- emptyHTML = trustedTypesPolicy.createHTML("");
1872
+ try {
1873
+ emptyHTML = _createTrustedHTML("");
1874
+ } catch (error) {
1875
+ trustedTypesPolicy = previousTrustedTypesPolicy;
1876
+ throw error;
1877
+ }
1878
+ } else if (cfg.TRUSTED_TYPES_POLICY === null) {
1879
+ trustedTypesPolicy = void 0;
1880
+ emptyHTML = "";
1772
1881
  } else {
1773
1882
  if (trustedTypesPolicy === void 0) {
1774
- trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1883
+ trustedTypesPolicy = _getDefaultTrustedTypesPolicy();
1775
1884
  }
1776
- if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
1777
- emptyHTML = trustedTypesPolicy.createHTML("");
1885
+ if (trustedTypesPolicy && typeof emptyHTML === "string") {
1886
+ emptyHTML = _createTrustedHTML("");
1778
1887
  }
1779
1888
  }
1780
- if ((hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) && ALLOWED_TAGS2 === DEFAULT_ALLOWED_TAGS) {
1781
- ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
1782
- }
1783
- if (hooks.uponSanitizeAttribute.length > 0 && ALLOWED_ATTR2 === DEFAULT_ALLOWED_ATTR) {
1784
- ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
1785
- }
1786
1889
  if (freeze) {
1787
1890
  freeze(cfg);
1788
1891
  }
@@ -1790,6 +1893,33 @@ function createDOMPurify() {
1790
1893
  };
1791
1894
  const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
1792
1895
  const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
1896
+ const _checkSvgNamespace = function _checkSvgNamespace2(tagName, parent, parentTagName) {
1897
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1898
+ return tagName === "svg";
1899
+ }
1900
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1901
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1902
+ }
1903
+ return Boolean(ALL_SVG_TAGS[tagName]);
1904
+ };
1905
+ const _checkMathMlNamespace = function _checkMathMlNamespace2(tagName, parent, parentTagName) {
1906
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1907
+ return tagName === "math";
1908
+ }
1909
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1910
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
1911
+ }
1912
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1913
+ };
1914
+ const _checkHtmlNamespace = function _checkHtmlNamespace2(tagName, parent, parentTagName) {
1915
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1916
+ return false;
1917
+ }
1918
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1919
+ return false;
1920
+ }
1921
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1922
+ };
1793
1923
  const _checkValidNamespace = function _checkValidNamespace2(element) {
1794
1924
  let parent = getParentNode(element);
1795
1925
  if (!parent || !parent.tagName) {
@@ -1804,31 +1934,13 @@ function createDOMPurify() {
1804
1934
  return false;
1805
1935
  }
1806
1936
  if (element.namespaceURI === SVG_NAMESPACE) {
1807
- if (parent.namespaceURI === HTML_NAMESPACE) {
1808
- return tagName === "svg";
1809
- }
1810
- if (parent.namespaceURI === MATHML_NAMESPACE) {
1811
- return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1812
- }
1813
- return Boolean(ALL_SVG_TAGS[tagName]);
1937
+ return _checkSvgNamespace(tagName, parent, parentTagName);
1814
1938
  }
1815
1939
  if (element.namespaceURI === MATHML_NAMESPACE) {
1816
- if (parent.namespaceURI === HTML_NAMESPACE) {
1817
- return tagName === "math";
1818
- }
1819
- if (parent.namespaceURI === SVG_NAMESPACE) {
1820
- return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
1821
- }
1822
- return Boolean(ALL_MATHML_TAGS[tagName]);
1940
+ return _checkMathMlNamespace(tagName, parent, parentTagName);
1823
1941
  }
1824
1942
  if (element.namespaceURI === HTML_NAMESPACE) {
1825
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1826
- return false;
1827
- }
1828
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1829
- return false;
1830
- }
1831
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1943
+ return _checkHtmlNamespace(tagName, parent, parentTagName);
1832
1944
  }
1833
1945
  if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
1834
1946
  return true;
@@ -1843,6 +1955,38 @@ function createDOMPurify() {
1843
1955
  getParentNode(node).removeChild(node);
1844
1956
  } catch (_2) {
1845
1957
  remove(node);
1958
+ if (!getParentNode(node)) {
1959
+ throw typeErrorCreate("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place");
1960
+ }
1961
+ }
1962
+ };
1963
+ const _neutralizeRoot = function _neutralizeRoot2(root) {
1964
+ _neutralizeSubtree(root);
1965
+ const childNodes = getChildNodes(root);
1966
+ if (childNodes) {
1967
+ const snapshot = [];
1968
+ arrayForEach(childNodes, (child) => {
1969
+ arrayPush(snapshot, child);
1970
+ });
1971
+ arrayForEach(snapshot, (child) => {
1972
+ try {
1973
+ remove(child);
1974
+ } catch (_2) {
1975
+ }
1976
+ });
1977
+ }
1978
+ const attributes = getAttributes(root);
1979
+ if (attributes) {
1980
+ for (let i = attributes.length - 1; i >= 0; --i) {
1981
+ const attribute = attributes[i];
1982
+ const name = attribute && attribute.name;
1983
+ if (typeof name === "string") {
1984
+ try {
1985
+ root.removeAttribute(name);
1986
+ } catch (_2) {
1987
+ }
1988
+ }
1989
+ }
1846
1990
  }
1847
1991
  };
1848
1992
  const _removeAttribute = function _removeAttribute2(name, element) {
@@ -1872,6 +2016,75 @@ function createDOMPurify() {
1872
2016
  }
1873
2017
  }
1874
2018
  };
2019
+ const _stripDisallowedAttributes = function _stripDisallowedAttributes2(element) {
2020
+ const attributes = getAttributes(element);
2021
+ if (!attributes) {
2022
+ return;
2023
+ }
2024
+ for (let i = attributes.length - 1; i >= 0; --i) {
2025
+ const attribute = attributes[i];
2026
+ const name = attribute && attribute.name;
2027
+ if (typeof name !== "string" || ALLOWED_ATTR2[transformCaseFunc(name)]) {
2028
+ continue;
2029
+ }
2030
+ try {
2031
+ element.removeAttribute(name);
2032
+ } catch (_2) {
2033
+ }
2034
+ }
2035
+ };
2036
+ const _neutralizeSubtree = function _neutralizeSubtree2(root) {
2037
+ const stack = [root];
2038
+ while (stack.length > 0) {
2039
+ const node = stack.pop();
2040
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
2041
+ if (nodeType === NODE_TYPE.element) {
2042
+ _stripDisallowedAttributes(node);
2043
+ }
2044
+ const childNodes = getChildNodes(node);
2045
+ if (childNodes) {
2046
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2047
+ stack.push(childNodes[i]);
2048
+ }
2049
+ }
2050
+ }
2051
+ };
2052
+ const _neutralizePatchLinkage = function _neutralizePatchLinkage2(root) {
2053
+ if (!SAFE_FOR_XML) {
2054
+ return;
2055
+ }
2056
+ const stack = [root];
2057
+ while (stack.length > 0) {
2058
+ const node = stack.pop();
2059
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
2060
+ if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {
2061
+ try {
2062
+ remove(node);
2063
+ } catch (_2) {
2064
+ }
2065
+ continue;
2066
+ }
2067
+ if (nodeType === NODE_TYPE.element) {
2068
+ const element = node;
2069
+ const lcTag = transformCaseFunc(getNodeName ? getNodeName(node) : node.nodeName);
2070
+ try {
2071
+ if (element.hasAttribute && element.hasAttribute("patchsrc")) {
2072
+ element.removeAttribute("patchsrc");
2073
+ }
2074
+ if (element.hasAttribute && element.hasAttribute("for") && lcTag !== "label" && lcTag !== "output") {
2075
+ element.removeAttribute("for");
2076
+ }
2077
+ } catch (_2) {
2078
+ }
2079
+ }
2080
+ const childNodes = getChildNodes(node);
2081
+ if (childNodes) {
2082
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2083
+ stack.push(childNodes[i]);
2084
+ }
2085
+ }
2086
+ }
2087
+ };
1875
2088
  const _initDocument = function _initDocument2(dirty) {
1876
2089
  let doc = null;
1877
2090
  let leadingWhitespace = null;
@@ -1884,7 +2097,7 @@ function createDOMPurify() {
1884
2097
  if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
1885
2098
  dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
1886
2099
  }
1887
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
2100
+ const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;
1888
2101
  if (NAMESPACE === HTML_NAMESPACE) {
1889
2102
  try {
1890
2103
  doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
@@ -1908,18 +2121,27 @@ function createDOMPurify() {
1908
2121
  return WHOLE_DOCUMENT ? doc.documentElement : body;
1909
2122
  };
1910
2123
  const _createNodeIterator = function _createNodeIterator2(root) {
2124
+ const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;
1911
2125
  return createNodeIterator.call(
1912
- root.ownerDocument || root,
2126
+ doc || root,
1913
2127
  root,
1914
2128
  // eslint-disable-next-line no-bitwise
1915
2129
  NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
1916
2130
  null
1917
2131
  );
1918
2132
  };
1919
- const _scrubTemplateExpressions = function _scrubTemplateExpressions2(node) {
2133
+ const _stripTemplateExpressions = function _stripTemplateExpressions2(value) {
2134
+ value = stringReplace(value, MUSTACHE_EXPR$1, " ");
2135
+ value = stringReplace(value, ERB_EXPR$1, " ");
2136
+ value = stringReplace(value, TMPLIT_EXPR$1, " ");
2137
+ return value;
2138
+ };
2139
+ const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {
2140
+ var _node$querySelectorAl;
1920
2141
  node.normalize();
2142
+ const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;
1921
2143
  const walker = createNodeIterator.call(
1922
- node.ownerDocument || node,
2144
+ doc || node,
1923
2145
  node,
1924
2146
  // eslint-disable-next-line no-bitwise
1925
2147
  NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION,
@@ -1927,13 +2149,17 @@ function createDOMPurify() {
1927
2149
  );
1928
2150
  let currentNode = walker.nextNode();
1929
2151
  while (currentNode) {
1930
- let data = currentNode.data;
1931
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
1932
- data = stringReplace(data, expr, " ");
1933
- });
1934
- currentNode.data = data;
2152
+ currentNode.data = _stripTemplateExpressions(currentNode.data);
1935
2153
  currentNode = walker.nextNode();
1936
2154
  }
2155
+ const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, "template");
2156
+ if (templates) {
2157
+ arrayForEach(templates, (tmpl) => {
2158
+ if (_isDocumentFragment(tmpl.content)) {
2159
+ _scrubTemplateExpressions2(tmpl.content);
2160
+ }
2161
+ });
2162
+ }
1937
2163
  };
1938
2164
  const _isClobbered = function _isClobbered2(element) {
1939
2165
  const realTagName = getNodeName ? getNodeName(element) : null;
@@ -1989,75 +2215,103 @@ function createDOMPurify() {
1989
2215
  }
1990
2216
  };
1991
2217
  function _executeHooks(hooks2, currentNode, data) {
2218
+ if (hooks2.length === 0) {
2219
+ return;
2220
+ }
1992
2221
  arrayForEach(hooks2, (hook) => {
1993
2222
  hook.call(DOMPurify, currentNode, data, CONFIG);
1994
2223
  });
1995
2224
  }
1996
- const _sanitizeElements = function _sanitizeElements2(currentNode) {
1997
- let content = null;
2225
+ const _isUnsafeNode = function _isUnsafeNode2(currentNode, tagName) {
2226
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {
2227
+ return true;
2228
+ }
2229
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
2230
+ return true;
2231
+ }
2232
+ if (currentNode.nodeType === NODE_TYPE.processingInstruction) {
2233
+ return true;
2234
+ }
2235
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {
2236
+ return true;
2237
+ }
2238
+ return false;
2239
+ };
2240
+ const _sanitizeDisallowedNode = function _sanitizeDisallowedNode2(currentNode, tagName, root) {
2241
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
2242
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
2243
+ return false;
2244
+ }
2245
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
2246
+ return false;
2247
+ }
2248
+ }
2249
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2250
+ const parentNode = getParentNode(currentNode);
2251
+ const childNodes = getChildNodes(currentNode);
2252
+ if (childNodes && parentNode) {
2253
+ const childCount = childNodes.length;
2254
+ for (let i = childCount - 1; i >= 0; --i) {
2255
+ const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];
2256
+ parentNode.insertBefore(hoisted, getNextSibling(currentNode));
2257
+ }
2258
+ }
2259
+ }
2260
+ _forceRemove(currentNode);
2261
+ return true;
2262
+ };
2263
+ const _forkSharedAllowlist = function _forkSharedAllowlist2(hookList, set, defaultSet, setConfigSet) {
2264
+ if (hookList.length === 0) {
2265
+ return set;
2266
+ }
2267
+ return set === defaultSet || set === setConfigSet ? clone(set) : set;
2268
+ };
2269
+ const _sanitizeElements = function _sanitizeElements2(currentNode, root) {
1998
2270
  _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
2271
+ if (currentNode !== root && getParentNode(currentNode) === null) {
2272
+ if (IN_PLACE) {
2273
+ _neutralizeSubtree(currentNode);
2274
+ }
2275
+ return true;
2276
+ }
1999
2277
  if (_isClobbered(currentNode)) {
2000
2278
  _forceRemove(currentNode);
2001
2279
  return true;
2002
2280
  }
2003
- const tagName = transformCaseFunc(currentNode.nodeName);
2281
+ const tagName = transformCaseFunc(getNodeName ? getNodeName(currentNode) : currentNode.nodeName);
2282
+ ALLOWED_TAGS2 = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS2, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);
2004
2283
  _executeHooks(hooks.uponSanitizeElement, currentNode, {
2005
2284
  tagName,
2006
2285
  allowedTags: ALLOWED_TAGS2
2007
2286
  });
2008
- if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
2009
- _forceRemove(currentNode);
2010
- return true;
2011
- }
2012
- if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
2013
- _forceRemove(currentNode);
2014
- return true;
2015
- }
2016
- if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {
2017
- _forceRemove(currentNode);
2287
+ if (currentNode !== root && getParentNode(currentNode) === null) {
2288
+ if (IN_PLACE) {
2289
+ _neutralizeSubtree(currentNode);
2290
+ }
2018
2291
  return true;
2019
2292
  }
2020
- if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
2293
+ if (_isUnsafeNode(currentNode, tagName)) {
2021
2294
  _forceRemove(currentNode);
2022
2295
  return true;
2023
2296
  }
2024
2297
  if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS2[tagName]) {
2025
- if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
2026
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
2027
- return false;
2028
- }
2029
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
2030
- return false;
2031
- }
2032
- }
2033
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
2034
- const parentNode = getParentNode(currentNode);
2035
- const childNodes = getChildNodes(currentNode);
2036
- if (childNodes && parentNode) {
2037
- const childCount = childNodes.length;
2038
- for (let i = childCount - 1; i >= 0; --i) {
2039
- const childClone = cloneNode(childNodes[i], true);
2040
- parentNode.insertBefore(childClone, getNextSibling(currentNode));
2041
- }
2042
- }
2298
+ const removed = _sanitizeDisallowedNode(currentNode, tagName, root);
2299
+ if (removed === false) {
2300
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
2043
2301
  }
2044
- _forceRemove(currentNode);
2045
- return true;
2302
+ return removed;
2046
2303
  }
2047
2304
  const nt2 = getNodeType ? getNodeType(currentNode) : currentNode.nodeType;
2048
2305
  if (nt2 === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {
2049
2306
  _forceRemove(currentNode);
2050
2307
  return true;
2051
2308
  }
2052
- if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
2309
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {
2053
2310
  _forceRemove(currentNode);
2054
2311
  return true;
2055
2312
  }
2056
2313
  if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {
2057
- content = currentNode.textContent;
2058
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
2059
- content = stringReplace(content, expr, " ");
2060
- });
2314
+ const content = _stripTemplateExpressions(currentNode.textContent);
2061
2315
  if (currentNode.textContent !== content) {
2062
2316
  arrayPush(DOMPurify.removed, {
2063
2317
  element: currentNode.cloneNode()
@@ -2072,13 +2326,19 @@ function createDOMPurify() {
2072
2326
  if (FORBID_ATTR[lcName]) {
2073
2327
  return false;
2074
2328
  }
2329
+ if (SAFE_FOR_XML && lcName === "patchsrc") {
2330
+ return false;
2331
+ }
2332
+ if (SAFE_FOR_XML && lcName === "for" && lcTag !== "label" && lcTag !== "output") {
2333
+ return false;
2334
+ }
2075
2335
  if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
2076
2336
  return false;
2077
2337
  }
2078
2338
  const nameIsPermitted = ALLOWED_ATTR2[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
2079
- if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
2339
+ if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) ;
2080
2340
  else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
2081
- else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
2341
+ else if (!nameIsPermitted) {
2082
2342
  if (
2083
2343
  // First condition does a very basic check if a) it's basically a valid custom element tagname AND
2084
2344
  // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
@@ -2103,12 +2363,42 @@ function createDOMPurify() {
2103
2363
  const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
2104
2364
  return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
2105
2365
  };
2366
+ const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute2(lcTag, lcName, namespaceURI, value) {
2367
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function" && !namespaceURI) {
2368
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2369
+ case "TrustedHTML": {
2370
+ return _createTrustedHTML(value);
2371
+ }
2372
+ case "TrustedScriptURL": {
2373
+ return _createTrustedScriptURL(value);
2374
+ }
2375
+ }
2376
+ }
2377
+ return value;
2378
+ };
2379
+ const _setAttributeValue = function _setAttributeValue2(currentNode, name, namespaceURI, value) {
2380
+ try {
2381
+ if (namespaceURI) {
2382
+ currentNode.setAttributeNS(namespaceURI, name, value);
2383
+ } else {
2384
+ currentNode.setAttribute(name, value);
2385
+ }
2386
+ if (_isClobbered(currentNode)) {
2387
+ _forceRemove(currentNode);
2388
+ } else {
2389
+ arrayPop(DOMPurify.removed);
2390
+ }
2391
+ } catch (_2) {
2392
+ _removeAttribute(name, currentNode);
2393
+ }
2394
+ };
2106
2395
  const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
2107
2396
  _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
2108
2397
  const attributes = currentNode.attributes;
2109
2398
  if (!attributes || _isClobbered(currentNode)) {
2110
2399
  return;
2111
2400
  }
2401
+ ALLOWED_ATTR2 = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR2, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);
2112
2402
  const hookEvent = {
2113
2403
  attrName: "",
2114
2404
  attrValue: "",
@@ -2117,6 +2407,7 @@ function createDOMPurify() {
2117
2407
  forceKeepAttr: void 0
2118
2408
  };
2119
2409
  let l3 = attributes.length;
2410
+ const lcTag = transformCaseFunc(currentNode.nodeName);
2120
2411
  while (l3--) {
2121
2412
  const attr = attributes[l3];
2122
2413
  const name = attr.name, namespaceURI = attr.namespaceURI, attrValue = attr.value;
@@ -2148,50 +2439,20 @@ function createDOMPurify() {
2148
2439
  _removeAttribute(name, currentNode);
2149
2440
  continue;
2150
2441
  }
2151
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
2442
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {
2152
2443
  _removeAttribute(name, currentNode);
2153
2444
  continue;
2154
2445
  }
2155
2446
  if (SAFE_FOR_TEMPLATES) {
2156
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
2157
- value = stringReplace(value, expr, " ");
2158
- });
2447
+ value = _stripTemplateExpressions(value);
2159
2448
  }
2160
- const lcTag = transformCaseFunc(currentNode.nodeName);
2161
2449
  if (!_isValidAttribute(lcTag, lcName, value)) {
2162
2450
  _removeAttribute(name, currentNode);
2163
2451
  continue;
2164
2452
  }
2165
- if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
2166
- if (namespaceURI) ;
2167
- else {
2168
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
2169
- case "TrustedHTML": {
2170
- value = trustedTypesPolicy.createHTML(value);
2171
- break;
2172
- }
2173
- case "TrustedScriptURL": {
2174
- value = trustedTypesPolicy.createScriptURL(value);
2175
- break;
2176
- }
2177
- }
2178
- }
2179
- }
2453
+ value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);
2180
2454
  if (value !== initValue) {
2181
- try {
2182
- if (namespaceURI) {
2183
- currentNode.setAttributeNS(namespaceURI, name, value);
2184
- } else {
2185
- currentNode.setAttribute(name, value);
2186
- }
2187
- if (_isClobbered(currentNode)) {
2188
- _forceRemove(currentNode);
2189
- } else {
2190
- arrayPop(DOMPurify.removed);
2191
- }
2192
- } catch (_2) {
2193
- _removeAttribute(name, currentNode);
2194
- }
2455
+ _setAttributeValue(currentNode, name, namespaceURI, value);
2195
2456
  }
2196
2457
  }
2197
2458
  _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
@@ -2202,48 +2463,67 @@ function createDOMPurify() {
2202
2463
  _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
2203
2464
  while (shadowNode = shadowIterator.nextNode()) {
2204
2465
  _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
2205
- _sanitizeElements(shadowNode);
2466
+ _sanitizeElements(shadowNode, fragment);
2206
2467
  _sanitizeAttributes(shadowNode);
2207
2468
  if (_isDocumentFragment(shadowNode.content)) {
2208
2469
  _sanitizeShadowDOM2(shadowNode.content);
2209
2470
  }
2210
2471
  const shadowNodeType = getNodeType ? getNodeType(shadowNode) : shadowNode.nodeType;
2211
2472
  if (shadowNodeType === NODE_TYPE.element) {
2212
- const innerSr = getShadowRoot ? getShadowRoot(shadowNode) : shadowNode.shadowRoot;
2473
+ const innerSr = getShadowRoot(shadowNode);
2213
2474
  if (_isDocumentFragment(innerSr)) {
2214
- _sanitizeAttachedShadowRoots2(innerSr);
2475
+ _sanitizeAttachedShadowRoots(innerSr);
2215
2476
  _sanitizeShadowDOM2(innerSr);
2216
2477
  }
2217
2478
  }
2218
2479
  }
2219
2480
  _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
2220
2481
  };
2221
- const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root) {
2222
- const nodeType = getNodeType ? getNodeType(root) : root.nodeType;
2223
- if (nodeType === NODE_TYPE.element) {
2224
- const sr = getShadowRoot ? getShadowRoot(root) : root.shadowRoot;
2225
- if (_isDocumentFragment(sr)) {
2226
- _sanitizeAttachedShadowRoots2(sr);
2227
- _sanitizeShadowDOM2(sr);
2482
+ const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots2(root) {
2483
+ const stack = [{
2484
+ node: root,
2485
+ shadow: null
2486
+ }];
2487
+ while (stack.length > 0) {
2488
+ const item = stack.pop();
2489
+ if (item.shadow) {
2490
+ _sanitizeShadowDOM2(item.shadow);
2491
+ continue;
2228
2492
  }
2229
- }
2230
- const childNodes = getChildNodes ? getChildNodes(root) : root.childNodes;
2231
- if (!childNodes) {
2232
- return;
2233
- }
2234
- const snapshot = [];
2235
- arrayForEach(childNodes, (child) => {
2236
- arrayPush(snapshot, child);
2237
- });
2238
- for (const child of snapshot) {
2239
- _sanitizeAttachedShadowRoots2(child);
2240
- }
2241
- if (nodeType === NODE_TYPE.element) {
2242
- const rootName = getNodeName ? getNodeName(root) : null;
2243
- if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
2244
- const content = root.content;
2245
- if (_isDocumentFragment(content)) {
2246
- _sanitizeAttachedShadowRoots2(content);
2493
+ const node = item.node;
2494
+ const nodeType = getNodeType ? getNodeType(node) : node.nodeType;
2495
+ const isElement = nodeType === NODE_TYPE.element;
2496
+ const childNodes = getChildNodes(node);
2497
+ if (childNodes) {
2498
+ for (let i = childNodes.length - 1; i >= 0; --i) {
2499
+ stack.push({
2500
+ node: childNodes[i],
2501
+ shadow: null
2502
+ });
2503
+ }
2504
+ }
2505
+ if (isElement) {
2506
+ const rootName = getNodeName ? getNodeName(node) : null;
2507
+ if (typeof rootName === "string" && transformCaseFunc(rootName) === "template") {
2508
+ const content = node.content;
2509
+ if (_isDocumentFragment(content)) {
2510
+ stack.push({
2511
+ node: content,
2512
+ shadow: null
2513
+ });
2514
+ }
2515
+ }
2516
+ }
2517
+ if (isElement) {
2518
+ const sr = getShadowRoot(node);
2519
+ if (_isDocumentFragment(sr)) {
2520
+ stack.push({
2521
+ node: null,
2522
+ shadow: sr
2523
+ }, {
2524
+ node: sr,
2525
+ shadow: null
2526
+ });
2247
2527
  }
2248
2528
  }
2249
2529
  }
@@ -2267,25 +2547,40 @@ function createDOMPurify() {
2267
2547
  if (!DOMPurify.isSupported) {
2268
2548
  return dirty;
2269
2549
  }
2270
- if (!SET_CONFIG) {
2550
+ if (SET_CONFIG) {
2551
+ ALLOWED_TAGS2 = SET_CONFIG_ALLOWED_TAGS;
2552
+ ALLOWED_ATTR2 = SET_CONFIG_ALLOWED_ATTR;
2553
+ } else {
2271
2554
  _parseConfig(cfg);
2272
2555
  }
2273
- DOMPurify.removed = [];
2274
- if (typeof dirty === "string") {
2275
- IN_PLACE = false;
2556
+ if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {
2557
+ ALLOWED_TAGS2 = clone(ALLOWED_TAGS2);
2558
+ }
2559
+ if (hooks.uponSanitizeAttribute.length > 0) {
2560
+ ALLOWED_ATTR2 = clone(ALLOWED_ATTR2);
2276
2561
  }
2277
- if (IN_PLACE) {
2562
+ DOMPurify.removed = [];
2563
+ const inPlace = IN_PLACE && typeof dirty !== "string" && _isNode(dirty);
2564
+ if (inPlace) {
2565
+ _neutralizePatchLinkage(dirty);
2278
2566
  const nn = getNodeName ? getNodeName(dirty) : dirty.nodeName;
2279
2567
  if (typeof nn === "string") {
2280
2568
  const tagName = transformCaseFunc(nn);
2281
2569
  if (!ALLOWED_TAGS2[tagName] || FORBID_TAGS[tagName]) {
2570
+ _neutralizeRoot(dirty);
2282
2571
  throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
2283
2572
  }
2284
2573
  }
2285
2574
  if (_isClobbered(dirty)) {
2575
+ _neutralizeRoot(dirty);
2286
2576
  throw typeErrorCreate("root node is clobbered and cannot be sanitized in-place");
2287
2577
  }
2288
- _sanitizeAttachedShadowRoots2(dirty);
2578
+ try {
2579
+ _sanitizeAttachedShadowRoots(dirty);
2580
+ } catch (error) {
2581
+ _neutralizeRoot(dirty);
2582
+ throw error;
2583
+ }
2289
2584
  } else if (_isNode(dirty)) {
2290
2585
  body = _initDocument("<!---->");
2291
2586
  importedNode = body.ownerDocument.importNode(dirty, true);
@@ -2296,11 +2591,11 @@ function createDOMPurify() {
2296
2591
  } else {
2297
2592
  body.appendChild(importedNode);
2298
2593
  }
2299
- _sanitizeAttachedShadowRoots2(importedNode);
2594
+ _sanitizeAttachedShadowRoots(importedNode);
2300
2595
  } else {
2301
2596
  if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
2302
2597
  dirty.indexOf("<") === -1) {
2303
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
2598
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;
2304
2599
  }
2305
2600
  body = _initDocument(dirty);
2306
2601
  if (!body) {
@@ -2310,23 +2605,41 @@ function createDOMPurify() {
2310
2605
  if (body && FORCE_BODY) {
2311
2606
  _forceRemove(body.firstChild);
2312
2607
  }
2313
- const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
2314
- while (currentNode = nodeIterator.nextNode()) {
2315
- _sanitizeElements(currentNode);
2316
- _sanitizeAttributes(currentNode);
2317
- if (_isDocumentFragment(currentNode.content)) {
2318
- _sanitizeShadowDOM2(currentNode.content);
2608
+ const walkRoot = inPlace ? dirty : body;
2609
+ try {
2610
+ const nodeIterator = _createNodeIterator(walkRoot);
2611
+ while (currentNode = nodeIterator.nextNode()) {
2612
+ _sanitizeElements(currentNode, walkRoot);
2613
+ _sanitizeAttributes(currentNode);
2614
+ if (_isDocumentFragment(currentNode.content)) {
2615
+ _sanitizeShadowDOM2(currentNode.content);
2616
+ }
2319
2617
  }
2618
+ } catch (error) {
2619
+ if (inPlace) {
2620
+ _neutralizeRoot(dirty);
2621
+ arrayForEach(DOMPurify.removed, (entry) => {
2622
+ if (entry.element) {
2623
+ _neutralizeSubtree(entry.element);
2624
+ }
2625
+ });
2626
+ }
2627
+ throw error;
2320
2628
  }
2321
- if (IN_PLACE) {
2629
+ if (inPlace) {
2630
+ arrayForEach(DOMPurify.removed, (entry) => {
2631
+ if (entry.element) {
2632
+ _neutralizeSubtree(entry.element);
2633
+ }
2634
+ });
2322
2635
  if (SAFE_FOR_TEMPLATES) {
2323
- _scrubTemplateExpressions(dirty);
2636
+ _scrubTemplateExpressions2(dirty);
2324
2637
  }
2325
2638
  return dirty;
2326
2639
  }
2327
2640
  if (RETURN_DOM) {
2328
2641
  if (SAFE_FOR_TEMPLATES) {
2329
- _scrubTemplateExpressions(body);
2642
+ _scrubTemplateExpressions2(body);
2330
2643
  }
2331
2644
  if (RETURN_DOM_FRAGMENT) {
2332
2645
  returnNode = createDocumentFragment.call(body.ownerDocument);
@@ -2346,20 +2659,24 @@ function createDOMPurify() {
2346
2659
  serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
2347
2660
  }
2348
2661
  if (SAFE_FOR_TEMPLATES) {
2349
- arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
2350
- serializedHTML = stringReplace(serializedHTML, expr, " ");
2351
- });
2662
+ serializedHTML = _stripTemplateExpressions(serializedHTML);
2352
2663
  }
2353
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
2664
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;
2354
2665
  };
2355
2666
  DOMPurify.setConfig = function() {
2356
2667
  let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2357
2668
  _parseConfig(cfg);
2358
2669
  SET_CONFIG = true;
2670
+ SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS2;
2671
+ SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR2;
2359
2672
  };
2360
2673
  DOMPurify.clearConfig = function() {
2361
2674
  CONFIG = null;
2362
2675
  SET_CONFIG = false;
2676
+ SET_CONFIG_ALLOWED_TAGS = null;
2677
+ SET_CONFIG_ALLOWED_ATTR = null;
2678
+ trustedTypesPolicy = defaultTrustedTypesPolicy;
2679
+ emptyHTML = "";
2363
2680
  };
2364
2681
  DOMPurify.isValidAttribute = function(tag, attr, value) {
2365
2682
  if (!CONFIG) {
@@ -2373,9 +2690,15 @@ function createDOMPurify() {
2373
2690
  if (typeof hookFunction !== "function") {
2374
2691
  return;
2375
2692
  }
2693
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
2694
+ return;
2695
+ }
2376
2696
  arrayPush(hooks[entryPoint], hookFunction);
2377
2697
  };
2378
2698
  DOMPurify.removeHook = function(entryPoint, hookFunction) {
2699
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
2700
+ return void 0;
2701
+ }
2379
2702
  if (hookFunction !== void 0) {
2380
2703
  const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);
2381
2704
  return index === -1 ? void 0 : arraySplice(hooks[entryPoint], index, 1)[0];
@@ -2383,6 +2706,9 @@ function createDOMPurify() {
2383
2706
  return arrayPop(hooks[entryPoint]);
2384
2707
  };
2385
2708
  DOMPurify.removeHooks = function(entryPoint) {
2709
+ if (!objectHasOwnProperty(hooks, entryPoint)) {
2710
+ return;
2711
+ }
2386
2712
  hooks[entryPoint] = [];
2387
2713
  };
2388
2714
  DOMPurify.removeAllHooks = function() {
@@ -8369,7 +8695,7 @@ function setControlValue(el, value) {
8369
8695
  }
8370
8696
 
8371
8697
  // src/version.ts
8372
- var VERSION = "0.14.0";
8698
+ var VERSION = "0.15.0";
8373
8699
  export {
8374
8700
  AgUiChat,
8375
8701
  AgUiClient,
@@ -8436,6 +8762,6 @@ export {
8436
8762
  /*! Bundled license information:
8437
8763
 
8438
8764
  dompurify/dist/purify.es.mjs:
8439
- (*! @license DOMPurify 3.4.7 | (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.7/LICENSE *)
8765
+ (*! @license DOMPurify 3.4.13 | (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.13/LICENSE *)
8440
8766
  */
8441
8767
  //# sourceMappingURL=index.js.map