dominds 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 (273) hide show
  1. package/LICENSE +157 -0
  2. package/README.md +250 -0
  3. package/README.zh.md +161 -0
  4. package/dist/access-control.js +253 -0
  5. package/dist/cli/create.js +263 -0
  6. package/dist/cli/read.js +84 -0
  7. package/dist/cli/tui.js +199 -0
  8. package/dist/cli/webui.js +169 -0
  9. package/dist/cli.js +227 -0
  10. package/dist/dialog-factory.js +53 -0
  11. package/dist/dialog-global-registry.js +68 -0
  12. package/dist/dialog-instance-registry.js +78 -0
  13. package/dist/dialog-run-state.js +198 -0
  14. package/dist/dialog.js +1024 -0
  15. package/dist/evt-registry.js +103 -0
  16. package/dist/index.js +8 -0
  17. package/dist/llm/client.js +69 -0
  18. package/dist/llm/defaults.yaml +386 -0
  19. package/dist/llm/driver.js +3214 -0
  20. package/dist/llm/gen/anthropic.js +611 -0
  21. package/dist/llm/gen/codex.js +375 -0
  22. package/dist/llm/gen/mock.js +326 -0
  23. package/dist/llm/gen/openai.js +470 -0
  24. package/dist/llm/gen/registry.js +26 -0
  25. package/dist/llm/gen.js +2 -0
  26. package/dist/llm/tools-projection.js +37 -0
  27. package/dist/log.js +228 -0
  28. package/dist/mcp/config.js +230 -0
  29. package/dist/mcp/sdk-client.js +129 -0
  30. package/dist/mcp/server-runtime.js +57 -0
  31. package/dist/mcp/stdio-client.js +280 -0
  32. package/dist/mcp/supervisor.js +979 -0
  33. package/dist/mcp/tool-names.js +109 -0
  34. package/dist/minds/builtin/cmdr/persona.md +3 -0
  35. package/dist/minds/builtin/dijiang/knowledge.md +287 -0
  36. package/dist/minds/builtin/dijiang/persona.md +7 -0
  37. package/dist/minds/builtin/fuxi/persona.en.md +59 -0
  38. package/dist/minds/builtin/fuxi/persona.zh.md +49 -0
  39. package/dist/minds/builtin/pangu/persona.en.md +78 -0
  40. package/dist/minds/builtin/pangu/persona.zh.md +71 -0
  41. package/dist/minds/load.js +617 -0
  42. package/dist/minds/minds-i18n.js +131 -0
  43. package/dist/minds/system-prompt.js +281 -0
  44. package/dist/persistence.js +3128 -0
  45. package/dist/problems.js +109 -0
  46. package/dist/server/api-routes.js +1031 -0
  47. package/dist/server/auth.js +180 -0
  48. package/dist/server/mime-types.js +32 -0
  49. package/dist/server/prompts-routes.js +543 -0
  50. package/dist/server/server-core.js +235 -0
  51. package/dist/server/setup-routes.js +697 -0
  52. package/dist/server/static-server.js +132 -0
  53. package/dist/server/websocket-handler.js +1011 -0
  54. package/dist/server.js +164 -0
  55. package/dist/shared/async-fifo-mutex.js +36 -0
  56. package/dist/shared/diligence.js +20 -0
  57. package/dist/shared/dotenv.js +144 -0
  58. package/dist/shared/evt.js +195 -0
  59. package/dist/shared/i18n/driver-messages.js +267 -0
  60. package/dist/shared/i18n/text.js +9 -0
  61. package/dist/shared/i18n/tool-result-messages.js +51 -0
  62. package/dist/shared/rtws-cli.js +73 -0
  63. package/dist/shared/runtime-language.js +47 -0
  64. package/dist/shared/team-mgmt-manual.js +116 -0
  65. package/dist/shared/types/context-health.js +2 -0
  66. package/dist/shared/types/dialog.js +11 -0
  67. package/dist/shared/types/i18n.js +2 -0
  68. package/dist/shared/types/index.js +26 -0
  69. package/dist/shared/types/language.js +40 -0
  70. package/dist/shared/types/problems.js +2 -0
  71. package/dist/shared/types/prompts.js +2 -0
  72. package/dist/shared/types/q4h.js +7 -0
  73. package/dist/shared/types/run-state.js +8 -0
  74. package/dist/shared/types/setup.js +2 -0
  75. package/dist/shared/types/storage.js +10 -0
  76. package/dist/shared/types/tellask.js +8 -0
  77. package/dist/shared/types/tools-registry.js +2 -0
  78. package/dist/shared/types/wire.js +12 -0
  79. package/dist/shared/utils/fmt.js +9 -0
  80. package/dist/shared/utils/html.js +20 -0
  81. package/dist/shared/utils/id.js +18 -0
  82. package/dist/shared/utils/inter-dialog-format.js +101 -0
  83. package/dist/shared/utils/time.js +13 -0
  84. package/dist/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  85. package/dist/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  86. package/dist/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  87. package/dist/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  88. package/dist/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  89. package/dist/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  90. package/dist/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  91. package/dist/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  92. package/dist/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  93. package/dist/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  94. package/dist/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  95. package/dist/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  96. package/dist/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  97. package/dist/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  98. package/dist/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  99. package/dist/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  100. package/dist/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  101. package/dist/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  102. package/dist/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  103. package/dist/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  104. package/dist/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  105. package/dist/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  106. package/dist/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  107. package/dist/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  108. package/dist/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  109. package/dist/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  110. package/dist/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  111. package/dist/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  112. package/dist/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  113. package/dist/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  114. package/dist/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  115. package/dist/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  116. package/dist/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  117. package/dist/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  118. package/dist/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  119. package/dist/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  120. package/dist/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  121. package/dist/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  122. package/dist/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  123. package/dist/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  124. package/dist/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  125. package/dist/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  126. package/dist/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  127. package/dist/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  128. package/dist/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  129. package/dist/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  130. package/dist/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  131. package/dist/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  132. package/dist/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  133. package/dist/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  134. package/dist/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  135. package/dist/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  136. package/dist/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  137. package/dist/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  138. package/dist/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  139. package/dist/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  140. package/dist/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  141. package/dist/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  142. package/dist/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  143. package/dist/static/assets/_baseUniq-Crfl3d5Y.js +661 -0
  144. package/dist/static/assets/_baseUniq-Crfl3d5Y.js.map +1 -0
  145. package/dist/static/assets/arc-CbA_x9GD.js +132 -0
  146. package/dist/static/assets/arc-CbA_x9GD.js.map +1 -0
  147. package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js +8685 -0
  148. package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js.map +1 -0
  149. package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js +3608 -0
  150. package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js.map +1 -0
  151. package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js +2482 -0
  152. package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js.map +1 -0
  153. package/dist/static/assets/channel-BVr1Yke-.js +8 -0
  154. package/dist/static/assets/channel-BVr1Yke-.js.map +1 -0
  155. package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js +17 -0
  156. package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js.map +1 -0
  157. package/dist/static/assets/chunk-55IACEB6-q172NeCV.js +14 -0
  158. package/dist/static/assets/chunk-55IACEB6-q172NeCV.js.map +1 -0
  159. package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js +1827 -0
  160. package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js.map +1 -0
  161. package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js +1916 -0
  162. package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js.map +1 -0
  163. package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js +20 -0
  164. package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js.map +1 -0
  165. package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js +25 -0
  166. package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js.map +1 -0
  167. package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js +18 -0
  168. package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js.map +1 -0
  169. package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js +109 -0
  170. package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js.map +1 -0
  171. package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js +23 -0
  172. package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js.map +1 -0
  173. package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js +23 -0
  174. package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js.map +1 -0
  175. package/dist/static/assets/clone-D2OgLSSn.js +9 -0
  176. package/dist/static/assets/clone-D2OgLSSn.js.map +1 -0
  177. package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js +4943 -0
  178. package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js.map +1 -0
  179. package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js +30240 -0
  180. package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js.map +1 -0
  181. package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js +695 -0
  182. package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js.map +1 -0
  183. package/dist/static/assets/defaultLocale-DVr69WTU.js +207 -0
  184. package/dist/static/assets/defaultLocale-DVr69WTU.js.map +1 -0
  185. package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js +849 -0
  186. package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js.map +1 -0
  187. package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js +303 -0
  188. package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js.map +1 -0
  189. package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js +213 -0
  190. package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js.map +1 -0
  191. package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js +1159 -0
  192. package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js.map +1 -0
  193. package/dist/static/assets/favicon-Cmg5RbCj.svg +8 -0
  194. package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js +2332 -0
  195. package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js.map +1 -0
  196. package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js +3681 -0
  197. package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js.map +1 -0
  198. package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js +1206 -0
  199. package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js.map +1 -0
  200. package/dist/static/assets/graph-CS0Pmm7c.js +597 -0
  201. package/dist/static/assets/graph-CS0Pmm7c.js.map +1 -0
  202. package/dist/static/assets/index-BS6HnGzC.js +112303 -0
  203. package/dist/static/assets/index-BS6HnGzC.js.map +1 -0
  204. package/dist/static/assets/index-DaIsSzC_.css +483 -0
  205. package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js +34 -0
  206. package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js.map +1 -0
  207. package/dist/static/assets/init-ZxktEp_H.js +17 -0
  208. package/dist/static/assets/init-ZxktEp_H.js.map +1 -0
  209. package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js +1255 -0
  210. package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js.map +1 -0
  211. package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js +1048 -0
  212. package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js.map +1 -0
  213. package/dist/static/assets/layout-8TGxpm23.js +2218 -0
  214. package/dist/static/assets/layout-8TGxpm23.js.map +1 -0
  215. package/dist/static/assets/linear-BATBPQQv.js +341 -0
  216. package/dist/static/assets/linear-BATBPQQv.js.map +1 -0
  217. package/dist/static/assets/min-B3oVH3AC.js +42 -0
  218. package/dist/static/assets/min-B3oVH3AC.js.map +1 -0
  219. package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js +1127 -0
  220. package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js.map +1 -0
  221. package/dist/static/assets/ordinal-CxptdPJm.js +77 -0
  222. package/dist/static/assets/ordinal-CxptdPJm.js.map +1 -0
  223. package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js +241 -0
  224. package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js.map +1 -0
  225. package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js +1338 -0
  226. package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js.map +1 -0
  227. package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js +1162 -0
  228. package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js.map +1 -0
  229. package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js +1195 -0
  230. package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js.map +1 -0
  231. package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js +3875 -0
  232. package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js.map +1 -0
  233. package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js +452 -0
  234. package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js.map +1 -0
  235. package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js +22 -0
  236. package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js.map +1 -0
  237. package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js +1223 -0
  238. package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js.map +1 -0
  239. package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js +18753 -0
  240. package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js.map +1 -0
  241. package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js +1888 -0
  242. package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js.map +1 -0
  243. package/dist/static/index.html +71 -0
  244. package/dist/static/testing/dom-observation-utils.js +425 -0
  245. package/dist/static/testing/e2e-test-helper.js +3119 -0
  246. package/dist/team.js +1160 -0
  247. package/dist/tellask.js +431 -0
  248. package/dist/tool.js +150 -0
  249. package/dist/tools/apply-patch.js +542 -0
  250. package/dist/tools/builtins.js +196 -0
  251. package/dist/tools/context-health.js +177 -0
  252. package/dist/tools/ctrl.js +478 -0
  253. package/dist/tools/diag.js +583 -0
  254. package/dist/tools/env.js +184 -0
  255. package/dist/tools/fs.js +818 -0
  256. package/dist/tools/mcp.js +138 -0
  257. package/dist/tools/mem.js +349 -0
  258. package/dist/tools/os.js +751 -0
  259. package/dist/tools/prompts/team_mgmt.en.md +70 -0
  260. package/dist/tools/prompts/team_mgmt.zh.md +70 -0
  261. package/dist/tools/prompts/ws_mod.en.md +86 -0
  262. package/dist/tools/prompts/ws_mod.zh.md +87 -0
  263. package/dist/tools/registry-snapshot.js +31 -0
  264. package/dist/tools/registry.js +121 -0
  265. package/dist/tools/ripgrep.js +678 -0
  266. package/dist/tools/team-mgmt.js +3300 -0
  267. package/dist/tools/txt.js +3178 -0
  268. package/dist/utils/id.js +72 -0
  269. package/dist/utils/task-doc.js +236 -0
  270. package/dist/utils/task-package.js +522 -0
  271. package/dist/utils/taskdoc-search.js +280 -0
  272. package/dist/utils/taskdoc.js +400 -0
  273. package/package.json +69 -0
