@lakamark/modulo-editor 0.2.0-alpha.1

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 (149) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +73 -0
  3. package/dist/modulo-editor.js +1018 -0
  4. package/dist/modulo-editor.js.map +1 -0
  5. package/dist/modulo-editor.umd.cjs +5 -0
  6. package/dist/modulo-editor.umd.cjs.map +1 -0
  7. package/dist/types/commands/builtin/BoldCommand.d.ts +9 -0
  8. package/dist/types/commands/builtin/BoldCommand.d.ts.map +1 -0
  9. package/dist/types/commands/builtin/HeadingCommand.d.ts +8 -0
  10. package/dist/types/commands/builtin/HeadingCommand.d.ts.map +1 -0
  11. package/dist/types/commands/builtin/ItalicCommand.d.ts +6 -0
  12. package/dist/types/commands/builtin/ItalicCommand.d.ts.map +1 -0
  13. package/dist/types/commands/builtin/index.d.ts +11 -0
  14. package/dist/types/commands/builtin/index.d.ts.map +1 -0
  15. package/dist/types/commands/contracts/EditorCommand.d.ts +18 -0
  16. package/dist/types/commands/contracts/EditorCommand.d.ts.map +1 -0
  17. package/dist/types/commands/contracts/EditorCommandContext.d.ts +15 -0
  18. package/dist/types/commands/contracts/EditorCommandContext.d.ts.map +1 -0
  19. package/dist/types/commands/contracts/EditorInput.d.ts +14 -0
  20. package/dist/types/commands/contracts/EditorInput.d.ts.map +1 -0
  21. package/dist/types/commands/contracts/index.d.ts +4 -0
  22. package/dist/types/commands/contracts/index.d.ts.map +1 -0
  23. package/dist/types/commands/index.d.ts +5 -0
  24. package/dist/types/commands/index.d.ts.map +1 -0
  25. package/dist/types/commands/registry/EditorCommandRegistry.d.ts +28 -0
  26. package/dist/types/commands/registry/EditorCommandRegistry.d.ts.map +1 -0
  27. package/dist/types/commands/registry/EditorCommandsApi.d.ts +14 -0
  28. package/dist/types/commands/registry/EditorCommandsApi.d.ts.map +1 -0
  29. package/dist/types/commands/registry/RegistryEditorCommandsApi.d.ts +20 -0
  30. package/dist/types/commands/registry/RegistryEditorCommandsApi.d.ts.map +1 -0
  31. package/dist/types/commands/registry/index.d.ts +4 -0
  32. package/dist/types/commands/registry/index.d.ts.map +1 -0
  33. package/dist/types/commands/setup/assertCustomCommandsAreValid.d.ts +12 -0
  34. package/dist/types/commands/setup/assertCustomCommandsAreValid.d.ts.map +1 -0
  35. package/dist/types/commands/setup/builtin-command-names.d.ts +16 -0
  36. package/dist/types/commands/setup/builtin-command-names.d.ts.map +1 -0
  37. package/dist/types/commands/setup/index.d.ts +6 -0
  38. package/dist/types/commands/setup/index.d.ts.map +1 -0
  39. package/dist/types/commands/setup/resolveBuiltinCommands.d.ts +4 -0
  40. package/dist/types/commands/setup/resolveBuiltinCommands.d.ts.map +1 -0
  41. package/dist/types/commands/setup/setupEditorCommands.d.ts +30 -0
  42. package/dist/types/commands/setup/setupEditorCommands.d.ts.map +1 -0
  43. package/dist/types/core/Builder/DefaultModuloEditorBuilder.d.ts +117 -0
  44. package/dist/types/core/Builder/DefaultModuloEditorBuilder.d.ts.map +1 -0
  45. package/dist/types/core/Builder/index.d.ts +2 -0
  46. package/dist/types/core/Builder/index.d.ts.map +1 -0
  47. package/dist/types/core/DefaultEditorDocument.d.ts +11 -0
  48. package/dist/types/core/DefaultEditorDocument.d.ts.map +1 -0
  49. package/dist/types/core/ModuloEditor.d.ts +93 -0
  50. package/dist/types/core/ModuloEditor.d.ts.map +1 -0
  51. package/dist/types/core/contracts/EditorDocument.d.ts +16 -0
  52. package/dist/types/core/contracts/EditorDocument.d.ts.map +1 -0
  53. package/dist/types/core/contracts/ModuloEditorBuilder.d.ts +23 -0
  54. package/dist/types/core/contracts/ModuloEditorBuilder.d.ts.map +1 -0
  55. package/dist/types/core/contracts/ModuloEditorOptions.d.ts +52 -0
  56. package/dist/types/core/contracts/ModuloEditorOptions.d.ts.map +1 -0
  57. package/dist/types/core/contracts/index.d.ts +4 -0
  58. package/dist/types/core/contracts/index.d.ts.map +1 -0
  59. package/dist/types/core/index.d.ts +6 -0
  60. package/dist/types/core/index.d.ts.map +1 -0
  61. package/dist/types/dom/DefaultEditorDomResolver.d.ts +42 -0
  62. package/dist/types/dom/DefaultEditorDomResolver.d.ts.map +1 -0
  63. package/dist/types/dom/contracts/EditorDomResolver.d.ts +20 -0
  64. package/dist/types/dom/contracts/EditorDomResolver.d.ts.map +1 -0
  65. package/dist/types/dom/contracts/EditorDomSlots.d.ts +62 -0
  66. package/dist/types/dom/contracts/EditorDomSlots.d.ts.map +1 -0
  67. package/dist/types/dom/contracts/index.d.ts +3 -0
  68. package/dist/types/dom/contracts/index.d.ts.map +1 -0
  69. package/dist/types/dom/index.d.ts +2 -0
  70. package/dist/types/dom/index.d.ts.map +1 -0
  71. package/dist/types/index.d.ts +7 -0
  72. package/dist/types/index.d.ts.map +1 -0
  73. package/dist/types/input/EditorInputAdapter.d.ts +17 -0
  74. package/dist/types/input/EditorInputAdapter.d.ts.map +1 -0
  75. package/dist/types/input/EditorInputState.d.ts +6 -0
  76. package/dist/types/input/EditorInputState.d.ts.map +1 -0
  77. package/dist/types/input/TextareaInputAdapter.d.ts +18 -0
  78. package/dist/types/input/TextareaInputAdapter.d.ts.map +1 -0
  79. package/dist/types/input/index.d.ts +4 -0
  80. package/dist/types/input/index.d.ts.map +1 -0
  81. package/dist/types/markdown/config/ConfigurableHtmlSanitizer.d.ts +23 -0
  82. package/dist/types/markdown/config/ConfigurableHtmlSanitizer.d.ts.map +1 -0
  83. package/dist/types/markdown/config/DefaultHtmlSanitizerConfig.d.ts +6 -0
  84. package/dist/types/markdown/config/DefaultHtmlSanitizerConfig.d.ts.map +1 -0
  85. package/dist/types/markdown/config/HtmlSanitizerConfig.d.ts +14 -0
  86. package/dist/types/markdown/config/HtmlSanitizerConfig.d.ts.map +1 -0
  87. package/dist/types/markdown/config/index.d.ts +4 -0
  88. package/dist/types/markdown/config/index.d.ts.map +1 -0
  89. package/dist/types/markdown/contracts/HtmlSanitizer.d.ts +15 -0
  90. package/dist/types/markdown/contracts/HtmlSanitizer.d.ts.map +1 -0
  91. package/dist/types/markdown/contracts/MarkdownParser.d.ts +12 -0
  92. package/dist/types/markdown/contracts/MarkdownParser.d.ts.map +1 -0
  93. package/dist/types/markdown/contracts/MarkdownProcessor.d.ts +12 -0
  94. package/dist/types/markdown/contracts/MarkdownProcessor.d.ts.map +1 -0
  95. package/dist/types/markdown/contracts/index.d.ts +4 -0
  96. package/dist/types/markdown/contracts/index.d.ts.map +1 -0
  97. package/dist/types/markdown/index.d.ts +6 -0
  98. package/dist/types/markdown/index.d.ts.map +1 -0
  99. package/dist/types/markdown/parser/DefaultMarkdownProcessor.d.ts +18 -0
  100. package/dist/types/markdown/parser/DefaultMarkdownProcessor.d.ts.map +1 -0
  101. package/dist/types/markdown/parser/PlainTextMarkdownParser.d.ts +11 -0
  102. package/dist/types/markdown/parser/PlainTextMarkdownParser.d.ts.map +1 -0
  103. package/dist/types/markdown/parser/index.d.ts +3 -0
  104. package/dist/types/markdown/parser/index.d.ts.map +1 -0
  105. package/dist/types/markdown/sanitizers/DomPurifyHtmlSanitizer.d.ts +27 -0
  106. package/dist/types/markdown/sanitizers/DomPurifyHtmlSanitizer.d.ts.map +1 -0
  107. package/dist/types/markdown/sanitizers/NoopHtmlSanitizer.d.ts +11 -0
  108. package/dist/types/markdown/sanitizers/NoopHtmlSanitizer.d.ts.map +1 -0
  109. package/dist/types/markdown/sanitizers/index.d.ts +3 -0
  110. package/dist/types/markdown/sanitizers/index.d.ts.map +1 -0
  111. package/dist/types/output/EditorOutputAdapter.d.ts +25 -0
  112. package/dist/types/output/EditorOutputAdapter.d.ts.map +1 -0
  113. package/dist/types/output/HtmlPreviewAdapter.d.ts +20 -0
  114. package/dist/types/output/HtmlPreviewAdapter.d.ts.map +1 -0
  115. package/dist/types/output/index.d.ts +3 -0
  116. package/dist/types/output/index.d.ts.map +1 -0
  117. package/dist/types/plugins/contracts/EditorPlugin.d.ts +19 -0
  118. package/dist/types/plugins/contracts/EditorPlugin.d.ts.map +1 -0
  119. package/dist/types/plugins/contracts/EditorPluginApi.d.ts +11 -0
  120. package/dist/types/plugins/contracts/EditorPluginApi.d.ts.map +1 -0
  121. package/dist/types/plugins/contracts/index.d.ts +3 -0
  122. package/dist/types/plugins/contracts/index.d.ts.map +1 -0
  123. package/dist/types/plugins/index.d.ts +3 -0
  124. package/dist/types/plugins/index.d.ts.map +1 -0
  125. package/dist/types/plugins/toolbar/base/CommandButtonPlugin.d.ts +31 -0
  126. package/dist/types/plugins/toolbar/base/CommandButtonPlugin.d.ts.map +1 -0
  127. package/dist/types/plugins/toolbar/base/CommandButtonPluginOptions.d.ts +23 -0
  128. package/dist/types/plugins/toolbar/base/CommandButtonPluginOptions.d.ts.map +1 -0
  129. package/dist/types/plugins/toolbar/base/index.d.ts +3 -0
  130. package/dist/types/plugins/toolbar/base/index.d.ts.map +1 -0
  131. package/dist/types/plugins/toolbar/buttons/BoldToolbarPlugin.d.ts +8 -0
  132. package/dist/types/plugins/toolbar/buttons/BoldToolbarPlugin.d.ts.map +1 -0
  133. package/dist/types/plugins/toolbar/buttons/HeadingToolbarPlugin.d.ts +5 -0
  134. package/dist/types/plugins/toolbar/buttons/HeadingToolbarPlugin.d.ts.map +1 -0
  135. package/dist/types/plugins/toolbar/buttons/ItalicToolbarPlugin.d.ts +5 -0
  136. package/dist/types/plugins/toolbar/buttons/ItalicToolbarPlugin.d.ts.map +1 -0
  137. package/dist/types/plugins/toolbar/buttons/index.d.ts +4 -0
  138. package/dist/types/plugins/toolbar/buttons/index.d.ts.map +1 -0
  139. package/dist/types/plugins/toolbar/createDefaultToolbarPlugins.d.ts +6 -0
  140. package/dist/types/plugins/toolbar/createDefaultToolbarPlugins.d.ts.map +1 -0
  141. package/dist/types/plugins/toolbar/index.d.ts +4 -0
  142. package/dist/types/plugins/toolbar/index.d.ts.map +1 -0
  143. package/dist/types/textarea/HiddenTextareaBridge.d.ts +12 -0
  144. package/dist/types/textarea/HiddenTextareaBridge.d.ts.map +1 -0
  145. package/dist/types/textarea/TextareaBridge.d.ts +24 -0
  146. package/dist/types/textarea/TextareaBridge.d.ts.map +1 -0
  147. package/dist/types/textarea/index.d.ts +3 -0
  148. package/dist/types/textarea/index.d.ts.map +1 -0
  149. package/package.json +71 -0
