dominds 1.13.2 → 1.15.2

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/dist/bootstrap/global-dialog-event-broadcaster.d.ts +18 -0
  2. package/dist/bootstrap/global-dialog-event-broadcaster.js +81 -0
  3. package/dist/dialog-fork.js +13 -12
  4. package/dist/dialog.d.ts +61 -50
  5. package/dist/dialog.js +284 -78
  6. package/dist/docs/dialog-system.md +12 -0
  7. package/dist/docs/dialog-system.zh.md +12 -0
  8. package/dist/docs/dominds-terminology.md +17 -0
  9. package/dist/docs/issues/global-dialog-event-broadcaster-missing.md +128 -0
  10. package/dist/docs/llm-provider-isolation.md +35 -0
  11. package/dist/docs/llm-provider-isolation.zh.md +35 -0
  12. package/dist/llm/client.d.ts +2 -1
  13. package/dist/llm/defaults.yaml +118 -4
  14. package/dist/llm/gen/anthropic.js +2 -4
  15. package/dist/llm/gen/codex.d.ts +11 -0
  16. package/dist/llm/gen/codex.js +41 -31
  17. package/dist/llm/gen/failure-classifier.js +17 -0
  18. package/dist/llm/gen/mock.js +45 -21
  19. package/dist/llm/gen/openai-compatible.d.ts +2 -0
  20. package/dist/llm/gen/openai-compatible.js +43 -38
  21. package/dist/llm/gen/openai.d.ts +3 -1
  22. package/dist/llm/gen/openai.js +888 -71
  23. package/dist/llm/gen/tool-call-context.d.ts +7 -2
  24. package/dist/llm/gen/tool-call-context.js +55 -13
  25. package/dist/llm/gen.d.ts +60 -3
  26. package/dist/llm/kernel-driver/context.js +1 -1
  27. package/dist/llm/kernel-driver/drive.js +374 -348
  28. package/dist/llm/kernel-driver/flow.js +3 -3
  29. package/dist/llm/kernel-driver/guardrails.d.ts +1 -1
  30. package/dist/llm/kernel-driver/guardrails.js +4 -4
  31. package/dist/llm/kernel-driver/runtime.js +11 -29
  32. package/dist/llm/kernel-driver/subdialog.js +56 -5
  33. package/dist/llm/kernel-driver/tellask-special.d.ts +38 -12
  34. package/dist/llm/kernel-driver/tellask-special.js +489 -180
  35. package/dist/llm/kernel-driver/types.d.ts +1 -1
  36. package/dist/persistence.d.ts +30 -62
  37. package/dist/persistence.js +978 -986
  38. package/dist/priming.js +398 -365
  39. package/dist/recovery/reply-special.js +3 -3
  40. package/dist/runtime/inter-dialog-format.d.ts +1 -1
  41. package/dist/runtime/inter-dialog-format.js +1 -1
  42. package/dist/runtime/reply-prompt-copy.js +4 -4
  43. package/dist/server/setup-routes.js +26 -5
  44. package/dist/server/snippets-routes.d.ts +1 -0
  45. package/dist/server/snippets-routes.js +20 -9
  46. package/dist/server/websocket-handler.js +58 -25
  47. package/dist/shared/utils/fbr.js +12 -8
  48. package/dist/shared/utils/inter-dialog-format.js +6 -4
  49. package/dist/team.d.ts +24 -13
  50. package/dist/team.js +123 -32
  51. package/dist/tool.d.ts +26 -0
  52. package/dist/tool.js +97 -0
  53. package/dist/tools/team_mgmt.js +18 -0
  54. package/package.json +2 -2
  55. package/webapp/dist/assets/{_basePickBy-CBOtd63g.js → _basePickBy-DsirmCgI.js} +3 -3
  56. package/webapp/dist/assets/_basePickBy-DsirmCgI.js.map +1 -0
  57. package/webapp/dist/assets/{_baseUniq-mfoKz4Wm.js → _baseUniq-tR6G8loB.js} +2 -2
  58. package/webapp/dist/assets/_baseUniq-tR6G8loB.js.map +1 -0
  59. package/webapp/dist/assets/{arc-Dq0WZLyu.js → arc-CzxpASkZ.js} +2 -2
  60. package/webapp/dist/assets/arc-CzxpASkZ.js.map +1 -0
  61. package/webapp/dist/assets/{architectureDiagram-VXUJARFQ-CNmygmp3.js → architectureDiagram-2XIMDMQ5-BSH7H5oI.js} +26 -8
  62. package/webapp/dist/assets/architectureDiagram-2XIMDMQ5-BSH7H5oI.js.map +1 -0
  63. package/webapp/dist/assets/{blockDiagram-VD42YOAC-DvE0lybt.js → blockDiagram-WCTKOSBZ-DpLIr7yO.js} +187 -170
  64. package/webapp/dist/assets/blockDiagram-WCTKOSBZ-DpLIr7yO.js.map +1 -0
  65. package/webapp/dist/assets/{c4Diagram-YG6GDRKO-CR7zJ2_u.js → c4Diagram-IC4MRINW-WuYKgWfY.js} +4 -4
  66. package/webapp/dist/assets/c4Diagram-IC4MRINW-WuYKgWfY.js.map +1 -0
  67. package/webapp/dist/assets/{channel-DrTrnYx4.js → channel-B-v9dqLN.js} +2 -2
  68. package/webapp/dist/assets/channel-B-v9dqLN.js.map +1 -0
  69. package/webapp/dist/assets/{chunk-4BX2VUAB-CVuJEIeN.js → chunk-4BX2VUAB-MtFUfKZy.js} +2 -2
  70. package/webapp/dist/assets/chunk-4BX2VUAB-MtFUfKZy.js.map +1 -0
  71. package/webapp/dist/assets/{chunk-55IACEB6-BxUoXApB.js → chunk-55IACEB6-rY9AJdzj.js} +2 -2
  72. package/webapp/dist/assets/chunk-55IACEB6-rY9AJdzj.js.map +1 -0
  73. package/webapp/dist/assets/{chunk-FMBD7UC4-TX-LVAaV.js → chunk-FMBD7UC4-B-RtOs7e.js} +2 -2
  74. package/webapp/dist/assets/chunk-FMBD7UC4-B-RtOs7e.js.map +1 -0
  75. package/webapp/dist/assets/{chunk-TZMSLE5B-Cw689yRl.js → chunk-JSJVCQXG-Da1d3uS4.js} +14 -6
  76. package/webapp/dist/assets/chunk-JSJVCQXG-Da1d3uS4.js.map +1 -0
  77. package/webapp/dist/assets/{chunk-QN33PNHL-D1uiKlOO.js → chunk-KX2RTZJC-DH9UrpuG.js} +2 -2
  78. package/webapp/dist/assets/chunk-KX2RTZJC-DH9UrpuG.js.map +1 -0
  79. package/webapp/dist/assets/{chunk-DI55MBZ5-SAhxUTqQ.js → chunk-NQ4KR5QH-CK365lrr.js} +9 -7
  80. package/webapp/dist/assets/chunk-NQ4KR5QH-CK365lrr.js.map +1 -0
  81. package/webapp/dist/assets/{chunk-QZHKN3VN-BxuV0Oba.js → chunk-QZHKN3VN-BCaWPGDm.js} +2 -2
  82. package/webapp/dist/assets/chunk-QZHKN3VN-BCaWPGDm.js.map +1 -0
  83. package/webapp/dist/assets/{chunk-B4BG7PRW-DpMa3-9L.js → chunk-WL4C6EOR-DDCnEwft.js} +171 -121
  84. package/webapp/dist/assets/chunk-WL4C6EOR-DDCnEwft.js.map +1 -0
  85. package/webapp/dist/assets/{classDiagram-2ON5EDUG-BTTGianr.js → classDiagram-VBA2DB6C-CvMBU4WA.js} +7 -6
  86. package/webapp/dist/assets/classDiagram-VBA2DB6C-CvMBU4WA.js.map +1 -0
  87. package/webapp/dist/assets/{classDiagram-v2-WZHVMYZB-BTTGianr.js → classDiagram-v2-RAHNMMFH-CvMBU4WA.js} +7 -6
  88. package/webapp/dist/assets/classDiagram-v2-RAHNMMFH-CvMBU4WA.js.map +1 -0
  89. package/webapp/dist/assets/{clone-Dk8cAI3I.js → clone-r98jR0MC.js} +2 -2
  90. package/webapp/dist/assets/clone-r98jR0MC.js.map +1 -0
  91. package/webapp/dist/assets/{cose-bilkent-S5V4N54A-BjJnzB2N.js → cose-bilkent-S5V4N54A-t6J60Ogk.js} +2 -2
  92. package/webapp/dist/assets/cose-bilkent-S5V4N54A-t6J60Ogk.js.map +1 -0
  93. package/webapp/dist/assets/cytoscape.esm-Bm8DJGmZ.js.map +1 -1
  94. package/webapp/dist/assets/{dagre-6UL2VRFP-VF-xGhAf.js → dagre-KLK3FWXG-BlqmY2DV.js} +7 -7
  95. package/webapp/dist/assets/dagre-KLK3FWXG-BlqmY2DV.js.map +1 -0
  96. package/webapp/dist/assets/defaultLocale-B2RvLBDe.js.map +1 -1
  97. package/webapp/dist/assets/{diagram-PSM6KHXK-Ba5U0oRY.js → diagram-E7M64L7V-FwCHeIUD.js} +10 -10
  98. package/webapp/dist/assets/diagram-E7M64L7V-FwCHeIUD.js.map +1 -0
  99. package/webapp/dist/assets/{diagram-QEK2KX5R-DoYCnEw_.js → diagram-IFDJBPK2-NhtmkuZG.js} +9 -8
  100. package/webapp/dist/assets/diagram-IFDJBPK2-NhtmkuZG.js.map +1 -0
  101. package/webapp/dist/assets/{diagram-S2PKOQOG-CkK4SRyE.js → diagram-P4PSJMXO-B9FcmokX.js} +8 -8
  102. package/webapp/dist/assets/diagram-P4PSJMXO-B9FcmokX.js.map +1 -0
  103. package/webapp/dist/assets/{erDiagram-Q2GNP2WA-DkI5eYww.js → erDiagram-INFDFZHY-DHKmWvtB.js} +96 -75
  104. package/webapp/dist/assets/erDiagram-INFDFZHY-DHKmWvtB.js.map +1 -0
  105. package/webapp/dist/assets/{flowDiagram-NV44I4VS-wOdPUQ7Y.js → flowDiagram-PKNHOUZH-C7Zi8I7T.js} +98 -81
  106. package/webapp/dist/assets/flowDiagram-PKNHOUZH-C7Zi8I7T.js.map +1 -0
  107. package/webapp/dist/assets/{ganttDiagram-JELNMOA3-BtRWgkUH.js → ganttDiagram-A5KZAMGK-Cv2T8tz_.js} +28 -3
  108. package/webapp/dist/assets/ganttDiagram-A5KZAMGK-Cv2T8tz_.js.map +1 -0
  109. package/webapp/dist/assets/{gitGraphDiagram-V2S2FVAM-Bsz7u1vi.js → gitGraphDiagram-K3NZZRJ6-DztaipJU.js} +38 -46
  110. package/webapp/dist/assets/gitGraphDiagram-K3NZZRJ6-DztaipJU.js.map +1 -0
  111. package/webapp/dist/assets/graph-C5yf62Vs.js +782 -0
  112. package/webapp/dist/assets/graph-C5yf62Vs.js.map +1 -0
  113. package/webapp/dist/assets/{index-xvYYeHuy.css → index-YaxF76or.css} +1 -1
  114. package/webapp/dist/assets/{index-rYmIohM_.js → index-hve5MWPs.js} +1603 -1415
  115. package/webapp/dist/assets/index-hve5MWPs.js.map +1 -0
  116. package/webapp/dist/assets/{infoDiagram-HS3SLOUP-BMaxCvH5.js → infoDiagram-LFFYTUFH-VgsbBPZP.js} +7 -7
  117. package/webapp/dist/assets/infoDiagram-LFFYTUFH-VgsbBPZP.js.map +1 -0
  118. package/webapp/dist/assets/init-ZxktEp_H.js.map +1 -1
  119. package/webapp/dist/assets/ishikawaDiagram-PHBUUO56-C7j3YWdw.js +966 -0
  120. package/webapp/dist/assets/ishikawaDiagram-PHBUUO56-C7j3YWdw.js.map +1 -0
  121. package/webapp/dist/assets/{journeyDiagram-XKPGCS4Q-ejyerzmG.js → journeyDiagram-4ABVD52K-OO8sev-Y.js} +5 -5
  122. package/webapp/dist/assets/journeyDiagram-4ABVD52K-OO8sev-Y.js.map +1 -0
  123. package/webapp/dist/assets/{kanban-definition-3W4ZIXB7-CYj35TEs.js → kanban-definition-K7BYSVSG-DiYCC1Ig.js} +5 -3
  124. package/webapp/dist/assets/kanban-definition-K7BYSVSG-DiYCC1Ig.js.map +1 -0
  125. package/webapp/dist/assets/{layout-7Ql4zmuL.js → layout-DdZSgGdu.js} +5 -5
  126. package/webapp/dist/assets/layout-DdZSgGdu.js.map +1 -0
  127. package/webapp/dist/assets/{linear-CVmgVPuZ.js → linear-7-aHtaFi.js} +2 -2
  128. package/webapp/dist/assets/linear-7-aHtaFi.js.map +1 -0
  129. package/webapp/dist/assets/{mindmap-definition-VGOIOE7T-DOpxjGVo.js → mindmap-definition-YRQLILUH-IG3I-RdD.js} +7 -5
  130. package/webapp/dist/assets/mindmap-definition-YRQLILUH-IG3I-RdD.js.map +1 -0
  131. package/webapp/dist/assets/ordinal-CxptdPJm.js.map +1 -1
  132. package/webapp/dist/assets/{pieDiagram-ADFJNKIX-CLQjpmAG.js → pieDiagram-SKSYHLDU-z68KJT5r.js} +8 -8
  133. package/webapp/dist/assets/pieDiagram-SKSYHLDU-z68KJT5r.js.map +1 -0
  134. package/webapp/dist/assets/{quadrantDiagram-AYHSOK5B-ClD_bz7z.js → quadrantDiagram-337W2JSQ-DaENWdO6.js} +3 -3
  135. package/webapp/dist/assets/quadrantDiagram-337W2JSQ-DaENWdO6.js.map +1 -0
  136. package/webapp/dist/assets/{requirementDiagram-UZGBJVZJ-DOpb-TWH.js → requirementDiagram-Z7DCOOCP-ROTFv4sa.js} +16 -6
  137. package/webapp/dist/assets/requirementDiagram-Z7DCOOCP-ROTFv4sa.js.map +1 -0
  138. package/webapp/dist/assets/{sankeyDiagram-TZEHDZUN-D8Hsj3yx.js → sankeyDiagram-WA2Y5GQK-CK7qtpzw.js} +2 -2
  139. package/webapp/dist/assets/sankeyDiagram-WA2Y5GQK-CK7qtpzw.js.map +1 -0
  140. package/webapp/dist/assets/{sequenceDiagram-WL72ISMW-CFMNjBER.js → sequenceDiagram-2WXFIKYE-R5lDySeI.js} +601 -201
  141. package/webapp/dist/assets/sequenceDiagram-2WXFIKYE-R5lDySeI.js.map +1 -0
  142. package/webapp/dist/assets/{stateDiagram-FKZM4ZOC-BQeDlw0P.js → stateDiagram-RAJIS63D-sr7msF5U.js} +9 -9
  143. package/webapp/dist/assets/stateDiagram-RAJIS63D-sr7msF5U.js.map +1 -0
  144. package/webapp/dist/assets/{stateDiagram-v2-4FDKWEC3-DscX61Rs.js → stateDiagram-v2-FVOUBMTO-X663liwS.js} +5 -5
  145. package/webapp/dist/assets/stateDiagram-v2-FVOUBMTO-X663liwS.js.map +1 -0
  146. package/webapp/dist/assets/{timeline-definition-IT6M3QCI-BcXPSTiw.js → timeline-definition-YZTLITO2-Bw0TdG26.js} +3 -3
  147. package/webapp/dist/assets/timeline-definition-YZTLITO2-Bw0TdG26.js.map +1 -0
  148. package/webapp/dist/assets/{treemap-GDKQZRPO-BBr4UV0Z.js → treemap-KZPCXAKY-D_sjKwI7.js} +37 -24
  149. package/webapp/dist/assets/treemap-KZPCXAKY-D_sjKwI7.js.map +1 -0
  150. package/webapp/dist/assets/vennDiagram-LZ73GAT5-DhlHIHid.js +2487 -0
  151. package/webapp/dist/assets/vennDiagram-LZ73GAT5-DhlHIHid.js.map +1 -0
  152. package/webapp/dist/assets/{xychartDiagram-PRI3JC2R-CS5RAtQE.js → xychartDiagram-JWTSCODW-C65ESjTc.js} +4 -4
  153. package/webapp/dist/assets/xychartDiagram-JWTSCODW-C65ESjTc.js.map +1 -0
  154. package/webapp/dist/index.html +2 -2
  155. package/webapp/dist/assets/_basePickBy-CBOtd63g.js.map +0 -1
  156. package/webapp/dist/assets/_baseUniq-mfoKz4Wm.js.map +0 -1
  157. package/webapp/dist/assets/arc-Dq0WZLyu.js.map +0 -1
  158. package/webapp/dist/assets/architectureDiagram-VXUJARFQ-CNmygmp3.js.map +0 -1
  159. package/webapp/dist/assets/blockDiagram-VD42YOAC-DvE0lybt.js.map +0 -1
  160. package/webapp/dist/assets/c4Diagram-YG6GDRKO-CR7zJ2_u.js.map +0 -1
  161. package/webapp/dist/assets/channel-DrTrnYx4.js.map +0 -1
  162. package/webapp/dist/assets/chunk-4BX2VUAB-CVuJEIeN.js.map +0 -1
  163. package/webapp/dist/assets/chunk-55IACEB6-BxUoXApB.js.map +0 -1
  164. package/webapp/dist/assets/chunk-B4BG7PRW-DpMa3-9L.js.map +0 -1
  165. package/webapp/dist/assets/chunk-DI55MBZ5-SAhxUTqQ.js.map +0 -1
  166. package/webapp/dist/assets/chunk-FMBD7UC4-TX-LVAaV.js.map +0 -1
  167. package/webapp/dist/assets/chunk-QN33PNHL-D1uiKlOO.js.map +0 -1
  168. package/webapp/dist/assets/chunk-QZHKN3VN-BxuV0Oba.js.map +0 -1
  169. package/webapp/dist/assets/chunk-TZMSLE5B-Cw689yRl.js.map +0 -1
  170. package/webapp/dist/assets/classDiagram-2ON5EDUG-BTTGianr.js.map +0 -1
  171. package/webapp/dist/assets/classDiagram-v2-WZHVMYZB-BTTGianr.js.map +0 -1
  172. package/webapp/dist/assets/clone-Dk8cAI3I.js.map +0 -1
  173. package/webapp/dist/assets/cose-bilkent-S5V4N54A-BjJnzB2N.js.map +0 -1
  174. package/webapp/dist/assets/dagre-6UL2VRFP-VF-xGhAf.js.map +0 -1
  175. package/webapp/dist/assets/diagram-PSM6KHXK-Ba5U0oRY.js.map +0 -1
  176. package/webapp/dist/assets/diagram-QEK2KX5R-DoYCnEw_.js.map +0 -1
  177. package/webapp/dist/assets/diagram-S2PKOQOG-CkK4SRyE.js.map +0 -1
  178. package/webapp/dist/assets/erDiagram-Q2GNP2WA-DkI5eYww.js.map +0 -1
  179. package/webapp/dist/assets/flowDiagram-NV44I4VS-wOdPUQ7Y.js.map +0 -1
  180. package/webapp/dist/assets/ganttDiagram-JELNMOA3-BtRWgkUH.js.map +0 -1
  181. package/webapp/dist/assets/gitGraphDiagram-V2S2FVAM-Bsz7u1vi.js.map +0 -1
  182. package/webapp/dist/assets/graph-DAMkuTbn.js +0 -425
  183. package/webapp/dist/assets/graph-DAMkuTbn.js.map +0 -1
  184. package/webapp/dist/assets/index-rYmIohM_.js.map +0 -1
  185. package/webapp/dist/assets/infoDiagram-HS3SLOUP-BMaxCvH5.js.map +0 -1
  186. package/webapp/dist/assets/journeyDiagram-XKPGCS4Q-ejyerzmG.js.map +0 -1
  187. package/webapp/dist/assets/kanban-definition-3W4ZIXB7-CYj35TEs.js.map +0 -1
  188. package/webapp/dist/assets/layout-7Ql4zmuL.js.map +0 -1
  189. package/webapp/dist/assets/linear-CVmgVPuZ.js.map +0 -1
  190. package/webapp/dist/assets/mindmap-definition-VGOIOE7T-DOpxjGVo.js.map +0 -1
  191. package/webapp/dist/assets/pieDiagram-ADFJNKIX-CLQjpmAG.js.map +0 -1
  192. package/webapp/dist/assets/quadrantDiagram-AYHSOK5B-ClD_bz7z.js.map +0 -1
  193. package/webapp/dist/assets/requirementDiagram-UZGBJVZJ-DOpb-TWH.js.map +0 -1
  194. package/webapp/dist/assets/sankeyDiagram-TZEHDZUN-D8Hsj3yx.js.map +0 -1
  195. package/webapp/dist/assets/sequenceDiagram-WL72ISMW-CFMNjBER.js.map +0 -1
  196. package/webapp/dist/assets/stateDiagram-FKZM4ZOC-BQeDlw0P.js.map +0 -1
  197. package/webapp/dist/assets/stateDiagram-v2-4FDKWEC3-DscX61Rs.js.map +0 -1
  198. package/webapp/dist/assets/timeline-definition-IT6M3QCI-BcXPSTiw.js.map +0 -1
  199. package/webapp/dist/assets/treemap-GDKQZRPO-BBr4UV0Z.js.map +0 -1
  200. package/webapp/dist/assets/xychartDiagram-PRI3JC2R-CS5RAtQE.js.map +0 -1