@@ -0,0 +1,849 @@
1
+ var _a;
2
+ import { _ as __name, D as cleanAndMerge, E as getConfig, H as selectSvgElement, e as configureSvgSize, l as log, b9 as styles2String, d as select, b as setAccTitle, a as getAccTitle, p as setDiagramTitle, q as getDiagramTitle, g as getAccDescription, s as setAccDescription, F as defaultConfig_default, ba as isLabelStyle, y as clear } from "./index-BS6HnGzC.js";
3
+ import { s as setupViewPortForSVG } from "./chunk-QN33PNHL-CnpBNkpP.js";
4
+ import { p as populateCommonDb } from "./chunk-4BX2VUAB-qCIn5Iic.js";
5
+ import { p as parse } from "./treemap-KMMF4GRG-DAGDLhj2.js";
6
+ import { b as format } from "./defaultLocale-DVr69WTU.js";
7
+ import { o as ordinal } from "./ordinal-CxptdPJm.js";
8
+ import "./min-B3oVH3AC.js";
9
+ import "./_baseUniq-Crfl3d5Y.js";
10
+ import "./init-ZxktEp_H.js";
11
+ function count(node) {
12
+ var sum = 0, children = node.children, i = children && children.length;
13
+ if (!i) sum = 1;
14
+ else while (--i >= 0) sum += children[i].value;
15
+ node.value = sum;
16
+ }
17
+ function node_count() {
18
+ return this.eachAfter(count);
19
+ }
20
+ function node_each(callback, that) {
21
+ let index = -1;
22
+ for (const node of this) {
23
+ callback.call(that, node, ++index, this);
24
+ }
25
+ return this;
26
+ }
27
+ function node_eachBefore(callback, that) {
28
+ var node = this, nodes = [node], children, i, index = -1;
29
+ while (node = nodes.pop()) {
30
+ callback.call(that, node, ++index, this);
31
+ if (children = node.children) {
32
+ for (i = children.length - 1; i >= 0; --i) {
33
+ nodes.push(children[i]);
34
+ }
35
+ }
36
+ }
37
+ return this;
38
+ }
39
+ function node_eachAfter(callback, that) {
40
+ var node = this, nodes = [node], next = [], children, i, n, index = -1;
41
+ while (node = nodes.pop()) {
42
+ next.push(node);
43
+ if (children = node.children) {
44
+ for (i = 0, n = children.length; i < n; ++i) {
45
+ nodes.push(children[i]);
46
+ }
47
+ }
48
+ }
49
+ while (node = next.pop()) {
50
+ callback.call(that, node, ++index, this);
51
+ }
52
+ return this;
53
+ }
54
+ function node_find(callback, that) {
55
+ let index = -1;
56
+ for (const node of this) {
57
+ if (callback.call(that, node, ++index, this)) {
58
+ return node;
59
+ }
60
+ }
61
+ }
62
+ function node_sum(value) {
63
+ return this.eachAfter(function(node) {
64
+ var sum = +value(node.data) || 0, children = node.children, i = children && children.length;
65
+ while (--i >= 0) sum += children[i].value;
66
+ node.value = sum;
67
+ });
68
+ }
69
+ function node_sort(compare) {
70
+ return this.eachBefore(function(node) {
71
+ if (node.children) {
72
+ node.children.sort(compare);
73
+ }
74
+ });
75
+ }
76
+ function node_path(end) {
77
+ var start = this, ancestor = leastCommonAncestor(start, end), nodes = [start];
78
+ while (start !== ancestor) {
79
+ start = start.parent;
80
+ nodes.push(start);
81
+ }
82
+ var k = nodes.length;
83
+ while (end !== ancestor) {
84
+ nodes.splice(k, 0, end);
85
+ end = end.parent;
86
+ }
87
+ return nodes;
88
+ }
89
+ function leastCommonAncestor(a, b) {
90
+ if (a === b) return a;
91
+ var aNodes = a.ancestors(), bNodes = b.ancestors(), c = null;
92
+ a = aNodes.pop();
93
+ b = bNodes.pop();
94
+ while (a === b) {
95
+ c = a;
96
+ a = aNodes.pop();
97
+ b = bNodes.pop();
98
+ }
99
+ return c;
100
+ }
101
+ function node_ancestors() {
102
+ var node = this, nodes = [node];
103
+ while (node = node.parent) {
104
+ nodes.push(node);
105
+ }
106
+ return nodes;
107
+ }
108
+ function node_descendants() {
109
+ return Array.from(this);
110
+ }
111
+ function node_leaves() {
112
+ var leaves = [];
113
+ this.eachBefore(function(node) {
114
+ if (!node.children) {
115
+ leaves.push(node);
116
+ }
117
+ });
118
+ return leaves;
119
+ }
120
+ function node_links() {
121
+ var root = this, links = [];
122
+ root.each(function(node) {
123
+ if (node !== root) {
124
+ links.push({ source: node.parent, target: node });
125
+ }
126
+ });
127
+ return links;
128
+ }
129
+ function* node_iterator() {
130
+ var node = this, current, next = [node], children, i, n;
131
+ do {
132
+ current = next.reverse(), next = [];
133
+ while (node = current.pop()) {
134
+ yield node;
135
+ if (children = node.children) {
136
+ for (i = 0, n = children.length; i < n; ++i) {
137
+ next.push(children[i]);
138
+ }
139
+ }
140
+ }
141
+ } while (next.length);
142
+ }
143
+ function hierarchy(data, children) {
144
+ if (data instanceof Map) {
145
+ data = [void 0, data];
146
+ if (children === void 0) children = mapChildren;
147
+ } else if (children === void 0) {
148
+ children = objectChildren;
149
+ }
150
+ var root = new Node(data), node, nodes = [root], child, childs, i, n;
151
+ while (node = nodes.pop()) {
152
+ if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {
153
+ node.children = childs;
154
+ for (i = n - 1; i >= 0; --i) {
155
+ nodes.push(child = childs[i] = new Node(childs[i]));
156
+ child.parent = node;
157
+ child.depth = node.depth + 1;
158
+ }
159
+ }
160
+ }
161
+ return root.eachBefore(computeHeight);
162
+ }
163
+ function node_copy() {
164
+ return hierarchy(this).eachBefore(copyData);
165
+ }
166
+ function objectChildren(d) {
167
+ return d.children;
168
+ }
169
+ function mapChildren(d) {
170
+ return Array.isArray(d) ? d[1] : null;
171
+ }
172
+ function copyData(node) {
173
+ if (node.data.value !== void 0) node.value = node.data.value;
174
+ node.data = node.data.data;
175
+ }
176
+ function computeHeight(node) {
177
+ var height = 0;
178
+ do
179
+ node.height = height;
180
+ while ((node = node.parent) && node.height < ++height);
181
+ }
182
+ function Node(data) {
183
+ this.data = data;
184
+ this.depth = this.height = 0;
185
+ this.parent = null;
186
+ }
187
+ Node.prototype = hierarchy.prototype = {
188
+ constructor: Node,
189
+ count: node_count,
190
+ each: node_each,
191
+ eachAfter: node_eachAfter,
192
+ eachBefore: node_eachBefore,
193
+ find: node_find,
194
+ sum: node_sum,
195
+ sort: node_sort,
196
+ path: node_path,
197
+ ancestors: node_ancestors,
198
+ descendants: node_descendants,
199
+ leaves: node_leaves,
200
+ links: node_links,
201
+ copy: node_copy,
202
+ [Symbol.iterator]: node_iterator
203
+ };
204
+ function required(f) {
205
+ if (typeof f !== "function") throw new Error();
206
+ return f;
207
+ }
208
+ function constantZero() {
209
+ return 0;
210
+ }
211
+ function constant(x) {
212
+ return function() {
213
+ return x;
214
+ };
215
+ }
216
+ function roundNode(node) {
217
+ node.x0 = Math.round(node.x0);
218
+ node.y0 = Math.round(node.y0);
219
+ node.x1 = Math.round(node.x1);
220
+ node.y1 = Math.round(node.y1);
221
+ }
222
+ function treemapDice(parent, x0, y0, x1, y1) {
223
+ var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (x1 - x0) / parent.value;
224
+ while (++i < n) {
225
+ node = nodes[i], node.y0 = y0, node.y1 = y1;
226
+ node.x0 = x0, node.x1 = x0 += node.value * k;
227
+ }
228
+ }
229
+ function treemapSlice(parent, x0, y0, x1, y1) {
230
+ var nodes = parent.children, node, i = -1, n = nodes.length, k = parent.value && (y1 - y0) / parent.value;
231
+ while (++i < n) {
232
+ node = nodes[i], node.x0 = x0, node.x1 = x1;
233
+ node.y0 = y0, node.y1 = y0 += node.value * k;
234
+ }
235
+ }
236
+ var phi = (1 + Math.sqrt(5)) / 2;
237
+ function squarifyRatio(ratio, parent, x0, y0, x1, y1) {
238
+ var rows = [], nodes = parent.children, row, nodeValue, i0 = 0, i1 = 0, n = nodes.length, dx, dy, value = parent.value, sumValue, minValue, maxValue, newRatio, minRatio, alpha, beta;
239
+ while (i0 < n) {
240
+ dx = x1 - x0, dy = y1 - y0;
241
+ do
242
+ sumValue = nodes[i1++].value;
243
+ while (!sumValue && i1 < n);
244
+ minValue = maxValue = sumValue;
245
+ alpha = Math.max(dy / dx, dx / dy) / (value * ratio);
246
+ beta = sumValue * sumValue * alpha;
247
+ minRatio = Math.max(maxValue / beta, beta / minValue);
248
+ for (; i1 < n; ++i1) {
249
+ sumValue += nodeValue = nodes[i1].value;
250
+ if (nodeValue < minValue) minValue = nodeValue;
251
+ if (nodeValue > maxValue) maxValue = nodeValue;
252
+ beta = sumValue * sumValue * alpha;
253
+ newRatio = Math.max(maxValue / beta, beta / minValue);
254
+ if (newRatio > minRatio) {
255
+ sumValue -= nodeValue;
256
+ break;
257
+ }
258
+ minRatio = newRatio;
259
+ }
260
+ rows.push(row = { value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1) });
261
+ if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);
262
+ else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);
263
+ value -= sumValue, i0 = i1;
264
+ }
265
+ return rows;
266
+ }
267
+ const squarify = (function custom(ratio) {
268
+ function squarify2(parent, x0, y0, x1, y1) {
269
+ squarifyRatio(ratio, parent, x0, y0, x1, y1);
270
+ }
271
+ squarify2.ratio = function(x) {
272
+ return custom((x = +x) > 1 ? x : 1);
273
+ };
274
+ return squarify2;
275
+ })(phi);
276
+ function treemap() {
277
+ var tile = squarify, round = false, dx = 1, dy = 1, paddingStack = [0], paddingInner = constantZero, paddingTop = constantZero, paddingRight = constantZero, paddingBottom = constantZero, paddingLeft = constantZero;
278
+ function treemap2(root) {
279
+ root.x0 = root.y0 = 0;
280
+ root.x1 = dx;
281
+ root.y1 = dy;
282
+ root.eachBefore(positionNode);
283
+ paddingStack = [0];
284
+ if (round) root.eachBefore(roundNode);
285
+ return root;
286
+ }
287
+ function positionNode(node) {
288
+ var p = paddingStack[node.depth], x0 = node.x0 + p, y0 = node.y0 + p, x1 = node.x1 - p, y1 = node.y1 - p;
289
+ if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
290
+ if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
291
+ node.x0 = x0;
292
+ node.y0 = y0;
293
+ node.x1 = x1;
294
+ node.y1 = y1;
295
+ if (node.children) {
296
+ p = paddingStack[node.depth + 1] = paddingInner(node) / 2;
297
+ x0 += paddingLeft(node) - p;
298
+ y0 += paddingTop(node) - p;
299
+ x1 -= paddingRight(node) - p;
300
+ y1 -= paddingBottom(node) - p;
301
+ if (x1 < x0) x0 = x1 = (x0 + x1) / 2;
302
+ if (y1 < y0) y0 = y1 = (y0 + y1) / 2;
303
+ tile(node, x0, y0, x1, y1);
304
+ }
305
+ }
306
+ treemap2.round = function(x) {
307
+ return arguments.length ? (round = !!x, treemap2) : round;
308
+ };
309
+ treemap2.size = function(x) {
310
+ return arguments.length ? (dx = +x[0], dy = +x[1], treemap2) : [dx, dy];
311
+ };
312
+ treemap2.tile = function(x) {
313
+ return arguments.length ? (tile = required(x), treemap2) : tile;
314
+ };
315
+ treemap2.padding = function(x) {
316
+ return arguments.length ? treemap2.paddingInner(x).paddingOuter(x) : treemap2.paddingInner();
317
+ };
318
+ treemap2.paddingInner = function(x) {
319
+ return arguments.length ? (paddingInner = typeof x === "function" ? x : constant(+x), treemap2) : paddingInner;
320
+ };
321
+ treemap2.paddingOuter = function(x) {
322
+ return arguments.length ? treemap2.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap2.paddingTop();
323
+ };
324
+ treemap2.paddingTop = function(x) {
325
+ return arguments.length ? (paddingTop = typeof x === "function" ? x : constant(+x), treemap2) : paddingTop;
326
+ };
327
+ treemap2.paddingRight = function(x) {
328
+ return arguments.length ? (paddingRight = typeof x === "function" ? x : constant(+x), treemap2) : paddingRight;
329
+ };
330
+ treemap2.paddingBottom = function(x) {
331
+ return arguments.length ? (paddingBottom = typeof x === "function" ? x : constant(+x), treemap2) : paddingBottom;
332
+ };
333
+ treemap2.paddingLeft = function(x) {
334
+ return arguments.length ? (paddingLeft = typeof x === "function" ? x : constant(+x), treemap2) : paddingLeft;
335
+ };
336
+ return treemap2;
337
+ }
338
+ var TreeMapDB = (_a = class {
339
+ constructor() {
340
+ this.nodes = [];
341
+ this.levels = /* @__PURE__ */ new Map();
342
+ this.outerNodes = [];
343
+ this.classes = /* @__PURE__ */ new Map();
344
+ this.setAccTitle = setAccTitle;
345
+ this.getAccTitle = getAccTitle;
346
+ this.setDiagramTitle = setDiagramTitle;
347
+ this.getDiagramTitle = getDiagramTitle;
348
+ this.getAccDescription = getAccDescription;
349
+ this.setAccDescription = setAccDescription;
350
+ }
351
+ getNodes() {
352
+ return this.nodes;
353
+ }
354
+ getConfig() {
355
+ const defaultConfig = defaultConfig_default;
356
+ const userConfig = getConfig();
357
+ return cleanAndMerge({
358
+ ...defaultConfig.treemap,
359
+ ...userConfig.treemap ?? {}
360
+ });
361
+ }
362
+ addNode(node, level) {
363
+ this.nodes.push(node);
364
+ this.levels.set(node, level);
365
+ if (level === 0) {
366
+ this.outerNodes.push(node);
367
+ this.root ?? (this.root = node);
368
+ }
369
+ }
370
+ getRoot() {
371
+ return { name: "", children: this.outerNodes };
372
+ }
373
+ addClass(id, _style) {
374
+ const styleClass = this.classes.get(id) ?? { id, styles: [], textStyles: [] };
375
+ const styles = _style.replace(/\\,/g, "§§§").replace(/,/g, ";").replace(/§§§/g, ",").split(";");
376
+ if (styles) {
377
+ styles.forEach((s) => {
378
+ if (isLabelStyle(s)) {
379
+ if (styleClass?.textStyles) {
380
+ styleClass.textStyles.push(s);
381
+ } else {
382
+ styleClass.textStyles = [s];
383
+ }
384
+ }
385
+ if (styleClass?.styles) {
386
+ styleClass.styles.push(s);
387
+ } else {
388
+ styleClass.styles = [s];
389
+ }
390
+ });
391
+ }
392
+ this.classes.set(id, styleClass);
393
+ }
394
+ getClasses() {
395
+ return this.classes;
396
+ }
397
+ getStylesForClass(classSelector) {
398
+ return this.classes.get(classSelector)?.styles ?? [];
399
+ }
400
+ clear() {
401
+ clear();
402
+ this.nodes = [];
403
+ this.levels = /* @__PURE__ */ new Map();
404
+ this.outerNodes = [];
405
+ this.classes = /* @__PURE__ */ new Map();
406
+ this.root = void 0;
407
+ }
408
+ }, __name(_a, "TreeMapDB"), _a);
409
+ function buildHierarchy(items) {
410
+ if (!items.length) {
411
+ return [];
412
+ }
413
+ const root = [];
414
+ const stack = [];
415
+ items.forEach((item) => {
416
+ const node = {
417
+ name: item.name,
418
+ children: item.type === "Leaf" ? void 0 : []
419
+ };
420
+ node.classSelector = item?.classSelector;
421
+ if (item?.cssCompiledStyles) {
422
+ node.cssCompiledStyles = [item.cssCompiledStyles];
423
+ }
424
+ if (item.type === "Leaf" && item.value !== void 0) {
425
+ node.value = item.value;
426
+ }
427
+ while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {
428
+ stack.pop();
429
+ }
430
+ if (stack.length === 0) {
431
+ root.push(node);
432
+ } else {
433
+ const parent = stack[stack.length - 1].node;
434
+ if (parent.children) {
435
+ parent.children.push(node);
436
+ } else {
437
+ parent.children = [node];
438
+ }
439
+ }
440
+ if (item.type !== "Leaf") {
441
+ stack.push({ node, level: item.level });
442
+ }
443
+ });
444
+ return root;
445
+ }
446
+ __name(buildHierarchy, "buildHierarchy");
447
+ var populate = /* @__PURE__ */ __name((ast, db) => {
448
+ populateCommonDb(ast, db);
449
+ const items = [];
450
+ for (const row of ast.TreemapRows ?? []) {
451
+ if (row.$type === "ClassDefStatement") {
452
+ db.addClass(row.className ?? "", row.styleText ?? "");
453
+ }
454
+ }
455
+ for (const row of ast.TreemapRows ?? []) {
456
+ const item = row.item;
457
+ if (!item) {
458
+ continue;
459
+ }
460
+ const level = row.indent ? parseInt(row.indent) : 0;
461
+ const name = getItemName(item);
462
+ const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];
463
+ const cssCompiledStyles = styles.length > 0 ? styles.join(";") : void 0;
464
+ const itemData = {
465
+ level,
466
+ name,
467
+ type: item.$type,
468
+ value: item.value,
469
+ classSelector: item.classSelector,
470
+ cssCompiledStyles
471
+ };
472
+ items.push(itemData);
473
+ }
474
+ const hierarchyNodes = buildHierarchy(items);
475
+ const addNodesRecursively = /* @__PURE__ */ __name((nodes, level) => {
476
+ for (const node of nodes) {
477
+ db.addNode(node, level);
478
+ if (node.children && node.children.length > 0) {
479
+ addNodesRecursively(node.children, level + 1);
480
+ }
481
+ }
482
+ }, "addNodesRecursively");
483
+ addNodesRecursively(hierarchyNodes, 0);
484
+ }, "populate");
485
+ var getItemName = /* @__PURE__ */ __name((item) => {
486
+ return item.name ? String(item.name) : "";
487
+ }, "getItemName");
488
+ var parser = {
489
+ // @ts-expect-error - TreeMapDB is not assignable to DiagramDB
490
+ parser: { yy: void 0 },
491
+ parse: /* @__PURE__ */ __name(async (text) => {
492
+ try {
493
+ const parseFunc = parse;
494
+ const ast = await parseFunc("treemap", text);
495
+ log.debug("Treemap AST:", ast);
496
+ const db = parser.parser?.yy;
497
+ if (!(db instanceof TreeMapDB)) {
498
+ throw new Error(
499
+ "parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
500
+ );
501
+ }
502
+ populate(ast, db);
503
+ } catch (error) {
504
+ log.error("Error parsing treemap:", error);
505
+ throw error;
506
+ }
507
+ }, "parse")
508
+ };
509
+ var DEFAULT_INNER_PADDING = 10;
510
+ var SECTION_INNER_PADDING = 10;
511
+ var SECTION_HEADER_HEIGHT = 25;
512
+ var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
513
+ const treemapDb = diagram2.db;
514
+ const config = treemapDb.getConfig();
515
+ const treemapInnerPadding = config.padding ?? DEFAULT_INNER_PADDING;
516
+ const title = treemapDb.getDiagramTitle();
517
+ const root = treemapDb.getRoot();
518
+ const { themeVariables } = getConfig();
519
+ if (!root) {
520
+ return;
521
+ }
522
+ const titleHeight = title ? 30 : 0;
523
+ const svg = selectSvgElement(id);
524
+ const width = config.nodeWidth ? config.nodeWidth * SECTION_INNER_PADDING : 960;
525
+ const height = config.nodeHeight ? config.nodeHeight * SECTION_INNER_PADDING : 500;
526
+ const svgWidth = width;
527
+ const svgHeight = height + titleHeight;
528
+ svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
529
+ configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
530
+ let valueFormat;
531
+ try {
532
+ const formatStr = config.valueFormat || ",";
533
+ if (formatStr === "$0,0") {
534
+ valueFormat = /* @__PURE__ */ __name((value) => "$" + format(",")(value), "valueFormat");
535
+ } else if (formatStr.startsWith("$") && formatStr.includes(",")) {
536
+ const precision = /\.\d+/.exec(formatStr);
537
+ const precisionStr = precision ? precision[0] : "";
538
+ valueFormat = /* @__PURE__ */ __name((value) => "$" + format("," + precisionStr)(value), "valueFormat");
539
+ } else if (formatStr.startsWith("$")) {
540
+ const restOfFormat = formatStr.substring(1);
541
+ valueFormat = /* @__PURE__ */ __name((value) => "$" + format(restOfFormat || "")(value), "valueFormat");
542
+ } else {
543
+ valueFormat = format(formatStr);
544
+ }
545
+ } catch (error) {
546
+ log.error("Error creating format function:", error);
547
+ valueFormat = format(",");
548
+ }
549
+ const colorScale = ordinal().range([
550
+ "transparent",
551
+ themeVariables.cScale0,
552
+ themeVariables.cScale1,
553
+ themeVariables.cScale2,
554
+ themeVariables.cScale3,
555
+ themeVariables.cScale4,
556
+ themeVariables.cScale5,
557
+ themeVariables.cScale6,
558
+ themeVariables.cScale7,
559
+ themeVariables.cScale8,
560
+ themeVariables.cScale9,
561
+ themeVariables.cScale10,
562
+ themeVariables.cScale11
563
+ ]);
564
+ const colorScalePeer = ordinal().range([
565
+ "transparent",
566
+ themeVariables.cScalePeer0,
567
+ themeVariables.cScalePeer1,
568
+ themeVariables.cScalePeer2,
569
+ themeVariables.cScalePeer3,
570
+ themeVariables.cScalePeer4,
571
+ themeVariables.cScalePeer5,
572
+ themeVariables.cScalePeer6,
573
+ themeVariables.cScalePeer7,
574
+ themeVariables.cScalePeer8,
575
+ themeVariables.cScalePeer9,
576
+ themeVariables.cScalePeer10,
577
+ themeVariables.cScalePeer11
578
+ ]);
579
+ const colorScaleLabel = ordinal().range([
580
+ themeVariables.cScaleLabel0,
581
+ themeVariables.cScaleLabel1,
582
+ themeVariables.cScaleLabel2,
583
+ themeVariables.cScaleLabel3,
584
+ themeVariables.cScaleLabel4,
585
+ themeVariables.cScaleLabel5,
586
+ themeVariables.cScaleLabel6,
587
+ themeVariables.cScaleLabel7,
588
+ themeVariables.cScaleLabel8,
589
+ themeVariables.cScaleLabel9,
590
+ themeVariables.cScaleLabel10,
591
+ themeVariables.cScaleLabel11
592
+ ]);
593
+ if (title) {
594
+ svg.append("text").attr("x", svgWidth / 2).attr("y", titleHeight / 2).attr("class", "treemapTitle").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
595
+ }
596
+ const g = svg.append("g").attr("transform", `translate(0, ${titleHeight})`).attr("class", "treemapContainer");
597
+ const hierarchyRoot = hierarchy(root).sum((d) => d.value ?? 0).sort((a, b) => (b.value ?? 0) - (a.value ?? 0));
598
+ const treemapLayout = treemap().size([width, height]).paddingTop(
599
+ (d) => d.children && d.children.length > 0 ? SECTION_HEADER_HEIGHT + SECTION_INNER_PADDING : 0
600
+ ).paddingInner(treemapInnerPadding).paddingLeft((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingRight((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingBottom((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).round(true);
601
+ const treemapData = treemapLayout(hierarchyRoot);
602
+ const branchNodes = treemapData.descendants().filter((d) => d.children && d.children.length > 0);
603
+ const sections = g.selectAll(".treemapSection").data(branchNodes).enter().append("g").attr("class", "treemapSection").attr("transform", (d) => `translate(${d.x0},${d.y0})`);
604
+ sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", SECTION_HEADER_HEIGHT).attr("class", "treemapSectionHeader").attr("fill", "none").attr("fill-opacity", 0.6).attr("stroke-width", 0.6).attr("style", (d) => {
605
+ if (d.depth === 0) {
606
+ return "display: none;";
607
+ }
608
+ return "";
609
+ });
610
+ sections.append("clipPath").attr("id", (_d, i) => `clip-section-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 12)).attr("height", SECTION_HEADER_HEIGHT);
611
+ sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", (_d, i) => {
612
+ return `treemapSection section${i}`;
613
+ }).attr("fill", (d) => colorScale(d.data.name)).attr("fill-opacity", 0.6).attr("stroke", (d) => colorScalePeer(d.data.name)).attr("stroke-width", 2).attr("stroke-opacity", 0.4).attr("style", (d) => {
614
+ if (d.depth === 0) {
615
+ return "display: none;";
616
+ }
617
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
618
+ return styles.nodeStyles + ";" + styles.borderStyles.join(";");
619
+ });
620
+ sections.append("text").attr("class", "treemapSectionLabel").attr("x", 6).attr("y", SECTION_HEADER_HEIGHT / 2).attr("dominant-baseline", "middle").text((d) => d.depth === 0 ? "" : d.data.name).attr("font-weight", "bold").attr("style", (d) => {
621
+ if (d.depth === 0) {
622
+ return "display: none;";
623
+ }
624
+ const labelStyles = "dominant-baseline: middle; font-size: 12px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
625
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
626
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
627
+ }).each(function(d) {
628
+ if (d.depth === 0) {
629
+ return;
630
+ }
631
+ const self = select(this);
632
+ const originalText = d.data.name;
633
+ self.text(originalText);
634
+ const totalHeaderWidth = d.x1 - d.x0;
635
+ const labelXPosition = 6;
636
+ let spaceForTextContent;
637
+ if (config.showValues !== false && d.value) {
638
+ const valueEndsAtXRelative = totalHeaderWidth - 10;
639
+ const estimatedValueTextActualWidth = 30;
640
+ const gapBetweenLabelAndValue = 10;
641
+ const labelMustEndBeforeX = valueEndsAtXRelative - estimatedValueTextActualWidth - gapBetweenLabelAndValue;
642
+ spaceForTextContent = labelMustEndBeforeX - labelXPosition;
643
+ } else {
644
+ const labelOwnRightPadding = 6;
645
+ spaceForTextContent = totalHeaderWidth - labelXPosition - labelOwnRightPadding;
646
+ }
647
+ const minimumWidthToDisplay = 15;
648
+ const actualAvailableWidth = Math.max(minimumWidthToDisplay, spaceForTextContent);
649
+ const textNode = self.node();
650
+ const currentTextContentLength = textNode.getComputedTextLength();
651
+ if (currentTextContentLength > actualAvailableWidth) {
652
+ const ellipsis = "...";
653
+ let currentTruncatedText = originalText;
654
+ while (currentTruncatedText.length > 0) {
655
+ currentTruncatedText = originalText.substring(0, currentTruncatedText.length - 1);
656
+ if (currentTruncatedText.length === 0) {
657
+ self.text(ellipsis);
658
+ if (textNode.getComputedTextLength() > actualAvailableWidth) {
659
+ self.text("");
660
+ }
661
+ break;
662
+ }
663
+ self.text(currentTruncatedText + ellipsis);
664
+ if (textNode.getComputedTextLength() <= actualAvailableWidth) {
665
+ break;
666
+ }
667
+ }
668
+ }
669
+ });
670
+ if (config.showValues !== false) {
671
+ sections.append("text").attr("class", "treemapSectionValue").attr("x", (d) => d.x1 - d.x0 - 10).attr("y", SECTION_HEADER_HEIGHT / 2).attr("text-anchor", "end").attr("dominant-baseline", "middle").text((d) => d.value ? valueFormat(d.value) : "").attr("font-style", "italic").attr("style", (d) => {
672
+ if (d.depth === 0) {
673
+ return "display: none;";
674
+ }
675
+ const labelStyles = "text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
676
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
677
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
678
+ });
679
+ }
680
+ const leafNodes = treemapData.leaves();
681
+ const cell = g.selectAll(".treemapLeafGroup").data(leafNodes).enter().append("g").attr("class", (d, i) => {
682
+ return `treemapNode treemapLeafGroup leaf${i}${d.data.classSelector ? ` ${d.data.classSelector}` : ""}x`;
683
+ }).attr("transform", (d) => `translate(${d.x0},${d.y0})`);
684
+ cell.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", "treemapLeaf").attr("fill", (d) => {
685
+ return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
686
+ }).attr("style", (d) => {
687
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
688
+ return styles.nodeStyles;
689
+ }).attr("fill-opacity", 0.3).attr("stroke", (d) => {
690
+ return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
691
+ }).attr("stroke-width", 3);
692
+ cell.append("clipPath").attr("id", (_d, i) => `clip-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 4)).attr("height", (d) => Math.max(0, d.y1 - d.y0 - 4));
693
+ const leafLabels = cell.append("text").attr("class", "treemapLabel").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", (d) => (d.y1 - d.y0) / 2).attr("style", (d) => {
694
+ const labelStyles = "text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:" + colorScaleLabel(d.data.name) + ";";
695
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
696
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
697
+ }).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.data.name);
698
+ leafLabels.each(function(d) {
699
+ const self = select(this);
700
+ const nodeWidth = d.x1 - d.x0;
701
+ const nodeHeight = d.y1 - d.y0;
702
+ const textNode = self.node();
703
+ const padding = 4;
704
+ const availableWidth = nodeWidth - 2 * padding;
705
+ const availableHeight = nodeHeight - 2 * padding;
706
+ if (availableWidth < 10 || availableHeight < 10) {
707
+ self.style("display", "none");
708
+ return;
709
+ }
710
+ let currentLabelFontSize = parseInt(self.style("font-size"), 10);
711
+ const minLabelFontSize = 8;
712
+ const originalValueRelFontSize = 28;
713
+ const valueScaleFactor = 0.6;
714
+ const minValueFontSize = 6;
715
+ const spacingBetweenLabelAndValue = 2;
716
+ while (textNode.getComputedTextLength() > availableWidth && currentLabelFontSize > minLabelFontSize) {
717
+ currentLabelFontSize--;
718
+ self.style("font-size", `${currentLabelFontSize}px`);
719
+ }
720
+ let prospectiveValueFontSize = Math.max(
721
+ minValueFontSize,
722
+ Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
723
+ );
724
+ let combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
725
+ while (combinedHeight > availableHeight && currentLabelFontSize > minLabelFontSize) {
726
+ currentLabelFontSize--;
727
+ prospectiveValueFontSize = Math.max(
728
+ minValueFontSize,
729
+ Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
730
+ );
731
+ if (prospectiveValueFontSize < minValueFontSize && currentLabelFontSize === minLabelFontSize) {
732
+ break;
733
+ }
734
+ self.style("font-size", `${currentLabelFontSize}px`);
735
+ combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
736
+ }
737
+ self.style("font-size", `${currentLabelFontSize}px`);
738
+ if (textNode.getComputedTextLength() > availableWidth || currentLabelFontSize < minLabelFontSize || availableHeight < currentLabelFontSize) {
739
+ self.style("display", "none");
740
+ }
741
+ });
742
+ if (config.showValues !== false) {
743
+ const leafValues = cell.append("text").attr("class", "treemapValue").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", function(d) {
744
+ return (d.y1 - d.y0) / 2;
745
+ }).attr("style", (d) => {
746
+ const labelStyles = "text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:" + colorScaleLabel(d.data.name) + ";";
747
+ const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
748
+ return labelStyles + styles.labelStyles.replace("color:", "fill:");
749
+ }).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.value ? valueFormat(d.value) : "");
750
+ leafValues.each(function(d) {
751
+ const valueTextElement = select(this);
752
+ const parentCellNode = this.parentNode;
753
+ if (!parentCellNode) {
754
+ valueTextElement.style("display", "none");
755
+ return;
756
+ }
757
+ const labelElement = select(parentCellNode).select(".treemapLabel");
758
+ if (labelElement.empty() || labelElement.style("display") === "none") {
759
+ valueTextElement.style("display", "none");
760
+ return;
761
+ }
762
+ const finalLabelFontSize = parseFloat(labelElement.style("font-size"));
763
+ const originalValueFontSize = 28;
764
+ const valueScaleFactor = 0.6;
765
+ const minValueFontSize = 6;
766
+ const spacingBetweenLabelAndValue = 2;
767
+ const actualValueFontSize = Math.max(
768
+ minValueFontSize,
769
+ Math.min(originalValueFontSize, Math.round(finalLabelFontSize * valueScaleFactor))
770
+ );
771
+ valueTextElement.style("font-size", `${actualValueFontSize}px`);
772
+ const labelCenterY = (d.y1 - d.y0) / 2;
773
+ const valueTopActualY = labelCenterY + finalLabelFontSize / 2 + spacingBetweenLabelAndValue;
774
+ valueTextElement.attr("y", valueTopActualY);
775
+ const nodeWidth = d.x1 - d.x0;
776
+ const nodeTotalHeight = d.y1 - d.y0;
777
+ const cellBottomPadding = 4;
778
+ const maxValueBottomY = nodeTotalHeight - cellBottomPadding;
779
+ const availableWidthForValue = nodeWidth - 2 * 4;
780
+ if (valueTextElement.node().getComputedTextLength() > availableWidthForValue || valueTopActualY + actualValueFontSize > maxValueBottomY || actualValueFontSize < minValueFontSize) {
781
+ valueTextElement.style("display", "none");
782
+ } else {
783
+ valueTextElement.style("display", null);
784
+ }
785
+ });
786
+ }
787
+ const diagramPadding = config.diagramPadding ?? 8;
788
+ setupViewPortForSVG(svg, diagramPadding, "flowchart", config?.useMaxWidth || false);
789
+ }, "draw");
790
+ var getClasses = /* @__PURE__ */ __name(function(_text, diagramObj) {
791
+ return diagramObj.db.getClasses();
792
+ }, "getClasses");
793
+ var renderer = { draw, getClasses };
794
+ var defaultTreemapStyleOptions = {
795
+ sectionStrokeColor: "black",
796
+ sectionStrokeWidth: "1",
797
+ sectionFillColor: "#efefef",
798
+ leafStrokeColor: "black",
799
+ leafStrokeWidth: "1",
800
+ leafFillColor: "#efefef",
801
+ labelColor: "black",
802
+ labelFontSize: "12px",
803
+ valueFontSize: "10px",
804
+ valueColor: "black",
805
+ titleColor: "black",
806
+ titleFontSize: "14px"
807
+ };
808
+ var getStyles = /* @__PURE__ */ __name(({
809
+ treemap: treemap2
810
+ } = {}) => {
811
+ const options = cleanAndMerge(defaultTreemapStyleOptions, treemap2);
812
+ return `
813
+ .treemapNode.section {
814
+ stroke: ${options.sectionStrokeColor};
815
+ stroke-width: ${options.sectionStrokeWidth};
816
+ fill: ${options.sectionFillColor};
817
+ }
818
+ .treemapNode.leaf {
819
+ stroke: ${options.leafStrokeColor};
820
+ stroke-width: ${options.leafStrokeWidth};
821
+ fill: ${options.leafFillColor};
822
+ }
823
+ .treemapLabel {
824
+ fill: ${options.labelColor};
825
+ font-size: ${options.labelFontSize};
826
+ }
827
+ .treemapValue {
828
+ fill: ${options.valueColor};
829
+ font-size: ${options.valueFontSize};
830
+ }
831
+ .treemapTitle {
832
+ fill: ${options.titleColor};
833
+ font-size: ${options.titleFontSize};
834
+ }
835
+ `;
836
+ }, "getStyles");
837
+ var styles_default = getStyles;
838
+ var diagram = {
839
+ parser,
840
+ get db() {
841
+ return new TreeMapDB();
842
+ },
843
+ renderer,
844
+ styles: styles_default
845
+ };
846
+ export {
847
+ diagram
848
+ };
849
+ //# sourceMappingURL=diagram-PSM6KHXK-8w1WbeDi.js.map