schematex 0.2.0 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +1 -1
  2. package/dist/ai/ai-sdk.cjs +85 -0
  3. package/dist/ai/ai-sdk.cjs.map +1 -0
  4. package/dist/ai/ai-sdk.d.cts +30 -0
  5. package/dist/ai/ai-sdk.d.ts +30 -0
  6. package/dist/ai/ai-sdk.js +83 -0
  7. package/dist/ai/ai-sdk.js.map +1 -0
  8. package/dist/ai/index.cjs +60 -0
  9. package/dist/ai/index.cjs.map +1 -0
  10. package/dist/ai/index.d.cts +155 -0
  11. package/dist/ai/index.d.ts +155 -0
  12. package/dist/ai/index.js +23 -0
  13. package/dist/ai/index.js.map +1 -0
  14. package/dist/browser.cjs +22 -21
  15. package/dist/browser.cjs.map +1 -1
  16. package/dist/browser.js +20 -19
  17. package/dist/browser.js.map +1 -1
  18. package/dist/{chunk-HLYA4QBB.js → chunk-2BM3HJSK.js} +545 -101
  19. package/dist/chunk-2BM3HJSK.js.map +1 -0
  20. package/dist/{chunk-ZO77FHBF.cjs → chunk-2JDVJRR3.cjs} +14 -6
  21. package/dist/chunk-2JDVJRR3.cjs.map +1 -0
  22. package/dist/{chunk-TIGP2OEJ.js → chunk-2VNMKOUO.js} +20 -5
  23. package/dist/chunk-2VNMKOUO.js.map +1 -0
  24. package/dist/{chunk-ULERCTGS.cjs → chunk-3YZ6FPQW.cjs} +36 -30
  25. package/dist/chunk-3YZ6FPQW.cjs.map +1 -0
  26. package/dist/{chunk-GEPBET4L.js → chunk-45KP67RR.js} +14 -6
  27. package/dist/chunk-45KP67RR.js.map +1 -0
  28. package/dist/chunk-4QP37LD3.js +1112 -0
  29. package/dist/chunk-4QP37LD3.js.map +1 -0
  30. package/dist/{chunk-HKRYKEOV.cjs → chunk-4S2WILLW.cjs} +4 -4
  31. package/dist/{chunk-HKRYKEOV.cjs.map → chunk-4S2WILLW.cjs.map} +1 -1
  32. package/dist/{chunk-IMHR3S5H.cjs → chunk-5AEN2PLB.cjs} +17 -9
  33. package/dist/chunk-5AEN2PLB.cjs.map +1 -0
  34. package/dist/{chunk-SPIW4VWP.js → chunk-5YYAYW67.js} +3 -3
  35. package/dist/{chunk-SPIW4VWP.js.map → chunk-5YYAYW67.js.map} +1 -1
  36. package/dist/{chunk-CEV3GZA3.cjs → chunk-6LZJTAA3.cjs} +552 -108
  37. package/dist/chunk-6LZJTAA3.cjs.map +1 -0
  38. package/dist/{chunk-IY52OWPG.cjs → chunk-A5D2IMOX.cjs} +18 -10
  39. package/dist/chunk-A5D2IMOX.cjs.map +1 -0
  40. package/dist/{chunk-AMP2FFES.cjs → chunk-B37IKTI7.cjs} +229 -52
  41. package/dist/chunk-B37IKTI7.cjs.map +1 -0
  42. package/dist/{chunk-LKHWBDWZ.cjs → chunk-B6INLQBU.cjs} +17 -11
  43. package/dist/chunk-B6INLQBU.cjs.map +1 -0
  44. package/dist/{chunk-DTMCQXXC.cjs → chunk-COLTVQWR.cjs} +184 -16
  45. package/dist/chunk-COLTVQWR.cjs.map +1 -0
  46. package/dist/{chunk-S6VPECM3.cjs → chunk-D7EHZFK4.cjs} +20 -5
  47. package/dist/chunk-D7EHZFK4.cjs.map +1 -0
  48. package/dist/chunk-DNZFOCV7.js +796 -0
  49. package/dist/chunk-DNZFOCV7.js.map +1 -0
  50. package/dist/{chunk-ZGKEFVJQ.cjs → chunk-E65ITQXV.cjs} +188 -32
  51. package/dist/chunk-E65ITQXV.cjs.map +1 -0
  52. package/dist/{chunk-7WXAAVR3.js → chunk-FCGHV6ZK.js} +17 -9
  53. package/dist/chunk-FCGHV6ZK.js.map +1 -0
  54. package/dist/{chunk-A74ZCP5I.js → chunk-FE6GAUNW.js} +36 -30
  55. package/dist/chunk-FE6GAUNW.js.map +1 -0
  56. package/dist/{chunk-MXJ6FHSY.js → chunk-JDTB7IKL.js} +3 -3
  57. package/dist/{chunk-MXJ6FHSY.js.map → chunk-JDTB7IKL.js.map} +1 -1
  58. package/dist/{chunk-RQX53J6M.js → chunk-LR4X4ZRG.js} +180 -24
  59. package/dist/chunk-LR4X4ZRG.js.map +1 -0
  60. package/dist/{chunk-MRGS54WN.js → chunk-M5B2UUNW.js} +3 -3
  61. package/dist/{chunk-MRGS54WN.js.map → chunk-M5B2UUNW.js.map} +1 -1
  62. package/dist/{chunk-LXNFVHDT.cjs → chunk-MCFQAUQV.cjs} +21 -13
  63. package/dist/chunk-MCFQAUQV.cjs.map +1 -0
  64. package/dist/chunk-MOU5QRZY.cjs +1121 -0
  65. package/dist/chunk-MOU5QRZY.cjs.map +1 -0
  66. package/dist/{chunk-TPA36ULU.js → chunk-OC22GGQN.js} +223 -46
  67. package/dist/chunk-OC22GGQN.js.map +1 -0
  68. package/dist/{chunk-2OIW3MAE.js → chunk-PGALHQFF.js} +3 -3
  69. package/dist/{chunk-2OIW3MAE.js.map → chunk-PGALHQFF.js.map} +1 -1
  70. package/dist/{chunk-3M7QWADF.cjs → chunk-QSQX77S2.cjs} +4 -4
  71. package/dist/{chunk-3M7QWADF.cjs.map → chunk-QSQX77S2.cjs.map} +1 -1
  72. package/dist/{chunk-VP54YPOX.cjs → chunk-QXIGHMH2.cjs} +498 -177
  73. package/dist/chunk-QXIGHMH2.cjs.map +1 -0
  74. package/dist/{chunk-YO4GU6JX.js → chunk-RP5UATRA.js} +175 -7
  75. package/dist/chunk-RP5UATRA.js.map +1 -0
  76. package/dist/{chunk-M6AMNXQ7.js → chunk-S3RBKJM5.js} +478 -157
  77. package/dist/chunk-S3RBKJM5.js.map +1 -0
  78. package/dist/{chunk-JZGFSRVT.js → chunk-SN7NTZI6.js} +9 -7
  79. package/dist/chunk-SN7NTZI6.js.map +1 -0
  80. package/dist/{chunk-L6IHSTPP.js → chunk-U6L3FAML.js} +16 -10
  81. package/dist/chunk-U6L3FAML.js.map +1 -0
  82. package/dist/{chunk-5SH5NUDW.js → chunk-UGCUNADI.js} +21 -13
  83. package/dist/chunk-UGCUNADI.js.map +1 -0
  84. package/dist/chunk-ULYRO2KY.cjs +800 -0
  85. package/dist/chunk-ULYRO2KY.cjs.map +1 -0
  86. package/dist/{chunk-4HPT4BOI.cjs → chunk-WYFXOXVK.cjs} +4 -4
  87. package/dist/{chunk-4HPT4BOI.cjs.map → chunk-WYFXOXVK.cjs.map} +1 -1
  88. package/dist/{chunk-YKO7DY2F.cjs → chunk-X7RPFTTR.cjs} +13 -13
  89. package/dist/{chunk-YKO7DY2F.cjs.map → chunk-X7RPFTTR.cjs.map} +1 -1
  90. package/dist/{chunk-4TS5NB7L.js → chunk-YQANC7HQ.js} +3 -3
  91. package/dist/{chunk-4TS5NB7L.js.map → chunk-YQANC7HQ.js.map} +1 -1
  92. package/dist/{chunk-HAIBAF6J.cjs → chunk-Z3DE6S64.cjs} +10 -8
  93. package/dist/chunk-Z3DE6S64.cjs.map +1 -0
  94. package/dist/{chunk-IQIJ6WW6.js → chunk-ZNDIGQJD.js} +15 -7
  95. package/dist/chunk-ZNDIGQJD.js.map +1 -0
  96. package/dist/{chunk-PIQG2Z5N.cjs → chunk-ZNOD4VZT.cjs} +4 -4
  97. package/dist/{chunk-PIQG2Z5N.cjs.map → chunk-ZNOD4VZT.cjs.map} +1 -1
  98. package/dist/diagrams/blockdiagram/index.cjs +5 -5
  99. package/dist/diagrams/blockdiagram/index.d.cts +1 -1
  100. package/dist/diagrams/blockdiagram/index.d.ts +1 -1
  101. package/dist/diagrams/blockdiagram/index.js +1 -1
  102. package/dist/diagrams/circuit/index.cjs +8 -8
  103. package/dist/diagrams/circuit/index.d.cts +1 -1
  104. package/dist/diagrams/circuit/index.d.ts +1 -1
  105. package/dist/diagrams/circuit/index.js +2 -2
  106. package/dist/diagrams/ecomap/index.cjs +8 -7
  107. package/dist/diagrams/ecomap/index.d.cts +2 -2
  108. package/dist/diagrams/ecomap/index.d.ts +2 -2
  109. package/dist/diagrams/ecomap/index.js +3 -2
  110. package/dist/diagrams/entity/index.cjs +6 -6
  111. package/dist/diagrams/entity/index.d.cts +1 -1
  112. package/dist/diagrams/entity/index.d.ts +1 -1
  113. package/dist/diagrams/entity/index.js +2 -2
  114. package/dist/diagrams/fishbone/index.cjs +8 -8
  115. package/dist/diagrams/fishbone/index.d.cts +1 -1
  116. package/dist/diagrams/fishbone/index.d.ts +1 -1
  117. package/dist/diagrams/fishbone/index.js +2 -2
  118. package/dist/diagrams/flowchart/index.cjs +8 -8
  119. package/dist/diagrams/flowchart/index.d.cts +2 -2
  120. package/dist/diagrams/flowchart/index.d.ts +2 -2
  121. package/dist/diagrams/flowchart/index.js +2 -2
  122. package/dist/diagrams/genogram/index.cjs +10 -9
  123. package/dist/diagrams/genogram/index.d.cts +1 -1
  124. package/dist/diagrams/genogram/index.d.ts +1 -1
  125. package/dist/diagrams/genogram/index.js +3 -2
  126. package/dist/diagrams/ladder/index.cjs +6 -6
  127. package/dist/diagrams/ladder/index.d.cts +1 -1
  128. package/dist/diagrams/ladder/index.d.ts +1 -1
  129. package/dist/diagrams/ladder/index.js +2 -2
  130. package/dist/diagrams/logic/index.cjs +6 -6
  131. package/dist/diagrams/logic/index.d.cts +1 -1
  132. package/dist/diagrams/logic/index.d.ts +1 -1
  133. package/dist/diagrams/logic/index.js +2 -2
  134. package/dist/diagrams/orgchart/index.cjs +7 -7
  135. package/dist/diagrams/orgchart/index.d.cts +5 -2
  136. package/dist/diagrams/orgchart/index.d.ts +5 -2
  137. package/dist/diagrams/orgchart/index.js +2 -2
  138. package/dist/diagrams/pedigree/index.cjs +8 -7
  139. package/dist/diagrams/pedigree/index.d.cts +1 -1
  140. package/dist/diagrams/pedigree/index.d.ts +1 -1
  141. package/dist/diagrams/pedigree/index.js +3 -2
  142. package/dist/diagrams/phylo/index.cjs +7 -7
  143. package/dist/diagrams/phylo/index.d.cts +1 -1
  144. package/dist/diagrams/phylo/index.d.ts +1 -1
  145. package/dist/diagrams/phylo/index.js +2 -2
  146. package/dist/diagrams/sld/index.cjs +6 -6
  147. package/dist/diagrams/sld/index.d.cts +1 -1
  148. package/dist/diagrams/sld/index.d.ts +1 -1
  149. package/dist/diagrams/sld/index.js +2 -2
  150. package/dist/diagrams/sociogram/index.cjs +7 -6
  151. package/dist/diagrams/sociogram/index.d.cts +2 -1
  152. package/dist/diagrams/sociogram/index.d.ts +2 -1
  153. package/dist/diagrams/sociogram/index.js +3 -2
  154. package/dist/diagrams/timing/index.cjs +4 -4
  155. package/dist/diagrams/timing/index.d.cts +1 -1
  156. package/dist/diagrams/timing/index.d.ts +1 -1
  157. package/dist/diagrams/timing/index.js +1 -1
  158. package/dist/diagrams/venn/index.cjs +9 -9
  159. package/dist/diagrams/venn/index.d.cts +1 -1
  160. package/dist/diagrams/venn/index.d.ts +1 -1
  161. package/dist/diagrams/venn/index.js +2 -2
  162. package/dist/{index-ga04CTBI.d.ts → index-C97K-kuw.d.ts} +1 -1
  163. package/dist/{index-SSGpCggE.d.cts → index-lsSaw3E0.d.cts} +1 -1
  164. package/dist/index.cjs +50 -49
  165. package/dist/index.d.cts +2 -2
  166. package/dist/index.d.ts +2 -2
  167. package/dist/index.js +19 -18
  168. package/dist/react.cjs +20 -19
  169. package/dist/react.cjs.map +1 -1
  170. package/dist/react.js +19 -18
  171. package/dist/react.js.map +1 -1
  172. package/dist/{types-BcPhMdHd.d.cts → types-C4LnMEcB.d.cts} +58 -4
  173. package/dist/{types-BcPhMdHd.d.ts → types-C4LnMEcB.d.ts} +58 -4
  174. package/package.json +30 -7
  175. package/dist/chunk-5SH5NUDW.js.map +0 -1
  176. package/dist/chunk-7WXAAVR3.js.map +0 -1
  177. package/dist/chunk-A74ZCP5I.js.map +0 -1
  178. package/dist/chunk-AMP2FFES.cjs.map +0 -1
  179. package/dist/chunk-CEV3GZA3.cjs.map +0 -1
  180. package/dist/chunk-DTMCQXXC.cjs.map +0 -1
  181. package/dist/chunk-GEPBET4L.js.map +0 -1
  182. package/dist/chunk-HAIBAF6J.cjs.map +0 -1
  183. package/dist/chunk-HLYA4QBB.js.map +0 -1
  184. package/dist/chunk-IMHR3S5H.cjs.map +0 -1
  185. package/dist/chunk-IQIJ6WW6.js.map +0 -1
  186. package/dist/chunk-IY52OWPG.cjs.map +0 -1
  187. package/dist/chunk-JZGFSRVT.js.map +0 -1
  188. package/dist/chunk-L6IHSTPP.js.map +0 -1
  189. package/dist/chunk-LKHWBDWZ.cjs.map +0 -1
  190. package/dist/chunk-LXNFVHDT.cjs.map +0 -1
  191. package/dist/chunk-M6AMNXQ7.js.map +0 -1
  192. package/dist/chunk-RQX53J6M.js.map +0 -1
  193. package/dist/chunk-S6VPECM3.cjs.map +0 -1
  194. package/dist/chunk-TIGP2OEJ.js.map +0 -1
  195. package/dist/chunk-TPA36ULU.js.map +0 -1
  196. package/dist/chunk-ULERCTGS.cjs.map +0 -1
  197. package/dist/chunk-VP54YPOX.cjs.map +0 -1
  198. package/dist/chunk-YO4GU6JX.js.map +0 -1
  199. package/dist/chunk-ZGKEFVJQ.cjs.map +0 -1
  200. package/dist/chunk-ZO77FHBF.cjs.map +0 -1
