@zettelgeist/cli 0.1.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.
Files changed (189) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +64 -0
  3. package/dist/bin.js +2211 -0
  4. package/dist/bin.js.map +7 -0
  5. package/dist/templates/export.html +27 -0
  6. package/dist/templates/skill/SKILL.md +220 -0
  7. package/dist/viewer-bundle/architecture-YZFGNWBL-W2K3EQOM.js +14 -0
  8. package/dist/viewer-bundle/architecture-YZFGNWBL-W2K3EQOM.js.map +7 -0
  9. package/dist/viewer-bundle/architectureDiagram-Q4EWVU46-LCGRUEWT.js +8884 -0
  10. package/dist/viewer-bundle/architectureDiagram-Q4EWVU46-LCGRUEWT.js.map +7 -0
  11. package/dist/viewer-bundle/base.css +248 -0
  12. package/dist/viewer-bundle/blockDiagram-DXYQGD6D-KAM7BOAP.js +3777 -0
  13. package/dist/viewer-bundle/blockDiagram-DXYQGD6D-KAM7BOAP.js.map +7 -0
  14. package/dist/viewer-bundle/board.css +370 -0
  15. package/dist/viewer-bundle/c4Diagram-AHTNJAMY-C3FIQYXA.js +2596 -0
  16. package/dist/viewer-bundle/c4Diagram-AHTNJAMY-C3FIQYXA.js.map +7 -0
  17. package/dist/viewer-bundle/chunk-2QXGXAO5.js +68 -0
  18. package/dist/viewer-bundle/chunk-2QXGXAO5.js.map +7 -0
  19. package/dist/viewer-bundle/chunk-5PZT7VUU.js +67 -0
  20. package/dist/viewer-bundle/chunk-5PZT7VUU.js.map +7 -0
  21. package/dist/viewer-bundle/chunk-5YJCJF2C.js +112 -0
  22. package/dist/viewer-bundle/chunk-5YJCJF2C.js.map +7 -0
  23. package/dist/viewer-bundle/chunk-6LYV7PBV.js +1011 -0
  24. package/dist/viewer-bundle/chunk-6LYV7PBV.js.map +7 -0
  25. package/dist/viewer-bundle/chunk-6VW7D5WX.js +48 -0
  26. package/dist/viewer-bundle/chunk-6VW7D5WX.js.map +7 -0
  27. package/dist/viewer-bundle/chunk-76C5OSD4.js +2048 -0
  28. package/dist/viewer-bundle/chunk-76C5OSD4.js.map +7 -0
  29. package/dist/viewer-bundle/chunk-7NZMPQDX.js +6957 -0
  30. package/dist/viewer-bundle/chunk-7NZMPQDX.js.map +7 -0
  31. package/dist/viewer-bundle/chunk-A634GTZN.js +122 -0
  32. package/dist/viewer-bundle/chunk-A634GTZN.js.map +7 -0
  33. package/dist/viewer-bundle/chunk-AJQJUKMU.js +133 -0
  34. package/dist/viewer-bundle/chunk-AJQJUKMU.js.map +7 -0
  35. package/dist/viewer-bundle/chunk-BM2KPNFW.js +5556 -0
  36. package/dist/viewer-bundle/chunk-BM2KPNFW.js.map +7 -0
  37. package/dist/viewer-bundle/chunk-CIDUOCCG.js +25 -0
  38. package/dist/viewer-bundle/chunk-CIDUOCCG.js.map +7 -0
  39. package/dist/viewer-bundle/chunk-CZHJHAOR.js +6397 -0
  40. package/dist/viewer-bundle/chunk-CZHJHAOR.js.map +7 -0
  41. package/dist/viewer-bundle/chunk-D5RLIWY4.js +125 -0
  42. package/dist/viewer-bundle/chunk-D5RLIWY4.js.map +7 -0
  43. package/dist/viewer-bundle/chunk-DI52DQAC.js +44 -0
  44. package/dist/viewer-bundle/chunk-DI52DQAC.js.map +7 -0
  45. package/dist/viewer-bundle/chunk-EXJQLTIV.js +51 -0
  46. package/dist/viewer-bundle/chunk-EXJQLTIV.js.map +7 -0
  47. package/dist/viewer-bundle/chunk-G3PPZWPW.js +96 -0
  48. package/dist/viewer-bundle/chunk-G3PPZWPW.js.map +7 -0
  49. package/dist/viewer-bundle/chunk-GTW4IDD4.js +30297 -0
  50. package/dist/viewer-bundle/chunk-GTW4IDD4.js.map +7 -0
  51. package/dist/viewer-bundle/chunk-GVE7OA3Z.js +59 -0
  52. package/dist/viewer-bundle/chunk-GVE7OA3Z.js.map +7 -0
  53. package/dist/viewer-bundle/chunk-JBUVKVPY.js +2042 -0
  54. package/dist/viewer-bundle/chunk-JBUVKVPY.js.map +7 -0
  55. package/dist/viewer-bundle/chunk-JQLVOAQB.js +20 -0
  56. package/dist/viewer-bundle/chunk-JQLVOAQB.js.map +7 -0
  57. package/dist/viewer-bundle/chunk-LQMQSYLO.js +101 -0
  58. package/dist/viewer-bundle/chunk-LQMQSYLO.js.map +7 -0
  59. package/dist/viewer-bundle/chunk-MBFAQ3IK.js +34 -0
  60. package/dist/viewer-bundle/chunk-MBFAQ3IK.js.map +7 -0
  61. package/dist/viewer-bundle/chunk-N7G7IIKG.js +25 -0
  62. package/dist/viewer-bundle/chunk-N7G7IIKG.js.map +7 -0
  63. package/dist/viewer-bundle/chunk-NW4YG3NS.js +171 -0
  64. package/dist/viewer-bundle/chunk-NW4YG3NS.js.map +7 -0
  65. package/dist/viewer-bundle/chunk-ODEP5TKB.js +61 -0
  66. package/dist/viewer-bundle/chunk-ODEP5TKB.js.map +7 -0
  67. package/dist/viewer-bundle/chunk-OGKINV23.js +1050 -0
  68. package/dist/viewer-bundle/chunk-OGKINV23.js.map +7 -0
  69. package/dist/viewer-bundle/chunk-OGMSNDVH.js +1994 -0
  70. package/dist/viewer-bundle/chunk-OGMSNDVH.js.map +7 -0
  71. package/dist/viewer-bundle/chunk-QJVSDNAW.js +25 -0
  72. package/dist/viewer-bundle/chunk-QJVSDNAW.js.map +7 -0
  73. package/dist/viewer-bundle/chunk-RBTT26R4.js +2721 -0
  74. package/dist/viewer-bundle/chunk-RBTT26R4.js.map +7 -0
  75. package/dist/viewer-bundle/chunk-RQIPIIE2.js +48 -0
  76. package/dist/viewer-bundle/chunk-RQIPIIE2.js.map +7 -0
  77. package/dist/viewer-bundle/chunk-SRTYTXTX.js +22 -0
  78. package/dist/viewer-bundle/chunk-SRTYTXTX.js.map +7 -0
  79. package/dist/viewer-bundle/chunk-TRL7YIZG.js +1663 -0
  80. package/dist/viewer-bundle/chunk-TRL7YIZG.js.map +7 -0
  81. package/dist/viewer-bundle/chunk-U5T7X4BV.js +172 -0
  82. package/dist/viewer-bundle/chunk-U5T7X4BV.js.map +7 -0
  83. package/dist/viewer-bundle/chunk-UCAW6C6C.js +48 -0
  84. package/dist/viewer-bundle/chunk-UCAW6C6C.js.map +7 -0
  85. package/dist/viewer-bundle/chunk-UEAG4BJQ.js +93 -0
  86. package/dist/viewer-bundle/chunk-UEAG4BJQ.js.map +7 -0
  87. package/dist/viewer-bundle/chunk-UVRE3R6A.js +1039 -0
  88. package/dist/viewer-bundle/chunk-UVRE3R6A.js.map +7 -0
  89. package/dist/viewer-bundle/chunk-VODO7SV4.js +25029 -0
  90. package/dist/viewer-bundle/chunk-VODO7SV4.js.map +7 -0
  91. package/dist/viewer-bundle/chunk-YEU62MVS.js +682 -0
  92. package/dist/viewer-bundle/chunk-YEU62MVS.js.map +7 -0
  93. package/dist/viewer-bundle/chunk-YFQT7PPW.js +987 -0
  94. package/dist/viewer-bundle/chunk-YFQT7PPW.js.map +7 -0
  95. package/dist/viewer-bundle/chunk-Z4G7FG27.js +48 -0
  96. package/dist/viewer-bundle/chunk-Z4G7FG27.js.map +7 -0
  97. package/dist/viewer-bundle/chunk-ZW4Y7DIF.js +2044 -0
  98. package/dist/viewer-bundle/chunk-ZW4Y7DIF.js.map +7 -0
  99. package/dist/viewer-bundle/classDiagram-6PBFFD2Q-7VKYXLUX.js +46 -0
  100. package/dist/viewer-bundle/classDiagram-6PBFFD2Q-7VKYXLUX.js.map +7 -0
  101. package/dist/viewer-bundle/classDiagram-v2-HSJHXN6E-ACCNN7EN.js +46 -0
  102. package/dist/viewer-bundle/classDiagram-v2-HSJHXN6E-ACCNN7EN.js.map +7 -0
  103. package/dist/viewer-bundle/cose-bilkent-S5V4N54A-MUJHAA34.js +5009 -0
  104. package/dist/viewer-bundle/cose-bilkent-S5V4N54A-MUJHAA34.js.map +7 -0
  105. package/dist/viewer-bundle/dagre-KV5264BT-YC5VV3WF.js +739 -0
  106. package/dist/viewer-bundle/dagre-KV5264BT-YC5VV3WF.js.map +7 -0
  107. package/dist/viewer-bundle/dark.css +13 -0
  108. package/dist/viewer-bundle/detail.css +539 -0
  109. package/dist/viewer-bundle/diagram-5BDNPKRD-RXFPVFYK.js +214 -0
  110. package/dist/viewer-bundle/diagram-5BDNPKRD-RXFPVFYK.js.map +7 -0
  111. package/dist/viewer-bundle/diagram-G4DWMVQ6-KN7CBNBQ.js +578 -0
  112. package/dist/viewer-bundle/diagram-G4DWMVQ6-KN7CBNBQ.js.map +7 -0
  113. package/dist/viewer-bundle/diagram-MMDJMWI5-ZN6TQ7ZC.js +345 -0
  114. package/dist/viewer-bundle/diagram-MMDJMWI5-ZN6TQ7ZC.js.map +7 -0
  115. package/dist/viewer-bundle/diagram-TYMM5635-MMTUJ4KA.js +255 -0
  116. package/dist/viewer-bundle/diagram-TYMM5635-MMTUJ4KA.js.map +7 -0
  117. package/dist/viewer-bundle/docs.css +88 -0
  118. package/dist/viewer-bundle/edit-modal-BEGC2AO6.js +176 -0
  119. package/dist/viewer-bundle/edit-modal-BEGC2AO6.js.map +7 -0
  120. package/dist/viewer-bundle/erDiagram-SMLLAGMA-TBHMLD2E.js +1349 -0
  121. package/dist/viewer-bundle/erDiagram-SMLLAGMA-TBHMLD2E.js.map +7 -0
  122. package/dist/viewer-bundle/flowDiagram-DWJPFMVM-BZHLK6QB.js +2501 -0
  123. package/dist/viewer-bundle/flowDiagram-DWJPFMVM-BZHLK6QB.js.map +7 -0
  124. package/dist/viewer-bundle/ganttDiagram-T4ZO3ILL-YBARPTQR.js +2654 -0
  125. package/dist/viewer-bundle/ganttDiagram-T4ZO3ILL-YBARPTQR.js.map +7 -0
  126. package/dist/viewer-bundle/gitGraph-7Q5UKJZL-HENKIQDX.js +14 -0
  127. package/dist/viewer-bundle/gitGraph-7Q5UKJZL-HENKIQDX.js.map +7 -0
  128. package/dist/viewer-bundle/gitGraphDiagram-UUTBAWPF-M4VV3YVA.js +1946 -0
  129. package/dist/viewer-bundle/gitGraphDiagram-UUTBAWPF-M4VV3YVA.js.map +7 -0
  130. package/dist/viewer-bundle/index.html +28 -0
  131. package/dist/viewer-bundle/info-OMHHGYJF-E773USRS.js +14 -0
  132. package/dist/viewer-bundle/info-OMHHGYJF-E773USRS.js.map +7 -0
  133. package/dist/viewer-bundle/infoDiagram-42DDH7IO-C7JGUXKK.js +59 -0
  134. package/dist/viewer-bundle/infoDiagram-42DDH7IO-C7JGUXKK.js.map +7 -0
  135. package/dist/viewer-bundle/ishikawaDiagram-UXIWVN3A-YBC4X4VB.js +1012 -0
  136. package/dist/viewer-bundle/ishikawaDiagram-UXIWVN3A-YBC4X4VB.js.map +7 -0
  137. package/dist/viewer-bundle/journeyDiagram-VCZTEJTY-6WKVEOOO.js +1303 -0
  138. package/dist/viewer-bundle/journeyDiagram-VCZTEJTY-6WKVEOOO.js.map +7 -0
  139. package/dist/viewer-bundle/kanban-definition-6JOO6SKY-URTTHHO4.js +1131 -0
  140. package/dist/viewer-bundle/kanban-definition-6JOO6SKY-URTTHHO4.js.map +7 -0
  141. package/dist/viewer-bundle/katex-QN5266ZE.js +14318 -0
  142. package/dist/viewer-bundle/katex-QN5266ZE.js.map +7 -0
  143. package/dist/viewer-bundle/light.css +15 -0
  144. package/dist/viewer-bundle/main.js +4816 -0
  145. package/dist/viewer-bundle/main.js.map +7 -0
  146. package/dist/viewer-bundle/mermaid.core-AEBXU2JK.js +1708 -0
  147. package/dist/viewer-bundle/mermaid.core-AEBXU2JK.js.map +7 -0
  148. package/dist/viewer-bundle/mindmap-definition-QFDTVHPH-KUMAMRSF.js +1277 -0
  149. package/dist/viewer-bundle/mindmap-definition-QFDTVHPH-KUMAMRSF.js.map +7 -0
  150. package/dist/viewer-bundle/packet-4T2RLAQJ-IRYWWA66.js +14 -0
  151. package/dist/viewer-bundle/packet-4T2RLAQJ-IRYWWA66.js.map +7 -0
  152. package/dist/viewer-bundle/pico.classless.min.css +4 -0
  153. package/dist/viewer-bundle/pie-ZZUOXDRM-JYO4VL5N.js +14 -0
  154. package/dist/viewer-bundle/pie-ZZUOXDRM-JYO4VL5N.js.map +7 -0
  155. package/dist/viewer-bundle/pieDiagram-DEJITSTG-QOEHQN3N.js +238 -0
  156. package/dist/viewer-bundle/pieDiagram-DEJITSTG-QOEHQN3N.js.map +7 -0
  157. package/dist/viewer-bundle/prompt-modal-C4LHI7BS.js +12 -0
  158. package/dist/viewer-bundle/prompt-modal-C4LHI7BS.js.map +7 -0
  159. package/dist/viewer-bundle/quadrantDiagram-34T5L4WZ-SJNPUU5N.js +1409 -0
  160. package/dist/viewer-bundle/quadrantDiagram-34T5L4WZ-SJNPUU5N.js.map +7 -0
  161. package/dist/viewer-bundle/radar-PYXPWWZC-45BRYQSB.js +14 -0
  162. package/dist/viewer-bundle/radar-PYXPWWZC-45BRYQSB.js.map +7 -0
  163. package/dist/viewer-bundle/reason-modal-MK34MQ73.js +68 -0
  164. package/dist/viewer-bundle/reason-modal-MK34MQ73.js.map +7 -0
  165. package/dist/viewer-bundle/requirementDiagram-MS252O5E-UOMT3FCC.js +1311 -0
  166. package/dist/viewer-bundle/requirementDiagram-MS252O5E-UOMT3FCC.js.map +7 -0
  167. package/dist/viewer-bundle/sankeyDiagram-XADWPNL6-LAVJ5C6A.js +1263 -0
  168. package/dist/viewer-bundle/sankeyDiagram-XADWPNL6-LAVJ5C6A.js.map +7 -0
  169. package/dist/viewer-bundle/sequenceDiagram-FGHM5R23-3IWTOUNQ.js +4655 -0
  170. package/dist/viewer-bundle/sequenceDiagram-FGHM5R23-3IWTOUNQ.js.map +7 -0
  171. package/dist/viewer-bundle/stateDiagram-FHFEXIEX-S2OVQQON.js +495 -0
  172. package/dist/viewer-bundle/stateDiagram-FHFEXIEX-S2OVQQON.js.map +7 -0
  173. package/dist/viewer-bundle/stateDiagram-v2-QKLJ7IA2-XNZ3XXSV.js +44 -0
  174. package/dist/viewer-bundle/stateDiagram-v2-QKLJ7IA2-XNZ3XXSV.js.map +7 -0
  175. package/dist/viewer-bundle/timeline-definition-GMOUNBTQ-FHVZ7MHE.js +1646 -0
  176. package/dist/viewer-bundle/timeline-definition-GMOUNBTQ-FHVZ7MHE.js.map +7 -0
  177. package/dist/viewer-bundle/treeView-SZITEDCU-RXZXNYAM.js +14 -0
  178. package/dist/viewer-bundle/treeView-SZITEDCU-RXZXNYAM.js.map +7 -0
  179. package/dist/viewer-bundle/treemap-W4RFUUIX-2IGOFSJM.js +14 -0
  180. package/dist/viewer-bundle/treemap-W4RFUUIX-2IGOFSJM.js.map +7 -0
  181. package/dist/viewer-bundle/vennDiagram-DHZGUBPP-HEAOEXEZ.js +2544 -0
  182. package/dist/viewer-bundle/vennDiagram-DHZGUBPP-HEAOEXEZ.js.map +7 -0
  183. package/dist/viewer-bundle/wardley-RL74JXVD-VSPCLOX2.js +14 -0
  184. package/dist/viewer-bundle/wardley-RL74JXVD-VSPCLOX2.js.map +7 -0
  185. package/dist/viewer-bundle/wardleyDiagram-NUSXRM2D-EBY4FG3X.js +938 -0
  186. package/dist/viewer-bundle/wardleyDiagram-NUSXRM2D-EBY4FG3X.js.map +7 -0
  187. package/dist/viewer-bundle/xychartDiagram-5P7HB3ND-SSMUQEXK.js +1952 -0
  188. package/dist/viewer-bundle/xychartDiagram-5P7HB3ND-SSMUQEXK.js.map +7 -0
  189. package/package.json +51 -0
