@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.
@@ -24,7 +24,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
25
25
  const MarkdownIt = require("markdown-it");
26
26
  let dom = null;
27
- async function jsdom_init(enable = true) {
27
+ let disable_disable_flag = false;
28
+ async function jsdom_init(enable = true, disable_disable = false) {
29
+ disable_disable_flag = disable_disable;
30
+ if (typeof document !== "undefined") return;
28
31
  const { default: jsdom } = await import("jsdom");
29
32
  const { JSDOM } = jsdom;
30
33
  dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
@@ -34,6 +37,7 @@ async function jsdom_init(enable = true) {
34
37
  if (enable) jsdom_enable();
35
38
  }
36
39
  function jsdom_enable() {
40
+ if (!dom) return;
37
41
  global.Storage = dom.window.Storage;
38
42
  global.window = dom.window;
39
43
  global.history = dom.window.history;
@@ -52,10 +56,22 @@ function jsdom_enable() {
52
56
  global.MutationObserver = dom.window.MutationObserver;
53
57
  }
54
58
  function jsdom_disable() {
59
+ if (disable_disable_flag) return;
60
+ if (!dom) return;
55
61
  global.window = void 0;
56
62
  global.history = void 0;
57
63
  global.document = void 0;
58
64
  }
65
+ const ABCSetting = {
66
+ env: "obsidian",
67
+ // 某些环境的独占 api,其他环境用不上
68
+ obsidian: {
69
+ global_app: null,
70
+ global_ctx: null,
71
+ mermaid: void 0,
72
+ markmap_event: void 0
73
+ }
74
+ };
59
75
  const ABReg = {
60
76
  /**
61
77
  * AB块头部
@@ -77,9 +93,9 @@ const ABReg = {
77
93
  * - 不允许 `::` 是避免与 dataview 的 inline property 冲突
78
94
  */
79
95
  // 有前缀版本(给选择器用)
80
- reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
96
+ reg_header: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
81
97
  // 可以用空`|`来解除首字符限制。(`|`注意:可以用来弄严格模式,`#`注意:建议后面空一格避免变成“标签”,`!`注意:别易误触发 `> [!note]`
82
- reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
98
+ reg_header_up: /^((\s|>\s|-\s|\*\s|\+\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
83
99
  // 向上检查标志的 头部选择器
84
100
  reg_mdit_head: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)\s?(.*)/,
85
101
  reg_mdit_tail: /^((\s|>\s|-\s|\*\s|\+\s)*)(::::*)/,
@@ -92,8 +108,8 @@ const ABReg = {
92
108
  reg_heading: /^((\s|>\s|-\s|\*\s|\+\s)*)(\#+\s)(.*)/,
93
109
  reg_table: /^((\s|>\s|-\s|\*\s|\+\s)*)(\|(.*)\|)/,
94
110
  // 无前缀版本(给处理器用,处理器不需要处理前缀,前缀在选择器阶段已经被去除了)
95
- reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
96
- reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?(%%)?\s*$/,
111
+ reg_header_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!|< )[\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
112
+ reg_header_up_noprefix: /^((\s)*)(%%)?(\[((?!toc|TOC|\!)< [\|\!#:;\(\)\s0-9a-zA-Z\u4e00-\u9fa5](?!.*::).*)\]):?\3\s*$/,
97
113
  reg_mdit_head_noprefix: /^((\s)*)(::::*)\s?(.*)/,
98
114
  reg_mdit_tail_noprefix: /^((\s)*)(::::*)/,
99
115
  reg_list_noprefix: /^((\s)*)(-\s|\*\s|\+\s)(.*)/,
@@ -106,12 +122,6 @@ const ABReg = {
106
122
  inline_split: /\| |, |, |\. |。 |: |: /
107
123
  // 内联切分。`|`或全角符号+一空格,半角符号+两空格 (后者由于空格压缩,若经历了重渲染可能有问题)
108
124
  };
109
- const ABCSetting = {
110
- env: "obsidian",
111
- // MarkdownPostProcessorContext类型, obsidian专用
112
- mermaid: void 0
113
- // obsidian专用,表示使用哪种方式渲染mermaid
114
- };
115
125
  const convert = (
116
126
  // Note: overloads in JSDoc can’t yet use different `@template`s.
117
127
  /**
@@ -386,11 +396,11 @@ function autoABAlias(header, selectorName, content) {
386
396
  } else if (selectorName == "table" || ABReg.reg_table_noprefix.test(content.trimStart())) {
387
397
  header = "|table_140lne" + header;
388
398
  }
389
- for (const item of ABAlias_json) {
399
+ for (const item of get_ABAlias_iter()) {
390
400
  header = header.replace(item.regex, item.replacement);
391
401
  }
392
402
  for (const item of ABAlias_json_withSub) {
393
- header = header.replace(item.regex, (match2, ...groups) => {
403
+ header = header.replace(item.regex, (_match, ...groups) => {
394
404
  return item.replacement.replace(/\$(\d+)/g, (_, number) => groups[number - 1] ?? "");
395
405
  });
396
406
  }
@@ -423,15 +433,35 @@ const ABAlias_json_withSub = [
423
433
  // 注意避免和原上/上面的callout语法冲突,以及自身递归
424
434
  ];
425
435
  const ABAlias_json_mdit = [
426
- { regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
436
+ { regex: /\|:::_140lne\|((?:mdit2|2)?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
427
437
  { regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
428
438
  { regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
429
- { regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
430
- { regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
431
- { regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
439
+ { regex: /\|:::_140lne\|((?:mdit2|2)?col|分栏)\|/, replacement: "|mditCol|" },
440
+ { regex: /\|:::_140lne\|((?:mdit2|2)?card|卡片)\|/, replacement: "|mditCard|" },
441
+ { regex: /\|:::_140lne\|((?:mdit2|2)?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" },
442
+ //
443
+ // {regex: /\|:::_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
444
+ // {regex: /\|:::_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
445
+ // {regex: /\|:::_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|"},
446
+ // {regex: /\|:::_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|"},
447
+ // {regex: /\|:::_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|"},
448
+ // list - 多叉多层树
449
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mermaid|flow|流程图)\|/, replacement: "|mdit2list|list2mermaid|" },
450
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mehrmaid|mdmermaid)\|/, replacement: "|mdit2list|list2mehrmaidText|code(mehrmaid)|" },
451
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|mdit2list|list2pumlMindmap|" },
452
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|mdit2list|list2markmap|" },
453
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(wbs|(工作)?分解(图|结构))\|/, replacement: "|mdit2list|list2pumlWBS|" },
454
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|mdit2list|list2table|" },
455
+ // list - lt树 (属于多层一叉树)
456
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|mdit2list|list2lt|" },
457
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(list|列表)\|/, replacement: "|mdit2list|list2lt|addClass(ab-listtable-likelist)|" },
458
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|mdit2list|list2dt|" },
459
+ // list - 二层树
460
+ { regex: /\|:::_140lne\|(fakeList|仿列表)\|/, replacement: "|mdit2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
461
+ // 至后
462
+ { regex: "|mdit2list|", replacement: "|mdit2listdata|listdata2strict|listdata2list|" }
432
463
  ];
433
464
  const ABAlias_json_title = [
434
- { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
435
465
  // title - list&title
436
466
  { regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
437
467
  { regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
@@ -450,7 +480,9 @@ const ABAlias_json_title = [
450
480
  { regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
451
481
  { regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
452
482
  // list - 二层树
453
- { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
483
+ { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
484
+ // 至后
485
+ { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" }
454
486
  ];
455
487
  const ABAlias_json_list = [
456
488
  // 特殊
@@ -534,7 +566,9 @@ const ABAlias_json_general = [
534
566
  { regex: "|超超小字|", replacement: "|addClass(ab-custom-font-smallxx)|" },
535
567
  { regex: "|加粗|", replacement: "|addClass(ab-custom-font-bold)|" }
536
568
  ];
537
- const ABAlias_json_default = [
569
+ const ABAlias_user = [];
570
+ const ABAlias_pro = [];
571
+ const ABAlias_default = [
538
572
  ...ABAlias_json_mdit,
539
573
  ...ABAlias_json_title,
540
574
  ...ABAlias_json_list,
@@ -544,10 +578,11 @@ const ABAlias_json_default = [
544
578
  ...ABAlias_json_general
545
579
  // 这个放最后
546
580
  ];
547
- let ABAlias_json = [
548
- ...ABAlias_json_default
549
- // 设置决定是否停用
550
- ];
581
+ function* get_ABAlias_iter() {
582
+ yield* ABAlias_user;
583
+ yield* ABAlias_pro;
584
+ yield* ABAlias_default;
585
+ }
551
586
  const ABAlias_json_end = [
552
587
  { regex: "|:::_140lne", replacement: "" },
553
588
  { regex: "|heading_140lne", replacement: "" },
@@ -604,24 +639,18 @@ class ABConvertManager {
604
639
  * @param header 转换方式
605
640
  * @param content 要转换的初始文本 (无前缀版本,前缀在选择器环节已经删除了)
606
641
  * @param selectorName 选择器名,空表示未知
607
- * @return 等于el,无用,后面可以删了
608
642
  */
609
643
  static autoABConvert(el, header, content, selectorName = "", ctx) {
610
- let prev_result = content;
611
- let prev_type = "string";
612
- let prev_type2 = ABConvert_IOEnum.text;
613
- let prev_processor;
614
644
  let prev2 = {
615
- // 组合在一起是为了引用传参
616
- prev_result,
617
- prev_type,
618
- prev_type2,
619
- prev_processor
645
+ prev_result: content,
646
+ prev_type: "string",
647
+ prev_type2: ABConvert_IOEnum.text,
648
+ prev_processor: void 0
620
649
  };
621
650
  {
622
- header = autoABAlias(header, selectorName, prev_result);
651
+ header = autoABAlias(header, selectorName, prev2.prev_result);
623
652
  let list_header = header.split("|");
624
- prev_result = this.autoABConvert_runConvert(el, list_header, prev2, ctx);
653
+ this.autoABConvert_runConvert(el, list_header, prev2, ctx);
625
654
  this.autoABConvert_last(el, header, selectorName, prev2, ctx);
626
655
  }
627
656
  }
@@ -680,7 +709,12 @@ class ABConvertManager {
680
709
  break;
681
710
  }
682
711
  }
683
- prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
712
+ try {
713
+ prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
714
+ } catch (e) {
715
+ console.error(`处理器执行错误, id:${abReplaceProcessor.id}, header:${item_header}, error:`, e);
716
+ break;
717
+ }
684
718
  prev2.prev_type = typeof prev2.prev_result;
685
719
  prev2.prev_type2 = abReplaceProcessor.process_return;
686
720
  prev2.prev_processor = abReplaceProcessor.process;
@@ -694,7 +728,7 @@ class ABConvertManager {
694
728
  /**
695
729
  * 子函数,后处理/尾处理,主要进行末尾追加指令
696
730
  */
697
- static autoABConvert_last(el, header, selectorName, prev2, ctx) {
731
+ static autoABConvert_last(el, _header, _selectorName, prev2, _ctx) {
698
732
  if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.text) {
699
733
  const subEl = document.createElement("div");
700
734
  el.appendChild(subEl);
@@ -702,7 +736,7 @@ class ABConvertManager {
702
736
  prev2.prev_result = el;
703
737
  prev2.prev_type = "object";
704
738
  prev2.prev_type2 = ABConvert_IOEnum.el;
705
- prev2.process = "md";
739
+ prev2.prev_processor = "md";
706
740
  } else if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.json) {
707
741
  const code_str = "```json\n" + prev2.prev_result + "\n```\n";
708
742
  const subEl = document.createElement("div");
@@ -711,7 +745,7 @@ class ABConvertManager {
711
745
  prev2.prev_result = el;
712
746
  prev2.prev_type = "object";
713
747
  prev2.prev_type2 = ABConvert_IOEnum.el;
714
- prev2.process = "show_json";
748
+ prev2.prev_processor = "show_json";
715
749
  } 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)) {
716
750
  const code_str = "```json\n" + JSON.stringify(prev2.prev_result, null, 2) + "\n```\n";
717
751
  const subEl = document.createElement("div");
@@ -720,7 +754,7 @@ class ABConvertManager {
720
754
  prev2.prev_result = el;
721
755
  prev2.prev_type = "object";
722
756
  prev2.prev_type2 = ABConvert_IOEnum.el;
723
- prev2.process = "show_listStream";
757
+ prev2.prev_processor = "show_listStream";
724
758
  } else if (prev2.prev_type == "object" && prev2.prev_type2 == ABConvert_IOEnum.el) {
725
759
  return prev2;
726
760
  } else {
@@ -1164,7 +1198,7 @@ class ListProcess {
1164
1198
  }
1165
1199
  }
1166
1200
  /**
1167
- * 标题大纲转列表数据(@todo 正文的level+10,要减掉)
1201
+ * 标题大纲转列表数据
1168
1202
  *
1169
1203
  * @detail
1170
1204
  * 这里要将标题、正文、列表 的等级合为一块,所以存在偏移值:
@@ -1173,6 +1207,7 @@ class ListProcess {
1173
1207
  * 2. 正文等级, = 0, 取值[+1,+Infi]
1174
1208
  * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
1175
1209
  *
1210
+ * (比较旧版是正文+10,列表+11,后来允许标题等级为负数。这样方便很多)
1176
1211
  */
1177
1212
  static title2data(text2) {
1178
1213
  let list_itemInfo = [];
@@ -1183,13 +1218,21 @@ class ListProcess {
1183
1218
  if (codeBlockFlag == "") {
1184
1219
  const match2 = line.match(ABReg.reg_code);
1185
1220
  if (match2 && match2[3]) {
1186
- codeBlockFlag = match2[1] + match2[3];
1187
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1221
+ if (mul_mode === "heading" || mul_mode === "") {
1222
+ list_itemInfo.push({
1223
+ content: line,
1224
+ level: 0
1225
+ });
1226
+ mul_mode = "para";
1227
+ } else {
1228
+ codeBlockFlag = match2[1] + match2[3];
1229
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1230
+ }
1188
1231
  continue;
1189
1232
  }
1190
1233
  } else {
1191
1234
  if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1192
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1235
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1193
1236
  continue;
1194
1237
  }
1195
1238
  const match_heading = line.match(ABReg.reg_heading_noprefix);
@@ -1206,21 +1249,125 @@ class ListProcess {
1206
1249
  list_itemInfo.push({
1207
1250
  content: match_list[4],
1208
1251
  level: match_list[1].length + 1
1209
- //+10
1210
1252
  });
1211
1253
  mul_mode = "list";
1212
1254
  } else if (/^\S/.test(line) && mul_mode == "list") {
1213
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1255
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1214
1256
  } else {
1215
1257
  if (mul_mode == "para") {
1216
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1258
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1259
+ } else if (/^\s*$/.test(line)) {
1260
+ continue;
1261
+ } else {
1262
+ list_itemInfo.push({
1263
+ content: line,
1264
+ level: 0
1265
+ });
1266
+ mul_mode = "para";
1267
+ }
1268
+ }
1269
+ }
1270
+ removeTailBlank();
1271
+ return list_itemInfo;
1272
+ function removeTailBlank() {
1273
+ if (mul_mode == "para" || mul_mode == "list") {
1274
+ list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content.replace(/\s*$/, "");
1275
+ }
1276
+ }
1277
+ }
1278
+ /**
1279
+ * MarkdownIt 转列表数据
1280
+ *
1281
+ * @detail
1282
+ * 与 title2data 的逻辑基本相同
1283
+ *
1284
+ * 这里要将Mdit标识 (@xxx)、正文、列表 的等级合为一块,所以存在偏移值:
1285
+ *
1286
+ * 1. Mdit等级, = `@<数字>`-100,
1287
+ * 2. 正文等级, = 0, 取值[+1,+Infi]
1288
+ * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
1289
+ *
1290
+ * 例如:
1291
+ *
1292
+ * :::
1293
+ *
1294
+ * @1 AAA
1295
+ *
1296
+ * aaa
1297
+ *
1298
+ * @2 BBB
1299
+ *
1300
+ * @2 B22
1301
+ *
1302
+ * ccc
1303
+ * ddd
1304
+ *
1305
+ * @1 A22
1306
+ *
1307
+ * :::
1308
+ *
1309
+ * 会被转化为
1310
+ *
1311
+ * - AAA
1312
+ * - BBB
1313
+ * - B22
1314
+ * - ccc
1315
+ * ddd
1316
+ * - A22
1317
+ */
1318
+ static mdit2data(text2) {
1319
+ let list_itemInfo = [];
1320
+ const list_text = text2.split("\n");
1321
+ let mul_mode = "";
1322
+ let codeBlockFlag = "";
1323
+ for (let line of list_text) {
1324
+ if (codeBlockFlag == "") {
1325
+ const match2 = line.match(ABReg.reg_code);
1326
+ if (match2 && match2[3]) {
1327
+ if (mul_mode === "mdit" || mul_mode === "") {
1328
+ list_itemInfo.push({
1329
+ content: line,
1330
+ level: 0
1331
+ });
1332
+ mul_mode = "para";
1333
+ } else {
1334
+ codeBlockFlag = match2[1] + match2[3];
1335
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1336
+ }
1337
+ continue;
1338
+ }
1339
+ } else {
1340
+ if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1341
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1342
+ continue;
1343
+ }
1344
+ const match_mdit = line.match(/^(\s*)@(\d+)\s+(.*)$/);
1345
+ const match_list = line.match(ABReg.reg_list_noprefix);
1346
+ if (match_mdit && !match_mdit[1]) {
1347
+ removeTailBlank();
1348
+ list_itemInfo.push({
1349
+ content: match_mdit[3],
1350
+ level: Number(match_mdit[2]) - 100
1351
+ });
1352
+ mul_mode = "mdit";
1353
+ } else if (match_list) {
1354
+ removeTailBlank();
1355
+ list_itemInfo.push({
1356
+ content: match_list[4],
1357
+ level: match_list[1].length + 1
1358
+ });
1359
+ mul_mode = "list";
1360
+ } else if (/^\S/.test(line) && mul_mode == "list") {
1361
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1362
+ } else {
1363
+ if (mul_mode == "para") {
1364
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1217
1365
  } else if (/^\s*$/.test(line)) {
1218
1366
  continue;
1219
1367
  } else {
1220
1368
  list_itemInfo.push({
1221
1369
  content: line,
1222
1370
  level: 0
1223
- //+10
1224
1371
  });
1225
1372
  mul_mode = "para";
1226
1373
  }
@@ -1455,6 +1602,16 @@ const abc_title2listdata = ABConvert.factory({
1455
1602
  return ListProcess.title2data(content);
1456
1603
  }
1457
1604
  });
1605
+ ABConvert.factory({
1606
+ id: "mdit2listdata",
1607
+ name: "mdit到listdata",
1608
+ process_param: ABConvert_IOEnum.text,
1609
+ process_return: ABConvert_IOEnum.list_stream,
1610
+ detail: "mdit到listdata",
1611
+ process: (el, header, content) => {
1612
+ return ListProcess.mdit2data(content);
1613
+ }
1614
+ });
1458
1615
  ABConvert.factory({
1459
1616
  id: "listdata2list",
1460
1617
  name: "listdata到列表",
@@ -2450,6 +2607,1085 @@ ABConvert.factory({
2450
2607
  return newContent;
2451
2608
  }
2452
2609
  });
2610
+ function _arrayLikeToArray(r, a) {
2611
+ (null == a || a > r.length) && (a = r.length);
2612
+ for (var e = 0, n2 = Array(a); e < a; e++) n2[e] = r[e];
2613
+ return n2;
2614
+ }
2615
+ function _arrayWithHoles(r) {
2616
+ if (Array.isArray(r)) return r;
2617
+ }
2618
+ function _iterableToArrayLimit(r, l2) {
2619
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2620
+ if (null != t) {
2621
+ var e, n2, i, u, a = [], f = true, o = false;
2622
+ try {
2623
+ if (i = (t = t.call(r)).next, 0 === l2) ;
2624
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
2625
+ } catch (r2) {
2626
+ o = true, n2 = r2;
2627
+ } finally {
2628
+ try {
2629
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
2630
+ } finally {
2631
+ if (o) throw n2;
2632
+ }
2633
+ }
2634
+ return a;
2635
+ }
2636
+ }
2637
+ function _nonIterableRest() {
2638
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2639
+ }
2640
+ function _slicedToArray(r, e) {
2641
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
2642
+ }
2643
+ function _unsupportedIterableToArray(r, a) {
2644
+ if (r) {
2645
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2646
+ var t = {}.toString.call(r).slice(8, -1);
2647
+ 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;
2648
+ }
2649
+ }
2650
+ const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2651
+ let freeze = Object.freeze, seal = Object.seal, create = Object.create;
2652
+ let _ref = typeof Reflect !== "undefined" && Reflect, apply = _ref.apply, construct = _ref.construct;
2653
+ if (!freeze) {
2654
+ freeze = function freeze2(x) {
2655
+ return x;
2656
+ };
2657
+ }
2658
+ if (!seal) {
2659
+ seal = function seal2(x) {
2660
+ return x;
2661
+ };
2662
+ }
2663
+ if (!apply) {
2664
+ apply = function apply2(func, thisArg) {
2665
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2666
+ args[_key - 2] = arguments[_key];
2667
+ }
2668
+ return func.apply(thisArg, args);
2669
+ };
2670
+ }
2671
+ if (!construct) {
2672
+ construct = function construct2(Func) {
2673
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2674
+ args[_key2 - 1] = arguments[_key2];
2675
+ }
2676
+ return new Func(...args);
2677
+ };
2678
+ }
2679
+ const arrayForEach = unapply(Array.prototype.forEach);
2680
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
2681
+ const arrayPop = unapply(Array.prototype.pop);
2682
+ const arrayPush = unapply(Array.prototype.push);
2683
+ const arraySplice = unapply(Array.prototype.splice);
2684
+ const arrayIsArray = Array.isArray;
2685
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
2686
+ const stringToString = unapply(String.prototype.toString);
2687
+ const stringMatch = unapply(String.prototype.match);
2688
+ const stringReplace = unapply(String.prototype.replace);
2689
+ const stringIndexOf = unapply(String.prototype.indexOf);
2690
+ const stringTrim = unapply(String.prototype.trim);
2691
+ const numberToString = unapply(Number.prototype.toString);
2692
+ const booleanToString = unapply(Boolean.prototype.toString);
2693
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
2694
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
2695
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
2696
+ const objectToString = unapply(Object.prototype.toString);
2697
+ const regExpTest = unapply(RegExp.prototype.test);
2698
+ const typeErrorCreate = unconstruct(TypeError);
2699
+ function unapply(func) {
2700
+ return function(thisArg) {
2701
+ if (thisArg instanceof RegExp) {
2702
+ thisArg.lastIndex = 0;
2703
+ }
2704
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2705
+ args[_key3 - 1] = arguments[_key3];
2706
+ }
2707
+ return apply(func, thisArg, args);
2708
+ };
2709
+ }
2710
+ function unconstruct(Func) {
2711
+ return function() {
2712
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2713
+ args[_key4] = arguments[_key4];
2714
+ }
2715
+ return construct(Func, args);
2716
+ };
2717
+ }
2718
+ function addToSet(set2, array) {
2719
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
2720
+ if (setPrototypeOf) {
2721
+ setPrototypeOf(set2, null);
2722
+ }
2723
+ if (!arrayIsArray(array)) {
2724
+ return set2;
2725
+ }
2726
+ let l2 = array.length;
2727
+ while (l2--) {
2728
+ let element = array[l2];
2729
+ if (typeof element === "string") {
2730
+ const lcElement = transformCaseFunc(element);
2731
+ if (lcElement !== element) {
2732
+ if (!isFrozen(array)) {
2733
+ array[l2] = lcElement;
2734
+ }
2735
+ element = lcElement;
2736
+ }
2737
+ }
2738
+ set2[element] = true;
2739
+ }
2740
+ return set2;
2741
+ }
2742
+ function cleanArray(array) {
2743
+ for (let index2 = 0; index2 < array.length; index2++) {
2744
+ const isPropertyExist = objectHasOwnProperty(array, index2);
2745
+ if (!isPropertyExist) {
2746
+ array[index2] = null;
2747
+ }
2748
+ }
2749
+ return array;
2750
+ }
2751
+ function clone$3(object) {
2752
+ const newObject = create(null);
2753
+ for (const _ref2 of entries(object)) {
2754
+ var _ref3 = _slicedToArray(_ref2, 2);
2755
+ const property = _ref3[0];
2756
+ const value = _ref3[1];
2757
+ const isPropertyExist = objectHasOwnProperty(object, property);
2758
+ if (isPropertyExist) {
2759
+ if (arrayIsArray(value)) {
2760
+ newObject[property] = cleanArray(value);
2761
+ } else if (value && typeof value === "object" && value.constructor === Object) {
2762
+ newObject[property] = clone$3(value);
2763
+ } else {
2764
+ newObject[property] = value;
2765
+ }
2766
+ }
2767
+ }
2768
+ return newObject;
2769
+ }
2770
+ function stringifyValue(value) {
2771
+ switch (typeof value) {
2772
+ case "string": {
2773
+ return value;
2774
+ }
2775
+ case "number": {
2776
+ return numberToString(value);
2777
+ }
2778
+ case "boolean": {
2779
+ return booleanToString(value);
2780
+ }
2781
+ case "bigint": {
2782
+ return bigintToString ? bigintToString(value) : "0";
2783
+ }
2784
+ case "symbol": {
2785
+ return symbolToString ? symbolToString(value) : "Symbol()";
2786
+ }
2787
+ case "undefined": {
2788
+ return objectToString(value);
2789
+ }
2790
+ case "function":
2791
+ case "object": {
2792
+ if (value === null) {
2793
+ return objectToString(value);
2794
+ }
2795
+ const valueAsRecord = value;
2796
+ const valueToString = lookupGetter(valueAsRecord, "toString");
2797
+ if (typeof valueToString === "function") {
2798
+ const stringified = valueToString(valueAsRecord);
2799
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
2800
+ }
2801
+ return objectToString(value);
2802
+ }
2803
+ default: {
2804
+ return objectToString(value);
2805
+ }
2806
+ }
2807
+ }
2808
+ function lookupGetter(object, prop2) {
2809
+ while (object !== null) {
2810
+ const desc = getOwnPropertyDescriptor(object, prop2);
2811
+ if (desc) {
2812
+ if (desc.get) {
2813
+ return unapply(desc.get);
2814
+ }
2815
+ if (typeof desc.value === "function") {
2816
+ return unapply(desc.value);
2817
+ }
2818
+ }
2819
+ object = getPrototypeOf(object);
2820
+ }
2821
+ function fallbackValue() {
2822
+ return null;
2823
+ }
2824
+ return fallbackValue;
2825
+ }
2826
+ function isRegex(value) {
2827
+ try {
2828
+ regExpTest(value, "");
2829
+ return true;
2830
+ } catch (_unused) {
2831
+ return false;
2832
+ }
2833
+ }
2834
+ 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"]);
2835
+ 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"]);
2836
+ 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"]);
2837
+ 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"]);
2838
+ 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"]);
2839
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
2840
+ const text$2 = freeze(["#text"]);
2841
+ 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"]);
2842
+ 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"]);
2843
+ 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"]);
2844
+ const xml$1 = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
2845
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
2846
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
2847
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
2848
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
2849
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
2850
+ const IS_ALLOWED_URI = seal(
2851
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
2852
+ // eslint-disable-line no-useless-escape
2853
+ );
2854
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
2855
+ const ATTR_WHITESPACE = seal(
2856
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
2857
+ // eslint-disable-line no-control-regex
2858
+ );
2859
+ const DOCTYPE_NAME = seal(/^html$/i);
2860
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
2861
+ const NODE_TYPE$1 = {
2862
+ element: 1,
2863
+ text: 3,
2864
+ // Deprecated
2865
+ progressingInstruction: 7,
2866
+ comment: 8,
2867
+ document: 9
2868
+ };
2869
+ const getGlobal = function getGlobal2() {
2870
+ return typeof window === "undefined" ? null : window;
2871
+ };
2872
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
2873
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
2874
+ return null;
2875
+ }
2876
+ let suffix = null;
2877
+ const ATTR_NAME = "data-tt-policy-suffix";
2878
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
2879
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
2880
+ }
2881
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
2882
+ try {
2883
+ return trustedTypes.createPolicy(policyName, {
2884
+ createHTML(html2) {
2885
+ return html2;
2886
+ },
2887
+ createScriptURL(scriptUrl) {
2888
+ return scriptUrl;
2889
+ }
2890
+ });
2891
+ } catch (_) {
2892
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
2893
+ return null;
2894
+ }
2895
+ };
2896
+ const _createHooksMap = function _createHooksMap2() {
2897
+ return {
2898
+ afterSanitizeAttributes: [],
2899
+ afterSanitizeElements: [],
2900
+ afterSanitizeShadowDOM: [],
2901
+ beforeSanitizeAttributes: [],
2902
+ beforeSanitizeElements: [],
2903
+ beforeSanitizeShadowDOM: [],
2904
+ uponSanitizeAttribute: [],
2905
+ uponSanitizeElement: [],
2906
+ uponSanitizeShadowNode: []
2907
+ };
2908
+ };
2909
+ function createDOMPurify() {
2910
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2911
+ const DOMPurify = (root2) => createDOMPurify(root2);
2912
+ DOMPurify.version = "3.4.3";
2913
+ DOMPurify.removed = [];
2914
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE$1.document || !window2.Element) {
2915
+ DOMPurify.isSupported = false;
2916
+ return DOMPurify;
2917
+ }
2918
+ let document2 = window2.document;
2919
+ const originalDocument = document2;
2920
+ const currentScript = originalDocument.currentScript;
2921
+ 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;
2922
+ const ElementPrototype = Element2.prototype;
2923
+ const cloneNode2 = lookupGetter(ElementPrototype, "cloneNode");
2924
+ const remove2 = lookupGetter(ElementPrototype, "remove");
2925
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2926
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2927
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2928
+ if (typeof HTMLTemplateElement === "function") {
2929
+ const template = document2.createElement("template");
2930
+ if (template.content && template.content.ownerDocument) {
2931
+ document2 = template.content.ownerDocument;
2932
+ }
2933
+ }
2934
+ let trustedTypesPolicy;
2935
+ let emptyHTML = "";
2936
+ const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName2 = _document.getElementsByTagName;
2937
+ const importNode = originalDocument.importNode;
2938
+ let hooks = _createHooksMap();
2939
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2940
+ 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;
2941
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
2942
+ let ALLOWED_TAGS = null;
2943
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text$2]);
2944
+ let ALLOWED_ATTR = null;
2945
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html$2, ...svg, ...mathMl, ...xml$1]);
2946
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2947
+ tagNameCheck: {
2948
+ writable: true,
2949
+ configurable: false,
2950
+ enumerable: true,
2951
+ value: null
2952
+ },
2953
+ attributeNameCheck: {
2954
+ writable: true,
2955
+ configurable: false,
2956
+ enumerable: true,
2957
+ value: null
2958
+ },
2959
+ allowCustomizedBuiltInElements: {
2960
+ writable: true,
2961
+ configurable: false,
2962
+ enumerable: true,
2963
+ value: false
2964
+ }
2965
+ }));
2966
+ let FORBID_TAGS = null;
2967
+ let FORBID_ATTR = null;
2968
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
2969
+ tagCheck: {
2970
+ writable: true,
2971
+ configurable: false,
2972
+ enumerable: true,
2973
+ value: null
2974
+ },
2975
+ attributeCheck: {
2976
+ writable: true,
2977
+ configurable: false,
2978
+ enumerable: true,
2979
+ value: null
2980
+ }
2981
+ }));
2982
+ let ALLOW_ARIA_ATTR = true;
2983
+ let ALLOW_DATA_ATTR = true;
2984
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
2985
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
2986
+ let SAFE_FOR_TEMPLATES = false;
2987
+ let SAFE_FOR_XML = true;
2988
+ let WHOLE_DOCUMENT = false;
2989
+ let SET_CONFIG = false;
2990
+ let FORCE_BODY = false;
2991
+ let RETURN_DOM = false;
2992
+ let RETURN_DOM_FRAGMENT = false;
2993
+ let RETURN_TRUSTED_TYPE = false;
2994
+ let SANITIZE_DOM = true;
2995
+ let SANITIZE_NAMED_PROPS = false;
2996
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
2997
+ let KEEP_CONTENT = true;
2998
+ let IN_PLACE = false;
2999
+ let USE_PROFILES = {};
3000
+ let FORBID_CONTENTS = null;
3001
+ 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"]);
3002
+ let DATA_URI_TAGS = null;
3003
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
3004
+ let URI_SAFE_ATTRIBUTES = null;
3005
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
3006
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
3007
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
3008
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
3009
+ let NAMESPACE = HTML_NAMESPACE;
3010
+ let IS_EMPTY_INPUT = false;
3011
+ let ALLOWED_NAMESPACES = null;
3012
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
3013
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
3014
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
3015
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
3016
+ let PARSER_MEDIA_TYPE = null;
3017
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
3018
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
3019
+ let transformCaseFunc = null;
3020
+ let CONFIG = null;
3021
+ const formElement = document2.createElement("form");
3022
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
3023
+ return testValue instanceof RegExp || testValue instanceof Function;
3024
+ };
3025
+ const _parseConfig = function _parseConfig2() {
3026
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3027
+ if (CONFIG && CONFIG === cfg) {
3028
+ return;
3029
+ }
3030
+ if (!cfg || typeof cfg !== "object") {
3031
+ cfg = {};
3032
+ }
3033
+ cfg = clone$3(cfg);
3034
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
3035
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
3036
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
3037
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
3038
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
3039
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
3040
+ 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;
3041
+ 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;
3042
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
3043
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone$3({});
3044
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone$3({});
3045
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone$3(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
3046
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
3047
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
3048
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
3049
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
3050
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
3051
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
3052
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
3053
+ RETURN_DOM = cfg.RETURN_DOM || false;
3054
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
3055
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
3056
+ FORCE_BODY = cfg.FORCE_BODY || false;
3057
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
3058
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
3059
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
3060
+ IN_PLACE = cfg.IN_PLACE || false;
3061
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
3062
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
3063
+ 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"]);
3064
+ 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"]);
3065
+ 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);
3066
+ CUSTOM_ELEMENT_HANDLING = create(null);
3067
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
3068
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
3069
+ }
3070
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
3071
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
3072
+ }
3073
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
3074
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
3075
+ }
3076
+ if (SAFE_FOR_TEMPLATES) {
3077
+ ALLOW_DATA_ATTR = false;
3078
+ }
3079
+ if (RETURN_DOM_FRAGMENT) {
3080
+ RETURN_DOM = true;
3081
+ }
3082
+ if (USE_PROFILES) {
3083
+ ALLOWED_TAGS = addToSet({}, text$2);
3084
+ ALLOWED_ATTR = create(null);
3085
+ if (USE_PROFILES.html === true) {
3086
+ addToSet(ALLOWED_TAGS, html$1$1);
3087
+ addToSet(ALLOWED_ATTR, html$2);
3088
+ }
3089
+ if (USE_PROFILES.svg === true) {
3090
+ addToSet(ALLOWED_TAGS, svg$1);
3091
+ addToSet(ALLOWED_ATTR, svg);
3092
+ addToSet(ALLOWED_ATTR, xml$1);
3093
+ }
3094
+ if (USE_PROFILES.svgFilters === true) {
3095
+ addToSet(ALLOWED_TAGS, svgFilters);
3096
+ addToSet(ALLOWED_ATTR, svg);
3097
+ addToSet(ALLOWED_ATTR, xml$1);
3098
+ }
3099
+ if (USE_PROFILES.mathMl === true) {
3100
+ addToSet(ALLOWED_TAGS, mathMl$1);
3101
+ addToSet(ALLOWED_ATTR, mathMl);
3102
+ addToSet(ALLOWED_ATTR, xml$1);
3103
+ }
3104
+ }
3105
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
3106
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
3107
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
3108
+ if (typeof cfg.ADD_TAGS === "function") {
3109
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
3110
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
3111
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
3112
+ ALLOWED_TAGS = clone$3(ALLOWED_TAGS);
3113
+ }
3114
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
3115
+ }
3116
+ }
3117
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
3118
+ if (typeof cfg.ADD_ATTR === "function") {
3119
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
3120
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
3121
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
3122
+ ALLOWED_ATTR = clone$3(ALLOWED_ATTR);
3123
+ }
3124
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
3125
+ }
3126
+ }
3127
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
3128
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
3129
+ }
3130
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
3131
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3132
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3133
+ }
3134
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
3135
+ }
3136
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
3137
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
3138
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
3139
+ }
3140
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
3141
+ }
3142
+ if (KEEP_CONTENT) {
3143
+ ALLOWED_TAGS["#text"] = true;
3144
+ }
3145
+ if (WHOLE_DOCUMENT) {
3146
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
3147
+ }
3148
+ if (ALLOWED_TAGS.table) {
3149
+ addToSet(ALLOWED_TAGS, ["tbody"]);
3150
+ delete FORBID_TAGS.tbody;
3151
+ }
3152
+ if (cfg.TRUSTED_TYPES_POLICY) {
3153
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
3154
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
3155
+ }
3156
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
3157
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
3158
+ }
3159
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
3160
+ emptyHTML = trustedTypesPolicy.createHTML("");
3161
+ } else {
3162
+ if (trustedTypesPolicy === void 0) {
3163
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
3164
+ }
3165
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
3166
+ emptyHTML = trustedTypesPolicy.createHTML("");
3167
+ }
3168
+ }
3169
+ if (freeze) {
3170
+ freeze(cfg);
3171
+ }
3172
+ CONFIG = cfg;
3173
+ };
3174
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
3175
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
3176
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
3177
+ let parent2 = getParentNode(element);
3178
+ if (!parent2 || !parent2.tagName) {
3179
+ parent2 = {
3180
+ namespaceURI: NAMESPACE,
3181
+ tagName: "template"
3182
+ };
3183
+ }
3184
+ const tagName = stringToLowerCase(element.tagName);
3185
+ const parentTagName = stringToLowerCase(parent2.tagName);
3186
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
3187
+ return false;
3188
+ }
3189
+ if (element.namespaceURI === SVG_NAMESPACE) {
3190
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3191
+ return tagName === "svg";
3192
+ }
3193
+ if (parent2.namespaceURI === MATHML_NAMESPACE) {
3194
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
3195
+ }
3196
+ return Boolean(ALL_SVG_TAGS[tagName]);
3197
+ }
3198
+ if (element.namespaceURI === MATHML_NAMESPACE) {
3199
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
3200
+ return tagName === "math";
3201
+ }
3202
+ if (parent2.namespaceURI === SVG_NAMESPACE) {
3203
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
3204
+ }
3205
+ return Boolean(ALL_MATHML_TAGS[tagName]);
3206
+ }
3207
+ if (element.namespaceURI === HTML_NAMESPACE) {
3208
+ if (parent2.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
3209
+ return false;
3210
+ }
3211
+ if (parent2.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
3212
+ return false;
3213
+ }
3214
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
3215
+ }
3216
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
3217
+ return true;
3218
+ }
3219
+ return false;
3220
+ };
3221
+ const _forceRemove = function _forceRemove2(node) {
3222
+ arrayPush(DOMPurify.removed, {
3223
+ element: node
3224
+ });
3225
+ try {
3226
+ getParentNode(node).removeChild(node);
3227
+ } catch (_) {
3228
+ remove2(node);
3229
+ }
3230
+ };
3231
+ const _removeAttribute = function _removeAttribute2(name2, element) {
3232
+ try {
3233
+ arrayPush(DOMPurify.removed, {
3234
+ attribute: element.getAttributeNode(name2),
3235
+ from: element
3236
+ });
3237
+ } catch (_) {
3238
+ arrayPush(DOMPurify.removed, {
3239
+ attribute: null,
3240
+ from: element
3241
+ });
3242
+ }
3243
+ element.removeAttribute(name2);
3244
+ if (name2 === "is") {
3245
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
3246
+ try {
3247
+ _forceRemove(element);
3248
+ } catch (_) {
3249
+ }
3250
+ } else {
3251
+ try {
3252
+ element.setAttribute(name2, "");
3253
+ } catch (_) {
3254
+ }
3255
+ }
3256
+ }
3257
+ };
3258
+ const _initDocument = function _initDocument2(dirty) {
3259
+ let doc = null;
3260
+ let leadingWhitespace = null;
3261
+ if (FORCE_BODY) {
3262
+ dirty = "<remove></remove>" + dirty;
3263
+ } else {
3264
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
3265
+ leadingWhitespace = matches && matches[0];
3266
+ }
3267
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
3268
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
3269
+ }
3270
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
3271
+ if (NAMESPACE === HTML_NAMESPACE) {
3272
+ try {
3273
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
3274
+ } catch (_) {
3275
+ }
3276
+ }
3277
+ if (!doc || !doc.documentElement) {
3278
+ doc = implementation.createDocument(NAMESPACE, "template", null);
3279
+ try {
3280
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
3281
+ } catch (_) {
3282
+ }
3283
+ }
3284
+ const body = doc.body || doc.documentElement;
3285
+ if (dirty && leadingWhitespace) {
3286
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
3287
+ }
3288
+ if (NAMESPACE === HTML_NAMESPACE) {
3289
+ return getElementsByTagName2.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
3290
+ }
3291
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
3292
+ };
3293
+ const _createNodeIterator = function _createNodeIterator2(root2) {
3294
+ return createNodeIterator.call(
3295
+ root2.ownerDocument || root2,
3296
+ root2,
3297
+ // eslint-disable-next-line no-bitwise
3298
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
3299
+ null
3300
+ );
3301
+ };
3302
+ const _isClobbered = function _isClobbered2(element) {
3303
+ 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");
3304
+ };
3305
+ const _isNode = function _isNode2(value) {
3306
+ return typeof Node3 === "function" && value instanceof Node3;
3307
+ };
3308
+ function _executeHooks(hooks2, currentNode, data2) {
3309
+ arrayForEach(hooks2, (hook) => {
3310
+ hook.call(DOMPurify, currentNode, data2, CONFIG);
3311
+ });
3312
+ }
3313
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
3314
+ let content = null;
3315
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
3316
+ if (_isClobbered(currentNode)) {
3317
+ _forceRemove(currentNode);
3318
+ return true;
3319
+ }
3320
+ const tagName = transformCaseFunc(currentNode.nodeName);
3321
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
3322
+ tagName,
3323
+ allowedTags: ALLOWED_TAGS
3324
+ });
3325
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
3326
+ _forceRemove(currentNode);
3327
+ return true;
3328
+ }
3329
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
3330
+ _forceRemove(currentNode);
3331
+ return true;
3332
+ }
3333
+ if (currentNode.nodeType === NODE_TYPE$1.progressingInstruction) {
3334
+ _forceRemove(currentNode);
3335
+ return true;
3336
+ }
3337
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE$1.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
3338
+ _forceRemove(currentNode);
3339
+ return true;
3340
+ }
3341
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
3342
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
3343
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
3344
+ return false;
3345
+ }
3346
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
3347
+ return false;
3348
+ }
3349
+ }
3350
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
3351
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
3352
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
3353
+ if (childNodes && parentNode) {
3354
+ const childCount = childNodes.length;
3355
+ for (let i = childCount - 1; i >= 0; --i) {
3356
+ const childClone = cloneNode2(childNodes[i], true);
3357
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
3358
+ }
3359
+ }
3360
+ }
3361
+ _forceRemove(currentNode);
3362
+ return true;
3363
+ }
3364
+ if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
3365
+ _forceRemove(currentNode);
3366
+ return true;
3367
+ }
3368
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
3369
+ _forceRemove(currentNode);
3370
+ return true;
3371
+ }
3372
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE$1.text) {
3373
+ content = currentNode.textContent;
3374
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3375
+ content = stringReplace(content, expr, " ");
3376
+ });
3377
+ if (currentNode.textContent !== content) {
3378
+ arrayPush(DOMPurify.removed, {
3379
+ element: currentNode.cloneNode()
3380
+ });
3381
+ currentNode.textContent = content;
3382
+ }
3383
+ }
3384
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
3385
+ return false;
3386
+ };
3387
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
3388
+ if (FORBID_ATTR[lcName]) {
3389
+ return false;
3390
+ }
3391
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
3392
+ return false;
3393
+ }
3394
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
3395
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
3396
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
3397
+ else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
3398
+ if (
3399
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
3400
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3401
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
3402
+ _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
3403
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3404
+ 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))
3405
+ ) ;
3406
+ else {
3407
+ return false;
3408
+ }
3409
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
3410
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3411
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
3412
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3413
+ else if (value) {
3414
+ return false;
3415
+ } else ;
3416
+ return true;
3417
+ };
3418
+ 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"]);
3419
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
3420
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
3421
+ };
3422
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
3423
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
3424
+ const attributes2 = currentNode.attributes;
3425
+ if (!attributes2 || _isClobbered(currentNode)) {
3426
+ return;
3427
+ }
3428
+ const hookEvent = {
3429
+ attrName: "",
3430
+ attrValue: "",
3431
+ keepAttr: true,
3432
+ allowedAttributes: ALLOWED_ATTR,
3433
+ forceKeepAttr: void 0
3434
+ };
3435
+ let l2 = attributes2.length;
3436
+ while (l2--) {
3437
+ const attr2 = attributes2[l2];
3438
+ const name2 = attr2.name, namespaceURI = attr2.namespaceURI, attrValue = attr2.value;
3439
+ const lcName = transformCaseFunc(name2);
3440
+ const initValue = attrValue;
3441
+ let value = name2 === "value" ? initValue : stringTrim(initValue);
3442
+ hookEvent.attrName = lcName;
3443
+ hookEvent.attrValue = value;
3444
+ hookEvent.keepAttr = true;
3445
+ hookEvent.forceKeepAttr = void 0;
3446
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
3447
+ value = hookEvent.attrValue;
3448
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
3449
+ _removeAttribute(name2, currentNode);
3450
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
3451
+ }
3452
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
3453
+ _removeAttribute(name2, currentNode);
3454
+ continue;
3455
+ }
3456
+ if (lcName === "attributename" && stringMatch(value, "href")) {
3457
+ _removeAttribute(name2, currentNode);
3458
+ continue;
3459
+ }
3460
+ if (hookEvent.forceKeepAttr) {
3461
+ continue;
3462
+ }
3463
+ if (!hookEvent.keepAttr) {
3464
+ _removeAttribute(name2, currentNode);
3465
+ continue;
3466
+ }
3467
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
3468
+ _removeAttribute(name2, currentNode);
3469
+ continue;
3470
+ }
3471
+ if (SAFE_FOR_TEMPLATES) {
3472
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3473
+ value = stringReplace(value, expr, " ");
3474
+ });
3475
+ }
3476
+ const lcTag = transformCaseFunc(currentNode.nodeName);
3477
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3478
+ _removeAttribute(name2, currentNode);
3479
+ continue;
3480
+ }
3481
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
3482
+ if (namespaceURI) ;
3483
+ else {
3484
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
3485
+ case "TrustedHTML": {
3486
+ value = trustedTypesPolicy.createHTML(value);
3487
+ break;
3488
+ }
3489
+ case "TrustedScriptURL": {
3490
+ value = trustedTypesPolicy.createScriptURL(value);
3491
+ break;
3492
+ }
3493
+ }
3494
+ }
3495
+ }
3496
+ if (value !== initValue) {
3497
+ try {
3498
+ if (namespaceURI) {
3499
+ currentNode.setAttributeNS(namespaceURI, name2, value);
3500
+ } else {
3501
+ currentNode.setAttribute(name2, value);
3502
+ }
3503
+ if (_isClobbered(currentNode)) {
3504
+ _forceRemove(currentNode);
3505
+ } else {
3506
+ arrayPop(DOMPurify.removed);
3507
+ }
3508
+ } catch (_) {
3509
+ _removeAttribute(name2, currentNode);
3510
+ }
3511
+ }
3512
+ }
3513
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3514
+ };
3515
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3516
+ let shadowNode = null;
3517
+ const shadowIterator = _createNodeIterator(fragment);
3518
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3519
+ while (shadowNode = shadowIterator.nextNode()) {
3520
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3521
+ _sanitizeElements(shadowNode);
3522
+ _sanitizeAttributes(shadowNode);
3523
+ if (shadowNode.content instanceof DocumentFragment) {
3524
+ _sanitizeShadowDOM2(shadowNode.content);
3525
+ }
3526
+ }
3527
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3528
+ };
3529
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root2) {
3530
+ if (root2.nodeType === NODE_TYPE$1.element && root2.shadowRoot instanceof DocumentFragment) {
3531
+ const sr = root2.shadowRoot;
3532
+ _sanitizeAttachedShadowRoots2(sr);
3533
+ _sanitizeShadowDOM2(sr);
3534
+ }
3535
+ const childNodes = root2.childNodes;
3536
+ if (!childNodes) {
3537
+ return;
3538
+ }
3539
+ const snapshot = [];
3540
+ arrayForEach(childNodes, (child) => {
3541
+ arrayPush(snapshot, child);
3542
+ });
3543
+ for (const child of snapshot) {
3544
+ _sanitizeAttachedShadowRoots2(child);
3545
+ }
3546
+ };
3547
+ DOMPurify.sanitize = function(dirty) {
3548
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3549
+ let body = null;
3550
+ let importedNode = null;
3551
+ let currentNode = null;
3552
+ let returnNode = null;
3553
+ IS_EMPTY_INPUT = !dirty;
3554
+ if (IS_EMPTY_INPUT) {
3555
+ dirty = "<!-->";
3556
+ }
3557
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
3558
+ dirty = stringifyValue(dirty);
3559
+ if (typeof dirty !== "string") {
3560
+ throw typeErrorCreate("dirty is not a string, aborting");
3561
+ }
3562
+ }
3563
+ if (!DOMPurify.isSupported) {
3564
+ return dirty;
3565
+ }
3566
+ if (!SET_CONFIG) {
3567
+ _parseConfig(cfg);
3568
+ }
3569
+ DOMPurify.removed = [];
3570
+ if (typeof dirty === "string") {
3571
+ IN_PLACE = false;
3572
+ }
3573
+ if (IN_PLACE) {
3574
+ const nn = dirty.nodeName;
3575
+ if (typeof nn === "string") {
3576
+ const tagName = transformCaseFunc(nn);
3577
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3578
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
3579
+ }
3580
+ }
3581
+ _sanitizeAttachedShadowRoots2(dirty);
3582
+ } else if (dirty instanceof Node3) {
3583
+ body = _initDocument("<!---->");
3584
+ importedNode = body.ownerDocument.importNode(dirty, true);
3585
+ if (importedNode.nodeType === NODE_TYPE$1.element && importedNode.nodeName === "BODY") {
3586
+ body = importedNode;
3587
+ } else if (importedNode.nodeName === "HTML") {
3588
+ body = importedNode;
3589
+ } else {
3590
+ body.appendChild(importedNode);
3591
+ }
3592
+ _sanitizeAttachedShadowRoots2(importedNode);
3593
+ } else {
3594
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
3595
+ dirty.indexOf("<") === -1) {
3596
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
3597
+ }
3598
+ body = _initDocument(dirty);
3599
+ if (!body) {
3600
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
3601
+ }
3602
+ }
3603
+ if (body && FORCE_BODY) {
3604
+ _forceRemove(body.firstChild);
3605
+ }
3606
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
3607
+ while (currentNode = nodeIterator.nextNode()) {
3608
+ _sanitizeElements(currentNode);
3609
+ _sanitizeAttributes(currentNode);
3610
+ if (currentNode.content instanceof DocumentFragment) {
3611
+ _sanitizeShadowDOM2(currentNode.content);
3612
+ }
3613
+ }
3614
+ if (IN_PLACE) {
3615
+ return dirty;
3616
+ }
3617
+ if (RETURN_DOM) {
3618
+ if (SAFE_FOR_TEMPLATES) {
3619
+ body.normalize();
3620
+ let html2 = body.innerHTML;
3621
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3622
+ html2 = stringReplace(html2, expr, " ");
3623
+ });
3624
+ body.innerHTML = html2;
3625
+ }
3626
+ if (RETURN_DOM_FRAGMENT) {
3627
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3628
+ while (body.firstChild) {
3629
+ returnNode.appendChild(body.firstChild);
3630
+ }
3631
+ } else {
3632
+ returnNode = body;
3633
+ }
3634
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3635
+ returnNode = importNode.call(originalDocument, returnNode, true);
3636
+ }
3637
+ return returnNode;
3638
+ }
3639
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3640
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3641
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
3642
+ }
3643
+ if (SAFE_FOR_TEMPLATES) {
3644
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3645
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
3646
+ });
3647
+ }
3648
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
3649
+ };
3650
+ DOMPurify.setConfig = function() {
3651
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3652
+ _parseConfig(cfg);
3653
+ SET_CONFIG = true;
3654
+ };
3655
+ DOMPurify.clearConfig = function() {
3656
+ CONFIG = null;
3657
+ SET_CONFIG = false;
3658
+ };
3659
+ DOMPurify.isValidAttribute = function(tag, attr2, value) {
3660
+ if (!CONFIG) {
3661
+ _parseConfig({});
3662
+ }
3663
+ const lcTag = transformCaseFunc(tag);
3664
+ const lcName = transformCaseFunc(attr2);
3665
+ return _isValidAttribute(lcTag, lcName, value);
3666
+ };
3667
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
3668
+ if (typeof hookFunction !== "function") {
3669
+ return;
3670
+ }
3671
+ arrayPush(hooks[entryPoint], hookFunction);
3672
+ };
3673
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
3674
+ if (hookFunction !== void 0) {
3675
+ const index2 = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3676
+ return index2 === -1 ? void 0 : arraySplice(hooks[entryPoint], index2, 1)[0];
3677
+ }
3678
+ return arrayPop(hooks[entryPoint]);
3679
+ };
3680
+ DOMPurify.removeHooks = function(entryPoint) {
3681
+ hooks[entryPoint] = [];
3682
+ };
3683
+ DOMPurify.removeAllHooks = function() {
3684
+ hooks = _createHooksMap();
3685
+ };
3686
+ return DOMPurify;
3687
+ }
3688
+ var purify = createDOMPurify();
2453
3689
  ABConvert.factory({
2454
3690
  id: "md",
2455
3691
  name: "md",
@@ -2469,7 +3705,7 @@ ABConvert.factory({
2469
3705
  process_param: ABConvert_IOEnum.text,
2470
3706
  process_return: ABConvert_IOEnum.el,
2471
3707
  process: (el, header, content) => {
2472
- el.innerHTML = `<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`;
3708
+ el.innerHTML = purify.sanitize(`<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`);
2473
3709
  return el;
2474
3710
  }
2475
3711
  });
@@ -2504,7 +3740,26 @@ ABConvert.factory({
2504
3740
  sub_button.textContent = "折叠";
2505
3741
  }
2506
3742
  };
2507
- sub_button.onclick = fn_fold;
3743
+ if (ABCSetting.env.startsWith("obsidian")) {
3744
+ sub_button.onclick = fn_fold;
3745
+ } else {
3746
+ sub_button.setAttribute("onclick", `
3747
+ const sub_button = this;
3748
+ const sub_el = this.nextElementSibling;
3749
+
3750
+ const is_hide = sub_el.getAttribute("is_hide")
3751
+ if (is_hide && is_hide=="false") {
3752
+ sub_el.setAttribute("is_hide", "true");
3753
+ sub_el.style.display = "none"
3754
+ sub_button.textContent = "展开"
3755
+ }
3756
+ else if(is_hide && is_hide=="true") {
3757
+ sub_el.setAttribute("is_hide", "false");
3758
+ sub_el.style.display = ""
3759
+ sub_button.textContent = "折叠"
3760
+ }
3761
+ `);
3762
+ }
2508
3763
  mid_el.appendChild(sub_button);
2509
3764
  mid_el.appendChild(sub_el);
2510
3765
  const isListTable = sub_el.classList.contains("ab-list-table-parent");
@@ -3170,12 +4425,10 @@ ABConvert.factory({
3170
4425
  process_return: ABConvert_IOEnum.json,
3171
4426
  process: (el, header, content) => {
3172
4427
  return JSON.stringify(
3173
- ABAlias_json.map((item) => {
3174
- return {
3175
- regex: item.regex.toString(),
3176
- replacement: item.replacement
3177
- };
3178
- }),
4428
+ Array.from(get_ABAlias_iter(), (item) => ({
4429
+ regex: item.regex.toString(),
4430
+ replacement: item.replacement
4431
+ })),
3179
4432
  null,
3180
4433
  2
3181
4434
  );
@@ -15126,7 +16379,7 @@ ABConvert.factory({
15126
16379
  async function render_pumlText(text2, div) {
15127
16380
  var encoded = plantumlEncoder.encode(text2);
15128
16381
  let url = "http://www.plantuml.com/plantuml/img/" + encoded;
15129
- div.innerHTML = `<img src="${url}">`;
16382
+ div.innerHTML = purify.sanitize(`<img src="${url}">`);
15130
16383
  return div;
15131
16384
  }
15132
16385
  function getID(length = 16) {
@@ -15301,206 +16554,20 @@ async function data2mindmap(list_itemInfo, div) {
15301
16554
  return render_mermaidText(mermaidText, div);
15302
16555
  }
15303
16556
  async function render_mermaidText(mermaidText, div) {
15304
- if (ABCSetting.env.startsWith("obsidian") && ABCSetting.mermaid) {
15305
- ABCSetting.mermaid.then(async (mermaid) => {
15306
- const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
15307
- div.innerHTML = svg;
16557
+ if (ABCSetting.env.startsWith("obsidian") && ABCSetting.obsidian.mermaid) {
16558
+ ABCSetting.obsidian.mermaid.then(async (mermaid) => {
16559
+ const { svg: svg2 } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
16560
+ const div_mermaid = document.createElement("div");
16561
+ div.appendChild(div_mermaid);
16562
+ div_mermaid.classList.add("mermaid");
16563
+ div_mermaid.innerHTML = svg2;
15308
16564
  });
15309
16565
  } else {
15310
16566
  div.classList.add("ab-raw");
15311
- div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
16567
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`);
15312
16568
  }
15313
16569
  return div;
15314
16570
  }
15315
- function abConvertEvent(d, isCycle = false) {
15316
- if (d.querySelector(".ab-super-width")) {
15317
- const els_note = d.querySelectorAll(".ab-note");
15318
- for (const el_note of els_note) {
15319
- if (el_note.querySelector(".ab-super-width")) {
15320
- const el_replace = el_note.parentNode;
15321
- if (el_replace && el_replace.classList.contains("ab-replace")) {
15322
- el_replace.classList.add("ab-super-width-p");
15323
- }
15324
- }
15325
- }
15326
- const els_view = document.querySelectorAll(".app-container .workspace-leaf");
15327
- for (const el_view of els_view) {
15328
- el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
15329
- }
15330
- }
15331
- if (d.querySelector(".ab-nodes-node")) {
15332
- const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
15333
- const list_children = d.querySelectorAll(".ab-nodes-node");
15334
- for (const children2 of list_children) {
15335
- const el_content = children2.querySelector(".ab-nodes-content");
15336
- if (!el_content) continue;
15337
- const el_child = children2.querySelector(".ab-nodes-children");
15338
- if (!el_child) continue;
15339
- const el_bracket = el_child.querySelector(".ab-nodes-bracket");
15340
- if (!el_bracket) continue;
15341
- const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
15342
- if (!el_bracket2) continue;
15343
- const els_child = el_child.childNodes;
15344
- if (els_child.length < 3) {
15345
- el_bracket.style.setProperty("display", "none");
15346
- el_bracket2.style.setProperty("display", "none");
15347
- continue;
15348
- }
15349
- const el_child_first = els_child[2];
15350
- const el_child_last = els_child[els_child.length - 1];
15351
- const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
15352
- const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
15353
- let height = 0;
15354
- let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
15355
- if (els_child.length == 3) {
15356
- height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
15357
- el_bracket2.style.cssText = `
15358
- height: ${height}px;
15359
- top: calc(50% - ${height / 2}px);
15360
- `;
15361
- } else {
15362
- el_bracket2.style.cssText = `
15363
- height: calc(100% - ${heightToReduce}px);
15364
- top: ${el_child_first.offsetHeight / 2}px;
15365
- `;
15366
- }
15367
- if (Array.prototype.includes.call(els_min, children2)) {
15368
- if (els_child.length == 3) {
15369
- el_bracket.style.cssText = `
15370
- display: block;
15371
- top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
15372
- clip-path: circle(40% at 50% 40%);
15373
- `;
15374
- } else {
15375
- el_bracket.setAttribute("display", "none");
15376
- }
15377
- if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
15378
- el_bracket2.style.cssText = `
15379
- height: 1px;
15380
- top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
15381
- width: 18px; /* 可以溢出点 */
15382
- border-radius: 0;
15383
- border: none;
15384
- border-bottom: 1px solid var(--node-color);
15385
- `;
15386
- } else {
15387
- if (els_child.length == 3) {
15388
- height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
15389
- el_bracket2.style.setProperty("height", `${height}px`);
15390
- el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
15391
- el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
15392
- el_bracket2.style.setProperty("border-top", `0`);
15393
- } else {
15394
- heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
15395
- el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
15396
- el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
15397
- }
15398
- el_bracket2.style.setProperty("width", "20px");
15399
- }
15400
- }
15401
- }
15402
- }
15403
- if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
15404
- const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
15405
- for (const root_el of root_el_list) {
15406
- root_el.classList.add("js-waterfall");
15407
- const list_children = root_el.querySelectorAll(".ab-items-item");
15408
- const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
15409
- let columnCount;
15410
- if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
15411
- columnCount = columnCountTmp;
15412
- } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
15413
- columnCount = list_children.length;
15414
- root_el.classList.add("ab-col" + columnCount);
15415
- } else {
15416
- columnCount = 4;
15417
- root_el.classList.add("ab-col" + columnCount);
15418
- }
15419
- const height_cache = [];
15420
- const el_cache = [];
15421
- for (let i = 0; i < columnCount; i++) {
15422
- height_cache.push(0);
15423
- el_cache.push([]);
15424
- }
15425
- for (const children2 of list_children) {
15426
- const minValue = Math.min.apply(null, height_cache);
15427
- const minIndex = height_cache.indexOf(minValue);
15428
- const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
15429
- height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
15430
- el_cache[minIndex].push(children2);
15431
- }
15432
- const fillNumber = columnCount - list_children.length % columnCount;
15433
- if (fillNumber != 4) {
15434
- for (let i = 0; i < fillNumber; i++) {
15435
- const children2 = document.createElement("div");
15436
- children2.classList.add(".ab-items-item.placeholder");
15437
- children2.setAttribute("style", "height: 20px");
15438
- const minValue = Math.min.apply(null, height_cache);
15439
- const minIndex = height_cache.indexOf(minValue);
15440
- height_cache[minIndex] += 20;
15441
- el_cache[minIndex].push(children2);
15442
- }
15443
- }
15444
- root_el.innerHTML = "";
15445
- for (let i = 0; i < columnCount; i++) {
15446
- for (const j of el_cache[i]) {
15447
- root_el.appendChild(j);
15448
- }
15449
- }
15450
- }
15451
- }
15452
- if (!isCycle && d.querySelector(".ab-markmap-div")) {
15453
- const divEl = d;
15454
- let markmapId = "";
15455
- if (divEl.tagName === "DIV") {
15456
- markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
15457
- }
15458
- let mindmaps;
15459
- if (markmapId) {
15460
- mindmaps = document.querySelectorAll("#" + markmapId);
15461
- } else {
15462
- mindmaps = document.querySelectorAll(".ab-markmap-div");
15463
- }
15464
- for (const el_div of mindmaps) {
15465
- const el_svg = el_div.querySelector("svg");
15466
- const el_g = el_svg?.querySelector("g");
15467
- if (el_svg && el_g) {
15468
- const scale_new = el_g.getBBox().height / el_div.offsetWidth;
15469
- el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
15470
- markmap_event(d);
15471
- }
15472
- }
15473
- }
15474
- }
15475
- function markmap_event(d) {
15476
- if (d.querySelector(".ab-markmap-svg")) {
15477
- console.log(" - markmap_event");
15478
- let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
15479
- if (script_el) script_el.remove();
15480
- const divEl = d;
15481
- let markmapId = "";
15482
- if (divEl.tagName === "DIV") {
15483
- markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
15484
- }
15485
- script_el = document.createElement("script");
15486
- document.head.appendChild(script_el);
15487
- script_el.type = "module";
15488
- script_el.setAttribute("script-id", "ab-markmap-script");
15489
- script_el.textContent = `
15490
- import { Markmap, } from 'https://jspm.dev/markmap-view';
15491
- const markmapId = "${markmapId || ""}";
15492
- let mindmaps;
15493
- if (markmapId) {
15494
- mindmaps = document.querySelectorAll('#' + markmapId);
15495
- } else {
15496
- mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
15497
- }
15498
- for(const mindmap of mindmaps) {
15499
- mindmap.innerHTML = "";
15500
- Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
15501
- }`;
15502
- }
15503
- }
15504
16571
  const testPath = "npm2url/dist/index.cjs";
15505
16572
  const defaultProviders = {
15506
16573
  jsdelivr: (path) => `https://cdn.jsdelivr.net/npm/${path}`,
@@ -41126,8 +42193,8 @@ function requireKatex() {
41126
42193
  var _functions = {};
41127
42194
  var _htmlGroupBuilders = {};
41128
42195
  var _mathmlGroupBuilders = {};
41129
- function defineFunction(_ref) {
41130
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
42196
+ function defineFunction(_ref2) {
42197
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
41131
42198
  var data2 = {
41132
42199
  type,
41133
42200
  numArgs: props.numArgs,
@@ -42125,8 +43192,8 @@ function requireKatex() {
42125
43192
  props: {
42126
43193
  numArgs: 1
42127
43194
  },
42128
- handler: function handler(_ref, args) {
42129
- var parser = _ref.parser, funcName = _ref.funcName;
43195
+ handler: function handler(_ref2, args) {
43196
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42130
43197
  var base = args[0];
42131
43198
  return {
42132
43199
  type: "accentUnder",
@@ -42201,8 +43268,8 @@ function requireKatex() {
42201
43268
  numArgs: 1,
42202
43269
  numOptionalArgs: 1
42203
43270
  },
42204
- handler: function handler(_ref, args, optArgs) {
42205
- var parser = _ref.parser, funcName = _ref.funcName;
43271
+ handler: function handler(_ref2, args, optArgs) {
43272
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42206
43273
  return {
42207
43274
  type: "xArrow",
42208
43275
  mode: parser.mode,
@@ -42294,8 +43361,8 @@ function requireKatex() {
42294
43361
  numArgs: 1,
42295
43362
  allowedInText: true
42296
43363
  },
42297
- handler: function handler(_ref, args) {
42298
- var parser = _ref.parser;
43364
+ handler: function handler(_ref2, args) {
43365
+ var parser = _ref2.parser;
42299
43366
  var arg = assertNodeType(args[0], "ordgroup");
42300
43367
  var group = arg.body;
42301
43368
  var number = "";
@@ -42333,8 +43400,8 @@ function requireKatex() {
42333
43400
  greediness: 3,
42334
43401
  argTypes: ["color", "original"]
42335
43402
  },
42336
- handler: function handler(_ref, args) {
42337
- var parser = _ref.parser;
43403
+ handler: function handler(_ref2, args) {
43404
+ var parser = _ref2.parser;
42338
43405
  var color2 = assertNodeType(args[0], "color-token").color;
42339
43406
  var body = args[1];
42340
43407
  return {
@@ -42380,8 +43447,8 @@ function requireKatex() {
42380
43447
  argTypes: ["size"],
42381
43448
  allowedInText: true
42382
43449
  },
42383
- handler: function handler(_ref, args, optArgs) {
42384
- var parser = _ref.parser, funcName = _ref.funcName;
43450
+ handler: function handler(_ref2, args, optArgs) {
43451
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42385
43452
  var size = optArgs[0];
42386
43453
  var newRow = funcName === "\\cr";
42387
43454
  var newLine = false;
@@ -42474,8 +43541,8 @@ function requireKatex() {
42474
43541
  numArgs: 0,
42475
43542
  allowedInText: true
42476
43543
  },
42477
- handler: function handler(_ref) {
42478
- var parser = _ref.parser, funcName = _ref.funcName;
43544
+ handler: function handler(_ref2) {
43545
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42479
43546
  parser.consumeSpaces();
42480
43547
  var token = parser.fetch();
42481
43548
  if (globalMap[token.text]) {
@@ -42809,14 +43876,14 @@ function requireKatex() {
42809
43876
  var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
42810
43877
  var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
42811
43878
  var pathNode = new domTree_PathNode(sqrtName, path);
42812
- var svg = new SvgNode([pathNode], {
43879
+ var svg2 = new SvgNode([pathNode], {
42813
43880
  // Note: 1000:1 ratio of viewBox to document em width.
42814
43881
  "width": "400em",
42815
43882
  "height": height + "em",
42816
43883
  "viewBox": "0 0 400000 " + viewBoxHeight,
42817
43884
  "preserveAspectRatio": "xMinYMin slice"
42818
43885
  });
42819
- return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
43886
+ return buildCommon.makeSvgSpan(["hide-tail"], [svg2], options);
42820
43887
  };
42821
43888
  var makeSqrtImage = function makeSqrtImage2(height, options) {
42822
43889
  var newOptions = options.havingBaseSizing();
@@ -43426,8 +44493,8 @@ function requireKatex() {
43426
44493
  greediness: 3,
43427
44494
  argTypes: ["color", "text"]
43428
44495
  },
43429
- handler: function handler(_ref, args, optArgs) {
43430
- var parser = _ref.parser, funcName = _ref.funcName;
44496
+ handler: function handler(_ref2, args, optArgs) {
44497
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43431
44498
  var color2 = assertNodeType(args[0], "color-token").color;
43432
44499
  var body = args[1];
43433
44500
  return {
@@ -43505,8 +44572,8 @@ function requireKatex() {
43505
44572
  mathmlBuilder: enclose_mathmlBuilder
43506
44573
  });
43507
44574
  var _environments = {};
43508
- function defineEnvironment(_ref) {
43509
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
44575
+ function defineEnvironment(_ref2) {
44576
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
43510
44577
  var data2 = {
43511
44578
  type,
43512
44579
  numArgs: props.numArgs || 0,
@@ -43537,8 +44604,8 @@ function requireKatex() {
43537
44604
  }
43538
44605
  return hlineInfo;
43539
44606
  }
43540
- function parseArray(parser, _ref, style) {
43541
- var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, addJot = _ref.addJot, cols = _ref.cols, arraystretch = _ref.arraystretch, colSeparationType = _ref.colSeparationType;
44607
+ function parseArray(parser, _ref2, style) {
44608
+ var hskipBeforeAndAfter = _ref2.hskipBeforeAndAfter, addJot = _ref2.addJot, cols = _ref2.cols, arraystretch = _ref2.arraystretch, colSeparationType = _ref2.colSeparationType;
43542
44609
  parser.gullet.beginGroup();
43543
44610
  parser.gullet.macros.set("\\\\", "\\cr");
43544
44611
  if (!arraystretch) {
@@ -44177,8 +45244,8 @@ function requireKatex() {
44177
45244
  numArgs: 1,
44178
45245
  argTypes: ["text"]
44179
45246
  },
44180
- handler: function handler(_ref, args) {
44181
- var parser = _ref.parser, funcName = _ref.funcName;
45247
+ handler: function handler(_ref2, args) {
45248
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44182
45249
  var nameGroup = args[0];
44183
45250
  if (nameGroup.type !== "ordgroup") {
44184
45251
  throw new src_ParseError("Invalid environment name", nameGroup);
@@ -44258,8 +45325,8 @@ function requireKatex() {
44258
45325
  props: {
44259
45326
  numArgs: 1
44260
45327
  },
44261
- handler: function handler(_ref, args) {
44262
- var parser = _ref.parser, funcName = _ref.funcName;
45328
+ handler: function handler(_ref2, args) {
45329
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44263
45330
  var body = args[0];
44264
45331
  return {
44265
45332
  type: "mclass",
@@ -44382,8 +45449,8 @@ function requireKatex() {
44382
45449
  numArgs: 1,
44383
45450
  greediness: 2
44384
45451
  },
44385
- handler: function handler(_ref, args) {
44386
- var parser = _ref.parser, funcName = _ref.funcName;
45452
+ handler: function handler(_ref2, args) {
45453
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44387
45454
  var body = args[0];
44388
45455
  var func = funcName;
44389
45456
  if (func in fontAliases) {
@@ -44637,8 +45704,8 @@ function requireKatex() {
44637
45704
  numArgs: 2,
44638
45705
  greediness: 2
44639
45706
  },
44640
- handler: function handler(_ref, args) {
44641
- var parser = _ref.parser, funcName = _ref.funcName;
45707
+ handler: function handler(_ref2, args) {
45708
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44642
45709
  var numer = args[0];
44643
45710
  var denom = args[1];
44644
45711
  var hasBarLine;
@@ -44939,8 +46006,8 @@ function requireKatex() {
44939
46006
  props: {
44940
46007
  numArgs: 1
44941
46008
  },
44942
- handler: function handler(_ref, args) {
44943
- var parser = _ref.parser, funcName = _ref.funcName;
46009
+ handler: function handler(_ref2, args) {
46010
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44944
46011
  return {
44945
46012
  type: "horizBrace",
44946
46013
  mode: parser.mode,
@@ -44960,8 +46027,8 @@ function requireKatex() {
44960
46027
  argTypes: ["url", "original"],
44961
46028
  allowedInText: true
44962
46029
  },
44963
- handler: function handler(_ref, args) {
44964
- var parser = _ref.parser;
46030
+ handler: function handler(_ref2, args) {
46031
+ var parser = _ref2.parser;
44965
46032
  var body = args[1];
44966
46033
  var href = assertNodeType(args[0], "url").url;
44967
46034
  if (!parser.settings.isTrusted({
@@ -45041,9 +46108,9 @@ function requireKatex() {
45041
46108
  argTypes: ["raw", "original"],
45042
46109
  allowedInText: true
45043
46110
  },
45044
- handler: function handler(_ref, args) {
45045
- var parser = _ref.parser, funcName = _ref.funcName;
45046
- _ref.token;
46111
+ handler: function handler(_ref2, args) {
46112
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46113
+ _ref2.token;
45047
46114
  var value = assertNodeType(args[0], "raw").string;
45048
46115
  var body = args[1];
45049
46116
  if (parser.settings.strict) {
@@ -45126,8 +46193,8 @@ function requireKatex() {
45126
46193
  numArgs: 2,
45127
46194
  allowedInText: true
45128
46195
  },
45129
- handler: function handler(_ref, args) {
45130
- var parser = _ref.parser;
46196
+ handler: function handler(_ref2, args) {
46197
+ var parser = _ref2.parser;
45131
46198
  return {
45132
46199
  type: "htmlmathml",
45133
46200
  mode: parser.mode,
@@ -45174,8 +46241,8 @@ function requireKatex() {
45174
46241
  argTypes: ["raw", "url"],
45175
46242
  allowedInText: false
45176
46243
  },
45177
- handler: function handler(_ref, args, optArgs) {
45178
- var parser = _ref.parser;
46244
+ handler: function handler(_ref2, args, optArgs) {
46245
+ var parser = _ref2.parser;
45179
46246
  var width = {
45180
46247
  number: 0,
45181
46248
  unit: "em"
@@ -45289,8 +46356,8 @@ function requireKatex() {
45289
46356
  argTypes: ["size"],
45290
46357
  allowedInText: true
45291
46358
  },
45292
- handler: function handler(_ref, args) {
45293
- var parser = _ref.parser, funcName = _ref.funcName;
46359
+ handler: function handler(_ref2, args) {
46360
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45294
46361
  var size = assertNodeType(args[0], "size");
45295
46362
  if (parser.settings.strict) {
45296
46363
  var mathFunction = funcName[1] === "m";
@@ -45329,8 +46396,8 @@ function requireKatex() {
45329
46396
  numArgs: 1,
45330
46397
  allowedInText: true
45331
46398
  },
45332
- handler: function handler(_ref, args) {
45333
- var parser = _ref.parser, funcName = _ref.funcName;
46399
+ handler: function handler(_ref2, args) {
46400
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45334
46401
  var body = args[0];
45335
46402
  return {
45336
46403
  type: "lap",
@@ -45374,8 +46441,8 @@ function requireKatex() {
45374
46441
  allowedInText: true,
45375
46442
  allowedInMath: false
45376
46443
  },
45377
- handler: function handler(_ref, args) {
45378
- var funcName = _ref.funcName, parser = _ref.parser;
46444
+ handler: function handler(_ref2, args) {
46445
+ var funcName = _ref2.funcName, parser = _ref2.parser;
45379
46446
  var outerMode = parser.mode;
45380
46447
  parser.switchMode("math");
45381
46448
  var close = funcName === "\\(" ? "\\)" : "$";
@@ -45423,8 +46490,8 @@ function requireKatex() {
45423
46490
  props: {
45424
46491
  numArgs: 4
45425
46492
  },
45426
- handler: function handler(_ref, args) {
45427
- var parser = _ref.parser;
46493
+ handler: function handler(_ref2, args) {
46494
+ var parser = _ref2.parser;
45428
46495
  return {
45429
46496
  type: "mathchoice",
45430
46497
  mode: parser.mode,
@@ -45656,8 +46723,8 @@ function requireKatex() {
45656
46723
  props: {
45657
46724
  numArgs: 0
45658
46725
  },
45659
- handler: function handler(_ref, args) {
45660
- var parser = _ref.parser, funcName = _ref.funcName;
46726
+ handler: function handler(_ref2, args) {
46727
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45661
46728
  var fName = funcName;
45662
46729
  if (fName.length === 1) {
45663
46730
  fName = singleCharBigOps[fName];
@@ -45863,8 +46930,8 @@ function requireKatex() {
45863
46930
  props: {
45864
46931
  numArgs: 1
45865
46932
  },
45866
- handler: function handler(_ref, args) {
45867
- var parser = _ref.parser, funcName = _ref.funcName;
46933
+ handler: function handler(_ref2, args) {
46934
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45868
46935
  var body = args[0];
45869
46936
  return {
45870
46937
  type: "operatorname",
@@ -45896,8 +46963,8 @@ function requireKatex() {
45896
46963
  props: {
45897
46964
  numArgs: 1
45898
46965
  },
45899
- handler: function handler(_ref, args) {
45900
- var parser = _ref.parser;
46966
+ handler: function handler(_ref2, args) {
46967
+ var parser = _ref2.parser;
45901
46968
  var body = args[0];
45902
46969
  return {
45903
46970
  type: "overline",
@@ -45942,8 +47009,8 @@ function requireKatex() {
45942
47009
  numArgs: 1,
45943
47010
  allowedInText: true
45944
47011
  },
45945
- handler: function handler(_ref, args) {
45946
- var parser = _ref.parser;
47012
+ handler: function handler(_ref2, args) {
47013
+ var parser = _ref2.parser;
45947
47014
  var body = args[0];
45948
47015
  return {
45949
47016
  type: "phantom",
@@ -46041,8 +47108,8 @@ function requireKatex() {
46041
47108
  argTypes: ["size", "hbox"],
46042
47109
  allowedInText: true
46043
47110
  },
46044
- handler: function handler(_ref, args) {
46045
- var parser = _ref.parser;
47111
+ handler: function handler(_ref2, args) {
47112
+ var parser = _ref2.parser;
46046
47113
  var amount = assertNodeType(args[0], "size").value;
46047
47114
  var body = args[1];
46048
47115
  return {
@@ -46079,8 +47146,8 @@ function requireKatex() {
46079
47146
  numOptionalArgs: 1,
46080
47147
  argTypes: ["size", "size", "size"]
46081
47148
  },
46082
- handler: function handler(_ref, args, optArgs) {
46083
- var parser = _ref.parser;
47149
+ handler: function handler(_ref2, args, optArgs) {
47150
+ var parser = _ref2.parser;
46084
47151
  var shift = optArgs[0];
46085
47152
  var width = assertNodeType(args[0], "size");
46086
47153
  var height = assertNodeType(args[1], "size");
@@ -46153,8 +47220,8 @@ function requireKatex() {
46153
47220
  numArgs: 0,
46154
47221
  allowedInText: true
46155
47222
  },
46156
- handler: function handler(_ref, args) {
46157
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47223
+ handler: function handler(_ref2, args) {
47224
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46158
47225
  var body = parser.parseExpression(false, breakOnTokenText);
46159
47226
  return {
46160
47227
  type: "sizing",
@@ -46181,8 +47248,8 @@ function requireKatex() {
46181
47248
  numOptionalArgs: 1,
46182
47249
  allowedInText: true
46183
47250
  },
46184
- handler: function handler(_ref, args, optArgs) {
46185
- var parser = _ref.parser;
47251
+ handler: function handler(_ref2, args, optArgs) {
47252
+ var parser = _ref2.parser;
46186
47253
  var smashHeight = false;
46187
47254
  var smashDepth = false;
46188
47255
  var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
@@ -46262,8 +47329,8 @@ function requireKatex() {
46262
47329
  numArgs: 1,
46263
47330
  numOptionalArgs: 1
46264
47331
  },
46265
- handler: function handler(_ref, args, optArgs) {
46266
- var parser = _ref.parser;
47332
+ handler: function handler(_ref2, args, optArgs) {
47333
+ var parser = _ref2.parser;
46267
47334
  var index2 = optArgs[0];
46268
47335
  var body = args[0];
46269
47336
  return {
@@ -46347,8 +47414,8 @@ function requireKatex() {
46347
47414
  numArgs: 0,
46348
47415
  allowedInText: true
46349
47416
  },
46350
- handler: function handler(_ref, args) {
46351
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47417
+ handler: function handler(_ref2, args) {
47418
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46352
47419
  var body = parser.parseExpression(true, breakOnTokenText);
46353
47420
  var style = funcName.slice(1, funcName.length - 5);
46354
47421
  return {
@@ -46733,8 +47800,8 @@ function requireKatex() {
46733
47800
  greediness: 2,
46734
47801
  allowedInText: true
46735
47802
  },
46736
- handler: function handler(_ref, args) {
46737
- var parser = _ref.parser, funcName = _ref.funcName;
47803
+ handler: function handler(_ref2, args) {
47804
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46738
47805
  var body = args[0];
46739
47806
  return {
46740
47807
  type: "text",
@@ -46760,8 +47827,8 @@ function requireKatex() {
46760
47827
  numArgs: 1,
46761
47828
  allowedInText: true
46762
47829
  },
46763
- handler: function handler(_ref, args) {
46764
- var parser = _ref.parser;
47830
+ handler: function handler(_ref2, args) {
47831
+ var parser = _ref2.parser;
46765
47832
  return {
46766
47833
  type: "underline",
46767
47834
  mode: parser.mode,
@@ -49631,7 +50698,7 @@ ABConvert.factory({
49631
50698
  process_return: ABConvert_IOEnum.el,
49632
50699
  process: (el, header, content) => {
49633
50700
  list2markmap(content, el);
49634
- markmap_event(el);
50701
+ ABCSetting.obsidian.markmap_event?.(el);
49635
50702
  return el;
49636
50703
  }
49637
50704
  });
@@ -49647,13 +50714,46 @@ function list2markmap(markdown, div) {
49647
50714
  svg_div.classList.add("ab-markmap-div");
49648
50715
  svg_div.id = "ab-markmap-div-" + id;
49649
50716
  const html_str = `<svg class="ab-markmap-svg" id="ab-markmap-${id}" data-json='${JSON.stringify(root2)}' style="height:${height_adapt}px"></svg>`;
49650
- svg_div.innerHTML = html_str;
50717
+ svg_div.innerHTML = purify.sanitize(html_str, {
50718
+ USE_PROFILES: { svg: true }
50719
+ });
49651
50720
  } else {
49652
50721
  div.classList.add("ab-raw");
49653
- div.innerHTML = `<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`;
50722
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`);
49654
50723
  }
49655
50724
  return div;
49656
50725
  }
50726
+ async function markmap_event(d) {
50727
+ if (ABCSetting.env == "obsidian-min") return;
50728
+ if (d.querySelector(".ab-markmap-svg")) {
50729
+ console.log(" - markmap_event");
50730
+ let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
50731
+ if (script_el) script_el.remove();
50732
+ const divEl = d;
50733
+ let markmapId = "";
50734
+ if (divEl.tagName === "DIV") {
50735
+ markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
50736
+ }
50737
+ script_el = document.createElement("script");
50738
+ document.head.appendChild(script_el);
50739
+ script_el.type = "module";
50740
+ script_el.setAttribute("script-id", "ab-markmap-script");
50741
+ script_el.textContent = `
50742
+ import { Markmap, } from 'https://jspm.dev/markmap-view';
50743
+ const markmapId = "${markmapId || ""}";
50744
+ let mindmaps;
50745
+ if (markmapId) {
50746
+ mindmaps = document.querySelectorAll('#' + markmapId);
50747
+ } else {
50748
+ mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
50749
+ }
50750
+ for(const mindmap of mindmaps) {
50751
+ mindmap.innerHTML = "";
50752
+ Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
50753
+ }`;
50754
+ }
50755
+ }
50756
+ ABCSetting.obsidian.markmap_event = markmap_event;
49657
50757
  const md = new MarkdownIt({
49658
50758
  html: true,
49659
50759
  // 启用 HTML 标签解析
@@ -49710,6 +50810,166 @@ const quartz_transformer_anyblock = () => {
49710
50810
  }
49711
50811
  };
49712
50812
  };
50813
+ function abConvertEvent(d, isCycle = false) {
50814
+ if (d.querySelector(".ab-super-width")) {
50815
+ const els_note = d.querySelectorAll(".ab-note");
50816
+ for (const el_note of els_note) {
50817
+ if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
50818
+ const el_replace = el_note.parentNode;
50819
+ if (el_replace && el_replace.classList.contains("ab-replace")) {
50820
+ el_replace.classList.add("ab-super-width-p");
50821
+ }
50822
+ }
50823
+ }
50824
+ const els_view = document.querySelectorAll(".app-container .workspace-leaf");
50825
+ for (const el_view of els_view) {
50826
+ el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
50827
+ }
50828
+ }
50829
+ if (d.querySelector(".ab-nodes-node")) {
50830
+ const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
50831
+ const list_children = d.querySelectorAll(".ab-nodes-node");
50832
+ for (const children2 of list_children) {
50833
+ const el_content = children2.querySelector(".ab-nodes-content");
50834
+ if (!el_content) continue;
50835
+ const el_child = children2.querySelector(".ab-nodes-children");
50836
+ if (!el_child) continue;
50837
+ const el_bracket = el_child.querySelector(".ab-nodes-bracket");
50838
+ if (!el_bracket) continue;
50839
+ const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
50840
+ if (!el_bracket2) continue;
50841
+ const els_child = el_child.childNodes;
50842
+ if (els_child.length < 3) {
50843
+ el_bracket.style.setProperty("display", "none");
50844
+ el_bracket2.style.setProperty("display", "none");
50845
+ continue;
50846
+ }
50847
+ const el_child_first = els_child[2];
50848
+ const el_child_last = els_child[els_child.length - 1];
50849
+ const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
50850
+ const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
50851
+ let height = 0;
50852
+ let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
50853
+ if (els_child.length == 3) {
50854
+ height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
50855
+ el_bracket2.style.cssText = `
50856
+ height: ${height}px;
50857
+ top: calc(50% - ${height / 2}px);
50858
+ `;
50859
+ } else {
50860
+ el_bracket2.style.cssText = `
50861
+ height: calc(100% - ${heightToReduce}px);
50862
+ top: ${el_child_first.offsetHeight / 2}px;
50863
+ `;
50864
+ }
50865
+ if (Array.prototype.includes.call(els_min, children2)) {
50866
+ if (els_child.length == 3) {
50867
+ el_bracket.style.cssText = `
50868
+ display: block;
50869
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
50870
+ clip-path: circle(40% at 50% 40%);
50871
+ `;
50872
+ } else {
50873
+ el_bracket.setAttribute("display", "none");
50874
+ }
50875
+ if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
50876
+ el_bracket2.style.cssText = `
50877
+ height: 1px;
50878
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
50879
+ width: 18px; /* 可以溢出点 */
50880
+ border-radius: 0;
50881
+ border: none;
50882
+ border-bottom: 1px solid var(--node-color);
50883
+ `;
50884
+ } else {
50885
+ if (els_child.length == 3) {
50886
+ height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
50887
+ el_bracket2.style.setProperty("height", `${height}px`);
50888
+ el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
50889
+ el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
50890
+ el_bracket2.style.setProperty("border-top", `0`);
50891
+ } else {
50892
+ heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
50893
+ el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
50894
+ el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
50895
+ }
50896
+ el_bracket2.style.setProperty("width", "20px");
50897
+ }
50898
+ }
50899
+ }
50900
+ }
50901
+ if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
50902
+ const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
50903
+ for (const root_el of root_el_list) {
50904
+ root_el.classList.add("js-waterfall");
50905
+ const list_children = root_el.querySelectorAll(".ab-items-item");
50906
+ const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
50907
+ let columnCount;
50908
+ if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
50909
+ columnCount = columnCountTmp;
50910
+ } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
50911
+ columnCount = list_children.length;
50912
+ root_el.classList.add("ab-col" + columnCount);
50913
+ } else {
50914
+ columnCount = 4;
50915
+ root_el.classList.add("ab-col" + columnCount);
50916
+ }
50917
+ const height_cache = [];
50918
+ const el_cache = [];
50919
+ for (let i = 0; i < columnCount; i++) {
50920
+ height_cache.push(0);
50921
+ el_cache.push([]);
50922
+ }
50923
+ for (const children2 of list_children) {
50924
+ const minValue = Math.min.apply(null, height_cache);
50925
+ const minIndex = height_cache.indexOf(minValue);
50926
+ const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
50927
+ height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
50928
+ el_cache[minIndex].push(children2);
50929
+ }
50930
+ const fillNumber = columnCount - list_children.length % columnCount;
50931
+ if (fillNumber != 4) {
50932
+ for (let i = 0; i < fillNumber; i++) {
50933
+ const children2 = document.createElement("div");
50934
+ children2.classList.add(".ab-items-item.placeholder");
50935
+ children2.setAttribute("style", "height: 20px");
50936
+ const minValue = Math.min.apply(null, height_cache);
50937
+ const minIndex = height_cache.indexOf(minValue);
50938
+ height_cache[minIndex] += 20;
50939
+ el_cache[minIndex].push(children2);
50940
+ }
50941
+ }
50942
+ root_el.innerHTML = "";
50943
+ for (let i = 0; i < columnCount; i++) {
50944
+ for (const j of el_cache[i]) {
50945
+ root_el.appendChild(j);
50946
+ }
50947
+ }
50948
+ }
50949
+ }
50950
+ if (!isCycle && d.querySelector(".ab-markmap-div")) {
50951
+ const divEl = d;
50952
+ let markmapId = "";
50953
+ if (divEl.tagName === "DIV") {
50954
+ markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
50955
+ }
50956
+ let mindmaps;
50957
+ if (markmapId) {
50958
+ mindmaps = document.querySelectorAll("#" + markmapId);
50959
+ } else {
50960
+ mindmaps = document.querySelectorAll(".ab-markmap-div");
50961
+ }
50962
+ for (const el_div of mindmaps) {
50963
+ const el_svg = el_div.querySelector("svg");
50964
+ const el_g = el_svg?.querySelector("g");
50965
+ if (el_svg && el_g) {
50966
+ const scale_new = el_g.getBBox().height / el_div.offsetWidth;
50967
+ el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
50968
+ ABCSetting.obsidian.markmap_event?.(d);
50969
+ }
50970
+ }
50971
+ }
50972
+ }
49713
50973
  exports.ABConvertManager = ABConvertManager;
49714
50974
  exports.ABReg = ABReg;
49715
50975
  exports.abConvertEvent = abConvertEvent;