@@ -1,32 +1,36 @@
1
1
  'use strict';
2
2
 
3
- var chunkIY52OWPG_cjs = require('./chunk-IY52OWPG.cjs');
4
- var chunkHKRYKEOV_cjs = require('./chunk-HKRYKEOV.cjs');
5
- var chunkLXNFVHDT_cjs = require('./chunk-LXNFVHDT.cjs');
6
- var chunkLKHWBDWZ_cjs = require('./chunk-LKHWBDWZ.cjs');
7
- var chunkULERCTGS_cjs = require('./chunk-ULERCTGS.cjs');
8
- var chunkPIQG2Z5N_cjs = require('./chunk-PIQG2Z5N.cjs');
9
- var chunkIMHR3S5H_cjs = require('./chunk-IMHR3S5H.cjs');
10
- var chunk3M7QWADF_cjs = require('./chunk-3M7QWADF.cjs');
11
- var chunkHAIBAF6J_cjs = require('./chunk-HAIBAF6J.cjs');
12
- var chunkCEV3GZA3_cjs = require('./chunk-CEV3GZA3.cjs');
13
- var chunkZGKEFVJQ_cjs = require('./chunk-ZGKEFVJQ.cjs');
14
- var chunkAMP2FFES_cjs = require('./chunk-AMP2FFES.cjs');
15
- var chunkYKO7DY2F_cjs = require('./chunk-YKO7DY2F.cjs');
16
- var chunkDTMCQXXC_cjs = require('./chunk-DTMCQXXC.cjs');
17
- var chunkZO77FHBF_cjs = require('./chunk-ZO77FHBF.cjs');
18
- var chunk4HPT4BOI_cjs = require('./chunk-4HPT4BOI.cjs');
19
- var chunkS6VPECM3_cjs = require('./chunk-S6VPECM3.cjs');
3
+ var chunkA5D2IMOX_cjs = require('./chunk-A5D2IMOX.cjs');
4
+ var chunk4S2WILLW_cjs = require('./chunk-4S2WILLW.cjs');
5
+ var chunkMCFQAUQV_cjs = require('./chunk-MCFQAUQV.cjs');
6
+ var chunkB6INLQBU_cjs = require('./chunk-B6INLQBU.cjs');
7
+ var chunk3YZ6FPQW_cjs = require('./chunk-3YZ6FPQW.cjs');
8
+ var chunkZNOD4VZT_cjs = require('./chunk-ZNOD4VZT.cjs');
9
+ var chunk5AEN2PLB_cjs = require('./chunk-5AEN2PLB.cjs');
10
+ var chunkQSQX77S2_cjs = require('./chunk-QSQX77S2.cjs');
11
+ var chunkZ3DE6S64_cjs = require('./chunk-Z3DE6S64.cjs');
12
+ var chunk6LZJTAA3_cjs = require('./chunk-6LZJTAA3.cjs');
13
+ var chunkE65ITQXV_cjs = require('./chunk-E65ITQXV.cjs');
14
+ var chunkB37IKTI7_cjs = require('./chunk-B37IKTI7.cjs');
15
+ var chunkX7RPFTTR_cjs = require('./chunk-X7RPFTTR.cjs');
16
+ var chunkCOLTVQWR_cjs = require('./chunk-COLTVQWR.cjs');
17
+ var chunk2JDVJRR3_cjs = require('./chunk-2JDVJRR3.cjs');
18
+ var chunkWYFXOXVK_cjs = require('./chunk-WYFXOXVK.cjs');
19
+ var chunkD7EHZFK4_cjs = require('./chunk-D7EHZFK4.cjs');
20
20
  var chunkHDKDQAEQ_cjs = require('./chunk-HDKDQAEQ.cjs');