@@ -0,0 +1,1018 @@
1
+ //#region src/commands/registry/EditorCommandRegistry.ts
2
+ var e = class {
3
+ commands = /* @__PURE__ */ new Map();
4
+ register(e) {
5
+ if (this.commands.has(e.name)) throw Error(`Editor command "${e.name}" is already registered.`);
6
+ this.commands.set(e.name, e);
7
+ }
8
+ get(e) {
9
+ return this.commands.get(e);
10
+ }
11
+ has(e) {
12
+ return this.commands.has(e);
13
+ }
14
+ all() {
15
+ return Array.from(this.commands.values());
16
+ }
17
+ execute(e, t) {
18
+ let n = this.get(e);
19
+ if (!n) throw Error(`Unknown editor command "${e}".`);
20
+ n.execute(t);
21
+ }
22
+ }, t = class {
23
+ registry;
24
+ contextResolver;
25
+ constructor(e, t) {
26
+ this.contextResolver = t, this.registry = e;
27
+ }
28
+ execute(e) {
29
+ let t = this.contextResolver();
30
+ this.registry.execute(e, t);
31
+ }
32
+ has(e) {
33
+ return this.registry.has(e);
34
+ }
35
+ }, n = [
36
+ "bold",
37
+ "italic",
38
+ "heading"
39
+ ];
40
+ function r(e) {
41
+ return n.includes(e);
42
+ }
43
+ //#endregion
44
+ //#region src/commands/setup/assertCustomCommandsAreValid.ts
45
+ function i(e) {
46
+ let t = /* @__PURE__ */ new Set();
47
+ for (let n of e) {
48
+ if (r(n.name)) throw Error(`Editor command "${n.name}" is reserved by the editor core.`);
49
+ if (t.has(n.name)) throw Error(`Editor command "${n.name}" is already defined.`);
50
+ t.add(n.name);
51
+ }
52
+ }
53
+ //#endregion
54
+ //#region src/commands/builtin/BoldCommand.ts
55
+ var a = class {
56
+ name = "bold";
57
+ execute(e) {
58
+ let { input: t, state: n } = e, { value: r, selectionStart: i, selectionEnd: a } = n, o = r.slice(0, i), s = r.slice(i, a), c = r.slice(a);
59
+ if (s.length > 0) {
60
+ let e = `${o}${`**${s}**`}${c}`;
61
+ t.setValue(e), t.focus(), t.setSelection(i + 2, a + 2);
62
+ return;
63
+ }
64
+ let l = `${o}****${c}`, u = i + 2;
65
+ t.setValue(l), t.focus(), t.setSelection(u, u);
66
+ }
67
+ }, o = class {
68
+ name = "italic";
69
+ execute(e) {
70
+ let { input: t, state: n } = e, { value: r, selectionStart: i, selectionEnd: a } = n, o = r.slice(0, i), s = r.slice(i, a), c = r.slice(a);
71
+ if (i === a) {
72
+ t.setValue(`${o}**${c}`), t.setSelection(i + 1, i + 1), t.focus();
73
+ return;
74
+ }
75
+ t.setValue(`${o}*${s}*${c}`), t.setSelection(i + 1, a + 1), t.focus();
76
+ }
77
+ }, s = class {
78
+ name;
79
+ level;
80
+ constructor(e) {
81
+ if (e < 1 || e > 6) throw Error("Heading level must be between 1 and 6.");
82
+ this.level = e, this.name = `heading-${e}`;
83
+ }
84
+ execute(e) {
85
+ let { input: t, state: n } = e, { value: r, selectionStart: i } = n, a = r.lastIndexOf("\n", i - 1) + 1, o = r.indexOf("\n", i), s = o === -1 ? r.length : o, c = r.slice(a, s), l = `${"#".repeat(this.level)} `, u = r.slice(0, a) + l + c + r.slice(s);
86
+ t.setValue(u), t.setSelection(i + l.length, i + l.length), t.focus();
87
+ }
88
+ };
89
+ //#endregion
90
+ //#region src/commands/builtin/index.ts
91
+ function c() {
92
+ return [
93
+ new a(),
94
+ new o(),
95
+ new s(1),
96
+ new s(2),
97
+ new s(3),
98
+ new s(4),
99
+ new s(5),
100
+ new s(6)
101
+ ];
102
+ }
103
+ //#endregion
104
+ //#region src/commands/setup/resolveBuiltinCommands.ts
105
+ function l(e) {
106
+ let t = c();
107
+ if (e === !1) return [];
108
+ if (e === !0 || e === void 0) return t;
109
+ let n = new Set(e);
110
+ return t.filter((e) => n.has(e.name));
111
+ }
112
+ //#endregion
113
+ //#region src/dom/DefaultEditorDomResolver.ts
114
+ var u = class {
115
+ resolve(e) {
116
+ let t = this.getDataAttribute(e, "header"), n = this.getDataAttribute(e, "toolbar"), r = this.getDataAttribute(e, "body"), i = this.getDataAttribute(e, "input"), a = this.getDataAttribute(e, "preview"), o = this.getDataAttribute(e, "footer"), s = this.getDataAttribute(e, "status"), c = this.getDataAttribute(e, "textarea");
117
+ if (!i) throw Error("ModuloEditor: missing [data-mo-editor-input].");
118
+ if (!a) throw Error("ModuloEditor: missing [data-mo-editor-preview].");
119
+ if (!c) throw Error("ModuloEditor: missing [data-mo-editor-textarea].");
120
+ return {
121
+ root: e,
122
+ header: t ?? null,
123
+ toolbar: n ?? null,
124
+ body: r ?? null,
125
+ input: i,
126
+ preview: a,
127
+ footer: o ?? null,
128
+ status: s ?? null,
129
+ textarea: c
130
+ };
131
+ }
132
+ getDataAttribute(e, t) {
133
+ let n = `[data-mo-editor-${t}]`;
134
+ return e.querySelector(n);
135
+ }
136
+ }, d = class {
137
+ content;
138
+ constructor(e = "") {
139
+ this.content = e;
140
+ }
141
+ getRawContent() {
142
+ return this.content;
143
+ }
144
+ setRawContent(e) {
145
+ this.content = e;
146
+ }
147
+ };
148
+ //#endregion
149
+ //#region src/commands/setup/setupEditorCommands.ts
150
+ function ee(e, t) {
151
+ let n = l(t.builtinCommands), r = t.commands ?? [];
152
+ i(r);
153
+ for (let t of n) e.register(t);
154
+ for (let t of r) e.register(t);
155
+ }
156
+ //#endregion
157
+ //#region src/input/TextareaInputAdapter.ts
158
+ var f = class {
159
+ textarea = null;
160
+ listeners = [];
161
+ mount(e, t) {
162
+ let n = document.createElement("textarea");
163
+ this.setTextareaAttributes(n, t), n.addEventListener("input", () => {
164
+ let e = n.value;
165
+ this.listeners.forEach((t) => {
166
+ t(e);
167
+ });
168
+ }), e.appendChild(n), this.textarea = n;
169
+ }
170
+ getState() {
171
+ let e = this.getElement();
172
+ return {
173
+ value: e.value,
174
+ selectionStart: e.selectionStart ?? 0,
175
+ selectionEnd: e.selectionEnd ?? 0
176
+ };
177
+ }
178
+ setSelection(e, t) {
179
+ this.getElement().setSelectionRange(e, t);
180
+ }
181
+ getValue() {
182
+ return this.textarea?.value ?? "";
183
+ }
184
+ setValue(e) {
185
+ this.textarea && (this.textarea.value = e);
186
+ }
187
+ focus() {
188
+ this.textarea?.focus();
189
+ }
190
+ onChange(e) {
191
+ return this.listeners.push(e), () => {
192
+ this.listeners = this.listeners.filter((t) => t !== e);
193
+ };
194
+ }
195
+ destroy() {
196
+ this.textarea?.remove(), this.textarea = null, this.listeners = [];
197
+ }
198
+ generateId() {
199
+ return `mo-editor-${Math.random().toString(36).slice(2)}`;
200
+ }
201
+ setTextareaAttributes(e, t) {
202
+ e.id = this.generateId(), e.className = "mo-editor__textarea", e.value = t, e.spellcheck = !1, e.ariaLabel = "Markdown editor";
203
+ }
204
+ getElement() {
205
+ if (!this.textarea) throw Error("Textarea input adapter is not mounted.");
206
+ return this.textarea;
207
+ }
208
+ }, p = class {
209
+ element = null;
210
+ mount(e) {
211
+ this.element = e;
212
+ }
213
+ render(e) {
214
+ this.element && (this.element.innerHTML = e);
215
+ }
216
+ destroy() {
217
+ this.element && (this.element.innerHTML = ""), this.element = null;
218
+ }
219
+ }, te = class {
220
+ textarea = null;
221
+ mount(e) {
222
+ this.textarea = e;
223
+ }
224
+ getValue() {
225
+ return this.textarea?.value ?? "";
226
+ }
227
+ setValue(e) {
228
+ this.textarea && (this.textarea.value = e);
229
+ }
230
+ destroy() {
231
+ this.textarea = null;
232
+ }
233
+ }, ne = class {
234
+ name;
235
+ commandName;
236
+ content;
237
+ button = null;
238
+ api = null;
239
+ constructor(e) {
240
+ this.name = e.pluginName, this.commandName = e.commandName, this.content = e.content;
241
+ }
242
+ setup(e) {
243
+ let t = e.slots.toolbar;
244
+ if (!t) return;
245
+ this.api = e;
246
+ let n = document.createElement("button");
247
+ n.type = "button", this.renderButtonContent(n), n.addEventListener("click", this.handleClick), t.appendChild(n), this.button = n;
248
+ }
249
+ destroy() {
250
+ this.button &&= (this.button.removeEventListener("click", this.handleClick), this.button.remove(), null), this.api = null;
251
+ }
252
+ renderButtonContent(e) {
253
+ let t = typeof this.content == "function" ? this.content() : this.content;
254
+ if (typeof t == "string") {
255
+ e.textContent = t;
256
+ return;
257
+ }
258
+ e.appendChild(t);
259
+ }
260
+ handleClick = () => {
261
+ this.api?.commands.has(this.commandName) && this.api.executeCommand(this.commandName);
262
+ };
263
+ }, re = class extends ne {
264
+ constructor() {
265
+ super({
266
+ pluginName: "toolbar-bold",
267
+ commandName: "bold",
268
+ content: "Bold"
269
+ });
270
+ }
271
+ }, ie = class extends ne {
272
+ constructor() {
273
+ super({
274
+ pluginName: "toolbar-italic",
275
+ commandName: "italic",
276
+ content: "Italic"
277
+ });
278
+ }
279
+ }, m = class extends ne {
280
+ constructor(e) {
281
+ super({
282
+ pluginName: `toolbar-heading-${e}`,
283
+ commandName: `heading-${e}`,
284
+ content: `H${e}`
285
+ });
286
+ }
287
+ };
288
+ //#endregion
289
+ //#region src/plugins/toolbar/createDefaultToolbarPlugins.ts
290
+ function h(e = {}) {
291
+ let { headings: t = [
292
+ 1,
293
+ 2,
294
+ 3
295
+ ] } = e;
296
+ return [
297
+ new re(),
298
+ new ie(),
299
+ ...t.map((e) => new m(e))
300
+ ];
301
+ }
302
+ //#endregion
303
+ //#region src/markdown/config/DefaultHtmlSanitizerConfig.ts
304
+ var g = {
305
+ allowedTags: [
306
+ "p",
307
+ "strong",
308
+ "em",
309
+ "code",
310
+ "pre",
311
+ "ul",
312
+ "ol",
313
+ "li",
314
+ "blockquote",
315
+ "a"
316
+ ],
317
+ allowedAttributes: { a: ["href", "title"] }
318
+ }, ae = class {
319
+ parse(e) {
320
+ let t = document.createElement("p");
321
+ return t.textContent = e, t.outerHTML;
322
+ }
323
+ }, oe = class {
324
+ parser;
325
+ sanitize;
326
+ constructor(e, t) {
327
+ this.parser = e, this.sanitize = t;
328
+ }
329
+ toHtml(e) {
330
+ let t = this.parser.parse(e);
331
+ return this.sanitize.sanitize(t);
332
+ }
333
+ }, { entries: se, setPrototypeOf: ce, isFrozen: le, getPrototypeOf: ue, getOwnPropertyDescriptor: _ } = Object, { freeze: v, seal: y, create: b } = Object, { apply: x, construct: S } = typeof Reflect < "u" && Reflect;
334
+ v ||= function(e) {
335
+ return e;
336
+ }, y ||= function(e) {
337
+ return e;
338
+ }, x ||= function(e, t) {
339
+ var n = [...arguments].slice(2);
340
+ return e.apply(t, n);
341
+ }, S ||= function(e) {
342
+ return new e(...[...arguments].slice(1));
343
+ };
344
+ var de = O(Array.prototype.forEach), fe = O(Array.prototype.lastIndexOf), pe = O(Array.prototype.pop), C = O(Array.prototype.push), me = O(Array.prototype.splice), he = O(String.prototype.toLowerCase), ge = O(String.prototype.toString), _e = O(String.prototype.match), w = O(String.prototype.replace), ve = O(String.prototype.indexOf), ye = O(String.prototype.trim), T = O(Object.prototype.hasOwnProperty), E = O(RegExp.prototype.test), D = be(TypeError);
345
+ function O(e) {
346
+ return function(t) {
347
+ t instanceof RegExp && (t.lastIndex = 0);
348
+ var n = [...arguments].slice(1);
349
+ return x(e, t, n);
350
+ };
351
+ }
352
+ function be(e) {
353
+ return function() {
354
+ return S(e, [...arguments]);
355
+ };
356
+ }
357
+ function k(e, t) {
358
+ let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : he;
359
+ ce && ce(e, null);
360
+ let r = t.length;
361
+ for (; r--;) {
362
+ let i = t[r];
363
+ if (typeof i == "string") {
364
+ let e = n(i);
365
+ e !== i && (le(t) || (t[r] = e), i = e);
366
+ }
367
+ e[i] = !0;
368
+ }
369
+ return e;
370
+ }
371
+ function xe(e) {
372
+ for (let t = 0; t < e.length; t++) T(e, t) || (e[t] = null);
373
+ return e;
374
+ }
375
+ function A(e) {
376
+ let t = b(null);
377
+ for (let [n, r] of se(e)) T(e, n) && (Array.isArray(r) ? t[n] = xe(r) : r && typeof r == "object" && r.constructor === Object ? t[n] = A(r) : t[n] = r);
378
+ return t;
379
+ }
380
+ function j(e, t) {
381
+ for (; e !== null;) {
382
+ let n = _(e, t);
383
+ if (n) {
384
+ if (n.get) return O(n.get);
385
+ if (typeof n.value == "function") return O(n.value);
386
+ }
387
+ e = ue(e);
388
+ }
389
+ function n() {
390
+ return null;
391
+ }
392
+ return n;
393
+ }
394
+ var Se = v(/* @__PURE__ */ "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".split(".")), Ce = v(/* @__PURE__ */ "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".split(".")), we = v([
395
+ "feBlend",
396
+ "feColorMatrix",
397
+ "feComponentTransfer",
398
+ "feComposite",
399
+ "feConvolveMatrix",
400
+ "feDiffuseLighting",
401
+ "feDisplacementMap",
402
+ "feDistantLight",
403
+ "feDropShadow",
404
+ "feFlood",
405
+ "feFuncA",
406
+ "feFuncB",
407
+ "feFuncG",
408
+ "feFuncR",
409
+ "feGaussianBlur",
410
+ "feImage",
411
+ "feMerge",
412
+ "feMergeNode",
413
+ "feMorphology",
414
+ "feOffset",
415
+ "fePointLight",
416
+ "feSpecularLighting",
417
+ "feSpotLight",
418
+ "feTile",
419
+ "feTurbulence"
420
+ ]), Te = v([
421
+ "animate",
422
+ "color-profile",
423
+ "cursor",
424
+ "discard",
425
+ "font-face",
426
+ "font-face-format",
427
+ "font-face-name",
428
+ "font-face-src",
429
+ "font-face-uri",
430
+ "foreignobject",
431
+ "hatch",
432
+ "hatchpath",
433
+ "mesh",
434
+ "meshgradient",
435
+ "meshpatch",
436
+ "meshrow",
437
+ "missing-glyph",
438
+ "script",
439
+ "set",
440
+ "solidcolor",
441
+ "unknown",
442
+ "use"
443
+ ]), Ee = v(/* @__PURE__ */ "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".split(".")), De = v([
444
+ "maction",
445
+ "maligngroup",
446
+ "malignmark",
447
+ "mlongdiv",
448
+ "mscarries",
449
+ "mscarry",
450
+ "msgroup",
451
+ "mstack",
452
+ "msline",
453
+ "msrow",
454
+ "semantics",
455
+ "annotation",
456
+ "annotation-xml",
457
+ "mprescripts",
458
+ "none"
459
+ ]), Oe = v(["#text"]), ke = v(/* @__PURE__ */ "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".split(".")), Ae = v(/* @__PURE__ */ "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".split(".")), je = v(/* @__PURE__ */ "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".split(".")), Me = v([
460
+ "xlink:href",
461
+ "xml:id",
462
+ "xlink:title",
463
+ "xml:space",
464
+ "xmlns:xlink"
465
+ ]), Ne = y(/\{\{[\w\W]*|[\w\W]*\}\}/gm), Pe = y(/<%[\w\W]*|[\w\W]*%>/gm), Fe = y(/\$\{[\w\W]*/gm), M = y(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ie = y(/^aria-[\-\w]+$/), Le = y(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), N = y(/^(?:\w+script|data):/i), Re = y(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), ze = y(/^html$/i), P = y(/^[a-z][.\w]*(-[.\w]+)+$/i), Be = /* @__PURE__ */ Object.freeze({
466
+ __proto__: null,
467
+ ARIA_ATTR: Ie,
468
+ ATTR_WHITESPACE: Re,
469
+ CUSTOM_ELEMENT: P,
470
+ DATA_ATTR: M,
471
+ DOCTYPE_NAME: ze,
472
+ ERB_EXPR: Pe,
473
+ IS_ALLOWED_URI: Le,
474
+ IS_SCRIPT_OR_DATA: N,
475
+ MUSTACHE_EXPR: Ne,
476
+ TMPLIT_EXPR: Fe
477
+ }), F = {
478
+ element: 1,
479
+ attribute: 2,
480
+ text: 3,
481
+ cdataSection: 4,
482
+ entityReference: 5,
483
+ entityNode: 6,
484
+ progressingInstruction: 7,
485
+ comment: 8,
486
+ document: 9,
487
+ documentType: 10,
488
+ documentFragment: 11,
489
+ notation: 12
490
+ }, Ve = function() {
491
+ return typeof window > "u" ? null : window;
492
+ }, He = function(e, t) {
493
+ if (typeof e != "object" || typeof e.createPolicy != "function") return null;
494
+ let n = null, r = "data-tt-policy-suffix";
495
+ t && t.hasAttribute(r) && (n = t.getAttribute(r));
496
+ let i = "dompurify" + (n ? "#" + n : "");
497
+ try {
498
+ return e.createPolicy(i, {
499
+ createHTML(e) {
500
+ return e;
501
+ },
502
+ createScriptURL(e) {
503
+ return e;
504
+ }
505
+ });
506
+ } catch {
507
+ return console.warn("TrustedTypes policy " + i + " could not be created."), null;
508
+ }
509
+ }, Ue = function() {
510
+ return {
511
+ afterSanitizeAttributes: [],
512
+ afterSanitizeElements: [],
513
+ afterSanitizeShadowDOM: [],
514
+ beforeSanitizeAttributes: [],
515
+ beforeSanitizeElements: [],
516
+ beforeSanitizeShadowDOM: [],
517
+ uponSanitizeAttribute: [],
518
+ uponSanitizeElement: [],
519
+ uponSanitizeShadowNode: []
520
+ };
521
+ };
522
+ function We() {
523
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Ve(), t = (e) => We(e);
524
+ if (t.version = "3.3.3", t.removed = [], !e || !e.document || e.document.nodeType !== F.document || !e.Element) return t.isSupported = !1, t;
525
+ let { document: n } = e, r = n, i = r.currentScript, { DocumentFragment: a, HTMLTemplateElement: o, Node: s, Element: c, NodeFilter: l, NamedNodeMap: u = e.NamedNodeMap || e.MozNamedAttrMap, HTMLFormElement: d, DOMParser: ee, trustedTypes: f } = e, p = c.prototype, te = j(p, "cloneNode"), ne = j(p, "remove"), re = j(p, "nextSibling"), ie = j(p, "childNodes"), m = j(p, "parentNode");
526
+ if (typeof o == "function") {
527
+ let e = n.createElement("template");
528
+ e.content && e.content.ownerDocument && (n = e.content.ownerDocument);
529
+ }
530
+ let h, g = "", { implementation: ae, createNodeIterator: oe, createDocumentFragment: ce, getElementsByTagName: le } = n, { importNode: ue } = r, _ = Ue();
531
+ t.isSupported = typeof se == "function" && typeof m == "function" && ae && ae.createHTMLDocument !== void 0;
532
+ let { MUSTACHE_EXPR: y, ERB_EXPR: x, TMPLIT_EXPR: S, DATA_ATTR: O, ARIA_ATTR: be, IS_SCRIPT_OR_DATA: xe, ATTR_WHITESPACE: Ne, CUSTOM_ELEMENT: Pe } = Be, { IS_ALLOWED_URI: Fe } = Be, M = null, Ie = k({}, [
533
+ ...Se,
534
+ ...Ce,
535
+ ...we,
536
+ ...Ee,
537
+ ...Oe
538
+ ]), N = null, Re = k({}, [
539
+ ...ke,
540
+ ...Ae,
541
+ ...je,
542
+ ...Me
543
+ ]), P = Object.seal(b(null, {
544
+ tagNameCheck: {
545
+ writable: !0,
546
+ configurable: !1,
547
+ enumerable: !0,
548
+ value: null
549
+ },
550
+ attributeNameCheck: {
551
+ writable: !0,
552
+ configurable: !1,
553
+ enumerable: !0,
554
+ value: null
555
+ },
556
+ allowCustomizedBuiltInElements: {
557
+ writable: !0,
558
+ configurable: !1,
559
+ enumerable: !0,
560
+ value: !1
561
+ }
562
+ })), I = null, L = null, R = Object.seal(b(null, {
563
+ tagCheck: {
564
+ writable: !0,
565
+ configurable: !1,
566
+ enumerable: !0,
567
+ value: null
568
+ },
569
+ attributeCheck: {
570
+ writable: !0,
571
+ configurable: !1,
572
+ enumerable: !0,
573
+ value: null
574
+ }
575
+ })), Ge = !0, Ke = !0, qe = !1, Je = !0, z = !1, Ye = !0, B = !1, Xe = !1, Ze = !1, V = !1, Qe = !1, $e = !1, et = !0, tt = !1, nt = !0, H = !1, U = {}, W = null, rt = k({}, [
576
+ "annotation-xml",
577
+ "audio",
578
+ "colgroup",
579
+ "desc",
580
+ "foreignobject",
581
+ "head",
582
+ "iframe",
583
+ "math",
584
+ "mi",
585
+ "mn",
586
+ "mo",
587
+ "ms",
588
+ "mtext",
589
+ "noembed",
590
+ "noframes",
591
+ "noscript",
592
+ "plaintext",
593
+ "script",
594
+ "style",
595
+ "svg",
596
+ "template",
597
+ "thead",
598
+ "title",
599
+ "video",
600
+ "xmp"
601
+ ]), it = null, at = k({}, [
602
+ "audio",
603
+ "video",
604
+ "img",
605
+ "source",
606
+ "image",
607
+ "track"
608
+ ]), ot = null, st = k({}, [
609
+ "alt",
610
+ "class",
611
+ "for",
612
+ "id",
613
+ "label",
614
+ "name",
615
+ "pattern",
616
+ "placeholder",
617
+ "role",
618
+ "summary",
619
+ "title",
620
+ "value",
621
+ "style",
622
+ "xmlns"
623
+ ]), ct = "http://www.w3.org/1998/Math/MathML", lt = "http://www.w3.org/2000/svg", G = "http://www.w3.org/1999/xhtml", K = G, ut = !1, dt = null, ft = k({}, [
624
+ ct,
625
+ lt,
626
+ G
627
+ ], ge), pt = k({}, [
628
+ "mi",
629
+ "mo",
630
+ "mn",
631
+ "ms",
632
+ "mtext"
633
+ ]), q = k({}, ["annotation-xml"]), mt = k({}, [
634
+ "title",
635
+ "style",
636
+ "font",
637
+ "a",
638
+ "script"
639
+ ]), J = null, ht = ["application/xhtml+xml", "text/html"], Y = null, X = null, gt = n.createElement("form"), _t = function(e) {
640
+ return e instanceof RegExp || e instanceof Function;
641
+ }, vt = function() {
642
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
643
+ if (!(X && X === e)) {
644
+ if ((!e || typeof e != "object") && (e = {}), e = A(e), J = ht.indexOf(e.PARSER_MEDIA_TYPE) === -1 ? "text/html" : e.PARSER_MEDIA_TYPE, Y = J === "application/xhtml+xml" ? ge : he, M = T(e, "ALLOWED_TAGS") ? k({}, e.ALLOWED_TAGS, Y) : Ie, N = T(e, "ALLOWED_ATTR") ? k({}, e.ALLOWED_ATTR, Y) : Re, dt = T(e, "ALLOWED_NAMESPACES") ? k({}, e.ALLOWED_NAMESPACES, ge) : ft, ot = T(e, "ADD_URI_SAFE_ATTR") ? k(A(st), e.ADD_URI_SAFE_ATTR, Y) : st, it = T(e, "ADD_DATA_URI_TAGS") ? k(A(at), e.ADD_DATA_URI_TAGS, Y) : at, W = T(e, "FORBID_CONTENTS") ? k({}, e.FORBID_CONTENTS, Y) : rt, I = T(e, "FORBID_TAGS") ? k({}, e.FORBID_TAGS, Y) : A({}), L = T(e, "FORBID_ATTR") ? k({}, e.FORBID_ATTR, Y) : A({}), U = T(e, "USE_PROFILES") ? e.USE_PROFILES : !1, Ge = e.ALLOW_ARIA_ATTR !== !1, Ke = e.ALLOW_DATA_ATTR !== !1, qe = e.ALLOW_UNKNOWN_PROTOCOLS || !1, Je = e.ALLOW_SELF_CLOSE_IN_ATTR !== !1, z = e.SAFE_FOR_TEMPLATES || !1, Ye = e.SAFE_FOR_XML !== !1, B = e.WHOLE_DOCUMENT || !1, V = e.RETURN_DOM || !1, Qe = e.RETURN_DOM_FRAGMENT || !1, $e = e.RETURN_TRUSTED_TYPE || !1, Ze = e.FORCE_BODY || !1, et = e.SANITIZE_DOM !== !1, tt = e.SANITIZE_NAMED_PROPS || !1, nt = e.KEEP_CONTENT !== !1, H = e.IN_PLACE || !1, Fe = e.ALLOWED_URI_REGEXP || Le, K = e.NAMESPACE || G, pt = e.MATHML_TEXT_INTEGRATION_POINTS || pt, q = e.HTML_INTEGRATION_POINTS || q, P = e.CUSTOM_ELEMENT_HANDLING || {}, e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (P.tagNameCheck = e.CUSTOM_ELEMENT_HANDLING.tagNameCheck), e.CUSTOM_ELEMENT_HANDLING && _t(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (P.attributeNameCheck = e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), e.CUSTOM_ELEMENT_HANDLING && typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (P.allowCustomizedBuiltInElements = e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), z && (Ke = !1), Qe && (V = !0), U && (M = k({}, Oe), N = b(null), U.html === !0 && (k(M, Se), k(N, ke)), U.svg === !0 && (k(M, Ce), k(N, Ae), k(N, Me)), U.svgFilters === !0 && (k(M, we), k(N, Ae), k(N, Me)), U.mathMl === !0 && (k(M, Ee), k(N, je), k(N, Me))), T(e, "ADD_TAGS") || (R.tagCheck = null), T(e, "ADD_ATTR") || (R.attributeCheck = null), e.ADD_TAGS && (typeof e.ADD_TAGS == "function" ? R.tagCheck = e.ADD_TAGS : (M === Ie && (M = A(M)), k(M, e.ADD_TAGS, Y))), e.ADD_ATTR && (typeof e.ADD_ATTR == "function" ? R.attributeCheck = e.ADD_ATTR : (N === Re && (N = A(N)), k(N, e.ADD_ATTR, Y))), e.ADD_URI_SAFE_ATTR && k(ot, e.ADD_URI_SAFE_ATTR, Y), e.FORBID_CONTENTS && (W === rt && (W = A(W)), k(W, e.FORBID_CONTENTS, Y)), e.ADD_FORBID_CONTENTS && (W === rt && (W = A(W)), k(W, e.ADD_FORBID_CONTENTS, Y)), nt && (M["#text"] = !0), B && k(M, [
645
+ "html",
646
+ "head",
647
+ "body"
648
+ ]), M.table && (k(M, ["tbody"]), delete I.tbody), e.TRUSTED_TYPES_POLICY) {
649
+ if (typeof e.TRUSTED_TYPES_POLICY.createHTML != "function") throw D("TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.");
650
+ if (typeof e.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw D("TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.");
651
+ h = e.TRUSTED_TYPES_POLICY, g = h.createHTML("");
652
+ } else h === void 0 && (h = He(f, i)), h !== null && typeof g == "string" && (g = h.createHTML(""));
653
+ v && v(e), X = e;
654
+ }
655
+ }, yt = k({}, [
656
+ ...Ce,
657
+ ...we,
658
+ ...Te
659
+ ]), bt = k({}, [...Ee, ...De]), xt = function(e) {
660
+ let t = m(e);
661
+ (!t || !t.tagName) && (t = {
662
+ namespaceURI: K,
663
+ tagName: "template"
664
+ });
665
+ let n = he(e.tagName), r = he(t.tagName);
666
+ return dt[e.namespaceURI] ? e.namespaceURI === lt ? t.namespaceURI === G ? n === "svg" : t.namespaceURI === ct ? n === "svg" && (r === "annotation-xml" || pt[r]) : !!yt[n] : e.namespaceURI === ct ? t.namespaceURI === G ? n === "math" : t.namespaceURI === lt ? n === "math" && q[r] : !!bt[n] : e.namespaceURI === G ? t.namespaceURI === lt && !q[r] || t.namespaceURI === ct && !pt[r] ? !1 : !bt[n] && (mt[n] || !yt[n]) : !!(J === "application/xhtml+xml" && dt[e.namespaceURI]) : !1;
667
+ }, Z = function(e) {
668
+ C(t.removed, { element: e });
669
+ try {
670
+ m(e).removeChild(e);
671
+ } catch {
672
+ ne(e);
673
+ }
674
+ }, Q = function(e, n) {
675
+ try {
676
+ C(t.removed, {
677
+ attribute: n.getAttributeNode(e),
678
+ from: n
679
+ });
680
+ } catch {
681
+ C(t.removed, {
682
+ attribute: null,
683
+ from: n
684
+ });
685
+ }
686
+ if (n.removeAttribute(e), e === "is") if (V || Qe) try {
687
+ Z(n);
688
+ } catch {}
689
+ else try {
690
+ n.setAttribute(e, "");
691
+ } catch {}
692
+ }, St = function(e) {
693
+ let t = null, r = null;
694
+ if (Ze) e = "<remove></remove>" + e;
695
+ else {
696
+ let t = _e(e, /^[\r\n\t ]+/);
697
+ r = t && t[0];
698
+ }
699
+ J === "application/xhtml+xml" && K === G && (e = "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>" + e + "</body></html>");
700
+ let i = h ? h.createHTML(e) : e;
701
+ if (K === G) try {
702
+ t = new ee().parseFromString(i, J);
703
+ } catch {}
704
+ if (!t || !t.documentElement) {
705
+ t = ae.createDocument(K, "template", null);
706
+ try {
707
+ t.documentElement.innerHTML = ut ? g : i;
708
+ } catch {}
709
+ }
710
+ let a = t.body || t.documentElement;
711
+ return e && r && a.insertBefore(n.createTextNode(r), a.childNodes[0] || null), K === G ? le.call(t, B ? "html" : "body")[0] : B ? t.documentElement : a;
712
+ }, Ct = function(e) {
713
+ return oe.call(e.ownerDocument || e, e, l.SHOW_ELEMENT | l.SHOW_COMMENT | l.SHOW_TEXT | l.SHOW_PROCESSING_INSTRUCTION | l.SHOW_CDATA_SECTION, null);
714
+ }, wt = function(e) {
715
+ return e instanceof d && (typeof e.nodeName != "string" || typeof e.textContent != "string" || typeof e.removeChild != "function" || !(e.attributes instanceof u) || typeof e.removeAttribute != "function" || typeof e.setAttribute != "function" || typeof e.namespaceURI != "string" || typeof e.insertBefore != "function" || typeof e.hasChildNodes != "function");
716
+ }, Tt = function(e) {
717
+ return typeof s == "function" && e instanceof s;
718
+ };
719
+ function $(e, n, r) {
720
+ de(e, (e) => {
721
+ e.call(t, n, r, X);
722
+ });
723
+ }
724
+ let Et = function(e) {
725
+ let n = null;
726
+ if ($(_.beforeSanitizeElements, e, null), wt(e)) return Z(e), !0;
727
+ let r = Y(e.nodeName);
728
+ if ($(_.uponSanitizeElement, e, {
729
+ tagName: r,
730
+ allowedTags: M
731
+ }), Ye && e.hasChildNodes() && !Tt(e.firstElementChild) && E(/<[/\w!]/g, e.innerHTML) && E(/<[/\w!]/g, e.textContent) || e.nodeType === F.progressingInstruction || Ye && e.nodeType === F.comment && E(/<[/\w]/g, e.data)) return Z(e), !0;
732
+ if (!(R.tagCheck instanceof Function && R.tagCheck(r)) && (!M[r] || I[r])) {
733
+ if (!I[r] && Ot(r) && (P.tagNameCheck instanceof RegExp && E(P.tagNameCheck, r) || P.tagNameCheck instanceof Function && P.tagNameCheck(r))) return !1;
734
+ if (nt && !W[r]) {
735
+ let t = m(e) || e.parentNode, n = ie(e) || e.childNodes;
736
+ if (n && t) {
737
+ let r = n.length;
738
+ for (let i = r - 1; i >= 0; --i) {
739
+ let r = te(n[i], !0);
740
+ r.__removalCount = (e.__removalCount || 0) + 1, t.insertBefore(r, re(e));
741
+ }
742
+ }
743
+ }
744
+ return Z(e), !0;
745
+ }
746
+ return e instanceof c && !xt(e) || (r === "noscript" || r === "noembed" || r === "noframes") && E(/<\/no(script|embed|frames)/i, e.innerHTML) ? (Z(e), !0) : (z && e.nodeType === F.text && (n = e.textContent, de([
747
+ y,
748
+ x,
749
+ S
750
+ ], (e) => {
751
+ n = w(n, e, " ");
752
+ }), e.textContent !== n && (C(t.removed, { element: e.cloneNode() }), e.textContent = n)), $(_.afterSanitizeElements, e, null), !1);
753
+ }, Dt = function(e, t, r) {
754
+ if (L[t] || et && (t === "id" || t === "name") && (r in n || r in gt)) return !1;
755
+ if (!(Ke && !L[t] && E(O, t)) && !(Ge && E(be, t)) && !(R.attributeCheck instanceof Function && R.attributeCheck(t, e))) {
756
+ if (!N[t] || L[t]) {
757
+ if (!(Ot(e) && (P.tagNameCheck instanceof RegExp && E(P.tagNameCheck, e) || P.tagNameCheck instanceof Function && P.tagNameCheck(e)) && (P.attributeNameCheck instanceof RegExp && E(P.attributeNameCheck, t) || P.attributeNameCheck instanceof Function && P.attributeNameCheck(t, e)) || t === "is" && P.allowCustomizedBuiltInElements && (P.tagNameCheck instanceof RegExp && E(P.tagNameCheck, r) || P.tagNameCheck instanceof Function && P.tagNameCheck(r)))) return !1;
758
+ } else if (!ot[t] && !E(Fe, w(r, Ne, "")) && !((t === "src" || t === "xlink:href" || t === "href") && e !== "script" && ve(r, "data:") === 0 && it[e]) && !(qe && !E(xe, w(r, Ne, ""))) && r) return !1;
759
+ }
760
+ return !0;
761
+ }, Ot = function(e) {
762
+ return e !== "annotation-xml" && _e(e, Pe);
763
+ }, kt = function(e) {
764
+ $(_.beforeSanitizeAttributes, e, null);
765
+ let { attributes: n } = e;
766
+ if (!n || wt(e)) return;
767
+ let r = {
768
+ attrName: "",
769
+ attrValue: "",
770
+ keepAttr: !0,
771
+ allowedAttributes: N,
772
+ forceKeepAttr: void 0
773
+ }, i = n.length;
774
+ for (; i--;) {
775
+ let { name: a, namespaceURI: o, value: s } = n[i], c = Y(a), l = s, u = a === "value" ? l : ye(l);
776
+ if (r.attrName = c, r.attrValue = u, r.keepAttr = !0, r.forceKeepAttr = void 0, $(_.uponSanitizeAttribute, e, r), u = r.attrValue, tt && (c === "id" || c === "name") && (Q(a, e), u = "user-content-" + u), Ye && E(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, u)) {
777
+ Q(a, e);
778
+ continue;
779
+ }
780
+ if (c === "attributename" && _e(u, "href")) {
781
+ Q(a, e);
782
+ continue;
783
+ }
784
+ if (r.forceKeepAttr) continue;
785
+ if (!r.keepAttr) {
786
+ Q(a, e);
787
+ continue;
788
+ }
789
+ if (!Je && E(/\/>/i, u)) {
790
+ Q(a, e);
791
+ continue;
792
+ }
793
+ z && de([
794
+ y,
795
+ x,
796
+ S
797
+ ], (e) => {
798
+ u = w(u, e, " ");
799
+ });
800
+ let d = Y(e.nodeName);
801
+ if (!Dt(d, c, u)) {
802
+ Q(a, e);
803
+ continue;
804
+ }
805
+ if (h && typeof f == "object" && typeof f.getAttributeType == "function" && !o) switch (f.getAttributeType(d, c)) {
806
+ case "TrustedHTML":
807
+ u = h.createHTML(u);
808
+ break;
809
+ case "TrustedScriptURL":
810
+ u = h.createScriptURL(u);
811
+ break;
812
+ }
813
+ if (u !== l) try {
814
+ o ? e.setAttributeNS(o, a, u) : e.setAttribute(a, u), wt(e) ? Z(e) : pe(t.removed);
815
+ } catch {
816
+ Q(a, e);
817
+ }
818
+ }
819
+ $(_.afterSanitizeAttributes, e, null);
820
+ }, At = function e(t) {
821
+ let n = null, r = Ct(t);
822
+ for ($(_.beforeSanitizeShadowDOM, t, null); n = r.nextNode();) $(_.uponSanitizeShadowNode, n, null), Et(n), kt(n), n.content instanceof a && e(n.content);
823
+ $(_.afterSanitizeShadowDOM, t, null);
824
+ };
825
+ return t.sanitize = function(e) {
826
+ let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = null, o = null, c = null, l = null;
827
+ if (ut = !e, ut && (e = "<!-->"), typeof e != "string" && !Tt(e)) if (typeof e.toString == "function") {
828
+ if (e = e.toString(), typeof e != "string") throw D("dirty is not a string, aborting");
829
+ } else throw D("toString is not a function");
830
+ if (!t.isSupported) return e;
831
+ if (Xe || vt(n), t.removed = [], typeof e == "string" && (H = !1), H) {
832
+ if (e.nodeName) {
833
+ let t = Y(e.nodeName);
834
+ if (!M[t] || I[t]) throw D("root node is forbidden and cannot be sanitized in-place");
835
+ }
836
+ } else if (e instanceof s) i = St("<!---->"), o = i.ownerDocument.importNode(e, !0), o.nodeType === F.element && o.nodeName === "BODY" || o.nodeName === "HTML" ? i = o : i.appendChild(o);
837
+ else {
838
+ if (!V && !z && !B && e.indexOf("<") === -1) return h && $e ? h.createHTML(e) : e;
839
+ if (i = St(e), !i) return V ? null : $e ? g : "";
840
+ }
841
+ i && Ze && Z(i.firstChild);
842
+ let u = Ct(H ? e : i);
843
+ for (; c = u.nextNode();) Et(c), kt(c), c.content instanceof a && At(c.content);
844
+ if (H) return e;
845
+ if (V) {
846
+ if (Qe) for (l = ce.call(i.ownerDocument); i.firstChild;) l.appendChild(i.firstChild);
847
+ else l = i;
848
+ return (N.shadowroot || N.shadowrootmode) && (l = ue.call(r, l, !0)), l;
849
+ }
850
+ let d = B ? i.outerHTML : i.innerHTML;
851
+ return B && M["!doctype"] && i.ownerDocument && i.ownerDocument.doctype && i.ownerDocument.doctype.name && E(ze, i.ownerDocument.doctype.name) && (d = "<!DOCTYPE " + i.ownerDocument.doctype.name + ">\n" + d), z && de([
852
+ y,
853
+ x,
854
+ S
855
+ ], (e) => {
856
+ d = w(d, e, " ");
857
+ }), h && $e ? h.createHTML(d) : d;
858
+ }, t.setConfig = function() {
859
+ vt(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), Xe = !0;
860
+ }, t.clearConfig = function() {
861
+ X = null, Xe = !1;
862
+ }, t.isValidAttribute = function(e, t, n) {
863
+ return X || vt({}), Dt(Y(e), Y(t), n);
864
+ }, t.addHook = function(e, t) {
865
+ typeof t == "function" && C(_[e], t);
866
+ }, t.removeHook = function(e, t) {
867
+ if (t !== void 0) {
868
+ let n = fe(_[e], t);
869
+ return n === -1 ? void 0 : me(_[e], n, 1)[0];
870
+ }
871
+ return pe(_[e]);
872
+ }, t.removeHooks = function(e) {
873
+ _[e] = [];
874
+ }, t.removeAllHooks = function() {
875
+ _ = Ue();
876
+ }, t;
877
+ }
878
+ var I = We(), L = class {
879
+ config;
880
+ constructor(e) {
881
+ this.config = e;
882
+ }
883
+ sanitize(e) {
884
+ return I.sanitize(e, {
885
+ USE_PROFILES: { html: !0 },
886
+ ALLOWED_TAGS: this.config.allowedTags ? [...this.config.allowedTags] : void 0,
887
+ ALLOWED_ATTR: this.flattenAllowedAttributes(this.config)
888
+ });
889
+ }
890
+ flattenAllowedAttributes(e) {
891
+ if (!e.allowedAttributes) return;
892
+ let t = /* @__PURE__ */ new Set();
893
+ return Object.values(e.allowedAttributes).forEach((e) => {
894
+ e.forEach((e) => {
895
+ t.add(e);
896
+ });
897
+ }), [...t];
898
+ }
899
+ }, R = class {
900
+ plugins;
901
+ root;
902
+ initialized = !1;
903
+ constructor(e) {
904
+ this.root = e;
905
+ }
906
+ use(...e) {
907
+ return this.assertNotInitialized(), this.plugins = e, this;
908
+ }
909
+ withoutPlugins() {
910
+ return this.assertNotInitialized(), this.plugins = !1, this;
911
+ }
912
+ init() {
913
+ if (this.initialized) throw Error("ModuloEditorBuilder: already initialized.");
914
+ let e = this.resolveRoot(this.root), t = new u(), n = this.plugins === !1 ? [] : this.plugins ?? h();
915
+ this.initialized = !0;
916
+ let r = new Ge({
917
+ root: e,
918
+ domResolver: t,
919
+ input: new f(),
920
+ output: new p(),
921
+ markdown: new oe(new ae(), new L(g)),
922
+ textareaBridge: new te(),
923
+ plugins: n
924
+ });
925
+ return r.init(), r;
926
+ }
927
+ resolveRoot(e) {
928
+ if (typeof e != "string") return e;
929
+ let t = document.querySelector(e);
930
+ if (!(t instanceof HTMLElement)) throw Error(`ModuloEditor: root element "${e}" not found.`);
931
+ return t;
932
+ }
933
+ assertNotInitialized() {
934
+ if (this.initialized) throw Error("ModuloEditorBuilder: configuration cannot be modified after init().");
935
+ }
936
+ }, Ge = class {
937
+ document;
938
+ input;
939
+ output;
940
+ markdown;
941
+ plugins;
942
+ commands;
943
+ root;
944
+ domResolver;
945
+ textareaBridge;
946
+ unsubscribeInputChange;
947
+ initialized = !1;
948
+ slots;
949
+ constructor({ document: n = new d(), input: r, output: i, markdown: a, commands: o = [], plugins: s = [], builtinCommands: c = !0, root: l, domResolver: f, textareaBridge: p }) {
950
+ this.document = n, this.input = r, this.output = i, this.markdown = a, this.plugins = s, this.root = l, this.domResolver = f ?? new u(), this.textareaBridge = p;
951
+ let te = new e();
952
+ ee(te, {
953
+ builtinCommands: c,
954
+ commands: o
955
+ }), this.commands = new t(te, () => this.createCommandContext());
956
+ }
957
+ static create(e) {
958
+ return new R(e);
959
+ }
960
+ init() {
961
+ if (this.initialized) return;
962
+ this.slots = this.domResolver.resolve(this.root);
963
+ let e = this.document.getRawContent();
964
+ this.input.mount(this.slots.input, e), this.textareaBridge?.mount(this.slots.textarea), this.textareaBridge?.setValue(e);
965
+ let t = this.markdown.toHtml(e);
966
+ this.output.render(t), this.output.mount(this.slots.preview), this.unsubscribeInputChange = this.input.onChange((e) => {
967
+ this.handleInputChange(e);
968
+ });
969
+ let n = this.createPluginApi();
970
+ for (let e of this.plugins) e.setup(n);
971
+ this.initialized = !0;
972
+ }
973
+ destroy() {
974
+ if (this.initialized) {
975
+ this.unsubscribeInputChange?.(), this.unsubscribeInputChange = void 0;
976
+ for (let e of this.plugins) e.destroy();
977
+ this.textareaBridge?.destroy(), this.input.destroy(), this.output.destroy(), this.initialized = !1;
978
+ }
979
+ }
980
+ setValue(e) {
981
+ this.document.setRawContent(e), this.input.setValue(e), this.textareaBridge?.setValue(e), this.output.render(this.markdown.toHtml(e));
982
+ }
983
+ getValue() {
984
+ return this.document.getRawContent();
985
+ }
986
+ executeCommand(e) {
987
+ this.commands.has(e) && (this.commands.execute(e), this.syncFromInput());
988
+ }
989
+ focus() {
990
+ this.input.focus();
991
+ }
992
+ handleInputChange(e) {
993
+ this.document.setRawContent(e), this.textareaBridge?.setValue(e), this.output.render(this.markdown.toHtml(e));
994
+ }
995
+ syncFromInput() {
996
+ let e = this.input.getValue();
997
+ this.document.setRawContent(e), this.output.render(this.markdown.toHtml(e));
998
+ }
999
+ createCommandContext() {
1000
+ return {
1001
+ input: this.input,
1002
+ state: this.input.getState()
1003
+ };
1004
+ }
1005
+ createPluginApi() {
1006
+ return {
1007
+ commands: this.commands,
1008
+ slots: this.slots,
1009
+ executeCommand: (e) => {
1010
+ this.executeCommand(e);
1011
+ }
1012
+ };
1013
+ }
1014
+ };
1015
+ //#endregion
1016
+ export { oe as DefaultMarkdownProcessor, Ge as ModuloEditor };
1017
+
1018
+ //# sourceMappingURL=modulo-editor.js.map