schematex 0.2.2 → 0.2.4

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 (163) hide show
  1. package/dist/ai/ai-sdk.cjs +85 -0
  2. package/dist/ai/ai-sdk.cjs.map +1 -0
  3. package/dist/ai/ai-sdk.d.cts +30 -0
  4. package/dist/ai/ai-sdk.d.ts +30 -0
  5. package/dist/ai/ai-sdk.js +83 -0
  6. package/dist/ai/ai-sdk.js.map +1 -0
  7. package/dist/ai/index.cjs +60 -0
  8. package/dist/ai/index.cjs.map +1 -0
  9. package/dist/ai/index.d.cts +155 -0
  10. package/dist/ai/index.d.ts +155 -0
  11. package/dist/ai/index.js +23 -0
  12. package/dist/ai/index.js.map +1 -0
  13. package/dist/browser.cjs +16 -15
  14. package/dist/browser.cjs.map +1 -1
  15. package/dist/browser.js +14 -13
  16. package/dist/browser.js.map +1 -1
  17. package/dist/{chunk-ZO77FHBF.cjs → chunk-2JDVJRR3.cjs} +14 -6
  18. package/dist/chunk-2JDVJRR3.cjs.map +1 -0
  19. package/dist/{chunk-QR7VTCI4.cjs → chunk-3YZ6FPQW.cjs} +13 -7
  20. package/dist/chunk-3YZ6FPQW.cjs.map +1 -0
  21. package/dist/{chunk-GEPBET4L.js → chunk-45KP67RR.js} +14 -6
  22. package/dist/chunk-45KP67RR.js.map +1 -0
  23. package/dist/{chunk-LKOBOVNL.cjs → chunk-5AEN2PLB.cjs} +14 -6
  24. package/dist/chunk-5AEN2PLB.cjs.map +1 -0
  25. package/dist/{chunk-7IRT3LOY.cjs → chunk-A5D2IMOX.cjs} +16 -8
  26. package/dist/chunk-A5D2IMOX.cjs.map +1 -0
  27. package/dist/{chunk-XVCAOGFL.cjs → chunk-B37IKTI7.cjs} +221 -44
  28. package/dist/chunk-B37IKTI7.cjs.map +1 -0
  29. package/dist/{chunk-ISACNVFE.cjs → chunk-B6INLQBU.cjs} +15 -9
  30. package/dist/chunk-B6INLQBU.cjs.map +1 -0
  31. package/dist/{chunk-YXIIWLLB.cjs → chunk-COLTVQWR.cjs} +174 -6
  32. package/dist/chunk-COLTVQWR.cjs.map +1 -0
  33. package/dist/chunk-DNZFOCV7.js +796 -0
  34. package/dist/chunk-DNZFOCV7.js.map +1 -0
  35. package/dist/chunk-DPQYGWCT.cjs +1121 -0
  36. package/dist/chunk-DPQYGWCT.cjs.map +1 -0
  37. package/dist/{chunk-XHZ7GXP2.cjs → chunk-E65ITQXV.cjs} +178 -22
  38. package/dist/chunk-E65ITQXV.cjs.map +1 -0
  39. package/dist/{chunk-LCR3KOJV.js → chunk-FCGHV6ZK.js} +16 -8
  40. package/dist/chunk-FCGHV6ZK.js.map +1 -0
  41. package/dist/{chunk-X2BQKXMA.js → chunk-FE6GAUNW.js} +13 -7
  42. package/dist/chunk-FE6GAUNW.js.map +1 -0
  43. package/dist/{chunk-YN467EEQ.js → chunk-H2OEUBPO.js} +547 -101
  44. package/dist/chunk-H2OEUBPO.js.map +1 -0
  45. package/dist/{chunk-Z3WOHHG3.js → chunk-J2LVOWVY.js} +177 -24
  46. package/dist/chunk-J2LVOWVY.js.map +1 -0
  47. package/dist/{chunk-CJ2A3UEQ.js → chunk-LR4X4ZRG.js} +179 -23
  48. package/dist/chunk-LR4X4ZRG.js.map +1 -0
  49. package/dist/{chunk-LXNFVHDT.cjs → chunk-MCFQAUQV.cjs} +21 -13
  50. package/dist/chunk-MCFQAUQV.cjs.map +1 -0
  51. package/dist/{chunk-Z63XPA2V.cjs → chunk-MJGDP3CS.cjs} +546 -100
  52. package/dist/chunk-MJGDP3CS.cjs.map +1 -0
  53. package/dist/chunk-MR5HU5WU.js +1112 -0
  54. package/dist/chunk-MR5HU5WU.js.map +1 -0
  55. package/dist/{chunk-7HKXU7J2.cjs → chunk-MSYBSOU2.cjs} +65 -38
  56. package/dist/chunk-MSYBSOU2.cjs.map +1 -0
  57. package/dist/{chunk-4KYW63IK.js → chunk-OC22GGQN.js} +222 -45
  58. package/dist/chunk-OC22GGQN.js.map +1 -0
  59. package/dist/{chunk-5UV5VQ7J.js → chunk-RP5UATRA.js} +174 -6
  60. package/dist/chunk-RP5UATRA.js.map +1 -0
  61. package/dist/{chunk-ZNZIL244.js → chunk-U6L3FAML.js} +15 -9
  62. package/dist/chunk-U6L3FAML.js.map +1 -0
  63. package/dist/{chunk-CXHPP5BL.cjs → chunk-UAGSCTYI.cjs} +177 -24
  64. package/dist/chunk-UAGSCTYI.cjs.map +1 -0
  65. package/dist/{chunk-5SH5NUDW.js → chunk-UGCUNADI.js} +21 -13
  66. package/dist/chunk-UGCUNADI.js.map +1 -0
  67. package/dist/chunk-ULYRO2KY.cjs +800 -0
  68. package/dist/chunk-ULYRO2KY.cjs.map +1 -0
  69. package/dist/{chunk-UUPYTUGR.js → chunk-VPKCW4PB.js} +54 -27
  70. package/dist/chunk-VPKCW4PB.js.map +1 -0
  71. package/dist/{chunk-6YMQSTFF.js → chunk-ZNDIGQJD.js} +14 -6
  72. package/dist/chunk-ZNDIGQJD.js.map +1 -0
  73. package/dist/diagrams/blockdiagram/index.cjs +5 -5
  74. package/dist/diagrams/blockdiagram/index.d.cts +1 -1
  75. package/dist/diagrams/blockdiagram/index.d.ts +1 -1
  76. package/dist/diagrams/blockdiagram/index.js +1 -1
  77. package/dist/diagrams/circuit/index.d.cts +1 -1
  78. package/dist/diagrams/circuit/index.d.ts +1 -1
  79. package/dist/diagrams/ecomap/index.cjs +7 -6
  80. package/dist/diagrams/ecomap/index.d.cts +2 -2
  81. package/dist/diagrams/ecomap/index.d.ts +2 -2
  82. package/dist/diagrams/ecomap/index.js +2 -1
  83. package/dist/diagrams/entity/index.d.cts +1 -1
  84. package/dist/diagrams/entity/index.d.ts +1 -1
  85. package/dist/diagrams/fishbone/index.cjs +7 -7
  86. package/dist/diagrams/fishbone/index.d.cts +1 -1
  87. package/dist/diagrams/fishbone/index.d.ts +1 -1
  88. package/dist/diagrams/fishbone/index.js +1 -1
  89. package/dist/diagrams/flowchart/index.cjs +7 -7
  90. package/dist/diagrams/flowchart/index.d.cts +2 -2
  91. package/dist/diagrams/flowchart/index.d.ts +2 -2
  92. package/dist/diagrams/flowchart/index.js +1 -1
  93. package/dist/diagrams/genogram/index.cjs +9 -8
  94. package/dist/diagrams/genogram/index.d.cts +1 -1
  95. package/dist/diagrams/genogram/index.d.ts +1 -1
  96. package/dist/diagrams/genogram/index.js +2 -1
  97. package/dist/diagrams/ladder/index.cjs +5 -5
  98. package/dist/diagrams/ladder/index.d.cts +1 -1
  99. package/dist/diagrams/ladder/index.d.ts +1 -1
  100. package/dist/diagrams/ladder/index.js +1 -1
  101. package/dist/diagrams/logic/index.d.cts +1 -1
  102. package/dist/diagrams/logic/index.d.ts +1 -1
  103. package/dist/diagrams/orgchart/index.cjs +6 -6
  104. package/dist/diagrams/orgchart/index.d.cts +5 -2
  105. package/dist/diagrams/orgchart/index.d.ts +5 -2
  106. package/dist/diagrams/orgchart/index.js +1 -1
  107. package/dist/diagrams/pedigree/index.cjs +7 -6
  108. package/dist/diagrams/pedigree/index.d.cts +1 -1
  109. package/dist/diagrams/pedigree/index.d.ts +1 -1
  110. package/dist/diagrams/pedigree/index.js +2 -1
  111. package/dist/diagrams/phylo/index.d.cts +1 -1
  112. package/dist/diagrams/phylo/index.d.ts +1 -1
  113. package/dist/diagrams/sld/index.cjs +5 -5
  114. package/dist/diagrams/sld/index.d.cts +1 -1
  115. package/dist/diagrams/sld/index.d.ts +1 -1
  116. package/dist/diagrams/sld/index.js +1 -1
  117. package/dist/diagrams/sociogram/index.cjs +6 -5
  118. package/dist/diagrams/sociogram/index.d.cts +2 -1
  119. package/dist/diagrams/sociogram/index.d.ts +2 -1
  120. package/dist/diagrams/sociogram/index.js +2 -1
  121. package/dist/diagrams/timing/index.cjs +4 -4
  122. package/dist/diagrams/timing/index.d.cts +1 -1
  123. package/dist/diagrams/timing/index.d.ts +1 -1
  124. package/dist/diagrams/timing/index.js +1 -1
  125. package/dist/diagrams/venn/index.d.cts +1 -1
  126. package/dist/diagrams/venn/index.d.ts +1 -1
  127. package/dist/{index-ga04CTBI.d.ts → index-BTZEka65.d.cts} +11 -2
  128. package/dist/{index-SSGpCggE.d.cts → index-DcU88F9i.d.ts} +11 -2
  129. package/dist/index.cjs +28 -27
  130. package/dist/index.d.cts +2 -2
  131. package/dist/index.d.ts +2 -2
  132. package/dist/index.js +13 -12
  133. package/dist/react.cjs +14 -13
  134. package/dist/react.cjs.map +1 -1
  135. package/dist/react.js +13 -12
  136. package/dist/react.js.map +1 -1
  137. package/dist/{types-BcPhMdHd.d.ts → types-C4LnMEcB.d.cts} +58 -4
  138. package/dist/{types-BcPhMdHd.d.cts → types-C4LnMEcB.d.ts} +58 -4
  139. package/package.json +27 -5
  140. package/dist/chunk-4KYW63IK.js.map +0 -1
  141. package/dist/chunk-5SH5NUDW.js.map +0 -1
  142. package/dist/chunk-5UV5VQ7J.js.map +0 -1
  143. package/dist/chunk-6YMQSTFF.js.map +0 -1
  144. package/dist/chunk-7HKXU7J2.cjs.map +0 -1
  145. package/dist/chunk-7IRT3LOY.cjs.map +0 -1
  146. package/dist/chunk-CJ2A3UEQ.js.map +0 -1
  147. package/dist/chunk-CXHPP5BL.cjs.map +0 -1
  148. package/dist/chunk-GEPBET4L.js.map +0 -1
  149. package/dist/chunk-ISACNVFE.cjs.map +0 -1
  150. package/dist/chunk-LCR3KOJV.js.map +0 -1
  151. package/dist/chunk-LKOBOVNL.cjs.map +0 -1
  152. package/dist/chunk-LXNFVHDT.cjs.map +0 -1
  153. package/dist/chunk-QR7VTCI4.cjs.map +0 -1
  154. package/dist/chunk-UUPYTUGR.js.map +0 -1
  155. package/dist/chunk-X2BQKXMA.js.map +0 -1
  156. package/dist/chunk-XHZ7GXP2.cjs.map +0 -1
  157. package/dist/chunk-XVCAOGFL.cjs.map +0 -1
  158. package/dist/chunk-YN467EEQ.js.map +0 -1
  159. package/dist/chunk-YXIIWLLB.cjs.map +0 -1
  160. package/dist/chunk-Z3WOHHG3.js.map +0 -1
  161. package/dist/chunk-Z63XPA2V.cjs.map +0 -1
  162. package/dist/chunk-ZNZIL244.js.map +0 -1
  163. package/dist/chunk-ZO77FHBF.cjs.map +0 -1
