@anoki/fse-ui
Version:
FSE UI components library
600 lines (599 loc) • 32.8 kB
JavaScript
/*! @license DOMPurify 3.4.2 | (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.2/LICENSE */
var ze, Nt;
function yn() {
if (Nt) return ze;
Nt = 1;
const {
entries: Ge,
setPrototypeOf: Be,
isFrozen: Ct,
getPrototypeOf: Mt,
getOwnPropertyDescriptor: wt
} = Object;
let {
freeze: S,
seal: L,
create: H
} = Object, {
apply: Ee,
construct: Ae
} = typeof Reflect < "u" && Reflect;
S || (S = function(n) {
return n;
}), L || (L = function(n) {
return n;
}), Ee || (Ee = function(n, l) {
for (var a = arguments.length, f = new Array(a > 2 ? a - 2 : 0), D = 2; D < a; D++)
f[D - 2] = arguments[D];
return n.apply(l, f);
}), Ae || (Ae = function(n) {
for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), f = 1; f < l; f++)
a[f - 1] = arguments[f];
return new n(...a);
});
const V = p(Array.prototype.forEach), Pt = p(Array.prototype.lastIndexOf), We = p(Array.prototype.pop), q = p(Array.prototype.push), xt = p(Array.prototype.splice), R = Array.isArray, $ = p(String.prototype.toLowerCase), ge = p(String.prototype.toString), Ye = p(String.prototype.match), z = p(String.prototype.replace), je = p(String.prototype.indexOf), kt = p(String.prototype.trim), vt = p(Number.prototype.toString), Ut = p(Boolean.prototype.toString), Xe = typeof BigInt > "u" ? null : p(BigInt.prototype.toString), Ve = typeof Symbol > "u" ? null : p(Symbol.prototype.toString), u = p(Object.prototype.hasOwnProperty), K = p(Object.prototype.toString), A = p(RegExp.prototype.test), re = Ft(TypeError);
function p(i) {
return function(n) {
n instanceof RegExp && (n.lastIndex = 0);
for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), f = 1; f < l; f++)
a[f - 1] = arguments[f];
return Ee(i, n, a);
};
}
function Ft(i) {
return function() {
for (var n = arguments.length, l = new Array(n), a = 0; a < n; a++)
l[a] = arguments[a];
return Ae(i, l);
};
}
function s(i, n) {
let l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : $;
if (Be && Be(i, null), !R(n))
return i;
let a = n.length;
for (; a--; ) {
let f = n[a];
if (typeof f == "string") {
const D = l(f);
D !== f && (Ct(n) || (n[a] = D), f = D);
}
i[f] = !0;
}
return i;
}
function Ht(i) {
for (let n = 0; n < i.length; n++)
u(i, n) || (i[n] = null);
return i;
}
function b(i) {
const n = H(null);
for (const [l, a] of Ge(i))
u(i, l) && (R(a) ? n[l] = Ht(a) : a && typeof a == "object" && a.constructor === Object ? n[l] = b(a) : n[l] = a);
return n;
}
function zt(i) {
switch (typeof i) {
case "string":
return i;
case "number":
return vt(i);
case "boolean":
return Ut(i);
case "bigint":
return Xe ? Xe(i) : "0";
case "symbol":
return Ve ? Ve(i) : "Symbol()";
case "undefined":
return K(i);
case "function":
case "object": {
if (i === null)
return K(i);
const n = i, l = G(n, "toString");
if (typeof l == "function") {
const a = l(n);
return typeof a == "string" ? a : K(a);
}
return K(i);
}
default:
return K(i);
}
}
function G(i, n) {
for (; i !== null; ) {
const a = wt(i, n);
if (a) {
if (a.get)
return p(a.get);
if (typeof a.value == "function")
return p(a.value);
}
i = Mt(i);
}
function l() {
return null;
}
return l;
}
function Gt(i) {
try {
return A(i, ""), !0;
} catch {
return !1;
}
}
const qe = S(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), he = S(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Se = S(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Bt = S(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Re = S(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), Wt = S(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), $e = S(["#text"]), Ke = S(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "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"]), Oe = S(["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"]), Ze = S(["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"]), ae = S(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Yt = L(/\{\{[\w\W]*|[\w\W]*\}\}/gm), jt = L(/<%[\w\W]*|[\w\W]*%>/gm), Xt = L(/\$\{[\w\W]*/gm), Vt = L(/^data-[\-\w.\u00B7-\uFFFF]+$/), qt = L(/^aria-[\-\w]+$/), Je = L(
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
// eslint-disable-line no-useless-escape
), $t = L(/^(?:\w+script|data):/i), Kt = L(
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
// eslint-disable-line no-control-regex
), Qe = L(/^html$/i), Zt = L(/^[a-z][.\w]*(-[.\w]+)+$/i);
var et = /* @__PURE__ */ Object.freeze({
__proto__: null,
ARIA_ATTR: qt,
ATTR_WHITESPACE: Kt,
CUSTOM_ELEMENT: Zt,
DATA_ATTR: Vt,
DOCTYPE_NAME: Qe,
ERB_EXPR: jt,
IS_ALLOWED_URI: Je,
IS_SCRIPT_OR_DATA: $t,
MUSTACHE_EXPR: Yt,
TMPLIT_EXPR: Xt
});
const Z = {
element: 1,
text: 3,
// Deprecated
progressingInstruction: 7,
comment: 8,
document: 9
}, Jt = function() {
return typeof window > "u" ? null : window;
}, Qt = function(n, l) {
if (typeof n != "object" || typeof n.createPolicy != "function")
return null;
let a = null;
const f = "data-tt-policy-suffix";
l && l.hasAttribute(f) && (a = l.getAttribute(f));
const D = "dompurify" + (a ? "#" + a : "");
try {
return n.createPolicy(D, {
createHTML(B) {
return B;
},
createScriptURL(B) {
return B;
}
});
} catch {
return console.warn("TrustedTypes policy " + D + " could not be created."), null;
}
}, tt = function() {
return {
afterSanitizeAttributes: [],
afterSanitizeElements: [],
afterSanitizeShadowDOM: [],
beforeSanitizeAttributes: [],
beforeSanitizeElements: [],
beforeSanitizeShadowDOM: [],
uponSanitizeAttribute: [],
uponSanitizeElement: [],
uponSanitizeShadowNode: []
};
};
function nt() {
let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Jt();
const n = (r) => nt(r);
if (n.version = "3.4.2", n.removed = [], !i || !i.document || i.document.nodeType !== Z.document || !i.Element)
return n.isSupported = !1, n;
let {
document: l
} = i;
const a = l, f = a.currentScript, {
DocumentFragment: D,
HTMLTemplateElement: B,
Node: ye,
Element: ot,
NodeFilter: J,
NamedNodeMap: tn = i.NamedNodeMap || i.MozNamedAttrMap,
HTMLFormElement: nn,
DOMParser: on,
trustedTypes: se
} = i, Q = ot.prototype, rn = G(Q, "cloneNode"), an = G(Q, "remove"), sn = G(Q, "nextSibling"), ln = G(Q, "childNodes"), le = G(Q, "parentNode");
if (typeof B == "function") {
const r = l.createElement("template");
r.content && r.content.ownerDocument && (l = r.content.ownerDocument);
}
let O, ee = "";
const {
implementation: be,
createNodeIterator: cn,
createDocumentFragment: fn,
getElementsByTagName: un
} = l, {
importNode: mn
} = a;
let y = tt();
n.isSupported = typeof Ge == "function" && typeof le == "function" && be && be.createHTMLDocument !== void 0;
const {
MUSTACHE_EXPR: ce,
ERB_EXPR: fe,
TMPLIT_EXPR: ue,
DATA_ATTR: pn,
ARIA_ATTR: Tn,
IS_SCRIPT_OR_DATA: dn,
ATTR_WHITESPACE: it,
CUSTOM_ELEMENT: _n
} = et;
let {
IS_ALLOWED_URI: rt
} = et, _ = null;
const at = s({}, [...qe, ...he, ...Se, ...Re, ...$e]);
let g = null;
const st = s({}, [...Ke, ...Oe, ...Ze, ...ae]);
let m = Object.seal(H(null, {
tagNameCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
attributeNameCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
allowCustomizedBuiltInElements: {
writable: !0,
configurable: !1,
enumerable: !0,
value: !1
}
})), te = null, me = null;
const k = Object.seal(H(null, {
tagCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
attributeCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
}
}));
let lt = !0, De = !0, ct = !1, ft = !0, v = !1, ne = !0, U = !1, Ie = !1, Le = !1, W = !1, pe = !1, Te = !1, ut = !0, mt = !1;
const pt = "user-content-";
let Ne = !0, oe = !1, Y = {}, w = null;
const Ce = s({}, ["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"]);
let Tt = null;
const dt = s({}, ["audio", "video", "img", "source", "image", "track"]);
let Me = null;
const _t = s({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), de = "http://www.w3.org/1998/Math/MathML", _e = "http://www.w3.org/2000/svg", P = "http://www.w3.org/1999/xhtml";
let j = P, we = !1, Pe = null;
const En = s({}, [de, _e, P], ge);
let xe = s({}, ["mi", "mo", "mn", "ms", "mtext"]), ke = s({}, ["annotation-xml"]);
const An = s({}, ["title", "style", "font", "a", "script"]);
let ie = null;
const gn = ["application/xhtml+xml", "text/html"], hn = "text/html";
let d = null, X = null;
const Sn = l.createElement("form"), Et = function(e) {
return e instanceof RegExp || e instanceof Function;
}, ve = function() {
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
if (X && X === e)
return;
(!e || typeof e != "object") && (e = {}), e = b(e), ie = // eslint-disable-next-line unicorn/prefer-includes
gn.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? hn : e.PARSER_MEDIA_TYPE, d = ie === "application/xhtml+xml" ? ge : $, _ = u(e, "ALLOWED_TAGS") && R(e.ALLOWED_TAGS) ? s({}, e.ALLOWED_TAGS, d) : at, g = u(e, "ALLOWED_ATTR") && R(e.ALLOWED_ATTR) ? s({}, e.ALLOWED_ATTR, d) : st, Pe = u(e, "ALLOWED_NAMESPACES") && R(e.ALLOWED_NAMESPACES) ? s({}, e.ALLOWED_NAMESPACES, ge) : En, Me = u(e, "ADD_URI_SAFE_ATTR") && R(e.ADD_URI_SAFE_ATTR) ? s(b(_t), e.ADD_URI_SAFE_ATTR, d) : _t, Tt = u(e, "ADD_DATA_URI_TAGS") && R(e.ADD_DATA_URI_TAGS) ? s(b(dt), e.ADD_DATA_URI_TAGS, d) : dt, w = u(e, "FORBID_CONTENTS") && R(e.FORBID_CONTENTS) ? s({}, e.FORBID_CONTENTS, d) : Ce, te = u(e, "FORBID_TAGS") && R(e.FORBID_TAGS) ? s({}, e.FORBID_TAGS, d) : b({}), me = u(e, "FORBID_ATTR") && R(e.FORBID_ATTR) ? s({}, e.FORBID_ATTR, d) : b({}), Y = u(e, "USE_PROFILES") ? e.USE_PROFILES && typeof e.USE_PROFILES == "object" ? b(e.USE_PROFILES) : e.USE_PROFILES : !1, lt = e.ALLOW_ARIA_ATTR !== !1, De = e.ALLOW_DATA_ATTR !== !1, ct = e.ALLOW_UNKNOWN_PROTOCOLS || !1, ft = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, v = e.SAFE_FOR_TEMPLATES || !1, ne = e.SAFE_FOR_XML !== !1, U = e.WHOLE_DOCUMENT || !1, W = e.RETURN_DOM || !1, pe = e.RETURN_DOM_FRAGMENT || !1, Te = e.RETURN_TRUSTED_TYPE || !1, Le = e.FORCE_BODY || !1, ut = e.SANITIZE_DOM !== !1, mt = e.SANITIZE_NAMED_PROPS || !1, Ne = e.KEEP_CONTENT !== !1, oe = e.IN_PLACE || !1, rt = Gt(e.ALLOWED_URI_REGEXP) ? e.ALLOWED_URI_REGEXP : Je, j = typeof e.NAMESPACE == "string" ? e.NAMESPACE : P, xe = u(e, "MATHML_TEXT_INTEGRATION_POINTS") && e.MATHML_TEXT_INTEGRATION_POINTS && typeof e.MATHML_TEXT_INTEGRATION_POINTS == "object" ? b(e.MATHML_TEXT_INTEGRATION_POINTS) : s({}, ["mi", "mo", "mn", "ms", "mtext"]), ke = u(e, "HTML_INTEGRATION_POINTS") && e.HTML_INTEGRATION_POINTS && typeof e.HTML_INTEGRATION_POINTS == "object" ? b(e.HTML_INTEGRATION_POINTS) : s({}, ["annotation-xml"]);
const t = u(e, "CUSTOM_ELEMENT_HANDLING") && e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING == "object" ? b(e.CUSTOM_ELEMENT_HANDLING) : H(null);
if (m = H(null), u(t, "tagNameCheck") && Et(t.tagNameCheck) && (m.tagNameCheck = t.tagNameCheck), u(t, "attributeNameCheck") && Et(t.attributeNameCheck) && (m.attributeNameCheck = t.attributeNameCheck), u(t, "allowCustomizedBuiltInElements") && typeof t.allowCustomizedBuiltInElements == "boolean" && (m.allowCustomizedBuiltInElements = t.allowCustomizedBuiltInElements), v && (De = !1), pe && (W = !0), Y && (_ = s({}, $e), g = H(null), Y.html === !0 && (s(_, qe), s(g, Ke)), Y.svg === !0 && (s(_, he), s(g, Oe), s(g, ae)), Y.svgFilters === !0 && (s(_, Se), s(g, Oe), s(g, ae)), Y.mathMl === !0 && (s(_, Re), s(g, Ze), s(g, ae))), k.tagCheck = null, k.attributeCheck = null, u(e, "ADD_TAGS") && (typeof e.ADD_TAGS == "function" ? k.tagCheck = e.ADD_TAGS : R(e.ADD_TAGS) && (_ === at && (_ = b(_)), s(_, e.ADD_TAGS, d))), u(e, "ADD_ATTR") && (typeof e.ADD_ATTR == "function" ? k.attributeCheck = e.ADD_ATTR : R(e.ADD_ATTR) && (g === st && (g = b(g)), s(g, e.ADD_ATTR, d))), u(e, "ADD_URI_SAFE_ATTR") && R(e.ADD_URI_SAFE_ATTR) && s(Me, e.ADD_URI_SAFE_ATTR, d), u(e, "FORBID_CONTENTS") && R(e.FORBID_CONTENTS) && (w === Ce && (w = b(w)), s(w, e.FORBID_CONTENTS, d)), u(e, "ADD_FORBID_CONTENTS") && R(e.ADD_FORBID_CONTENTS) && (w === Ce && (w = b(w)), s(w, e.ADD_FORBID_CONTENTS, d)), Ne && (_["#text"] = !0), U && s(_, ["html", "head", "body"]), _.table && (s(_, ["tbody"]), delete te.tbody), e.TRUSTED_TYPES_POLICY) {
if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function")
throw re('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function")
throw re('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
O = e.TRUSTED_TYPES_POLICY, ee = O.createHTML("");
} else
O === void 0 && (O = Qt(se, f)), O !== null && typeof ee == "string" && (ee = O.createHTML(""));
S && S(e), X = e;
}, At = s({}, [...he, ...Se, ...Bt]), gt = s({}, [...Re, ...Wt]), Rn = function(e) {
let t = le(e);
(!t || !t.tagName) && (t = {
namespaceURI: j,
tagName: "template"
});
const o = $(e.tagName), c = $(t.tagName);
return Pe[e.namespaceURI] ? e.namespaceURI === _e ? t.namespaceURI === P ? o === "svg" : t.namespaceURI === de ? o === "svg" && (c === "annotation-xml" || xe[c]) : !!At[o] : e.namespaceURI === de ? t.namespaceURI === P ? o === "math" : t.namespaceURI === _e ? o === "math" && ke[c] : !!gt[o] : e.namespaceURI === P ? t.namespaceURI === _e && !ke[c] || t.namespaceURI === de && !xe[c] ? !1 : !gt[o] && (An[o] || !At[o]) : !!(ie === "application/xhtml+xml" && Pe[e.namespaceURI]) : !1;
}, C = function(e) {
q(n.removed, {
element: e
});
try {
le(e).removeChild(e);
} catch {
an(e);
}
}, F = function(e, t) {
try {
q(n.removed, {
attribute: t.getAttributeNode(e),
from: t
});
} catch {
q(n.removed, {
attribute: null,
from: t
});
}
if (t.removeAttribute(e), e === "is")
if (W || pe)
try {
C(t);
} catch {
}
else
try {
t.setAttribute(e, "");
} catch {
}
}, ht = function(e) {
let t = null, o = null;
if (Le)
e = "<remove></remove>" + e;
else {
const T = Ye(e, /^[\r\n\t ]+/);
o = T && T[0];
}
ie === "application/xhtml+xml" && j === P && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
const c = O ? O.createHTML(e) : e;
if (j === P)
try {
t = new on().parseFromString(c, ie);
} catch {
}
if (!t || !t.documentElement) {
t = be.createDocument(j, "template", null);
try {
t.documentElement.innerHTML = we ? ee : c;
} catch {
}
}
const h = t.body || t.documentElement;
return e && o && h.insertBefore(l.createTextNode(o), h.childNodes[0] || null), j === P ? un.call(t, U ? "html" : "body")[0] : U ? t.documentElement : h;
}, St = function(e) {
return cn.call(
e.ownerDocument || e,
e,
// eslint-disable-next-line no-bitwise
J.SHOW_ELEMENT | J.SHOW_COMMENT | J.SHOW_TEXT | J.SHOW_PROCESSING_INSTRUCTION | J.SHOW_CDATA_SECTION,
null
);
}, Ue = function(e) {
return e instanceof nn && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof tn) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
}, Fe = function(e) {
return typeof ye == "function" && e instanceof ye;
};
function x(r, e, t) {
V(r, (o) => {
o.call(n, e, t, X);
});
}
const Rt = function(e) {
let t = null;
if (x(y.beforeSanitizeElements, e, null), Ue(e))
return C(e), !0;
const o = d(e.nodeName);
if (x(y.uponSanitizeElement, e, {
tagName: o,
allowedTags: _
}), ne && e.hasChildNodes() && !Fe(e.firstElementChild) && A(/<[/\w!]/g, e.innerHTML) && A(/<[/\w!]/g, e.textContent) || ne && e.namespaceURI === P && o === "style" && Fe(e.firstElementChild) || e.nodeType === Z.progressingInstruction || ne && e.nodeType === Z.comment && A(/<[/\w]/g, e.data))
return C(e), !0;
if (te[o] || !(k.tagCheck instanceof Function && k.tagCheck(o)) && !_[o]) {
if (!te[o] && yt(o) && (m.tagNameCheck instanceof RegExp && A(m.tagNameCheck, o) || m.tagNameCheck instanceof Function && m.tagNameCheck(o)))
return !1;
if (Ne && !w[o]) {
const c = le(e) || e.parentNode, h = ln(e) || e.childNodes;
if (h && c) {
const T = h.length;
for (let I = T - 1; I >= 0; --I) {
const N = rn(h[I], !0);
c.insertBefore(N, sn(e));
}
}
}
return C(e), !0;
}
return e instanceof ot && !Rn(e) || (o === "noscript" || o === "noembed" || o === "noframes") && A(/<\/no(script|embed|frames)/i, e.innerHTML) ? (C(e), !0) : (v && e.nodeType === Z.text && (t = e.textContent, V([ce, fe, ue], (c) => {
t = z(t, c, " ");
}), e.textContent !== t && (q(n.removed, {
element: e.cloneNode()
}), e.textContent = t)), x(y.afterSanitizeElements, e, null), !1);
}, Ot = function(e, t, o) {
if (me[t] || ut && (t === "id" || t === "name") && (o in l || o in Sn))
return !1;
const c = g[t] || k.attributeCheck instanceof Function && k.attributeCheck(t, e);
if (!(De && !me[t] && A(pn, t))) {
if (!(lt && A(Tn, t))) {
if (!c || me[t]) {
if (
// First condition does a very basic check if a) it's basically a valid custom element tagname AND
// b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
// and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
!(yt(e) && (m.tagNameCheck instanceof RegExp && A(m.tagNameCheck, e) || m.tagNameCheck instanceof Function && m.tagNameCheck(e)) && (m.attributeNameCheck instanceof RegExp && A(m.attributeNameCheck, t) || m.attributeNameCheck instanceof Function && m.attributeNameCheck(t, e)) || // Alternative, second condition checks if it's an `is`-attribute, AND
// the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
t === "is" && m.allowCustomizedBuiltInElements && (m.tagNameCheck instanceof RegExp && A(m.tagNameCheck, o) || m.tagNameCheck instanceof Function && m.tagNameCheck(o)))
) return !1;
} else if (!Me[t]) {
if (!A(rt, z(o, it, ""))) {
if (!((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && je(o, "data:") === 0 && Tt[e])) {
if (!(ct && !A(dn, z(o, it, "")))) {
if (o)
return !1;
}
}
}
}
}
}
return !0;
}, On = s({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]), yt = function(e) {
return !On[$(e)] && A(_n, e);
}, bt = function(e) {
x(y.beforeSanitizeAttributes, e, null);
const {
attributes: t
} = e;
if (!t || Ue(e))
return;
const o = {
attrName: "",
attrValue: "",
keepAttr: !0,
allowedAttributes: g,
forceKeepAttr: void 0
};
let c = t.length;
for (; c--; ) {
const h = t[c], {
name: T,
namespaceURI: I,
value: N
} = h, M = d(T), He = N;
let E = T === "value" ? He : kt(He);
if (o.attrName = M, o.attrValue = E, o.keepAttr = !0, o.forceKeepAttr = void 0, x(y.uponSanitizeAttribute, e, o), E = o.attrValue, mt && (M === "id" || M === "name") && je(E, pt) !== 0 && (F(T, e), E = pt + E), ne && A(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, E)) {
F(T, e);
continue;
}
if (M === "attributename" && Ye(E, "href")) {
F(T, e);
continue;
}
if (o.forceKeepAttr)
continue;
if (!o.keepAttr) {
F(T, e);
continue;
}
if (!ft && A(/\/>/i, E)) {
F(T, e);
continue;
}
v && V([ce, fe, ue], (Lt) => {
E = z(E, Lt, " ");
});
const It = d(e.nodeName);
if (!Ot(It, M, E)) {
F(T, e);
continue;
}
if (O && typeof se == "object" && typeof se.getAttributeType == "function" && !I)
switch (se.getAttributeType(It, M)) {
case "TrustedHTML": {
E = O.createHTML(E);
break;
}
case "TrustedScriptURL": {
E = O.createScriptURL(E);
break;
}
}
if (E !== He)
try {
I ? e.setAttributeNS(I, T, E) : e.setAttribute(T, E), Ue(e) ? C(e) : We(n.removed);
} catch {
F(T, e);
}
}
x(y.afterSanitizeAttributes, e, null);
}, Dt = function(e) {
let t = null;
const o = St(e);
for (x(y.beforeSanitizeShadowDOM, e, null); t = o.nextNode(); )
x(y.uponSanitizeShadowNode, t, null), Rt(t), bt(t), t.content instanceof D && Dt(t.content);
x(y.afterSanitizeShadowDOM, e, null);
};
return n.sanitize = function(r) {
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = null, o = null, c = null, h = null;
if (we = !r, we && (r = "<!-->"), typeof r != "string" && !Fe(r) && (r = zt(r), typeof r != "string"))
throw re("dirty is not a string, aborting");
if (!n.isSupported)
return r;
if (Ie || ve(e), n.removed = [], typeof r == "string" && (oe = !1), oe) {
const N = r.nodeName;
if (typeof N == "string") {
const M = d(N);
if (!_[M] || te[M])
throw re("root node is forbidden and cannot be sanitized in-place");
}
} else if (r instanceof ye)
t = ht("<!---->"), o = t.ownerDocument.importNode(r, !0), o.nodeType === Z.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? t = o : t.appendChild(o);
else {
if (!W && !v && !U && // eslint-disable-next-line unicorn/prefer-includes
r.indexOf("<") === -1)
return O && Te ? O.createHTML(r) : r;
if (t = ht(r), !t)
return W ? null : Te ? ee : "";
}
t && Le && C(t.firstChild);
const T = St(oe ? r : t);
for (; c = T.nextNode(); )
Rt(c), bt(c), c.content instanceof D && Dt(c.content);
if (oe)
return r;
if (W) {
if (v) {
t.normalize();
let N = t.innerHTML;
V([ce, fe, ue], (M) => {
N = z(N, M, " ");
}), t.innerHTML = N;
}
if (pe)
for (h = fn.call(t.ownerDocument); t.firstChild; )
h.appendChild(t.firstChild);
else
h = t;
return (g.shadowroot || g.shadowrootmode) && (h = mn.call(a, h, !0)), h;
}
let I = U ? t.outerHTML : t.innerHTML;
return U && _["!doctype"] && t.ownerDocument && t.ownerDocument.doctype && t.ownerDocument.doctype.name && A(Qe, t.ownerDocument.doctype.name) && (I = "<!DOCTYPE " + t.ownerDocument.doctype.name + `>
` + I), v && V([ce, fe, ue], (N) => {
I = z(I, N, " ");
}), O && Te ? O.createHTML(I) : I;
}, n.setConfig = function() {
let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
ve(r), Ie = !0;
}, n.clearConfig = function() {
X = null, Ie = !1;
}, n.isValidAttribute = function(r, e, t) {
X || ve({});
const o = d(r), c = d(e);
return Ot(o, c, t);
}, n.addHook = function(r, e) {
typeof e == "function" && q(y[r], e);
}, n.removeHook = function(r, e) {
if (e !== void 0) {
const t = Pt(y[r], e);
return t === -1 ? void 0 : xt(y[r], t, 1)[0];
}
return We(y[r]);
}, n.removeHooks = function(r) {
y[r] = [];
}, n.removeAllHooks = function() {
y = tt();
}, n;
}
var en = nt();
return ze = en, ze;
}
export {
yn as __require
};
//# sourceMappingURL=index.es626.js.map