@clevertask/scribe 0.0.10 → 0.0.12

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.
Files changed (39) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/clsx-OuTLNxxd.js +16 -0
  3. package/dist/components/Menu/BarMenu.js +119 -4
  4. package/dist/components/Menu/BubbleMenu.js +1 -1
  5. package/dist/components/Menu/Mobile/ListOptionBar.d.ts +6 -0
  6. package/dist/components/Menu/Mobile/ListOptionBar.js +40 -0
  7. package/dist/components/Scribe/extension/emoji/EmojiList.d.ts +1 -0
  8. package/dist/components/Scribe/extension/emoji/EmojiList.js +35 -0
  9. package/dist/components/Scribe/extension/emoji/suggest.d.ts +16 -0
  10. package/dist/components/Scribe/extension/emoji/suggest.js +40 -0
  11. package/dist/components/Scribe/extension/extension-link.js +221 -217
  12. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  13. package/dist/components/Scribe/extension/index.d.ts +1 -1
  14. package/dist/components/Scribe/extension/index.js +33 -28
  15. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +8 -6
  16. package/dist/components/Scribe/extension/slashCommand/index.js +4 -153
  17. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts +1 -1
  18. package/dist/components/Scribe/extension/slashCommand/renderItems.js +14 -14
  19. package/dist/components/Scribe/index.d.ts +1 -0
  20. package/dist/components/Scribe/index.js +85 -61
  21. package/dist/index-B0pieAxt.js +160 -0
  22. package/dist/index-CCS9HOYd.js +51031 -0
  23. package/dist/{index-Gm-3o3nq.js → index-DoNRu1rY.js} +1654 -1553
  24. package/dist/index-VneQGVTd.js +2385 -0
  25. package/dist/main.css +64 -6
  26. package/dist/marked.esm-BS_MmRZC.js +1566 -0
  27. package/dist/purify.es-BGaRrCfO.js +553 -0
  28. package/dist/turndown.browser.es-RmA_HBaI.js +649 -0
  29. package/dist/utils/create-scribe-editor.js +7 -6
  30. package/dist/utils/html-to-markdown.js +7 -6
  31. package/dist/utils/markdown-to-html.js +4 -3
  32. package/package.json +44 -41
  33. package/dist/BarMenu-SiPgB2ow.js +0 -134
  34. package/dist/browser-DEobZXxB.js +0 -2099
  35. package/dist/components/Scribe/extension/math-extension.d.ts +0 -2
  36. package/dist/components/Scribe/extension/math-extension.js +0 -11770
  37. package/dist/index-C3_lI_rP.js +0 -2269
  38. package/dist/index-NRgJVTH-.js +0 -7576
  39. package/dist/turndown.browser.es-BSoGafvq.js +0 -1164