@@ -1,5 +1,6 @@
1
+ import { parseLegendDirective, applyLegendOverrides, renderLegend } from './chunk-DNZFOCV7.js';
1
2
  import { resolveGenogramTheme, STROKE_WIDTH, cssCustomProperties } from './chunk-2VNMKOUO.js';
2
- import { title, text, group, el, rect, pattern, path, circle, defs, polygon, line, desc, svgRoot } from './chunk-KLJEK547.js';
3
+ import { title, text, group, pattern, path, circle, el, defs, polygon, rect, line, desc, svgRoot } from './chunk-KLJEK547.js';
3
4
 
4
5
  // src/diagrams/genogram/parser.ts
5
6
  var ParseError = class extends Error {
@@ -108,6 +109,7 @@ function parseGenogram(text2) {
108
109
  const individualsMap = /* @__PURE__ */ new Map();
109
110
  const relationships = [];
110
111
  const childSpecialProps = /* @__PURE__ */ new Map();
112
+ const legendOverrides = {};
111
113
  skipBlankAndComments(state);
112
114
  while (state.currentLine < state.lines.length) {
113
115
  skipBlankAndComments(state);
@@ -118,6 +120,10 @@ function parseGenogram(text2) {
118
120
  state.currentLine++;
119
121
  continue;
120
122
  }
123
+ if (parseLegendDirective(trimmed, legendOverrides)) {
124
+ state.currentLine++;
125
+ continue;
126
+ }
121
127
  const emotionalMatch = detectEmotionalOp(trimmed);
122
128
  if (emotionalMatch) {
123
129
  const { leftId, emotionalType, rightId: emRightId, directional, label: emLabel } = emotionalMatch;
@@ -243,11 +249,13 @@ function parseGenogram(text2) {
243
249
  });
244
250
  }
245
251
  }
252
+ const hasLegendOverrides = Object.keys(legendOverrides).length > 0 && Object.values(legendOverrides).some((v) => v !== void 0);
246
253
  return {
247
254
  type: "genogram",
248
255
  individuals: Array.from(individualsMap.values()),
249
256
  relationships,
250
- metadata: Object.keys(metadata).length > 0 ? metadata : void 0
257
+ metadata: Object.keys(metadata).length > 0 ? metadata : void 0,
258
+ legendOverrides: hasLegendOverrides ? legendOverrides : void 0
251
259
  };
252
260
  }
