@anyblock/remark-any-block 1.0.2 → 3.4.11

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.
@@ -1,6 +1,9 @@
1
1
  import MarkdownIt from "markdown-it";
2
2
  let dom = null;
3
- async function jsdom_init(enable = true) {
3
+ let disable_disable_flag = false;
4
+ async function jsdom_init(enable = true, disable_disable = false) {
5
+ disable_disable_flag = disable_disable;
6
+ if (typeof document !== "undefined") return;
4
7
  const { default: jsdom } = await import("jsdom");
5
8
  const { JSDOM } = jsdom;
6
9
  dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
@@ -10,6 +13,7 @@ async function jsdom_init(enable = true) {
10
13
  if (enable) jsdom_enable();
11
14
  }
12
15
  function jsdom_enable() {
16
+ if (!dom) return;
13
17
  global.Storage = dom.window.Storage;
14
18
  global.window = dom.window;
15
19
  global.history = dom.window.history;
@@ -28,10 +32,22 @@ function jsdom_enable() {
28
32
  global.MutationObserver = dom.window.MutationObserver;
29
33
  }
30
34
  function jsdom_disable() {
35
+ if (disable_disable_flag) return;
36
+ if (!dom) return;
31
37
  global.window = void 0;
32
38
  global.history = void 0;
33
39
  global.document = void 0;
34
40
  }
41
+ const ABCSetting = {
42
+ env: "obsidian",
43
+ // 某些环境的独占 api,其他环境用不上
44
+ obsidian: {
45
+ global_app: null,
46
+ global_ctx: null,
47
+ mermaid: void 0,
48
+ markmap_event: void 0
49
+ }
50
+ };
35
51
  const ABReg = {
36
52
  /**
37
53
  * AB块头部
@@ -53,9 +69,9 @@ const ABReg = {
53
69
  * - 不允许 `::` 是避免与 dataview 的 inline property 冲突
54
70
  */
55
71
  // 有前缀版本(给选择器用)
56
- reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
72
+ reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
57
73
  // 可以用空`|`来解除首字符限制。(`|`注意:可以用来弄严格模式,`#`注意:建议后面空一格避免变成“标签”,`!`注意:别易误触发 `> [!note]`
58
- reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
74
+ reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
59
75
  // 向上检查标志的 头部选择器
60
76
  reg_mdit_head: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)\s?(.*)/,
61
77
  reg_mdit_tail: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)/,
@@ -68,8 +84,8 @@ const ABReg = {
68
84
  reg_heading: /^((\s|>\s|-\s|\*\s|\+\s)*)(\#+\s)(.*)/,
69
85
  reg_table: /^((\s|>\s|-\s|\*\s|\+\s)*)(\|(.*)\|)/,
70
86
  // 无前缀版本(给处理器用,处理器不需要处理前缀,前缀在选择器阶段已经被去除了)
71
- reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
72
- reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
87
+ reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
88
+ reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
73
89
  reg_mdit_head_noprefix: /^((\s)*)(::::*)\s?(.*)/,
74
90
  reg_mdit_tail_noprefix: /^((\s)*)(::::*)/,
75
91
  reg_list_noprefix: /^((\s)*)(-\s|\*\s|\+\s)(.*)/,
@@ -82,12 +98,6 @@ const ABReg = {
82
98
  inline_split: /\| |, |, |\. |。 |: |: /
83
99
  // 内联切分。`|`或全角符号+一空格,半角符号+两空格 (后者由于空格压缩,若经历了重渲染可能有问题)
84
100
  };
85
- const ABCSetting = {
86
- env: "obsidian",
87
- // MarkdownPostProcessorContext类型, obsidian专用
88
- mermaid: void 0
89
- // obsidian专用,表示使用哪种方式渲染mermaid
90
- };
91
101
  const convert = (
92
102
  // Note: overloads in JSDoc can’t yet use different `@template`s.
93
103
  /**
@@ -362,11 +372,11 @@ function autoABAlias(header, selectorName, content) {
362
372
  } else if (selectorName == "table" || ABReg.reg_table_noprefix.test(content.trimStart())) {
363
373
  header = "|table_140lne" + header;
364
374
  }
365
- for (const item of ABAlias_json) {
375
+ for (const item of get_ABAlias_iter()) {
366
376
  header = header.replace(item.regex, item.replacement);
367
377
  }
368
378
  for (const item of ABAlias_json_withSub) {
369
- header = header.replace(item.regex, (match2, ...groups) => {
379
+ header = header.replace(item.regex, (_match, ...groups) => {
370
380
  return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1] ?? "");
371
381
  });
372
382
  }
@@ -399,15 +409,35 @@ const ABAlias_json_withSub = [
399
409
  // 注意避免和原上/上面的callout语法冲突,以及自身递归
400
410
  ];
401
411
  const ABAlias_json_mdit = [
402
- { regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
412
+ { regex: /\|:::_140lne\|((?:mdit2|2)?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
403
413
  { regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
404
414
  { regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
405
- { regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
406
- { regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
407
- { regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
415
+ { regex: /\|:::_140lne\|((?:mdit2|2)?col|分栏)\|/, replacement: "|mditCol|" },
416
+ { regex: /\|:::_140lne\|((?:mdit2|2)?card|卡片)\|/, replacement: "|mditCard|" },
417
+ { regex: /\|:::_140lne\|((?:mdit2|2)?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" },
418
+ //
419
+ // {regex: /\|:::_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
420
+ // {regex: /\|:::_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
421
+ // {regex: /\|:::_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|"},
422
+ // {regex: /\|:::_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|"},
423
+ // {regex: /\|:::_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|"},
424
+ // list - 多叉多层树
425
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mermaid|flow|流程图)\|/, replacement: "|mdit2list|list2mermaid|" },
426
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mehrmaid|mdmermaid)\|/, replacement: "|mdit2list|list2mehrmaidText|code(mehrmaid)|" },
427
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|mdit2list|list2pumlMindmap|" },
428
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|mdit2list|list2markmap|" },
429
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(wbs|(工作)?分解(图|结构))\|/, replacement: "|mdit2list|list2pumlWBS|" },
430
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|mdit2list|list2table|" },
431
+ // list - lt树 (属于多层一叉树)
432
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|mdit2list|list2lt|" },
433
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(list|列表)\|/, replacement: "|mdit2list|list2lt|addClass(ab-listtable-likelist)|" },
434
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|mdit2list|list2dt|" },
435
+ // list - 二层树
436
+ { regex: /\|:::_140lne\|(fakeList|仿列表)\|/, replacement: "|mdit2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
437
+ // 至后
438
+ { regex: "|mdit2list|", replacement: "|mdit2listdata|listdata2strict|listdata2list|" }
408
439
  ];
409
440
  const ABAlias_json_title = [
410
- { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
411
441
  // title - list&title
412
442
  { regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
413
443
  { regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
@@ -426,7 +456,9 @@ const ABAlias_json_title = [
426
456
  { regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
427
457
  { regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
428
458
  // list - 二层树
429
- { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
459
+ { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
460
+ // 至后
461
+ { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" }
430
462
  ];
431
463
  const ABAlias_json_list = [
432
464
  // 特殊
@@ -510,7 +542,9 @@ const ABAlias_json_general = [
510
542
  { regex: "|超超小字|", replacement: "|addClass(ab-custom-font-smallxx)|" },
511
543
  { regex: "|加粗|", replacement: "|addClass(ab-custom-font-bold)|" }
512
544
  ];
513
- const ABAlias_json_default = [
545
+ const ABAlias_user = [];
546
+ const ABAlias_pro = [];
547
+ const ABAlias_default = [
514
548
  ...ABAlias_json_mdit,
515
549
  ...ABAlias_json_title,
516
550
  ...ABAlias_json_list,
@@ -520,10 +554,11 @@ const ABAlias_json_default = [
520
554
  ...ABAlias_json_general
521
555
  // 这个放最后
522
556
  ];
523
- let ABAlias_json = [
524
- ...ABAlias_json_default
525
- // 设置决定是否停用
526
- ];
557
+ function* get_ABAlias_iter() {
558
+ yield* ABAlias_user;
559
+ yield* ABAlias_pro;
560
+ yield* ABAlias_default;
561
+ }
527
562
  const ABAlias_json_end = [
528
563
  { regex: "|:::_140lne", replacement: "" },
529
564
  { regex: "|heading_140lne", replacement: "" },
@@ -580,24 +615,18 @@ class ABConvertManager {
580
615
  * @param header 转换方式
581
616
  * @param content 要转换的初始文本 (无前缀版本,前缀在选择器环节已经删除了)
582
617
  * @param selectorName 选择器名,空表示未知
583
- * @return 等于el,无用,后面可以删了
584
618
  */
585
619
  static autoABConvert(el, header, content, selectorName = "", ctx) {
586
- let prev_result = content;
587
- let prev_type = "string";
588
- let prev_type2 = ABConvert_IOEnum.text;
589
- let prev_processor;
590
620
  let prev2 = {
591
- // 组合在一起是为了引用传参
592
- prev_result,
593
- prev_type,
594
- prev_type2,
595
- prev_processor
621
+ prev_result: content,
622
+ prev_type: "string",
623
+ prev_type2: ABConvert_IOEnum.text,
624
+ prev_processor: void 0
596
625
  };
597
626
  {
598
- header = autoABAlias(header, selectorName, prev_result);
627
+ header = autoABAlias(header, selectorName, prev2.prev_result);
599
628
  let list_header = header.split("|");
600
- prev_result = this.autoABConvert_runConvert(el, list_header, prev2, ctx);
629
+ this.autoABConvert_runConvert(el, list_header, prev2, ctx);
601
630
  this.autoABConvert_last(el, header, selectorName, prev2, ctx);
602
631
  }
603
632
  }
@@ -656,7 +685,12 @@ class ABConvertManager {
656
685
  break;
657
686
  }
658
687
  }
659
- prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
688
+ try {
689
+ prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
690
+ } catch (e) {
691
+ console.error(`处理器执行错误, id:${abReplaceProcessor.id}, header:${item_header}, error:`, e);
692
+ break;
693
+ }
660
694
  prev2.prev_type = typeof prev2.prev_result;
661
695
  prev2.prev_type2 = abReplaceProcessor.process_return;
662
696
  prev2.prev_processor = abReplaceProcessor.process;
@@ -670,7 +704,7 @@ class ABConvertManager {
670
704
  /**
671
705
  * 子函数,后处理/尾处理,主要进行末尾追加指令
672
706
  */
673
- static autoABConvert_last(el, header, selectorName, prev2, ctx) {
707
+ static autoABConvert_last(el, _header, _selectorName, prev2, _ctx) {
674
708
  if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.text) {
675
709
  const subEl = document.createElement("div");
676
710
  el.appendChild(subEl);
@@ -678,7 +712,7 @@ class ABConvertManager {
678
712
  prev2.prev_result = el;
679
713
  prev2.prev_type = "object";
680
714
  prev2.prev_type2 = ABConvert_IOEnum.el;
681
- prev2.process = "md";
715
+ prev2.prev_processor = "md";
682
716
  } else if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.json) {
683
717
  const code_str = "```json\n" + prev2.prev_result + "\n```\n";
684
718
  const subEl = document.createElement("div");
@@ -687,7 +721,7 @@ class ABConvertManager {
687
721
  prev2.prev_result = el;
688
722
  prev2.prev_type = "object";
689
723
  prev2.prev_type2 = ABConvert_IOEnum.el;
690
- prev2.process = "show_json";
724
+ prev2.prev_processor = "show_json";
691
725
  } else if (prev2.prev_type == "object" && (prev2.prev_type2 == ABConvert_IOEnum.list_stream || prev2.prev_type2 == ABConvert_IOEnum.c2list_stream || prev2.prev_type2 == ABConvert_IOEnum.json)) {
692
726
  const code_str = "```json\n" + JSON.stringify(prev2.prev_result, null, 2) + "\n```\n";
693
727
  const subEl = document.createElement("div");
@@ -696,7 +730,7 @@ class ABConvertManager {
696
730
  prev2.prev_result = el;
697
731
  prev2.prev_type = "object";
698
732
  prev2.prev_type2 = ABConvert_IOEnum.el;
699
- prev2.process = "show_listStream";
733
+ prev2.prev_processor = "show_listStream";
700
734
  } else if (prev2.prev_type == "object" && prev2.prev_type2 == ABConvert_IOEnum.el) {
701
735
  return prev2;
702
736
  } else {
@@ -1140,7 +1174,7 @@ class ListProcess {
1140
1174
  }
1141
1175
  }
1142
1176
  /**
1143
- * 标题大纲转列表数据(@todo 正文的level+10,要减掉)
1177
+ * 标题大纲转列表数据
1144
1178
  *
1145
1179
  * @detail
1146
1180
  * 这里要将标题、正文、列表 的等级合为一块,所以存在偏移值:
@@ -1149,6 +1183,7 @@ class ListProcess {
1149
1183
  * 2. 正文等级, = 0, 取值[+1,+Infi]
1150
1184
  * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
1151
1185
  *
1186
+ * (比较旧版是正文+10,列表+11,后来允许标题等级为负数。这样方便很多)
1152
1187
  */
1153
1188
  static title2data(text2) {
1154
1189
  let list_itemInfo = [];
@@ -1159,13 +1194,21 @@ class ListProcess {
1159
1194
  if (codeBlockFlag == "") {
1160
1195
  const match2 = line.match(ABReg.reg_code);
1161
1196
  if (match2 && match2[3]) {
1162
- codeBlockFlag = match2[1] + match2[3];
1163
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1197
+ if (mul_mode === "heading" || mul_mode === "") {
1198
+ list_itemInfo.push({
1199
+ content: line,
1200
+ level: 0
1201
+ });
1202
+ mul_mode = "para";
1203
+ } else {
1204
+ codeBlockFlag = match2[1] + match2[3];
1205
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1206
+ }
1164
1207
  continue;
1165
1208
  }
1166
1209
  } else {
1167
1210
  if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1168
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1211
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1169
1212
  continue;
1170
1213
  }
1171
1214
  const match_heading = line.match(ABReg.reg_heading_noprefix);
@@ -1182,21 +1225,125 @@ class ListProcess {
1182
1225
  list_itemInfo.push({
1183
1226
  content: match_list[4],
1184
1227
  level: match_list[1].length + 1
1185
- //+10
1186
1228
  });
1187
1229
  mul_mode = "list";
1188
1230
  } else if (/^\S/.test(line) && mul_mode == "list") {
1189
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1231
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1190
1232
  } else {
1191
1233
  if (mul_mode == "para") {
1192
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1234
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1235
+ } else if (/^\s*$/.test(line)) {
1236
+ continue;
1237
+ } else {
1238
+ list_itemInfo.push({
1239
+ content: line,
1240
+ level: 0
1241
+ });
1242
+ mul_mode = "para";
1243
+ }
1244
+ }
1245
+ }
1246
+ removeTailBlank();
1247
+ return list_itemInfo;
1248
+ function removeTailBlank() {
1249
+ if (mul_mode == "para" || mul_mode == "list") {
1250
+ list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content.replace(/\s*$/, "");
1251
+ }
1252
+ }
1253
+ }
1254
+ /**
1255
+ * MarkdownIt 转列表数据
1256
+ *
1257
+ * @detail
1258
+ * 与 title2data 的逻辑基本相同
1259
+ *
1260
+ * 这里要将Mdit标识 (@xxx)、正文、列表 的等级合为一块,所以存在偏移值:
1261
+ *
1262
+ * 1. Mdit等级, = `@<数字>`-100,
1263
+ * 2. 正文等级, = 0, 取值[+1,+Infi]
1264
+ * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
1265
+ *
1266
+ * 例如:
1267
+ *
1268
+ * :::
1269
+ *
1270
+ * @1 AAA
1271
+ *
1272
+ * aaa
1273
+ *
1274
+ * @2 BBB
1275
+ *
1276
+ * @2 B22
1277
+ *
1278
+ * ccc
1279
+ * ddd
1280
+ *
1281
+ * @1 A22
1282
+ *
1283
+ * :::
1284
+ *
1285
+ * 会被转化为
1286
+ *
1287
+ * - AAA
1288
+ * - BBB
1289
+ * - B22
1290
+ * - ccc
1291
+ * ddd
1292
+ * - A22
1293
+ */
1294
+ static mdit2data(text2) {
1295
+ let list_itemInfo = [];
1296
+ const list_text = text2.split("\n");
1297
+ let mul_mode = "";
1298
+ let codeBlockFlag = "";
1299
+ for (let line of list_text) {
1300
+ if (codeBlockFlag == "") {
1301
+ const match2 = line.match(ABReg.reg_code);
1302
+ if (match2 && match2[3]) {
1303
+ if (mul_mode === "mdit" || mul_mode === "") {
1304
+ list_itemInfo.push({
1305
+ content: line,
1306
+ level: 0
1307
+ });
1308
+ mul_mode = "para";
1309
+ } else {
1310
+ codeBlockFlag = match2[1] + match2[3];
1311
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1312
+ }
1313
+ continue;
1314
+ }
1315
+ } else {
1316
+ if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1317
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1318
+ continue;
1319
+ }
1320
+ const match_mdit = line.match(/^(\s*)@(\d+)\s+(.*)$/);
1321
+ const match_list = line.match(ABReg.reg_list_noprefix);
1322
+ if (match_mdit && !match_mdit[1]) {
1323
+ removeTailBlank();
1324
+ list_itemInfo.push({
1325
+ content: match_mdit[3],
1326
+ level: Number(match_mdit[2]) - 100
1327
+ });
1328
+ mul_mode = "mdit";
1329
+ } else if (match_list) {
1330
+ removeTailBlank();
1331
+ list_itemInfo.push({
1332
+ content: match_list[4],
1333
+ level: match_list[1].length + 1
1334
+ });
1335
+ mul_mode = "list";
1336
+ } else if (/^\S/.test(line) && mul_mode == "list") {
1337
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1338
+ } else {
1339
+ if (mul_mode == "para") {
1340
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1193
1341
  } else if (/^\s*$/.test(line)) {
1194
1342
  continue;
1195
1343
  } else {
1196
1344
  list_itemInfo.push({
1197
1345
  content: line,
1198
1346
  level: 0
1199
- //+10
1200
1347
  });
1201
1348
  mul_mode = "para";
1202
1349
  }
@@ -1431,6 +1578,16 @@ const abc_title2listdata = ABConvert.factory({
1431
1578
  return ListProcess.title2data(content);
1432
1579
  }
1433
1580
  });
1581
+ ABConvert.factory({
1582
+ id: "mdit2listdata",
1583
+ name: "mdit到listdata",
1584
+ process_param: ABConvert_IOEnum.text,
1585
+ process_return: ABConvert_IOEnum.list_stream,
1586
+ detail: "mdit到listdata",
1587
+ process: (el, header, content) => {
1588
+ return ListProcess.mdit2data(content);
1589
+ }
1590
+ });
1434
1591
  ABConvert.factory({
1435
1592
  id: "listdata2list",
1436
1593
  name: "listdata到列表",
@@ -2426,6 +2583,1085 @@ ABConvert.factory({
2426
2583
  return newContent;
2427
2584
  }
2428
2585
  });
2586
+ function _arrayLikeToArray(r, a) {
2587
+ (null == a || a > r.length) && (a = r.length);
2588
+ for (var e = 0, n2 = Array(a); e < a; e++) n2[e] = r[e];
2589
+ return n2;
2590
+ }
2591
+ function _arrayWithHoles(r) {
2592
+ if (Array.isArray(r)) return r;
2593
+ }
2594
+ function _iterableToArrayLimit(r, l2) {
2595
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2596
+ if (null != t) {
2597
+ var e, n2, i, u, a = [], f = true, o = false;
2598
+ try {
2599
+ if (i = (t = t.call(r)).next, 0 === l2) ;
2600
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
2601
+ } catch (r2) {
2602
+ o = true, n2 = r2;
2603
+ } finally {
2604
+ try {
2605
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
2606
+ } finally {
2607
+ if (o) throw n2;
2608
+ }
2609
+ }
2610
+ return a;
2611
+ }
2612
+ }
2613
+ function _nonIterableRest() {
2614
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2615
+ }
2616
+ function _slicedToArray(r, e) {
2617
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
2618
+ }
2619
+ function _unsupportedIterableToArray(r, a) {
2620
+ if (r) {
2621
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2622
+ var t = {}.toString.call(r).slice(8, -1);
2623
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
2624
+ }
2625
+ }
2626
+ const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2627
+ let freeze = Object.freeze, seal = Object.seal, create = Object.create;
2628
+ let _ref = typeof Reflect !== "undefined" && Reflect, apply = _ref.apply, construct = _ref.construct;
2629
+ if (!freeze) {
2630
+ freeze = function freeze2(x) {
2631
+ return x;
2632
+ };
2633
+ }
2634
+ if (!seal) {
2635
+ seal = function seal2(x) {
2636
+ return x;
2637
+ };
2638
+ }
2639
+ if (!apply) {
2640
+ apply = function apply2(func, thisArg) {
2641
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2642
+ args[_key - 2] = arguments[_key];
2643
+ }
2644
+ return func.apply(thisArg, args);
2645
+ };
2646
+ }
2647
+ if (!construct) {
2648
+ construct = function construct2(Func) {
2649
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2650
+ args[_key2 - 1] = arguments[_key2];
2651
+ }
2652
+ return new Func(...args);
2653
+ };
2654
+ }
2655
+ const arrayForEach = unapply(Array.prototype.forEach);
2656
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
2657
+ const arrayPop = unapply(Array.prototype.pop);
2658
+ const arrayPush = unapply(Array.prototype.push);
2659
+ const arraySplice = unapply(Array.prototype.splice);
2660
+ const arrayIsArray = Array.isArray;
2661
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
2662
+ const stringToString = unapply(String.prototype.toString);
2663
+ const stringMatch = unapply(String.prototype.match);
2664
+ const stringReplace = unapply(String.prototype.replace);
2665
+ const stringIndexOf = unapply(String.prototype.indexOf);
2666
+ const stringTrim = unapply(String.prototype.trim);
2667
+ const numberToString = unapply(Number.prototype.toString);
2668
+ const booleanToString = unapply(Boolean.prototype.toString);
2669
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
2670
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
2671
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
2672
+ const objectToString = unapply(Object.prototype.toString);
2673
+ const regExpTest = unapply(RegExp.prototype.test);
2674
+ const typeErrorCreate = unconstruct(TypeError);
2675
+ function unapply(func) {
2676
+ return function(thisArg) {
2677
+ if (thisArg instanceof RegExp) {
2678
+ thisArg.lastIndex = 0;
2679
+ }
2680
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2681
+ args[_key3 - 1] = arguments[_key3];
2682
+ }
2683
+ return apply(func, thisArg, args);
2684
+ };
2685
+ }
2686
+ function unconstruct(Func) {
2687
+ return function() {
2688
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2689
+ args[_key4] = arguments[_key4];
2690
+ }
2691
+ return construct(Func, args);
2692
+ };
2693
+ }
2694
+ function addToSet(set2, array) {
2695
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
2696
+ if (setPrototypeOf) {
2697
+ setPrototypeOf(set2, null);
2698
+ }
2699
+ if (!arrayIsArray(array)) {
2700
+ return set2;
2701
+ }
2702
+ let l2 = array.length;
2703
+ while (l2--) {
2704
+ let element = array[l2];
2705
+ if (typeof element === "string") {
2706
+ const lcElement = transformCaseFunc(element);
2707
+ if (lcElement !== element) {
2708
+ if (!isFrozen(array)) {
2709
+ array[l2] = lcElement;
2710
+ }
2711
+ element = lcElement;
2712
+ }
2713
+ }
2714
+ set2[element] = true;
2715
+ }
2716
+ return set2;
2717
+ }
2718
+ function cleanArray(array) {
2719
+ for (let index2 = 0; index2 < array.length; index2++) {
2720
+ const isPropertyExist = objectHasOwnProperty(array, index2);
2721
+ if (!isPropertyExist) {
2722
+ array[index2] = null;
2723
+ }
2724
+ }
2725
+ return array;
2726
+ }
2727
+ function clone$3(object) {
2728
+ const newObject = create(null);
2729
+ for (const _ref2 of entries(object)) {
2730
+ var _ref3 = _slicedToArray(_ref2, 2);
2731
+ const property = _ref3[0];
2732
+ const value = _ref3[1];
2733
+ const isPropertyExist = objectHasOwnProperty(object, property);
2734
+ if (isPropertyExist) {
2735
+ if (arrayIsArray(value)) {
2736
+ newObject[property] = cleanArray(value);
2737
+ } else if (value && typeof value === "object" && value.constructor === Object) {
2738
+ newObject[property] = clone$3(value);
2739
+ } else {
2740
+ newObject[property] = value;
2741
+ }
2742
+ }
2743
+ }
2744
+ return newObject;
2745
+ }
2746
+ function stringifyValue(value) {
2747
+ switch (typeof value) {
2748
+ case "string": {
2749
+ return value;
2750
+ }
2751
+ case "number": {
2752
+ return numberToString(value);
2753
+ }
2754
+ case "boolean": {
2755
+ return booleanToString(value);
2756
+ }
2757
+ case "bigint": {
2758
+ return bigintToString ? bigintToString(value) : "0";
2759
+ }
2760
+ case "symbol": {
2761
+ return symbolToString ? symbolToString(value) : "Symbol()";
2762
+ }
2763
+ case "undefined": {
2764
+ return objectToString(value);
2765
+ }
2766
+ case "function":
2767
+ case "object": {
2768
+ if (value === null) {
2769
+ return objectToString(value);
2770
+ }
2771
+ const valueAsRecord = value;
2772
+ const valueToString = lookupGetter(valueAsRecord, "toString");
2773
+ if (typeof valueToString === "function") {
2774
+ const stringified = valueToString(valueAsRecord);
2775
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
2776
+ }
2777
+ return objectToString(value);
2778
+ }
2779
+ default: {
2780
+ return objectToString(value);
2781
+ }
2782
+ }
2783
+ }
2784
+ function lookupGetter(object, prop2) {
2785
+ while (object !== null) {
2786
+ const desc = getOwnPropertyDescriptor(object, prop2);
2787
+ if (desc) {
2788
+ if (desc.get) {
2789
+ return unapply(desc.get);
2790
+ }
2791
+ if (typeof desc.value === "function") {
2792
+ return unapply(desc.value);
2793
+ }
2794
+ }
2795
+ object = getPrototypeOf(object);
2796
+ }
2797
+ function fallbackValue() {
2798
+ return null;
2799
+ }
2800
+ return fallbackValue;
2801
+ }
2802
+ function isRegex(value) {
2803
+ try {
2804
+ regExpTest(value, "");
2805
+ return true;
2806
+ } catch (_unused) {
2807
+ return false;
2808
+ }
2809
+ }
2810
+ const html$1$1 = freeze(["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"]);
2811
+ const svg$1 = freeze(["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"]);
2812
+ const svgFilters = freeze(["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"]);
2813
+ const svgDisallowed = freeze(["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"]);
2814
+ const mathMl$1 = freeze(["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"]);
2815
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
2816
+ const text$2 = freeze(["#text"]);
2817
+ const html$2 = freeze(["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"]);
2818
+ const svg = freeze(["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"]);
2819
+ const mathMl = freeze(["accent", "accentunder", "align", "bevelled", "close", "columnalign", "columnlines", "columnspacing", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lquote", "lspace", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]);
2820
+ const xml$1 = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
2821
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
2822
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
2823
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
2824
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
2825
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
2826
+ const IS_ALLOWED_URI = seal(
2827
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
2828
+ // eslint-disable-line no-useless-escape
2829
+ );
2830
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
2831
+ const ATTR_WHITESPACE = seal(
2832
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
2833
+ // eslint-disable-line no-control-regex
2834
+ );
2835
+ const DOCTYPE_NAME = seal(/^html$/i);
2836
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
2837
+ const NODE_TYPE$1 = {
2838
+ element: 1,
2839
+ text: 3,
2840
+ // Deprecated
2841
+ progressingInstruction: 7,
2842
+ comment: 8,
2843
+ document: 9
2844
+ };
2845
+ const getGlobal = function getGlobal2() {
2846
+ return typeof window === "undefined" ? null : window;
2847
+ };
2848
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
2849
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
2850
+ return null;
2851
+ }
2852
+ let suffix = null;
2853
+ const ATTR_NAME = "data-tt-policy-suffix";
2854
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
2855
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
2856
+ }
2857
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
2858
+ try {
2859
+ return trustedTypes.createPolicy(policyName, {
2860
+ createHTML(html2) {
2861
+ return html2;
2862
+ },
2863
+ createScriptURL(scriptUrl) {
2864
+ return scriptUrl;
2865
+ }
2866
+ });
2867
+ } catch (_) {
2868
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
2869
+ return null;
2870
+ }
2871
+ };
2872
+ const _createHooksMap = function _createHooksMap2() {
2873
+ return {
2874
+ afterSanitizeAttributes: [],
2875
+ afterSanitizeElements: [],
2876
+ afterSanitizeShadowDOM: [],
2877
+ beforeSanitizeAttributes: [],
2878
+ beforeSanitizeElements: [],
2879
+ beforeSanitizeShadowDOM: [],
2880
+ uponSanitizeAttribute: [],
2881
+ uponSanitizeElement: [],
2882
+ uponSanitizeShadowNode: []
2883
+ };
2884
+ };
2885
+ function createDOMPurify() {
2886
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2887
+ const DOMPurify = (root2) => createDOMPurify(root2);
2888
+ DOMPurify.version = "3.4.3";
2889
+ DOMPurify.removed = [];
2890
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE$1.document || !window2.Element) {
2891
+ DOMPurify.isSupported = false;
2892
+ return DOMPurify;
2893
+ }
2894
+ let document2 = window2.document;
2895
+ const originalDocument = document2;
2896
+ const currentScript = originalDocument.currentScript;
2897
+ const DocumentFragment = window2.DocumentFragment, HTMLTemplateElement = window2.HTMLTemplateElement, Node3 = window2.Node, Element2 = window2.Element, NodeFilter = window2.NodeFilter, _window$NamedNodeMap = window2.NamedNodeMap, NamedNodeMap = _window$NamedNodeMap === void 0 ? window2.NamedNodeMap || window2.MozNamedAttrMap : _window$NamedNodeMap, HTMLFormElement = window2.HTMLFormElement, DOMParser = window2.DOMParser, trustedTypes = window2.trustedTypes;
2898
+ const ElementPrototype = Element2.prototype;
2899
+ const cloneNode2 = lookupGetter(ElementPrototype, "cloneNode");
2900
+ const remove2 = lookupGetter(ElementPrototype, "remove");
2901
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2902
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2903
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2904
+ if (typeof HTMLTemplateElement === "function") {
2905
+ const template = document2.createElement("template");
2906
+ if (template.content && template.content.ownerDocument) {
2907
+ document2 = template.content.ownerDocument;
2908
+ }
2909
+ }
2910
+ let trustedTypesPolicy;
2911
+ let emptyHTML = "";
2912
+ const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName2 = _document.getElementsByTagName;
2913
+ const importNode = originalDocument.importNode;
2914
+ let hooks = _createHooksMap();
2915
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2916
+ const MUSTACHE_EXPR$1 = MUSTACHE_EXPR, ERB_EXPR$1 = ERB_EXPR, TMPLIT_EXPR$1 = TMPLIT_EXPR, DATA_ATTR$1 = DATA_ATTR, ARIA_ATTR$1 = ARIA_ATTR, IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA, ATTR_WHITESPACE$1 = ATTR_WHITESPACE, CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;
2917
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
2918
+ let ALLOWED_TAGS = null;
2919
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text$2]);
2920
+ let ALLOWED_ATTR = null;
2921
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html$2, ...svg, ...mathMl, ...xml$1]);
2922
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2923
+ tagNameCheck: {
2924
+ writable: true,
2925
+ configurable: false,
2926
+ enumerable: true,
2927
+ value: null
2928
+ },
2929
+ attributeNameCheck: {
2930
+ writable: true,
2931
+ configurable: false,
2932
+ enumerable: true,
2933
+ value: null
2934
+ },
2935
+ allowCustomizedBuiltInElements: {
2936
+ writable: true,
2937
+ configurable: false,
2938
+ enumerable: true,
2939
+ value: false
2940
+ }
2941
+ }));
2942
+ let FORBID_TAGS = null;
2943
+ let FORBID_ATTR = null;
2944
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
2945
+ tagCheck: {
2946
+ writable: true,
2947
+ configurable: false,
2948
+ enumerable: true,
2949
+ value: null
2950
+ },
2951
+ attributeCheck: {
2952
+ writable: true,
2953
+ configurable: false,
2954
+ enumerable: true,
2955
+ value: null
2956
+ }
2957
+ }));
2958
+ let ALLOW_ARIA_ATTR = true;
2959
+ let ALLOW_DATA_ATTR = true;
2960
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
2961
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
2962
+ let SAFE_FOR_TEMPLATES = false;
2963
+ let SAFE_FOR_XML = true;
2964
+ let WHOLE_DOCUMENT = false;
2965
+ let SET_CONFIG = false;
2966
+ let FORCE_BODY = false;
2967
+ let RETURN_DOM = false;
2968
+ let RETURN_DOM_FRAGMENT = false;
2969
+ let RETURN_TRUSTED_TYPE = false;
2970
+ let SANITIZE_DOM = true;
2971
+ let SANITIZE_NAMED_PROPS = false;
2972
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
2973
+ let KEEP_CONTENT = true;
2974
+ let IN_PLACE = false;
2975
+ let USE_PROFILES = {};
2976
+ let FORBID_CONTENTS = null;
2977
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ["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"]);
2978
+ let DATA_URI_TAGS = null;
2979
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
2980
+ let URI_SAFE_ATTRIBUTES = null;
2981
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
2982
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
2983
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2984
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
2985
+ let NAMESPACE = HTML_NAMESPACE;
2986
+ let IS_EMPTY_INPUT = false;
2987
+ let ALLOWED_NAMESPACES = null;
2988
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
2989
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
2990
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
2991
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
2992
+ let PARSER_MEDIA_TYPE = null;
2993
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
2994
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
2995
+ let transformCaseFunc = null;
2996
+ let CONFIG = null;
2997
+ const formElement = document2.createElement("form");
2998
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
2999
+ return testValue instanceof RegExp || testValue instanceof Function;
3000
+ };
3001
+ const _parseConfig = function _parseConfig2() {
3002
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3003
+ if (CONFIG && CONFIG === cfg) {
3004
+ return;
3005
+ }
3006
+ if (!cfg || typeof cfg !== "object") {
3007
+ cfg = {};
3008
+ }
3009
+ cfg = clone$3(cfg);
3010
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
3011
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
3012
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
3013
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
3014
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
3015
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
3016
+ URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR) ? addToSet(clone$3(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;
3017
+ DATA_URI_TAGS = objectHasOwnProperty(cfg, "ADD_DATA_URI_TAGS") && arrayIsArray(cfg.ADD_DATA_URI_TAGS) ? addToSet(clone$3(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;
3018
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
3019
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone$3({});
3020
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone$3({});
3021
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone$3(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
3022
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
3023
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
3024
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
3025
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
3026
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
3027
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
3028
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
3029
+ RETURN_DOM = cfg.RETURN_DOM || false;
3030
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
3031
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
3032
+ FORCE_BODY = cfg.FORCE_BODY || false;
3033
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
3034
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
3035
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
3036
+ IN_PLACE = cfg.IN_PLACE || false;
3037
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
3038
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
3039
+ MATHML_TEXT_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "MATHML_TEXT_INTEGRATION_POINTS") && cfg.MATHML_TEXT_INTEGRATION_POINTS && typeof cfg.MATHML_TEXT_INTEGRATION_POINTS === "object" ? clone$3(cfg.MATHML_TEXT_INTEGRATION_POINTS) : addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
3040
+ HTML_INTEGRATION_POINTS = objectHasOwnProperty(cfg, "HTML_INTEGRATION_POINTS") && cfg.HTML_INTEGRATION_POINTS && typeof cfg.HTML_INTEGRATION_POINTS === "object" ? clone$3(cfg.HTML_INTEGRATION_POINTS) : addToSet({}, ["annotation-xml"]);
3041
+ const customElementHandling = objectHasOwnProperty(cfg, "CUSTOM_ELEMENT_HANDLING") && cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING === "object" ? clone$3(cfg.CUSTOM_ELEMENT_HANDLING) : create(null);
3042
+ CUSTOM_ELEMENT_HANDLING = create(null);
3043
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
3044
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
3045
+ }
3046
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
3047
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
3048
+ }
3049
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
3050
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
3051
+ }
3052
+ if (SAFE_FOR_TEMPLATES) {
3053
+ ALLOW_DATA_ATTR = false;
3054
+ }
3055
+ if (RETURN_DOM_FRAGMENT) {
3056
+ RETURN_DOM = true;
3057
+ }
3058
+ if (USE_PROFILES) {
3059
+ ALLOWED_TAGS = addToSet({}, text$2);
3060
+ ALLOWED_ATTR = create(null);
3061
+ if (USE_PROFILES.html === true) {
3062
+ addToSet(ALLOWED_TAGS, html$1$1);
3063
+ addToSet(ALLOWED_ATTR, html$2);
3064
+ }
3065
+ if (USE_PROFILES.svg === true) {
3066
+ addToSet(ALLOWED_TAGS, svg$1);
3067
+ addToSet(ALLOWED_ATTR, svg);
3068
+ addToSet(ALLOWED_ATTR, xml$1);
3069
+ }
3070
+ if (USE_PROFILES.svgFilters === true) {
3071
+ addToSet(ALLOWED_TAGS, svgFilters);
3072
+ addToSet(ALLOWED_ATTR, svg);
3073
+ addToSet(ALLOWED_ATTR, xml$1);
3074
+ }
3075
+ if (USE_PROFILES.mathMl === true) {
3076
+ addToSet(ALLOWED_TAGS, mathMl$1);
3077
+ addToSet(ALLOWED_ATTR, mathMl);
3078
+ addToSet(ALLOWED_ATTR, xml$1);
3079
+ }
3080
+ }
3081
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
3082
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
3083
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
3084
+ if (typeof cfg.ADD_TAGS === "function") {
3085
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
3086
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
3087
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
3088
+ ALLOWED_TAGS = clone$3(ALLOWED_TAGS);
3089
+ }
3090
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
3091
+ }
3092
+ }
3093
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
3094
+ if (typeof cfg.ADD_ATTR === "function") {
3095
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
3096
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
3097
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
3098
+ ALLOWED_ATTR = clone$3(ALLOWED_ATTR);
3099
+ }
3100
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
3101
+ }
3102
+ }
3103
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
3104
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
3105
+ }
3106
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
3107
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3108
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3109
+ }
3110
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
3111
+ }
3112
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
3113
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3114
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3115
+ }
3116
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
3117
+ }
3118
+ if (KEEP_CONTENT) {
3119
+ ALLOWED_TAGS["#text"] = true;
3120
+ }
3121
+ if (WHOLE_DOCUMENT) {
3122
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
3123
+ }
3124
+ if (ALLOWED_TAGS.table) {
3125
+ addToSet(ALLOWED_TAGS, ["tbody"]);
3126
+ delete FORBID_TAGS.tbody;
3127
+ }
3128
+ if (cfg.TRUSTED_TYPES_POLICY) {
3129
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
3130
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
3131
+ }
3132
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
3133
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
3134
+ }
3135
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
3136
+ emptyHTML = trustedTypesPolicy.createHTML("");
3137
+ } else {
3138
+ if (trustedTypesPolicy === void 0) {
3139
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
3140
+ }
3141
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
3142
+ emptyHTML = trustedTypesPolicy.createHTML("");
3143
+ }
3144
+ }
3145
+ if (freeze) {
3146
+ freeze(cfg);
3147
+ }
3148
+ CONFIG = cfg;
3149
+ };
3150
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
3151
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
3152
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
3153
+ let parent2 = getParentNode(element);
3154
+ if (!parent2 || !parent2.tagName) {
3155
+ parent2 = {
3156
+ namespaceURI: NAMESPACE,
3157
+ tagName: "template"
3158
+ };
3159
+ }
3160
+ const tagName = stringToLowerCase(element.tagName);
3161
+ const parentTagName = stringToLowerCase(parent2.tagName);
3162
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
3163
+ return false;
3164
+ }
3165
+ if (element.namespaceURI === SVG_NAMESPACE) {
3166
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3167
+ return tagName === "svg";
3168
+ }
3169
+ if (parent2.namespaceURI === MATHML_NAMESPACE) {
3170
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
3171
+ }
3172
+ return Boolean(ALL_SVG_TAGS[tagName]);
3173
+ }
3174
+ if (element.namespaceURI === MATHML_NAMESPACE) {
3175
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3176
+ return tagName === "math";
3177
+ }
3178
+ if (parent2.namespaceURI === SVG_NAMESPACE) {
3179
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
3180
+ }
3181
+ return Boolean(ALL_MATHML_TAGS[tagName]);
3182
+ }
3183
+ if (element.namespaceURI === HTML_NAMESPACE) {
3184
+ if (parent2.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
3185
+ return false;
3186
+ }
3187
+ if (parent2.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
3188
+ return false;
3189
+ }
3190
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
3191
+ }
3192
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
3193
+ return true;
3194
+ }
3195
+ return false;
3196
+ };
3197
+ const _forceRemove = function _forceRemove2(node) {
3198
+ arrayPush(DOMPurify.removed, {
3199
+ element: node
3200
+ });
3201
+ try {
3202
+ getParentNode(node).removeChild(node);
3203
+ } catch (_) {
3204
+ remove2(node);
3205
+ }
3206
+ };
3207
+ const _removeAttribute = function _removeAttribute2(name2, element) {
3208
+ try {
3209
+ arrayPush(DOMPurify.removed, {
3210
+ attribute: element.getAttributeNode(name2),
3211
+ from: element
3212
+ });
3213
+ } catch (_) {
3214
+ arrayPush(DOMPurify.removed, {
3215
+ attribute: null,
3216
+ from: element
3217
+ });
3218
+ }
3219
+ element.removeAttribute(name2);
3220
+ if (name2 === "is") {
3221
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
3222
+ try {
3223
+ _forceRemove(element);
3224
+ } catch (_) {
3225
+ }
3226
+ } else {
3227
+ try {
3228
+ element.setAttribute(name2, "");
3229
+ } catch (_) {
3230
+ }
3231
+ }
3232
+ }
3233
+ };
3234
+ const _initDocument = function _initDocument2(dirty) {
3235
+ let doc = null;
3236
+ let leadingWhitespace = null;
3237
+ if (FORCE_BODY) {
3238
+ dirty = "<remove></remove>" + dirty;
3239
+ } else {
3240
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
3241
+ leadingWhitespace = matches && matches[0];
3242
+ }
3243
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
3244
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
3245
+ }
3246
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
3247
+ if (NAMESPACE === HTML_NAMESPACE) {
3248
+ try {
3249
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
3250
+ } catch (_) {
3251
+ }
3252
+ }
3253
+ if (!doc || !doc.documentElement) {
3254
+ doc = implementation.createDocument(NAMESPACE, "template", null);
3255
+ try {
3256
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
3257
+ } catch (_) {
3258
+ }
3259
+ }
3260
+ const body = doc.body || doc.documentElement;
3261
+ if (dirty && leadingWhitespace) {
3262
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
3263
+ }
3264
+ if (NAMESPACE === HTML_NAMESPACE) {
3265
+ return getElementsByTagName2.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
3266
+ }
3267
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
3268
+ };
3269
+ const _createNodeIterator = function _createNodeIterator2(root2) {
3270
+ return createNodeIterator.call(
3271
+ root2.ownerDocument || root2,
3272
+ root2,
3273
+ // eslint-disable-next-line no-bitwise
3274
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
3275
+ null
3276
+ );
3277
+ };
3278
+ const _isClobbered = function _isClobbered2(element) {
3279
+ return element instanceof HTMLFormElement && (typeof element.nodeName !== "string" || typeof element.textContent !== "string" || typeof element.removeChild !== "function" || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== "function" || typeof element.setAttribute !== "function" || typeof element.namespaceURI !== "string" || typeof element.insertBefore !== "function" || typeof element.hasChildNodes !== "function");
3280
+ };
3281
+ const _isNode = function _isNode2(value) {
3282
+ return typeof Node3 === "function" && value instanceof Node3;
3283
+ };
3284
+ function _executeHooks(hooks2, currentNode, data2) {
3285
+ arrayForEach(hooks2, (hook) => {
3286
+ hook.call(DOMPurify, currentNode, data2, CONFIG);
3287
+ });
3288
+ }
3289
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
3290
+ let content = null;
3291
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
3292
+ if (_isClobbered(currentNode)) {
3293
+ _forceRemove(currentNode);
3294
+ return true;
3295
+ }
3296
+ const tagName = transformCaseFunc(currentNode.nodeName);
3297
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
3298
+ tagName,
3299
+ allowedTags: ALLOWED_TAGS
3300
+ });
3301
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
3302
+ _forceRemove(currentNode);
3303
+ return true;
3304
+ }
3305
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
3306
+ _forceRemove(currentNode);
3307
+ return true;
3308
+ }
3309
+ if (currentNode.nodeType === NODE_TYPE$1.progressingInstruction) {
3310
+ _forceRemove(currentNode);
3311
+ return true;
3312
+ }
3313
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE$1.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
3314
+ _forceRemove(currentNode);
3315
+ return true;
3316
+ }
3317
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
3318
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
3319
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
3320
+ return false;
3321
+ }
3322
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
3323
+ return false;
3324
+ }
3325
+ }
3326
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
3327
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
3328
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
3329
+ if (childNodes && parentNode) {
3330
+ const childCount = childNodes.length;
3331
+ for (let i = childCount - 1; i >= 0; --i) {
3332
+ const childClone = cloneNode2(childNodes[i], true);
3333
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
3334
+ }
3335
+ }
3336
+ }
3337
+ _forceRemove(currentNode);
3338
+ return true;
3339
+ }
3340
+ if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
3341
+ _forceRemove(currentNode);
3342
+ return true;
3343
+ }
3344
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
3345
+ _forceRemove(currentNode);
3346
+ return true;
3347
+ }
3348
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE$1.text) {
3349
+ content = currentNode.textContent;
3350
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3351
+ content = stringReplace(content, expr, " ");
3352
+ });
3353
+ if (currentNode.textContent !== content) {
3354
+ arrayPush(DOMPurify.removed, {
3355
+ element: currentNode.cloneNode()
3356
+ });
3357
+ currentNode.textContent = content;
3358
+ }
3359
+ }
3360
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
3361
+ return false;
3362
+ };
3363
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
3364
+ if (FORBID_ATTR[lcName]) {
3365
+ return false;
3366
+ }
3367
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
3368
+ return false;
3369
+ }
3370
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
3371
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
3372
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
3373
+ else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
3374
+ if (
3375
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
3376
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3377
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
3378
+ _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || // Alternative, second condition checks if it's an `is`-attribute, AND
3379
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3380
+ lcName === "is" && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))
3381
+ ) ;
3382
+ else {
3383
+ return false;
3384
+ }
3385
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
3386
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3387
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
3388
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3389
+ else if (value) {
3390
+ return false;
3391
+ } else ;
3392
+ return true;
3393
+ };
3394
+ const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ["annotation-xml", "color-profile", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "missing-glyph"]);
3395
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
3396
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
3397
+ };
3398
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
3399
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
3400
+ const attributes2 = currentNode.attributes;
3401
+ if (!attributes2 || _isClobbered(currentNode)) {
3402
+ return;
3403
+ }
3404
+ const hookEvent = {
3405
+ attrName: "",
3406
+ attrValue: "",
3407
+ keepAttr: true,
3408
+ allowedAttributes: ALLOWED_ATTR,
3409
+ forceKeepAttr: void 0
3410
+ };
3411
+ let l2 = attributes2.length;
3412
+ while (l2--) {
3413
+ const attr2 = attributes2[l2];
3414
+ const name2 = attr2.name, namespaceURI = attr2.namespaceURI, attrValue = attr2.value;
3415
+ const lcName = transformCaseFunc(name2);
3416
+ const initValue = attrValue;
3417
+ let value = name2 === "value" ? initValue : stringTrim(initValue);
3418
+ hookEvent.attrName = lcName;
3419
+ hookEvent.attrValue = value;
3420
+ hookEvent.keepAttr = true;
3421
+ hookEvent.forceKeepAttr = void 0;
3422
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
3423
+ value = hookEvent.attrValue;
3424
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
3425
+ _removeAttribute(name2, currentNode);
3426
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
3427
+ }
3428
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
3429
+ _removeAttribute(name2, currentNode);
3430
+ continue;
3431
+ }
3432
+ if (lcName === "attributename" && stringMatch(value, "href")) {
3433
+ _removeAttribute(name2, currentNode);
3434
+ continue;
3435
+ }
3436
+ if (hookEvent.forceKeepAttr) {
3437
+ continue;
3438
+ }
3439
+ if (!hookEvent.keepAttr) {
3440
+ _removeAttribute(name2, currentNode);
3441
+ continue;
3442
+ }
3443
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
3444
+ _removeAttribute(name2, currentNode);
3445
+ continue;
3446
+ }
3447
+ if (SAFE_FOR_TEMPLATES) {
3448
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3449
+ value = stringReplace(value, expr, " ");
3450
+ });
3451
+ }
3452
+ const lcTag = transformCaseFunc(currentNode.nodeName);
3453
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3454
+ _removeAttribute(name2, currentNode);
3455
+ continue;
3456
+ }
3457
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
3458
+ if (namespaceURI) ;
3459
+ else {
3460
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
3461
+ case "TrustedHTML": {
3462
+ value = trustedTypesPolicy.createHTML(value);
3463
+ break;
3464
+ }
3465
+ case "TrustedScriptURL": {
3466
+ value = trustedTypesPolicy.createScriptURL(value);
3467
+ break;
3468
+ }
3469
+ }
3470
+ }
3471
+ }
3472
+ if (value !== initValue) {
3473
+ try {
3474
+ if (namespaceURI) {
3475
+ currentNode.setAttributeNS(namespaceURI, name2, value);
3476
+ } else {
3477
+ currentNode.setAttribute(name2, value);
3478
+ }
3479
+ if (_isClobbered(currentNode)) {
3480
+ _forceRemove(currentNode);
3481
+ } else {
3482
+ arrayPop(DOMPurify.removed);
3483
+ }
3484
+ } catch (_) {
3485
+ _removeAttribute(name2, currentNode);
3486
+ }
3487
+ }
3488
+ }
3489
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3490
+ };
3491
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3492
+ let shadowNode = null;
3493
+ const shadowIterator = _createNodeIterator(fragment);
3494
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3495
+ while (shadowNode = shadowIterator.nextNode()) {
3496
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3497
+ _sanitizeElements(shadowNode);
3498
+ _sanitizeAttributes(shadowNode);
3499
+ if (shadowNode.content instanceof DocumentFragment) {
3500
+ _sanitizeShadowDOM2(shadowNode.content);
3501
+ }
3502
+ }
3503
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3504
+ };
3505
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root2) {
3506
+ if (root2.nodeType === NODE_TYPE$1.element && root2.shadowRoot instanceof DocumentFragment) {
3507
+ const sr = root2.shadowRoot;
3508
+ _sanitizeAttachedShadowRoots2(sr);
3509
+ _sanitizeShadowDOM2(sr);
3510
+ }
3511
+ const childNodes = root2.childNodes;
3512
+ if (!childNodes) {
3513
+ return;
3514
+ }
3515
+ const snapshot = [];
3516
+ arrayForEach(childNodes, (child) => {
3517
+ arrayPush(snapshot, child);
3518
+ });
3519
+ for (const child of snapshot) {
3520
+ _sanitizeAttachedShadowRoots2(child);
3521
+ }
3522
+ };
3523
+ DOMPurify.sanitize = function(dirty) {
3524
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3525
+ let body = null;
3526
+ let importedNode = null;
3527
+ let currentNode = null;
3528
+ let returnNode = null;
3529
+ IS_EMPTY_INPUT = !dirty;
3530
+ if (IS_EMPTY_INPUT) {
3531
+ dirty = "<!-->";
3532
+ }
3533
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
3534
+ dirty = stringifyValue(dirty);
3535
+ if (typeof dirty !== "string") {
3536
+ throw typeErrorCreate("dirty is not a string, aborting");
3537
+ }
3538
+ }
3539
+ if (!DOMPurify.isSupported) {
3540
+ return dirty;
3541
+ }
3542
+ if (!SET_CONFIG) {
3543
+ _parseConfig(cfg);
3544
+ }
3545
+ DOMPurify.removed = [];
3546
+ if (typeof dirty === "string") {
3547
+ IN_PLACE = false;
3548
+ }
3549
+ if (IN_PLACE) {
3550
+ const nn = dirty.nodeName;
3551
+ if (typeof nn === "string") {
3552
+ const tagName = transformCaseFunc(nn);
3553
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3554
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
3555
+ }
3556
+ }
3557
+ _sanitizeAttachedShadowRoots2(dirty);
3558
+ } else if (dirty instanceof Node3) {
3559
+ body = _initDocument("<!---->");
3560
+ importedNode = body.ownerDocument.importNode(dirty, true);
3561
+ if (importedNode.nodeType === NODE_TYPE$1.element && importedNode.nodeName === "BODY") {
3562
+ body = importedNode;
3563
+ } else if (importedNode.nodeName === "HTML") {
3564
+ body = importedNode;
3565
+ } else {
3566
+ body.appendChild(importedNode);
3567
+ }
3568
+ _sanitizeAttachedShadowRoots2(importedNode);
3569
+ } else {
3570
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
3571
+ dirty.indexOf("<") === -1) {
3572
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
3573
+ }
3574
+ body = _initDocument(dirty);
3575
+ if (!body) {
3576
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
3577
+ }
3578
+ }
3579
+ if (body && FORCE_BODY) {
3580
+ _forceRemove(body.firstChild);
3581
+ }
3582
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
3583
+ while (currentNode = nodeIterator.nextNode()) {
3584
+ _sanitizeElements(currentNode);
3585
+ _sanitizeAttributes(currentNode);
3586
+ if (currentNode.content instanceof DocumentFragment) {
3587
+ _sanitizeShadowDOM2(currentNode.content);
3588
+ }
3589
+ }
3590
+ if (IN_PLACE) {
3591
+ return dirty;
3592
+ }
3593
+ if (RETURN_DOM) {
3594
+ if (SAFE_FOR_TEMPLATES) {
3595
+ body.normalize();
3596
+ let html2 = body.innerHTML;
3597
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3598
+ html2 = stringReplace(html2, expr, " ");
3599
+ });
3600
+ body.innerHTML = html2;
3601
+ }
3602
+ if (RETURN_DOM_FRAGMENT) {
3603
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3604
+ while (body.firstChild) {
3605
+ returnNode.appendChild(body.firstChild);
3606
+ }
3607
+ } else {
3608
+ returnNode = body;
3609
+ }
3610
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3611
+ returnNode = importNode.call(originalDocument, returnNode, true);
3612
+ }
3613
+ return returnNode;
3614
+ }
3615
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3616
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3617
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
3618
+ }
3619
+ if (SAFE_FOR_TEMPLATES) {
3620
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3621
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
3622
+ });
3623
+ }
3624
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
3625
+ };
3626
+ DOMPurify.setConfig = function() {
3627
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3628
+ _parseConfig(cfg);
3629
+ SET_CONFIG = true;
3630
+ };
3631
+ DOMPurify.clearConfig = function() {
3632
+ CONFIG = null;
3633
+ SET_CONFIG = false;
3634
+ };
3635
+ DOMPurify.isValidAttribute = function(tag, attr2, value) {
3636
+ if (!CONFIG) {
3637
+ _parseConfig({});
3638
+ }
3639
+ const lcTag = transformCaseFunc(tag);
3640
+ const lcName = transformCaseFunc(attr2);
3641
+ return _isValidAttribute(lcTag, lcName, value);
3642
+ };
3643
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
3644
+ if (typeof hookFunction !== "function") {
3645
+ return;
3646
+ }
3647
+ arrayPush(hooks[entryPoint], hookFunction);
3648
+ };
3649
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
3650
+ if (hookFunction !== void 0) {
3651
+ const index2 = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3652
+ return index2 === -1 ? void 0 : arraySplice(hooks[entryPoint], index2, 1)[0];
3653
+ }
3654
+ return arrayPop(hooks[entryPoint]);
3655
+ };
3656
+ DOMPurify.removeHooks = function(entryPoint) {
3657
+ hooks[entryPoint] = [];
3658
+ };
3659
+ DOMPurify.removeAllHooks = function() {
3660
+ hooks = _createHooksMap();
3661
+ };
3662
+ return DOMPurify;
3663
+ }
3664
+ var purify = createDOMPurify();
2429
3665
  ABConvert.factory({
2430
3666
  id: "md",
2431
3667
  name: "md",
@@ -2445,7 +3681,7 @@ ABConvert.factory({
2445
3681
  process_param: ABConvert_IOEnum.text,
2446
3682
  process_return: ABConvert_IOEnum.el,
2447
3683
  process: (el, header, content) => {
2448
- el.innerHTML = `<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`;
3684
+ el.innerHTML = purify.sanitize(`<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`);
2449
3685
  return el;
2450
3686
  }
2451
3687
  });
@@ -2480,7 +3716,26 @@ ABConvert.factory({
2480
3716
  sub_button.textContent = "折叠";
2481
3717
  }
2482
3718
  };
2483
- sub_button.onclick = fn_fold;
3719
+ if (ABCSetting.env.startsWith("obsidian")) {
3720
+ sub_button.onclick = fn_fold;
3721
+ } else {
3722
+ sub_button.setAttribute("onclick", `
3723
+ const sub_button = this;
3724
+ const sub_el = this.nextElementSibling;
3725
+
3726
+ const is_hide = sub_el.getAttribute("is_hide")
3727
+ if (is_hide && is_hide=="false") {
3728
+ sub_el.setAttribute("is_hide", "true");
3729
+ sub_el.style.display = "none"
3730
+ sub_button.textContent = "展开"
3731
+ }
3732
+ else if(is_hide && is_hide=="true") {
3733
+ sub_el.setAttribute("is_hide", "false");
3734
+ sub_el.style.display = ""
3735
+ sub_button.textContent = "折叠"
3736
+ }
3737
+ `);
3738
+ }
2484
3739
  mid_el.appendChild(sub_button);
2485
3740
  mid_el.appendChild(sub_el);
2486
3741
  const isListTable = sub_el.classList.contains("ab-list-table-parent");
@@ -3146,12 +4401,10 @@ ABConvert.factory({
3146
4401
  process_return: ABConvert_IOEnum.json,
3147
4402
  process: (el, header, content) => {
3148
4403
  return JSON.stringify(
3149
- ABAlias_json.map((item) => {
3150
- return {
3151
- regex: item.regex.toString(),
3152
- replacement: item.replacement
3153
- };
3154
- }),
4404
+ Array.from(get_ABAlias_iter(), (item) => ({
4405
+ regex: item.regex.toString(),
4406
+ replacement: item.replacement
4407
+ })),
3155
4408
  null,
3156
4409
  2
3157
4410
  );
@@ -15102,7 +16355,7 @@ ABConvert.factory({
15102
16355
  async function render_pumlText(text2, div) {
15103
16356
  var encoded = plantumlEncoder.encode(text2);
15104
16357
  let url = "http://www.plantuml.com/plantuml/img/" + encoded;
15105
- div.innerHTML = `<img src="${url}">`;
16358
+ div.innerHTML = purify.sanitize(`<img src="${url}">`);
15106
16359
  return div;
15107
16360
  }
15108
16361
  function getID(length = 16) {
@@ -15277,206 +16530,20 @@ async function data2mindmap(list_itemInfo, div) {
15277
16530
  return render_mermaidText(mermaidText, div);
15278
16531
  }
15279
16532
  async function render_mermaidText(mermaidText, div) {
15280
- if (ABCSetting.env.startsWith("obsidian") && ABCSetting.mermaid) {
15281
- ABCSetting.mermaid.then(async (mermaid) => {
15282
- const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
15283
- div.innerHTML = svg;
16533
+ if (ABCSetting.env.startsWith("obsidian") && ABCSetting.obsidian.mermaid) {
16534
+ ABCSetting.obsidian.mermaid.then(async (mermaid) => {
16535
+ const { svg: svg2 } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
16536
+ const div_mermaid = document.createElement("div");
16537
+ div.appendChild(div_mermaid);
16538
+ div_mermaid.classList.add("mermaid");
16539
+ div_mermaid.innerHTML = svg2;
15284
16540
  });
15285
16541
  } else {
15286
16542
  div.classList.add("ab-raw");
15287
- div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
16543
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`);
15288
16544
  }
15289
16545
  return div;
15290
16546
  }
15291
- function abConvertEvent(d, isCycle = false) {
15292
- if (d.querySelector(".ab-super-width")) {
15293
- const els_note = d.querySelectorAll(".ab-note");
15294
- for (const el_note of els_note) {
15295
- if (el_note.querySelector(".ab-super-width")) {
15296
- const el_replace = el_note.parentNode;
15297
- if (el_replace && el_replace.classList.contains("ab-replace")) {
15298
- el_replace.classList.add("ab-super-width-p");
15299
- }
15300
- }
15301
- }
15302
- const els_view = document.querySelectorAll(".app-container .workspace-leaf");
15303
- for (const el_view of els_view) {
15304
- el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
15305
- }
15306
- }
15307
- if (d.querySelector(".ab-nodes-node")) {
15308
- const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
15309
- const list_children = d.querySelectorAll(".ab-nodes-node");
15310
- for (const children2 of list_children) {
15311
- const el_content = children2.querySelector(".ab-nodes-content");
15312
- if (!el_content) continue;
15313
- const el_child = children2.querySelector(".ab-nodes-children");
15314
- if (!el_child) continue;
15315
- const el_bracket = el_child.querySelector(".ab-nodes-bracket");
15316
- if (!el_bracket) continue;
15317
- const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
15318
- if (!el_bracket2) continue;
15319
- const els_child = el_child.childNodes;
15320
- if (els_child.length < 3) {
15321
- el_bracket.style.setProperty("display", "none");
15322
- el_bracket2.style.setProperty("display", "none");
15323
- continue;
15324
- }
15325
- const el_child_first = els_child[2];
15326
- const el_child_last = els_child[els_child.length - 1];
15327
- const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
15328
- const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
15329
- let height = 0;
15330
- let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
15331
- if (els_child.length == 3) {
15332
- height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
15333
- el_bracket2.style.cssText = `
15334
- height: ${height}px;
15335
- top: calc(50% - ${height / 2}px);
15336
- `;
15337
- } else {
15338
- el_bracket2.style.cssText = `
15339
- height: calc(100% - ${heightToReduce}px);
15340
- top: ${el_child_first.offsetHeight / 2}px;
15341
- `;
15342
- }
15343
- if (Array.prototype.includes.call(els_min, children2)) {
15344
- if (els_child.length == 3) {
15345
- el_bracket.style.cssText = `
15346
- display: block;
15347
- top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
15348
- clip-path: circle(40% at 50% 40%);
15349
- `;
15350
- } else {
15351
- el_bracket.setAttribute("display", "none");
15352
- }
15353
- if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
15354
- el_bracket2.style.cssText = `
15355
- height: 1px;
15356
- top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
15357
- width: 18px; /* 可以溢出点 */
15358
- border-radius: 0;
15359
- border: none;
15360
- border-bottom: 1px solid var(--node-color);
15361
- `;
15362
- } else {
15363
- if (els_child.length == 3) {
15364
- height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
15365
- el_bracket2.style.setProperty("height", `${height}px`);
15366
- el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
15367
- el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
15368
- el_bracket2.style.setProperty("border-top", `0`);
15369
- } else {
15370
- heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
15371
- el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
15372
- el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
15373
- }
15374
- el_bracket2.style.setProperty("width", "20px");
15375
- }
15376
- }
15377
- }
15378
- }
15379
- if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
15380
- const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
15381
- for (const root_el of root_el_list) {
15382
- root_el.classList.add("js-waterfall");
15383
- const list_children = root_el.querySelectorAll(".ab-items-item");
15384
- const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
15385
- let columnCount;
15386
- if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
15387
- columnCount = columnCountTmp;
15388
- } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
15389
- columnCount = list_children.length;
15390
- root_el.classList.add("ab-col" + columnCount);
15391
- } else {
15392
- columnCount = 4;
15393
- root_el.classList.add("ab-col" + columnCount);
15394
- }
15395
- const height_cache = [];
15396
- const el_cache = [];
15397
- for (let i = 0; i < columnCount; i++) {
15398
- height_cache.push(0);
15399
- el_cache.push([]);
15400
- }
15401
- for (const children2 of list_children) {
15402
- const minValue = Math.min.apply(null, height_cache);
15403
- const minIndex = height_cache.indexOf(minValue);
15404
- const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
15405
- height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
15406
- el_cache[minIndex].push(children2);
15407
- }
15408
- const fillNumber = columnCount - list_children.length % columnCount;
15409
- if (fillNumber != 4) {
15410
- for (let i = 0; i < fillNumber; i++) {
15411
- const children2 = document.createElement("div");
15412
- children2.classList.add(".ab-items-item.placeholder");
15413
- children2.setAttribute("style", "height: 20px");
15414
- const minValue = Math.min.apply(null, height_cache);
15415
- const minIndex = height_cache.indexOf(minValue);
15416
- height_cache[minIndex] += 20;
15417
- el_cache[minIndex].push(children2);
15418
- }
15419
- }
15420
- root_el.innerHTML = "";
15421
- for (let i = 0; i < columnCount; i++) {
15422
- for (const j of el_cache[i]) {
15423
- root_el.appendChild(j);
15424
- }
15425
- }
15426
- }
15427
- }
15428
- if (!isCycle && d.querySelector(".ab-markmap-div")) {
15429
- const divEl = d;
15430
- let markmapId = "";
15431
- if (divEl.tagName === "DIV") {
15432
- markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
15433
- }
15434
- let mindmaps;
15435
- if (markmapId) {
15436
- mindmaps = document.querySelectorAll("#" + markmapId);
15437
- } else {
15438
- mindmaps = document.querySelectorAll(".ab-markmap-div");
15439
- }
15440
- for (const el_div of mindmaps) {
15441
- const el_svg = el_div.querySelector("svg");
15442
- const el_g = el_svg?.querySelector("g");
15443
- if (el_svg && el_g) {
15444
- const scale_new = el_g.getBBox().height / el_div.offsetWidth;
15445
- el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
15446
- markmap_event(d);
15447
- }
15448
- }
15449
- }
15450
- }
15451
- function markmap_event(d) {
15452
- if (d.querySelector(".ab-markmap-svg")) {
15453
- console.log(" - markmap_event");
15454
- let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
15455
- if (script_el) script_el.remove();
15456
- const divEl = d;
15457
- let markmapId = "";
15458
- if (divEl.tagName === "DIV") {
15459
- markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
15460
- }
15461
- script_el = document.createElement("script");
15462
- document.head.appendChild(script_el);
15463
- script_el.type = "module";
15464
- script_el.setAttribute("script-id", "ab-markmap-script");
15465
- script_el.textContent = `
15466
- import { Markmap, } from 'https://jspm.dev/markmap-view';
15467
- const markmapId = "${markmapId || ""}";
15468
- let mindmaps;
15469
- if (markmapId) {
15470
- mindmaps = document.querySelectorAll('#' + markmapId);
15471
- } else {
15472
- mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
15473
- }
15474
- for(const mindmap of mindmaps) {
15475
- mindmap.innerHTML = "";
15476
- Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
15477
- }`;
15478
- }
15479
- }
15480
16547
  const testPath = "npm2url/dist/index.cjs";
15481
16548
  const defaultProviders = {
15482
16549
  jsdelivr: (path) => `https://cdn.jsdelivr.net/npm/${path}`,
@@ -41102,8 +42169,8 @@ function requireKatex() {
41102
42169
  var _functions = {};
41103
42170
  var _htmlGroupBuilders = {};
41104
42171
  var _mathmlGroupBuilders = {};
41105
- function defineFunction(_ref) {
41106
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
42172
+ function defineFunction(_ref2) {
42173
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
41107
42174
  var data2 = {
41108
42175
  type,
41109
42176
  numArgs: props.numArgs,
@@ -42101,8 +43168,8 @@ function requireKatex() {
42101
43168
  props: {
42102
43169
  numArgs: 1
42103
43170
  },
42104
- handler: function handler(_ref, args) {
42105
- var parser = _ref.parser, funcName = _ref.funcName;
43171
+ handler: function handler(_ref2, args) {
43172
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42106
43173
  var base = args[0];
42107
43174
  return {
42108
43175
  type: "accentUnder",
@@ -42177,8 +43244,8 @@ function requireKatex() {
42177
43244
  numArgs: 1,
42178
43245
  numOptionalArgs: 1
42179
43246
  },
42180
- handler: function handler(_ref, args, optArgs) {
42181
- var parser = _ref.parser, funcName = _ref.funcName;
43247
+ handler: function handler(_ref2, args, optArgs) {
43248
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42182
43249
  return {
42183
43250
  type: "xArrow",
42184
43251
  mode: parser.mode,
@@ -42270,8 +43337,8 @@ function requireKatex() {
42270
43337
  numArgs: 1,
42271
43338
  allowedInText: true
42272
43339
  },
42273
- handler: function handler(_ref, args) {
42274
- var parser = _ref.parser;
43340
+ handler: function handler(_ref2, args) {
43341
+ var parser = _ref2.parser;
42275
43342
  var arg = assertNodeType(args[0], "ordgroup");
42276
43343
  var group = arg.body;
42277
43344
  var number = "";
@@ -42309,8 +43376,8 @@ function requireKatex() {
42309
43376
  greediness: 3,
42310
43377
  argTypes: ["color", "original"]
42311
43378
  },
42312
- handler: function handler(_ref, args) {
42313
- var parser = _ref.parser;
43379
+ handler: function handler(_ref2, args) {
43380
+ var parser = _ref2.parser;
42314
43381
  var color2 = assertNodeType(args[0], "color-token").color;
42315
43382
  var body = args[1];
42316
43383
  return {
@@ -42356,8 +43423,8 @@ function requireKatex() {
42356
43423
  argTypes: ["size"],
42357
43424
  allowedInText: true
42358
43425
  },
42359
- handler: function handler(_ref, args, optArgs) {
42360
- var parser = _ref.parser, funcName = _ref.funcName;
43426
+ handler: function handler(_ref2, args, optArgs) {
43427
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42361
43428
  var size = optArgs[0];
42362
43429
  var newRow = funcName === "\\cr";
42363
43430
  var newLine = false;
@@ -42450,8 +43517,8 @@ function requireKatex() {
42450
43517
  numArgs: 0,
42451
43518
  allowedInText: true
42452
43519
  },
42453
- handler: function handler(_ref) {
42454
- var parser = _ref.parser, funcName = _ref.funcName;
43520
+ handler: function handler(_ref2) {
43521
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42455
43522
  parser.consumeSpaces();
42456
43523
  var token = parser.fetch();
42457
43524
  if (globalMap[token.text]) {
@@ -42785,14 +43852,14 @@ function requireKatex() {
42785
43852
  var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
42786
43853
  var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
42787
43854
  var pathNode = new domTree_PathNode(sqrtName, path);
42788
- var svg = new SvgNode([pathNode], {
43855
+ var svg2 = new SvgNode([pathNode], {
42789
43856
  // Note: 1000:1 ratio of viewBox to document em width.
42790
43857
  "width": "400em",
42791
43858
  "height": height + "em",
42792
43859
  "viewBox": "0 0 400000 " + viewBoxHeight,
42793
43860
  "preserveAspectRatio": "xMinYMin slice"
42794
43861
  });
42795
- return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
43862
+ return buildCommon.makeSvgSpan(["hide-tail"], [svg2], options);
42796
43863
  };
42797
43864
  var makeSqrtImage = function makeSqrtImage2(height, options) {
42798
43865
  var newOptions = options.havingBaseSizing();
@@ -43402,8 +44469,8 @@ function requireKatex() {
43402
44469
  greediness: 3,
43403
44470
  argTypes: ["color", "text"]
43404
44471
  },
43405
- handler: function handler(_ref, args, optArgs) {
43406
- var parser = _ref.parser, funcName = _ref.funcName;
44472
+ handler: function handler(_ref2, args, optArgs) {
44473
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43407
44474
  var color2 = assertNodeType(args[0], "color-token").color;
43408
44475
  var body = args[1];
43409
44476
  return {
@@ -43481,8 +44548,8 @@ function requireKatex() {
43481
44548
  mathmlBuilder: enclose_mathmlBuilder
43482
44549
  });
43483
44550
  var _environments = {};
43484
- function defineEnvironment(_ref) {
43485
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
44551
+ function defineEnvironment(_ref2) {
44552
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
43486
44553
  var data2 = {
43487
44554
  type,
43488
44555
  numArgs: props.numArgs || 0,
@@ -43513,8 +44580,8 @@ function requireKatex() {
43513
44580
  }
43514
44581
  return hlineInfo;
43515
44582
  }
43516
- function parseArray(parser, _ref, style) {
43517
- var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, addJot = _ref.addJot, cols = _ref.cols, arraystretch = _ref.arraystretch, colSeparationType = _ref.colSeparationType;
44583
+ function parseArray(parser, _ref2, style) {
44584
+ var hskipBeforeAndAfter = _ref2.hskipBeforeAndAfter, addJot = _ref2.addJot, cols = _ref2.cols, arraystretch = _ref2.arraystretch, colSeparationType = _ref2.colSeparationType;
43518
44585
  parser.gullet.beginGroup();
43519
44586
  parser.gullet.macros.set("\\\\", "\\cr");
43520
44587
  if (!arraystretch) {
@@ -44153,8 +45220,8 @@ function requireKatex() {
44153
45220
  numArgs: 1,
44154
45221
  argTypes: ["text"]
44155
45222
  },
44156
- handler: function handler(_ref, args) {
44157
- var parser = _ref.parser, funcName = _ref.funcName;
45223
+ handler: function handler(_ref2, args) {
45224
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44158
45225
  var nameGroup = args[0];
44159
45226
  if (nameGroup.type !== "ordgroup") {
44160
45227
  throw new src_ParseError("Invalid environment name", nameGroup);
@@ -44234,8 +45301,8 @@ function requireKatex() {
44234
45301
  props: {
44235
45302
  numArgs: 1
44236
45303
  },
44237
- handler: function handler(_ref, args) {
44238
- var parser = _ref.parser, funcName = _ref.funcName;
45304
+ handler: function handler(_ref2, args) {
45305
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44239
45306
  var body = args[0];
44240
45307
  return {
44241
45308
  type: "mclass",
@@ -44358,8 +45425,8 @@ function requireKatex() {
44358
45425
  numArgs: 1,
44359
45426
  greediness: 2
44360
45427
  },
44361
- handler: function handler(_ref, args) {
44362
- var parser = _ref.parser, funcName = _ref.funcName;
45428
+ handler: function handler(_ref2, args) {
45429
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44363
45430
  var body = args[0];
44364
45431
  var func = funcName;
44365
45432
  if (func in fontAliases) {
@@ -44613,8 +45680,8 @@ function requireKatex() {
44613
45680
  numArgs: 2,
44614
45681
  greediness: 2
44615
45682
  },
44616
- handler: function handler(_ref, args) {
44617
- var parser = _ref.parser, funcName = _ref.funcName;
45683
+ handler: function handler(_ref2, args) {
45684
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44618
45685
  var numer = args[0];
44619
45686
  var denom = args[1];
44620
45687
  var hasBarLine;
@@ -44915,8 +45982,8 @@ function requireKatex() {
44915
45982
  props: {
44916
45983
  numArgs: 1
44917
45984
  },
44918
- handler: function handler(_ref, args) {
44919
- var parser = _ref.parser, funcName = _ref.funcName;
45985
+ handler: function handler(_ref2, args) {
45986
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44920
45987
  return {
44921
45988
  type: "horizBrace",
44922
45989
  mode: parser.mode,
@@ -44936,8 +46003,8 @@ function requireKatex() {
44936
46003
  argTypes: ["url", "original"],
44937
46004
  allowedInText: true
44938
46005
  },
44939
- handler: function handler(_ref, args) {
44940
- var parser = _ref.parser;
46006
+ handler: function handler(_ref2, args) {
46007
+ var parser = _ref2.parser;
44941
46008
  var body = args[1];
44942
46009
  var href = assertNodeType(args[0], "url").url;
44943
46010
  if (!parser.settings.isTrusted({
@@ -45017,9 +46084,9 @@ function requireKatex() {
45017
46084
  argTypes: ["raw", "original"],
45018
46085
  allowedInText: true
45019
46086
  },
45020
- handler: function handler(_ref, args) {
45021
- var parser = _ref.parser, funcName = _ref.funcName;
45022
- _ref.token;
46087
+ handler: function handler(_ref2, args) {
46088
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46089
+ _ref2.token;
45023
46090
  var value = assertNodeType(args[0], "raw").string;
45024
46091
  var body = args[1];
45025
46092
  if (parser.settings.strict) {
@@ -45102,8 +46169,8 @@ function requireKatex() {
45102
46169
  numArgs: 2,
45103
46170
  allowedInText: true
45104
46171
  },
45105
- handler: function handler(_ref, args) {
45106
- var parser = _ref.parser;
46172
+ handler: function handler(_ref2, args) {
46173
+ var parser = _ref2.parser;
45107
46174
  return {
45108
46175
  type: "htmlmathml",
45109
46176
  mode: parser.mode,
@@ -45150,8 +46217,8 @@ function requireKatex() {
45150
46217
  argTypes: ["raw", "url"],
45151
46218
  allowedInText: false
45152
46219
  },
45153
- handler: function handler(_ref, args, optArgs) {
45154
- var parser = _ref.parser;
46220
+ handler: function handler(_ref2, args, optArgs) {
46221
+ var parser = _ref2.parser;
45155
46222
  var width = {
45156
46223
  number: 0,
45157
46224
  unit: "em"
@@ -45265,8 +46332,8 @@ function requireKatex() {
45265
46332
  argTypes: ["size"],
45266
46333
  allowedInText: true
45267
46334
  },
45268
- handler: function handler(_ref, args) {
45269
- var parser = _ref.parser, funcName = _ref.funcName;
46335
+ handler: function handler(_ref2, args) {
46336
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45270
46337
  var size = assertNodeType(args[0], "size");
45271
46338
  if (parser.settings.strict) {
45272
46339
  var mathFunction = funcName[1] === "m";
@@ -45305,8 +46372,8 @@ function requireKatex() {
45305
46372
  numArgs: 1,
45306
46373
  allowedInText: true
45307
46374
  },
45308
- handler: function handler(_ref, args) {
45309
- var parser = _ref.parser, funcName = _ref.funcName;
46375
+ handler: function handler(_ref2, args) {
46376
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45310
46377
  var body = args[0];
45311
46378
  return {
45312
46379
  type: "lap",
@@ -45350,8 +46417,8 @@ function requireKatex() {
45350
46417
  allowedInText: true,
45351
46418
  allowedInMath: false
45352
46419
  },
45353
- handler: function handler(_ref, args) {
45354
- var funcName = _ref.funcName, parser = _ref.parser;
46420
+ handler: function handler(_ref2, args) {
46421
+ var funcName = _ref2.funcName, parser = _ref2.parser;
45355
46422
  var outerMode = parser.mode;
45356
46423
  parser.switchMode("math");
45357
46424
  var close = funcName === "\\(" ? "\\)" : "$";
@@ -45399,8 +46466,8 @@ function requireKatex() {
45399
46466
  props: {
45400
46467
  numArgs: 4
45401
46468
  },
45402
- handler: function handler(_ref, args) {
45403
- var parser = _ref.parser;
46469
+ handler: function handler(_ref2, args) {
46470
+ var parser = _ref2.parser;
45404
46471
  return {
45405
46472
  type: "mathchoice",
45406
46473
  mode: parser.mode,
@@ -45632,8 +46699,8 @@ function requireKatex() {
45632
46699
  props: {
45633
46700
  numArgs: 0
45634
46701
  },
45635
- handler: function handler(_ref, args) {
45636
- var parser = _ref.parser, funcName = _ref.funcName;
46702
+ handler: function handler(_ref2, args) {
46703
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45637
46704
  var fName = funcName;
45638
46705
  if (fName.length === 1) {
45639
46706
  fName = singleCharBigOps[fName];
@@ -45839,8 +46906,8 @@ function requireKatex() {
45839
46906
  props: {
45840
46907
  numArgs: 1
45841
46908
  },
45842
- handler: function handler(_ref, args) {
45843
- var parser = _ref.parser, funcName = _ref.funcName;
46909
+ handler: function handler(_ref2, args) {
46910
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45844
46911
  var body = args[0];
45845
46912
  return {
45846
46913
  type: "operatorname",
@@ -45872,8 +46939,8 @@ function requireKatex() {
45872
46939
  props: {
45873
46940
  numArgs: 1
45874
46941
  },
45875
- handler: function handler(_ref, args) {
45876
- var parser = _ref.parser;
46942
+ handler: function handler(_ref2, args) {
46943
+ var parser = _ref2.parser;
45877
46944
  var body = args[0];
45878
46945
  return {
45879
46946
  type: "overline",
@@ -45918,8 +46985,8 @@ function requireKatex() {
45918
46985
  numArgs: 1,
45919
46986
  allowedInText: true
45920
46987
  },
45921
- handler: function handler(_ref, args) {
45922
- var parser = _ref.parser;
46988
+ handler: function handler(_ref2, args) {
46989
+ var parser = _ref2.parser;
45923
46990
  var body = args[0];
45924
46991
  return {
45925
46992
  type: "phantom",
@@ -46017,8 +47084,8 @@ function requireKatex() {
46017
47084
  argTypes: ["size", "hbox"],
46018
47085
  allowedInText: true
46019
47086
  },
46020
- handler: function handler(_ref, args) {
46021
- var parser = _ref.parser;
47087
+ handler: function handler(_ref2, args) {
47088
+ var parser = _ref2.parser;
46022
47089
  var amount = assertNodeType(args[0], "size").value;
46023
47090
  var body = args[1];
46024
47091
  return {
@@ -46055,8 +47122,8 @@ function requireKatex() {
46055
47122
  numOptionalArgs: 1,
46056
47123
  argTypes: ["size", "size", "size"]
46057
47124
  },
46058
- handler: function handler(_ref, args, optArgs) {
46059
- var parser = _ref.parser;
47125
+ handler: function handler(_ref2, args, optArgs) {
47126
+ var parser = _ref2.parser;
46060
47127
  var shift = optArgs[0];
46061
47128
  var width = assertNodeType(args[0], "size");
46062
47129
  var height = assertNodeType(args[1], "size");
@@ -46129,8 +47196,8 @@ function requireKatex() {
46129
47196
  numArgs: 0,
46130
47197
  allowedInText: true
46131
47198
  },
46132
- handler: function handler(_ref, args) {
46133
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47199
+ handler: function handler(_ref2, args) {
47200
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46134
47201
  var body = parser.parseExpression(false, breakOnTokenText);
46135
47202
  return {
46136
47203
  type: "sizing",
@@ -46157,8 +47224,8 @@ function requireKatex() {
46157
47224
  numOptionalArgs: 1,
46158
47225
  allowedInText: true
46159
47226
  },
46160
- handler: function handler(_ref, args, optArgs) {
46161
- var parser = _ref.parser;
47227
+ handler: function handler(_ref2, args, optArgs) {
47228
+ var parser = _ref2.parser;
46162
47229
  var smashHeight = false;
46163
47230
  var smashDepth = false;
46164
47231
  var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
@@ -46238,8 +47305,8 @@ function requireKatex() {
46238
47305
  numArgs: 1,
46239
47306
  numOptionalArgs: 1
46240
47307
  },
46241
- handler: function handler(_ref, args, optArgs) {
46242
- var parser = _ref.parser;
47308
+ handler: function handler(_ref2, args, optArgs) {
47309
+ var parser = _ref2.parser;
46243
47310
  var index2 = optArgs[0];
46244
47311
  var body = args[0];
46245
47312
  return {
@@ -46323,8 +47390,8 @@ function requireKatex() {
46323
47390
  numArgs: 0,
46324
47391
  allowedInText: true
46325
47392
  },
46326
- handler: function handler(_ref, args) {
46327
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47393
+ handler: function handler(_ref2, args) {
47394
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46328
47395
  var body = parser.parseExpression(true, breakOnTokenText);
46329
47396
  var style = funcName.slice(1, funcName.length - 5);
46330
47397
  return {
@@ -46709,8 +47776,8 @@ function requireKatex() {
46709
47776
  greediness: 2,
46710
47777
  allowedInText: true
46711
47778
  },
46712
- handler: function handler(_ref, args) {
46713
- var parser = _ref.parser, funcName = _ref.funcName;
47779
+ handler: function handler(_ref2, args) {
47780
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46714
47781
  var body = args[0];
46715
47782
  return {
46716
47783
  type: "text",
@@ -46736,8 +47803,8 @@ function requireKatex() {
46736
47803
  numArgs: 1,
46737
47804
  allowedInText: true
46738
47805
  },
46739
- handler: function handler(_ref, args) {
46740
- var parser = _ref.parser;
47806
+ handler: function handler(_ref2, args) {
47807
+ var parser = _ref2.parser;
46741
47808
  return {
46742
47809
  type: "underline",
46743
47810
  mode: parser.mode,
@@ -49607,7 +50674,7 @@ ABConvert.factory({
49607
50674
  process_return: ABConvert_IOEnum.el,
49608
50675
  process: (el, header, content) => {
49609
50676
  list2markmap(content, el);
49610
- markmap_event(el);
50677
+ ABCSetting.obsidian.markmap_event?.(el);
49611
50678
  return el;
49612
50679
  }
49613
50680
  });
@@ -49623,13 +50690,46 @@ function list2markmap(markdown, div) {
49623
50690
  svg_div.classList.add("ab-markmap-div");
49624
50691
  svg_div.id = "ab-markmap-div-" + id;
49625
50692
  const html_str = `<svg class="ab-markmap-svg" id="ab-markmap-${id}" data-json='${JSON.stringify(root2)}' style="height:${height_adapt}px"></svg>`;
49626
- svg_div.innerHTML = html_str;
50693
+ svg_div.innerHTML = purify.sanitize(html_str, {
50694
+ USE_PROFILES: { svg: true }
50695
+ });
49627
50696
  } else {
49628
50697
  div.classList.add("ab-raw");
49629
- div.innerHTML = `<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`;
50698
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`);
49630
50699
  }
49631
50700
  return div;
49632
50701
  }
50702
+ async function markmap_event(d) {
50703
+ if (ABCSetting.env == "obsidian-min") return;
50704
+ if (d.querySelector(".ab-markmap-svg")) {
50705
+ console.log(" - markmap_event");
50706
+ let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
50707
+ if (script_el) script_el.remove();
50708
+ const divEl = d;
50709
+ let markmapId = "";
50710
+ if (divEl.tagName === "DIV") {
50711
+ markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
50712
+ }
50713
+ script_el = document.createElement("script");
50714
+ document.head.appendChild(script_el);
50715
+ script_el.type = "module";
50716
+ script_el.setAttribute("script-id", "ab-markmap-script");
50717
+ script_el.textContent = `
50718
+ import { Markmap, } from 'https://jspm.dev/markmap-view';
50719
+ const markmapId = "${markmapId || ""}";
50720
+ let mindmaps;
50721
+ if (markmapId) {
50722
+ mindmaps = document.querySelectorAll('#' + markmapId);
50723
+ } else {
50724
+ mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
50725
+ }
50726
+ for(const mindmap of mindmaps) {
50727
+ mindmap.innerHTML = "";
50728
+ Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
50729
+ }`;
50730
+ }
50731
+ }
50732
+ ABCSetting.obsidian.markmap_event = markmap_event;
49633
50733
  const md = new MarkdownIt({
49634
50734
  html: true,
49635
50735
  // 启用 HTML 标签解析
@@ -49686,6 +50786,166 @@ const quartz_transformer_anyblock = () => {
49686
50786
  }
49687
50787
  };
49688
50788
  };
50789
+ function abConvertEvent(d, isCycle = false) {
50790
+ if (d.querySelector(".ab-super-width")) {
50791
+ const els_note = d.querySelectorAll(".ab-note");
50792
+ for (const el_note of els_note) {
50793
+ if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
50794
+ const el_replace = el_note.parentNode;
50795
+ if (el_replace && el_replace.classList.contains("ab-replace")) {
50796
+ el_replace.classList.add("ab-super-width-p");
50797
+ }
50798
+ }
50799
+ }
50800
+ const els_view = document.querySelectorAll(".app-container .workspace-leaf");
50801
+ for (const el_view of els_view) {
50802
+ el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
50803
+ }
50804
+ }
50805
+ if (d.querySelector(".ab-nodes-node")) {
50806
+ const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
50807
+ const list_children = d.querySelectorAll(".ab-nodes-node");
50808
+ for (const children2 of list_children) {
50809
+ const el_content = children2.querySelector(".ab-nodes-content");
50810
+ if (!el_content) continue;
50811
+ const el_child = children2.querySelector(".ab-nodes-children");
50812
+ if (!el_child) continue;
50813
+ const el_bracket = el_child.querySelector(".ab-nodes-bracket");
50814
+ if (!el_bracket) continue;
50815
+ const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
50816
+ if (!el_bracket2) continue;
50817
+ const els_child = el_child.childNodes;
50818
+ if (els_child.length < 3) {
50819
+ el_bracket.style.setProperty("display", "none");
50820
+ el_bracket2.style.setProperty("display", "none");
50821
+ continue;
50822
+ }
50823
+ const el_child_first = els_child[2];
50824
+ const el_child_last = els_child[els_child.length - 1];
50825
+ const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
50826
+ const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
50827
+ let height = 0;
50828
+ let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
50829
+ if (els_child.length == 3) {
50830
+ height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
50831
+ el_bracket2.style.cssText = `
50832
+ height: ${height}px;
50833
+ top: calc(50% - ${height / 2}px);
50834
+ `;
50835
+ } else {
50836
+ el_bracket2.style.cssText = `
50837
+ height: calc(100% - ${heightToReduce}px);
50838
+ top: ${el_child_first.offsetHeight / 2}px;
50839
+ `;
50840
+ }
50841
+ if (Array.prototype.includes.call(els_min, children2)) {
50842
+ if (els_child.length == 3) {
50843
+ el_bracket.style.cssText = `
50844
+ display: block;
50845
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
50846
+ clip-path: circle(40% at 50% 40%);
50847
+ `;
50848
+ } else {
50849
+ el_bracket.setAttribute("display", "none");
50850
+ }
50851
+ if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
50852
+ el_bracket2.style.cssText = `
50853
+ height: 1px;
50854
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
50855
+ width: 18px; /* 可以溢出点 */
50856
+ border-radius: 0;
50857
+ border: none;
50858
+ border-bottom: 1px solid var(--node-color);
50859
+ `;
50860
+ } else {
50861
+ if (els_child.length == 3) {
50862
+ height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
50863
+ el_bracket2.style.setProperty("height", `${height}px`);
50864
+ el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
50865
+ el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
50866
+ el_bracket2.style.setProperty("border-top", `0`);
50867
+ } else {
50868
+ heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
50869
+ el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
50870
+ el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
50871
+ }
50872
+ el_bracket2.style.setProperty("width", "20px");
50873
+ }
50874
+ }
50875
+ }
50876
+ }
50877
+ if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
50878
+ const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
50879
+ for (const root_el of root_el_list) {
50880
+ root_el.classList.add("js-waterfall");
50881
+ const list_children = root_el.querySelectorAll(".ab-items-item");
50882
+ const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
50883
+ let columnCount;
50884
+ if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
50885
+ columnCount = columnCountTmp;
50886
+ } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
50887
+ columnCount = list_children.length;
50888
+ root_el.classList.add("ab-col" + columnCount);
50889
+ } else {
50890
+ columnCount = 4;
50891
+ root_el.classList.add("ab-col" + columnCount);
50892
+ }
50893
+ const height_cache = [];
50894
+ const el_cache = [];
50895
+ for (let i = 0; i < columnCount; i++) {
50896
+ height_cache.push(0);
50897
+ el_cache.push([]);
50898
+ }
50899
+ for (const children2 of list_children) {
50900
+ const minValue = Math.min.apply(null, height_cache);
50901
+ const minIndex = height_cache.indexOf(minValue);
50902
+ const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
50903
+ height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
50904
+ el_cache[minIndex].push(children2);
50905
+ }
50906
+ const fillNumber = columnCount - list_children.length % columnCount;
50907
+ if (fillNumber != 4) {
50908
+ for (let i = 0; i < fillNumber; i++) {
50909
+ const children2 = document.createElement("div");
50910
+ children2.classList.add(".ab-items-item.placeholder");
50911
+ children2.setAttribute("style", "height: 20px");
50912
+ const minValue = Math.min.apply(null, height_cache);
50913
+ const minIndex = height_cache.indexOf(minValue);
50914
+ height_cache[minIndex] += 20;
50915
+ el_cache[minIndex].push(children2);
50916
+ }
50917
+ }
50918
+ root_el.innerHTML = "";
50919
+ for (let i = 0; i < columnCount; i++) {
50920
+ for (const j of el_cache[i]) {
50921
+ root_el.appendChild(j);
50922
+ }
50923
+ }
50924
+ }
50925
+ }
50926
+ if (!isCycle && d.querySelector(".ab-markmap-div")) {
50927
+ const divEl = d;
50928
+ let markmapId = "";
50929
+ if (divEl.tagName === "DIV") {
50930
+ markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
50931
+ }
50932
+ let mindmaps;
50933
+ if (markmapId) {
50934
+ mindmaps = document.querySelectorAll("#" + markmapId);
50935
+ } else {
50936
+ mindmaps = document.querySelectorAll(".ab-markmap-div");
50937
+ }
50938
+ for (const el_div of mindmaps) {
50939
+ const el_svg = el_div.querySelector("svg");
50940
+ const el_g = el_svg?.querySelector("g");
50941
+ if (el_svg && el_g) {
50942
+ const scale_new = el_g.getBBox().height / el_div.offsetWidth;
50943
+ el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
50944
+ ABCSetting.obsidian.markmap_event?.(d);
50945
+ }
50946
+ }
50947
+ }
50948
+ }
49689
50949
  export {
49690
50950
  ABConvertManager,
49691
50951
  ABReg,