@@ -1,1164 +0,0 @@
1
- /*! @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 */
2
- const {
3
- entries: Lt,
4
- setPrototypeOf: Tt,
5
- isFrozen: sn,
6
- getPrototypeOf: cn,
7
- getOwnPropertyDescriptor: fn
8
- } = Object;
9
- let {
10
- freeze: v,
11
- seal: C,
12
- create: Dt
13
- } = Object, {
14
- apply: He,
15
- construct: Be
16
- } = typeof Reflect < "u" && Reflect;
17
- v || (v = function(t) {
18
- return t;
19
- });
20
- C || (C = function(t) {
21
- return t;
22
- });
23
- He || (He = function(t, r, i) {
24
- return t.apply(r, i);
25
- });
26
- Be || (Be = function(t, r) {
27
- return new t(...r);
28
- });
29
- const ue = b(Array.prototype.forEach), un = b(Array.prototype.lastIndexOf), Et = b(Array.prototype.pop), Z = b(Array.prototype.push), mn = b(Array.prototype.splice), pe = b(String.prototype.toLowerCase), Ie = b(String.prototype.toString), At = b(String.prototype.match), Q = b(String.prototype.replace), pn = b(String.prototype.indexOf), dn = b(String.prototype.trim), I = b(Object.prototype.hasOwnProperty), O = b(RegExp.prototype.test), J = hn(TypeError);
30
- function b(e) {
31
- return function(t) {
32
- t instanceof RegExp && (t.lastIndex = 0);
33
- for (var r = arguments.length, i = new Array(r > 1 ? r - 1 : 0), s = 1; s < r; s++)
34
- i[s - 1] = arguments[s];
35
- return He(e, t, i);
36
- };
37
- }
38
- function hn(e) {
39
- return function() {
40
- for (var t = arguments.length, r = new Array(t), i = 0; i < t; i++)
41
- r[i] = arguments[i];
42
- return Be(e, r);
43
- };
44
- }
45
- function f(e, t) {
46
- let r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : pe;
47
- Tt && Tt(e, null);
48
- let i = t.length;
49
- for (; i--; ) {
50
- let s = t[i];
51
- if (typeof s == "string") {
52
- const c = r(s);
53
- c !== s && (sn(t) || (t[i] = c), s = c);
54
- }
55
- e[s] = !0;
56
- }
57
- return e;
58
- }
59
- function gn(e) {
60
- for (let t = 0; t < e.length; t++)
61
- I(e, t) || (e[t] = null);
62
- return e;
63
- }
64
- function U(e) {
65
- const t = Dt(null);
66
- for (const [r, i] of Lt(e))
67
- I(e, r) && (Array.isArray(i) ? t[r] = gn(i) : i && typeof i == "object" && i.constructor === Object ? t[r] = U(i) : t[r] = i);
68
- return t;
69
- }
70
- function ee(e, t) {
71
- for (; e !== null; ) {
72
- const i = fn(e, t);
73
- if (i) {
74
- if (i.get)
75
- return b(i.get);
76
- if (typeof i.value == "function")
77
- return b(i.value);
78
- }
79
- e = cn(e);
80
- }
81
- function r() {
82
- return null;
83
- }
84
- return r;
85
- }
86
- const _t = v(["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"]), Me = v(["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"]), we = v(["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"]), Tn = v(["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"]), ke = v(["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"]), En = v(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), St = v(["#text"]), Rt = v(["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"]), xe = v(["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"]), yt = v(["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"]), me = v(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), An = C(/\{\{[\w\W]*|[\w\W]*\}\}/gm), _n = C(/<%[\w\W]*|[\w\W]*%>/gm), Sn = C(/\$\{[\w\W]*/gm), Rn = C(/^data-[\-\w.\u00B7-\uFFFF]+$/), yn = C(/^aria-[\-\w]+$/), Ct = C(
87
- /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
88
- // eslint-disable-line no-useless-escape
89
- ), Nn = C(/^(?:\w+script|data):/i), On = C(
90
- /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
91
- // eslint-disable-line no-control-regex
92
- ), It = C(/^html$/i), vn = C(/^[a-z][.\w]*(-[.\w]+)+$/i);
93
- var Nt = /* @__PURE__ */ Object.freeze({
94
- __proto__: null,
95
- ARIA_ATTR: yn,
96
- ATTR_WHITESPACE: On,
97
- CUSTOM_ELEMENT: vn,
98
- DATA_ATTR: Rn,
99
- DOCTYPE_NAME: It,
100
- ERB_EXPR: _n,
101
- IS_ALLOWED_URI: Ct,
102
- IS_SCRIPT_OR_DATA: Nn,
103
- MUSTACHE_EXPR: An,
104
- TMPLIT_EXPR: Sn
105
- });
106
- const te = {
107
- element: 1,
108
- text: 3,
109
- // Deprecated
110
- progressingInstruction: 7,
111
- comment: 8,
112
- document: 9
113
- }, bn = function() {
114
- return typeof window > "u" ? null : window;
115
- }, Ln = function(t, r) {
116
- if (typeof t != "object" || typeof t.createPolicy != "function")
117
- return null;
118
- let i = null;
119
- const s = "data-tt-policy-suffix";
120
- r && r.hasAttribute(s) && (i = r.getAttribute(s));
121
- const c = "dompurify" + (i ? "#" + i : "");
122
- try {
123
- return t.createPolicy(c, {
124
- createHTML(p) {
125
- return p;
126
- },
127
- createScriptURL(p) {
128
- return p;
129
- }
130
- });
131
- } catch {
132
- return console.warn("TrustedTypes policy " + c + " could not be created."), null;
133
- }
134
- }, Ot = function() {
135
- return {
136
- afterSanitizeAttributes: [],
137
- afterSanitizeElements: [],
138
- afterSanitizeShadowDOM: [],
139
- beforeSanitizeAttributes: [],
140
- beforeSanitizeElements: [],
141
- beforeSanitizeShadowDOM: [],
142
- uponSanitizeAttribute: [],
143
- uponSanitizeElement: [],
144
- uponSanitizeShadowNode: []
145
- };
146
- };
147
- function Mt() {
148
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : bn();
149
- const t = (l) => Mt(l);
150
- if (t.version = "3.2.5", t.removed = [], !e || !e.document || e.document.nodeType !== te.document || !e.Element)
151
- return t.isSupported = !1, t;
152
- let {
153
- document: r
154
- } = e;
155
- const i = r, s = i.currentScript, {
156
- DocumentFragment: c,
157
- HTMLTemplateElement: p,
158
- Node: L,
159
- Element: m,
160
- NodeFilter: S,
161
- NamedNodeMap: F = e.NamedNodeMap || e.MozNamedAttrMap,
162
- HTMLFormElement: he,
163
- DOMParser: Bt,
164
- trustedTypes: ne
165
- } = e, $ = m.prototype, zt = ee($, "cloneNode"), Wt = ee($, "remove"), Gt = ee($, "nextSibling"), Yt = ee($, "childNodes"), re = ee($, "parentNode");
166
- if (typeof p == "function") {
167
- const l = r.createElement("template");
168
- l.content && l.content.ownerDocument && (r = l.content.ownerDocument);
169
- }
170
- let R, V = "";
171
- const {
172
- implementation: ge,
173
- createNodeIterator: $t,
174
- createDocumentFragment: Vt,
175
- getElementsByTagName: Xt
176
- } = r, {
177
- importNode: jt
178
- } = i;
179
- let y = Ot();
180
- t.isSupported = typeof Lt == "function" && typeof re == "function" && ge && ge.createHTMLDocument !== void 0;
181
- const {
182
- MUSTACHE_EXPR: Te,
183
- ERB_EXPR: Ee,
184
- TMPLIT_EXPR: Ae,
185
- DATA_ATTR: Kt,
186
- ARIA_ATTR: qt,
187
- IS_SCRIPT_OR_DATA: Zt,
188
- ATTR_WHITESPACE: Ve,
189
- CUSTOM_ELEMENT: Qt
190
- } = Nt;
191
- let {
192
- IS_ALLOWED_URI: Xe
193
- } = Nt, h = null;
194
- const je = f({}, [..._t, ...Me, ...we, ...ke, ...St]);
195
- let T = null;
196
- const Ke = f({}, [...Rt, ...xe, ...yt, ...me]);
197
- let d = Object.seal(Dt(null, {
198
- tagNameCheck: {
199
- writable: !0,
200
- configurable: !1,
201
- enumerable: !0,
202
- value: null
203
- },
204
- attributeNameCheck: {
205
- writable: !0,
206
- configurable: !1,
207
- enumerable: !0,
208
- value: null
209
- },
210
- allowCustomizedBuiltInElements: {
211
- writable: !0,
212
- configurable: !1,
213
- enumerable: !0,
214
- value: !1
215
- }
216
- })), X = null, _e = null, qe = !0, Se = !0, Ze = !1, Qe = !0, H = !1, Re = !0, P = !1, ye = !1, Ne = !1, B = !1, ie = !1, ae = !1, Je = !0, et = !1;
217
- const Jt = "user-content-";
218
- let Oe = !0, j = !1, z = {}, W = null;
219
- const tt = f({}, ["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"]);
220
- let nt = null;
221
- const rt = f({}, ["audio", "video", "img", "source", "image", "track"]);
222
- let ve = null;
223
- const it = f({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), oe = "http://www.w3.org/1998/Math/MathML", le = "http://www.w3.org/2000/svg", k = "http://www.w3.org/1999/xhtml";
224
- let G = k, be = !1, Le = null;
225
- const en = f({}, [oe, le, k], Ie);
226
- let se = f({}, ["mi", "mo", "mn", "ms", "mtext"]), ce = f({}, ["annotation-xml"]);
227
- const tn = f({}, ["title", "style", "font", "a", "script"]);
228
- let K = null;
229
- const nn = ["application/xhtml+xml", "text/html"], rn = "text/html";
230
- let g = null, Y = null;
231
- const an = r.createElement("form"), at = function(n) {
232
- return n instanceof RegExp || n instanceof Function;
233
- }, De = function() {
234
- let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
235
- if (!(Y && Y === n)) {
236
- if ((!n || typeof n != "object") && (n = {}), n = U(n), K = // eslint-disable-next-line unicorn/prefer-includes
237
- nn.indexOf(n.PARSER_MEDIA_TYPE) === -1 ? rn : n.PARSER_MEDIA_TYPE, g = K === "application/xhtml+xml" ? Ie : pe, h = I(n, "ALLOWED_TAGS") ? f({}, n.ALLOWED_TAGS, g) : je, T = I(n, "ALLOWED_ATTR") ? f({}, n.ALLOWED_ATTR, g) : Ke, Le = I(n, "ALLOWED_NAMESPACES") ? f({}, n.ALLOWED_NAMESPACES, Ie) : en, ve = I(n, "ADD_URI_SAFE_ATTR") ? f(U(it), n.ADD_URI_SAFE_ATTR, g) : it, nt = I(n, "ADD_DATA_URI_TAGS") ? f(U(rt), n.ADD_DATA_URI_TAGS, g) : rt, W = I(n, "FORBID_CONTENTS") ? f({}, n.FORBID_CONTENTS, g) : tt, X = I(n, "FORBID_TAGS") ? f({}, n.FORBID_TAGS, g) : {}, _e = I(n, "FORBID_ATTR") ? f({}, n.FORBID_ATTR, g) : {}, z = I(n, "USE_PROFILES") ? n.USE_PROFILES : !1, qe = n.ALLOW_ARIA_ATTR !== !1, Se = n.ALLOW_DATA_ATTR !== !1, Ze = n.ALLOW_UNKNOWN_PROTOCOLS || !1, Qe = n.ALLOW_SELF_CLOSE_IN_ATTR !== !1, H = n.SAFE_FOR_TEMPLATES || !1, Re = n.SAFE_FOR_XML !== !1, P = n.WHOLE_DOCUMENT || !1, B = n.RETURN_DOM || !1, ie = n.RETURN_DOM_FRAGMENT || !1, ae = n.RETURN_TRUSTED_TYPE || !1, Ne = n.FORCE_BODY || !1, Je = n.SANITIZE_DOM !== !1, et = n.SANITIZE_NAMED_PROPS || !1, Oe = n.KEEP_CONTENT !== !1, j = n.IN_PLACE || !1, Xe = n.ALLOWED_URI_REGEXP || Ct, G = n.NAMESPACE || k, se = n.MATHML_TEXT_INTEGRATION_POINTS || se, ce = n.HTML_INTEGRATION_POINTS || ce, d = n.CUSTOM_ELEMENT_HANDLING || {}, n.CUSTOM_ELEMENT_HANDLING && at(n.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (d.tagNameCheck = n.CUSTOM_ELEMENT_HANDLING.tagNameCheck), n.CUSTOM_ELEMENT_HANDLING && at(n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (d.attributeNameCheck = n.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), n.CUSTOM_ELEMENT_HANDLING && typeof n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (d.allowCustomizedBuiltInElements = n.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), H && (Se = !1), ie && (B = !0), z && (h = f({}, St), T = [], z.html === !0 && (f(h, _t), f(T, Rt)), z.svg === !0 && (f(h, Me), f(T, xe), f(T, me)), z.svgFilters === !0 && (f(h, we), f(T, xe), f(T, me)), z.mathMl === !0 && (f(h, ke), f(T, yt), f(T, me))), n.ADD_TAGS && (h === je && (h = U(h)), f(h, n.ADD_TAGS, g)), n.ADD_ATTR && (T === Ke && (T = U(T)), f(T, n.ADD_ATTR, g)), n.ADD_URI_SAFE_ATTR && f(ve, n.ADD_URI_SAFE_ATTR, g), n.FORBID_CONTENTS && (W === tt && (W = U(W)), f(W, n.FORBID_CONTENTS, g)), Oe && (h["#text"] = !0), P && f(h, ["html", "head", "body"]), h.table && (f(h, ["tbody"]), delete X.tbody), n.TRUSTED_TYPES_POLICY) {
238
- if (typeof n.TRUSTED_TYPES_POLICY.createHTML != "function")
239
- throw J('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
240
- if (typeof n.TRUSTED_TYPES_POLICY.createScriptURL != "function")
241
- throw J('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
242
- R = n.TRUSTED_TYPES_POLICY, V = R.createHTML("");
243
- } else
244
- R === void 0 && (R = Ln(ne, s)), R !== null && typeof V == "string" && (V = R.createHTML(""));
245
- v && v(n), Y = n;
246
- }
247
- }, ot = f({}, [...Me, ...we, ...Tn]), lt = f({}, [...ke, ...En]), on = function(n) {
248
- let a = re(n);
249
- (!a || !a.tagName) && (a = {
250
- namespaceURI: G,
251
- tagName: "template"
252
- });
253
- const o = pe(n.tagName), u = pe(a.tagName);
254
- return Le[n.namespaceURI] ? n.namespaceURI === le ? a.namespaceURI === k ? o === "svg" : a.namespaceURI === oe ? o === "svg" && (u === "annotation-xml" || se[u]) : !!ot[o] : n.namespaceURI === oe ? a.namespaceURI === k ? o === "math" : a.namespaceURI === le ? o === "math" && ce[u] : !!lt[o] : n.namespaceURI === k ? a.namespaceURI === le && !ce[u] || a.namespaceURI === oe && !se[u] ? !1 : !lt[o] && (tn[o] || !ot[o]) : !!(K === "application/xhtml+xml" && Le[n.namespaceURI]) : !1;
255
- }, M = function(n) {
256
- Z(t.removed, {
257
- element: n
258
- });
259
- try {
260
- re(n).removeChild(n);
261
- } catch {
262
- Wt(n);
263
- }
264
- }, fe = function(n, a) {
265
- try {
266
- Z(t.removed, {
267
- attribute: a.getAttributeNode(n),
268
- from: a
269
- });
270
- } catch {
271
- Z(t.removed, {
272
- attribute: null,
273
- from: a
274
- });
275
- }
276
- if (a.removeAttribute(n), n === "is")
277
- if (B || ie)
278
- try {
279
- M(a);
280
- } catch {
281
- }
282
- else
283
- try {
284
- a.setAttribute(n, "");
285
- } catch {
286
- }
287
- }, st = function(n) {
288
- let a = null, o = null;
289
- if (Ne)
290
- n = "<remove></remove>" + n;
291
- else {
292
- const E = At(n, /^[\r\n\t ]+/);
293
- o = E && E[0];
294
- }
295
- K === "application/xhtml+xml" && G === k && (n = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + n + "</body></html>");
296
- const u = R ? R.createHTML(n) : n;
297
- if (G === k)
298
- try {
299
- a = new Bt().parseFromString(u, K);
300
- } catch {
301
- }
302
- if (!a || !a.documentElement) {
303
- a = ge.createDocument(G, "template", null);
304
- try {
305
- a.documentElement.innerHTML = be ? V : u;
306
- } catch {
307
- }
308
- }
309
- const A = a.body || a.documentElement;
310
- return n && o && A.insertBefore(r.createTextNode(o), A.childNodes[0] || null), G === k ? Xt.call(a, P ? "html" : "body")[0] : P ? a.documentElement : A;
311
- }, ct = function(n) {
312
- return $t.call(
313
- n.ownerDocument || n,
314
- n,
315
- // eslint-disable-next-line no-bitwise
316
- S.SHOW_ELEMENT | S.SHOW_COMMENT | S.SHOW_TEXT | S.SHOW_PROCESSING_INSTRUCTION | S.SHOW_CDATA_SECTION,
317
- null
318
- );
319
- }, Ce = function(n) {
320
- return n instanceof he && (typeof n.nodeName != "string" || typeof n.textContent != "string" || typeof n.removeChild != "function" || !(n.attributes instanceof F) || typeof n.removeAttribute != "function" || typeof n.setAttribute != "function" || typeof n.namespaceURI != "string" || typeof n.insertBefore != "function" || typeof n.hasChildNodes != "function");
321
- }, ft = function(n) {
322
- return typeof L == "function" && n instanceof L;
323
- };
324
- function x(l, n, a) {
325
- ue(l, (o) => {
326
- o.call(t, n, a, Y);
327
- });
328
- }
329
- const ut = function(n) {
330
- let a = null;
331
- if (x(y.beforeSanitizeElements, n, null), Ce(n))
332
- return M(n), !0;
333
- const o = g(n.nodeName);
334
- if (x(y.uponSanitizeElement, n, {
335
- tagName: o,
336
- allowedTags: h
337
- }), n.hasChildNodes() && !ft(n.firstElementChild) && O(/<[/\w!]/g, n.innerHTML) && O(/<[/\w!]/g, n.textContent) || n.nodeType === te.progressingInstruction || Re && n.nodeType === te.comment && O(/<[/\w]/g, n.data))
338
- return M(n), !0;
339
- if (!h[o] || X[o]) {
340
- if (!X[o] && pt(o) && (d.tagNameCheck instanceof RegExp && O(d.tagNameCheck, o) || d.tagNameCheck instanceof Function && d.tagNameCheck(o)))
341
- return !1;
342
- if (Oe && !W[o]) {
343
- const u = re(n) || n.parentNode, A = Yt(n) || n.childNodes;
344
- if (A && u) {
345
- const E = A.length;
346
- for (let D = E - 1; D >= 0; --D) {
347
- const w = zt(A[D], !0);
348
- w.__removalCount = (n.__removalCount || 0) + 1, u.insertBefore(w, Gt(n));
349
- }
350
- }
351
- }
352
- return M(n), !0;
353
- }
354
- return n instanceof m && !on(n) || (o === "noscript" || o === "noembed" || o === "noframes") && O(/<\/no(script|embed|frames)/i, n.innerHTML) ? (M(n), !0) : (H && n.nodeType === te.text && (a = n.textContent, ue([Te, Ee, Ae], (u) => {
355
- a = Q(a, u, " ");
356
- }), n.textContent !== a && (Z(t.removed, {
357
- element: n.cloneNode()
358
- }), n.textContent = a)), x(y.afterSanitizeElements, n, null), !1);
359
- }, mt = function(n, a, o) {
360
- if (Je && (a === "id" || a === "name") && (o in r || o in an))
361
- return !1;
362
- if (!(Se && !_e[a] && O(Kt, a))) {
363
- if (!(qe && O(qt, a))) {
364
- if (!T[a] || _e[a]) {
365
- if (
366
- // First condition does a very basic check if a) it's basically a valid custom element tagname AND
367
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
368
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
369
- !(pt(n) && (d.tagNameCheck instanceof RegExp && O(d.tagNameCheck, n) || d.tagNameCheck instanceof Function && d.tagNameCheck(n)) && (d.attributeNameCheck instanceof RegExp && O(d.attributeNameCheck, a) || d.attributeNameCheck instanceof Function && d.attributeNameCheck(a)) || // Alternative, second condition checks if it's an `is`-attribute, AND
370
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
371
- a === "is" && d.allowCustomizedBuiltInElements && (d.tagNameCheck instanceof RegExp && O(d.tagNameCheck, o) || d.tagNameCheck instanceof Function && d.tagNameCheck(o)))
372
- ) return !1;
373
- } else if (!ve[a]) {
374
- if (!O(Xe, Q(o, Ve, ""))) {
375
- if (!((a === "src" || a === "xlink:href" || a === "href") && n !== "script" && pn(o, "data:") === 0 && nt[n])) {
376
- if (!(Ze && !O(Zt, Q(o, Ve, "")))) {
377
- if (o)
378
- return !1;
379
- }
380
- }
381
- }
382
- }
383
- }
384
- }
385
- return !0;
386
- }, pt = function(n) {
387
- return n !== "annotation-xml" && At(n, Qt);
388
- }, dt = function(n) {
389
- x(y.beforeSanitizeAttributes, n, null);
390
- const {
391
- attributes: a
392
- } = n;
393
- if (!a || Ce(n))
394
- return;
395
- const o = {
396
- attrName: "",
397
- attrValue: "",
398
- keepAttr: !0,
399
- allowedAttributes: T,
400
- forceKeepAttr: void 0
401
- };
402
- let u = a.length;
403
- for (; u--; ) {
404
- const A = a[u], {
405
- name: E,
406
- namespaceURI: D,
407
- value: w
408
- } = A, q = g(E);
409
- let N = E === "value" ? w : dn(w);
410
- if (o.attrName = q, o.attrValue = N, o.keepAttr = !0, o.forceKeepAttr = void 0, x(y.uponSanitizeAttribute, n, o), N = o.attrValue, et && (q === "id" || q === "name") && (fe(E, n), N = Jt + N), Re && O(/((--!?|])>)|<\/(style|title)/i, N)) {
411
- fe(E, n);
412
- continue;
413
- }
414
- if (o.forceKeepAttr || (fe(E, n), !o.keepAttr))
415
- continue;
416
- if (!Qe && O(/\/>/i, N)) {
417
- fe(E, n);
418
- continue;
419
- }
420
- H && ue([Te, Ee, Ae], (gt) => {
421
- N = Q(N, gt, " ");
422
- });
423
- const ht = g(n.nodeName);
424
- if (mt(ht, q, N)) {
425
- if (R && typeof ne == "object" && typeof ne.getAttributeType == "function" && !D)
426
- switch (ne.getAttributeType(ht, q)) {
427
- case "TrustedHTML": {
428
- N = R.createHTML(N);
429
- break;
430
- }
431
- case "TrustedScriptURL": {
432
- N = R.createScriptURL(N);
433
- break;
434
- }
435
- }
436
- try {
437
- D ? n.setAttributeNS(D, E, N) : n.setAttribute(E, N), Ce(n) ? M(n) : Et(t.removed);
438
- } catch {
439
- }
440
- }
441
- }
442
- x(y.afterSanitizeAttributes, n, null);
443
- }, ln = function l(n) {
444
- let a = null;
445
- const o = ct(n);
446
- for (x(y.beforeSanitizeShadowDOM, n, null); a = o.nextNode(); )
447
- x(y.uponSanitizeShadowNode, a, null), ut(a), dt(a), a.content instanceof c && l(a.content);
448
- x(y.afterSanitizeShadowDOM, n, null);
449
- };
450
- return t.sanitize = function(l) {
451
- let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = null, o = null, u = null, A = null;
452
- if (be = !l, be && (l = "<!-->"), typeof l != "string" && !ft(l))
453
- if (typeof l.toString == "function") {
454
- if (l = l.toString(), typeof l != "string")
455
- throw J("dirty is not a string, aborting");
456
- } else
457
- throw J("toString is not a function");
458
- if (!t.isSupported)
459
- return l;
460
- if (ye || De(n), t.removed = [], typeof l == "string" && (j = !1), j) {
461
- if (l.nodeName) {
462
- const w = g(l.nodeName);
463
- if (!h[w] || X[w])
464
- throw J("root node is forbidden and cannot be sanitized in-place");
465
- }
466
- } else if (l instanceof L)
467
- a = st("<!---->"), o = a.ownerDocument.importNode(l, !0), o.nodeType === te.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? a = o : a.appendChild(o);
468
- else {
469
- if (!B && !H && !P && // eslint-disable-next-line unicorn/prefer-includes
470
- l.indexOf("<") === -1)
471
- return R && ae ? R.createHTML(l) : l;
472
- if (a = st(l), !a)
473
- return B ? null : ae ? V : "";
474
- }
475
- a && Ne && M(a.firstChild);
476
- const E = ct(j ? l : a);
477
- for (; u = E.nextNode(); )
478
- ut(u), dt(u), u.content instanceof c && ln(u.content);
479
- if (j)
480
- return l;
481
- if (B) {
482
- if (ie)
483
- for (A = Vt.call(a.ownerDocument); a.firstChild; )
484
- A.appendChild(a.firstChild);
485
- else
486
- A = a;
487
- return (T.shadowroot || T.shadowrootmode) && (A = jt.call(i, A, !0)), A;
488
- }
489
- let D = P ? a.outerHTML : a.innerHTML;
490
- return P && h["!doctype"] && a.ownerDocument && a.ownerDocument.doctype && a.ownerDocument.doctype.name && O(It, a.ownerDocument.doctype.name) && (D = "<!DOCTYPE " + a.ownerDocument.doctype.name + `>
491
- ` + D), H && ue([Te, Ee, Ae], (w) => {
492
- D = Q(D, w, " ");
493
- }), R && ae ? R.createHTML(D) : D;
494
- }, t.setConfig = function() {
495
- let l = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
496
- De(l), ye = !0;
497
- }, t.clearConfig = function() {
498
- Y = null, ye = !1;
499
- }, t.isValidAttribute = function(l, n, a) {
500
- Y || De({});
501
- const o = g(l), u = g(n);
502
- return mt(o, u, a);
503
- }, t.addHook = function(l, n) {
504
- typeof n == "function" && Z(y[l], n);
505
- }, t.removeHook = function(l, n) {
506
- if (n !== void 0) {
507
- const a = un(y[l], n);
508
- return a === -1 ? void 0 : mn(y[l], a, 1)[0];
509
- }
510
- return Et(y[l]);
511
- }, t.removeHooks = function(l) {
512
- y[l] = [];
513
- }, t.removeAllHooks = function() {
514
- y = Ot();
515
- }, t;
516
- }
517
- var er = Mt();
518
- function Dn(e) {
519
- for (var t = 1; t < arguments.length; t++) {
520
- var r = arguments[t];
521
- for (var i in r)
522
- r.hasOwnProperty(i) && (e[i] = r[i]);
523
- }
524
- return e;
525
- }
526
- function ze(e, t) {
527
- return Array(t + 1).join(e);
528
- }
529
- function Cn(e) {
530
- return e.replace(/^\n*/, "");
531
- }
532
- function In(e) {
533
- for (var t = e.length; t > 0 && e[t - 1] === `
534
- `; ) t--;
535
- return e.substring(0, t);
536
- }
537
- var Mn = [
538
- "ADDRESS",
539
- "ARTICLE",
540
- "ASIDE",
541
- "AUDIO",
542
- "BLOCKQUOTE",
543
- "BODY",
544
- "CANVAS",
545
- "CENTER",
546
- "DD",
547
- "DIR",
548
- "DIV",
549
- "DL",
550
- "DT",
551
- "FIELDSET",
552
- "FIGCAPTION",
553
- "FIGURE",
554
- "FOOTER",
555
- "FORM",
556
- "FRAMESET",
557
- "H1",
558
- "H2",
559
- "H3",
560
- "H4",
561
- "H5",
562
- "H6",
563
- "HEADER",
564
- "HGROUP",
565
- "HR",
566
- "HTML",
567
- "ISINDEX",
568
- "LI",
569
- "MAIN",
570
- "MENU",
571
- "NAV",
572
- "NOFRAMES",
573
- "NOSCRIPT",
574
- "OL",
575
- "OUTPUT",
576
- "P",
577
- "PRE",
578
- "SECTION",
579
- "TABLE",
580
- "TBODY",
581
- "TD",
582
- "TFOOT",
583
- "TH",
584
- "THEAD",
585
- "TR",
586
- "UL"
587
- ];
588
- function Ge(e) {
589
- return Ye(e, Mn);
590
- }
591
- var wt = [
592
- "AREA",
593
- "BASE",
594
- "BR",
595
- "COL",
596
- "COMMAND",
597
- "EMBED",
598
- "HR",
599
- "IMG",
600
- "INPUT",
601
- "KEYGEN",
602
- "LINK",
603
- "META",
604
- "PARAM",
605
- "SOURCE",
606
- "TRACK",
607
- "WBR"
608
- ];
609
- function kt(e) {
610
- return Ye(e, wt);
611
- }
612
- function wn(e) {
613
- return Pt(e, wt);
614
- }
615
- var xt = [
616
- "A",
617
- "TABLE",
618
- "THEAD",
619
- "TBODY",
620
- "TFOOT",
621
- "TH",
622
- "TD",
623
- "IFRAME",
624
- "SCRIPT",
625
- "AUDIO",
626
- "VIDEO"
627
- ];
628
- function kn(e) {
629
- return Ye(e, xt);
630
- }
631
- function xn(e) {
632
- return Pt(e, xt);
633
- }
634
- function Ye(e, t) {
635
- return t.indexOf(e.nodeName) >= 0;
636
- }
637
- function Pt(e, t) {
638
- return e.getElementsByTagName && t.some(function(r) {
639
- return e.getElementsByTagName(r).length;
640
- });
641
- }
642
- var _ = {};
643
- _.paragraph = {
644
- filter: "p",
645
- replacement: function(e) {
646
- return `
647
-
648
- ` + e + `
649
-
650
- `;
651
- }
652
- };
653
- _.lineBreak = {
654
- filter: "br",
655
- replacement: function(e, t, r) {
656
- return r.br + `
657
- `;
658
- }
659
- };
660
- _.heading = {
661
- filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
662
- replacement: function(e, t, r) {
663
- var i = Number(t.nodeName.charAt(1));
664
- if (r.headingStyle === "setext" && i < 3) {
665
- var s = ze(i === 1 ? "=" : "-", e.length);
666
- return `
667
-
668
- ` + e + `
669
- ` + s + `
670
-
671
- `;
672
- } else
673
- return `
674
-
675
- ` + ze("#", i) + " " + e + `
676
-
677
- `;
678
- }
679
- };
680
- _.blockquote = {
681
- filter: "blockquote",
682
- replacement: function(e) {
683
- return e = e.replace(/^\n+|\n+$/g, ""), e = e.replace(/^/gm, "> "), `
684
-
685
- ` + e + `
686
-
687
- `;
688
- }
689
- };
690
- _.list = {
691
- filter: ["ul", "ol"],
692
- replacement: function(e, t) {
693
- var r = t.parentNode;
694
- return r.nodeName === "LI" && r.lastElementChild === t ? `
695
- ` + e : `
696
-
697
- ` + e + `
698
-
699
- `;
700
- }
701
- };
702
- _.listItem = {
703
- filter: "li",
704
- replacement: function(e, t, r) {
705
- e = e.replace(/^\n+/, "").replace(/\n+$/, `
706
- `).replace(/\n/gm, `
707
- `);
708
- var i = r.bulletListMarker + " ", s = t.parentNode;
709
- if (s.nodeName === "OL") {
710
- var c = s.getAttribute("start"), p = Array.prototype.indexOf.call(s.children, t);
711
- i = (c ? Number(c) + p : p + 1) + ". ";
712
- }
713
- return i + e + (t.nextSibling && !/\n$/.test(e) ? `
714
- ` : "");
715
- }
716
- };
717
- _.indentedCodeBlock = {
718
- filter: function(e, t) {
719
- return t.codeBlockStyle === "indented" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
720
- },
721
- replacement: function(e, t, r) {
722
- return `
723
-
724
- ` + t.firstChild.textContent.replace(/\n/g, `
725
- `) + `
726
-
727
- `;
728
- }
729
- };
730
- _.fencedCodeBlock = {
731
- filter: function(e, t) {
732
- return t.codeBlockStyle === "fenced" && e.nodeName === "PRE" && e.firstChild && e.firstChild.nodeName === "CODE";
733
- },
734
- replacement: function(e, t, r) {
735
- for (var i = t.firstChild.getAttribute("class") || "", s = (i.match(/language-(\S+)/) || [null, ""])[1], c = t.firstChild.textContent, p = r.fence.charAt(0), L = 3, m = new RegExp("^" + p + "{3,}", "gm"), S; S = m.exec(c); )
736
- S[0].length >= L && (L = S[0].length + 1);
737
- var F = ze(p, L);
738
- return `
739
-
740
- ` + F + s + `
741
- ` + c.replace(/\n$/, "") + `
742
- ` + F + `
743
-
744
- `;
745
- }
746
- };
747
- _.horizontalRule = {
748
- filter: "hr",
749
- replacement: function(e, t, r) {
750
- return `
751
-
752
- ` + r.hr + `
753
-
754
- `;
755
- }
756
- };
757
- _.inlineLink = {
758
- filter: function(e, t) {
759
- return t.linkStyle === "inlined" && e.nodeName === "A" && e.getAttribute("href");
760
- },
761
- replacement: function(e, t) {
762
- var r = t.getAttribute("href");
763
- r && (r = r.replace(/([()])/g, "\\$1"));
764
- var i = de(t.getAttribute("title"));
765
- return i && (i = ' "' + i.replace(/"/g, '\\"') + '"'), "[" + e + "](" + r + i + ")";
766
- }
767
- };
768
- _.referenceLink = {
769
- filter: function(e, t) {
770
- return t.linkStyle === "referenced" && e.nodeName === "A" && e.getAttribute("href");
771
- },
772
- replacement: function(e, t, r) {
773
- var i = t.getAttribute("href"), s = de(t.getAttribute("title"));
774
- s && (s = ' "' + s + '"');
775
- var c, p;
776
- switch (r.linkReferenceStyle) {
777
- case "collapsed":
778
- c = "[" + e + "][]", p = "[" + e + "]: " + i + s;
779
- break;
780
- case "shortcut":
781
- c = "[" + e + "]", p = "[" + e + "]: " + i + s;
782
- break;
783
- default:
784
- var L = this.references.length + 1;
785
- c = "[" + e + "][" + L + "]", p = "[" + L + "]: " + i + s;
786
- }
787
- return this.references.push(p), c;
788
- },
789
- references: [],
790
- append: function(e) {
791
- var t = "";
792
- return this.references.length && (t = `
793
-
794
- ` + this.references.join(`
795
- `) + `
796
-
797
- `, this.references = []), t;
798
- }
799
- };
800
- _.emphasis = {
801
- filter: ["em", "i"],
802
- replacement: function(e, t, r) {
803
- return e.trim() ? r.emDelimiter + e + r.emDelimiter : "";
804
- }
805
- };
806
- _.strong = {
807
- filter: ["strong", "b"],
808
- replacement: function(e, t, r) {
809
- return e.trim() ? r.strongDelimiter + e + r.strongDelimiter : "";
810
- }
811
- };
812
- _.code = {
813
- filter: function(e) {
814
- var t = e.previousSibling || e.nextSibling, r = e.parentNode.nodeName === "PRE" && !t;
815
- return e.nodeName === "CODE" && !r;
816
- },
817
- replacement: function(e) {
818
- if (!e) return "";
819
- e = e.replace(/\r?\n|\r/g, " ");
820
- for (var t = /^`|^ .*?[^ ].* $|`$/.test(e) ? " " : "", r = "`", i = e.match(/`+/gm) || []; i.indexOf(r) !== -1; ) r = r + "`";
821
- return r + t + e + t + r;
822
- }
823
- };
824
- _.image = {
825
- filter: "img",
826
- replacement: function(e, t) {
827
- var r = de(t.getAttribute("alt")), i = t.getAttribute("src") || "", s = de(t.getAttribute("title")), c = s ? ' "' + s + '"' : "";
828
- return i ? "![" + r + "](" + i + c + ")" : "";
829
- }
830
- };
831
- function de(e) {
832
- return e ? e.replace(/(\n+\s*)+/g, `
833
- `) : "";
834
- }
835
- function Ut(e) {
836
- this.options = e, this._keep = [], this._remove = [], this.blankRule = {
837
- replacement: e.blankReplacement
838
- }, this.keepReplacement = e.keepReplacement, this.defaultRule = {
839
- replacement: e.defaultReplacement
840
- }, this.array = [];
841
- for (var t in e.rules) this.array.push(e.rules[t]);
842
- }
843
- Ut.prototype = {
844
- add: function(e, t) {
845
- this.array.unshift(t);
846
- },
847
- keep: function(e) {
848
- this._keep.unshift({
849
- filter: e,
850
- replacement: this.keepReplacement
851
- });
852
- },
853
- remove: function(e) {
854
- this._remove.unshift({
855
- filter: e,
856
- replacement: function() {
857
- return "";
858
- }
859
- });
860
- },
861
- forNode: function(e) {
862
- if (e.isBlank) return this.blankRule;
863
- var t;
864
- return (t = Pe(this.array, e, this.options)) || (t = Pe(this._keep, e, this.options)) || (t = Pe(this._remove, e, this.options)) ? t : this.defaultRule;
865
- },
866
- forEach: function(e) {
867
- for (var t = 0; t < this.array.length; t++) e(this.array[t], t);
868
- }
869
- };
870
- function Pe(e, t, r) {
871
- for (var i = 0; i < e.length; i++) {
872
- var s = e[i];
873
- if (Pn(s, t, r)) return s;
874
- }
875
- }
876
- function Pn(e, t, r) {
877
- var i = e.filter;
878
- if (typeof i == "string") {
879
- if (i === t.nodeName.toLowerCase()) return !0;
880
- } else if (Array.isArray(i)) {
881
- if (i.indexOf(t.nodeName.toLowerCase()) > -1) return !0;
882
- } else if (typeof i == "function") {
883
- if (i.call(e, t, r)) return !0;
884
- } else
885
- throw new TypeError("`filter` needs to be a string, array, or function");
886
- }
887
- function Un(e) {
888
- var t = e.element, r = e.isBlock, i = e.isVoid, s = e.isPre || function(he) {
889
- return he.nodeName === "PRE";
890
- };
891
- if (!(!t.firstChild || s(t))) {
892
- for (var c = null, p = !1, L = null, m = vt(L, t, s); m !== t; ) {
893
- if (m.nodeType === 3 || m.nodeType === 4) {
894
- var S = m.data.replace(/[ \r\n\t]+/g, " ");
895
- if ((!c || / $/.test(c.data)) && !p && S[0] === " " && (S = S.substr(1)), !S) {
896
- m = Ue(m);
897
- continue;
898
- }
899
- m.data = S, c = m;
900
- } else if (m.nodeType === 1)
901
- r(m) || m.nodeName === "BR" ? (c && (c.data = c.data.replace(/ $/, "")), c = null, p = !1) : i(m) || s(m) ? (c = null, p = !0) : c && (p = !1);
902
- else {
903
- m = Ue(m);
904
- continue;
905
- }
906
- var F = vt(L, m, s);
907
- L = m, m = F;
908
- }
909
- c && (c.data = c.data.replace(/ $/, ""), c.data || Ue(c));
910
- }
911
- }
912
- function Ue(e) {
913
- var t = e.nextSibling || e.parentNode;
914
- return e.parentNode.removeChild(e), t;
915
- }
916
- function vt(e, t, r) {
917
- return e && e.parentNode === t || r(t) ? t.nextSibling || t.parentNode : t.firstChild || t.nextSibling || t.parentNode;
918
- }
919
- var $e = typeof window < "u" ? window : {};
920
- function Fn() {
921
- var e = $e.DOMParser, t = !1;
922
- try {
923
- new e().parseFromString("", "text/html") && (t = !0);
924
- } catch {
925
- }
926
- return t;
927
- }
928
- function Hn() {
929
- var e = function() {
930
- };
931
- return Bn() ? e.prototype.parseFromString = function(t) {
932
- var r = new window.ActiveXObject("htmlfile");
933
- return r.designMode = "on", r.open(), r.write(t), r.close(), r;
934
- } : e.prototype.parseFromString = function(t) {
935
- var r = document.implementation.createHTMLDocument("");
936
- return r.open(), r.write(t), r.close(), r;
937
- }, e;
938
- }
939
- function Bn() {
940
- var e = !1;
941
- try {
942
- document.implementation.createHTMLDocument("").open();
943
- } catch {
944
- $e.ActiveXObject && (e = !0);
945
- }
946
- return e;
947
- }
948
- var zn = Fn() ? $e.DOMParser : Hn();
949
- function Wn(e, t) {
950
- var r;
951
- if (typeof e == "string") {
952
- var i = Gn().parseFromString(
953
- // DOM parsers arrange elements in the <head> and <body>.
954
- // Wrapping in a custom element ensures elements are reliably arranged in
955
- // a single element.
956
- '<x-turndown id="turndown-root">' + e + "</x-turndown>",
957
- "text/html"
958
- );
959
- r = i.getElementById("turndown-root");
960
- } else
961
- r = e.cloneNode(!0);
962
- return Un({
963
- element: r,
964
- isBlock: Ge,
965
- isVoid: kt,
966
- isPre: t.preformattedCode ? Yn : null
967
- }), r;
968
- }
969
- var Fe;
970
- function Gn() {
971
- return Fe = Fe || new zn(), Fe;
972
- }
973
- function Yn(e) {
974
- return e.nodeName === "PRE" || e.nodeName === "CODE";
975
- }
976
- function $n(e, t) {
977
- return e.isBlock = Ge(e), e.isCode = e.nodeName === "CODE" || e.parentNode.isCode, e.isBlank = Vn(e), e.flankingWhitespace = Xn(e, t), e;
978
- }
979
- function Vn(e) {
980
- return !kt(e) && !kn(e) && /^\s*$/i.test(e.textContent) && !wn(e) && !xn(e);
981
- }
982
- function Xn(e, t) {
983
- if (e.isBlock || t.preformattedCode && e.isCode)
984
- return { leading: "", trailing: "" };
985
- var r = jn(e.textContent);
986
- return r.leadingAscii && bt("left", e, t) && (r.leading = r.leadingNonAscii), r.trailingAscii && bt("right", e, t) && (r.trailing = r.trailingNonAscii), { leading: r.leading, trailing: r.trailing };
987
- }
988
- function jn(e) {
989
- var t = e.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
990
- return {
991
- leading: t[1],
992
- // whole string for whitespace-only strings
993
- leadingAscii: t[2],
994
- leadingNonAscii: t[3],
995
- trailing: t[4],
996
- // empty for whitespace-only strings
997
- trailingNonAscii: t[5],
998
- trailingAscii: t[6]
999
- };
1000
- }
1001
- function bt(e, t, r) {
1002
- var i, s, c;
1003
- return e === "left" ? (i = t.previousSibling, s = / $/) : (i = t.nextSibling, s = /^ /), i && (i.nodeType === 3 ? c = s.test(i.nodeValue) : r.preformattedCode && i.nodeName === "CODE" ? c = !1 : i.nodeType === 1 && !Ge(i) && (c = s.test(i.textContent))), c;
1004
- }
1005
- var Kn = Array.prototype.reduce, qn = [
1006
- [/\\/g, "\\\\"],
1007
- [/\*/g, "\\*"],
1008
- [/^-/g, "\\-"],
1009
- [/^\+ /g, "\\+ "],
1010
- [/^(=+)/g, "\\$1"],
1011
- [/^(#{1,6}) /g, "\\$1 "],
1012
- [/`/g, "\\`"],
1013
- [/^~~~/g, "\\~~~"],
1014
- [/\[/g, "\\["],
1015
- [/\]/g, "\\]"],
1016
- [/^>/g, "\\>"],
1017
- [/_/g, "\\_"],
1018
- [/^(\d+)\. /g, "$1\\. "]
1019
- ];
1020
- function We(e) {
1021
- if (!(this instanceof We)) return new We(e);
1022
- var t = {
1023
- rules: _,
1024
- headingStyle: "setext",
1025
- hr: "* * *",
1026
- bulletListMarker: "*",
1027
- codeBlockStyle: "indented",
1028
- fence: "```",
1029
- emDelimiter: "_",
1030
- strongDelimiter: "**",
1031
- linkStyle: "inlined",
1032
- linkReferenceStyle: "full",
1033
- br: " ",
1034
- preformattedCode: !1,
1035
- blankReplacement: function(r, i) {
1036
- return i.isBlock ? `
1037
-
1038
- ` : "";
1039
- },
1040
- keepReplacement: function(r, i) {
1041
- return i.isBlock ? `
1042
-
1043
- ` + i.outerHTML + `
1044
-
1045
- ` : i.outerHTML;
1046
- },
1047
- defaultReplacement: function(r, i) {
1048
- return i.isBlock ? `
1049
-
1050
- ` + r + `
1051
-
1052
- ` : r;
1053
- }
1054
- };
1055
- this.options = Dn({}, t, e), this.rules = new Ut(this.options);
1056
- }
1057
- We.prototype = {
1058
- /**
1059
- * The entry point for converting a string or DOM node to Markdown
1060
- * @public
1061
- * @param {String|HTMLElement} input The string or DOM node to convert
1062
- * @returns A Markdown representation of the input
1063
- * @type String
1064
- */
1065
- turndown: function(e) {
1066
- if (!Jn(e))
1067
- throw new TypeError(
1068
- e + " is not a string, or an element/document/fragment node."
1069
- );
1070
- if (e === "") return "";
1071
- var t = Ft.call(this, new Wn(e, this.options));
1072
- return Zn.call(this, t);
1073
- },
1074
- /**
1075
- * Add one or more plugins
1076
- * @public
1077
- * @param {Function|Array} plugin The plugin or array of plugins to add
1078
- * @returns The Turndown instance for chaining
1079
- * @type Object
1080
- */
1081
- use: function(e) {
1082
- if (Array.isArray(e))
1083
- for (var t = 0; t < e.length; t++) this.use(e[t]);
1084
- else if (typeof e == "function")
1085
- e(this);
1086
- else
1087
- throw new TypeError("plugin must be a Function or an Array of Functions");
1088
- return this;
1089
- },
1090
- /**
1091
- * Adds a rule
1092
- * @public
1093
- * @param {String} key The unique key of the rule
1094
- * @param {Object} rule The rule
1095
- * @returns The Turndown instance for chaining
1096
- * @type Object
1097
- */
1098
- addRule: function(e, t) {
1099
- return this.rules.add(e, t), this;
1100
- },
1101
- /**
1102
- * Keep a node (as HTML) that matches the filter
1103
- * @public
1104
- * @param {String|Array|Function} filter The unique key of the rule
1105
- * @returns The Turndown instance for chaining
1106
- * @type Object
1107
- */
1108
- keep: function(e) {
1109
- return this.rules.keep(e), this;
1110
- },
1111
- /**
1112
- * Remove a node that matches the filter
1113
- * @public
1114
- * @param {String|Array|Function} filter The unique key of the rule
1115
- * @returns The Turndown instance for chaining
1116
- * @type Object
1117
- */
1118
- remove: function(e) {
1119
- return this.rules.remove(e), this;
1120
- },
1121
- /**
1122
- * Escapes Markdown syntax
1123
- * @public
1124
- * @param {String} string The string to escape
1125
- * @returns A string with Markdown syntax escaped
1126
- * @type String
1127
- */
1128
- escape: function(e) {
1129
- return qn.reduce(function(t, r) {
1130
- return t.replace(r[0], r[1]);
1131
- }, e);
1132
- }
1133
- };
1134
- function Ft(e) {
1135
- var t = this;
1136
- return Kn.call(e.childNodes, function(r, i) {
1137
- i = new $n(i, t.options);
1138
- var s = "";
1139
- return i.nodeType === 3 ? s = i.isCode ? i.nodeValue : t.escape(i.nodeValue) : i.nodeType === 1 && (s = Qn.call(t, i)), Ht(r, s);
1140
- }, "");
1141
- }
1142
- function Zn(e) {
1143
- var t = this;
1144
- return this.rules.forEach(function(r) {
1145
- typeof r.append == "function" && (e = Ht(e, r.append(t.options)));
1146
- }), e.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
1147
- }
1148
- function Qn(e) {
1149
- var t = this.rules.forNode(e), r = Ft.call(this, e), i = e.flankingWhitespace;
1150
- return (i.leading || i.trailing) && (r = r.trim()), i.leading + t.replacement(r, e, this.options) + i.trailing;
1151
- }
1152
- function Ht(e, t) {
1153
- var r = In(e), i = Cn(t), s = Math.max(e.length - r.length, t.length - i.length), c = `
1154
-
1155
- `.substring(0, s);
1156
- return r + c + i;
1157
- }
1158
- function Jn(e) {
1159
- return e != null && (typeof e == "string" || e.nodeType && (e.nodeType === 1 || e.nodeType === 9 || e.nodeType === 11));
1160
- }
1161
- export {
1162
- We as T,
1163
- er as p
1164
- };