UNPKG

@anoki/fse-ui

Version:

FSE UI components library

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