253
261
  function currentLineText(state) {
@@ -913,7 +921,9 @@ function computeEdges(graph, positions, config) {
913
921
  path: dropPath
914
922
  });
915
923
  if (childPositions.length > 1) {
916
- const sibPath = `M ${leftX} ${dropY} L ${rightX} ${dropY}`;
924
+ const sibLeft = Math.min(leftX, midX);
925
+ const sibRight = Math.max(rightX, midX);
926
+ const sibPath = `M ${sibLeft} ${dropY} L ${sibRight} ${dropY}`;
917
927
  edges.push({
918
928
  from: fu.partners[0],
919
929
  to: fu.partners[1],
@@ -1148,96 +1158,30 @@ function getRequiredDefs(individuals, includeArrowMarker = false) {
1148
1158
  }
1149
1159
  }
1150
1160
  const children = [];
1151
- if (neededFills.has("half-left")) {
1152
- children.push(
1153
- el("clipPath", { id: "schematex-genogram-clip-half-left-rect" }, [
1154
- rect({ x: "0", y: "0", width: "50%", height: "100%" })
1155
- ]),
1156
- el("clipPath", { id: "schematex-genogram-clip-half-left-circle" }, [
1157
- rect({ x: "-50", y: "-50", width: "50", height: "100" })
1158
- ])
1159
- );
1160
- }
1161
- if (neededFills.has("half-right")) {
1162
- children.push(
1163
- el("clipPath", { id: "schematex-genogram-clip-half-right-rect" }, [
1164
- rect({ x: "50%", y: "0", width: "50%", height: "100%" })
1165
- ]),
1166
- el("clipPath", { id: "schematex-genogram-clip-half-right-circle" }, [
1167
- rect({ x: "0", y: "-50", width: "50", height: "100" })
1168
- ])
1169
- );
1170
- }
1171
- if (neededFills.has("half-bottom")) {
1172
- children.push(
1173
- el("clipPath", { id: "schematex-genogram-clip-half-bottom-rect" }, [
1174
- rect({ x: "0", y: "50%", width: "100%", height: "50%" })
1175
- ]),
1176
- el("clipPath", { id: "schematex-genogram-clip-half-bottom-circle" }, [
1177
- rect({ x: "-50", y: "0", width: "100", height: "50" })
1178
- ])
1179
- );
1180
- }
1181
- if (neededFills.has("quarter")) {
1182
- children.push(
1183
- el("clipPath", { id: "schematex-genogram-clip-quarter-rect" }, [
1184
- rect({ x: "0", y: "0", width: "50%", height: "50%" })
1185
- ]),
1186
- el("clipPath", { id: "schematex-genogram-clip-quarter-circle" }, [
1187
- rect({ x: "-50", y: "-50", width: "50", height: "50" })
1188
- ])
1189
- );
1190
- }
1191
- if (neededFills.has("half-top")) {
1192
- children.push(
1193
- el("clipPath", { id: "schematex-genogram-clip-half-top-rect" }, [
1194
- rect({ x: "0", y: "0", width: "100%", height: "50%" })
1195
- ]),
1196
- el("clipPath", { id: "schematex-genogram-clip-half-top-circle" }, [
1197
- rect({ x: "-50", y: "-50", width: "100", height: "50" })
1198
- ])
1199
- );
1200
- }
1201
- if (neededFills.has("quad-tl")) {
1202
- children.push(
1203
- el("clipPath", { id: "schematex-genogram-clip-quad-tl-rect" }, [
1204
- rect({ x: "0", y: "0", width: "50%", height: "50%" })
1205
- ]),
1206
- el("clipPath", { id: "schematex-genogram-clip-quad-tl-circle" }, [
1207
- rect({ x: "-50", y: "-50", width: "50", height: "50" })
1208
- ])
1209
- );
1210
- }
1211
- if (neededFills.has("quad-tr")) {
1212
- children.push(
1213
- el("clipPath", { id: "schematex-genogram-clip-quad-tr-rect" }, [
1214
- rect({ x: "50%", y: "0", width: "50%", height: "50%" })
1215
- ]),
1216
- el("clipPath", { id: "schematex-genogram-clip-quad-tr-circle" }, [
1217
- rect({ x: "0", y: "-50", width: "50", height: "50" })
1218
- ])
1219
- );
1220
- }
1221
- if (neededFills.has("quad-bl")) {
1222
- children.push(
1223
- el("clipPath", { id: "schematex-genogram-clip-quad-bl-rect" }, [
1224
- rect({ x: "0", y: "50%", width: "50%", height: "50%" })
1225
- ]),
1226
- el("clipPath", { id: "schematex-genogram-clip-quad-bl-circle" }, [
1227
- rect({ x: "-50", y: "0", width: "50", height: "50" })
1228
- ])
1229
- );
1230
- }
1231
- if (neededFills.has("quad-br")) {
1161
+ function quadClips(suffix, x, y, w, h) {
1162
+ const r = rect({ x, y, width: w, height: h });
1232
1163
  children.push(
1233
- el("clipPath", { id: "schematex-genogram-clip-quad-br-rect" }, [
1234
- rect({ x: "50%", y: "50%", width: "50%", height: "50%" })
1235
- ]),
1236
- el("clipPath", { id: "schematex-genogram-clip-quad-br-circle" }, [
1237
- rect({ x: "0", y: "0", width: "50", height: "50" })
1238
- ])
1164
+ el(
1165
+ "clipPath",
1166
+ { id: `schematex-genogram-clip-${suffix}-rect`, clipPathUnits: "objectBoundingBox" },
1167
+ [r]
1168
+ ),
1169
+ el(
1170
+ "clipPath",
1171
+ { id: `schematex-genogram-clip-${suffix}-circle`, clipPathUnits: "objectBoundingBox" },
1172
+ [r]
1173
+ )
1239
1174
  );
1240
1175
  }
1176
+ if (neededFills.has("half-left")) quadClips("half-left", 0, 0, 0.5, 1);
1177
+ if (neededFills.has("half-right")) quadClips("half-right", 0.5, 0, 0.5, 1);
1178
+ if (neededFills.has("half-top")) quadClips("half-top", 0, 0, 1, 0.5);
1179
+ if (neededFills.has("half-bottom")) quadClips("half-bottom", 0, 0.5, 1, 0.5);
1180
+ if (neededFills.has("quarter")) quadClips("quarter", 0, 0, 0.5, 0.5);
1181
+ if (neededFills.has("quad-tl")) quadClips("quad-tl", 0, 0, 0.5, 0.5);
1182
+ if (neededFills.has("quad-tr")) quadClips("quad-tr", 0.5, 0, 0.5, 0.5);
1183
+ if (neededFills.has("quad-bl")) quadClips("quad-bl", 0, 0.5, 0.5, 0.5);
1184
+ if (neededFills.has("quad-br")) quadClips("quad-br", 0.5, 0.5, 0.5, 0.5);
1241
1185
  if (neededFills.has("striped")) {
1242
1186
  children.push(
1243
1187
  pattern(
@@ -1418,6 +1362,469 @@ function conditionFillElement(sex, half, cond) {
1418
1362
  }
1419
1363
  }
1420
1364
 
1365
+ // src/diagrams/genogram/legend.ts
1366
+ var EMOTIONAL_TYPES2 = /* @__PURE__ */ new Set([
1367
+ "harmony",
1368
+ "close",
1369
+ "bestfriends",
1370
+ "love",
1371
+ "inlove",
1372
+ "friendship",
1373
+ "hostile",
1374
+ "conflict",
1375
+ "enmity",
1376
+ "distant-hostile",
1377
+ "cutoff",
1378
+ "close-hostile",
1379
+ "fused",
1380
+ "fused-hostile",
1381
+ "distant",
1382
+ "normal",
1383
+ "nevermet",
1384
+ "abuse",
1385
+ "physical-abuse",
1386
+ "emotional-abuse",
1387
+ "sexual-abuse",
1388
+ "neglect",
1389
+ "manipulative",
1390
+ "controlling",
1391
+ "jealous",
1392
+ "focused",
1393
+ "focused-neg",
1394
+ "distrust",
1395
+ "admirer",
1396
+ "limerence"
1397
+ ]);
1398
+ var STRUCTURAL_TYPES = /* @__PURE__ */ new Set([
1399
+ "married",
1400
+ "divorced",
1401
+ "separated",
1402
+ "engaged",
1403
+ "cohabiting",
1404
+ "domestic-partnership",
1405
+ "consanguineous",
1406
+ "parent-child",
1407
+ "adopted",
1408
+ "foster",
1409
+ "twin-identical",
1410
+ "twin-fraternal"
1411
+ ]);
1412
+ var HERITAGE_PALETTE = [
1413
+ "#2563eb",
1414
+ "#059669",
1415
+ "#d97706",
1416
+ "#dc2626",
1417
+ "#7c3aed",
1418
+ "#0891b2",
1419
+ "#ca8a04",
1420
+ "#db2777"
1421
+ ];
1422
+ var SECTIONS = [
1423
+ { id: "symbols", title: "Symbols" },
1424
+ { id: "structural", title: "Structural" },
1425
+ { id: "relationships", title: "Relationships" },
1426
+ { id: "conditions", title: "Conditions" },
1427
+ { id: "heritage", title: "Heritage" },
1428
+ { id: "markers", title: "Markers" }
1429
+ ];
1430
+ function buildGenogramLegend(ast, theme) {
1431
+ const items = [];
1432
+ items.push(...buildSymbolItems(ast.individuals, theme));
1433
+ items.push(...buildStructuralItems(ast.relationships, theme));
1434
+ items.push(...buildRelationshipItems(ast.relationships));
1435
+ items.push(...buildConditionItems(ast.individuals));
1436
+ items.push(...buildHeritageItems(ast.individuals));
1437
+ items.push(...buildMarkerItems(ast.individuals, theme));
1438
+ return {
1439
+ mode: "auto",
1440
+ title: "Legend",
1441
+ position: "bottom-inline",
1442
+ columns: 1,
1443
+ sections: SECTIONS,
1444
+ items
1445
+ };
1446
+ }
1447
+ var OBVIOUS_SEX = /* @__PURE__ */ new Set(["male", "female"]);
1448
+ function buildSymbolItems(individuals, theme) {
1449
+ const items = [];
1450
+ const sexUsed = /* @__PURE__ */ new Set();
1451
+ const statusUsed = /* @__PURE__ */ new Set();
1452
+ for (const ind of individuals) {
1453
+ sexUsed.add(ind.sex);
1454
+ if (ind.status && ind.status !== "alive") statusUsed.add(ind.status);
1455
+ }
1456
+ const sexOrder = [
1457
+ "unknown",
1458
+ "other",
1459
+ "nonbinary",
1460
+ "intersex"
1461
+ ];
1462
+ for (const s of sexOrder) {
1463
+ if (!sexUsed.has(s)) continue;
1464
+ if (OBVIOUS_SEX.has(s)) continue;
1465
+ items.push({
1466
+ key: `sex.${s}`,
1467
+ label: sexLabel(s),
1468
+ kind: "shape",
1469
+ shape: sexShape(s),
1470
+ fill: theme ? sexFill(s, theme) : void 0,
1471
+ color: theme?.stroke,
1472
+ section: "symbols"
1473
+ });
1474
+ }
1475
+ const statusOrder = [
1476
+ "deceased",
1477
+ "stillborn",
1478
+ "miscarriage",
1479
+ "abortion",
1480
+ "pregnancy",
1481
+ "sab",
1482
+ "tab",
1483
+ "ectopic"
1484
+ ];
1485
+ for (const st of statusOrder) {
1486
+ if (!statusUsed.has(st)) continue;
1487
+ items.push({
1488
+ key: `status.${st}`,
1489
+ label: statusLabel(st),
1490
+ kind: "marker",
1491
+ marker: statusMarker(st),
1492
+ color: theme?.deceasedMark,
1493
+ section: "symbols"
1494
+ });
1495
+ }
1496
+ return items;
1497
+ }
1498
+ function sexFill(s, theme) {
1499
+ switch (s) {
1500
+ case "male":
1501
+ return theme.maleFill;
1502
+ case "female":
1503
+ return theme.femaleFill;
1504
+ default:
1505
+ return theme.unknownFill;
1506
+ }
1507
+ }
1508
+ function sexShape(s) {
1509
+ switch (s) {
1510
+ case "male":
1511
+ return "square";
1512
+ case "female":
1513
+ return "circle";
1514
+ case "unknown":
1515
+ return "diamond";
1516
+ case "other":
1517
+ case "nonbinary":
1518
+ return "diamond";
1519
+ case "intersex":
1520
+ return "diamond";
1521
+ default:
1522
+ return "square";
1523
+ }
1524
+ }
1525
+ function sexLabel(s) {
1526
+ switch (s) {
1527
+ case "male":
1528
+ return "Male";
1529
+ case "female":
1530
+ return "Female";
1531
+ case "unknown":
1532
+ return "Unknown";
1533
+ case "other":
1534
+ return "Other";
1535
+ case "nonbinary":
1536
+ return "Non-binary";
1537
+ case "intersex":
1538
+ return "Intersex";
1539
+ default:
1540
+ return s;
1541
+ }
1542
+ }
1543
+ function statusMarker(s) {
1544
+ switch (s) {
1545
+ case "deceased":
1546
+ case "stillborn":
1547
+ return "X";
1548
+ case "miscarriage":
1549
+ case "sab":
1550
+ case "tab":
1551
+ case "abortion":
1552
+ case "ectopic":
1553
+ return "slash";
1554
+ default:
1555
+ return "dot";
1556
+ }
1557
+ }
1558
+ function statusLabel(s) {
1559
+ switch (s) {
1560
+ case "deceased":
1561
+ return "Deceased";
1562
+ case "stillborn":
1563
+ return "Stillborn";
1564
+ case "miscarriage":
1565
+ return "Miscarriage";
1566
+ case "abortion":
1567
+ return "Abortion";
1568
+ case "pregnancy":
1569
+ return "Pregnancy";
1570
+ case "sab":
1571
+ return "Spontaneous abortion";
1572
+ case "tab":
1573
+ return "Therapeutic abortion";
1574
+ case "ectopic":
1575
+ return "Ectopic pregnancy";
1576
+ default:
1577
+ return s;
1578
+ }
1579
+ }
1580
+ var OBVIOUS_STRUCTURAL = /* @__PURE__ */ new Set([
1581
+ "married",
1582
+ // single horizontal line — universal McGoldrick
1583
+ "parent-child"
1584
+ // single vertical line — universal
1585
+ ]);
1586
+ function buildStructuralItems(rels, theme) {
1587
+ const used = /* @__PURE__ */ new Set();
1588
+ for (const r of rels) {
1589
+ if (STRUCTURAL_TYPES.has(r.type)) used.add(r.type);
1590
+ }
1591
+ const order = [
1592
+ "divorced",
1593
+ "separated",
1594
+ "engaged",
1595
+ "cohabiting",
1596
+ "domestic-partnership",
1597
+ "consanguineous",
1598
+ "adopted",
1599
+ "foster",
1600
+ "twin-identical",
1601
+ "twin-fraternal"
1602
+ ];
1603
+ const items = [];
1604
+ for (const t of order) {
1605
+ if (!used.has(t)) continue;
1606
+ if (OBVIOUS_STRUCTURAL.has(t)) continue;
1607
+ items.push(structuralItem(t, theme));
1608
+ }
1609
+ return items;
1610
+ }
1611
+ function structuralItem(t, theme) {
1612
+ const base = {
1613
+ key: t,
1614
+ label: humanize(t),
1615
+ kind: "line",
1616
+ color: theme?.stroke,
1617
+ section: "structural",
1618
+ pattern: "solid"
1619
+ };
1620
+ switch (t) {
1621
+ case "divorced":
1622
+ return { ...base, kind: "edge", marker: "X", pattern: "solid" };
1623
+ case "separated":
1624
+ return { ...base, kind: "edge", marker: "slash", pattern: "solid" };
1625
+ case "engaged":
1626
+ case "cohabiting":
1627
+ case "adopted":
1628
+ case "foster":
1629
+ return { ...base, pattern: "dashed" };
1630
+ case "consanguineous":
1631
+ return { ...base, pattern: "double" };
1632
+ case "twin-identical":
1633
+ case "twin-fraternal":
1634
+ return { ...base, pattern: "solid" };
1635
+ default:
1636
+ return base;
1637
+ }
1638
+ }
1639
+ function buildRelationshipItems(rels) {
1640
+ const used = /* @__PURE__ */ new Set();
1641
+ for (const r of rels) {
1642
+ if (EMOTIONAL_TYPES2.has(r.type)) used.add(r.type);
1643
+ }
1644
+ const order = [
1645
+ "harmony",
1646
+ "close",
1647
+ "bestfriends",
1648
+ "love",
1649
+ "inlove",
1650
+ "friendship",
1651
+ "hostile",
1652
+ "conflict",
1653
+ "enmity",
1654
+ "distant-hostile",
1655
+ "cutoff",
1656
+ "close-hostile",
1657
+ "fused",
1658
+ "fused-hostile",
1659
+ "distant",
1660
+ "normal",
1661
+ "nevermet",
1662
+ "abuse",
1663
+ "physical-abuse",
1664
+ "emotional-abuse",
1665
+ "sexual-abuse",
1666
+ "neglect",
1667
+ "manipulative",
1668
+ "controlling",
1669
+ "jealous",
1670
+ "focused",
1671
+ "focused-neg",
1672
+ "distrust",
1673
+ "admirer",
1674
+ "limerence"
1675
+ ];
1676
+ const items = [];
1677
+ for (const t of order) {
1678
+ if (!used.has(t)) continue;
1679
+ items.push({
1680
+ key: t,
1681
+ label: humanize(t),
1682
+ kind: "line",
1683
+ color: emotionalColor(t),
1684
+ pattern: emotionalPattern(t),
1685
+ strokeWidth: emotionalStrokeWidth(t),
1686
+ section: "relationships"
1687
+ });
1688
+ }
1689
+ return items;
1690
+ }
1691
+ function emotionalColor(t) {
1692
+ if (["harmony", "close", "bestfriends", "love", "inlove", "friendship"].includes(t)) return "#4caf50";
1693
+ if (["hostile", "conflict", "enmity", "distant-hostile", "cutoff"].includes(t)) return "#e53935";
1694
+ if (["close-hostile", "fused", "fused-hostile"].includes(t)) return "#9c27b0";
1695
+ if (["distant", "normal", "nevermet"].includes(t)) return "#9e9e9e";
1696
+ if (["abuse", "physical-abuse", "emotional-abuse", "sexual-abuse", "neglect"].includes(t)) return "#b71c1c";
1697
+ if (["manipulative", "controlling", "jealous"].includes(t)) return "#e65100";
1698
+ return "#1565c0";
1699
+ }
1700
+ function emotionalPattern(t) {
1701
+ if (["hostile", "conflict", "enmity", "distant-hostile", "close-hostile", "fused-hostile"].includes(t)) return "zigzag";
1702
+ if (["distant", "nevermet"].includes(t)) return "dashed";
1703
+ if (t === "cutoff") return "broken";
1704
+ return "solid";
1705
+ }
1706
+ function emotionalStrokeWidth(t) {
1707
+ if (["fused", "fused-hostile", "bestfriends"].includes(t)) return 4;
1708
+ if (["close", "close-hostile", "love", "inlove"].includes(t)) return 3;
1709
+ return 2;
1710
+ }
1711
+ function buildConditionItems(individuals) {
1712
+ const seen = /* @__PURE__ */ new Map();
1713
+ for (const ind of individuals) {
1714
+ if (!ind.conditions) continue;
1715
+ for (const c of ind.conditions) {
1716
+ if (seen.has(c.label)) continue;
1717
+ const color = c.color ?? defaultCategoryColor(c.category);
1718
+ const isFull = c.fill === "full";
1719
+ seen.set(c.label, {
1720
+ key: c.label,
1721
+ label: humanize(c.label),
1722
+ kind: isFull ? "fill" : "fill-pattern",
1723
+ color,
1724
+ shape: isFull ? void 0 : c.fill,
1725
+ section: "conditions"
1726
+ });
1727
+ }
1728
+ }
1729
+ return Array.from(seen.values());
1730
+ }
1731
+ function defaultCategoryColor(cat) {
1732
+ if (!cat) return "#9ca3af";
1733
+ const map = {
1734
+ cardiovascular: "#dc2626",
1735
+ cancer: "#a21caf",
1736
+ diabetes: "#d97706",
1737
+ "mental-health": "#2563eb",
1738
+ depression: "#1d4ed8",
1739
+ anxiety: "#0ea5e9",
1740
+ bipolar: "#6366f1",
1741
+ ptsd: "#475569",
1742
+ "substance-alcohol": "#92400e",
1743
+ "substance-drugs": "#7c2d12",
1744
+ "substance-tobacco": "#854d0e",
1745
+ neurological: "#7e22ce",
1746
+ respiratory: "#0891b2",
1747
+ autoimmune: "#be185d",
1748
+ genetic: "#0f766e",
1749
+ reproductive: "#db2777",
1750
+ "eating-disorder": "#9333ea",
1751
+ "learning-developmental": "#0369a1",
1752
+ kidney: "#b45309",
1753
+ "liver-gi": "#ca8a04",
1754
+ obesity: "#ea580c",
1755
+ other: "#9ca3af"
1756
+ };
1757
+ return map[cat] ?? "#9ca3af";
1758
+ }
1759
+ function buildHeritageItems(individuals) {
1760
+ const all = /* @__PURE__ */ new Set();
1761
+ for (const ind of individuals) {
1762
+ if (!ind.heritage) continue;
1763
+ for (const h of ind.heritage) all.add(h);
1764
+ }
1765
+ const ordered = Array.from(all).sort();
1766
+ return ordered.map((id, i) => ({
1767
+ key: id,
1768
+ label: humanize(id),
1769
+ kind: "fill",
1770
+ color: HERITAGE_PALETTE[i % HERITAGE_PALETTE.length],
1771
+ section: "heritage"
1772
+ }));
1773
+ }
1774
+ function buildMarkerItems(individuals, theme) {
1775
+ const used = /* @__PURE__ */ new Set();
1776
+ for (const ind of individuals) {
1777
+ if (!ind.markers) continue;
1778
+ for (const m of ind.markers) used.add(m);
1779
+ }
1780
+ const order = [
1781
+ "proband",
1782
+ "consultand",
1783
+ "evaluated",
1784
+ "index-person",
1785
+ "transgender",
1786
+ "no-children",
1787
+ "infertile"
1788
+ ];
1789
+ const items = [];
1790
+ for (const m of order) {
1791
+ if (!used.has(m)) continue;
1792
+ items.push(markerItem(m, theme));
1793
+ }
1794
+ return items;
1795
+ }
1796
+ function markerItem(m, theme) {
1797
+ switch (m) {
1798
+ case "proband":
1799
+ return { key: `marker.${m}`, label: "Proband (P)", kind: "marker", marker: "P", section: "markers" };
1800
+ case "consultand":
1801
+ return { key: `marker.${m}`, label: "Consultand (C)", kind: "marker", marker: "C", section: "markers" };
1802
+ case "evaluated":
1803
+ return { key: `marker.${m}`, label: "Evaluated (E)", kind: "marker", marker: "E", section: "markers" };
1804
+ case "index-person":
1805
+ return {
1806
+ key: `marker.${m}`,
1807
+ label: "Index person (focal subject)",
1808
+ kind: "shape",
1809
+ shape: "concentric-square",
1810
+ fill: "#fef3c7",
1811
+ color: theme?.stroke,
1812
+ section: "markers"
1813
+ };
1814
+ case "transgender":
1815
+ return { key: `marker.${m}`, label: "Transgender", kind: "marker", marker: "star", section: "markers" };
1816
+ case "no-children":
1817
+ return { key: `marker.${m}`, label: "No children (by choice)", kind: "marker", marker: "slash", section: "markers" };
1818
+ case "infertile":
1819
+ return { key: `marker.${m}`, label: "Infertile", kind: "marker", marker: "X", section: "markers" };
1820
+ default:
1821
+ return { key: `marker.${m}`, label: humanize(m), kind: "marker", marker: "dot", section: "markers" };
1822
+ }
1823
+ }
1824
+ function humanize(s) {
1825
+ return s.replace(/[-_]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
1826
+ }
1827
+
1421
1828
  // src/diagrams/genogram/renderer.ts
1422
1829
  function renderGenogram(layout, config, ast) {
1423
1830
  const hasDirectional = layout.edges.some((e) => e.relationship.directional);
@@ -1444,8 +1851,9 @@ function renderGenogram(layout, config, ast) {
1444
1851
  defsStr,
1445
1852
  styleStr
1446
1853
  ];
1854
+ const chartContent = [];
1447
1855
  if (chartTitle) {
1448
- layers.push(
1856
+ chartContent.push(
1449
1857
  text(
1450
1858
  {
1451
1859
  x: layout.width / 2,
@@ -1460,17 +1868,54 @@ function renderGenogram(layout, config, ast) {
1460
1868
  )
1461
1869
  );
1462
1870
  }
1463
- const contentGroup = group(
1464
- { transform: titleHeight > 0 ? `translate(0, ${titleHeight})` : void 0 },
1465
- [edgeLayers, emotionalLayer, ...nodeLayers, labelLayer, edgeLabelLayer]
1871
+ chartContent.push(
1872
+ group(
1873
+ { transform: titleHeight > 0 ? `translate(0, ${titleHeight})` : void 0 },
1874
+ [edgeLayers, emotionalLayer, ...nodeLayers, labelLayer, edgeLabelLayer]
1875
+ )
1876
+ );
1877
+ let finalWidth = layout.width;
1878
+ let finalHeight = totalHeight;
1879
+ let legendSvg = "";
1880
+ if (ast) {
1881
+ const themeBase = resolveGenogramTheme(config.theme);
1882
+ const autoSpec = buildGenogramLegend(ast, themeBase);
1883
+ const finalSpec = applyLegendOverrides(autoSpec, ast.legendOverrides);
1884
+ if (finalSpec.mode === "on" && finalSpec.items.length > 0) {
1885
+ const { svg, bbox: lb } = renderLegend(
1886
+ finalSpec,
1887
+ {
1888
+ canvasWidth: layout.width,
1889
+ canvasHeight: totalHeight,
1890
+ padding: 16,
1891
+ titleHeight
1892
+ },
1893
+ themeBase,
1894
+ { fontFamily: config.fontFamily, fontSize: config.fontSize }
1895
+ );
1896
+ if (svg) {
1897
+ legendSvg = svg;
1898
+ const overflowX = lb.x + lb.w + 8;
1899
+ const overflowY = lb.y + lb.h + 8;
1900
+ if (overflowX > finalWidth) finalWidth = overflowX;
1901
+ if (overflowY > finalHeight) finalHeight = overflowY;
1902
+ }
1903
+ }
1904
+ }
1905
+ const chartXOffset = Math.max(0, (finalWidth - layout.width) / 2);
1906
+ layers.push(
1907
+ group(
1908
+ { transform: chartXOffset > 0 ? `translate(${chartXOffset}, 0)` : void 0 },
1909
+ chartContent
1910
+ )
1466
1911
  );
1467
- layers.push(contentGroup);
1912
+ if (legendSvg) layers.push(legendSvg);
1468
1913
  return svgRoot(
1469
1914
  {
1470
- viewBox: `0 0 ${layout.width} ${totalHeight}`,
1915
+ viewBox: `0 0 ${finalWidth} ${finalHeight}`,
1471
1916
  class: "schematex-diagram schematex-genogram",
1472
- width: layout.width,
1473
- height: totalHeight
1917
+ width: finalWidth,
1918
+ height: finalHeight
1474
1919
  },
1475
1920
  layers
1476
1921
  );
@@ -1491,7 +1936,8 @@ function buildStyles(config) {
1491
1936
  .schematex-genogram-edge-divorced .schematex-genogram-divorce-mark { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; }
1492
1937
  .schematex-genogram-edge-separated .schematex-genogram-separation-mark { stroke: ${t.neutral}; stroke-width: ${STROKE_WIDTH.normal}; }
1493
1938
  .schematex-genogram-deceased-mark { stroke: ${t.deceasedMark}; stroke-width: ${STROKE_WIDTH.normal}; stroke-linecap: round; }
1494
- .schematex-genogram-condition-fill { fill: ${t.conditionFill}; }
1939
+ /* Inline fill on each .schematex-genogram-condition-fill element comes from cond.color. The CSS only sets a default for elements that did not receive an inline fill attribute. */
1940
+ .schematex-genogram-condition-fill:not([fill]) { fill: ${t.conditionFill}; }
1495
1941
  .schematex-genogram-age { font-family: ${config.fontFamily}; fill: ${t.text}; pointer-events: none; }
1496
1942
  .schematex-genogram-title { fill: ${t.text}; }
1497
1943
  .schematex-genogram-edge-label { font-family: ${config.fontFamily}; fill: ${t.text}; }
@@ -1792,5 +2238,5 @@ var genogram = {
1792
2238
  };
1793
2239
 
1794
2240
  export { ParseError, genogram, getRequiredDefs, layoutGenogram, parseGenogram, renderGenogram, renderIndividualSymbol };
1795
- //# sourceMappingURL=chunk-YN467EEQ.js.map
1796
- //# sourceMappingURL=chunk-YN467EEQ.js.map
2241
+ //# sourceMappingURL=chunk-H2OEUBPO.js.map
2242
+ //# sourceMappingURL=chunk-H2OEUBPO.js.map