@@ -0,0 +1,1012 @@
1
+ import {
2
+ selectSvgElement
3
+ } from "./chunk-N7G7IIKG.js";
4
+ import {
5
+ at
6
+ } from "./chunk-6LYV7PBV.js";
7
+ import {
8
+ parseFontSize
9
+ } from "./chunk-UVRE3R6A.js";
10
+ import "./chunk-G3PPZWPW.js";
11
+ import {
12
+ clear,
13
+ common_default,
14
+ configureSvgSize,
15
+ getAccDescription,
16
+ getAccTitle,
17
+ getConfig2,
18
+ getDiagramTitle,
19
+ setAccDescription,
20
+ setAccTitle,
21
+ setDiagramTitle
22
+ } from "./chunk-7NZMPQDX.js";
23
+ import "./chunk-YEU62MVS.js";
24
+ import {
25
+ __name
26
+ } from "./chunk-CZHJHAOR.js";
27
+ import "./chunk-DI52DQAC.js";
28
+
29
+ // ../../node_modules/.pnpm/mermaid@11.14.0/node_modules/mermaid/dist/chunks/mermaid.core/ishikawaDiagram-UXIWVN3A.mjs
30
+ var parser = function() {
31
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
32
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
33
+ return o2;
34
+ }, "o"), $V0 = [1, 4], $V1 = [1, 14], $V2 = [1, 12], $V3 = [1, 13], $V4 = [6, 7, 8], $V5 = [1, 20], $V6 = [1, 18], $V7 = [1, 19], $V8 = [6, 7, 11], $V9 = [1, 6, 13, 14], $Va = [1, 23], $Vb = [1, 24], $Vc = [1, 6, 7, 11, 13, 14];
35
+ var parser2 = {
36
+ trace: /* @__PURE__ */ __name(function trace() {
37
+ }, "trace"),
38
+ yy: {},
39
+ symbols_: { "error": 2, "start": 3, "ishikawa": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "ISHIKAWA": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "TEXT": 14, "$accept": 0, "$end": 1 },
40
+ terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "ISHIKAWA", 11: "EOF", 13: "SPACELIST", 14: "TEXT" },
41
+ productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 1], [12, 1], [12, 1]],
42
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
43
+ var $0 = $$.length - 1;
44
+ switch (yystate) {
45
+ case 6:
46
+ case 7:
47
+ return yy;
48
+ break;
49
+ case 15:
50
+ yy.addNode($$[$0 - 1].length, $$[$0].trim());
51
+ break;
52
+ case 16:
53
+ yy.addNode(0, $$[$0].trim());
54
+ break;
55
+ }
56
+ }, "anonymous"),
57
+ table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: $V3 }, o($V4, [2, 3]), { 1: [2, 2] }, o($V4, [2, 4]), o($V4, [2, 5]), { 1: [2, 6], 6: $V1, 12: 15, 13: $V2, 14: $V3 }, { 6: $V1, 9: 16, 12: 11, 13: $V2, 14: $V3 }, { 6: $V5, 7: $V6, 10: 17, 11: $V7 }, o($V8, [2, 18], { 14: [1, 21] }), o($V8, [2, 16]), o($V8, [2, 17]), { 6: $V5, 7: $V6, 10: 22, 11: $V7 }, { 1: [2, 7], 6: $V1, 12: 15, 13: $V2, 14: $V3 }, o($V9, [2, 14], { 7: $Va, 11: $Vb }), o($Vc, [2, 8]), o($Vc, [2, 9]), o($Vc, [2, 10]), o($V8, [2, 15]), o($V9, [2, 13], { 7: $Va, 11: $Vb }), o($Vc, [2, 11]), o($Vc, [2, 12])],
58
+ defaultActions: { 2: [2, 1], 6: [2, 2] },
59
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
60
+ if (hash.recoverable) {
61
+ this.trace(str);
62
+ } else {
63
+ var error = new Error(str);
64
+ error.hash = hash;
65
+ throw error;
66
+ }
67
+ }, "parseError"),
68
+ parse: /* @__PURE__ */ __name(function parse(input) {
69
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
70
+ var args = lstack.slice.call(arguments, 1);
71
+ var lexer2 = Object.create(this.lexer);
72
+ var sharedState = { yy: {} };
73
+ for (var k in this.yy) {
74
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
75
+ sharedState.yy[k] = this.yy[k];
76
+ }
77
+ }
78
+ lexer2.setInput(input, sharedState.yy);
79
+ sharedState.yy.lexer = lexer2;
80
+ sharedState.yy.parser = this;
81
+ if (typeof lexer2.yylloc == "undefined") {
82
+ lexer2.yylloc = {};
83
+ }
84
+ var yyloc = lexer2.yylloc;
85
+ lstack.push(yyloc);
86
+ var ranges = lexer2.options && lexer2.options.ranges;
87
+ if (typeof sharedState.yy.parseError === "function") {
88
+ this.parseError = sharedState.yy.parseError;
89
+ } else {
90
+ this.parseError = Object.getPrototypeOf(this).parseError;
91
+ }
92
+ function popStack(n) {
93
+ stack.length = stack.length - 2 * n;
94
+ vstack.length = vstack.length - n;
95
+ lstack.length = lstack.length - n;
96
+ }
97
+ __name(popStack, "popStack");
98
+ function lex() {
99
+ var token;
100
+ token = tstack.pop() || lexer2.lex() || EOF;
101
+ if (typeof token !== "number") {
102
+ if (token instanceof Array) {
103
+ tstack = token;
104
+ token = tstack.pop();
105
+ }
106
+ token = self.symbols_[token] || token;
107
+ }
108
+ return token;
109
+ }
110
+ __name(lex, "lex");
111
+ var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
112
+ while (true) {
113
+ state = stack[stack.length - 1];
114
+ if (this.defaultActions[state]) {
115
+ action = this.defaultActions[state];
116
+ } else {
117
+ if (symbol === null || typeof symbol == "undefined") {
118
+ symbol = lex();
119
+ }
120
+ action = table[state] && table[state][symbol];
121
+ }
122
+ if (typeof action === "undefined" || !action.length || !action[0]) {
123
+ var errStr = "";
124
+ expected = [];
125
+ for (p in table[state]) {
126
+ if (this.terminals_[p] && p > TERROR) {
127
+ expected.push("'" + this.terminals_[p] + "'");
128
+ }
129
+ }
130
+ if (lexer2.showPosition) {
131
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
132
+ } else {
133
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
134
+ }
135
+ this.parseError(errStr, {
136
+ text: lexer2.match,
137
+ token: this.terminals_[symbol] || symbol,
138
+ line: lexer2.yylineno,
139
+ loc: yyloc,
140
+ expected
141
+ });
142
+ }
143
+ if (action[0] instanceof Array && action.length > 1) {
144
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
145
+ }
146
+ switch (action[0]) {
147
+ case 1:
148
+ stack.push(symbol);
149
+ vstack.push(lexer2.yytext);
150
+ lstack.push(lexer2.yylloc);
151
+ stack.push(action[1]);
152
+ symbol = null;
153
+ if (!preErrorSymbol) {
154
+ yyleng = lexer2.yyleng;
155
+ yytext = lexer2.yytext;
156
+ yylineno = lexer2.yylineno;
157
+ yyloc = lexer2.yylloc;
158
+ if (recovering > 0) {
159
+ recovering--;
160
+ }
161
+ } else {
162
+ symbol = preErrorSymbol;
163
+ preErrorSymbol = null;
164
+ }
165
+ break;
166
+ case 2:
167
+ len = this.productions_[action[1]][1];
168
+ yyval.$ = vstack[vstack.length - len];
169
+ yyval._$ = {
170
+ first_line: lstack[lstack.length - (len || 1)].first_line,
171
+ last_line: lstack[lstack.length - 1].last_line,
172
+ first_column: lstack[lstack.length - (len || 1)].first_column,
173
+ last_column: lstack[lstack.length - 1].last_column
174
+ };
175
+ if (ranges) {
176
+ yyval._$.range = [
177
+ lstack[lstack.length - (len || 1)].range[0],
178
+ lstack[lstack.length - 1].range[1]
179
+ ];
180
+ }
181
+ r = this.performAction.apply(yyval, [
182
+ yytext,
183
+ yyleng,
184
+ yylineno,
185
+ sharedState.yy,
186
+ action[1],
187
+ vstack,
188
+ lstack
189
+ ].concat(args));
190
+ if (typeof r !== "undefined") {
191
+ return r;
192
+ }
193
+ if (len) {
194
+ stack = stack.slice(0, -1 * len * 2);
195
+ vstack = vstack.slice(0, -1 * len);
196
+ lstack = lstack.slice(0, -1 * len);
197
+ }
198
+ stack.push(this.productions_[action[1]][0]);
199
+ vstack.push(yyval.$);
200
+ lstack.push(yyval._$);
201
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
202
+ stack.push(newState);
203
+ break;
204
+ case 3:
205
+ return true;
206
+ }
207
+ }
208
+ return true;
209
+ }, "parse")
210
+ };
211
+ var lexer = /* @__PURE__ */ function() {
212
+ var lexer2 = {
213
+ EOF: 1,
214
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
215
+ if (this.yy.parser) {
216
+ this.yy.parser.parseError(str, hash);
217
+ } else {
218
+ throw new Error(str);
219
+ }
220
+ }, "parseError"),
221
+ // resets the lexer, sets new input
222
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
223
+ this.yy = yy || this.yy || {};
224
+ this._input = input;
225
+ this._more = this._backtrack = this.done = false;
226
+ this.yylineno = this.yyleng = 0;
227
+ this.yytext = this.matched = this.match = "";
228
+ this.conditionStack = ["INITIAL"];
229
+ this.yylloc = {
230
+ first_line: 1,
231
+ first_column: 0,
232
+ last_line: 1,
233
+ last_column: 0
234
+ };
235
+ if (this.options.ranges) {
236
+ this.yylloc.range = [0, 0];
237
+ }
238
+ this.offset = 0;
239
+ return this;
240
+ }, "setInput"),
241
+ // consumes and returns one char from the input
242
+ input: /* @__PURE__ */ __name(function() {
243
+ var ch = this._input[0];
244
+ this.yytext += ch;
245
+ this.yyleng++;
246
+ this.offset++;
247
+ this.match += ch;
248
+ this.matched += ch;
249
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
250
+ if (lines) {
251
+ this.yylineno++;
252
+ this.yylloc.last_line++;
253
+ } else {
254
+ this.yylloc.last_column++;
255
+ }
256
+ if (this.options.ranges) {
257
+ this.yylloc.range[1]++;
258
+ }
259
+ this._input = this._input.slice(1);
260
+ return ch;
261
+ }, "input"),
262
+ // unshifts one char (or a string) into the input
263
+ unput: /* @__PURE__ */ __name(function(ch) {
264
+ var len = ch.length;
265
+ var lines = ch.split(/(?:\r\n?|\n)/g);
266
+ this._input = ch + this._input;
267
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
268
+ this.offset -= len;
269
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
270
+ this.match = this.match.substr(0, this.match.length - 1);
271
+ this.matched = this.matched.substr(0, this.matched.length - 1);
272
+ if (lines.length - 1) {
273
+ this.yylineno -= lines.length - 1;
274
+ }
275
+ var r = this.yylloc.range;
276
+ this.yylloc = {
277
+ first_line: this.yylloc.first_line,
278
+ last_line: this.yylineno + 1,
279
+ first_column: this.yylloc.first_column,
280
+ last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
281
+ };
282
+ if (this.options.ranges) {
283
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
284
+ }
285
+ this.yyleng = this.yytext.length;
286
+ return this;
287
+ }, "unput"),
288
+ // When called from action, caches matched text and appends it on next action
289
+ more: /* @__PURE__ */ __name(function() {
290
+ this._more = true;
291
+ return this;
292
+ }, "more"),
293
+ // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
294
+ reject: /* @__PURE__ */ __name(function() {
295
+ if (this.options.backtrack_lexer) {
296
+ this._backtrack = true;
297
+ } else {
298
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
299
+ text: "",
300
+ token: null,
301
+ line: this.yylineno
302
+ });
303
+ }
304
+ return this;
305
+ }, "reject"),
306
+ // retain first n characters of the match
307
+ less: /* @__PURE__ */ __name(function(n) {
308
+ this.unput(this.match.slice(n));
309
+ }, "less"),
310
+ // displays already matched input, i.e. for error messages
311
+ pastInput: /* @__PURE__ */ __name(function() {
312
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
313
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
314
+ }, "pastInput"),
315
+ // displays upcoming input, i.e. for error messages
316
+ upcomingInput: /* @__PURE__ */ __name(function() {
317
+ var next = this.match;
318
+ if (next.length < 20) {
319
+ next += this._input.substr(0, 20 - next.length);
320
+ }
321
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
322
+ }, "upcomingInput"),
323
+ // displays the character position where the lexing error occurred, i.e. for error messages
324
+ showPosition: /* @__PURE__ */ __name(function() {
325
+ var pre = this.pastInput();
326
+ var c = new Array(pre.length + 1).join("-");
327
+ return pre + this.upcomingInput() + "\n" + c + "^";
328
+ }, "showPosition"),
329
+ // test the lexed token: return FALSE when not a match, otherwise return token
330
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
331
+ var token, lines, backup;
332
+ if (this.options.backtrack_lexer) {
333
+ backup = {
334
+ yylineno: this.yylineno,
335
+ yylloc: {
336
+ first_line: this.yylloc.first_line,
337
+ last_line: this.last_line,
338
+ first_column: this.yylloc.first_column,
339
+ last_column: this.yylloc.last_column
340
+ },
341
+ yytext: this.yytext,
342
+ match: this.match,
343
+ matches: this.matches,
344
+ matched: this.matched,
345
+ yyleng: this.yyleng,
346
+ offset: this.offset,
347
+ _more: this._more,
348
+ _input: this._input,
349
+ yy: this.yy,
350
+ conditionStack: this.conditionStack.slice(0),
351
+ done: this.done
352
+ };
353
+ if (this.options.ranges) {
354
+ backup.yylloc.range = this.yylloc.range.slice(0);
355
+ }
356
+ }
357
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
358
+ if (lines) {
359
+ this.yylineno += lines.length;
360
+ }
361
+ this.yylloc = {
362
+ first_line: this.yylloc.last_line,
363
+ last_line: this.yylineno + 1,
364
+ first_column: this.yylloc.last_column,
365
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
366
+ };
367
+ this.yytext += match[0];
368
+ this.match += match[0];
369
+ this.matches = match;
370
+ this.yyleng = this.yytext.length;
371
+ if (this.options.ranges) {
372
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
373
+ }
374
+ this._more = false;
375
+ this._backtrack = false;
376
+ this._input = this._input.slice(match[0].length);
377
+ this.matched += match[0];
378
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
379
+ if (this.done && this._input) {
380
+ this.done = false;
381
+ }
382
+ if (token) {
383
+ return token;
384
+ } else if (this._backtrack) {
385
+ for (var k in backup) {
386
+ this[k] = backup[k];
387
+ }
388
+ return false;
389
+ }
390
+ return false;
391
+ }, "test_match"),
392
+ // return next match in input
393
+ next: /* @__PURE__ */ __name(function() {
394
+ if (this.done) {
395
+ return this.EOF;
396
+ }
397
+ if (!this._input) {
398
+ this.done = true;
399
+ }
400
+ var token, match, tempMatch, index;
401
+ if (!this._more) {
402
+ this.yytext = "";
403
+ this.match = "";
404
+ }
405
+ var rules = this._currentRules();
406
+ for (var i = 0; i < rules.length; i++) {
407
+ tempMatch = this._input.match(this.rules[rules[i]]);
408
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
409
+ match = tempMatch;
410
+ index = i;
411
+ if (this.options.backtrack_lexer) {
412
+ token = this.test_match(tempMatch, rules[i]);
413
+ if (token !== false) {
414
+ return token;
415
+ } else if (this._backtrack) {
416
+ match = false;
417
+ continue;
418
+ } else {
419
+ return false;
420
+ }
421
+ } else if (!this.options.flex) {
422
+ break;
423
+ }
424
+ }
425
+ }
426
+ if (match) {
427
+ token = this.test_match(match, rules[index]);
428
+ if (token !== false) {
429
+ return token;
430
+ }
431
+ return false;
432
+ }
433
+ if (this._input === "") {
434
+ return this.EOF;
435
+ } else {
436
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
437
+ text: "",
438
+ token: null,
439
+ line: this.yylineno
440
+ });
441
+ }
442
+ }, "next"),
443
+ // return next match that has a token
444
+ lex: /* @__PURE__ */ __name(function lex() {
445
+ var r = this.next();
446
+ if (r) {
447
+ return r;
448
+ } else {
449
+ return this.lex();
450
+ }
451
+ }, "lex"),
452
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
453
+ begin: /* @__PURE__ */ __name(function begin(condition) {
454
+ this.conditionStack.push(condition);
455
+ }, "begin"),
456
+ // pop the previously active lexer condition state off the condition stack
457
+ popState: /* @__PURE__ */ __name(function popState() {
458
+ var n = this.conditionStack.length - 1;
459
+ if (n > 0) {
460
+ return this.conditionStack.pop();
461
+ } else {
462
+ return this.conditionStack[0];
463
+ }
464
+ }, "popState"),
465
+ // produce the lexer rule set which is active for the currently active lexer condition state
466
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
467
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
468
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
469
+ } else {
470
+ return this.conditions["INITIAL"].rules;
471
+ }
472
+ }, "_currentRules"),
473
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
474
+ topState: /* @__PURE__ */ __name(function topState(n) {
475
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
476
+ if (n >= 0) {
477
+ return this.conditionStack[n];
478
+ } else {
479
+ return "INITIAL";
480
+ }
481
+ }, "topState"),
482
+ // alias for begin(condition)
483
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
484
+ this.begin(condition);
485
+ }, "pushState"),
486
+ // return the number of states currently on the stack
487
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
488
+ return this.conditionStack.length;
489
+ }, "stateStackSize"),
490
+ options: { "case-insensitive": true },
491
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
492
+ var YYSTATE = YY_START;
493
+ switch ($avoiding_name_collisions) {
494
+ case 0:
495
+ return 6;
496
+ break;
497
+ case 1:
498
+ return 8;
499
+ break;
500
+ case 2:
501
+ return 8;
502
+ break;
503
+ case 3:
504
+ return 6;
505
+ break;
506
+ case 4:
507
+ return 7;
508
+ break;
509
+ case 5:
510
+ return 13;
511
+ break;
512
+ case 6:
513
+ return 14;
514
+ break;
515
+ case 7:
516
+ return 11;
517
+ break;
518
+ }
519
+ }, "anonymous"),
520
+ rules: [/^(?:\s*%%.*)/i, /^(?:ishikawa-beta\b)/i, /^(?:ishikawa\b)/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:[^\n]+)/i, /^(?:$)/i],
521
+ conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } }
522
+ };
523
+ return lexer2;
524
+ }();
525
+ parser2.lexer = lexer;
526
+ function Parser() {
527
+ this.yy = {};
528
+ }
529
+ __name(Parser, "Parser");
530
+ Parser.prototype = parser2;
531
+ parser2.Parser = Parser;
532
+ return new Parser();
533
+ }();
534
+ parser.parser = parser;
535
+ var ishikawa_default = parser;
536
+ var IshikawaDB = class {
537
+ constructor() {
538
+ this.stack = [];
539
+ this.clear = this.clear.bind(this);
540
+ this.addNode = this.addNode.bind(this);
541
+ this.getRoot = this.getRoot.bind(this);
542
+ }
543
+ static {
544
+ __name(this, "IshikawaDB");
545
+ }
546
+ clear() {
547
+ this.root = void 0;
548
+ this.stack = [];
549
+ this.baseLevel = void 0;
550
+ clear();
551
+ }
552
+ getRoot() {
553
+ return this.root;
554
+ }
555
+ addNode(rawLevel, text) {
556
+ const label = common_default.sanitizeText(text, getConfig2());
557
+ if (!this.root) {
558
+ this.root = { text: label, children: [] };
559
+ this.stack = [{ level: 0, node: this.root }];
560
+ setDiagramTitle(label);
561
+ return;
562
+ }
563
+ this.baseLevel ??= rawLevel;
564
+ let level = rawLevel - this.baseLevel + 1;
565
+ if (level <= 0) {
566
+ level = 1;
567
+ }
568
+ while (this.stack.length > 1 && this.stack[this.stack.length - 1].level >= level) {
569
+ this.stack.pop();
570
+ }
571
+ const parent = this.stack[this.stack.length - 1].node;
572
+ const node = { text: label, children: [] };
573
+ parent.children.push(node);
574
+ this.stack.push({ level, node });
575
+ }
576
+ getAccTitle() {
577
+ return getAccTitle();
578
+ }
579
+ setAccTitle(title) {
580
+ setAccTitle(title);
581
+ }
582
+ getAccDescription() {
583
+ return getAccDescription();
584
+ }
585
+ setAccDescription(description) {
586
+ setAccDescription(description);
587
+ }
588
+ getDiagramTitle() {
589
+ return getDiagramTitle();
590
+ }
591
+ setDiagramTitle(title) {
592
+ setDiagramTitle(title);
593
+ }
594
+ };
595
+ var FONT_SIZE_DEFAULT = 14;
596
+ var SPINE_BASE_LENGTH = 250;
597
+ var BONE_STUB = 30;
598
+ var BONE_BASE = 60;
599
+ var BONE_PER_CHILD = 5;
600
+ var ANGLE = 82 * Math.PI / 180;
601
+ var COS_A = Math.cos(ANGLE);
602
+ var SIN_A = Math.sin(ANGLE);
603
+ var applyPaddedViewBox = /* @__PURE__ */ __name((svgEl, pad, maxW) => {
604
+ const bbox = svgEl.node().getBBox();
605
+ const w = bbox.width + pad * 2;
606
+ const h = bbox.height + pad * 2;
607
+ configureSvgSize(svgEl, h, w, maxW);
608
+ svgEl.attr("viewBox", `${bbox.x - pad} ${bbox.y - pad} ${w} ${h}`);
609
+ }, "applyPaddedViewBox");
610
+ var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
611
+ const db = diagram2.db;
612
+ const root = db.getRoot();
613
+ if (!root) {
614
+ return;
615
+ }
616
+ const drawConfig = getConfig2();
617
+ const { look, handDrawnSeed, themeVariables } = drawConfig;
618
+ const fontSize = parseFontSize(drawConfig.fontSize)[0] ?? FONT_SIZE_DEFAULT;
619
+ const isHandDrawn = look === "handDrawn";
620
+ const causes = root.children ?? [];
621
+ const padding = drawConfig.ishikawa?.diagramPadding ?? 20;
622
+ const useMaxWidth = drawConfig.ishikawa?.useMaxWidth ?? false;
623
+ const svg = selectSvgElement(id);
624
+ const g = svg.append("g").attr("class", "ishikawa");
625
+ const roughSvg = isHandDrawn ? at.svg(svg.node()) : void 0;
626
+ const roughContext = roughSvg ? {
627
+ roughSvg,
628
+ seed: handDrawnSeed ?? 0,
629
+ lineColor: themeVariables?.lineColor ?? "#333",
630
+ fillColor: themeVariables?.mainBkg ?? "#fff"
631
+ } : void 0;
632
+ const markerId = `ishikawa-arrow-${id}`;
633
+ if (!isHandDrawn) {
634
+ g.append("defs").append("marker").attr("id", markerId).attr("viewBox", "0 0 10 10").attr("refX", 0).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 Z").attr("class", "ishikawa-arrow");
635
+ }
636
+ let spineX = 0;
637
+ let spineY = SPINE_BASE_LENGTH;
638
+ const spineLine = isHandDrawn ? void 0 : drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine");
639
+ drawHead(g, spineX, spineY, root.text, fontSize, roughContext);
640
+ if (!causes.length) {
641
+ if (isHandDrawn) {
642
+ drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine", roughContext);
643
+ }
644
+ applyPaddedViewBox(svg, padding, useMaxWidth);
645
+ return;
646
+ }
647
+ spineX -= 20;
648
+ const upperCauses = causes.filter((_, i) => i % 2 === 0);
649
+ const lowerCauses = causes.filter((_, i) => i % 2 === 1);
650
+ const upperStats = sideStats(upperCauses);
651
+ const lowerStats = sideStats(lowerCauses);
652
+ const descendantTotal = upperStats.total + lowerStats.total;
653
+ let upperLen = SPINE_BASE_LENGTH;
654
+ let lowerLen = SPINE_BASE_LENGTH;
655
+ if (descendantTotal > 0) {
656
+ const pool = SPINE_BASE_LENGTH * 2;
657
+ const minLen = SPINE_BASE_LENGTH * 0.3;
658
+ upperLen = Math.max(minLen, pool * (upperStats.total / descendantTotal));
659
+ lowerLen = Math.max(minLen, pool * (lowerStats.total / descendantTotal));
660
+ }
661
+ const minSpacing = fontSize * 2;
662
+ upperLen = Math.max(upperLen, upperStats.max * minSpacing);
663
+ lowerLen = Math.max(lowerLen, lowerStats.max * minSpacing);
664
+ spineY = Math.max(upperLen, SPINE_BASE_LENGTH);
665
+ if (spineLine) {
666
+ spineLine.attr("y1", spineY).attr("y2", spineY);
667
+ }
668
+ g.select(".ishikawa-head-group").attr("transform", `translate(0,${spineY})`);
669
+ const pairCount = Math.ceil(causes.length / 2);
670
+ for (let p = 0; p < pairCount; p++) {
671
+ const pg = g.append("g").attr("class", "ishikawa-pair");
672
+ for (const [cause, dir, len] of [
673
+ [causes[p * 2], -1, upperLen],
674
+ [causes[p * 2 + 1], 1, lowerLen]
675
+ ]) {
676
+ if (cause) {
677
+ drawBranch(pg, cause, spineX, spineY, dir, len, fontSize, roughContext);
678
+ }
679
+ }
680
+ spineX = pg.selectAll("text").nodes().reduce((left, n) => Math.min(left, n.getBBox().x), Infinity);
681
+ }
682
+ if (isHandDrawn) {
683
+ drawLine(g, spineX, spineY, 0, spineY, "ishikawa-spine", roughContext);
684
+ } else {
685
+ spineLine.attr("x1", spineX);
686
+ const markerUrl = `url(#${markerId})`;
687
+ g.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start", markerUrl);
688
+ }
689
+ applyPaddedViewBox(svg, padding, useMaxWidth);
690
+ }, "draw");
691
+ var sideStats = /* @__PURE__ */ __name((nodes) => {
692
+ const countDescendants = /* @__PURE__ */ __name((node) => node.children.reduce((sum, child) => sum + 1 + countDescendants(child), 0), "countDescendants");
693
+ return nodes.reduce(
694
+ (stats, node) => {
695
+ const descendants = countDescendants(node);
696
+ stats.total += descendants;
697
+ stats.max = Math.max(stats.max, descendants);
698
+ return stats;
699
+ },
700
+ { total: 0, max: 0 }
701
+ );
702
+ }, "sideStats");
703
+ var drawHead = /* @__PURE__ */ __name((svg, x, y, label, fontSize, roughContext) => {
704
+ const maxChars = Math.max(6, Math.floor(110 / (fontSize * 0.6)));
705
+ const headGroup = svg.append("g").attr("class", "ishikawa-head-group").attr("transform", `translate(${x},${y})`);
706
+ const textEl = drawMultilineText(
707
+ headGroup,
708
+ wrapText(label, maxChars),
709
+ 0,
710
+ 0,
711
+ "ishikawa-head-label",
712
+ "start",
713
+ fontSize
714
+ );
715
+ const tb = textEl.node().getBBox();
716
+ const w = Math.max(60, tb.width + 6);
717
+ const h = Math.max(40, tb.height * 2 + 40);
718
+ const headPath = `M 0 ${-h / 2} L 0 ${h / 2} Q ${w * 2.4} 0 0 ${-h / 2} Z`;
719
+ if (roughContext) {
720
+ const roughNode = roughContext.roughSvg.path(headPath, {
721
+ roughness: 1.5,
722
+ seed: roughContext.seed,
723
+ fill: roughContext.fillColor,
724
+ fillStyle: "hachure",
725
+ fillWeight: 2.5,
726
+ hachureGap: 5,
727
+ stroke: roughContext.lineColor,
728
+ strokeWidth: 2
729
+ });
730
+ headGroup.insert(() => roughNode, ":first-child").attr("class", "ishikawa-head");
731
+ } else {
732
+ headGroup.insert("path", ":first-child").attr("class", "ishikawa-head").attr("d", headPath);
733
+ }
734
+ textEl.attr("transform", `translate(${(w - tb.width) / 2 - tb.x + 3},${-tb.y - tb.height / 2})`);
735
+ }, "drawHead");
736
+ var flattenTree = /* @__PURE__ */ __name((children, direction) => {
737
+ const entries = [];
738
+ const yOrder = [];
739
+ const walk = /* @__PURE__ */ __name((nodes, pid, depth) => {
740
+ const ordered = direction === -1 ? [...nodes].reverse() : nodes;
741
+ for (const child of ordered) {
742
+ const idx = entries.length;
743
+ const gc = child.children ?? [];
744
+ entries.push({
745
+ depth,
746
+ text: wrapText(child.text, 15),
747
+ parentIndex: pid,
748
+ childCount: gc.length
749
+ });
750
+ if (depth % 2 === 0) {
751
+ yOrder.push(idx);
752
+ if (gc.length) {
753
+ walk(gc, idx, depth + 1);
754
+ }
755
+ } else {
756
+ if (gc.length) {
757
+ walk(gc, idx, depth + 1);
758
+ }
759
+ yOrder.push(idx);
760
+ }
761
+ }
762
+ }, "walk");
763
+ walk(children, -1, 2);
764
+ return { entries, yOrder };
765
+ }, "flattenTree");
766
+ var drawCauseLabel = /* @__PURE__ */ __name((svg, text, x, y, direction, fontSize, roughContext) => {
767
+ const lg = svg.append("g").attr("class", "ishikawa-label-group");
768
+ const lt = drawMultilineText(
769
+ lg,
770
+ text,
771
+ x,
772
+ y + 11 * direction,
773
+ "ishikawa-label cause",
774
+ "middle",
775
+ fontSize
776
+ );
777
+ const tb = lt.node().getBBox();
778
+ if (roughContext) {
779
+ const roughNode = roughContext.roughSvg.rectangle(
780
+ tb.x - 20,
781
+ tb.y - 2,
782
+ tb.width + 40,
783
+ tb.height + 4,
784
+ {
785
+ roughness: 1.5,
786
+ seed: roughContext.seed,
787
+ fill: roughContext.fillColor,
788
+ fillStyle: "hachure",
789
+ fillWeight: 2.5,
790
+ hachureGap: 5,
791
+ stroke: roughContext.lineColor,
792
+ strokeWidth: 2
793
+ }
794
+ );
795
+ lg.insert(() => roughNode, ":first-child").attr("class", "ishikawa-label-box");
796
+ } else {
797
+ lg.insert("rect", ":first-child").attr("class", "ishikawa-label-box").attr("x", tb.x - 20).attr("y", tb.y - 2).attr("width", tb.width + 40).attr("height", tb.height + 4);
798
+ }
799
+ }, "drawCauseLabel");
800
+ var drawArrowMarker = /* @__PURE__ */ __name((g, x, y, dx, dy, roughContext) => {
801
+ const len = Math.sqrt(dx * dx + dy * dy);
802
+ if (len === 0) {
803
+ return;
804
+ }
805
+ const ux = dx / len;
806
+ const uy = dy / len;
807
+ const s = 6;
808
+ const px = -uy * s;
809
+ const py = ux * s;
810
+ const tipX = x;
811
+ const tipY = y;
812
+ const d = `M ${tipX} ${tipY} L ${tipX - ux * s * 2 + px} ${tipY - uy * s * 2 + py} L ${tipX - ux * s * 2 - px} ${tipY - uy * s * 2 - py} Z`;
813
+ const roughNode = roughContext.roughSvg.path(d, {
814
+ roughness: 1,
815
+ seed: roughContext.seed,
816
+ fill: roughContext.lineColor,
817
+ fillStyle: "solid",
818
+ stroke: roughContext.lineColor,
819
+ strokeWidth: 1
820
+ });
821
+ g.append(() => roughNode);
822
+ }, "drawArrowMarker");
823
+ var drawBranch = /* @__PURE__ */ __name((svg, node, startX, startY, direction, length, fontSize, roughContext) => {
824
+ const children = node.children ?? [];
825
+ const lineLen = length * (children.length ? 1 : 0.2);
826
+ const dx = -COS_A * lineLen;
827
+ const dy = SIN_A * lineLen * direction;
828
+ const endX = startX + dx;
829
+ const endY = startY + dy;
830
+ drawLine(svg, startX, startY, endX, endY, "ishikawa-branch", roughContext);
831
+ if (roughContext) {
832
+ drawArrowMarker(svg, startX, startY, startX - endX, startY - endY, roughContext);
833
+ }
834
+ drawCauseLabel(svg, node.text, endX, endY, direction, fontSize, roughContext);
835
+ if (!children.length) {
836
+ return;
837
+ }
838
+ const { entries, yOrder } = flattenTree(children, direction);
839
+ const entryCount = entries.length;
840
+ const ys = new Array(entryCount);
841
+ for (const [slot, entryIdx] of yOrder.entries()) {
842
+ ys[entryIdx] = startY + dy * ((slot + 1) / (entryCount + 1));
843
+ }
844
+ const bones = /* @__PURE__ */ new Map();
845
+ bones.set(-1, {
846
+ x0: startX,
847
+ y0: startY,
848
+ x1: endX,
849
+ y1: endY,
850
+ childCount: children.length,
851
+ childrenDrawn: 0
852
+ });
853
+ const diagonalX = -COS_A;
854
+ const diagonalY = SIN_A * direction;
855
+ const oddLabel = direction < 0 ? "ishikawa-label up" : "ishikawa-label down";
856
+ for (const [i, e] of entries.entries()) {
857
+ const y = ys[i];
858
+ const par = bones.get(e.parentIndex);
859
+ const grp = svg.append("g").attr("class", "ishikawa-sub-group");
860
+ let bx0 = 0;
861
+ let by0 = 0;
862
+ let bx1 = 0;
863
+ if (e.depth % 2 === 0) {
864
+ const dyP = par.y1 - par.y0;
865
+ bx0 = lerp(par.x0, par.x1, dyP ? (y - par.y0) / dyP : 0.5);
866
+ by0 = y;
867
+ bx1 = bx0 - (e.childCount > 0 ? BONE_BASE + e.childCount * BONE_PER_CHILD : BONE_STUB);
868
+ drawLine(grp, bx0, y, bx1, y, "ishikawa-sub-branch", roughContext);
869
+ if (roughContext) {
870
+ drawArrowMarker(grp, bx0, y, 1, 0, roughContext);
871
+ }
872
+ drawMultilineText(grp, e.text, bx1, y, "ishikawa-label align", "end", fontSize);
873
+ } else {
874
+ const k = par.childrenDrawn++;
875
+ bx0 = lerp(par.x0, par.x1, (par.childCount - k) / (par.childCount + 1));
876
+ by0 = par.y0;
877
+ bx1 = bx0 + diagonalX * ((y - by0) / diagonalY);
878
+ drawLine(grp, bx0, by0, bx1, y, "ishikawa-sub-branch", roughContext);
879
+ if (roughContext) {
880
+ drawArrowMarker(grp, bx0, by0, bx0 - bx1, by0 - y, roughContext);
881
+ }
882
+ drawMultilineText(grp, e.text, bx1, y, oddLabel, "end", fontSize);
883
+ }
884
+ if (e.childCount > 0) {
885
+ bones.set(i, {
886
+ x0: bx0,
887
+ y0: by0,
888
+ x1: bx1,
889
+ y1: y,
890
+ childCount: e.childCount,
891
+ childrenDrawn: 0
892
+ });
893
+ }
894
+ }
895
+ }, "drawBranch");
896
+ var splitLines = /* @__PURE__ */ __name((text) => text.split(/<br\s*\/?>|\n/), "splitLines");
897
+ var wrapText = /* @__PURE__ */ __name((text, maxChars) => {
898
+ if (text.length <= maxChars) {
899
+ return text;
900
+ }
901
+ const lines = [];
902
+ for (const word of text.split(/\s+/)) {
903
+ const last = lines.length - 1;
904
+ if (last >= 0 && lines[last].length + 1 + word.length <= maxChars) {
905
+ lines[last] += " " + word;
906
+ } else {
907
+ lines.push(word);
908
+ }
909
+ }
910
+ return lines.join("\n");
911
+ }, "wrapText");
912
+ var drawMultilineText = /* @__PURE__ */ __name((g, text, x, y, cls, anchor, fontSize) => {
913
+ const lines = splitLines(text);
914
+ const lh = fontSize * 1.05;
915
+ const el = g.append("text").attr("class", cls).attr("text-anchor", anchor).attr("x", x).attr("y", y - (lines.length - 1) * lh / 2);
916
+ for (const [i, line] of lines.entries()) {
917
+ el.append("tspan").attr("x", x).attr("dy", i === 0 ? 0 : lh).text(line);
918
+ }
919
+ return el;
920
+ }, "drawMultilineText");
921
+ var lerp = /* @__PURE__ */ __name((a, b, t) => a + (b - a) * t, "lerp");
922
+ var drawLine = /* @__PURE__ */ __name((g, x1, y1, x2, y2, cls, roughContext) => {
923
+ if (roughContext) {
924
+ const roughNode = roughContext.roughSvg.line(x1, y1, x2, y2, {
925
+ roughness: 1.5,
926
+ seed: roughContext.seed,
927
+ stroke: roughContext.lineColor,
928
+ strokeWidth: 2
929
+ });
930
+ g.append(() => roughNode).attr("class", cls);
931
+ return void 0;
932
+ }
933
+ return g.append("line").attr("class", cls).attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2);
934
+ }, "drawLine");
935
+ var renderer = { draw };
936
+ var getStyles = /* @__PURE__ */ __name((options) => `
937
+ .ishikawa .ishikawa-spine,
938
+ .ishikawa .ishikawa-branch,
939
+ .ishikawa .ishikawa-sub-branch {
940
+ stroke: ${options.lineColor};
941
+ stroke-width: 2;
942
+ fill: none;
943
+ }
944
+
945
+ .ishikawa .ishikawa-sub-branch {
946
+ stroke-width: 1;
947
+ }
948
+
949
+ .ishikawa .ishikawa-arrow {
950
+ fill: ${options.lineColor};
951
+ }
952
+
953
+ .ishikawa .ishikawa-head {
954
+ fill: ${options.mainBkg};
955
+ stroke: ${options.lineColor};
956
+ stroke-width: 2;
957
+ }
958
+
959
+ .ishikawa .ishikawa-label-box {
960
+ fill: ${options.mainBkg};
961
+ stroke: ${options.lineColor};
962
+ stroke-width: 2;
963
+ }
964
+
965
+ .ishikawa text {
966
+ font-family: ${options.fontFamily};
967
+ font-size: ${options.fontSize};
968
+ fill: ${options.textColor};
969
+ }
970
+
971
+ .ishikawa .ishikawa-head-label {
972
+ font-weight: 600;
973
+ text-anchor: middle;
974
+ dominant-baseline: middle;
975
+ font-size: 14px;
976
+ }
977
+
978
+ .ishikawa .ishikawa-label {
979
+ text-anchor: end;
980
+ }
981
+
982
+ .ishikawa .ishikawa-label.cause {
983
+ text-anchor: middle;
984
+ dominant-baseline: middle;
985
+ }
986
+
987
+ .ishikawa .ishikawa-label.align {
988
+ text-anchor: end;
989
+ dominant-baseline: middle;
990
+ }
991
+
992
+ .ishikawa .ishikawa-label.up {
993
+ dominant-baseline: baseline;
994
+ }
995
+
996
+ .ishikawa .ishikawa-label.down {
997
+ dominant-baseline: hanging;
998
+ }
999
+ `, "getStyles");
1000
+ var ishikawaStyles_default = getStyles;
1001
+ var diagram = {
1002
+ parser: ishikawa_default,
1003
+ get db() {
1004
+ return new IshikawaDB();
1005
+ },
1006
+ renderer,
1007
+ styles: ishikawaStyles_default
1008
+ };
1009
+ export {
1010
+ diagram
1011
+ };
1012
+ //# sourceMappingURL=ishikawaDiagram-UXIWVN3A-YBC4X4VB.js.map