@anoki/fse-ui
Version:
FSE UI components library
558 lines (557 loc) • 30.6 kB
JavaScript
/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */
var Ue, Rt;
function Tn() {
if (Rt) return Ue;
Rt = 1;
const {
entries: Fe,
setPrototypeOf: He,
isFrozen: Ot,
getPrototypeOf: yt,
getOwnPropertyDescriptor: Lt
} = Object;
let {
freeze: g,
seal: L,
create: me
} = Object, {
apply: pe,
construct: de
} = typeof Reflect < "u" && Reflect;
g || (g = function(o) {
return o;
}), L || (L = function(o) {
return o;
}), pe || (pe = function(o, l) {
for (var a = arguments.length, c = new Array(a > 2 ? a - 2 : 0), O = 2; O < a; O++)
c[O - 2] = arguments[O];
return o.apply(l, c);
}), de || (de = function(o) {
for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++)
a[c - 1] = arguments[c];
return new o(...a);
});
const ee = A(Array.prototype.forEach), bt = A(Array.prototype.lastIndexOf), ze = A(Array.prototype.pop), B = A(Array.prototype.push), Dt = A(Array.prototype.splice), te = A(String.prototype.toLowerCase), Te = A(String.prototype.toString), Ee = A(String.prototype.match), Y = A(String.prototype.replace), Nt = A(String.prototype.indexOf), It = A(String.prototype.trim), b = A(Object.prototype.hasOwnProperty), h = A(RegExp.prototype.test), X = Ct(TypeError);
function A(s) {
return function(o) {
o instanceof RegExp && (o.lastIndex = 0);
for (var l = arguments.length, a = new Array(l > 1 ? l - 1 : 0), c = 1; c < l; c++)
a[c - 1] = arguments[c];
return pe(s, o, a);
};
}
function Ct(s) {
return function() {
for (var o = arguments.length, l = new Array(o), a = 0; a < o; a++)
l[a] = arguments[a];
return de(s, l);
};
}
function r(s, o) {
let l = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : te;
He && He(s, null);
let a = o.length;
for (; a--; ) {
let c = o[a];
if (typeof c == "string") {
const O = l(c);
O !== c && (Ot(o) || (o[a] = O), c = O);
}
s[c] = !0;
}
return s;
}
function Mt(s) {
for (let o = 0; o < s.length; o++)
b(s, o) || (s[o] = null);
return s;
}
function N(s) {
const o = me(null);
for (const [l, a] of Fe(s))
b(s, l) && (Array.isArray(a) ? o[l] = Mt(a) : a && typeof a == "object" && a.constructor === Object ? o[l] = N(a) : o[l] = a);
return o;
}
function j(s, o) {
for (; s !== null; ) {
const a = Lt(s, o);
if (a) {
if (a.get)
return A(a.get);
if (typeof a.value == "function")
return A(a.value);
}
s = yt(s);
}
function l() {
return null;
}
return l;
}
const Ge = g(["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"]), _e = g(["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"]), ge = g(["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"]), wt = g(["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"]), he = g(["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"]), xt = g(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), We = g(["#text"]), Be = g(["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", "slot"]), Ae = g(["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"]), Ye = g(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "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"]), ne = g(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Pt = L(/\{\{[\w\W]*|[\w\W]*\}\}/gm), vt = L(/<%[\w\W]*|[\w\W]*%>/gm), kt = L(/\$\{[\w\W]*/gm), Ut = L(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ft = L(/^aria-[\-\w]+$/), Xe = L(
/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
// eslint-disable-line no-useless-escape
), Ht = L(/^(?:\w+script|data):/i), zt = L(
/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
// eslint-disable-line no-control-regex
), je = L(/^html$/i), Gt = L(/^[a-z][.\w]*(-[.\w]+)+$/i);
var Ve = /* @__PURE__ */ Object.freeze({
__proto__: null,
ARIA_ATTR: Ft,
ATTR_WHITESPACE: zt,
CUSTOM_ELEMENT: Gt,
DATA_ATTR: Ut,
DOCTYPE_NAME: je,
ERB_EXPR: vt,
IS_ALLOWED_URI: Xe,
IS_SCRIPT_OR_DATA: Ht,
MUSTACHE_EXPR: Pt,
TMPLIT_EXPR: kt
});
const V = {
element: 1,
text: 3,
// Deprecated
progressingInstruction: 7,
comment: 8,
document: 9
}, Wt = function() {
return typeof window > "u" ? null : window;
}, Bt = function(o, l) {
if (typeof o != "object" || typeof o.createPolicy != "function")
return null;
let a = null;
const c = "data-tt-policy-suffix";
l && l.hasAttribute(c) && (a = l.getAttribute(c));
const O = "dompurify" + (a ? "#" + a : "");
try {
return o.createPolicy(O, {
createHTML(P) {
return P;
},
createScriptURL(P) {
return P;
}
});
} catch {
return console.warn("TrustedTypes policy " + O + " could not be created."), null;
}
}, qe = function() {
return {
afterSanitizeAttributes: [],
afterSanitizeElements: [],
afterSanitizeShadowDOM: [],
beforeSanitizeAttributes: [],
beforeSanitizeElements: [],
beforeSanitizeShadowDOM: [],
uponSanitizeAttribute: [],
uponSanitizeElement: [],
uponSanitizeShadowNode: []
};
};
function $e() {
let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Wt();
const o = (i) => $e(i);
if (o.version = "3.3.0", o.removed = [], !s || !s.document || s.document.nodeType !== V.document || !s.Element)
return o.isSupported = !1, o;
let {
document: l
} = s;
const a = l, c = a.currentScript, {
DocumentFragment: O,
HTMLTemplateElement: P,
Node: Se,
Element: Ke,
NodeFilter: q,
NamedNodeMap: Xt = s.NamedNodeMap || s.MozNamedAttrMap,
HTMLFormElement: jt,
DOMParser: Vt,
trustedTypes: oe
} = s, $ = Ke.prototype, qt = j($, "cloneNode"), $t = j($, "remove"), Kt = j($, "nextSibling"), Zt = j($, "childNodes"), ie = j($, "parentNode");
if (typeof P == "function") {
const i = l.createElement("template");
i.content && i.content.ownerDocument && (l = i.content.ownerDocument);
}
let S, K = "";
const {
implementation: Re,
createNodeIterator: Jt,
createDocumentFragment: Qt,
getElementsByTagName: en
} = l, {
importNode: tn
} = a;
let R = qe();
o.isSupported = typeof Fe == "function" && typeof ie == "function" && Re && Re.createHTMLDocument !== void 0;
const {
MUSTACHE_EXPR: Oe,
ERB_EXPR: ye,
TMPLIT_EXPR: Le,
DATA_ATTR: nn,
ARIA_ATTR: on,
IS_SCRIPT_OR_DATA: an,
ATTR_WHITESPACE: Ze,
CUSTOM_ELEMENT: rn
} = Ve;
let {
IS_ALLOWED_URI: Je
} = Ve, p = null;
const Qe = r({}, [...Ge, ..._e, ...ge, ...he, ...We]);
let T = null;
const et = r({}, [...Be, ...Ae, ...Ye, ...ne]);
let u = Object.seal(me(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
}
})), Z = null, be = null;
const v = Object.seal(me(null, {
tagCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
},
attributeCheck: {
writable: !0,
configurable: !1,
enumerable: !0,
value: null
}
}));
let tt = !0, De = !0, nt = !1, ot = !0, k = !1, ae = !0, w = !1, Ne = !1, Ie = !1, U = !1, re = !1, se = !1, it = !0, at = !1;
const sn = "user-content-";
let Ce = !0, J = !1, F = {}, H = null;
const rt = r({}, ["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 st = null;
const lt = r({}, ["audio", "video", "img", "source", "image", "track"]);
let Me = null;
const ct = r({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), le = "http://www.w3.org/1998/Math/MathML", ce = "http://www.w3.org/2000/svg", I = "http://www.w3.org/1999/xhtml";
let z = I, we = !1, xe = null;
const ln = r({}, [le, ce, I], Te);
let fe = r({}, ["mi", "mo", "mn", "ms", "mtext"]), ue = r({}, ["annotation-xml"]);
const cn = r({}, ["title", "style", "font", "a", "script"]);
let Q = null;
const fn = ["application/xhtml+xml", "text/html"], un = "text/html";
let d = null, G = null;
const mn = l.createElement("form"), ft = function(e) {
return e instanceof RegExp || e instanceof Function;
}, Pe = function() {
let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
if (!(G && G === e)) {
if ((!e || typeof e != "object") && (e = {}), e = N(e), Q = // eslint-disable-next-line unicorn/prefer-includes
fn.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? un : e.PARSER_MEDIA_TYPE, d = Q === "application/xhtml+xml" ? Te : te, p = b(e, "ALLOWED_TAGS") ? r({}, e.ALLOWED_TAGS, d) : Qe, T = b(e, "ALLOWED_ATTR") ? r({}, e.ALLOWED_ATTR, d) : et, xe = b(e, "ALLOWED_NAMESPACES") ? r({}, e.ALLOWED_NAMESPACES, Te) : ln, Me = b(e, "ADD_URI_SAFE_ATTR") ? r(N(ct), e.ADD_URI_SAFE_ATTR, d) : ct, st = b(e, "ADD_DATA_URI_TAGS") ? r(N(lt), e.ADD_DATA_URI_TAGS, d) : lt, H = b(e, "FORBID_CONTENTS") ? r({}, e.FORBID_CONTENTS, d) : rt, Z = b(e, "FORBID_TAGS") ? r({}, e.FORBID_TAGS, d) : N({}), be = b(e, "FORBID_ATTR") ? r({}, e.FORBID_ATTR, d) : N({}), F = b(e, "USE_PROFILES") ? e.USE_PROFILES : !1, tt = e.ALLOW_ARIA_ATTR !== !1, De = e.ALLOW_DATA_ATTR !== !1, nt = e.ALLOW_UNKNOWN_PROTOCOLS || !1, ot = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, k = e.SAFE_FOR_TEMPLATES || !1, ae = e.SAFE_FOR_XML !== !1, w = e.WHOLE_DOCUMENT || !1, U = e.RETURN_DOM || !1, re = e.RETURN_DOM_FRAGMENT || !1, se = e.RETURN_TRUSTED_TYPE || !1, Ie = e.FORCE_BODY || !1, it = e.SANITIZE_DOM !== !1, at = e.SANITIZE_NAMED_PROPS || !1, Ce = e.KEEP_CONTENT !== !1, J = e.IN_PLACE || !1, Je = e.ALLOWED_URI_REGEXP || Xe, z = e.NAMESPACE || I, fe = e.MATHML_TEXT_INTEGRATION_POINTS || fe, ue = e.HTML_INTEGRATION_POINTS || ue, u = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && ft(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (u.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && ft(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (u.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (u.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), k && (De = !1), re && (U = !0), F && (p = r({}, We), T = [], F.html === !0 && (r(p, Ge), r(T, Be)), F.svg === !0 && (r(p, _e), r(T, Ae), r(T, ne)), F.svgFilters === !0 && (r(p, ge), r(T, Ae), r(T, ne)), F.mathMl === !0 && (r(p, he), r(T, Ye), r(T, ne))), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? v.tagCheck = e.ADD_TAGS : (p === Qe && (p = N(p)), r(p, e.ADD_TAGS, d))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? v.attributeCheck = e.ADD_ATTR : (T === et && (T = N(T)), r(T, e.ADD_ATTR, d))), e.ADD_URI_SAFE_ATTR && r(Me, e.ADD_URI_SAFE_ATTR, d), e.FORBID_CONTENTS && (H === rt && (H = N(H)), r(H, e.FORBID_CONTENTS, d)), Ce && (p["#text"] = !0), w && r(p, ["html", "head", "body"]), p.table && (r(p, ["tbody"]), delete Z.tbody), e.TRUSTED_TYPES_POLICY) {
if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function")
throw X('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function")
throw X('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
S = e.TRUSTED_TYPES_POLICY, K = S.createHTML("");
} else
S === void 0 && (S = Bt(oe, c)), S !== null && typeof K == "string" && (K = S.createHTML(""));
g && g(e), G = e;
}
}, ut = r({}, [..._e, ...ge, ...wt]), mt = r({}, [...he, ...xt]), pn = function(e) {
let t = ie(e);
(!t || !t.tagName) && (t = {
namespaceURI: z,
tagName: "template"
});
const n = te(e.tagName), f = te(t.tagName);
return xe[e.namespaceURI] ? e.namespaceURI === ce ? t.namespaceURI === I ? n === "svg" : t.namespaceURI === le ? n === "svg" && (f === "annotation-xml" || fe[f]) : !!ut[n] : e.namespaceURI === le ? t.namespaceURI === I ? n === "math" : t.namespaceURI === ce ? n === "math" && ue[f] : !!mt[n] : e.namespaceURI === I ? t.namespaceURI === ce && !ue[f] || t.namespaceURI === le && !fe[f] ? !1 : !mt[n] && (cn[n] || !ut[n]) : !!(Q === "application/xhtml+xml" && xe[e.namespaceURI]) : !1;
}, D = function(e) {
B(o.removed, {
element: e
});
try {
ie(e).removeChild(e);
} catch {
$t(e);
}
}, x = function(e, t) {
try {
B(o.removed, {
attribute: t.getAttributeNode(e),
from: t
});
} catch {
B(o.removed, {
attribute: null,
from: t
});
}
if (t.removeAttribute(e), e === "is")
if (U || re)
try {
D(t);
} catch {
}
else
try {
t.setAttribute(e, "");
} catch {
}
}, pt = function(e) {
let t = null, n = null;
if (Ie)
e = "<remove></remove>" + e;
else {
const m = Ee(e, /^[\r\n\t ]+/);
n = m && m[0];
}
Q === "application/xhtml+xml" && z === I && (e = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + e + "</body></html>");
const f = S ? S.createHTML(e) : e;
if (z === I)
try {
t = new Vt().parseFromString(f, Q);
} catch {
}
if (!t || !t.documentElement) {
t = Re.createDocument(z, "template", null);
try {
t.documentElement.innerHTML = we ? K : f;
} catch {
}
}
const _ = t.body || t.documentElement;
return e && n && _.insertBefore(l.createTextNode(n), _.childNodes[0] || null), z === I ? en.call(t, w ? "html" : "body")[0] : w ? t.documentElement : _;
}, dt = function(e) {
return Jt.call(
e.ownerDocument || e,
e,
// eslint-disable-next-line no-bitwise
q.SHOW_ELEMENT | q.SHOW_COMMENT | q.SHOW_TEXT | q.SHOW_PROCESSING_INSTRUCTION | q.SHOW_CDATA_SECTION,
null
);
}, ve = function(e) {
return e instanceof jt && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof Xt) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
}, Tt = function(e) {
return typeof Se == "function" && e instanceof Se;
};
function C(i, e, t) {
ee(i, (n) => {
n.call(o, e, t, G);
});
}
const Et = function(e) {
let t = null;
if (C(R.beforeSanitizeElements, e, null), ve(e))
return D(e), !0;
const n = d(e.nodeName);
if (C(R.uponSanitizeElement, e, {
tagName: n,
allowedTags: p
}), ae && e.hasChildNodes() && !Tt(e.firstElementChild) && h(/<[/\w!]/g, e.innerHTML) && h(/<[/\w!]/g, e.textContent) || e.nodeType === V.progressingInstruction || ae && e.nodeType === V.comment && h(/<[/\w]/g, e.data))
return D(e), !0;
if (!(v.tagCheck instanceof Function && v.tagCheck(n)) && (!p[n] || Z[n])) {
if (!Z[n] && gt(n) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n)))
return !1;
if (Ce && !H[n]) {
const f = ie(e) || e.parentNode, _ = Zt(e) || e.childNodes;
if (_ && f) {
const m = _.length;
for (let y = m - 1; y >= 0; --y) {
const M = qt(_[y], !0);
M.__removalCount = (e.__removalCount || 0) + 1, f.insertBefore(M, Kt(e));
}
}
}
return D(e), !0;
}
return e instanceof Ke && !pn(e) || (n === "noscript" || n === "noembed" || n === "noframes") && h(/<\/no(script|embed|frames)/i, e.innerHTML) ? (D(e), !0) : (k && e.nodeType === V.text && (t = e.textContent, ee([Oe, ye, Le], (f) => {
t = Y(t, f, " ");
}), e.textContent !== t && (B(o.removed, {
element: e.cloneNode()
}), e.textContent = t)), C(R.afterSanitizeElements, e, null), !1);
}, _t = function(e, t, n) {
if (it && (t === "id" || t === "name") && (n in l || n in mn))
return !1;
if (!(De && !be[t] && h(nn, t))) {
if (!(tt && h(on, t))) {
if (!(v.attributeCheck instanceof Function && v.attributeCheck(t, e))) {
if (!T[t] || be[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
!(gt(e) && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, e) || u.tagNameCheck instanceof Function && u.tagNameCheck(e)) && (u.attributeNameCheck instanceof RegExp && h(u.attributeNameCheck, t) || u.attributeNameCheck instanceof Function && u.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" && u.allowCustomizedBuiltInElements && (u.tagNameCheck instanceof RegExp && h(u.tagNameCheck, n) || u.tagNameCheck instanceof Function && u.tagNameCheck(n)))
) return !1;
} else if (!Me[t]) {
if (!h(Je, Y(n, Ze, ""))) {
if (!((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && Nt(n, "data:") === 0 && st[e])) {
if (!(nt && !h(an, Y(n, Ze, "")))) {
if (n)
return !1;
}
}
}
}
}
}
}
return !0;
}, gt = function(e) {
return e !== "annotation-xml" && Ee(e, rn);
}, ht = function(e) {
C(R.beforeSanitizeAttributes, e, null);
const {
attributes: t
} = e;
if (!t || ve(e))
return;
const n = {
attrName: "",
attrValue: "",
keepAttr: !0,
allowedAttributes: T,
forceKeepAttr: void 0
};
let f = t.length;
for (; f--; ) {
const _ = t[f], {
name: m,
namespaceURI: y,
value: M
} = _, W = d(m), ke = M;
let E = m === "value" ? ke : It(ke);
if (n.attrName = W, n.attrValue = E, n.keepAttr = !0, n.forceKeepAttr = void 0, C(R.uponSanitizeAttribute, e, n), E = n.attrValue, at && (W === "id" || W === "name") && (x(m, e), E = sn + E), ae && h(/((--!?|])>)|<\/(style|title|textarea)/i, E)) {
x(m, e);
continue;
}
if (W === "attributename" && Ee(E, "href")) {
x(m, e);
continue;
}
if (n.forceKeepAttr)
continue;
if (!n.keepAttr) {
x(m, e);
continue;
}
if (!ot && h(/\/>/i, E)) {
x(m, e);
continue;
}
k && ee([Oe, ye, Le], (St) => {
E = Y(E, St, " ");
});
const At = d(e.nodeName);
if (!_t(At, W, E)) {
x(m, e);
continue;
}
if (S && typeof oe == "object" && typeof oe.getAttributeType == "function" && !y)
switch (oe.getAttributeType(At, W)) {
case "TrustedHTML": {
E = S.createHTML(E);
break;
}
case "TrustedScriptURL": {
E = S.createScriptURL(E);
break;
}
}
if (E !== ke)
try {
y ? e.setAttributeNS(y, m, E) : e.setAttribute(m, E), ve(e) ? D(e) : ze(o.removed);
} catch {
x(m, e);
}
}
C(R.afterSanitizeAttributes, e, null);
}, dn = function i(e) {
let t = null;
const n = dt(e);
for (C(R.beforeSanitizeShadowDOM, e, null); t = n.nextNode(); )
C(R.uponSanitizeShadowNode, t, null), Et(t), ht(t), t.content instanceof O && i(t.content);
C(R.afterSanitizeShadowDOM, e, null);
};
return o.sanitize = function(i) {
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = null, n = null, f = null, _ = null;
if (we = !i, we && (i = "<!-->"), typeof i != "string" && !Tt(i))
if (typeof i.toString == "function") {
if (i = i.toString(), typeof i != "string")
throw X("dirty is not a string, aborting");
} else
throw X("toString is not a function");
if (!o.isSupported)
return i;
if (Ne || Pe(e), o.removed = [], typeof i == "string" && (J = !1), J) {
if (i.nodeName) {
const M = d(i.nodeName);
if (!p[M] || Z[M])
throw X("root node is forbidden and cannot be sanitized in-place");
}
} else if (i instanceof Se)
t = pt("<!---->"), n = t.ownerDocument.importNode(i, !0), n.nodeType === V.element && n.nodeName === "BODY" || n.nodeName === "HTML" ? t = n : t.appendChild(n);
else {
if (!U && !k && !w && // eslint-disable-next-line unicorn/prefer-includes
i.indexOf("<") === -1)
return S && se ? S.createHTML(i) : i;
if (t = pt(i), !t)
return U ? null : se ? K : "";
}
t && Ie && D(t.firstChild);
const m = dt(J ? i : t);
for (; f = m.nextNode(); )
Et(f), ht(f), f.content instanceof O && dn(f.content);
if (J)
return i;
if (U) {
if (re)
for (_ = Qt.call(t.ownerDocument); t.firstChild; )
_.appendChild(t.firstChild);
else
_ = t;
return (T.shadowroot || T.shadowrootmode) && (_ = tn.call(a, _, !0)), _;
}
let y = w ? t.outerHTML : t.innerHTML;
return w && p["!doctype"] && t.ownerDocument && t.ownerDocument.doctype && t.ownerDocument.doctype.name && h(je, t.ownerDocument.doctype.name) && (y = "<!DOCTYPE " + t.ownerDocument.doctype.name + `>
` + y), k && ee([Oe, ye, Le], (M) => {
y = Y(y, M, " ");
}), S && se ? S.createHTML(y) : y;
}, o.setConfig = function() {
let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
Pe(i), Ne = !0;
}, o.clearConfig = function() {
G = null, Ne = !1;
}, o.isValidAttribute = function(i, e, t) {
G || Pe({});
const n = d(i), f = d(e);
return _t(n, f, t);
}, o.addHook = function(i, e) {
typeof e == "function" && B(R[i], e);
}, o.removeHook = function(i, e) {
if (e !== void 0) {
const t = bt(R[i], e);
return t === -1 ? void 0 : Dt(R[i], t, 1)[0];
}
return ze(R[i]);
}, o.removeHooks = function(i) {
R[i] = [];
}, o.removeAllHooks = function() {
R = qe();
}, o;
}
var Yt = $e();
return Ue = Yt, Ue;
}
export {
Tn as __require
};
//# sourceMappingURL=index.es463.js.map