21
21
 
22
22
  // src/diagrams/decisiontree/parser.ts
23
23
  var DTreeParseError = class extends Error {
24
- constructor(message, line2) {
24
+ constructor(message, line2, column, source) {
25
25
  super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
26
26
  this.line = line2;
27
+ this.column = column;
28
+ this.source = source;
27
29
  this.name = "DTreeParseError";
28
30
  }
29
31
  line;
32
+ column;
33
+ source;
30
34
  };
31
35
  function preprocess(src) {
32
36
  const out = [];
@@ -1074,7 +1078,7 @@ function wrapText(text2, maxChars) {
1074
1078
  return lines.slice(0, 2);
1075
1079
  }
1076
1080
  function renderDecisionTree(ast, config) {
1077
- const t = chunkS6VPECM3_cjs.resolveBaseTheme(config?.theme ?? "default");
1081
+ const t = chunkD7EHZFK4_cjs.resolveBaseTheme(config?.theme ?? "default");
1078
1082
  const layout = layoutDecisionTree(ast);
1079
1083
  const titleOffset = ast.title ? 36 : 10;
1080
1084
  const width = Math.ceil(layout.width);
@@ -1227,12 +1231,16 @@ function formatYear(value, span) {
1227
1231
 
1228
1232
  // src/diagrams/timeline/parser.ts
1229
1233
  var TimelineParseError = class extends Error {
1230
- constructor(message, line2) {
1234
+ constructor(message, line2, column, source) {
1231
1235
  super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
1232
1236
  this.line = line2;
1237
+ this.column = column;
1238
+ this.source = source;
1233
1239
  this.name = "TimelineParseError";
1234
1240
  }
1235
1241
  line;
1242
+ column;
1243
+ source;
1236
1244
  };
1237
1245
  function preprocess2(src) {
1238
1246
  const out = [];
@@ -2097,7 +2105,7 @@ var ERA_ROW_GAP = 2;
2097
2105
  function renderTimeline(src, config) {
2098
2106
  const ast = parseTimeline(src);
2099
2107
  const layout = layoutTimeline(ast);
2100
- const theme = chunkS6VPECM3_cjs.resolveTimelineTheme(config?.theme ?? "default");
2108
+ const theme = chunkD7EHZFK4_cjs.resolveTimelineTheme(config?.theme ?? "default");
2101
2109
  const styleBlock = styleForTheme(theme, config?.fontFamily);
2102
2110
  const children = [
2103
2111
  chunkHDKDQAEQ_cjs.title(ast.title ? `Timeline \u2014 ${ast.title}` : "Timeline"),
@@ -2142,7 +2150,7 @@ function renderTimeline(src, config) {
2142
2150
  function styleForTheme(theme, fontFamily) {
2143
2151
  const font = fontFamily ?? "system-ui, -apple-system, sans-serif";
2144
2152
  return `
2145
- .st-timeline { ${chunkS6VPECM3_cjs.cssCustomProperties(theme)}
2153
+ .st-timeline { ${chunkD7EHZFK4_cjs.cssCustomProperties(theme)}
2146
2154
  --st-axis: ${theme.axis};
2147
2155
  --st-axis-label: ${theme.axisLabel};
2148
2156
  --st-era-label: ${theme.eraLabel};
@@ -2620,8 +2628,193 @@ var timeline = {
2620
2628
  }
2621
2629
  };
2622
2630
 
2631
+ // src/diagrams/mindmap/inline.ts
2632
+ var RE_TASK = /^\[( |x|X)\]\s+(.*)$/;
2633
+ function tokenizeInline(raw) {
2634
+ const tokens = [];
2635
+ let text2 = raw;
2636
+ const task = text2.match(RE_TASK);
2637
+ if (task) {
2638
+ tokens.push({ kind: "checkbox", checked: task[1].toLowerCase() === "x" });
2639
+ text2 = task[2];
2640
+ }
2641
+ parseInto(text2, tokens, { bold: false, italic: false });
2642
+ return tokens;
2643
+ }
2644
+ function parseInto(src, out, style) {
2645
+ let i = 0;
2646
+ let plain = "";
2647
+ const flushPlain = () => {
2648
+ if (plain.length === 0) return;
2649
+ out.push({ kind: "text", value: plain, bold: style.bold || void 0, italic: style.italic || void 0 });
2650
+ plain = "";
2651
+ };
2652
+ while (i < src.length) {
2653
+ const ch = src[i];
2654
+ if (ch === "`") {
2655
+ const end = src.indexOf("`", i + 1);
2656
+ if (end > i) {
2657
+ flushPlain();
2658
+ out.push({ kind: "code", value: src.slice(i + 1, end) });
2659
+ i = end + 1;
2660
+ continue;
2661
+ }
2662
+ }
2663
+ if (ch === "[") {
2664
+ const closeBracket = findUnescaped(src, "]", i + 1);
2665
+ if (closeBracket > 0 && src[closeBracket + 1] === "(") {
2666
+ const closeParen = findUnescaped(src, ")", closeBracket + 2);
2667
+ if (closeParen > 0) {
2668
+ flushPlain();
2669
+ const inner = [];
2670
+ parseInto(src.slice(i + 1, closeBracket), inner, style);
2671
+ out.push({ kind: "link", href: src.slice(closeBracket + 2, closeParen), value: inner });
2672
+ i = closeParen + 1;
2673
+ continue;
2674
+ }
2675
+ }
2676
+ }
2677
+ if (ch === "*" && src[i + 1] === "*") {
2678
+ const end = src.indexOf("**", i + 2);
2679
+ if (end > i) {
2680
+ flushPlain();
2681
+ parseInto(src.slice(i + 2, end), out, { ...style, bold: true });
2682
+ i = end + 2;
2683
+ continue;
2684
+ }
2685
+ }
2686
+ if (ch === "*") {
2687
+ const end = src.indexOf("*", i + 1);
2688
+ if (end > i && src[end + 1] !== "*") {
2689
+ flushPlain();
2690
+ parseInto(src.slice(i + 1, end), out, { ...style, italic: true });
2691
+ i = end + 1;
2692
+ continue;
2693
+ }
2694
+ }
2695
+ plain += ch;
2696
+ i++;
2697
+ }
2698
+ flushPlain();
2699
+ }
2700
+ function findUnescaped(s, ch, from) {
2701
+ for (let i = from; i < s.length; i++) {
2702
+ if (s[i] === "\\") {
2703
+ i++;
2704
+ continue;
2705
+ }
2706
+ if (s[i] === ch) return i;
2707
+ }
2708
+ return -1;
2709
+ }
2710
+ var EM_REGULAR = 0.58;
2711
+ var EM_BOLD = 0.62;
2712
+ var EM_CODE = 0.62;
2713
+ var CHECKBOX_EM = 1.05;
2714
+ function measureTokens(tokens, fontSize) {
2715
+ let w = 0;
2716
+ for (const t of tokens) {
2717
+ w += tokenWidth(t, fontSize);
2718
+ }
2719
+ return w;
2720
+ }
2721
+ function tokenWidth(t, fs) {
2722
+ switch (t.kind) {
2723
+ case "text": {
2724
+ const em = t.bold ? EM_BOLD : EM_REGULAR;
2725
+ return t.value.length * fs * em;
2726
+ }
2727
+ case "code":
2728
+ return t.value.length * fs * EM_CODE + 4;
2729
+ case "link":
2730
+ return measureTokens(t.value, fs);
2731
+ case "checkbox":
2732
+ return fs * CHECKBOX_EM;
2733
+ }
2734
+ }
2735
+ function tokensToPlainText(tokens) {
2736
+ let out = "";
2737
+ for (const t of tokens) {
2738
+ switch (t.kind) {
2739
+ case "text":
2740
+ case "code":
2741
+ out += t.value;
2742
+ break;
2743
+ case "link":
2744
+ out += tokensToPlainText(t.value);
2745
+ break;
2746
+ case "checkbox":
2747
+ out += t.checked ? "[x] " : "[ ] ";
2748
+ break;
2749
+ }
2750
+ }
2751
+ return out;
2752
+ }
2753
+ function wrapTokens(tokens, maxWidth, fontSize) {
2754
+ const lines = [];
2755
+ let line2 = [];
2756
+ let lineW = 0;
2757
+ const pushLine = () => {
2758
+ lines.push({ tokens: line2, width: lineW });
2759
+ line2 = [];
2760
+ lineW = 0;
2761
+ };
2762
+ const pushAtomic = (t, w) => {
2763
+ if (lineW > 0 && lineW + w > maxWidth) pushLine();
2764
+ line2.push(t);
2765
+ lineW += w;
2766
+ };
2767
+ for (const t of tokens) {
2768
+ if (t.kind === "text") {
2769
+ const words = splitWordsWithTrailingSpace(t.value);
2770
+ for (const w of words) {
2771
+ const wt = { kind: "text", value: w, bold: t.bold, italic: t.italic };
2772
+ const ww = tokenWidth(wt, fontSize);
2773
+ if (lineW > 0 && lineW + ww > maxWidth) {
2774
+ pushLine();
2775
+ const trimmed = w.replace(/^ +/, "");
2776
+ if (trimmed.length === 0) continue;
2777
+ const tt = { kind: "text", value: trimmed, bold: t.bold, italic: t.italic };
2778
+ line2.push(tt);
2779
+ lineW = tokenWidth(tt, fontSize);
2780
+ } else {
2781
+ line2.push(wt);
2782
+ lineW += ww;
2783
+ }
2784
+ }
2785
+ } else {
2786
+ pushAtomic(t, tokenWidth(t, fontSize));
2787
+ }
2788
+ }
2789
+ pushLine();
2790
+ return lines;
2791
+ }
2792
+ function splitWordsWithTrailingSpace(s) {
2793
+ if (s.length === 0) return [];
2794
+ const out = [];
2795
+ const re = /(\S+\s*)|(\s+)/g;
2796
+ let m;
2797
+ while ((m = re.exec(s)) !== null) {
2798
+ out.push(m[0]);
2799
+ }
2800
+ return out.length > 0 ? out : [s];
2801
+ }
2802
+
2623
2803
  // src/diagrams/mindmap/parser.ts
2804
+ var MindmapParseError = class extends Error {
2805
+ constructor(message, line2, column, source) {
2806
+ super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
2807
+ this.line = line2;
2808
+ this.column = column;
2809
+ this.source = source;
2810
+ this.name = "MindmapParseError";
2811
+ }
2812
+ line;
2813
+ column;
2814
+ source;
2815
+ };
2624
2816
  var VALID_STYLES = ["map", "logic-right"];
2817
+ var DEFAULT_MAX_LABEL_WIDTH = 240;
2625
2818
  function parseDirective(line2, out) {
2626
2819
  const body = line2.replace(/^%%\s*/, "").trim();
2627
2820
  const idx = body.indexOf(":");
@@ -2632,26 +2825,39 @@ function parseDirective(line2, out) {
2632
2825
  out.style = val;
2633
2826
  } else if (key === "theme") {
2634
2827
  out.themeOverride = val;
2828
+ } else if (key === "maxlabelwidth") {
2829
+ const n = Number(val);
2830
+ if (Number.isFinite(n) && n >= 80 && n <= 1e3) out.maxLabelWidth = n;
2635
2831
  }
2636
2832
  }
2833
+ function makeNode(id, label, depth) {
2834
+ return { id, label, tokens: tokenizeInline(label), depth, children: [] };
2835
+ }
2637
2836
  function parseMindmap(text2) {
2638
- const lines = text2.split(/\r?\n/);
2639
- if (lines[0]?.trim().toLowerCase() === "mindmap") lines.shift();
2640
- const directives = { style: "map" };
2837
+ const allLines = text2.split(/\r?\n/);
2838
+ let lineOffset = 0;
2839
+ if (allLines[0]?.trim().toLowerCase() === "mindmap") {
2840
+ allLines.shift();
2841
+ lineOffset = 1;
2842
+ }
2843
+ const lines = allLines;
2844
+ const directives = { style: "map", maxLabelWidth: DEFAULT_MAX_LABEL_WIDTH };
2641
2845
  let root = null;
2642
2846
  let idCounter2 = 0;
2643
2847
  const nextId2 = () => `n${idCounter2++}`;
2644
2848
  const stack = [];
2645
2849
  let lastHeadingDepth = 0;
2646
- const attach = (node, depth) => {
2850
+ const attach = (node, depth, lineNo, source) => {
2647
2851
  while (stack.length && stack[stack.length - 1].depth >= depth) stack.pop();
2648
2852
  const parent = stack[stack.length - 1]?.node;
2649
- if (!parent) throw new Error("Mindmap: orphan node \u2014 expected root # heading first");
2853
+ if (!parent) throw new MindmapParseError("orphan node \u2014 expected root # heading first", lineNo, void 0, source);
2650
2854
  node.depth = parent.depth + 1;
2651
2855
  parent.children.push(node);
2652
2856
  stack.push({ node, depth });
2653
2857
  };
2654
- for (const raw of lines) {
2858
+ for (let i = 0; i < lines.length; i++) {
2859
+ const raw = lines[i] ?? "";
2860
+ const lineNo = i + 1 + lineOffset;
2655
2861
  const line2 = raw.replace(/\s+$/, "");
2656
2862
  const trimmed = line2.trim();
2657
2863
  if (!trimmed) continue;
@@ -2663,14 +2869,14 @@ function parseMindmap(text2) {
2663
2869
  if (heading) {
2664
2870
  const depth = heading[1].length - 1;
2665
2871
  const label = heading[2].trim();
2666
- const node = { id: nextId2(), label, depth, children: [] };
2872
+ const node = makeNode(nextId2(), label, depth);
2667
2873
  if (depth === 0) {
2668
- if (root) throw new Error("Mindmap: multiple `#` center nodes not allowed");
2874
+ if (root) throw new MindmapParseError("multiple `#` center nodes not allowed", lineNo, void 0, line2);
2669
2875
  root = node;
2670
2876
  stack.length = 0;
2671
2877
  stack.push({ node, depth: 0 });
2672
2878
  } else {
2673
- attach(node, depth);
2879
+ attach(node, depth, lineNo, line2);
2674
2880
  }
2675
2881
  lastHeadingDepth = depth;
2676
2882
  continue;
@@ -2680,16 +2886,17 @@ function parseMindmap(text2) {
2680
2886
  const indent = bullet[1].length;
2681
2887
  const depth = lastHeadingDepth + 1 + Math.floor(indent / 2);
2682
2888
  const label = bullet[2].trim();
2683
- const node = { id: nextId2(), label, depth, children: [] };
2684
- attach(node, depth);
2889
+ const node = makeNode(nextId2(), label, depth);
2890
+ attach(node, depth, lineNo, line2);
2685
2891
  continue;
2686
2892
  }
2687
2893
  }
2688
- if (!root) throw new Error("Mindmap: missing central topic \u2014 start with `# Title`");
2894
+ if (!root) throw new MindmapParseError("missing central topic \u2014 start with `# Title`");
2689
2895
  const ast = {
2690
2896
  type: "mindmap",
2691
2897
  style: directives.style,
2692
- root
2898
+ root,
2899
+ maxLabelWidth: directives.maxLabelWidth
2693
2900
  };
2694
2901
  if (directives.themeOverride) ast.themeOverride = directives.themeOverride;
2695
2902
  return ast;
@@ -2697,10 +2904,10 @@ function parseMindmap(text2) {
2697
2904
 
2698
2905
  // src/diagrams/mindmap/layout.ts
2699
2906
  var PADDING = 40;
2700
- var SIBLING_GAP = 20;
2907
+ var SIBLING_GAP = 18;
2701
2908
  var MAIN_GAP = 44;
2702
- var ROOT_CAPSULE_PAD_X = 10;
2703
- var ROOT_CAPSULE_PAD_Y = 10;
2909
+ var UNDERLINE_GAP = 4;
2910
+ var LINE_GAP = 4;
2704
2911
  function bezierGapFor(childDepth) {
2705
2912
  if (childDepth <= 1) return 90;
2706
2913
  if (childDepth === 2) return 60;
@@ -2714,47 +2921,68 @@ function fontSizeOf(depth) {
2714
2921
  if (depth === 1) return FONT_MAIN;
2715
2922
  return FONT_SUB;
2716
2923
  }
2717
- function estimateLabelWidth2(label, depth) {
2718
- return Math.max(32, label.length * fontSizeOf(depth) * 0.58);
2924
+ function lineHeightOf(fs) {
2925
+ return fs + LINE_GAP;
2719
2926
  }
2720
- function rowHeightOf(depth) {
2721
- return fontSizeOf(depth) + 14;
2927
+ function widthBudget(depth, maxLabelWidth) {
2928
+ if (depth === 0) return maxLabelWidth * 1.5;
2929
+ return maxLabelWidth;
2930
+ }
2931
+ function measureLabel(node, maxWidth) {
2932
+ const fs = fontSizeOf(node.depth);
2933
+ const raw = measureTokens(node.tokens, fs);
2934
+ let lines;
2935
+ if (raw <= maxWidth) {
2936
+ lines = [{ tokens: node.tokens.slice(), width: raw }];
2937
+ } else {
2938
+ lines = wrapTokens(node.tokens, maxWidth, fs);
2939
+ }
2940
+ let maxW = 0;
2941
+ for (const ln of lines) if (ln.width > maxW) maxW = ln.width;
2942
+ const lh = lineHeightOf(fs);
2943
+ const height = lines.length * lh + UNDERLINE_GAP;
2944
+ return { lines, width: Math.max(32, maxW), height };
2722
2945
  }
2723
- function computeColumns(subtreeRoots, firstColStartX) {
2946
+ function computeMaxLW(subtreeRoots, maxLabelWidth) {
2724
2947
  const maxLW = [];
2725
2948
  const walk = (n) => {
2726
- const lw = estimateLabelWidth2(n.label, n.depth);
2727
- if (maxLW[n.depth] === void 0 || lw > maxLW[n.depth]) maxLW[n.depth] = lw;
2949
+ const m = measureLabel(n, widthBudget(n.depth, maxLabelWidth));
2950
+ if (maxLW[n.depth] === void 0 || m.width > maxLW[n.depth]) maxLW[n.depth] = m.width;
2728
2951
  for (const c of n.children) walk(c);
2729
2952
  };
2730
2953
  for (const r of subtreeRoots) walk(r);
2954
+ return maxLW;
2955
+ }
2956
+ function buildColumns(maxLW, firstColStartX, rootDepth) {
2731
2957
  const center = [];
2732
- if (subtreeRoots.length === 0) return { center };
2733
- const rootDepth = subtreeRoots[0].depth;
2958
+ if (maxLW[rootDepth] === void 0) return { center };
2734
2959
  let slotLeft = firstColStartX;
2735
2960
  center[rootDepth] = slotLeft + maxLW[rootDepth] / 2;
2736
2961
  for (let d = rootDepth + 1; d < maxLW.length; d++) {
2737
2962
  slotLeft = slotLeft + maxLW[d - 1] + bezierGapFor(d);
2738
- center[d] = slotLeft + maxLW[d] / 2;
2963
+ center[d] = slotLeft + (maxLW[d] ?? 0) / 2;
2739
2964
  }
2740
2965
  return { center };
2741
2966
  }
2742
- function tidyRight(node, yTop, branchIdx, columns, out) {
2743
- const rowH = rowHeightOf(node.depth);
2744
- const lw = estimateLabelWidth2(node.label, node.depth);
2967
+ function tidyRight(node, yTop, branchIdx, columns, maxLabelWidth, maxLW, out) {
2968
+ const m = measureLabel(node, widthBudget(node.depth, maxLabelWidth));
2745
2969
  const x = columns.center[node.depth];
2970
+ const fs = fontSizeOf(node.depth);
2971
+ const labelWidth = Math.max(m.width, maxLW[node.depth] ?? m.width);
2746
2972
  if (node.children.length === 0) {
2747
2973
  const ln2 = {
2748
2974
  node,
2749
2975
  x,
2750
- y: yTop + rowH / 2,
2976
+ y: yTop + m.height / 2,
2751
2977
  side: "right",
2752
2978
  branchIndex: branchIdx,
2753
- labelWidth: lw,
2754
- labelHeight: rowH
2979
+ labelWidth,
2980
+ labelHeight: m.height,
2981
+ fontSize: fs,
2982
+ lines: m.lines
2755
2983
  };
2756
2984
  out.push(ln2);
2757
- return { layoutNode: ln2, height: rowH };
2985
+ return { layoutNode: ln2, height: m.height };
2758
2986
  }
2759
2987
  let cursor = yTop;
2760
2988
  const childLayouts = [];
@@ -2765,12 +2993,14 @@ function tidyRight(node, yTop, branchIdx, columns, out) {
2765
2993
  cursor,
2766
2994
  branchIdx,
2767
2995
  columns,
2996
+ maxLabelWidth,
2997
+ maxLW,
2768
2998
  out
2769
2999
  );
2770
3000
  childLayouts.push(cln);
2771
3001
  cursor += height;
2772
3002
  }
2773
- const totalH = Math.max(rowH, cursor - yTop);
3003
+ const totalH = Math.max(m.height, cursor - yTop);
2774
3004
  const firstY = childLayouts[0].y;
2775
3005
  const lastY = childLayouts[childLayouts.length - 1].y;
2776
3006
  const parentY = (firstY + lastY) / 2;
@@ -2780,8 +3010,10 @@ function tidyRight(node, yTop, branchIdx, columns, out) {
2780
3010
  y: parentY,
2781
3011
  side: "right",
2782
3012
  branchIndex: branchIdx,
2783
- labelWidth: lw,
2784
- labelHeight: rowH
3013
+ labelWidth,
3014
+ labelHeight: m.height,
3015
+ fontSize: fs,
3016
+ lines: m.lines
2785
3017
  };
2786
3018
  out.push(ln);
2787
3019
  return { layoutNode: ln, height: totalH };
@@ -2796,7 +3028,15 @@ function bezierH(x1, y1, x2, y2) {
2796
3028
  return `M ${x1.toFixed(1)} ${y1.toFixed(1)} C ${(x1 + k).toFixed(1)} ${y1.toFixed(1)}, ${(x2 - k).toFixed(1)} ${y2.toFixed(1)}, ${x2.toFixed(1)} ${y2.toFixed(1)}`;
2797
3029
  }
2798
3030
  function edgeWidthFor(depth) {
2799
- return depth <= 1 ? 2.2 : 1.4;
3031
+ if (depth <= 1) return 2.2;
3032
+ if (depth === 2) return 1.6;
3033
+ return 1.2;
3034
+ }
3035
+ function underlineWidthFor(depth) {
3036
+ if (depth === 0) return 2.4;
3037
+ if (depth === 1) return 2.2;
3038
+ if (depth === 2) return 1.6;
3039
+ return 1.2;
2800
3040
  }
2801
3041
  function normalize(nodes) {
2802
3042
  let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
@@ -2807,8 +3047,8 @@ function normalize(nodes) {
2807
3047
  const rightX = n.x + lw / 2;
2808
3048
  minX = Math.min(minX, leftX);
2809
3049
  maxX = Math.max(maxX, rightX);
2810
- minY = Math.min(minY, n.y - lh);
2811
- maxY = Math.max(maxY, n.y + lh);
3050
+ minY = Math.min(minY, n.y - lh / 2);
3051
+ maxY = Math.max(maxY, n.y + lh / 2);
2812
3052
  }
2813
3053
  const dx = PADDING - minX;
2814
3054
  const dy = PADDING - minY;
@@ -2818,10 +3058,14 @@ function normalize(nodes) {
2818
3058
  }
2819
3059
  return { width: maxX - minX + PADDING * 2, height: maxY - minY + PADDING * 2 };
2820
3060
  }
3061
+ function underlineY(n) {
3062
+ return n.y + n.labelHeight / 2 - UNDERLINE_GAP / 2;
3063
+ }
2821
3064
  function buildEdges(root, byId) {
2822
3065
  const edges = [];
2823
3066
  const walk = (parent) => {
2824
3067
  const pln = byId.get(parent.id);
3068
+ const pUY = underlineY(pln);
2825
3069
  for (const c of parent.children) {
2826
3070
  const cln = byId.get(c.id);
2827
3071
  let fromX;
@@ -2835,7 +3079,7 @@ function buildEdges(root, byId) {
2835
3079
  edges.push({
2836
3080
  from: parent.id,
2837
3081
  to: c.id,
2838
- path: bezierH(fromX, pln.y, toX, cln.y),
3082
+ path: bezierH(fromX, pUY, toX, underlineY(cln)),
2839
3083
  color: "",
2840
3084
  width: edgeWidthFor(c.depth)
2841
3085
  });
@@ -2852,24 +3096,23 @@ function layoutMap(ast) {
2852
3096
  const rightMains = mains.slice(0, rightCount);
2853
3097
  const leftMains = mains.slice(rightCount);
2854
3098
  const nodes = [];
2855
- const rootLabelW = estimateLabelWidth2(root.label, 0);
2856
- const rootCapsuleW = rootLabelW + ROOT_CAPSULE_PAD_X * 2;
2857
- const rootCapsuleH = rowHeightOf(0) + ROOT_CAPSULE_PAD_Y;
2858
- const firstColLeft = rootCapsuleW / 2 + bezierGapFor(1);
2859
- const rightCols = computeColumns(rightMains, firstColLeft);
3099
+ const mw = ast.maxLabelWidth;
3100
+ const rootM = measureLabel(root, widthBudget(0, mw));
3101
+ const firstColLeft = rootM.width / 2 + bezierGapFor(1);
3102
+ const maxLW = computeMaxLW([...rightMains, ...leftMains], mw);
3103
+ const cols = buildColumns(maxLW, firstColLeft, 1);
2860
3104
  let rightCursor = 0;
2861
3105
  for (let i = 0; i < rightMains.length; i++) {
2862
3106
  if (i > 0) rightCursor += MAIN_GAP;
2863
- const { height: height2 } = tidyRight(rightMains[i], rightCursor, i, rightCols, nodes);
3107
+ const { height: height2 } = tidyRight(rightMains[i], rightCursor, i, cols, mw, maxLW, nodes);
2864
3108
  rightCursor += height2;
2865
3109
  }
2866
3110
  const rightHeight = rightCursor;
2867
- const leftCols = computeColumns(leftMains, firstColLeft);
2868
3111
  const leftStart = nodes.length;
2869
3112
  let leftCursor = 0;
2870
3113
  for (let i = 0; i < leftMains.length; i++) {
2871
3114
  if (i > 0) leftCursor += MAIN_GAP;
2872
- const { height: height2 } = tidyRight(leftMains[i], leftCursor, rightCount + i, leftCols, nodes);
3115
+ const { height: height2 } = tidyRight(leftMains[i], leftCursor, rightCount + i, cols, mw, maxLW, nodes);
2873
3116
  leftCursor += height2;
2874
3117
  }
2875
3118
  const leftHeight = leftCursor;
@@ -2884,8 +3127,10 @@ function layoutMap(ast) {
2884
3127
  y: rootY,
2885
3128
  side: "center",
2886
3129
  branchIndex: -1,
2887
- labelWidth: rootCapsuleW,
2888
- labelHeight: rootCapsuleH
3130
+ labelWidth: rootM.width,
3131
+ labelHeight: rootM.height,
3132
+ fontSize: fontSizeOf(0),
3133
+ lines: rootM.lines
2889
3134
  };
2890
3135
  nodes.push(rootNode);
2891
3136
  const { width, height } = normalize(nodes);
@@ -2896,15 +3141,15 @@ function layoutMap(ast) {
2896
3141
  function layoutLogicRight(ast) {
2897
3142
  const root = ast.root;
2898
3143
  const nodes = [];
2899
- const rootLabelW = estimateLabelWidth2(root.label, 0);
2900
- const rootCapsuleW = rootLabelW + ROOT_CAPSULE_PAD_X * 2;
2901
- const rootCapsuleH = rowHeightOf(0) + ROOT_CAPSULE_PAD_Y;
2902
- const firstColLeft = rootCapsuleW / 2 + bezierGapFor(1);
2903
- const cols = computeColumns(root.children, firstColLeft);
3144
+ const mw = ast.maxLabelWidth;
3145
+ const rootM = measureLabel(root, widthBudget(0, mw));
3146
+ const firstColLeft = rootM.width / 2 + bezierGapFor(1);
3147
+ const maxLW = computeMaxLW(root.children, mw);
3148
+ const cols = buildColumns(maxLW, firstColLeft, 1);
2904
3149
  let cursor = 0;
2905
3150
  for (let i = 0; i < root.children.length; i++) {
2906
3151
  if (i > 0) cursor += MAIN_GAP;
2907
- const { height: height2 } = tidyRight(root.children[i], cursor, i, cols, nodes);
3152
+ const { height: height2 } = tidyRight(root.children[i], cursor, i, cols, mw, maxLW, nodes);
2908
3153
  cursor += height2;
2909
3154
  }
2910
3155
  const totalHeight = cursor;
@@ -2914,8 +3159,10 @@ function layoutLogicRight(ast) {
2914
3159
  y: totalHeight / 2,
2915
3160
  side: "center",
2916
3161
  branchIndex: -1,
2917
- labelWidth: rootCapsuleW,
2918
- labelHeight: rootCapsuleH
3162
+ labelWidth: rootM.width,
3163
+ labelHeight: rootM.height,
3164
+ fontSize: fontSizeOf(0),
3165
+ lines: rootM.lines
2919
3166
  };
2920
3167
  nodes.push(rootNode);
2921
3168
  const { width, height } = normalize(nodes);
@@ -2930,95 +3177,174 @@ function layoutMindmap(ast) {
2930
3177
  }
2931
3178
 
2932
3179
  // src/diagrams/mindmap/renderer.ts
2933
- var UNDERLINE_MAIN = 2.2;
2934
- var UNDERLINE_MAIN_MONO = 1.5;
3180
+ function strokeScale(theme) {
3181
+ return theme.branchPalette.length <= 1 ? 0.7 : 1;
3182
+ }
2935
3183
  function paletteColor(theme, branchIndex) {
2936
3184
  if (branchIndex < 0) return theme.centralFill;
2937
3185
  return theme.branchPalette[branchIndex % theme.branchPalette.length];
2938
3186
  }
2939
- function underlineMain(theme) {
2940
- return theme.branchPalette.length <= 1 ? UNDERLINE_MAIN_MONO : UNDERLINE_MAIN;
3187
+ function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
3188
+ const baselineY = cy + fontSize * 0.35;
3189
+ const tspans = [];
3190
+ const decorations = [];
3191
+ let cursor = leftX;
3192
+ const emit = (tok, inheritedHref) => {
3193
+ switch (tok.kind) {
3194
+ case "text": {
3195
+ const w = measureToken(tok, fontSize);
3196
+ tspans.push(
3197
+ tspan({
3198
+ x: cursor,
3199
+ y: baselineY,
3200
+ fill: inheritedHref ? theme.linkColor : theme.text,
3201
+ "font-weight": tok.bold ? 700 : fontWeight,
3202
+ "font-style": tok.italic ? "italic" : void 0,
3203
+ "text-decoration": inheritedHref ? "underline" : void 0
3204
+ }, tok.value)
3205
+ );
3206
+ cursor += w;
3207
+ break;
3208
+ }
3209
+ case "code": {
3210
+ const w = measureToken(tok, fontSize);
3211
+ decorations.push(chunkHDKDQAEQ_cjs.rect({
3212
+ x: cursor,
3213
+ y: cy - fontSize * 0.6,
3214
+ width: w,
3215
+ height: fontSize * 1.2,
3216
+ rx: 3,
3217
+ ry: 3,
3218
+ fill: theme.codeBg
3219
+ }));
3220
+ tspans.push(
3221
+ tspan({
3222
+ x: cursor + 2,
3223
+ y: baselineY,
3224
+ fill: theme.codeFg,
3225
+ "font-family": "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
3226
+ "font-size": fontSize * 0.92
3227
+ }, tok.value)
3228
+ );
3229
+ cursor += w;
3230
+ break;
3231
+ }
3232
+ case "link": {
3233
+ const aStart = `<a href="${chunkHDKDQAEQ_cjs.escapeXml(tok.href)}" target="_blank" rel="noopener">`;
3234
+ const innerStart = tspans.length;
3235
+ for (const inner of tok.value) emit(inner, tok.href);
3236
+ const innerTspans = tspans.splice(innerStart).join("");
3237
+ tspans.push(aStart + innerTspans + "</a>");
3238
+ break;
3239
+ }
3240
+ case "checkbox": {
3241
+ const size = fontSize * 0.85;
3242
+ const boxX = cursor;
3243
+ const boxY = cy - size / 2;
3244
+ decorations.push(chunkHDKDQAEQ_cjs.rect({
3245
+ x: boxX,
3246
+ y: boxY,
3247
+ width: size,
3248
+ height: size,
3249
+ rx: 2,
3250
+ ry: 2,
3251
+ fill: tok.checked ? theme.checkboxFill : "none",
3252
+ stroke: tok.checked ? theme.checkboxFill : theme.checkboxStroke,
3253
+ "stroke-width": 1.5
3254
+ }));
3255
+ if (tok.checked) {
3256
+ const p = `M ${(boxX + size * 0.2).toFixed(1)} ${(boxY + size * 0.5).toFixed(1)} L ${(boxX + size * 0.42).toFixed(1)} ${(boxY + size * 0.72).toFixed(1)} L ${(boxX + size * 0.82).toFixed(1)} ${(boxY + size * 0.28).toFixed(1)}`;
3257
+ decorations.push(chunkHDKDQAEQ_cjs.path({
3258
+ d: p,
3259
+ fill: "none",
3260
+ stroke: "#ffffff",
3261
+ "stroke-width": 2,
3262
+ "stroke-linecap": "round",
3263
+ "stroke-linejoin": "round"
3264
+ }));
3265
+ }
3266
+ cursor += size + fontSize * 0.25;
3267
+ break;
3268
+ }
3269
+ }
3270
+ };
3271
+ for (const tok of line2.tokens) emit(tok);
3272
+ const textElement = chunkHDKDQAEQ_cjs.el("text", {
3273
+ "font-family": fontFamily,
3274
+ "font-size": fontSize,
3275
+ "font-weight": fontWeight
3276
+ }, tspans.join(""));
3277
+ return { textElement, decorations };
3278
+ }
3279
+ function measureToken(tok, fs) {
3280
+ switch (tok.kind) {
3281
+ case "text":
3282
+ return tok.value.length * fs * (tok.bold ? 0.62 : 0.58);
3283
+ case "code":
3284
+ return tok.value.length * fs * 0.62 + 4;
3285
+ case "link": {
3286
+ let w = 0;
3287
+ for (const t of tok.value) w += measureToken(t, fs);
3288
+ return w;
3289
+ }
3290
+ case "checkbox":
3291
+ return fs * 0.85 + fs * 0.25;
3292
+ }
2941
3293
  }
2942
- function renderCentral(n, theme, fontFamily) {
2943
- const fs = fontSizeOf(0);
2944
- const pillW = n.labelWidth;
2945
- const pillH = n.labelHeight;
2946
- return chunkHDKDQAEQ_cjs.group(
2947
- { class: "schematex-mindmap-central", "data-node-id": n.node.id },
2948
- [
2949
- chunkHDKDQAEQ_cjs.rect({
2950
- x: n.x - pillW / 2,
2951
- y: n.y - pillH / 2,
2952
- width: pillW,
2953
- height: pillH,
2954
- rx: pillH / 2,
2955
- ry: pillH / 2,
2956
- fill: "none",
2957
- stroke: theme.textMuted,
2958
- "stroke-width": underlineMain(theme)
2959
- }),
2960
- chunkHDKDQAEQ_cjs.text(
2961
- {
2962
- x: n.x,
2963
- y: n.y + fs * 0.35,
2964
- "text-anchor": "middle",
2965
- "font-family": fontFamily,
2966
- "font-size": fs,
2967
- "font-weight": 700,
2968
- fill: theme.text
2969
- },
2970
- n.node.label
2971
- )
2972
- ]
2973
- );
3294
+ function tspan(attrs, content) {
3295
+ const pairs = [];
3296
+ for (const [k, v] of Object.entries(attrs)) {
3297
+ if (v === void 0) continue;
3298
+ pairs.push(`${k}="${typeof v === "number" ? String(v) : chunkHDKDQAEQ_cjs.escapeXml(String(v))}"`);
3299
+ }
3300
+ return `<tspan ${pairs.join(" ")}>${chunkHDKDQAEQ_cjs.escapeXml(content)}</tspan>`;
2974
3301
  }
2975
- function renderBranchNode(n, color, theme, fontFamily) {
3302
+ function renderNode(n, color, theme, fontFamily) {
3303
+ const isRoot = n.node.depth === 0;
2976
3304
  const isMain = n.node.depth === 1;
2977
- const fs = fontSizeOf(n.node.depth);
2978
- const tx = n.x;
2979
- const ty = isMain ? n.y - 3 : n.y + fs * 0.35;
3305
+ const fs = n.fontSize;
3306
+ const lh = lineHeightOf(fs);
3307
+ const lineCount = n.lines.length;
3308
+ const topY = n.y - n.labelHeight / 2;
3309
+ const underlineY2 = n.y + n.labelHeight / 2 - UNDERLINE_GAP / 2;
3310
+ const children = [];
3311
+ const decorations = [];
3312
+ const weight = isRoot ? 700 : isMain ? 600 : 400;
3313
+ const textLeft = n.x - n.labelWidth / 2;
3314
+ for (let i = 0; i < lineCount; i++) {
3315
+ const line2 = n.lines[i];
3316
+ const cy = topY + (i + 0.5) * lh;
3317
+ const r = renderLine(line2, textLeft, cy, fs, fontFamily, weight, theme);
3318
+ decorations.push(...r.decorations);
3319
+ children.push(r.textElement);
3320
+ }
2980
3321
  const ux1 = n.x - n.labelWidth / 2;
2981
3322
  const ux2 = n.x + n.labelWidth / 2;
2982
- const uy = n.y;
2983
- const children = [
2984
- chunkHDKDQAEQ_cjs.text(
2985
- {
2986
- x: tx,
2987
- y: ty,
2988
- "text-anchor": "middle",
2989
- "font-family": fontFamily,
2990
- "font-size": fs,
2991
- "font-weight": isMain ? 600 : 400,
2992
- fill: theme.text
2993
- },
2994
- n.node.label
2995
- )
2996
- ];
2997
- if (isMain) {
2998
- children.push(
2999
- chunkHDKDQAEQ_cjs.el("line", {
3000
- x1: ux1,
3001
- y1: uy,
3002
- x2: ux2,
3003
- y2: uy,
3004
- stroke: color,
3005
- "stroke-width": underlineMain(theme),
3006
- "stroke-linecap": "round"
3007
- })
3008
- );
3009
- }
3323
+ const sw = underlineWidthFor(n.node.depth) * strokeScale(theme);
3324
+ children.push(
3325
+ chunkHDKDQAEQ_cjs.el("line", {
3326
+ x1: ux1,
3327
+ y1: underlineY2,
3328
+ x2: ux2,
3329
+ y2: underlineY2,
3330
+ stroke: color,
3331
+ "stroke-width": sw,
3332
+ "stroke-linecap": "round"
3333
+ })
3334
+ );
3335
+ const cls = isRoot ? "schematex-mindmap-central" : isMain ? "schematex-mindmap-main" : "schematex-mindmap-leaf";
3010
3336
  return chunkHDKDQAEQ_cjs.group(
3011
3337
  {
3012
- class: isMain ? "schematex-mindmap-main" : "schematex-mindmap-leaf",
3338
+ class: cls,
3013
3339
  "data-node-id": n.node.id,
3014
3340
  "data-depth": n.node.depth,
3015
3341
  "data-branch-idx": n.branchIndex
3016
3342
  },
3017
- children
3343
+ [...decorations, ...children]
3018
3344
  );
3019
3345
  }
3020
3346
  function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -apple-system, sans-serif") {
3021
- const theme = chunkS6VPECM3_cjs.resolveMindmapTheme(ast.themeOverride ?? themeName);
3347
+ const theme = chunkD7EHZFK4_cjs.resolveMindmapTheme(ast.themeOverride ?? themeName);
3022
3348
  const layout = layoutMindmap(ast);
3023
3349
  const byId = new Map(layout.nodes.map((n) => [n.node.id, n]));
3024
3350
  const edgeSvgs = [];
@@ -3038,15 +3364,10 @@ function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -
3038
3364
  }
3039
3365
  const nodeSvgs = [];
3040
3366
  for (const n of layout.nodes) {
3041
- if (n.node.depth === 0) {
3042
- nodeSvgs.push(renderCentral(n, theme, fontFamily));
3043
- } else {
3044
- nodeSvgs.push(
3045
- renderBranchNode(n, paletteColor(theme, n.branchIndex), theme, fontFamily)
3046
- );
3047
- }
3367
+ const color = n.node.depth === 0 ? theme.centralFill : paletteColor(theme, n.branchIndex);
3368
+ nodeSvgs.push(renderNode(n, color, theme, fontFamily));
3048
3369
  }
3049
- const title2 = ast.title ?? ast.root.label;
3370
+ const title2 = ast.title ?? tokensToPlainText(ast.root.tokens);
3050
3371
  return chunkHDKDQAEQ_cjs.svgRoot(
3051
3372
  {
3052
3373
  viewBox: `0 0 ${layout.width.toFixed(1)} ${layout.height.toFixed(1)}`,
@@ -4485,24 +4806,24 @@ var matrix = {
4485
4806
 
4486
4807
  // src/core/api.ts
4487
4808
  var plugins = [
4488
- chunkCEV3GZA3_cjs.genogram,
4489
- chunkZGKEFVJQ_cjs.ecomap,
4490
- chunkAMP2FFES_cjs.pedigree,
4491
- chunkYKO7DY2F_cjs.phylo,
4492
- chunkDTMCQXXC_cjs.sociogram,
4493
- chunkZO77FHBF_cjs.timing,
4494
- chunk4HPT4BOI_cjs.logic,
4495
- chunkHKRYKEOV_cjs.circuit,
4496
- chunkLXNFVHDT_cjs.blockdiagram,
4497
- chunkLKHWBDWZ_cjs.ladder,
4498
- chunkULERCTGS_cjs.sld,
4499
- chunkPIQG2Z5N_cjs.entity,
4500
- chunkIMHR3S5H_cjs.fishbone,
4501
- chunk3M7QWADF_cjs.venn,
4502
- chunkHAIBAF6J_cjs.flowchart,
4809
+ chunk6LZJTAA3_cjs.genogram,
4810
+ chunkE65ITQXV_cjs.ecomap,
4811
+ chunkB37IKTI7_cjs.pedigree,
4812
+ chunkX7RPFTTR_cjs.phylo,
4813
+ chunkCOLTVQWR_cjs.sociogram,
4814
+ chunk2JDVJRR3_cjs.timing,
4815
+ chunkWYFXOXVK_cjs.logic,
4816
+ chunk4S2WILLW_cjs.circuit,
4817
+ chunkMCFQAUQV_cjs.blockdiagram,
4818
+ chunkB6INLQBU_cjs.ladder,
4819
+ chunk3YZ6FPQW_cjs.sld,
4820
+ chunkZNOD4VZT_cjs.entity,
4821
+ chunk5AEN2PLB_cjs.fishbone,
4822
+ chunkQSQX77S2_cjs.venn,
4823
+ chunkZ3DE6S64_cjs.flowchart,
4503
4824
  mindmap,
4504
4825
  matrix,
4505
- chunkIY52OWPG_cjs.orgchart,
4826
+ chunkA5D2IMOX_cjs.orgchart,
4506
4827
  decisiontree,
4507
4828
  timeline
4508
4829
  ];
@@ -4540,5 +4861,5 @@ exports.decisiontree = decisiontree;
4540
4861
  exports.parse = parse;
4541
4862
  exports.render = render;
4542
4863
  exports.timeline = timeline;
4543
- //# sourceMappingURL=chunk-VP54YPOX.cjs.map
4544
- //# sourceMappingURL=chunk-VP54YPOX.cjs.map
4864
+ //# sourceMappingURL=chunk-QXIGHMH2.cjs.map
4865
+ //# sourceMappingURL=chunk-QXIGHMH2.cjs.map