@@ -0,0 +1,966 @@
1
+ var _a;
2
+ import { _ as __name, c as getConfig2, N as parseFontSize, I as selectSvgElement, as as at, z as clear, k as common_default, p as setDiagramTitle, a as getAccTitle, b as setAccTitle, g as getAccDescription, s as setAccDescription, q as getDiagramTitle, e as configureSvgSize } from "./index-hve5MWPs.js";
3
+ var parser = (function() {
4
+ var o = /* @__PURE__ */ __name(function(k, v, o2, l) {
5
+ for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v) ;
6
+ return o2;
7
+ }, "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];
8
+ var parser2 = {
9
+ trace: /* @__PURE__ */ __name(function trace() {
10
+ }, "trace"),
11
+ yy: {},
12
+ 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 },
13
+ terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "ISHIKAWA", 11: "EOF", 13: "SPACELIST", 14: "TEXT" },
14
+ 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]],
15
+ performAction: /* @__PURE__ */ __name(function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
16
+ var $0 = $$.length - 1;
17
+ switch (yystate) {
18
+ case 6:
19
+ case 7:
20
+ return yy;
21
+ case 15:
22
+ yy.addNode($$[$0 - 1].length, $$[$0].trim());
23
+ break;
24
+ case 16:
25
+ yy.addNode(0, $$[$0].trim());
26
+ break;
27
+ }
28
+ }, "anonymous"),
29
+ 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])],
30
+ defaultActions: { 2: [2, 1], 6: [2, 2] },
31
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
32
+ if (hash.recoverable) {
33
+ this.trace(str);
34
+ } else {
35
+ var error = new Error(str);
36
+ error.hash = hash;
37
+ throw error;
38
+ }
39
+ }, "parseError"),
40
+ parse: /* @__PURE__ */ __name(function parse(input) {
41
+ var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
42
+ var args = lstack.slice.call(arguments, 1);
43
+ var lexer2 = Object.create(this.lexer);
44
+ var sharedState = { yy: {} };
45
+ for (var k in this.yy) {
46
+ if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
47
+ sharedState.yy[k] = this.yy[k];
48
+ }
49
+ }
50
+ lexer2.setInput(input, sharedState.yy);
51
+ sharedState.yy.lexer = lexer2;
52
+ sharedState.yy.parser = this;
53
+ if (typeof lexer2.yylloc == "undefined") {
54
+ lexer2.yylloc = {};
55
+ }
56
+ var yyloc = lexer2.yylloc;
57
+ lstack.push(yyloc);
58
+ var ranges = lexer2.options && lexer2.options.ranges;
59
+ if (typeof sharedState.yy.parseError === "function") {
60
+ this.parseError = sharedState.yy.parseError;
61
+ } else {
62
+ this.parseError = Object.getPrototypeOf(this).parseError;
63
+ }
64
+ function popStack(n) {
65
+ stack.length = stack.length - 2 * n;
66
+ vstack.length = vstack.length - n;
67
+ lstack.length = lstack.length - n;
68
+ }
69
+ __name(popStack, "popStack");
70
+ function lex() {
71
+ var token;
72
+ token = tstack.pop() || lexer2.lex() || EOF;
73
+ if (typeof token !== "number") {
74
+ if (token instanceof Array) {
75
+ tstack = token;
76
+ token = tstack.pop();
77
+ }
78
+ token = self.symbols_[token] || token;
79
+ }
80
+ return token;
81
+ }
82
+ __name(lex, "lex");
83
+ var symbol, state, action, r, yyval = {}, p, len, newState, expected;
84
+ while (true) {
85
+ state = stack[stack.length - 1];
86
+ if (this.defaultActions[state]) {
87
+ action = this.defaultActions[state];
88
+ } else {
89
+ if (symbol === null || typeof symbol == "undefined") {
90
+ symbol = lex();
91
+ }
92
+ action = table[state] && table[state][symbol];
93
+ }
94
+ if (typeof action === "undefined" || !action.length || !action[0]) {
95
+ var errStr = "";
96
+ expected = [];
97
+ for (p in table[state]) {
98
+ if (this.terminals_[p] && p > TERROR) {
99
+ expected.push("'" + this.terminals_[p] + "'");
100
+ }
101
+ }
102
+ if (lexer2.showPosition) {
103
+ errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
104
+ } else {
105
+ errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
106
+ }
107
+ this.parseError(errStr, {
108
+ text: lexer2.match,
109
+ token: this.terminals_[symbol] || symbol,
110
+ line: lexer2.yylineno,
111
+ loc: yyloc,
112
+ expected
113
+ });
114
+ }
115
+ if (action[0] instanceof Array && action.length > 1) {
116
+ throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
117
+ }
118
+ switch (action[0]) {
119
+ case 1:
120
+ stack.push(symbol);
121
+ vstack.push(lexer2.yytext);
122
+ lstack.push(lexer2.yylloc);
123
+ stack.push(action[1]);
124
+ symbol = null;
125
+ {
126
+ yyleng = lexer2.yyleng;
127
+ yytext = lexer2.yytext;
128
+ yylineno = lexer2.yylineno;
129
+ yyloc = lexer2.yylloc;
130
+ }
131
+ break;
132
+ case 2:
133
+ len = this.productions_[action[1]][1];
134
+ yyval.$ = vstack[vstack.length - len];
135
+ yyval._$ = {
136
+ first_line: lstack[lstack.length - (len || 1)].first_line,
137
+ last_line: lstack[lstack.length - 1].last_line,
138
+ first_column: lstack[lstack.length - (len || 1)].first_column,
139
+ last_column: lstack[lstack.length - 1].last_column
140
+ };
141
+ if (ranges) {
142
+ yyval._$.range = [
143
+ lstack[lstack.length - (len || 1)].range[0],
144
+ lstack[lstack.length - 1].range[1]
145
+ ];
146
+ }
147
+ r = this.performAction.apply(yyval, [
148
+ yytext,
149
+ yyleng,
150
+ yylineno,
151
+ sharedState.yy,
152
+ action[1],
153
+ vstack,
154
+ lstack
155
+ ].concat(args));
156
+ if (typeof r !== "undefined") {
157
+ return r;
158
+ }
159
+ if (len) {
160
+ stack = stack.slice(0, -1 * len * 2);
161
+ vstack = vstack.slice(0, -1 * len);
162
+ lstack = lstack.slice(0, -1 * len);
163
+ }
164
+ stack.push(this.productions_[action[1]][0]);
165
+ vstack.push(yyval.$);
166
+ lstack.push(yyval._$);
167
+ newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
168
+ stack.push(newState);
169
+ break;
170
+ case 3:
171
+ return true;
172
+ }
173
+ }
174
+ return true;
175
+ }, "parse")
176
+ };
177
+ var lexer = /* @__PURE__ */ (function() {
178
+ var lexer2 = {
179
+ EOF: 1,
180
+ parseError: /* @__PURE__ */ __name(function parseError(str, hash) {
181
+ if (this.yy.parser) {
182
+ this.yy.parser.parseError(str, hash);
183
+ } else {
184
+ throw new Error(str);
185
+ }
186
+ }, "parseError"),
187
+ // resets the lexer, sets new input
188
+ setInput: /* @__PURE__ */ __name(function(input, yy) {
189
+ this.yy = yy || this.yy || {};
190
+ this._input = input;
191
+ this._more = this._backtrack = this.done = false;
192
+ this.yylineno = this.yyleng = 0;
193
+ this.yytext = this.matched = this.match = "";
194
+ this.conditionStack = ["INITIAL"];
195
+ this.yylloc = {
196
+ first_line: 1,
197
+ first_column: 0,
198
+ last_line: 1,
199
+ last_column: 0
200
+ };
201
+ if (this.options.ranges) {
202
+ this.yylloc.range = [0, 0];
203
+ }
204
+ this.offset = 0;
205
+ return this;
206
+ }, "setInput"),
207
+ // consumes and returns one char from the input
208
+ input: /* @__PURE__ */ __name(function() {
209
+ var ch = this._input[0];
210
+ this.yytext += ch;
211
+ this.yyleng++;
212
+ this.offset++;
213
+ this.match += ch;
214
+ this.matched += ch;
215
+ var lines = ch.match(/(?:\r\n?|\n).*/g);
216
+ if (lines) {
217
+ this.yylineno++;
218
+ this.yylloc.last_line++;
219
+ } else {
220
+ this.yylloc.last_column++;
221
+ }
222
+ if (this.options.ranges) {
223
+ this.yylloc.range[1]++;
224
+ }
225
+ this._input = this._input.slice(1);
226
+ return ch;
227
+ }, "input"),
228
+ // unshifts one char (or a string) into the input
229
+ unput: /* @__PURE__ */ __name(function(ch) {
230
+ var len = ch.length;
231
+ var lines = ch.split(/(?:\r\n?|\n)/g);
232
+ this._input = ch + this._input;
233
+ this.yytext = this.yytext.substr(0, this.yytext.length - len);
234
+ this.offset -= len;
235
+ var oldLines = this.match.split(/(?:\r\n?|\n)/g);
236
+ this.match = this.match.substr(0, this.match.length - 1);
237
+ this.matched = this.matched.substr(0, this.matched.length - 1);
238
+ if (lines.length - 1) {
239
+ this.yylineno -= lines.length - 1;
240
+ }
241
+ var r = this.yylloc.range;
242
+ this.yylloc = {
243
+ first_line: this.yylloc.first_line,
244
+ last_line: this.yylineno + 1,
245
+ first_column: this.yylloc.first_column,
246
+ 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
247
+ };
248
+ if (this.options.ranges) {
249
+ this.yylloc.range = [r[0], r[0] + this.yyleng - len];
250
+ }
251
+ this.yyleng = this.yytext.length;
252
+ return this;
253
+ }, "unput"),
254
+ // When called from action, caches matched text and appends it on next action
255
+ more: /* @__PURE__ */ __name(function() {
256
+ this._more = true;
257
+ return this;
258
+ }, "more"),
259
+ // 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.
260
+ reject: /* @__PURE__ */ __name(function() {
261
+ if (this.options.backtrack_lexer) {
262
+ this._backtrack = true;
263
+ } else {
264
+ 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(), {
265
+ text: "",
266
+ token: null,
267
+ line: this.yylineno
268
+ });
269
+ }
270
+ return this;
271
+ }, "reject"),
272
+ // retain first n characters of the match
273
+ less: /* @__PURE__ */ __name(function(n) {
274
+ this.unput(this.match.slice(n));
275
+ }, "less"),
276
+ // displays already matched input, i.e. for error messages
277
+ pastInput: /* @__PURE__ */ __name(function() {
278
+ var past = this.matched.substr(0, this.matched.length - this.match.length);
279
+ return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
280
+ }, "pastInput"),
281
+ // displays upcoming input, i.e. for error messages
282
+ upcomingInput: /* @__PURE__ */ __name(function() {
283
+ var next = this.match;
284
+ if (next.length < 20) {
285
+ next += this._input.substr(0, 20 - next.length);
286
+ }
287
+ return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
288
+ }, "upcomingInput"),
289
+ // displays the character position where the lexing error occurred, i.e. for error messages
290
+ showPosition: /* @__PURE__ */ __name(function() {
291
+ var pre = this.pastInput();
292
+ var c = new Array(pre.length + 1).join("-");
293
+ return pre + this.upcomingInput() + "\n" + c + "^";
294
+ }, "showPosition"),
295
+ // test the lexed token: return FALSE when not a match, otherwise return token
296
+ test_match: /* @__PURE__ */ __name(function(match, indexed_rule) {
297
+ var token, lines, backup;
298
+ if (this.options.backtrack_lexer) {
299
+ backup = {
300
+ yylineno: this.yylineno,
301
+ yylloc: {
302
+ first_line: this.yylloc.first_line,
303
+ last_line: this.last_line,
304
+ first_column: this.yylloc.first_column,
305
+ last_column: this.yylloc.last_column
306
+ },
307
+ yytext: this.yytext,
308
+ match: this.match,
309
+ matches: this.matches,
310
+ matched: this.matched,
311
+ yyleng: this.yyleng,
312
+ offset: this.offset,
313
+ _more: this._more,
314
+ _input: this._input,
315
+ yy: this.yy,
316
+ conditionStack: this.conditionStack.slice(0),
317
+ done: this.done
318
+ };
319
+ if (this.options.ranges) {
320
+ backup.yylloc.range = this.yylloc.range.slice(0);
321
+ }
322
+ }
323
+ lines = match[0].match(/(?:\r\n?|\n).*/g);
324
+ if (lines) {
325
+ this.yylineno += lines.length;
326
+ }
327
+ this.yylloc = {
328
+ first_line: this.yylloc.last_line,
329
+ last_line: this.yylineno + 1,
330
+ first_column: this.yylloc.last_column,
331
+ last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
332
+ };
333
+ this.yytext += match[0];
334
+ this.match += match[0];
335
+ this.matches = match;
336
+ this.yyleng = this.yytext.length;
337
+ if (this.options.ranges) {
338
+ this.yylloc.range = [this.offset, this.offset += this.yyleng];
339
+ }
340
+ this._more = false;
341
+ this._backtrack = false;
342
+ this._input = this._input.slice(match[0].length);
343
+ this.matched += match[0];
344
+ token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
345
+ if (this.done && this._input) {
346
+ this.done = false;
347
+ }
348
+ if (token) {
349
+ return token;
350
+ } else if (this._backtrack) {
351
+ for (var k in backup) {
352
+ this[k] = backup[k];
353
+ }
354
+ return false;
355
+ }
356
+ return false;
357
+ }, "test_match"),
358
+ // return next match in input
359
+ next: /* @__PURE__ */ __name(function() {
360
+ if (this.done) {
361
+ return this.EOF;
362
+ }
363
+ if (!this._input) {
364
+ this.done = true;
365
+ }
366
+ var token, match, tempMatch, index;
367
+ if (!this._more) {
368
+ this.yytext = "";
369
+ this.match = "";
370
+ }
371
+ var rules = this._currentRules();
372
+ for (var i = 0; i < rules.length; i++) {
373
+ tempMatch = this._input.match(this.rules[rules[i]]);
374
+ if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
375
+ match = tempMatch;
376
+ index = i;
377
+ if (this.options.backtrack_lexer) {
378
+ token = this.test_match(tempMatch, rules[i]);
379
+ if (token !== false) {
380
+ return token;
381
+ } else if (this._backtrack) {
382
+ match = false;
383
+ continue;
384
+ } else {
385
+ return false;
386
+ }
387
+ } else if (!this.options.flex) {
388
+ break;
389
+ }
390
+ }
391
+ }
392
+ if (match) {
393
+ token = this.test_match(match, rules[index]);
394
+ if (token !== false) {
395
+ return token;
396
+ }
397
+ return false;
398
+ }
399
+ if (this._input === "") {
400
+ return this.EOF;
401
+ } else {
402
+ return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
403
+ text: "",
404
+ token: null,
405
+ line: this.yylineno
406
+ });
407
+ }
408
+ }, "next"),
409
+ // return next match that has a token
410
+ lex: /* @__PURE__ */ __name(function lex() {
411
+ var r = this.next();
412
+ if (r) {
413
+ return r;
414
+ } else {
415
+ return this.lex();
416
+ }
417
+ }, "lex"),
418
+ // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
419
+ begin: /* @__PURE__ */ __name(function begin(condition) {
420
+ this.conditionStack.push(condition);
421
+ }, "begin"),
422
+ // pop the previously active lexer condition state off the condition stack
423
+ popState: /* @__PURE__ */ __name(function popState() {
424
+ var n = this.conditionStack.length - 1;
425
+ if (n > 0) {
426
+ return this.conditionStack.pop();
427
+ } else {
428
+ return this.conditionStack[0];
429
+ }
430
+ }, "popState"),
431
+ // produce the lexer rule set which is active for the currently active lexer condition state
432
+ _currentRules: /* @__PURE__ */ __name(function _currentRules() {
433
+ if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
434
+ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
435
+ } else {
436
+ return this.conditions["INITIAL"].rules;
437
+ }
438
+ }, "_currentRules"),
439
+ // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
440
+ topState: /* @__PURE__ */ __name(function topState(n) {
441
+ n = this.conditionStack.length - 1 - Math.abs(n || 0);
442
+ if (n >= 0) {
443
+ return this.conditionStack[n];
444
+ } else {
445
+ return "INITIAL";
446
+ }
447
+ }, "topState"),
448
+ // alias for begin(condition)
449
+ pushState: /* @__PURE__ */ __name(function pushState(condition) {
450
+ this.begin(condition);
451
+ }, "pushState"),
452
+ // return the number of states currently on the stack
453
+ stateStackSize: /* @__PURE__ */ __name(function stateStackSize() {
454
+ return this.conditionStack.length;
455
+ }, "stateStackSize"),
456
+ options: { "case-insensitive": true },
457
+ performAction: /* @__PURE__ */ __name(function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
458
+ switch ($avoiding_name_collisions) {
459
+ case 0:
460
+ return 6;
461
+ case 1:
462
+ return 8;
463
+ case 2:
464
+ return 8;
465
+ case 3:
466
+ return 6;
467
+ case 4:
468
+ return 7;
469
+ case 5:
470
+ return 13;
471
+ case 6:
472
+ return 14;
473
+ case 7:
474
+ return 11;
475
+ }
476
+ }, "anonymous"),
477
+ rules: [/^(?:\s*%%.*)/i, /^(?:ishikawa-beta\b)/i, /^(?:ishikawa\b)/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[\s]+)/i, /^(?:[^\n]+)/i, /^(?:$)/i],
478
+ conditions: { "INITIAL": { "rules": [0, 1, 2, 3, 4, 5, 6, 7], "inclusive": true } }
479
+ };
480
+ return lexer2;
481
+ })();
482
+ parser2.lexer = lexer;
483
+ function Parser() {
484
+ this.yy = {};
485
+ }
486
+ __name(Parser, "Parser");
487
+ Parser.prototype = parser2;
488
+ parser2.Parser = Parser;
489
+ return new Parser();
490
+ })();
491
+ parser.parser = parser;
492
+ var ishikawa_default = parser;
493
+ var IshikawaDB = (_a = class {
494
+ constructor() {
495
+ this.stack = [];
496
+ this.clear = this.clear.bind(this);
497
+ this.addNode = this.addNode.bind(this);
498
+ this.getRoot = this.getRoot.bind(this);
499
+ }
500
+ clear() {
501
+ this.root = void 0;
502
+ this.stack = [];
503
+ this.baseLevel = void 0;
504
+ clear();
505
+ }
506
+ getRoot() {
507
+ return this.root;
508
+ }
509
+ addNode(rawLevel, text) {
510
+ const label = common_default.sanitizeText(text, getConfig2());
511
+ if (!this.root) {
512
+ this.baseLevel = rawLevel;
513
+ this.root = { text: label, children: [] };
514
+ this.stack = [{ level: 0, node: this.root }];
515
+ setDiagramTitle(label);
516
+ return;
517
+ }
518
+ let level = rawLevel - (this.baseLevel ?? 0);
519
+ if (level <= 0) {
520
+ level = 1;
521
+ }
522
+ while (this.stack.length > 1 && this.stack[this.stack.length - 1].level >= level) {
523
+ this.stack.pop();
524
+ }
525
+ const parent = this.stack[this.stack.length - 1].node;
526
+ const node = { text: label, children: [] };
527
+ parent.children.push(node);
528
+ this.stack.push({ level, node });
529
+ }
530
+ getAccTitle() {
531
+ return getAccTitle();
532
+ }
533
+ setAccTitle(title) {
534
+ setAccTitle(title);
535
+ }
536
+ getAccDescription() {
537
+ return getAccDescription();
538
+ }
539
+ setAccDescription(description) {
540
+ setAccDescription(description);
541
+ }
542
+ getDiagramTitle() {
543
+ return getDiagramTitle();
544
+ }
545
+ setDiagramTitle(title) {
546
+ setDiagramTitle(title);
547
+ }
548
+ }, __name(_a, "IshikawaDB"), _a);
549
+ var FONT_SIZE_DEFAULT = 14;
550
+ var SPINE_BASE_LENGTH = 250;
551
+ var BONE_STUB = 30;
552
+ var BONE_BASE = 60;
553
+ var BONE_PER_CHILD = 5;
554
+ var ANGLE = 82 * Math.PI / 180;
555
+ var COS_A = Math.cos(ANGLE);
556
+ var SIN_A = Math.sin(ANGLE);
557
+ var applyPaddedViewBox = /* @__PURE__ */ __name((svgEl, pad, maxW) => {
558
+ const bbox = svgEl.node().getBBox();
559
+ const w = bbox.width + pad * 2;
560
+ const h = bbox.height + pad * 2;
561
+ configureSvgSize(svgEl, h, w, maxW);
562
+ svgEl.attr("viewBox", `${bbox.x - pad} ${bbox.y - pad} ${w} ${h}`);
563
+ }, "applyPaddedViewBox");
564
+ var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
565
+ const db = diagram2.db;
566
+ const root = db.getRoot();
567
+ if (!root) {
568
+ return;
569
+ }
570
+ const drawConfig = getConfig2();
571
+ const { look, handDrawnSeed, themeVariables } = drawConfig;
572
+ const fontSize = parseFontSize(drawConfig.fontSize)[0] ?? FONT_SIZE_DEFAULT;
573
+ const isHandDrawn = look === "handDrawn";
574
+ const causes = root.children ?? [];
575
+ const padding = drawConfig.ishikawa?.diagramPadding ?? 20;
576
+ const useMaxWidth = drawConfig.ishikawa?.useMaxWidth ?? false;
577
+ const svg = selectSvgElement(id);
578
+ const g = svg.append("g").attr("class", "ishikawa");
579
+ const roughSvg = isHandDrawn ? at.svg(svg.node()) : void 0;
580
+ const roughContext = roughSvg ? {
581
+ roughSvg,
582
+ seed: handDrawnSeed ?? 0,
583
+ lineColor: themeVariables?.lineColor ?? "#333",
584
+ fillColor: themeVariables?.mainBkg ?? "#fff"
585
+ } : void 0;
586
+ const markerId = `ishikawa-arrow-${id}`;
587
+ if (!isHandDrawn) {
588
+ 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");
589
+ }
590
+ let spineX = 0;
591
+ let spineY = SPINE_BASE_LENGTH;
592
+ const spineLine = isHandDrawn ? void 0 : drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine");
593
+ drawHead(g, spineX, spineY, root.text, fontSize, roughContext);
594
+ if (!causes.length) {
595
+ if (isHandDrawn) {
596
+ drawLine(g, spineX, spineY, spineX, spineY, "ishikawa-spine", roughContext);
597
+ }
598
+ applyPaddedViewBox(svg, padding, useMaxWidth);
599
+ return;
600
+ }
601
+ spineX -= 20;
602
+ const upperCauses = causes.filter((_, i) => i % 2 === 0);
603
+ const lowerCauses = causes.filter((_, i) => i % 2 === 1);
604
+ const upperStats = sideStats(upperCauses);
605
+ const lowerStats = sideStats(lowerCauses);
606
+ const descendantTotal = upperStats.total + lowerStats.total;
607
+ let upperLen = SPINE_BASE_LENGTH;
608
+ let lowerLen = SPINE_BASE_LENGTH;
609
+ if (descendantTotal > 0) {
610
+ const pool = SPINE_BASE_LENGTH * 2;
611
+ const minLen = SPINE_BASE_LENGTH * 0.3;
612
+ upperLen = Math.max(minLen, pool * (upperStats.total / descendantTotal));
613
+ lowerLen = Math.max(minLen, pool * (lowerStats.total / descendantTotal));
614
+ }
615
+ const minSpacing = fontSize * 2;
616
+ upperLen = Math.max(upperLen, upperStats.max * minSpacing);
617
+ lowerLen = Math.max(lowerLen, lowerStats.max * minSpacing);
618
+ spineY = Math.max(upperLen, SPINE_BASE_LENGTH);
619
+ if (spineLine) {
620
+ spineLine.attr("y1", spineY).attr("y2", spineY);
621
+ }
622
+ g.select(".ishikawa-head-group").attr("transform", `translate(0,${spineY})`);
623
+ const pairCount = Math.ceil(causes.length / 2);
624
+ for (let p = 0; p < pairCount; p++) {
625
+ const pg = g.append("g").attr("class", "ishikawa-pair");
626
+ for (const [cause, dir, len] of [
627
+ [causes[p * 2], -1, upperLen],
628
+ [causes[p * 2 + 1], 1, lowerLen]
629
+ ]) {
630
+ if (cause) {
631
+ drawBranch(pg, cause, spineX, spineY, dir, len, fontSize, roughContext);
632
+ }
633
+ }
634
+ spineX = pg.selectAll("text").nodes().reduce((left, n) => Math.min(left, n.getBBox().x), Infinity);
635
+ }
636
+ if (isHandDrawn) {
637
+ drawLine(g, spineX, spineY, 0, spineY, "ishikawa-spine", roughContext);
638
+ } else {
639
+ spineLine.attr("x1", spineX);
640
+ const markerUrl = `url(#${markerId})`;
641
+ g.selectAll("line.ishikawa-branch, line.ishikawa-sub-branch").attr("marker-start", markerUrl);
642
+ }
643
+ applyPaddedViewBox(svg, padding, useMaxWidth);
644
+ }, "draw");
645
+ var sideStats = /* @__PURE__ */ __name((nodes) => {
646
+ const countDescendants = /* @__PURE__ */ __name((node) => node.children.reduce((sum, child) => sum + 1 + countDescendants(child), 0), "countDescendants");
647
+ return nodes.reduce(
648
+ (stats, node) => {
649
+ const descendants = countDescendants(node);
650
+ stats.total += descendants;
651
+ stats.max = Math.max(stats.max, descendants);
652
+ return stats;
653
+ },
654
+ { total: 0, max: 0 }
655
+ );
656
+ }, "sideStats");
657
+ var drawHead = /* @__PURE__ */ __name((svg, x, y, label, fontSize, roughContext) => {
658
+ const maxChars = Math.max(6, Math.floor(110 / (fontSize * 0.6)));
659
+ const headGroup = svg.append("g").attr("class", "ishikawa-head-group").attr("transform", `translate(${x},${y})`);
660
+ const textEl = drawMultilineText(
661
+ headGroup,
662
+ wrapText(label, maxChars),
663
+ 0,
664
+ 0,
665
+ "ishikawa-head-label",
666
+ "start",
667
+ fontSize
668
+ );
669
+ const tb = textEl.node().getBBox();
670
+ const w = Math.max(60, tb.width + 6);
671
+ const h = Math.max(40, tb.height * 2 + 40);
672
+ const headPath = `M 0 ${-h / 2} L 0 ${h / 2} Q ${w * 2.4} 0 0 ${-h / 2} Z`;
673
+ if (roughContext) {
674
+ const roughNode = roughContext.roughSvg.path(headPath, {
675
+ roughness: 1.5,
676
+ seed: roughContext.seed,
677
+ fill: roughContext.fillColor,
678
+ fillStyle: "hachure",
679
+ fillWeight: 2.5,
680
+ hachureGap: 5,
681
+ stroke: roughContext.lineColor,
682
+ strokeWidth: 2
683
+ });
684
+ headGroup.insert(() => roughNode, ":first-child").attr("class", "ishikawa-head");
685
+ } else {
686
+ headGroup.insert("path", ":first-child").attr("class", "ishikawa-head").attr("d", headPath);
687
+ }
688
+ textEl.attr("transform", `translate(${(w - tb.width) / 2 - tb.x + 3},${-tb.y - tb.height / 2})`);
689
+ }, "drawHead");
690
+ var flattenTree = /* @__PURE__ */ __name((children, direction) => {
691
+ const entries = [];
692
+ const yOrder = [];
693
+ const walk = /* @__PURE__ */ __name((nodes, pid, depth) => {
694
+ const ordered = direction === -1 ? [...nodes].reverse() : nodes;
695
+ for (const child of ordered) {
696
+ const idx = entries.length;
697
+ const gc = child.children ?? [];
698
+ entries.push({
699
+ depth,
700
+ text: wrapText(child.text, 15),
701
+ parentIndex: pid,
702
+ childCount: gc.length
703
+ });
704
+ if (depth % 2 === 0) {
705
+ yOrder.push(idx);
706
+ if (gc.length) {
707
+ walk(gc, idx, depth + 1);
708
+ }
709
+ } else {
710
+ if (gc.length) {
711
+ walk(gc, idx, depth + 1);
712
+ }
713
+ yOrder.push(idx);
714
+ }
715
+ }
716
+ }, "walk");
717
+ walk(children, -1, 2);
718
+ return { entries, yOrder };
719
+ }, "flattenTree");
720
+ var drawCauseLabel = /* @__PURE__ */ __name((svg, text, x, y, direction, fontSize, roughContext) => {
721
+ const lg = svg.append("g").attr("class", "ishikawa-label-group");
722
+ const lt = drawMultilineText(
723
+ lg,
724
+ text,
725
+ x,
726
+ y + 11 * direction,
727
+ "ishikawa-label cause",
728
+ "middle",
729
+ fontSize
730
+ );
731
+ const tb = lt.node().getBBox();
732
+ if (roughContext) {
733
+ const roughNode = roughContext.roughSvg.rectangle(
734
+ tb.x - 20,
735
+ tb.y - 2,
736
+ tb.width + 40,
737
+ tb.height + 4,
738
+ {
739
+ roughness: 1.5,
740
+ seed: roughContext.seed,
741
+ fill: roughContext.fillColor,
742
+ fillStyle: "hachure",
743
+ fillWeight: 2.5,
744
+ hachureGap: 5,
745
+ stroke: roughContext.lineColor,
746
+ strokeWidth: 2
747
+ }
748
+ );
749
+ lg.insert(() => roughNode, ":first-child").attr("class", "ishikawa-label-box");
750
+ } else {
751
+ 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);
752
+ }
753
+ }, "drawCauseLabel");
754
+ var drawArrowMarker = /* @__PURE__ */ __name((g, x, y, dx, dy, roughContext) => {
755
+ const len = Math.sqrt(dx * dx + dy * dy);
756
+ if (len === 0) {
757
+ return;
758
+ }
759
+ const ux = dx / len;
760
+ const uy = dy / len;
761
+ const s = 6;
762
+ const px = -uy * s;
763
+ const py = ux * s;
764
+ const tipX = x;
765
+ const tipY = y;
766
+ 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`;
767
+ const roughNode = roughContext.roughSvg.path(d, {
768
+ roughness: 1,
769
+ seed: roughContext.seed,
770
+ fill: roughContext.lineColor,
771
+ fillStyle: "solid",
772
+ stroke: roughContext.lineColor,
773
+ strokeWidth: 1
774
+ });
775
+ g.append(() => roughNode);
776
+ }, "drawArrowMarker");
777
+ var drawBranch = /* @__PURE__ */ __name((svg, node, startX, startY, direction, length, fontSize, roughContext) => {
778
+ const children = node.children ?? [];
779
+ const lineLen = length * (children.length ? 1 : 0.2);
780
+ const dx = -COS_A * lineLen;
781
+ const dy = SIN_A * lineLen * direction;
782
+ const endX = startX + dx;
783
+ const endY = startY + dy;
784
+ drawLine(svg, startX, startY, endX, endY, "ishikawa-branch", roughContext);
785
+ if (roughContext) {
786
+ drawArrowMarker(svg, startX, startY, startX - endX, startY - endY, roughContext);
787
+ }
788
+ drawCauseLabel(svg, node.text, endX, endY, direction, fontSize, roughContext);
789
+ if (!children.length) {
790
+ return;
791
+ }
792
+ const { entries, yOrder } = flattenTree(children, direction);
793
+ const entryCount = entries.length;
794
+ const ys = new Array(entryCount);
795
+ for (const [slot, entryIdx] of yOrder.entries()) {
796
+ ys[entryIdx] = startY + dy * ((slot + 1) / (entryCount + 1));
797
+ }
798
+ const bones = /* @__PURE__ */ new Map();
799
+ bones.set(-1, {
800
+ x0: startX,
801
+ y0: startY,
802
+ x1: endX,
803
+ y1: endY,
804
+ childCount: children.length,
805
+ childrenDrawn: 0
806
+ });
807
+ const diagonalX = -COS_A;
808
+ const diagonalY = SIN_A * direction;
809
+ const oddLabel = direction < 0 ? "ishikawa-label up" : "ishikawa-label down";
810
+ for (const [i, e] of entries.entries()) {
811
+ const y = ys[i];
812
+ const par = bones.get(e.parentIndex);
813
+ const grp = svg.append("g").attr("class", "ishikawa-sub-group");
814
+ let bx0 = 0;
815
+ let by0 = 0;
816
+ let bx1 = 0;
817
+ if (e.depth % 2 === 0) {
818
+ const dyP = par.y1 - par.y0;
819
+ bx0 = lerp(par.x0, par.x1, dyP ? (y - par.y0) / dyP : 0.5);
820
+ by0 = y;
821
+ bx1 = bx0 - (e.childCount > 0 ? BONE_BASE + e.childCount * BONE_PER_CHILD : BONE_STUB);
822
+ drawLine(grp, bx0, y, bx1, y, "ishikawa-sub-branch", roughContext);
823
+ if (roughContext) {
824
+ drawArrowMarker(grp, bx0, y, 1, 0, roughContext);
825
+ }
826
+ drawMultilineText(grp, e.text, bx1, y, "ishikawa-label align", "end", fontSize);
827
+ } else {
828
+ const k = par.childrenDrawn++;
829
+ bx0 = lerp(par.x0, par.x1, (par.childCount - k) / (par.childCount + 1));
830
+ by0 = par.y0;
831
+ bx1 = bx0 + diagonalX * ((y - by0) / diagonalY);
832
+ drawLine(grp, bx0, by0, bx1, y, "ishikawa-sub-branch", roughContext);
833
+ if (roughContext) {
834
+ drawArrowMarker(grp, bx0, by0, bx0 - bx1, by0 - y, roughContext);
835
+ }
836
+ drawMultilineText(grp, e.text, bx1, y, oddLabel, "end", fontSize);
837
+ }
838
+ if (e.childCount > 0) {
839
+ bones.set(i, {
840
+ x0: bx0,
841
+ y0: by0,
842
+ x1: bx1,
843
+ y1: y,
844
+ childCount: e.childCount,
845
+ childrenDrawn: 0
846
+ });
847
+ }
848
+ }
849
+ }, "drawBranch");
850
+ var splitLines = /* @__PURE__ */ __name((text) => text.split(/<br\s*\/?>|\n/), "splitLines");
851
+ var wrapText = /* @__PURE__ */ __name((text, maxChars) => {
852
+ if (text.length <= maxChars) {
853
+ return text;
854
+ }
855
+ const lines = [];
856
+ for (const word of text.split(/\s+/)) {
857
+ const last = lines.length - 1;
858
+ if (last >= 0 && lines[last].length + 1 + word.length <= maxChars) {
859
+ lines[last] += " " + word;
860
+ } else {
861
+ lines.push(word);
862
+ }
863
+ }
864
+ return lines.join("\n");
865
+ }, "wrapText");
866
+ var drawMultilineText = /* @__PURE__ */ __name((g, text, x, y, cls, anchor, fontSize) => {
867
+ const lines = splitLines(text);
868
+ const lh = fontSize * 1.05;
869
+ const el = g.append("text").attr("class", cls).attr("text-anchor", anchor).attr("x", x).attr("y", y - (lines.length - 1) * lh / 2);
870
+ for (const [i, line] of lines.entries()) {
871
+ el.append("tspan").attr("x", x).attr("dy", i === 0 ? 0 : lh).text(line);
872
+ }
873
+ return el;
874
+ }, "drawMultilineText");
875
+ var lerp = /* @__PURE__ */ __name((a, b, t) => a + (b - a) * t, "lerp");
876
+ var drawLine = /* @__PURE__ */ __name((g, x1, y1, x2, y2, cls, roughContext) => {
877
+ if (roughContext) {
878
+ const roughNode = roughContext.roughSvg.line(x1, y1, x2, y2, {
879
+ roughness: 1.5,
880
+ seed: roughContext.seed,
881
+ stroke: roughContext.lineColor,
882
+ strokeWidth: 2
883
+ });
884
+ g.append(() => roughNode).attr("class", cls);
885
+ return void 0;
886
+ }
887
+ return g.append("line").attr("class", cls).attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2);
888
+ }, "drawLine");
889
+ var renderer = { draw };
890
+ var getStyles = /* @__PURE__ */ __name((options) => `
891
+ .ishikawa .ishikawa-spine,
892
+ .ishikawa .ishikawa-branch,
893
+ .ishikawa .ishikawa-sub-branch {
894
+ stroke: ${options.lineColor};
895
+ stroke-width: 2;
896
+ fill: none;
897
+ }
898
+
899
+ .ishikawa .ishikawa-sub-branch {
900
+ stroke-width: 1;
901
+ }
902
+
903
+ .ishikawa .ishikawa-arrow {
904
+ fill: ${options.lineColor};
905
+ }
906
+
907
+ .ishikawa .ishikawa-head {
908
+ fill: ${options.mainBkg};
909
+ stroke: ${options.lineColor};
910
+ stroke-width: 2;
911
+ }
912
+
913
+ .ishikawa .ishikawa-label-box {
914
+ fill: ${options.mainBkg};
915
+ stroke: ${options.lineColor};
916
+ stroke-width: 2;
917
+ }
918
+
919
+ .ishikawa text {
920
+ font-family: ${options.fontFamily};
921
+ font-size: ${options.fontSize};
922
+ fill: ${options.textColor};
923
+ }
924
+
925
+ .ishikawa .ishikawa-head-label {
926
+ font-weight: 600;
927
+ text-anchor: middle;
928
+ dominant-baseline: middle;
929
+ font-size: 14px;
930
+ }
931
+
932
+ .ishikawa .ishikawa-label {
933
+ text-anchor: end;
934
+ }
935
+
936
+ .ishikawa .ishikawa-label.cause {
937
+ text-anchor: middle;
938
+ dominant-baseline: middle;
939
+ }
940
+
941
+ .ishikawa .ishikawa-label.align {
942
+ text-anchor: end;
943
+ dominant-baseline: middle;
944
+ }
945
+
946
+ .ishikawa .ishikawa-label.up {
947
+ dominant-baseline: baseline;
948
+ }
949
+
950
+ .ishikawa .ishikawa-label.down {
951
+ dominant-baseline: hanging;
952
+ }
953
+ `, "getStyles");
954
+ var ishikawaStyles_default = getStyles;
955
+ var diagram = {
956
+ parser: ishikawa_default,
957
+ get db() {
958
+ return new IshikawaDB();
959
+ },
960
+ renderer,
961
+ styles: ishikawaStyles_default
962
+ };
963
+ export {
964
+ diagram
965
+ };
966
+ //# sourceMappingURL=ishikawaDiagram-PHBUUO56-C7j3YWdw.js.map