markdown-it-any-block 3.4.4 → 3.5.0

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.
@@ -3,7 +3,10 @@ const ABCSetting = {
3
3
  env: "obsidian",
4
4
  // 某些环境的独占 api,其他环境用不上
5
5
  obsidian: {
6
- mermaid: void 0
6
+ global_app: null,
7
+ global_ctx: null,
8
+ mermaid: void 0,
9
+ markmap_event: void 0
7
10
  }
8
11
  };
9
12
  const ABReg = {
@@ -176,15 +179,39 @@ const ABAlias_json_withSub = [
176
179
  // 注意避免和原上/上面的callout语法冲突,以及自身递归
177
180
  ];
178
181
  const ABAlias_json_mdit = [
179
- { regex: /\|:::_140lne\|(2?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
182
+ { regex: /\|:::_140lne\|((?:mdit2|2)?tabs?|标签页?)\|/, replacement: "|mditTabs|" },
180
183
  { regex: "|:::_140lne|demo|", replacement: "|mditDemo|" },
181
184
  { regex: "|:::_140lne|abDemo|", replacement: "|mditABDemo|" },
182
- { regex: /\|:::_140lne\|(2?col|分栏)\|/, replacement: "|mditCol|" },
183
- { regex: /\|:::_140lne\|(2?card|卡片)\|/, replacement: "|mditCard|" },
184
- { regex: /\|:::_140lne\|(2?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" }
185
+ { regex: /\|:::_140lne\|((?:mdit2|2)?col|分栏)\|/, replacement: "|mditCol|" },
186
+ { regex: /\|:::_140lne\|((?:mdit2|2)?card|卡片)\|/, replacement: "|mditCard|" },
187
+ { regex: /\|:::_140lne\|((?:mdit2|2)?chat|聊天)\|/, replacement: "|mditChat|code(chat)|" },
188
+ //
189
+ // {regex: /\|:::_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|"},
190
+ // {regex: /\|:::_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|"},
191
+ // {regex: /\|:::_140lne\|2?(col|分栏)\||\|title2col\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-col)|"},
192
+ // {regex: /\|:::_140lne\|2?(card|卡片)\||\|title2card\|/, replacement: "|title2c2listdata|c2listdata2items|addClass(ab-card)|addClass(ab-lay-vfall)|"},
193
+ // {regex: /\|:::_140lne\|2?(nodes?|节点)\||\|(title2node|title2abMindmap)\|/, replacement: "|title2listdata|listdata2strict|listdata2nodes|"},
194
+ // list - 多叉多层树
195
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mermaid|flow|流程图)\|/, replacement: "|mdit2list|list2mermaid|" },
196
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(mehrmaid|mdmermaid)\|/, replacement: "|mdit2list|list2mehrmaidText|code(mehrmaid)|" },
197
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|mdit2list|list2pumlMindmap|" },
198
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|mdit2list|list2markmap|" },
199
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(wbs|(工作)?分解(图|结构))\|/, replacement: "|mdit2list|list2pumlWBS|" },
200
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|mdit2Listdata|listdata2strict|listdata2table|" },
201
+ // list - lt树 (属于多层一叉树)
202
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|mdit2list|list2lt|" },
203
+ { regex: /\|:::_140lne\|2?(list|列表)\|/, replacement: "|mdit2list|list2lt|addClass(ab-listtable-likelist)|" },
204
+ { regex: /\|:::_140lne\|(?:mdit2|2)?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|mdit2list|list2dt|" },
205
+ // list - 二层树
206
+ { regex: /\|:::_140lne\|(fakeList|仿列表)\|/, replacement: "|mdit2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
207
+ // 至后
208
+ { regex: "|mdit2list|", replacement: "|mdit2listdata|listdata2strict|listdata2list|" },
209
+ { regex: "|mdit2List|", replacement: "|mdit2Listdata|listdata2strict|listdata2list|" }
185
210
  ];
186
211
  const ABAlias_json_title = [
187
- { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" },
212
+ // 至前,特殊
213
+ { regex: "|heading2", replacement: "|title2" },
214
+ { regex: "|h2", replacement: "|title2" },
188
215
  // title - list&title
189
216
  { regex: /\|heading_140lne\|2?(timeline|时间线)\|/, replacement: "|title2timeline|" },
190
217
  { regex: /\|heading_140lne\|2?(tabs?|标签页?)\||\|title2tabs?\|/, replacement: "|title2c2listdata|c2listdata2tab|" },
@@ -197,13 +224,15 @@ const ABAlias_json_title = [
197
224
  { regex: /\|heading_140lne\|2?(puml)?(plantuml|mindmap|脑图|思维导图)\|/, replacement: "|title2list|list2pumlMindmap|" },
198
225
  { regex: /\|heading_140lne\|2?(markmap|mdMindmap|md脑图|md思维导图)\|/, replacement: "|title2list|list2markmap|" },
199
226
  { regex: /\|heading_140lne\|2?(wbs|(工作)?分解(图|结构))\|/, replacement: "|title2list|list2pumlWBS|" },
200
- { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2list|list2table|" },
227
+ { regex: /\|heading_140lne\|2?(table|multiWayTable|multiCrossTable|表格?|多叉表格?|跨行表格?)\|/, replacement: "|title2Listdata|listdata2strict|listdata2table|" },
201
228
  // list - lt树 (属于多层一叉树)
202
229
  { regex: /\|heading_140lne\|2?(lt|listTable|treeTable|listGrid|treeGrid|列表格|树形表格?)\|/, replacement: "|title2list|list2lt|" },
203
230
  { regex: /\|heading_140lne\|2?(list|列表)\|/, replacement: "|title2list|list2lt|addClass(ab-listtable-likelist)|" },
204
231
  { regex: /\|heading_140lne\|2?(dir|dirTree|目录树?|目录结构)\|/, replacement: "|title2list|list2dt|" },
205
232
  // list - 二层树
206
- { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" }
233
+ { regex: /\|heading_140lne\|(fakeList|仿列表)\|/, replacement: "|title2list|list2table|addClass(ab-table-fc)|addClass(ab-table-likelist)|" },
234
+ // 至后
235
+ { regex: "|title2list|", replacement: "|title2listdata|listdata2strict|listdata2list|" }
207
236
  ];
208
237
  const ABAlias_json_list = [
209
238
  // 特殊
@@ -360,24 +389,18 @@ class ABConvertManager {
360
389
  * @param header 转换方式
361
390
  * @param content 要转换的初始文本 (无前缀版本,前缀在选择器环节已经删除了)
362
391
  * @param selectorName 选择器名,空表示未知
363
- * @return 等于el,无用,后面可以删了
364
392
  */
365
393
  static autoABConvert(el, header, content, selectorName = "", ctx) {
366
- let prev_result = content;
367
- let prev_type = "string";
368
- let prev_type2 = ABConvert_IOEnum.text;
369
- let prev_processor;
370
394
  let prev2 = {
371
- // 组合在一起是为了引用传参
372
- prev_result,
373
- prev_type,
374
- prev_type2,
375
- prev_processor
395
+ prev_result: content,
396
+ prev_type: "string",
397
+ prev_type2: ABConvert_IOEnum.text,
398
+ prev_processor: void 0
376
399
  };
377
400
  {
378
- header = autoABAlias(header, selectorName, prev_result);
401
+ header = autoABAlias(header, selectorName, prev2.prev_result);
379
402
  let list_header = header.split("|");
380
- prev_result = this.autoABConvert_runConvert(el, list_header, prev2, ctx);
403
+ this.autoABConvert_runConvert(el, list_header, prev2, ctx);
381
404
  this.autoABConvert_last(el, header, selectorName, prev2, ctx);
382
405
  }
383
406
  }
@@ -436,7 +459,12 @@ class ABConvertManager {
436
459
  break;
437
460
  }
438
461
  }
439
- prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
462
+ try {
463
+ prev2.prev_result = abReplaceProcessor.process(el, item_header, prev2.prev_result, ctx);
464
+ } catch (e) {
465
+ console.error(`处理器执行错误, id:${abReplaceProcessor.id}, header:${item_header}, error:`, e);
466
+ break;
467
+ }
440
468
  prev2.prev_type = typeof prev2.prev_result;
441
469
  prev2.prev_type2 = abReplaceProcessor.process_return;
442
470
  prev2.prev_processor = abReplaceProcessor.process;
@@ -450,7 +478,7 @@ class ABConvertManager {
450
478
  /**
451
479
  * 子函数,后处理/尾处理,主要进行末尾追加指令
452
480
  */
453
- static autoABConvert_last(el, header, selectorName, prev2, ctx) {
481
+ static autoABConvert_last(el, _header, _selectorName, prev2, _ctx) {
454
482
  if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.text) {
455
483
  const subEl = document.createElement("div");
456
484
  el.appendChild(subEl);
@@ -458,7 +486,7 @@ class ABConvertManager {
458
486
  prev2.prev_result = el;
459
487
  prev2.prev_type = "object";
460
488
  prev2.prev_type2 = ABConvert_IOEnum.el;
461
- prev2.process = "md";
489
+ prev2.prev_processor = "md";
462
490
  } else if (prev2.prev_type == "string" && prev2.prev_type2 == ABConvert_IOEnum.json) {
463
491
  const code_str = "```json\n" + prev2.prev_result + "\n```\n";
464
492
  const subEl = document.createElement("div");
@@ -467,7 +495,7 @@ class ABConvertManager {
467
495
  prev2.prev_result = el;
468
496
  prev2.prev_type = "object";
469
497
  prev2.prev_type2 = ABConvert_IOEnum.el;
470
- prev2.process = "show_json";
498
+ prev2.prev_processor = "show_json";
471
499
  } 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)) {
472
500
  const code_str = "```json\n" + JSON.stringify(prev2.prev_result, null, 2) + "\n```\n";
473
501
  const subEl = document.createElement("div");
@@ -476,7 +504,7 @@ class ABConvertManager {
476
504
  prev2.prev_result = el;
477
505
  prev2.prev_type = "object";
478
506
  prev2.prev_type2 = ABConvert_IOEnum.el;
479
- prev2.process = "show_listStream";
507
+ prev2.prev_processor = "show_listStream";
480
508
  } else if (prev2.prev_type == "object" && prev2.prev_type2 == ABConvert_IOEnum.el) {
481
509
  return prev2;
482
510
  } else {
@@ -920,7 +948,7 @@ class ListProcess {
920
948
  }
921
949
  }
922
950
  /**
923
- * 标题大纲转列表数据(@todo 正文的level+10,要减掉)
951
+ * 标题大纲转列表数据
924
952
  *
925
953
  * @detail
926
954
  * 这里要将标题、正文、列表 的等级合为一块,所以存在偏移值:
@@ -929,8 +957,13 @@ class ListProcess {
929
957
  * 2. 正文等级, = 0, 取值[+1,+Infi]
930
958
  * 3. 列表等级, = `(.*)-`个数+1, 取值[0]
931
959
  *
960
+ * (比较旧版是正文+10,列表+11,后来允许标题等级为负数。这样方便很多)
961
+ *
962
+ * @fine_mode 精细拆分模式
963
+ * - true: 会将正文和列表拆分成多个节点
964
+ * - false: 会将标题+正文+列表合并成一个节点
932
965
  */
933
- static title2data(text2) {
966
+ static title2data(text2, fine_mode = true) {
934
967
  let list_itemInfo = [];
935
968
  const list_text = text2.split("\n");
936
969
  let mul_mode = "";
@@ -940,12 +973,23 @@ class ListProcess {
940
973
  const match2 = line.match(ABReg.reg_code);
941
974
  if (match2 && match2[3]) {
942
975
  codeBlockFlag = match2[1] + match2[3];
943
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
976
+ if (!fine_mode && list_itemInfo.length > 0) {
977
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
978
+ } else if (mul_mode === "heading" || mul_mode === "") {
979
+ removeTailBlank();
980
+ list_itemInfo.push({
981
+ content: line,
982
+ level: 0
983
+ });
984
+ mul_mode = "para";
985
+ } else {
986
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
987
+ }
944
988
  continue;
945
989
  }
946
990
  } else {
947
991
  if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
948
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
992
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
949
993
  continue;
950
994
  }
951
995
  const match_heading = line.match(ABReg.reg_heading_noprefix);
@@ -953,32 +997,133 @@ class ListProcess {
953
997
  if (match_heading && !match_heading[1]) {
954
998
  removeTailBlank();
955
999
  list_itemInfo.push({
956
- content: match_heading[4],
1000
+ content: fine_mode ? match_heading[4] : line,
1001
+ // 可选是否把标题标志也放进去
957
1002
  level: match_heading[3].length - 1 - 10
958
1003
  });
959
1004
  mul_mode = "heading";
1005
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1006
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1007
+ continue;
960
1008
  } else if (match_list) {
961
1009
  removeTailBlank();
962
1010
  list_itemInfo.push({
963
1011
  content: match_list[4],
964
1012
  level: match_list[1].length + 1
965
- //+10
966
1013
  });
967
1014
  mul_mode = "list";
968
- } else if (/^\S/.test(line) && mul_mode == "list") {
969
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1015
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1016
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1017
+ continue;
970
1018
  } else {
971
1019
  if (mul_mode == "para") {
972
- list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content + "\n" + line;
1020
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1021
+ continue;
973
1022
  } else if (/^\s*$/.test(line)) {
974
1023
  continue;
975
1024
  } else {
1025
+ removeTailBlank();
976
1026
  list_itemInfo.push({
977
1027
  content: line,
978
1028
  level: 0
979
- //+10
980
1029
  });
981
1030
  mul_mode = "para";
1031
+ continue;
1032
+ }
1033
+ }
1034
+ }
1035
+ removeTailBlank();
1036
+ return list_itemInfo;
1037
+ function removeTailBlank() {
1038
+ if (mul_mode == "para" || mul_mode == "list") {
1039
+ list_itemInfo[list_itemInfo.length - 1].content = list_itemInfo[list_itemInfo.length - 1].content.replace(/\s*$/, "");
1040
+ }
1041
+ }
1042
+ }
1043
+ /**
1044
+ * MarkdownIt 转列表数据
1045
+ *
1046
+ * @detail
1047
+ * 与 title2data 的逻辑基本相同
1048
+ *
1049
+ * 有很多写法变型和语法糖,所以逻辑比较复杂。
1050
+ * 具体设计详见 "docs/docs/dev docs/其他层级表示法.md"
1051
+ *
1052
+ * 支持:
1053
+ *
1054
+ * - 单行标题模式
1055
+ * - 多行标题模式
1056
+ * - 缺少分割标题模式
1057
+ *
1058
+ * @fine_mode 精细拆分模式
1059
+ * - true: 会将正文和列表拆分成多个节点
1060
+ * - false: 会将标题+正文+列表合并成一个节点
1061
+ */
1062
+ static mdit2data(text2, fine_mode = true) {
1063
+ let list_itemInfo = [];
1064
+ const list_text = text2.split("\n");
1065
+ let mul_mode = "";
1066
+ let codeBlockFlag = "";
1067
+ for (let line of list_text) {
1068
+ if (codeBlockFlag == "") {
1069
+ const match2 = line.match(ABReg.reg_code);
1070
+ if (match2 && match2[3]) {
1071
+ codeBlockFlag = match2[1] + match2[3];
1072
+ if (!fine_mode && list_itemInfo.length > 0) {
1073
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1074
+ } else if (mul_mode === "mdit" || mul_mode === "") {
1075
+ removeTailBlank();
1076
+ list_itemInfo.push({
1077
+ content: line,
1078
+ level: 0
1079
+ });
1080
+ mul_mode = "para";
1081
+ } else {
1082
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1083
+ }
1084
+ continue;
1085
+ }
1086
+ } else {
1087
+ if (line.indexOf(codeBlockFlag) == 0) codeBlockFlag = "";
1088
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1089
+ continue;
1090
+ }
1091
+ const match_mdit = line.match(/^(\s*)@(\d+)(?:\s+(.*))?$/);
1092
+ const match_list = line.match(ABReg.reg_list_noprefix);
1093
+ if (match_mdit && !match_mdit[1]) {
1094
+ removeTailBlank();
1095
+ list_itemInfo.push({
1096
+ content: match_mdit[3] ?? "",
1097
+ level: Number(match_mdit[2]) - 100
1098
+ });
1099
+ mul_mode = "mdit";
1100
+ } else if (!fine_mode && list_itemInfo.length > 0) {
1101
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1102
+ continue;
1103
+ } else if (match_list) {
1104
+ removeTailBlank();
1105
+ list_itemInfo.push({
1106
+ content: match_list[4],
1107
+ level: match_list[1].length + 1
1108
+ });
1109
+ mul_mode = "list";
1110
+ } else if (mul_mode == "list" && /^\s/.test(line)) {
1111
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line.trimStart();
1112
+ continue;
1113
+ } else {
1114
+ if (mul_mode == "para") {
1115
+ list_itemInfo[list_itemInfo.length - 1].content += "\n" + line;
1116
+ continue;
1117
+ } else if (/^\s*$/.test(line)) {
1118
+ continue;
1119
+ } else {
1120
+ removeTailBlank();
1121
+ list_itemInfo.push({
1122
+ content: line,
1123
+ level: 0
1124
+ });
1125
+ mul_mode = "para";
1126
+ continue;
982
1127
  }
983
1128
  }
984
1129
  }
@@ -1197,7 +1342,7 @@ const abc_list2listdata = ABConvert.factory({
1197
1342
  process_param: ABConvert_IOEnum.text,
1198
1343
  process_return: ABConvert_IOEnum.list_stream,
1199
1344
  detail: "列表到listdata",
1200
- process: (el, header, content) => {
1345
+ process: (_el, _header, content) => {
1201
1346
  return ListProcess.list2data(content);
1202
1347
  }
1203
1348
  });
@@ -1206,9 +1351,39 @@ const abc_title2listdata = ABConvert.factory({
1206
1351
  name: "标题到listdata",
1207
1352
  process_param: ABConvert_IOEnum.text,
1208
1353
  process_return: ABConvert_IOEnum.list_stream,
1209
- detail: "标题到listdata",
1210
- process: (el, header, content) => {
1211
- return ListProcess.title2data(content);
1354
+ detail: "标题到listdata。细粒度版本,列表会拆分成多个节点",
1355
+ process: (_el, _header, content) => {
1356
+ return ListProcess.title2data(content, true);
1357
+ }
1358
+ });
1359
+ ABConvert.factory({
1360
+ id: "title2Listdata",
1361
+ name: "标题到Listdata",
1362
+ process_param: ABConvert_IOEnum.text,
1363
+ process_return: ABConvert_IOEnum.list_stream,
1364
+ detail: "标题到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1365
+ process: (_el, _header, content) => {
1366
+ return ListProcess.title2data(content, false);
1367
+ }
1368
+ });
1369
+ ABConvert.factory({
1370
+ id: "mdit2listdata",
1371
+ name: "mdit到listdata",
1372
+ process_param: ABConvert_IOEnum.text,
1373
+ process_return: ABConvert_IOEnum.list_stream,
1374
+ detail: "mdit到listdata。细粒度版本,列表会拆分成多个节点",
1375
+ process: (_el, _header, content) => {
1376
+ return ListProcess.mdit2data(content, true);
1377
+ }
1378
+ });
1379
+ ABConvert.factory({
1380
+ id: "mdit2Listdata",
1381
+ name: "mdit到Listdata",
1382
+ process_param: ABConvert_IOEnum.text,
1383
+ process_return: ABConvert_IOEnum.list_stream,
1384
+ detail: "mdit到Listdata。粗粒度版本,列表为一个节点,不会拆分",
1385
+ process: (_el, _header, content) => {
1386
+ return ListProcess.mdit2data(content, false);
1212
1387
  }
1213
1388
  });
1214
1389
  ABConvert.factory({
@@ -1217,7 +1392,7 @@ ABConvert.factory({
1217
1392
  process_param: ABConvert_IOEnum.list_stream,
1218
1393
  process_return: ABConvert_IOEnum.text,
1219
1394
  detail: "listdata到列表",
1220
- process: (el, header, content) => {
1395
+ process: (_el, _header, content) => {
1221
1396
  return ListProcess.data2list(content);
1222
1397
  }
1223
1398
  });
@@ -1227,17 +1402,18 @@ ABConvert.factory({
1227
1402
  process_param: ABConvert_IOEnum.list_stream,
1228
1403
  process_return: ABConvert_IOEnum.el,
1229
1404
  detail: "listdata到节点图",
1230
- process: (el, header, content) => {
1405
+ process: (el, _header, content) => {
1231
1406
  return ListProcess.data2nodes(content, el);
1232
1407
  }
1233
1408
  });
1234
1409
  ABConvert.factory({
1235
1410
  id: "listdata2strict",
1236
1411
  name: "listdata严格化",
1412
+ match: /listdata2strict|listdata2lint/,
1237
1413
  process_param: ABConvert_IOEnum.list_stream,
1238
1414
  process_return: ABConvert_IOEnum.list_stream,
1239
1415
  detail: "将列表数据转化为更规范的列表数据。统一缩进符(2空格 4空格 tab混用)为level 1、禁止跳等级(h1直接就到h3)",
1240
- process: (el, header, content) => {
1416
+ process: (_el, _header, content) => {
1241
1417
  return ListProcess.data2strict(content);
1242
1418
  }
1243
1419
  });
@@ -1247,7 +1423,7 @@ ABConvert.factory({
1247
1423
  process_param: ABConvert_IOEnum.list_stream,
1248
1424
  process_return: ABConvert_IOEnum.list_stream,
1249
1425
  detail: "当列表中存在任务列表项时,令此列表项支持任务项",
1250
- process: (el, header, content) => {
1426
+ process: (_el, _header, content) => {
1251
1427
  return ListProcess.data2taskData(content);
1252
1428
  }
1253
1429
  });
@@ -1257,7 +1433,7 @@ ABConvert.factory({
1257
1433
  process_param: ABConvert_IOEnum.text,
1258
1434
  process_return: ABConvert_IOEnum.json,
1259
1435
  detail: "列表到listnode",
1260
- process: (el, header, content) => {
1436
+ process: (_el, _header, content) => {
1261
1437
  const data2 = ListProcess.list2listnode(content);
1262
1438
  return JSON.stringify(data2, null, 2);
1263
1439
  }
@@ -1268,7 +1444,7 @@ ABConvert.factory({
1268
1444
  process_param: ABConvert_IOEnum.text,
1269
1445
  process_return: ABConvert_IOEnum.json,
1270
1446
  detail: "列表到json",
1271
- process: (el, header, content) => {
1447
+ process: (_el, _header, content) => {
1272
1448
  const data2 = ListProcess.list2json(content);
1273
1449
  return JSON.stringify(data2, null, 2);
1274
1450
  }
@@ -1781,6 +1957,19 @@ ABConvert.factory({
1781
1957
  return el = TableProcess.data2table(data2, el, matchs[2] == "T");
1782
1958
  }
1783
1959
  });
1960
+ ABConvert.factory({
1961
+ id: "listdata2table",
1962
+ name: "列表数据转表格",
1963
+ match: /listdata2(md)?table(T)?/,
1964
+ default: "listdata2table",
1965
+ process_param: ABConvert_IOEnum.list_stream,
1966
+ process_return: ABConvert_IOEnum.el,
1967
+ process: (el, header, content) => {
1968
+ const matchs = header.match(/listdata2(md)?table(T)?/);
1969
+ if (!matchs) return el;
1970
+ return el = TableProcess.data2table(content, el, matchs[2] == "T");
1971
+ }
1972
+ });
1784
1973
  ABConvert.factory({
1785
1974
  id: "list2c2t",
1786
1975
  name: "列表转二列表格",
@@ -2206,6 +2395,1086 @@ ABConvert.factory({
2206
2395
  return newContent;
2207
2396
  }
2208
2397
  });
2398
+ /*! @license DOMPurify 3.4.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.3/LICENSE */
2399
+ function _arrayLikeToArray(r, a) {
2400
+ (null == a || a > r.length) && (a = r.length);
2401
+ for (var e = 0, n2 = Array(a); e < a; e++) n2[e] = r[e];
2402
+ return n2;
2403
+ }
2404
+ function _arrayWithHoles(r) {
2405
+ if (Array.isArray(r)) return r;
2406
+ }
2407
+ function _iterableToArrayLimit(r, l2) {
2408
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2409
+ if (null != t) {
2410
+ var e, n2, i, u, a = [], f = true, o = false;
2411
+ try {
2412
+ if (i = (t = t.call(r)).next, 0 === l2) ;
2413
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l2); f = true) ;
2414
+ } catch (r2) {
2415
+ o = true, n2 = r2;
2416
+ } finally {
2417
+ try {
2418
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
2419
+ } finally {
2420
+ if (o) throw n2;
2421
+ }
2422
+ }
2423
+ return a;
2424
+ }
2425
+ }
2426
+ function _nonIterableRest() {
2427
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2428
+ }
2429
+ function _slicedToArray(r, e) {
2430
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
2431
+ }
2432
+ function _unsupportedIterableToArray(r, a) {
2433
+ if (r) {
2434
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
2435
+ var t = {}.toString.call(r).slice(8, -1);
2436
+ 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;
2437
+ }
2438
+ }
2439
+ const entries = Object.entries, setPrototypeOf = Object.setPrototypeOf, isFrozen = Object.isFrozen, getPrototypeOf = Object.getPrototypeOf, getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2440
+ let freeze = Object.freeze, seal = Object.seal, create = Object.create;
2441
+ let _ref = typeof Reflect !== "undefined" && Reflect, apply = _ref.apply, construct = _ref.construct;
2442
+ if (!freeze) {
2443
+ freeze = function freeze2(x) {
2444
+ return x;
2445
+ };
2446
+ }
2447
+ if (!seal) {
2448
+ seal = function seal2(x) {
2449
+ return x;
2450
+ };
2451
+ }
2452
+ if (!apply) {
2453
+ apply = function apply2(func, thisArg) {
2454
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
2455
+ args[_key - 2] = arguments[_key];
2456
+ }
2457
+ return func.apply(thisArg, args);
2458
+ };
2459
+ }
2460
+ if (!construct) {
2461
+ construct = function construct2(Func) {
2462
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2463
+ args[_key2 - 1] = arguments[_key2];
2464
+ }
2465
+ return new Func(...args);
2466
+ };
2467
+ }
2468
+ const arrayForEach = unapply(Array.prototype.forEach);
2469
+ const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);
2470
+ const arrayPop = unapply(Array.prototype.pop);
2471
+ const arrayPush = unapply(Array.prototype.push);
2472
+ const arraySplice = unapply(Array.prototype.splice);
2473
+ const arrayIsArray = Array.isArray;
2474
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
2475
+ const stringToString = unapply(String.prototype.toString);
2476
+ const stringMatch = unapply(String.prototype.match);
2477
+ const stringReplace = unapply(String.prototype.replace);
2478
+ const stringIndexOf = unapply(String.prototype.indexOf);
2479
+ const stringTrim = unapply(String.prototype.trim);
2480
+ const numberToString = unapply(Number.prototype.toString);
2481
+ const booleanToString = unapply(Boolean.prototype.toString);
2482
+ const bigintToString = typeof BigInt === "undefined" ? null : unapply(BigInt.prototype.toString);
2483
+ const symbolToString = typeof Symbol === "undefined" ? null : unapply(Symbol.prototype.toString);
2484
+ const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);
2485
+ const objectToString = unapply(Object.prototype.toString);
2486
+ const regExpTest = unapply(RegExp.prototype.test);
2487
+ const typeErrorCreate = unconstruct(TypeError);
2488
+ function unapply(func) {
2489
+ return function(thisArg) {
2490
+ if (thisArg instanceof RegExp) {
2491
+ thisArg.lastIndex = 0;
2492
+ }
2493
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2494
+ args[_key3 - 1] = arguments[_key3];
2495
+ }
2496
+ return apply(func, thisArg, args);
2497
+ };
2498
+ }
2499
+ function unconstruct(Func) {
2500
+ return function() {
2501
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2502
+ args[_key4] = arguments[_key4];
2503
+ }
2504
+ return construct(Func, args);
2505
+ };
2506
+ }
2507
+ function addToSet(set2, array) {
2508
+ let transformCaseFunc = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : stringToLowerCase;
2509
+ if (setPrototypeOf) {
2510
+ setPrototypeOf(set2, null);
2511
+ }
2512
+ if (!arrayIsArray(array)) {
2513
+ return set2;
2514
+ }
2515
+ let l2 = array.length;
2516
+ while (l2--) {
2517
+ let element = array[l2];
2518
+ if (typeof element === "string") {
2519
+ const lcElement = transformCaseFunc(element);
2520
+ if (lcElement !== element) {
2521
+ if (!isFrozen(array)) {
2522
+ array[l2] = lcElement;
2523
+ }
2524
+ element = lcElement;
2525
+ }
2526
+ }
2527
+ set2[element] = true;
2528
+ }
2529
+ return set2;
2530
+ }
2531
+ function cleanArray(array) {
2532
+ for (let index2 = 0; index2 < array.length; index2++) {
2533
+ const isPropertyExist = objectHasOwnProperty(array, index2);
2534
+ if (!isPropertyExist) {
2535
+ array[index2] = null;
2536
+ }
2537
+ }
2538
+ return array;
2539
+ }
2540
+ function clone$3(object) {
2541
+ const newObject = create(null);
2542
+ for (const _ref2 of entries(object)) {
2543
+ var _ref3 = _slicedToArray(_ref2, 2);
2544
+ const property = _ref3[0];
2545
+ const value = _ref3[1];
2546
+ const isPropertyExist = objectHasOwnProperty(object, property);
2547
+ if (isPropertyExist) {
2548
+ if (arrayIsArray(value)) {
2549
+ newObject[property] = cleanArray(value);
2550
+ } else if (value && typeof value === "object" && value.constructor === Object) {
2551
+ newObject[property] = clone$3(value);
2552
+ } else {
2553
+ newObject[property] = value;
2554
+ }
2555
+ }
2556
+ }
2557
+ return newObject;
2558
+ }
2559
+ function stringifyValue(value) {
2560
+ switch (typeof value) {
2561
+ case "string": {
2562
+ return value;
2563
+ }
2564
+ case "number": {
2565
+ return numberToString(value);
2566
+ }
2567
+ case "boolean": {
2568
+ return booleanToString(value);
2569
+ }
2570
+ case "bigint": {
2571
+ return bigintToString ? bigintToString(value) : "0";
2572
+ }
2573
+ case "symbol": {
2574
+ return symbolToString ? symbolToString(value) : "Symbol()";
2575
+ }
2576
+ case "undefined": {
2577
+ return objectToString(value);
2578
+ }
2579
+ case "function":
2580
+ case "object": {
2581
+ if (value === null) {
2582
+ return objectToString(value);
2583
+ }
2584
+ const valueAsRecord = value;
2585
+ const valueToString = lookupGetter(valueAsRecord, "toString");
2586
+ if (typeof valueToString === "function") {
2587
+ const stringified = valueToString(valueAsRecord);
2588
+ return typeof stringified === "string" ? stringified : objectToString(stringified);
2589
+ }
2590
+ return objectToString(value);
2591
+ }
2592
+ default: {
2593
+ return objectToString(value);
2594
+ }
2595
+ }
2596
+ }
2597
+ function lookupGetter(object, prop2) {
2598
+ while (object !== null) {
2599
+ const desc = getOwnPropertyDescriptor(object, prop2);
2600
+ if (desc) {
2601
+ if (desc.get) {
2602
+ return unapply(desc.get);
2603
+ }
2604
+ if (typeof desc.value === "function") {
2605
+ return unapply(desc.value);
2606
+ }
2607
+ }
2608
+ object = getPrototypeOf(object);
2609
+ }
2610
+ function fallbackValue() {
2611
+ return null;
2612
+ }
2613
+ return fallbackValue;
2614
+ }
2615
+ function isRegex(value) {
2616
+ try {
2617
+ regExpTest(value, "");
2618
+ return true;
2619
+ } catch (_unused) {
2620
+ return false;
2621
+ }
2622
+ }
2623
+ 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"]);
2624
+ 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"]);
2625
+ 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"]);
2626
+ 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"]);
2627
+ 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"]);
2628
+ const mathMlDisallowed = freeze(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]);
2629
+ const text$2 = freeze(["#text"]);
2630
+ 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"]);
2631
+ 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"]);
2632
+ 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"]);
2633
+ const xml$1 = freeze(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]);
2634
+ const MUSTACHE_EXPR = seal(/{{[\w\W]*|^[\w\W]*}}/g);
2635
+ const ERB_EXPR = seal(/<%[\w\W]*|^[\w\W]*%>/g);
2636
+ const TMPLIT_EXPR = seal(/\${[\w\W]*/g);
2637
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/);
2638
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/);
2639
+ const IS_ALLOWED_URI = seal(
2640
+ /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i
2641
+ // eslint-disable-line no-useless-escape
2642
+ );
2643
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
2644
+ const ATTR_WHITESPACE = seal(
2645
+ /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g
2646
+ // eslint-disable-line no-control-regex
2647
+ );
2648
+ const DOCTYPE_NAME = seal(/^html$/i);
2649
+ const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i);
2650
+ const NODE_TYPE$1 = {
2651
+ element: 1,
2652
+ text: 3,
2653
+ // Deprecated
2654
+ progressingInstruction: 7,
2655
+ comment: 8,
2656
+ document: 9
2657
+ };
2658
+ const getGlobal = function getGlobal2() {
2659
+ return typeof window === "undefined" ? null : window;
2660
+ };
2661
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy2(trustedTypes, purifyHostElement) {
2662
+ if (typeof trustedTypes !== "object" || typeof trustedTypes.createPolicy !== "function") {
2663
+ return null;
2664
+ }
2665
+ let suffix = null;
2666
+ const ATTR_NAME = "data-tt-policy-suffix";
2667
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
2668
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
2669
+ }
2670
+ const policyName = "dompurify" + (suffix ? "#" + suffix : "");
2671
+ try {
2672
+ return trustedTypes.createPolicy(policyName, {
2673
+ createHTML(html2) {
2674
+ return html2;
2675
+ },
2676
+ createScriptURL(scriptUrl) {
2677
+ return scriptUrl;
2678
+ }
2679
+ });
2680
+ } catch (_) {
2681
+ console.warn("TrustedTypes policy " + policyName + " could not be created.");
2682
+ return null;
2683
+ }
2684
+ };
2685
+ const _createHooksMap = function _createHooksMap2() {
2686
+ return {
2687
+ afterSanitizeAttributes: [],
2688
+ afterSanitizeElements: [],
2689
+ afterSanitizeShadowDOM: [],
2690
+ beforeSanitizeAttributes: [],
2691
+ beforeSanitizeElements: [],
2692
+ beforeSanitizeShadowDOM: [],
2693
+ uponSanitizeAttribute: [],
2694
+ uponSanitizeElement: [],
2695
+ uponSanitizeShadowNode: []
2696
+ };
2697
+ };
2698
+ function createDOMPurify() {
2699
+ let window2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : getGlobal();
2700
+ const DOMPurify = (root2) => createDOMPurify(root2);
2701
+ DOMPurify.version = "3.4.3";
2702
+ DOMPurify.removed = [];
2703
+ if (!window2 || !window2.document || window2.document.nodeType !== NODE_TYPE$1.document || !window2.Element) {
2704
+ DOMPurify.isSupported = false;
2705
+ return DOMPurify;
2706
+ }
2707
+ let document2 = window2.document;
2708
+ const originalDocument = document2;
2709
+ const currentScript = originalDocument.currentScript;
2710
+ 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;
2711
+ const ElementPrototype = Element2.prototype;
2712
+ const cloneNode2 = lookupGetter(ElementPrototype, "cloneNode");
2713
+ const remove2 = lookupGetter(ElementPrototype, "remove");
2714
+ const getNextSibling = lookupGetter(ElementPrototype, "nextSibling");
2715
+ const getChildNodes = lookupGetter(ElementPrototype, "childNodes");
2716
+ const getParentNode = lookupGetter(ElementPrototype, "parentNode");
2717
+ if (typeof HTMLTemplateElement === "function") {
2718
+ const template = document2.createElement("template");
2719
+ if (template.content && template.content.ownerDocument) {
2720
+ document2 = template.content.ownerDocument;
2721
+ }
2722
+ }
2723
+ let trustedTypesPolicy;
2724
+ let emptyHTML = "";
2725
+ const _document = document2, implementation = _document.implementation, createNodeIterator = _document.createNodeIterator, createDocumentFragment = _document.createDocumentFragment, getElementsByTagName2 = _document.getElementsByTagName;
2726
+ const importNode = originalDocument.importNode;
2727
+ let hooks = _createHooksMap();
2728
+ DOMPurify.isSupported = typeof entries === "function" && typeof getParentNode === "function" && implementation && implementation.createHTMLDocument !== void 0;
2729
+ 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;
2730
+ let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;
2731
+ let ALLOWED_TAGS = null;
2732
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text$2]);
2733
+ let ALLOWED_ATTR = null;
2734
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html$2, ...svg, ...mathMl, ...xml$1]);
2735
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {
2736
+ tagNameCheck: {
2737
+ writable: true,
2738
+ configurable: false,
2739
+ enumerable: true,
2740
+ value: null
2741
+ },
2742
+ attributeNameCheck: {
2743
+ writable: true,
2744
+ configurable: false,
2745
+ enumerable: true,
2746
+ value: null
2747
+ },
2748
+ allowCustomizedBuiltInElements: {
2749
+ writable: true,
2750
+ configurable: false,
2751
+ enumerable: true,
2752
+ value: false
2753
+ }
2754
+ }));
2755
+ let FORBID_TAGS = null;
2756
+ let FORBID_ATTR = null;
2757
+ const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {
2758
+ tagCheck: {
2759
+ writable: true,
2760
+ configurable: false,
2761
+ enumerable: true,
2762
+ value: null
2763
+ },
2764
+ attributeCheck: {
2765
+ writable: true,
2766
+ configurable: false,
2767
+ enumerable: true,
2768
+ value: null
2769
+ }
2770
+ }));
2771
+ let ALLOW_ARIA_ATTR = true;
2772
+ let ALLOW_DATA_ATTR = true;
2773
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
2774
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
2775
+ let SAFE_FOR_TEMPLATES = false;
2776
+ let SAFE_FOR_XML = true;
2777
+ let WHOLE_DOCUMENT = false;
2778
+ let SET_CONFIG = false;
2779
+ let FORCE_BODY = false;
2780
+ let RETURN_DOM = false;
2781
+ let RETURN_DOM_FRAGMENT = false;
2782
+ let RETURN_TRUSTED_TYPE = false;
2783
+ let SANITIZE_DOM = true;
2784
+ let SANITIZE_NAMED_PROPS = false;
2785
+ const SANITIZE_NAMED_PROPS_PREFIX = "user-content-";
2786
+ let KEEP_CONTENT = true;
2787
+ let IN_PLACE = false;
2788
+ let USE_PROFILES = {};
2789
+ let FORBID_CONTENTS = null;
2790
+ 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"]);
2791
+ let DATA_URI_TAGS = null;
2792
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ["audio", "video", "img", "source", "image", "track"]);
2793
+ let URI_SAFE_ATTRIBUTES = null;
2794
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]);
2795
+ const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
2796
+ const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
2797
+ const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
2798
+ let NAMESPACE = HTML_NAMESPACE;
2799
+ let IS_EMPTY_INPUT = false;
2800
+ let ALLOWED_NAMESPACES = null;
2801
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
2802
+ let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ["mi", "mo", "mn", "ms", "mtext"]);
2803
+ let HTML_INTEGRATION_POINTS = addToSet({}, ["annotation-xml"]);
2804
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ["title", "style", "font", "a", "script"]);
2805
+ let PARSER_MEDIA_TYPE = null;
2806
+ const SUPPORTED_PARSER_MEDIA_TYPES = ["application/xhtml+xml", "text/html"];
2807
+ const DEFAULT_PARSER_MEDIA_TYPE = "text/html";
2808
+ let transformCaseFunc = null;
2809
+ let CONFIG = null;
2810
+ const formElement = document2.createElement("form");
2811
+ const isRegexOrFunction = function isRegexOrFunction2(testValue) {
2812
+ return testValue instanceof RegExp || testValue instanceof Function;
2813
+ };
2814
+ const _parseConfig = function _parseConfig2() {
2815
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2816
+ if (CONFIG && CONFIG === cfg) {
2817
+ return;
2818
+ }
2819
+ if (!cfg || typeof cfg !== "object") {
2820
+ cfg = {};
2821
+ }
2822
+ cfg = clone$3(cfg);
2823
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
2824
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;
2825
+ transformCaseFunc = PARSER_MEDIA_TYPE === "application/xhtml+xml" ? stringToString : stringToLowerCase;
2826
+ ALLOWED_TAGS = objectHasOwnProperty(cfg, "ALLOWED_TAGS") && arrayIsArray(cfg.ALLOWED_TAGS) ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
2827
+ ALLOWED_ATTR = objectHasOwnProperty(cfg, "ALLOWED_ATTR") && arrayIsArray(cfg.ALLOWED_ATTR) ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
2828
+ ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, "ALLOWED_NAMESPACES") && arrayIsArray(cfg.ALLOWED_NAMESPACES) ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
2829
+ 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;
2830
+ 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;
2831
+ FORBID_CONTENTS = objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS) ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
2832
+ FORBID_TAGS = objectHasOwnProperty(cfg, "FORBID_TAGS") && arrayIsArray(cfg.FORBID_TAGS) ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone$3({});
2833
+ FORBID_ATTR = objectHasOwnProperty(cfg, "FORBID_ATTR") && arrayIsArray(cfg.FORBID_ATTR) ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone$3({});
2834
+ USE_PROFILES = objectHasOwnProperty(cfg, "USE_PROFILES") ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === "object" ? clone$3(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;
2835
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false;
2836
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false;
2837
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false;
2838
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false;
2839
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false;
2840
+ SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false;
2841
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false;
2842
+ RETURN_DOM = cfg.RETURN_DOM || false;
2843
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false;
2844
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false;
2845
+ FORCE_BODY = cfg.FORCE_BODY || false;
2846
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false;
2847
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false;
2848
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false;
2849
+ IN_PLACE = cfg.IN_PLACE || false;
2850
+ IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI;
2851
+ NAMESPACE = typeof cfg.NAMESPACE === "string" ? cfg.NAMESPACE : HTML_NAMESPACE;
2852
+ 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"]);
2853
+ 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"]);
2854
+ 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);
2855
+ CUSTOM_ELEMENT_HANDLING = create(null);
2856
+ if (objectHasOwnProperty(customElementHandling, "tagNameCheck") && isRegexOrFunction(customElementHandling.tagNameCheck)) {
2857
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck;
2858
+ }
2859
+ if (objectHasOwnProperty(customElementHandling, "attributeNameCheck") && isRegexOrFunction(customElementHandling.attributeNameCheck)) {
2860
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck;
2861
+ }
2862
+ if (objectHasOwnProperty(customElementHandling, "allowCustomizedBuiltInElements") && typeof customElementHandling.allowCustomizedBuiltInElements === "boolean") {
2863
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements;
2864
+ }
2865
+ if (SAFE_FOR_TEMPLATES) {
2866
+ ALLOW_DATA_ATTR = false;
2867
+ }
2868
+ if (RETURN_DOM_FRAGMENT) {
2869
+ RETURN_DOM = true;
2870
+ }
2871
+ if (USE_PROFILES) {
2872
+ ALLOWED_TAGS = addToSet({}, text$2);
2873
+ ALLOWED_ATTR = create(null);
2874
+ if (USE_PROFILES.html === true) {
2875
+ addToSet(ALLOWED_TAGS, html$1$1);
2876
+ addToSet(ALLOWED_ATTR, html$2);
2877
+ }
2878
+ if (USE_PROFILES.svg === true) {
2879
+ addToSet(ALLOWED_TAGS, svg$1);
2880
+ addToSet(ALLOWED_ATTR, svg);
2881
+ addToSet(ALLOWED_ATTR, xml$1);
2882
+ }
2883
+ if (USE_PROFILES.svgFilters === true) {
2884
+ addToSet(ALLOWED_TAGS, svgFilters);
2885
+ addToSet(ALLOWED_ATTR, svg);
2886
+ addToSet(ALLOWED_ATTR, xml$1);
2887
+ }
2888
+ if (USE_PROFILES.mathMl === true) {
2889
+ addToSet(ALLOWED_TAGS, mathMl$1);
2890
+ addToSet(ALLOWED_ATTR, mathMl);
2891
+ addToSet(ALLOWED_ATTR, xml$1);
2892
+ }
2893
+ }
2894
+ EXTRA_ELEMENT_HANDLING.tagCheck = null;
2895
+ EXTRA_ELEMENT_HANDLING.attributeCheck = null;
2896
+ if (objectHasOwnProperty(cfg, "ADD_TAGS")) {
2897
+ if (typeof cfg.ADD_TAGS === "function") {
2898
+ EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;
2899
+ } else if (arrayIsArray(cfg.ADD_TAGS)) {
2900
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
2901
+ ALLOWED_TAGS = clone$3(ALLOWED_TAGS);
2902
+ }
2903
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
2904
+ }
2905
+ }
2906
+ if (objectHasOwnProperty(cfg, "ADD_ATTR")) {
2907
+ if (typeof cfg.ADD_ATTR === "function") {
2908
+ EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;
2909
+ } else if (arrayIsArray(cfg.ADD_ATTR)) {
2910
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
2911
+ ALLOWED_ATTR = clone$3(ALLOWED_ATTR);
2912
+ }
2913
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
2914
+ }
2915
+ }
2916
+ if (objectHasOwnProperty(cfg, "ADD_URI_SAFE_ATTR") && arrayIsArray(cfg.ADD_URI_SAFE_ATTR)) {
2917
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
2918
+ }
2919
+ if (objectHasOwnProperty(cfg, "FORBID_CONTENTS") && arrayIsArray(cfg.FORBID_CONTENTS)) {
2920
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2921
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
2922
+ }
2923
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
2924
+ }
2925
+ if (objectHasOwnProperty(cfg, "ADD_FORBID_CONTENTS") && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {
2926
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
2927
+ FORBID_CONTENTS = clone$3(FORBID_CONTENTS);
2928
+ }
2929
+ addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);
2930
+ }
2931
+ if (KEEP_CONTENT) {
2932
+ ALLOWED_TAGS["#text"] = true;
2933
+ }
2934
+ if (WHOLE_DOCUMENT) {
2935
+ addToSet(ALLOWED_TAGS, ["html", "head", "body"]);
2936
+ }
2937
+ if (ALLOWED_TAGS.table) {
2938
+ addToSet(ALLOWED_TAGS, ["tbody"]);
2939
+ delete FORBID_TAGS.tbody;
2940
+ }
2941
+ if (cfg.TRUSTED_TYPES_POLICY) {
2942
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== "function") {
2943
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
2944
+ }
2945
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== "function") {
2946
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
2947
+ }
2948
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;
2949
+ emptyHTML = trustedTypesPolicy.createHTML("");
2950
+ } else {
2951
+ if (trustedTypesPolicy === void 0) {
2952
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
2953
+ }
2954
+ if (trustedTypesPolicy !== null && typeof emptyHTML === "string") {
2955
+ emptyHTML = trustedTypesPolicy.createHTML("");
2956
+ }
2957
+ }
2958
+ if (freeze) {
2959
+ freeze(cfg);
2960
+ }
2961
+ CONFIG = cfg;
2962
+ };
2963
+ const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);
2964
+ const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);
2965
+ const _checkValidNamespace = function _checkValidNamespace2(element) {
2966
+ let parent2 = getParentNode(element);
2967
+ if (!parent2 || !parent2.tagName) {
2968
+ parent2 = {
2969
+ namespaceURI: NAMESPACE,
2970
+ tagName: "template"
2971
+ };
2972
+ }
2973
+ const tagName = stringToLowerCase(element.tagName);
2974
+ const parentTagName = stringToLowerCase(parent2.tagName);
2975
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
2976
+ return false;
2977
+ }
2978
+ if (element.namespaceURI === SVG_NAMESPACE) {
2979
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
2980
+ return tagName === "svg";
2981
+ }
2982
+ if (parent2.namespaceURI === MATHML_NAMESPACE) {
2983
+ return tagName === "svg" && (parentTagName === "annotation-xml" || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
2984
+ }
2985
+ return Boolean(ALL_SVG_TAGS[tagName]);
2986
+ }
2987
+ if (element.namespaceURI === MATHML_NAMESPACE) {
2988
+ if (parent2.namespaceURI === HTML_NAMESPACE) {
2989
+ return tagName === "math";
2990
+ }
2991
+ if (parent2.namespaceURI === SVG_NAMESPACE) {
2992
+ return tagName === "math" && HTML_INTEGRATION_POINTS[parentTagName];
2993
+ }
2994
+ return Boolean(ALL_MATHML_TAGS[tagName]);
2995
+ }
2996
+ if (element.namespaceURI === HTML_NAMESPACE) {
2997
+ if (parent2.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
2998
+ return false;
2999
+ }
3000
+ if (parent2.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
3001
+ return false;
3002
+ }
3003
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
3004
+ }
3005
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && ALLOWED_NAMESPACES[element.namespaceURI]) {
3006
+ return true;
3007
+ }
3008
+ return false;
3009
+ };
3010
+ const _forceRemove = function _forceRemove2(node) {
3011
+ arrayPush(DOMPurify.removed, {
3012
+ element: node
3013
+ });
3014
+ try {
3015
+ getParentNode(node).removeChild(node);
3016
+ } catch (_) {
3017
+ remove2(node);
3018
+ }
3019
+ };
3020
+ const _removeAttribute = function _removeAttribute2(name2, element) {
3021
+ try {
3022
+ arrayPush(DOMPurify.removed, {
3023
+ attribute: element.getAttributeNode(name2),
3024
+ from: element
3025
+ });
3026
+ } catch (_) {
3027
+ arrayPush(DOMPurify.removed, {
3028
+ attribute: null,
3029
+ from: element
3030
+ });
3031
+ }
3032
+ element.removeAttribute(name2);
3033
+ if (name2 === "is") {
3034
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
3035
+ try {
3036
+ _forceRemove(element);
3037
+ } catch (_) {
3038
+ }
3039
+ } else {
3040
+ try {
3041
+ element.setAttribute(name2, "");
3042
+ } catch (_) {
3043
+ }
3044
+ }
3045
+ }
3046
+ };
3047
+ const _initDocument = function _initDocument2(dirty) {
3048
+ let doc = null;
3049
+ let leadingWhitespace = null;
3050
+ if (FORCE_BODY) {
3051
+ dirty = "<remove></remove>" + dirty;
3052
+ } else {
3053
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
3054
+ leadingWhitespace = matches && matches[0];
3055
+ }
3056
+ if (PARSER_MEDIA_TYPE === "application/xhtml+xml" && NAMESPACE === HTML_NAMESPACE) {
3057
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + "</body></html>";
3058
+ }
3059
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
3060
+ if (NAMESPACE === HTML_NAMESPACE) {
3061
+ try {
3062
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
3063
+ } catch (_) {
3064
+ }
3065
+ }
3066
+ if (!doc || !doc.documentElement) {
3067
+ doc = implementation.createDocument(NAMESPACE, "template", null);
3068
+ try {
3069
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
3070
+ } catch (_) {
3071
+ }
3072
+ }
3073
+ const body = doc.body || doc.documentElement;
3074
+ if (dirty && leadingWhitespace) {
3075
+ body.insertBefore(document2.createTextNode(leadingWhitespace), body.childNodes[0] || null);
3076
+ }
3077
+ if (NAMESPACE === HTML_NAMESPACE) {
3078
+ return getElementsByTagName2.call(doc, WHOLE_DOCUMENT ? "html" : "body")[0];
3079
+ }
3080
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
3081
+ };
3082
+ const _createNodeIterator = function _createNodeIterator2(root2) {
3083
+ return createNodeIterator.call(
3084
+ root2.ownerDocument || root2,
3085
+ root2,
3086
+ // eslint-disable-next-line no-bitwise
3087
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION,
3088
+ null
3089
+ );
3090
+ };
3091
+ const _isClobbered = function _isClobbered2(element) {
3092
+ 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");
3093
+ };
3094
+ const _isNode = function _isNode2(value) {
3095
+ return typeof Node3 === "function" && value instanceof Node3;
3096
+ };
3097
+ function _executeHooks(hooks2, currentNode, data2) {
3098
+ arrayForEach(hooks2, (hook) => {
3099
+ hook.call(DOMPurify, currentNode, data2, CONFIG);
3100
+ });
3101
+ }
3102
+ const _sanitizeElements = function _sanitizeElements2(currentNode) {
3103
+ let content = null;
3104
+ _executeHooks(hooks.beforeSanitizeElements, currentNode, null);
3105
+ if (_isClobbered(currentNode)) {
3106
+ _forceRemove(currentNode);
3107
+ return true;
3108
+ }
3109
+ const tagName = transformCaseFunc(currentNode.nodeName);
3110
+ _executeHooks(hooks.uponSanitizeElement, currentNode, {
3111
+ tagName,
3112
+ allowedTags: ALLOWED_TAGS
3113
+ });
3114
+ if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) {
3115
+ _forceRemove(currentNode);
3116
+ return true;
3117
+ }
3118
+ if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && tagName === "style" && _isNode(currentNode.firstElementChild)) {
3119
+ _forceRemove(currentNode);
3120
+ return true;
3121
+ }
3122
+ if (currentNode.nodeType === NODE_TYPE$1.progressingInstruction) {
3123
+ _forceRemove(currentNode);
3124
+ return true;
3125
+ }
3126
+ if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE$1.comment && regExpTest(/<[/\w]/g, currentNode.data)) {
3127
+ _forceRemove(currentNode);
3128
+ return true;
3129
+ }
3130
+ if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {
3131
+ if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {
3132
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {
3133
+ return false;
3134
+ }
3135
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {
3136
+ return false;
3137
+ }
3138
+ }
3139
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
3140
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
3141
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
3142
+ if (childNodes && parentNode) {
3143
+ const childCount = childNodes.length;
3144
+ for (let i = childCount - 1; i >= 0; --i) {
3145
+ const childClone = cloneNode2(childNodes[i], true);
3146
+ parentNode.insertBefore(childClone, getNextSibling(currentNode));
3147
+ }
3148
+ }
3149
+ }
3150
+ _forceRemove(currentNode);
3151
+ return true;
3152
+ }
3153
+ if (currentNode instanceof Element2 && !_checkValidNamespace(currentNode)) {
3154
+ _forceRemove(currentNode);
3155
+ return true;
3156
+ }
3157
+ if ((tagName === "noscript" || tagName === "noembed" || tagName === "noframes") && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
3158
+ _forceRemove(currentNode);
3159
+ return true;
3160
+ }
3161
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE$1.text) {
3162
+ content = currentNode.textContent;
3163
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3164
+ content = stringReplace(content, expr, " ");
3165
+ });
3166
+ if (currentNode.textContent !== content) {
3167
+ arrayPush(DOMPurify.removed, {
3168
+ element: currentNode.cloneNode()
3169
+ });
3170
+ currentNode.textContent = content;
3171
+ }
3172
+ }
3173
+ _executeHooks(hooks.afterSanitizeElements, currentNode, null);
3174
+ return false;
3175
+ };
3176
+ const _isValidAttribute = function _isValidAttribute2(lcTag, lcName, value) {
3177
+ if (FORBID_ATTR[lcName]) {
3178
+ return false;
3179
+ }
3180
+ if (SANITIZE_DOM && (lcName === "id" || lcName === "name") && (value in document2 || value in formElement)) {
3181
+ return false;
3182
+ }
3183
+ const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);
3184
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR$1, lcName)) ;
3185
+ else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) ;
3186
+ else if (!nameIsPermitted || FORBID_ATTR[lcName]) {
3187
+ if (
3188
+ // First condition does a very basic check if a) it's basically a valid custom element tagname AND
3189
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3190
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
3191
+ _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
3192
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
3193
+ 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))
3194
+ ) ;
3195
+ else {
3196
+ return false;
3197
+ }
3198
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ;
3199
+ else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3200
+ else if ((lcName === "src" || lcName === "xlink:href" || lcName === "href") && lcTag !== "script" && stringIndexOf(value, "data:") === 0 && DATA_URI_TAGS[lcTag]) ;
3201
+ else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ""))) ;
3202
+ else if (value) {
3203
+ return false;
3204
+ } else ;
3205
+ return true;
3206
+ };
3207
+ 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"]);
3208
+ const _isBasicCustomElement = function _isBasicCustomElement2(tagName) {
3209
+ return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);
3210
+ };
3211
+ const _sanitizeAttributes = function _sanitizeAttributes2(currentNode) {
3212
+ _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);
3213
+ const attributes2 = currentNode.attributes;
3214
+ if (!attributes2 || _isClobbered(currentNode)) {
3215
+ return;
3216
+ }
3217
+ const hookEvent = {
3218
+ attrName: "",
3219
+ attrValue: "",
3220
+ keepAttr: true,
3221
+ allowedAttributes: ALLOWED_ATTR,
3222
+ forceKeepAttr: void 0
3223
+ };
3224
+ let l2 = attributes2.length;
3225
+ while (l2--) {
3226
+ const attr2 = attributes2[l2];
3227
+ const name2 = attr2.name, namespaceURI = attr2.namespaceURI, attrValue = attr2.value;
3228
+ const lcName = transformCaseFunc(name2);
3229
+ const initValue = attrValue;
3230
+ let value = name2 === "value" ? initValue : stringTrim(initValue);
3231
+ hookEvent.attrName = lcName;
3232
+ hookEvent.attrValue = value;
3233
+ hookEvent.keepAttr = true;
3234
+ hookEvent.forceKeepAttr = void 0;
3235
+ _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);
3236
+ value = hookEvent.attrValue;
3237
+ if (SANITIZE_NAMED_PROPS && (lcName === "id" || lcName === "name") && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {
3238
+ _removeAttribute(name2, currentNode);
3239
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
3240
+ }
3241
+ if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {
3242
+ _removeAttribute(name2, currentNode);
3243
+ continue;
3244
+ }
3245
+ if (lcName === "attributename" && stringMatch(value, "href")) {
3246
+ _removeAttribute(name2, currentNode);
3247
+ continue;
3248
+ }
3249
+ if (hookEvent.forceKeepAttr) {
3250
+ continue;
3251
+ }
3252
+ if (!hookEvent.keepAttr) {
3253
+ _removeAttribute(name2, currentNode);
3254
+ continue;
3255
+ }
3256
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
3257
+ _removeAttribute(name2, currentNode);
3258
+ continue;
3259
+ }
3260
+ if (SAFE_FOR_TEMPLATES) {
3261
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3262
+ value = stringReplace(value, expr, " ");
3263
+ });
3264
+ }
3265
+ const lcTag = transformCaseFunc(currentNode.nodeName);
3266
+ if (!_isValidAttribute(lcTag, lcName, value)) {
3267
+ _removeAttribute(name2, currentNode);
3268
+ continue;
3269
+ }
3270
+ if (trustedTypesPolicy && typeof trustedTypes === "object" && typeof trustedTypes.getAttributeType === "function") {
3271
+ if (namespaceURI) ;
3272
+ else {
3273
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
3274
+ case "TrustedHTML": {
3275
+ value = trustedTypesPolicy.createHTML(value);
3276
+ break;
3277
+ }
3278
+ case "TrustedScriptURL": {
3279
+ value = trustedTypesPolicy.createScriptURL(value);
3280
+ break;
3281
+ }
3282
+ }
3283
+ }
3284
+ }
3285
+ if (value !== initValue) {
3286
+ try {
3287
+ if (namespaceURI) {
3288
+ currentNode.setAttributeNS(namespaceURI, name2, value);
3289
+ } else {
3290
+ currentNode.setAttribute(name2, value);
3291
+ }
3292
+ if (_isClobbered(currentNode)) {
3293
+ _forceRemove(currentNode);
3294
+ } else {
3295
+ arrayPop(DOMPurify.removed);
3296
+ }
3297
+ } catch (_) {
3298
+ _removeAttribute(name2, currentNode);
3299
+ }
3300
+ }
3301
+ }
3302
+ _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);
3303
+ };
3304
+ const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {
3305
+ let shadowNode = null;
3306
+ const shadowIterator = _createNodeIterator(fragment);
3307
+ _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);
3308
+ while (shadowNode = shadowIterator.nextNode()) {
3309
+ _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);
3310
+ _sanitizeElements(shadowNode);
3311
+ _sanitizeAttributes(shadowNode);
3312
+ if (shadowNode.content instanceof DocumentFragment) {
3313
+ _sanitizeShadowDOM2(shadowNode.content);
3314
+ }
3315
+ }
3316
+ _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);
3317
+ };
3318
+ const _sanitizeAttachedShadowRoots2 = function _sanitizeAttachedShadowRoots(root2) {
3319
+ if (root2.nodeType === NODE_TYPE$1.element && root2.shadowRoot instanceof DocumentFragment) {
3320
+ const sr = root2.shadowRoot;
3321
+ _sanitizeAttachedShadowRoots2(sr);
3322
+ _sanitizeShadowDOM2(sr);
3323
+ }
3324
+ const childNodes = root2.childNodes;
3325
+ if (!childNodes) {
3326
+ return;
3327
+ }
3328
+ const snapshot = [];
3329
+ arrayForEach(childNodes, (child) => {
3330
+ arrayPush(snapshot, child);
3331
+ });
3332
+ for (const child of snapshot) {
3333
+ _sanitizeAttachedShadowRoots2(child);
3334
+ }
3335
+ };
3336
+ DOMPurify.sanitize = function(dirty) {
3337
+ let cfg = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
3338
+ let body = null;
3339
+ let importedNode = null;
3340
+ let currentNode = null;
3341
+ let returnNode = null;
3342
+ IS_EMPTY_INPUT = !dirty;
3343
+ if (IS_EMPTY_INPUT) {
3344
+ dirty = "<!-->";
3345
+ }
3346
+ if (typeof dirty !== "string" && !_isNode(dirty)) {
3347
+ dirty = stringifyValue(dirty);
3348
+ if (typeof dirty !== "string") {
3349
+ throw typeErrorCreate("dirty is not a string, aborting");
3350
+ }
3351
+ }
3352
+ if (!DOMPurify.isSupported) {
3353
+ return dirty;
3354
+ }
3355
+ if (!SET_CONFIG) {
3356
+ _parseConfig(cfg);
3357
+ }
3358
+ DOMPurify.removed = [];
3359
+ if (typeof dirty === "string") {
3360
+ IN_PLACE = false;
3361
+ }
3362
+ if (IN_PLACE) {
3363
+ const nn = dirty.nodeName;
3364
+ if (typeof nn === "string") {
3365
+ const tagName = transformCaseFunc(nn);
3366
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
3367
+ throw typeErrorCreate("root node is forbidden and cannot be sanitized in-place");
3368
+ }
3369
+ }
3370
+ _sanitizeAttachedShadowRoots2(dirty);
3371
+ } else if (dirty instanceof Node3) {
3372
+ body = _initDocument("<!---->");
3373
+ importedNode = body.ownerDocument.importNode(dirty, true);
3374
+ if (importedNode.nodeType === NODE_TYPE$1.element && importedNode.nodeName === "BODY") {
3375
+ body = importedNode;
3376
+ } else if (importedNode.nodeName === "HTML") {
3377
+ body = importedNode;
3378
+ } else {
3379
+ body.appendChild(importedNode);
3380
+ }
3381
+ _sanitizeAttachedShadowRoots2(importedNode);
3382
+ } else {
3383
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
3384
+ dirty.indexOf("<") === -1) {
3385
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
3386
+ }
3387
+ body = _initDocument(dirty);
3388
+ if (!body) {
3389
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : "";
3390
+ }
3391
+ }
3392
+ if (body && FORCE_BODY) {
3393
+ _forceRemove(body.firstChild);
3394
+ }
3395
+ const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);
3396
+ while (currentNode = nodeIterator.nextNode()) {
3397
+ _sanitizeElements(currentNode);
3398
+ _sanitizeAttributes(currentNode);
3399
+ if (currentNode.content instanceof DocumentFragment) {
3400
+ _sanitizeShadowDOM2(currentNode.content);
3401
+ }
3402
+ }
3403
+ if (IN_PLACE) {
3404
+ return dirty;
3405
+ }
3406
+ if (RETURN_DOM) {
3407
+ if (SAFE_FOR_TEMPLATES) {
3408
+ body.normalize();
3409
+ let html2 = body.innerHTML;
3410
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3411
+ html2 = stringReplace(html2, expr, " ");
3412
+ });
3413
+ body.innerHTML = html2;
3414
+ }
3415
+ if (RETURN_DOM_FRAGMENT) {
3416
+ returnNode = createDocumentFragment.call(body.ownerDocument);
3417
+ while (body.firstChild) {
3418
+ returnNode.appendChild(body.firstChild);
3419
+ }
3420
+ } else {
3421
+ returnNode = body;
3422
+ }
3423
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
3424
+ returnNode = importNode.call(originalDocument, returnNode, true);
3425
+ }
3426
+ return returnNode;
3427
+ }
3428
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
3429
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS["!doctype"] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
3430
+ serializedHTML = "<!DOCTYPE " + body.ownerDocument.doctype.name + ">\n" + serializedHTML;
3431
+ }
3432
+ if (SAFE_FOR_TEMPLATES) {
3433
+ arrayForEach([MUSTACHE_EXPR$1, ERB_EXPR$1, TMPLIT_EXPR$1], (expr) => {
3434
+ serializedHTML = stringReplace(serializedHTML, expr, " ");
3435
+ });
3436
+ }
3437
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
3438
+ };
3439
+ DOMPurify.setConfig = function() {
3440
+ let cfg = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3441
+ _parseConfig(cfg);
3442
+ SET_CONFIG = true;
3443
+ };
3444
+ DOMPurify.clearConfig = function() {
3445
+ CONFIG = null;
3446
+ SET_CONFIG = false;
3447
+ };
3448
+ DOMPurify.isValidAttribute = function(tag, attr2, value) {
3449
+ if (!CONFIG) {
3450
+ _parseConfig({});
3451
+ }
3452
+ const lcTag = transformCaseFunc(tag);
3453
+ const lcName = transformCaseFunc(attr2);
3454
+ return _isValidAttribute(lcTag, lcName, value);
3455
+ };
3456
+ DOMPurify.addHook = function(entryPoint, hookFunction) {
3457
+ if (typeof hookFunction !== "function") {
3458
+ return;
3459
+ }
3460
+ arrayPush(hooks[entryPoint], hookFunction);
3461
+ };
3462
+ DOMPurify.removeHook = function(entryPoint, hookFunction) {
3463
+ if (hookFunction !== void 0) {
3464
+ const index2 = arrayLastIndexOf(hooks[entryPoint], hookFunction);
3465
+ return index2 === -1 ? void 0 : arraySplice(hooks[entryPoint], index2, 1)[0];
3466
+ }
3467
+ return arrayPop(hooks[entryPoint]);
3468
+ };
3469
+ DOMPurify.removeHooks = function(entryPoint) {
3470
+ hooks[entryPoint] = [];
3471
+ };
3472
+ DOMPurify.removeAllHooks = function() {
3473
+ hooks = _createHooksMap();
3474
+ };
3475
+ return DOMPurify;
3476
+ }
3477
+ var purify = createDOMPurify();
2209
3478
  ABConvert.factory({
2210
3479
  id: "md",
2211
3480
  name: "md",
@@ -2225,7 +3494,7 @@ ABConvert.factory({
2225
3494
  process_param: ABConvert_IOEnum.text,
2226
3495
  process_return: ABConvert_IOEnum.el,
2227
3496
  process: (el, header, content) => {
2228
- el.innerHTML = `<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`;
3497
+ el.innerHTML = purify.sanitize(`<p>${content.replace(/ /g, "&nbsp;").split("\n").join("<br/>")}</p>`);
2229
3498
  return el;
2230
3499
  }
2231
3500
  });
@@ -14823,7 +16092,7 @@ ABConvert.factory({
14823
16092
  async function render_pumlText(text2, div) {
14824
16093
  var encoded = plantumlEncoder.encode(text2);
14825
16094
  let url = "http://www.plantuml.com/plantuml/img/" + encoded;
14826
- div.innerHTML = `<img src="${url}">`;
16095
+ div.innerHTML = purify.sanitize(`<img src="${url}">`);
14827
16096
  return div;
14828
16097
  }
14829
16098
  function getID(length = 16) {
@@ -15000,207 +16269,18 @@ async function data2mindmap(list_itemInfo, div) {
15000
16269
  async function render_mermaidText(mermaidText, div) {
15001
16270
  if (ABCSetting.env.startsWith("obsidian") && ABCSetting.obsidian.mermaid) {
15002
16271
  ABCSetting.obsidian.mermaid.then(async (mermaid) => {
15003
- const { svg } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
16272
+ const { svg: svg2 } = await mermaid.render("ab-mermaid-" + getID(), mermaidText);
15004
16273
  const div_mermaid = document.createElement("div");
15005
16274
  div.appendChild(div_mermaid);
15006
16275
  div_mermaid.classList.add("mermaid");
15007
- div_mermaid.innerHTML = svg;
16276
+ div_mermaid.innerHTML = svg2;
15008
16277
  });
15009
16278
  } else {
15010
16279
  div.classList.add("ab-raw");
15011
- div.innerHTML = `<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`;
16280
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="mermaid" content-data='${mermaidText}'></div>`);
15012
16281
  }
15013
16282
  return div;
15014
16283
  }
15015
- function abConvertEvent(d, isCycle = false) {
15016
- if (d.querySelector(".ab-super-width")) {
15017
- const els_note = d.querySelectorAll(".ab-note");
15018
- for (const el_note of els_note) {
15019
- if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
15020
- const el_replace = el_note.parentNode;
15021
- if (el_replace && el_replace.classList.contains("ab-replace")) {
15022
- el_replace.classList.add("ab-super-width-p");
15023
- }
15024
- }
15025
- }
15026
- const els_view = document.querySelectorAll(".app-container .workspace-leaf");
15027
- for (const el_view of els_view) {
15028
- el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
15029
- }
15030
- }
15031
- if (d.querySelector(".ab-nodes-node")) {
15032
- const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
15033
- const list_children = d.querySelectorAll(".ab-nodes-node");
15034
- for (const children2 of list_children) {
15035
- const el_content = children2.querySelector(".ab-nodes-content");
15036
- if (!el_content) continue;
15037
- const el_child = children2.querySelector(".ab-nodes-children");
15038
- if (!el_child) continue;
15039
- const el_bracket = el_child.querySelector(".ab-nodes-bracket");
15040
- if (!el_bracket) continue;
15041
- const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
15042
- if (!el_bracket2) continue;
15043
- const els_child = el_child.childNodes;
15044
- if (els_child.length < 3) {
15045
- el_bracket.style.setProperty("display", "none");
15046
- el_bracket2.style.setProperty("display", "none");
15047
- continue;
15048
- }
15049
- const el_child_first = els_child[2];
15050
- const el_child_last = els_child[els_child.length - 1];
15051
- const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
15052
- const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
15053
- let height = 0;
15054
- let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
15055
- if (els_child.length == 3) {
15056
- height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
15057
- el_bracket2.style.cssText = `
15058
- height: ${height}px;
15059
- top: calc(50% - ${height / 2}px);
15060
- `;
15061
- } else {
15062
- el_bracket2.style.cssText = `
15063
- height: calc(100% - ${heightToReduce}px);
15064
- top: ${el_child_first.offsetHeight / 2}px;
15065
- `;
15066
- }
15067
- if (Array.prototype.includes.call(els_min, children2)) {
15068
- if (els_child.length == 3) {
15069
- el_bracket.style.cssText = `
15070
- display: block;
15071
- top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
15072
- clip-path: circle(40% at 50% 40%);
15073
- `;
15074
- } else {
15075
- el_bracket.setAttribute("display", "none");
15076
- }
15077
- if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
15078
- el_bracket2.style.cssText = `
15079
- height: 1px;
15080
- top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
15081
- width: 18px; /* 可以溢出点 */
15082
- border-radius: 0;
15083
- border: none;
15084
- border-bottom: 1px solid var(--node-color);
15085
- `;
15086
- } else {
15087
- if (els_child.length == 3) {
15088
- height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
15089
- el_bracket2.style.setProperty("height", `${height}px`);
15090
- el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
15091
- el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
15092
- el_bracket2.style.setProperty("border-top", `0`);
15093
- } else {
15094
- heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
15095
- el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
15096
- el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
15097
- }
15098
- el_bracket2.style.setProperty("width", "20px");
15099
- }
15100
- }
15101
- }
15102
- }
15103
- if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
15104
- const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
15105
- for (const root_el of root_el_list) {
15106
- root_el.classList.add("js-waterfall");
15107
- const list_children = root_el.querySelectorAll(".ab-items-item");
15108
- const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
15109
- let columnCount;
15110
- if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
15111
- columnCount = columnCountTmp;
15112
- } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
15113
- columnCount = list_children.length;
15114
- root_el.classList.add("ab-col" + columnCount);
15115
- } else {
15116
- columnCount = 4;
15117
- root_el.classList.add("ab-col" + columnCount);
15118
- }
15119
- const height_cache = [];
15120
- const el_cache = [];
15121
- for (let i = 0; i < columnCount; i++) {
15122
- height_cache.push(0);
15123
- el_cache.push([]);
15124
- }
15125
- for (const children2 of list_children) {
15126
- const minValue = Math.min.apply(null, height_cache);
15127
- const minIndex = height_cache.indexOf(minValue);
15128
- const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
15129
- height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
15130
- el_cache[minIndex].push(children2);
15131
- }
15132
- const fillNumber = columnCount - list_children.length % columnCount;
15133
- if (fillNumber != 4) {
15134
- for (let i = 0; i < fillNumber; i++) {
15135
- const children2 = document.createElement("div");
15136
- children2.classList.add(".ab-items-item.placeholder");
15137
- children2.setAttribute("style", "height: 20px");
15138
- const minValue = Math.min.apply(null, height_cache);
15139
- const minIndex = height_cache.indexOf(minValue);
15140
- height_cache[minIndex] += 20;
15141
- el_cache[minIndex].push(children2);
15142
- }
15143
- }
15144
- root_el.innerHTML = "";
15145
- for (let i = 0; i < columnCount; i++) {
15146
- for (const j of el_cache[i]) {
15147
- root_el.appendChild(j);
15148
- }
15149
- }
15150
- }
15151
- }
15152
- if (!isCycle && d.querySelector(".ab-markmap-div")) {
15153
- const divEl = d;
15154
- let markmapId = "";
15155
- if (divEl.tagName === "DIV") {
15156
- markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
15157
- }
15158
- let mindmaps;
15159
- if (markmapId) {
15160
- mindmaps = document.querySelectorAll("#" + markmapId);
15161
- } else {
15162
- mindmaps = document.querySelectorAll(".ab-markmap-div");
15163
- }
15164
- for (const el_div of mindmaps) {
15165
- const el_svg = el_div.querySelector("svg");
15166
- const el_g = el_svg?.querySelector("g");
15167
- if (el_svg && el_g) {
15168
- const scale_new = el_g.getBBox().height / el_div.offsetWidth;
15169
- el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
15170
- markmap_event(d);
15171
- }
15172
- }
15173
- }
15174
- }
15175
- function markmap_event(d) {
15176
- if (d.querySelector(".ab-markmap-svg")) {
15177
- console.log(" - markmap_event");
15178
- let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
15179
- if (script_el) script_el.remove();
15180
- const divEl = d;
15181
- let markmapId = "";
15182
- if (divEl.tagName === "DIV") {
15183
- markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
15184
- }
15185
- script_el = document.createElement("script");
15186
- document.head.appendChild(script_el);
15187
- script_el.type = "module";
15188
- script_el.setAttribute("script-id", "ab-markmap-script");
15189
- script_el.textContent = `
15190
- import { Markmap, } from 'https://jspm.dev/markmap-view';
15191
- const markmapId = "${markmapId || ""}";
15192
- let mindmaps;
15193
- if (markmapId) {
15194
- mindmaps = document.querySelectorAll('#' + markmapId);
15195
- } else {
15196
- mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
15197
- }
15198
- for(const mindmap of mindmaps) {
15199
- mindmap.innerHTML = "";
15200
- Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
15201
- }`;
15202
- }
15203
- }
15204
16284
  const testPath = "npm2url/dist/index.cjs";
15205
16285
  const defaultProviders = {
15206
16286
  jsdelivr: (path) => `https://cdn.jsdelivr.net/npm/${path}`,
@@ -40790,8 +41870,8 @@ var katex$1 = { exports: {} };
40790
41870
  var _functions = {};
40791
41871
  var _htmlGroupBuilders = {};
40792
41872
  var _mathmlGroupBuilders = {};
40793
- function defineFunction(_ref) {
40794
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
41873
+ function defineFunction(_ref2) {
41874
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
40795
41875
  var data2 = {
40796
41876
  type,
40797
41877
  numArgs: props.numArgs,
@@ -41789,8 +42869,8 @@ var katex$1 = { exports: {} };
41789
42869
  props: {
41790
42870
  numArgs: 1
41791
42871
  },
41792
- handler: function handler(_ref, args) {
41793
- var parser = _ref.parser, funcName = _ref.funcName;
42872
+ handler: function handler(_ref2, args) {
42873
+ var parser = _ref2.parser, funcName = _ref2.funcName;
41794
42874
  var base = args[0];
41795
42875
  return {
41796
42876
  type: "accentUnder",
@@ -41865,8 +42945,8 @@ var katex$1 = { exports: {} };
41865
42945
  numArgs: 1,
41866
42946
  numOptionalArgs: 1
41867
42947
  },
41868
- handler: function handler(_ref, args, optArgs) {
41869
- var parser = _ref.parser, funcName = _ref.funcName;
42948
+ handler: function handler(_ref2, args, optArgs) {
42949
+ var parser = _ref2.parser, funcName = _ref2.funcName;
41870
42950
  return {
41871
42951
  type: "xArrow",
41872
42952
  mode: parser.mode,
@@ -41958,8 +43038,8 @@ var katex$1 = { exports: {} };
41958
43038
  numArgs: 1,
41959
43039
  allowedInText: true
41960
43040
  },
41961
- handler: function handler(_ref, args) {
41962
- var parser = _ref.parser;
43041
+ handler: function handler(_ref2, args) {
43042
+ var parser = _ref2.parser;
41963
43043
  var arg = assertNodeType(args[0], "ordgroup");
41964
43044
  var group = arg.body;
41965
43045
  var number = "";
@@ -41997,8 +43077,8 @@ var katex$1 = { exports: {} };
41997
43077
  greediness: 3,
41998
43078
  argTypes: ["color", "original"]
41999
43079
  },
42000
- handler: function handler(_ref, args) {
42001
- var parser = _ref.parser;
43080
+ handler: function handler(_ref2, args) {
43081
+ var parser = _ref2.parser;
42002
43082
  var color = assertNodeType(args[0], "color-token").color;
42003
43083
  var body = args[1];
42004
43084
  return {
@@ -42044,8 +43124,8 @@ var katex$1 = { exports: {} };
42044
43124
  argTypes: ["size"],
42045
43125
  allowedInText: true
42046
43126
  },
42047
- handler: function handler(_ref, args, optArgs) {
42048
- var parser = _ref.parser, funcName = _ref.funcName;
43127
+ handler: function handler(_ref2, args, optArgs) {
43128
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42049
43129
  var size = optArgs[0];
42050
43130
  var newRow = funcName === "\\cr";
42051
43131
  var newLine = false;
@@ -42138,8 +43218,8 @@ var katex$1 = { exports: {} };
42138
43218
  numArgs: 0,
42139
43219
  allowedInText: true
42140
43220
  },
42141
- handler: function handler(_ref) {
42142
- var parser = _ref.parser, funcName = _ref.funcName;
43221
+ handler: function handler(_ref2) {
43222
+ var parser = _ref2.parser, funcName = _ref2.funcName;
42143
43223
  parser.consumeSpaces();
42144
43224
  var token = parser.fetch();
42145
43225
  if (globalMap[token.text]) {
@@ -42473,14 +43553,14 @@ var katex$1 = { exports: {} };
42473
43553
  var delimiter_sqrtSvg = function sqrtSvg(sqrtName, height, viewBoxHeight, extraViniculum, options) {
42474
43554
  var path = sqrtPath(sqrtName, extraViniculum, viewBoxHeight);
42475
43555
  var pathNode = new domTree_PathNode(sqrtName, path);
42476
- var svg = new SvgNode([pathNode], {
43556
+ var svg2 = new SvgNode([pathNode], {
42477
43557
  // Note: 1000:1 ratio of viewBox to document em width.
42478
43558
  "width": "400em",
42479
43559
  "height": height + "em",
42480
43560
  "viewBox": "0 0 400000 " + viewBoxHeight,
42481
43561
  "preserveAspectRatio": "xMinYMin slice"
42482
43562
  });
42483
- return buildCommon.makeSvgSpan(["hide-tail"], [svg], options);
43563
+ return buildCommon.makeSvgSpan(["hide-tail"], [svg2], options);
42484
43564
  };
42485
43565
  var makeSqrtImage = function makeSqrtImage2(height, options) {
42486
43566
  var newOptions = options.havingBaseSizing();
@@ -43090,8 +44170,8 @@ var katex$1 = { exports: {} };
43090
44170
  greediness: 3,
43091
44171
  argTypes: ["color", "text"]
43092
44172
  },
43093
- handler: function handler(_ref, args, optArgs) {
43094
- var parser = _ref.parser, funcName = _ref.funcName;
44173
+ handler: function handler(_ref2, args, optArgs) {
44174
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43095
44175
  var color = assertNodeType(args[0], "color-token").color;
43096
44176
  var body = args[1];
43097
44177
  return {
@@ -43169,8 +44249,8 @@ var katex$1 = { exports: {} };
43169
44249
  mathmlBuilder: enclose_mathmlBuilder
43170
44250
  });
43171
44251
  var _environments = {};
43172
- function defineEnvironment(_ref) {
43173
- var type = _ref.type, names = _ref.names, props = _ref.props, handler = _ref.handler, htmlBuilder = _ref.htmlBuilder, mathmlBuilder = _ref.mathmlBuilder;
44252
+ function defineEnvironment(_ref2) {
44253
+ var type = _ref2.type, names = _ref2.names, props = _ref2.props, handler = _ref2.handler, htmlBuilder = _ref2.htmlBuilder, mathmlBuilder = _ref2.mathmlBuilder;
43174
44254
  var data2 = {
43175
44255
  type,
43176
44256
  numArgs: props.numArgs || 0,
@@ -43201,8 +44281,8 @@ var katex$1 = { exports: {} };
43201
44281
  }
43202
44282
  return hlineInfo;
43203
44283
  }
43204
- function parseArray(parser, _ref, style) {
43205
- var hskipBeforeAndAfter = _ref.hskipBeforeAndAfter, addJot = _ref.addJot, cols = _ref.cols, arraystretch = _ref.arraystretch, colSeparationType = _ref.colSeparationType;
44284
+ function parseArray(parser, _ref2, style) {
44285
+ var hskipBeforeAndAfter = _ref2.hskipBeforeAndAfter, addJot = _ref2.addJot, cols = _ref2.cols, arraystretch = _ref2.arraystretch, colSeparationType = _ref2.colSeparationType;
43206
44286
  parser.gullet.beginGroup();
43207
44287
  parser.gullet.macros.set("\\\\", "\\cr");
43208
44288
  if (!arraystretch) {
@@ -43841,8 +44921,8 @@ var katex$1 = { exports: {} };
43841
44921
  numArgs: 1,
43842
44922
  argTypes: ["text"]
43843
44923
  },
43844
- handler: function handler(_ref, args) {
43845
- var parser = _ref.parser, funcName = _ref.funcName;
44924
+ handler: function handler(_ref2, args) {
44925
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43846
44926
  var nameGroup = args[0];
43847
44927
  if (nameGroup.type !== "ordgroup") {
43848
44928
  throw new src_ParseError("Invalid environment name", nameGroup);
@@ -43922,8 +45002,8 @@ var katex$1 = { exports: {} };
43922
45002
  props: {
43923
45003
  numArgs: 1
43924
45004
  },
43925
- handler: function handler(_ref, args) {
43926
- var parser = _ref.parser, funcName = _ref.funcName;
45005
+ handler: function handler(_ref2, args) {
45006
+ var parser = _ref2.parser, funcName = _ref2.funcName;
43927
45007
  var body = args[0];
43928
45008
  return {
43929
45009
  type: "mclass",
@@ -44046,8 +45126,8 @@ var katex$1 = { exports: {} };
44046
45126
  numArgs: 1,
44047
45127
  greediness: 2
44048
45128
  },
44049
- handler: function handler(_ref, args) {
44050
- var parser = _ref.parser, funcName = _ref.funcName;
45129
+ handler: function handler(_ref2, args) {
45130
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44051
45131
  var body = args[0];
44052
45132
  var func = funcName;
44053
45133
  if (func in fontAliases) {
@@ -44301,8 +45381,8 @@ var katex$1 = { exports: {} };
44301
45381
  numArgs: 2,
44302
45382
  greediness: 2
44303
45383
  },
44304
- handler: function handler(_ref, args) {
44305
- var parser = _ref.parser, funcName = _ref.funcName;
45384
+ handler: function handler(_ref2, args) {
45385
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44306
45386
  var numer = args[0];
44307
45387
  var denom = args[1];
44308
45388
  var hasBarLine;
@@ -44603,8 +45683,8 @@ var katex$1 = { exports: {} };
44603
45683
  props: {
44604
45684
  numArgs: 1
44605
45685
  },
44606
- handler: function handler(_ref, args) {
44607
- var parser = _ref.parser, funcName = _ref.funcName;
45686
+ handler: function handler(_ref2, args) {
45687
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44608
45688
  return {
44609
45689
  type: "horizBrace",
44610
45690
  mode: parser.mode,
@@ -44624,8 +45704,8 @@ var katex$1 = { exports: {} };
44624
45704
  argTypes: ["url", "original"],
44625
45705
  allowedInText: true
44626
45706
  },
44627
- handler: function handler(_ref, args) {
44628
- var parser = _ref.parser;
45707
+ handler: function handler(_ref2, args) {
45708
+ var parser = _ref2.parser;
44629
45709
  var body = args[1];
44630
45710
  var href = assertNodeType(args[0], "url").url;
44631
45711
  if (!parser.settings.isTrusted({
@@ -44705,9 +45785,9 @@ var katex$1 = { exports: {} };
44705
45785
  argTypes: ["raw", "original"],
44706
45786
  allowedInText: true
44707
45787
  },
44708
- handler: function handler(_ref, args) {
44709
- var parser = _ref.parser, funcName = _ref.funcName;
44710
- _ref.token;
45788
+ handler: function handler(_ref2, args) {
45789
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45790
+ _ref2.token;
44711
45791
  var value = assertNodeType(args[0], "raw").string;
44712
45792
  var body = args[1];
44713
45793
  if (parser.settings.strict) {
@@ -44790,8 +45870,8 @@ var katex$1 = { exports: {} };
44790
45870
  numArgs: 2,
44791
45871
  allowedInText: true
44792
45872
  },
44793
- handler: function handler(_ref, args) {
44794
- var parser = _ref.parser;
45873
+ handler: function handler(_ref2, args) {
45874
+ var parser = _ref2.parser;
44795
45875
  return {
44796
45876
  type: "htmlmathml",
44797
45877
  mode: parser.mode,
@@ -44838,8 +45918,8 @@ var katex$1 = { exports: {} };
44838
45918
  argTypes: ["raw", "url"],
44839
45919
  allowedInText: false
44840
45920
  },
44841
- handler: function handler(_ref, args, optArgs) {
44842
- var parser = _ref.parser;
45921
+ handler: function handler(_ref2, args, optArgs) {
45922
+ var parser = _ref2.parser;
44843
45923
  var width = {
44844
45924
  number: 0,
44845
45925
  unit: "em"
@@ -44953,8 +46033,8 @@ var katex$1 = { exports: {} };
44953
46033
  argTypes: ["size"],
44954
46034
  allowedInText: true
44955
46035
  },
44956
- handler: function handler(_ref, args) {
44957
- var parser = _ref.parser, funcName = _ref.funcName;
46036
+ handler: function handler(_ref2, args) {
46037
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44958
46038
  var size = assertNodeType(args[0], "size");
44959
46039
  if (parser.settings.strict) {
44960
46040
  var mathFunction = funcName[1] === "m";
@@ -44993,8 +46073,8 @@ var katex$1 = { exports: {} };
44993
46073
  numArgs: 1,
44994
46074
  allowedInText: true
44995
46075
  },
44996
- handler: function handler(_ref, args) {
44997
- var parser = _ref.parser, funcName = _ref.funcName;
46076
+ handler: function handler(_ref2, args) {
46077
+ var parser = _ref2.parser, funcName = _ref2.funcName;
44998
46078
  var body = args[0];
44999
46079
  return {
45000
46080
  type: "lap",
@@ -45038,8 +46118,8 @@ var katex$1 = { exports: {} };
45038
46118
  allowedInText: true,
45039
46119
  allowedInMath: false
45040
46120
  },
45041
- handler: function handler(_ref, args) {
45042
- var funcName = _ref.funcName, parser = _ref.parser;
46121
+ handler: function handler(_ref2, args) {
46122
+ var funcName = _ref2.funcName, parser = _ref2.parser;
45043
46123
  var outerMode = parser.mode;
45044
46124
  parser.switchMode("math");
45045
46125
  var close = funcName === "\\(" ? "\\)" : "$";
@@ -45087,8 +46167,8 @@ var katex$1 = { exports: {} };
45087
46167
  props: {
45088
46168
  numArgs: 4
45089
46169
  },
45090
- handler: function handler(_ref, args) {
45091
- var parser = _ref.parser;
46170
+ handler: function handler(_ref2, args) {
46171
+ var parser = _ref2.parser;
45092
46172
  return {
45093
46173
  type: "mathchoice",
45094
46174
  mode: parser.mode,
@@ -45320,8 +46400,8 @@ var katex$1 = { exports: {} };
45320
46400
  props: {
45321
46401
  numArgs: 0
45322
46402
  },
45323
- handler: function handler(_ref, args) {
45324
- var parser = _ref.parser, funcName = _ref.funcName;
46403
+ handler: function handler(_ref2, args) {
46404
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45325
46405
  var fName = funcName;
45326
46406
  if (fName.length === 1) {
45327
46407
  fName = singleCharBigOps[fName];
@@ -45526,8 +46606,8 @@ var katex$1 = { exports: {} };
45526
46606
  props: {
45527
46607
  numArgs: 1
45528
46608
  },
45529
- handler: function handler(_ref, args) {
45530
- var parser = _ref.parser, funcName = _ref.funcName;
46609
+ handler: function handler(_ref2, args) {
46610
+ var parser = _ref2.parser, funcName = _ref2.funcName;
45531
46611
  var body = args[0];
45532
46612
  return {
45533
46613
  type: "operatorname",
@@ -45559,8 +46639,8 @@ var katex$1 = { exports: {} };
45559
46639
  props: {
45560
46640
  numArgs: 1
45561
46641
  },
45562
- handler: function handler(_ref, args) {
45563
- var parser = _ref.parser;
46642
+ handler: function handler(_ref2, args) {
46643
+ var parser = _ref2.parser;
45564
46644
  var body = args[0];
45565
46645
  return {
45566
46646
  type: "overline",
@@ -45605,8 +46685,8 @@ var katex$1 = { exports: {} };
45605
46685
  numArgs: 1,
45606
46686
  allowedInText: true
45607
46687
  },
45608
- handler: function handler(_ref, args) {
45609
- var parser = _ref.parser;
46688
+ handler: function handler(_ref2, args) {
46689
+ var parser = _ref2.parser;
45610
46690
  var body = args[0];
45611
46691
  return {
45612
46692
  type: "phantom",
@@ -45704,8 +46784,8 @@ var katex$1 = { exports: {} };
45704
46784
  argTypes: ["size", "hbox"],
45705
46785
  allowedInText: true
45706
46786
  },
45707
- handler: function handler(_ref, args) {
45708
- var parser = _ref.parser;
46787
+ handler: function handler(_ref2, args) {
46788
+ var parser = _ref2.parser;
45709
46789
  var amount = assertNodeType(args[0], "size").value;
45710
46790
  var body = args[1];
45711
46791
  return {
@@ -45742,8 +46822,8 @@ var katex$1 = { exports: {} };
45742
46822
  numOptionalArgs: 1,
45743
46823
  argTypes: ["size", "size", "size"]
45744
46824
  },
45745
- handler: function handler(_ref, args, optArgs) {
45746
- var parser = _ref.parser;
46825
+ handler: function handler(_ref2, args, optArgs) {
46826
+ var parser = _ref2.parser;
45747
46827
  var shift = optArgs[0];
45748
46828
  var width = assertNodeType(args[0], "size");
45749
46829
  var height = assertNodeType(args[1], "size");
@@ -45816,8 +46896,8 @@ var katex$1 = { exports: {} };
45816
46896
  numArgs: 0,
45817
46897
  allowedInText: true
45818
46898
  },
45819
- handler: function handler(_ref, args) {
45820
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
46899
+ handler: function handler(_ref2, args) {
46900
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
45821
46901
  var body = parser.parseExpression(false, breakOnTokenText);
45822
46902
  return {
45823
46903
  type: "sizing",
@@ -45844,8 +46924,8 @@ var katex$1 = { exports: {} };
45844
46924
  numOptionalArgs: 1,
45845
46925
  allowedInText: true
45846
46926
  },
45847
- handler: function handler(_ref, args, optArgs) {
45848
- var parser = _ref.parser;
46927
+ handler: function handler(_ref2, args, optArgs) {
46928
+ var parser = _ref2.parser;
45849
46929
  var smashHeight = false;
45850
46930
  var smashDepth = false;
45851
46931
  var tbArg = optArgs[0] && assertNodeType(optArgs[0], "ordgroup");
@@ -45925,8 +47005,8 @@ var katex$1 = { exports: {} };
45925
47005
  numArgs: 1,
45926
47006
  numOptionalArgs: 1
45927
47007
  },
45928
- handler: function handler(_ref, args, optArgs) {
45929
- var parser = _ref.parser;
47008
+ handler: function handler(_ref2, args, optArgs) {
47009
+ var parser = _ref2.parser;
45930
47010
  var index2 = optArgs[0];
45931
47011
  var body = args[0];
45932
47012
  return {
@@ -46010,8 +47090,8 @@ var katex$1 = { exports: {} };
46010
47090
  numArgs: 0,
46011
47091
  allowedInText: true
46012
47092
  },
46013
- handler: function handler(_ref, args) {
46014
- var breakOnTokenText = _ref.breakOnTokenText, funcName = _ref.funcName, parser = _ref.parser;
47093
+ handler: function handler(_ref2, args) {
47094
+ var breakOnTokenText = _ref2.breakOnTokenText, funcName = _ref2.funcName, parser = _ref2.parser;
46015
47095
  var body = parser.parseExpression(true, breakOnTokenText);
46016
47096
  var style = funcName.slice(1, funcName.length - 5);
46017
47097
  return {
@@ -46396,8 +47476,8 @@ var katex$1 = { exports: {} };
46396
47476
  greediness: 2,
46397
47477
  allowedInText: true
46398
47478
  },
46399
- handler: function handler(_ref, args) {
46400
- var parser = _ref.parser, funcName = _ref.funcName;
47479
+ handler: function handler(_ref2, args) {
47480
+ var parser = _ref2.parser, funcName = _ref2.funcName;
46401
47481
  var body = args[0];
46402
47482
  return {
46403
47483
  type: "text",
@@ -46423,8 +47503,8 @@ var katex$1 = { exports: {} };
46423
47503
  numArgs: 1,
46424
47504
  allowedInText: true
46425
47505
  },
46426
- handler: function handler(_ref, args) {
46427
- var parser = _ref.parser;
47506
+ handler: function handler(_ref2, args) {
47507
+ var parser = _ref2.parser;
46428
47508
  return {
46429
47509
  type: "underline",
46430
47510
  mode: parser.mode,
@@ -49285,7 +50365,7 @@ ABConvert.factory({
49285
50365
  process_return: ABConvert_IOEnum.el,
49286
50366
  process: (el, header, content) => {
49287
50367
  list2markmap(content, el);
49288
- markmap_event(el);
50368
+ ABCSetting.obsidian.markmap_event?.(el);
49289
50369
  return el;
49290
50370
  }
49291
50371
  });
@@ -49301,13 +50381,46 @@ function list2markmap(markdown, div) {
49301
50381
  svg_div.classList.add("ab-markmap-div");
49302
50382
  svg_div.id = "ab-markmap-div-" + id;
49303
50383
  const html_str = `<svg class="ab-markmap-svg" id="ab-markmap-${id}" data-json='${JSON.stringify(root2)}' style="height:${height_adapt}px"></svg>`;
49304
- svg_div.innerHTML = html_str;
50384
+ svg_div.innerHTML = purify.sanitize(html_str, {
50385
+ USE_PROFILES: { svg: true }
50386
+ });
49305
50387
  } else {
49306
50388
  div.classList.add("ab-raw");
49307
- div.innerHTML = `<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`;
50389
+ div.innerHTML = purify.sanitize(`<div class="ab-raw-data" type-data="markmap" content-data='${markdown}'></div>`);
49308
50390
  }
49309
50391
  return div;
49310
50392
  }
50393
+ async function markmap_event(d) {
50394
+ if (ABCSetting.env == "obsidian-min") return;
50395
+ if (d.querySelector(".ab-markmap-svg")) {
50396
+ console.log(" - markmap_event");
50397
+ let script_el = document.querySelector('script[script-id="ab-markmap-script"]');
50398
+ if (script_el) script_el.remove();
50399
+ const divEl = d;
50400
+ let markmapId = "";
50401
+ if (divEl.tagName === "DIV") {
50402
+ markmapId = divEl.querySelector(".ab-markmap-svg")?.id || "";
50403
+ }
50404
+ script_el = document.createElement("script");
50405
+ document.head.appendChild(script_el);
50406
+ script_el.type = "module";
50407
+ script_el.setAttribute("script-id", "ab-markmap-script");
50408
+ script_el.textContent = `
50409
+ import { Markmap, } from 'https://jspm.dev/markmap-view';
50410
+ const markmapId = "${markmapId || ""}";
50411
+ let mindmaps;
50412
+ if (markmapId) {
50413
+ mindmaps = document.querySelectorAll('#' + markmapId);
50414
+ } else {
50415
+ mindmaps = document.querySelectorAll('.ab-markmap-svg'); // 注意一下这里的选择器
50416
+ }
50417
+ for(const mindmap of mindmaps) {
50418
+ mindmap.innerHTML = "";
50419
+ Markmap.create(mindmap,null,JSON.parse(mindmap.getAttribute('data-json')));
50420
+ }`;
50421
+ }
50422
+ }
50423
+ ABCSetting.obsidian.markmap_event = markmap_event;
49311
50424
  const jsdom_api = {
49312
50425
  jsdom_enable: () => {
49313
50426
  },
@@ -49578,6 +50691,166 @@ function ab_mdit_client(md, options) {
49578
50691
  md.use(abSelector_squareInline);
49579
50692
  md.use(abSelector_container);
49580
50693
  }
50694
+ function abConvertEvent(d, isCycle = false) {
50695
+ if (d.querySelector(".ab-super-width")) {
50696
+ const els_note = d.querySelectorAll(".ab-note");
50697
+ for (const el_note of els_note) {
50698
+ if (el_note.classList.contains("ab-super-width") || el_note.querySelector(".ab-super-width")) {
50699
+ const el_replace = el_note.parentNode;
50700
+ if (el_replace && el_replace.classList.contains("ab-replace")) {
50701
+ el_replace.classList.add("ab-super-width-p");
50702
+ }
50703
+ }
50704
+ }
50705
+ const els_view = document.querySelectorAll(".app-container .workspace-leaf");
50706
+ for (const el_view of els_view) {
50707
+ el_view.style.setProperty("--ab-width-outer", (el_view.offsetWidth - 40).toString() + "px");
50708
+ }
50709
+ }
50710
+ if (d.querySelector(".ab-nodes-node")) {
50711
+ const els_min = document.querySelectorAll(".ab-nodes.min .ab-nodes-node");
50712
+ const list_children = d.querySelectorAll(".ab-nodes-node");
50713
+ for (const children2 of list_children) {
50714
+ const el_content = children2.querySelector(".ab-nodes-content");
50715
+ if (!el_content) continue;
50716
+ const el_child = children2.querySelector(".ab-nodes-children");
50717
+ if (!el_child) continue;
50718
+ const el_bracket = el_child.querySelector(".ab-nodes-bracket");
50719
+ if (!el_bracket) continue;
50720
+ const el_bracket2 = el_child.querySelector(".ab-nodes-bracket2");
50721
+ if (!el_bracket2) continue;
50722
+ const els_child = el_child.childNodes;
50723
+ if (els_child.length < 3) {
50724
+ el_bracket.style.setProperty("display", "none");
50725
+ el_bracket2.style.setProperty("display", "none");
50726
+ continue;
50727
+ }
50728
+ const el_child_first = els_child[2];
50729
+ const el_child_last = els_child[els_child.length - 1];
50730
+ const el_child_first_content = el_child_first.querySelector(".ab-nodes-content");
50731
+ const el_child_last_content = el_child_last.querySelector(".ab-nodes-content");
50732
+ let height = 0;
50733
+ let heightToReduce = (el_child_first.offsetHeight + el_child_last.offsetHeight) / 2;
50734
+ if (els_child.length == 3) {
50735
+ height = el_child_first_content.offsetHeight - 20 > 20 ? el_child_first_content.offsetHeight - 20 : 20;
50736
+ el_bracket2.style.cssText = `
50737
+ height: ${height}px;
50738
+ top: calc(50% - ${height / 2}px);
50739
+ `;
50740
+ } else {
50741
+ el_bracket2.style.cssText = `
50742
+ height: calc(100% - ${heightToReduce}px);
50743
+ top: ${el_child_first.offsetHeight / 2}px;
50744
+ `;
50745
+ }
50746
+ if (Array.prototype.includes.call(els_min, children2)) {
50747
+ if (els_child.length == 3) {
50748
+ el_bracket.style.cssText = `
50749
+ display: block;
50750
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 3px);
50751
+ clip-path: circle(40% at 50% 40%);
50752
+ `;
50753
+ } else {
50754
+ el_bracket.setAttribute("display", "none");
50755
+ }
50756
+ if (els_child.length == 3 && el_content.offsetHeight == el_child_first_content.offsetHeight) {
50757
+ el_bracket2.style.cssText = `
50758
+ height: 1px;
50759
+ top: calc(50% + ${el_content.offsetHeight / 2}px - 1px);
50760
+ width: 18px; /* 可以溢出点 */
50761
+ border-radius: 0;
50762
+ border: none;
50763
+ border-bottom: 1px solid var(--node-color);
50764
+ `;
50765
+ } else {
50766
+ if (els_child.length == 3) {
50767
+ height = el_child_last_content.offsetHeight / 2 - el_content.offsetHeight / 2;
50768
+ el_bracket2.style.setProperty("height", `${height}px`);
50769
+ el_bracket2.style.setProperty("top", `calc(50% + ${el_content.offsetHeight / 2}px)`);
50770
+ el_bracket2.style.setProperty("border-radius", `0 0 0 10px`);
50771
+ el_bracket2.style.setProperty("border-top", `0`);
50772
+ } else {
50773
+ heightToReduce = el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 + el_child_last.offsetHeight / 2 - el_child_last_content.offsetHeight / 2;
50774
+ el_bracket2.style.setProperty("height", `calc(100% - ${heightToReduce}px + 1px)`);
50775
+ el_bracket2.style.setProperty("top", `${el_child_first.offsetHeight / 2 + el_child_first_content.offsetHeight / 2 - 1}px`);
50776
+ }
50777
+ el_bracket2.style.setProperty("width", "20px");
50778
+ }
50779
+ }
50780
+ }
50781
+ }
50782
+ if (d.querySelector(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)")) {
50783
+ const root_el_list = d.querySelectorAll(".ab-items.ab-lay-vfall:not(.js-waterfall):not(.ab-lay-hfall):not(.ab-lay-grid)");
50784
+ for (const root_el of root_el_list) {
50785
+ root_el.classList.add("js-waterfall");
50786
+ const list_children = root_el.querySelectorAll(".ab-items-item");
50787
+ const columnCountTmp = parseInt(window.getComputedStyle(root_el).getPropertyValue("column-count"));
50788
+ let columnCount;
50789
+ if (columnCountTmp && !isNaN(columnCountTmp) && columnCountTmp > 0) {
50790
+ columnCount = columnCountTmp;
50791
+ } else if (root_el.classList.contains("ab-col-auto") && list_children.length <= 4) {
50792
+ columnCount = list_children.length;
50793
+ root_el.classList.add("ab-col" + columnCount);
50794
+ } else {
50795
+ columnCount = 4;
50796
+ root_el.classList.add("ab-col" + columnCount);
50797
+ }
50798
+ const height_cache = [];
50799
+ const el_cache = [];
50800
+ for (let i = 0; i < columnCount; i++) {
50801
+ height_cache.push(0);
50802
+ el_cache.push([]);
50803
+ }
50804
+ for (const children2 of list_children) {
50805
+ const minValue = Math.min.apply(null, height_cache);
50806
+ const minIndex = height_cache.indexOf(minValue);
50807
+ const heightTmp = parseInt(window.getComputedStyle(children2).getPropertyValue("height"));
50808
+ height_cache[minIndex] += heightTmp && !isNaN(heightTmp) && heightTmp > 0 ? heightTmp : 10;
50809
+ el_cache[minIndex].push(children2);
50810
+ }
50811
+ const fillNumber = columnCount - list_children.length % columnCount;
50812
+ if (fillNumber != 4) {
50813
+ for (let i = 0; i < fillNumber; i++) {
50814
+ const children2 = document.createElement("div");
50815
+ children2.classList.add(".ab-items-item.placeholder");
50816
+ children2.setAttribute("style", "height: 20px");
50817
+ const minValue = Math.min.apply(null, height_cache);
50818
+ const minIndex = height_cache.indexOf(minValue);
50819
+ height_cache[minIndex] += 20;
50820
+ el_cache[minIndex].push(children2);
50821
+ }
50822
+ }
50823
+ root_el.innerHTML = "";
50824
+ for (let i = 0; i < columnCount; i++) {
50825
+ for (const j of el_cache[i]) {
50826
+ root_el.appendChild(j);
50827
+ }
50828
+ }
50829
+ }
50830
+ }
50831
+ if (!isCycle && d.querySelector(".ab-markmap-div")) {
50832
+ const divEl = d;
50833
+ let markmapId = "";
50834
+ if (divEl.tagName === "DIV") {
50835
+ markmapId = divEl.querySelector(".ab-markmap-div")?.id || "";
50836
+ }
50837
+ let mindmaps;
50838
+ if (markmapId) {
50839
+ mindmaps = document.querySelectorAll("#" + markmapId);
50840
+ } else {
50841
+ mindmaps = document.querySelectorAll(".ab-markmap-div");
50842
+ }
50843
+ for (const el_div of mindmaps) {
50844
+ const el_svg = el_div.querySelector("svg");
50845
+ const el_g = el_svg?.querySelector("g");
50846
+ if (el_svg && el_g) {
50847
+ const scale_new = el_g.getBBox().height / el_div.offsetWidth;
50848
+ el_svg.setAttribute("style", `height:${el_g.getBBox().height * scale_new + 40}px`);
50849
+ ABCSetting.obsidian.markmap_event?.(d);
50850
+ }
50851
+ }
50852
+ }
50853
+ }
49581
50854
  export {
49582
50855
  ABReg as A,
49583
50856
  ab_mdit as a,
@@ -49586,4 +50859,4 @@ export {
49586
50859
  ABConvertManager as d,
49587
50860
  jsdom_api as j
49588
50861
  };
49589
- //# sourceMappingURL=index_mdit-DeveGzkz.js.map
50862
+ //# sourceMappingURL=ABConvertEvent-DXDgKtXz.js.map