egatari 0.6.17 → 0.6.19

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 (171) hide show
  1. package/CHANGELOG.md +68 -1
  2. package/README.ja.md +14 -13
  3. package/README.md +2 -1
  4. package/components.lock.json +153 -54
  5. package/components2.lock.json +1001 -1
  6. package/kit/build.mjs +1 -1
  7. package/kit/check-messages.mjs +9 -0
  8. package/kit/check.mjs +8 -0
  9. package/kit/core/bookmark.mjs +28 -0
  10. package/kit/core/build-core.mjs +5 -3
  11. package/kit/core/check-parity.mjs +6 -0
  12. package/kit/core/check-rules.mjs +4 -3
  13. package/kit/core/check-source.mjs +10 -1
  14. package/kit/core/checks.mjs +79 -0
  15. package/kit/core/find-replace.mjs +170 -0
  16. package/kit/core/format.mjs +4 -1
  17. package/kit/core/image-insert.mjs +197 -0
  18. package/kit/core/image-size.mjs +1 -1
  19. package/kit/core/layout-scan.mjs +1 -1
  20. package/kit/core/llm-fix.mjs +1 -1
  21. package/kit/core/llm-pack-assemble.mjs +40 -67
  22. package/kit/core/llm-pack-data.mjs +882 -52
  23. package/kit/core/llm-pack.mjs +6 -4
  24. package/kit/core/llm-request.mjs +2 -2
  25. package/kit/core/new-deck-pack.mjs +38 -44
  26. package/kit/core/new-deck.mjs +82 -74
  27. package/kit/core/part-labels.mjs +3 -0
  28. package/kit/core/portable.mjs +5 -2
  29. package/kit/core/purposes.mjs +9 -3
  30. package/kit/core/sample-info.mjs +17 -3
  31. package/kit/core/scorm.mjs +30 -6
  32. package/kit/core/script-unclosed.mjs +49 -0
  33. package/kit/core/slide-ops.mjs +27 -1
  34. package/kit/core/tate-mix.mjs +25 -0
  35. package/kit/core/template-text.mjs +2 -0
  36. package/kit/core/theme-derive.mjs +56 -17
  37. package/kit/core/theme-shapes.mjs +15 -1
  38. package/kit/deck.js +124 -6
  39. package/kit/instruction-version.json +1 -1
  40. package/kit/layouts.css +8 -0
  41. package/kit/llm-pack.mjs +5 -7
  42. package/kit/panes.js +17 -1
  43. package/kit/player.json +1 -1
  44. package/kit/player.lock.json +2 -2
  45. package/kit/presenter.js +36 -4
  46. package/kit/tools.js +54 -2
  47. package/kit/track.js +46 -5
  48. package/package.json +1 -1
  49. package/server/editor-ui.js +21 -1
  50. package/vendor/components/CATALOG.md +25 -22
  51. package/vendor/components/sha256/038f9d32c89c8212ab25d6e3180023b6fe024a53053ab2ef1443ecab92e3ce43/index.js +205 -0
  52. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/README.en.md +44 -0
  53. package/vendor/components/sha256/07479cb6e5194a01b2a8a9029f3646060f0dbb673f2737d2132738af2eb379e5/index.js +306 -0
  54. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/README.en.md +54 -0
  55. package/vendor/components/sha256/077678d8b14a8065c4f74a9fe1669728c68a0f763bfdca18b304f5c3d863632a/index.js +470 -0
  56. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/README.en.md +23 -0
  57. package/vendor/components/sha256/0840322bf51eeb3c8188ce21ad70af17c13974ac0151065a39c430a3813ee07f/index.js +289 -0
  58. package/vendor/components/sha256/0c25d49d23529879054737aa181951519fe585c4728fd505e0e3c8869953eac7/index.js +934 -0
  59. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/LICENSE-strokesvg.txt +115 -0
  60. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/OFL.txt +93 -0
  61. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/index.js +755 -0
  62. package/vendor/components/sha256/0dd302b82925f35743a893d5c271898ada3659aa0de2d3249ef45936aad10ae0/strokes-CHANGES.md +20 -0
  63. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/README.en.md +25 -0
  64. package/vendor/components/sha256/0e9e92df8d70eb6d9fcf10916c361769c7cd37baacece8d7eb96bbbc7fbcf942/index.js +317 -0
  65. package/vendor/components/sha256/12ef6a11055407f5cddc40154a49cf2737b0786429fe0fcc94ee1d8245597b40/index.js +244 -0
  66. package/vendor/components/sha256/13c9ce43396b2f5693ce430a924dae4ddcd1e8a4ad0c9b9e724ff52acb874d0c/index.js +354 -0
  67. package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/README.en.md +34 -0
  68. package/vendor/components/sha256/15306d854d67d52ca2b1d66135f0d3296882e6b21fd85c029399b8077c8a7f9d/index.js +398 -0
  69. package/vendor/components/sha256/1a0f21def0efbbdef64461cafa40f3883bc7f7122adf79d01f09ca4a245e5dcb/index.js +465 -0
  70. package/vendor/components/sha256/208175d05b37d326855fad792b10137f785e5d05d91a2cde119d0dbd69d2ed98/index.js +100 -0
  71. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/README.en.md +34 -0
  72. package/vendor/components/sha256/218d88998b70f0732c18d91ccc238b2d63f6b0aaa483883b83685a25468f214a/index.js +246 -0
  73. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/README.en.md +24 -0
  74. package/vendor/components/sha256/2579bcb46b6525902763cd15a2e08fc5ebd9a2695cdaba63438e5b47907a47e0/index.js +554 -0
  75. package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/README.en.md +23 -0
  76. package/vendor/components/sha256/277ac772315f93737a094cd0f0842726f2435d352d9a90822aebfe0d5d7e79a1/index.js +294 -0
  77. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/README.en.md +28 -0
  78. package/vendor/components/sha256/2787e410e533e4ad48b0a3c2b652579cf5797f9c51fcf32f5478212a7acef95f/index.js +214 -0
  79. package/vendor/components/sha256/2a011338d0fc3c77e102eaa57cde2b6e3726bc279f133174b0b8c9a654263cbc/index.js +824 -0
  80. package/vendor/components/sha256/2fce5ab0c31dca0aa1586a2c69237870a9cce46c0bc6ab7392c27968d016bd15/index.js +75 -0
  81. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/README.en.md +23 -0
  82. package/vendor/components/sha256/3417efe4722f569690563d9abcea8b144db2f8fa97b83cf0118fb3a34cd4cb2b/index.js +150 -0
  83. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/README.en.md +18 -0
  84. package/vendor/components/sha256/3a7962fa87c670447eed54aca08604ef03cd26bf2c334b4667190060e6a17965/index.js +279 -0
  85. package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/README.en.md +47 -0
  86. package/vendor/components/sha256/3be5f64deb1951327b614b29a9b632878fab362687c76e3f48f3af1d1ebbb1cf/index.js +223 -0
  87. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/README.en.md +42 -0
  88. package/vendor/components/sha256/42450c6b36404d66641568f6d6f55e42a4a036d4d9cdf308f709464913b32fe9/index.js +272 -0
  89. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/README.en.md +30 -0
  90. package/vendor/components/sha256/45cea6c1abfb3467e3e3dbe7fec58647716999a0c39cf7163531ae389f898d29/index.js +305 -0
  91. package/vendor/components/sha256/4c8cae404d551a1bb021e8345af5aa45d4f412f13497aa84b142f11a29a365dc/index.js +124 -0
  92. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/README.en.md +23 -0
  93. package/vendor/components/sha256/5521b5b40a43c48c5ae5a50ce87afb3d47bb23b133b16841086d8322364cdd5e/index.js +120 -0
  94. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/README.en.md +18 -0
  95. package/vendor/components/sha256/5fe30fd7a84b937a1325d8af2b8e437211efae82ab46d5a433bc4ef07bcaef11/index.js +243 -0
  96. package/vendor/components/sha256/631f4c4b90c9a41c0f26c9600d5cf2d6447251d04a20f08f48a85aeb4cb0f6fb/index.js +107 -0
  97. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/README.en.md +31 -0
  98. package/vendor/components/sha256/6749f44ed6476a05d4e3026373c188a0e1a19b77a5836579813f62a1477ac35e/index.js +271 -0
  99. package/vendor/components/sha256/701f1deef79fe05eeb18e1119e5a5c4d60a9dfe265e93a4dff79223bc598dbf0/index.js +521 -0
  100. package/vendor/components/sha256/711cf58fa946c9c0abc953b2f695d02bf5a5a7f73851b09f834e894baf88be38/index.js +122 -0
  101. package/vendor/components/sha256/728576c57a5ccb39531ad4cb8074fce95480f01603a77dbf57dca0e52199f7c4/index.js +37 -0
  102. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/README.en.md +18 -0
  103. package/vendor/components/sha256/73edc74a2dc4a63b717106c1c1572967b6d306270574e9635d032de16c8ada72/index.js +382 -0
  104. package/vendor/components/sha256/76bdb63c3e5e14fbb4816bc9f235490817bb5d7be990a826f5077aa08226702c/index.js +162 -0
  105. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/README.en.md +51 -0
  106. package/vendor/components/sha256/7a5adf73fc053b9f2ca56643b5683b42589edb0f63c845ecb7ae7e6b87eccc30/index.js +230 -0
  107. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/README.en.md +26 -0
  108. package/vendor/components/sha256/7ab483e7fb05f646b062340d70f2749d070b4f64fed7acc0b8a7754d9ef9fded/index.js +322 -0
  109. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/README.en.md +18 -0
  110. package/vendor/components/sha256/7af6e5e6dffb618b39f27d883c691ca128f3af06040ee505e75c79c678bfdcfe/index.js +103 -0
  111. package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/README.en.md +44 -0
  112. package/vendor/components/sha256/7c7b0373cfd38fd5ecb4169021e0b908f0a17be1a29b14f85dd89fdb92e7bf81/index.js +306 -0
  113. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ABCJS-ADAPTER.md +101 -0
  114. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/LICENSE-abcjs.txt +21 -0
  115. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/chords.json +89 -0
  116. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/doremi.json +261 -0
  117. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/extras.json +192 -0
  118. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/kaeru.json +521 -0
  119. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/rhythm.json +248 -0
  120. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/fixtures/ties.json +360 -0
  121. package/vendor/components/sha256/7dea2c3728b85122b04515aa06ab198657529e7cd101b9ab34d4ecb2905ce94e/index.js +508 -0
  122. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/README.en.md +22 -0
  123. package/vendor/components/sha256/832556ea9c82c292a3ba9e1b332f2405c5c2f969ff8157c91ed80226ec8ac62e/index.js +145 -0
  124. package/vendor/components/sha256/8a4b6dce84d7a69aaafeb75c1c572fe7904fd49e3169c1c85851ccaeae2a7b11/index.js +41 -0
  125. package/vendor/components/sha256/8bb511cb90902bc7721e59ca08685b26adbf33539e36a4a45172485d6d3d455b/index.js +250 -0
  126. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/README.en.md +21 -0
  127. package/vendor/components/sha256/8db9c936c36b79b9e3b2be37639487b15502a6937f411ed714621a8091437e9b/index.js +108 -0
  128. package/vendor/components/sha256/8e5e90c90cb6b06a790b0420e43d79d7da663f1cc19ff06d381ec849b4a8fc57/index.js +312 -0
  129. package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/README.en.md +34 -0
  130. package/vendor/components/sha256/939bdae590ebed3d182b0c9940a35b6c03872505bfa242341990a81cae02fd06/index.js +397 -0
  131. package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/README.en.md +44 -0
  132. package/vendor/components/sha256/9c5dd0bc0c3279c5f0fea3fdb9d0735870880aef96e8bbf9ecdd77dff0f5ddc8/index.js +551 -0
  133. package/vendor/components/sha256/a1c2b2fa06e4229815ab82a9202c266ec887a67632a175854c7d136a92389ca3/index.js +69 -0
  134. package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/README.en.md +18 -0
  135. package/vendor/components/sha256/a5b032657720d3beb64f0b3699954e13b0eb985f36161b9ae046c83fd6048ff5/index.js +382 -0
  136. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/README.en.md +38 -0
  137. package/vendor/components/sha256/a7c4282db79d46557bdbaf84ca519606dc46f3c23455db4a26f663453f85813c/index.js +414 -0
  138. package/vendor/components/sha256/aac2f8a23cb1b606e9635061cb288f006588c80a7258540cae846ae677f55ff5/index.js +238 -0
  139. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/README.en.md +45 -0
  140. package/vendor/components/sha256/ace7e82e866b577ad42bbc4b64e11bae18982e3236aadceb6c2e6c20f41234cf/index.js +211 -0
  141. package/vendor/components/sha256/aeb0b9b5991a5c1df7191c397780a699f2c7310123ca210a58486c0a23e44006/index.js +342 -0
  142. package/vendor/components/sha256/af3355efd6739a56c6cb53990100f41703361c475c123b9b2762421c68509036/index.js +315 -0
  143. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/LICENSE-tabler.txt +21 -0
  144. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/index.js +4868 -0
  145. package/vendor/components/sha256/b10183a66b58b827a1410cf8b0117af567647684464d5777529dc66f0cea343a/names.txt +4808 -0
  146. package/vendor/components/sha256/b348ea64cc19632df96a91dfd7c435e4a62095aede72b504d03537be70d6d930/index.js +606 -0
  147. package/vendor/components/sha256/b53bfa03d1e9feb3cb492f440bf9d100c96eb4fe6b76c42b512a56e9158829cd/index.js +351 -0
  148. package/vendor/components/sha256/b9443e1cdac4850b1ead9f8449a3061678bbb77fbc53eb9b23d01e1cf50750c3/index.js +619 -0
  149. package/vendor/components/sha256/bc1e2a02c959ac203819d03c0d25b3776a6a9a4290aae860b26cbbe3d29e876d/index.js +268 -0
  150. package/vendor/components/sha256/beeb180c0e2250bb04490b092c0a235cae47fca2ed1de2d9ef078a5c14b1a963/index.js +429 -0
  151. package/vendor/components/sha256/c5fd7713e55e96d75824a21146c0251896d7d9dd028b4d169191433135a97981/index.js +200 -0
  152. package/vendor/components/sha256/c61987e9994940fc668ed8a010e575ee52027b54ed9c5dd1cc9fdf67649092b3/index.js +404 -0
  153. package/vendor/components/sha256/ccc8bfe174b6903ec254dfef4f5d1c614271ea39963649add7fcb8d83c081eba/index.js +278 -0
  154. package/vendor/components/sha256/da267bc65fde0a9279127d5a82f6c253ad74984da6fb11391f00604ad9ffe80d/index.js +93 -0
  155. package/vendor/components/sha256/dea36cd7010991a572ef394ee32b5e17564aeff09d3ec4ed3820d7e43c9a58be/index.js +484 -0
  156. package/vendor/components/sha256/df3fdb2aed487d4f6e60a8abab1fe0d1e9fa2a4193fd162edf3c384ea8db5a1b/index.js +180 -0
  157. package/vendor/components/sha256/e27d517f39eb554c7a9ecea7b59fcf1d347c4deeb3fe2250797aa233bfb7e2b0/index.js +747 -0
  158. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/README.en.md +20 -0
  159. package/vendor/components/sha256/e31f6b058503f7980597c89b3e964c512ee08de7cba3fa99904d499abbb5d0e8/index.js +310 -0
  160. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/README.en.md +30 -0
  161. package/vendor/components/sha256/f4100076a37dbde6046d85969d651feffc925bd984ffe9f333ea9bd2b6816918/index.js +192 -0
  162. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/README.en.md +24 -0
  163. package/vendor/components/sha256/fa6442fa3c5082cf161c29308fe0ecbd85fa33e8e4bad08c12e7961b46b1365b/index.js +214 -0
  164. package/vendor/components-2/manifest-2.16.0.json +2919 -0
  165. package/vendor/components-2/manifest-2.17.0.json +2852 -0
  166. package/vendor/components-2/manifest-2.18.0.json +3182 -0
  167. package/vendor/components-2/manifest-2.20.0.json +3217 -0
  168. package/vendor/components-2/manifest-2.21.0.json +3220 -0
  169. package/vendor/egatari-spec/SOURCE.json +2 -2
  170. package/vendor/egatari-spec/schema/deck-meta.schema.json +3 -0
  171. package/vendor/egatari-spec/schema/egatari-metadata.schema.json +6 -0
@@ -0,0 +1,554 @@
1
+ // m-network:グラフの探索と巡回路。頂点(作者の座標)と辺(重み・向き)を描き、ステップごとに今の頂点・候補・訪れた頂点を
2
+ // 塗り分け、選んだ辺を 1 本ずつ引き、経路の長さなどの合計を出す。数値と状態は、探索を実際に走らせたスクリプトの出力を書く
3
+ // <m-network style="height:480px"><script type="application/json">
4
+ // {"nodes": [{"id": "A", "x": 0, "y": 0}, {"id": "B", "x": 4, "y": 0}, {"id": "C", "x": 2, "y": 3}],
5
+ // "edges": [{"from": "A", "to": "B", "w": 4}, {"from": "A", "to": "C", "w": 3}, {"from": "B", "to": "C", "w": 2}],
6
+ // "frontierKind": "queue", "total": {"label": "経路の長さ"},
7
+ // "steps": [{"current": "A", "visited": ["A"], "frontier": ["B", "C"], "parent": {"B": "A", "C": "A"}},
8
+ // {"current": "C", "visited": ["A", "C"], "frontier": ["B"], "take": [["A", "C"]], "total": 3}]}
9
+ // (JSON の終わり)</m-network>
10
+ // 座標は作者の単位のまま(y は下向き)。パーツが縦横の比を保って枠に収める。
11
+ // ステップの状態:current・visited・frontier・total は書いたステップからその値(書かなければ前のステップのまま。current の null で消す)。
12
+ // parent は前のステップに足していく(null で消す)。take と drop は選んだ辺の集まりを前のステップから増減する。
13
+ // 状態はステップ 1..k だけから決まる((k, t) だけで画面が決まる)。
14
+ // 色:今の頂点 --emph(太い輪)、候補 --accent2(点線の輪と下の帯)、訪れた頂点 --muted の塗り、選んだ辺と探索の木 --term、ほかの辺 --line。
15
+ // 確かめること(data):知らない id、ない辺の take(complete のときを除く)、選んでいない辺の drop、
16
+ // 選んだ辺がすべて重みを持つときに total が重みの和と合わないこと(total.check: false で確かめない)
17
+ egatariParts.define({name: "network", version: "2.2.0", requires: {base: "1.3.0"}, element: "m-network"}, function(deps){
18
+ "use strict";
19
+ var base = deps.base;
20
+ var ID = {type: "string"};
21
+ var PAIR = {type: "array", minItems: 2, maxItems: 2, items: ID};
22
+ var KIND = {
23
+ queue: {ja: "待ち行列(左が先頭)", en: "Queue (front on the left)"},
24
+ stack: {ja: "スタック(右が上)", en: "Stack (top on the right)"},
25
+ pq: {ja: "優先度付きキュー", en: "Priority queue"},
26
+ set: {ja: "候補", en: "Frontier"},
27
+ };
28
+ return class extends base.MotionElement {
29
+ static partName = "network";
30
+ static preview = "none";
31
+ static shape = {
32
+ schema: {type: "object", additionalProperties: false, required: ["steps"], anyOf: [{required: ["nodes"]}, {required: ["layout"]}], properties: {
33
+ directed: {type: "boolean"},
34
+ complete: {type: "boolean"},
35
+ stochastic: {type: "boolean"},
36
+ frontierKind: {type: "string", enum: ["queue", "stack", "pq", "set"]},
37
+ total: {type: "object", additionalProperties: false, properties: {label: {type: "string"}, unit: {type: "string"}, digits: {type: "integer"}, check: {type: "boolean"}, of: {type: "string", enum: ["path", "taken"]}}},
38
+ nodes: {type: "array", minItems: 1, maxItems: 24, items: {type: "object", additionalProperties: false, required: ["id", "x", "y"], properties: {
39
+ id: ID, x: {type: "number"}, y: {type: "number"}, label: {type: "string"}, shape: {type: "string", enum: ["circle", "ellipse", "box"]}, observed: {type: "boolean"}}}},
40
+ edges: {type: "array", maxItems: 60, items: {type: "object", additionalProperties: false, required: ["from", "to"], properties: {
41
+ from: ID, to: ID, w: {type: "number"}, bi: {type: "boolean"}}}},
42
+ plates: {type: "array", maxItems: 4, items: {type: "object", additionalProperties: false, required: ["nodes"], properties: {nodes: {type: "array", minItems: 1, items: ID}, label: {type: "string"}}}},
43
+ layout: {type: "string", enum: ["trellis"]},
44
+ states: {type: "array", minItems: 1, maxItems: 6, items: ID},
45
+ T: {type: "integer"},
46
+ transitions: {type: "array", maxItems: 36, items: {type: "object", additionalProperties: false, required: ["from", "to"], properties: {from: ID, to: ID, w: {type: "number"}}}},
47
+ steps: {type: "array", minItems: 1, maxItems: 40, items: {type: "object", additionalProperties: false, properties: {
48
+ current: {type: ["string", "null"]},
49
+ visited: {type: "array", items: ID},
50
+ frontier: {type: "array", items: {type: ["string", "array"]}},
51
+ parent: {type: "object"},
52
+ take: {type: "array", items: PAIR},
53
+ drop: {type: "array", items: PAIR},
54
+ total: {type: "number"},
55
+ note: {type: "string"}}}}}},
56
+ example: {nodes: [{id: "A", x: 0, y: 0}, {id: "B", x: 4, y: 0}], edges: [{from: "A", to: "B", w: 4}],
57
+ steps: [{current: "A", frontier: ["B"]}, {current: "B", take: [["A", "B"]], total: 4}]},
58
+ };
59
+ static props = {
60
+ dur: {type: "number", default: 0.6, doc: "1 本の辺を引く秒数(頂点の色の変化はその半分)"},
61
+ size: {type: "number", default: 24, doc: "字の大きさ(px、24 以上)"},
62
+ weights: {type: "bool", default: true, doc: "辺の重みを書く"},
63
+ };
64
+ get steps(){
65
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
66
+ return ((this.data || {}).steps || []).length;
67
+ }
68
+ // 書いたデータ。layout: "trellis"(隠れマルコフモデルの格子)なら、状態 × 時刻の頂点(id は "状態@時刻")と、隣の時刻への遷移の辺に広げる
69
+ get net(){
70
+ if (this._net !== undefined) return this._net;
71
+ var d = this.data || {};
72
+ if (d.layout !== "trellis") return (this._net = d);
73
+ var S = d.states || [], T = Math.max(1, Math.min(8, d.T || 1)), nodes = [], edges = [];
74
+ for (var t = 1; t <= T; t++) S.forEach(function(s, i){ nodes.push({id: s + "@" + t, x: (t - 1) * 3, y: i * 1.6, label: s}); });
75
+ for (var t2 = 1; t2 < T; t2++) (d.transitions || []).forEach(function(e){ edges.push({from: e.from + "@" + t2, to: e.to + "@" + (t2 + 1), w: e.w}); });
76
+ return (this._net = Object.assign({}, d, {nodes: nodes, edges: edges, directed: true, trellisT: T}));
77
+ }
78
+ // 辺の鍵:向きのないグラフでは [A, B] と [B, A] を同じ辺にする
79
+ key(a, b){ return this.directed || a < b ? a + "\u0000" + b : b + "\u0000" + a; }
80
+ // ステップ 0..N の状態と、確かめた結果。データだけから決める(mount の前にも steps が要る)
81
+ plan(){
82
+ if (this._plan) return this._plan;
83
+ var self = this, d = this.net || {}, bad = [];
84
+ if (!(d.nodes || []).length) bad.push("nodes (or layout: \"trellis\" with states and T) are needed");
85
+ if (d.layout === "trellis" && !(this.data.states || []).length) bad.push("layout: \"trellis\" needs states");
86
+ (d.plates || []).forEach(function(pt, i){ (pt.nodes || []).forEach(function(id){ if (!(d.nodes || []).some(function(n){ return n.id === id; })) bad.push("plates[" + i + "]: unknown node \"" + id + "\""); }); });
87
+ this.directed = !!d.directed;
88
+ var ids = {}, edges = {};
89
+ (d.nodes || []).forEach(function(n){ if (ids[n.id]) bad.push("node id \"" + n.id + "\" is used twice"); ids[n.id] = n; });
90
+ (d.edges || []).forEach(function(e, i){
91
+ if (!ids[e.from] || !ids[e.to]){ bad.push("edges[" + i + "] joins an unknown node (" + (ids[e.from] ? e.to : e.from) + ")"); return; }
92
+ edges[self.key(e.from, e.to)] = e;
93
+ });
94
+ // stochastic:向きのあるグラフで、各頂点から出る辺の w の和が 1(推移確率)
95
+ if (d.stochastic){
96
+ if (!this.directed) bad.push("stochastic needs directed: true");
97
+ else Object.keys(ids).forEach(function(id){
98
+ var out = Object.keys(edges).map(function(k){ return edges[k]; }).filter(function(e){ return e.from === id; });
99
+ if (!out.length) return;
100
+ if (out.some(function(e){ return typeof e.w !== "number"; })){ bad.push("stochastic: an edge from " + id + " has no w"); return; }
101
+ var sum = out.reduce(function(a, e){ return a + e.w; }, 0);
102
+ if (Math.abs(sum - 1) > 1e-6) bad.push("stochastic: the edges from " + id + " sum to " + +sum.toFixed(9) + ", not 1");
103
+ });
104
+ }
105
+ var known = function(id, where){ if (ids[id]) return true; bad.push(where + ": unknown node \"" + id + "\""); return false; };
106
+ var check = !(d.total && d.total.check === false);
107
+ var st = {current: null, visited: [], frontier: [], parent: {}, chosen: {}, total: undefined, note: "", take: [], drop: []};
108
+ var states = [st];
109
+ (d.steps || []).forEach(function(s, i){
110
+ var w = "steps[" + i + "]", n = {current: st.current, visited: st.visited, frontier: st.frontier, parent: Object.assign({}, st.parent),
111
+ chosen: Object.assign({}, st.chosen), total: st.total, note: s.note || "", take: [], drop: []};
112
+ if (s.current !== undefined) n.current = s.current === null || known(s.current, w + ".current") ? s.current : null;
113
+ if (s.visited) n.visited = s.visited.filter(function(id){ return known(id, w + ".visited"); });
114
+ if (s.frontier) n.frontier = s.frontier.map(function(f){
115
+ var id = Array.isArray(f) ? f[0] : f;
116
+ if (typeof id !== "string" || !known(id, w + ".frontier")) return null;
117
+ return {id: id, key: Array.isArray(f) && f.length > 1 ? f[1] : undefined};
118
+ }).filter(Boolean);
119
+ if (s.parent) Object.keys(s.parent).forEach(function(c){
120
+ var p = s.parent[c];
121
+ if (!known(c, w + ".parent")) return;
122
+ if (p === null){ delete n.parent[c]; return; }
123
+ if (typeof p === "string" && known(p, w + ".parent." + c)) n.parent[c] = p;
124
+ });
125
+ (s.drop || []).forEach(function(pr){
126
+ var k = self.key(pr[0], pr[1]);
127
+ if (!n.chosen[k]){ bad.push(w + ".drop: " + pr[0] + "–" + pr[1] + " was not chosen"); return; }
128
+ delete n.chosen[k]; n.drop.push(k);
129
+ });
130
+ (s.take || []).forEach(function(pr){
131
+ if (!known(pr[0], w + ".take") || !known(pr[1], w + ".take")) return;
132
+ var k = self.key(pr[0], pr[1]);
133
+ if (!d.complete && !edges[k]){ bad.push(w + ".take: there is no edge " + pr[0] + (self.directed ? "→" : "–") + pr[1]); return; }
134
+ n.chosen[k] = [pr[0], pr[1]]; n.take.push({k: k, a: pr[0], b: pr[1]});
135
+ });
136
+ if (s.total !== undefined){
137
+ n.total = s.total;
138
+ // 何の合計か:total.of、なければ parent があるときは出発点から current までの道のり(探索)、ないときは選んだ辺の w の和(経路・巡回路)
139
+ var of = d.total && d.total.of ? d.total.of : Object.keys(n.parent).length ? "path" : "taken", ws = null, what = "";
140
+ if (of === "path" && n.current){
141
+ ws = []; var c = n.current, seen = {};
142
+ while (n.parent[c] !== undefined && !seen[c]){ seen[c] = 1; var e = edges[self.key(n.parent[c], c)]; if (!e || typeof e.w !== "number"){ ws = null; break; } ws.push(e.w); c = n.parent[c]; }
143
+ what = "the path to " + n.current + " along parent";
144
+ } else if (of === "taken"){
145
+ var ks = Object.keys(n.chosen);
146
+ ws = ks.length && ks.every(function(k){ return edges[k] && typeof edges[k].w === "number"; }) ? ks.map(function(k){ return edges[k].w; }) : null;
147
+ what = "the chosen edges' weights";
148
+ }
149
+ if (check && ws && ws.length){
150
+ var sum = ws.reduce(function(a, x){ return a + x; }, 0);
151
+ // 見せている桁の分だけ許す:辺の数 × ½·10^−d(d は w の小数の桁の最大)
152
+ var dec = ws.reduce(function(m, x){ var f = String(x).split(".")[1]; return Math.max(m, f ? f.length : 0); }, 0);
153
+ // total が w より細かい桁で書かれているときだけ(w を丸めて書いたとき)。同じ桁なら正確に合うはず
154
+ var decT = (String(s.total).split(".")[1] || "").length, exact = 1e-9 * Math.max(1, Math.abs(sum));
155
+ var tol = decT > dec ? Math.max(exact, ws.length * 0.5 * Math.pow(10, -dec) + 1e-12) : exact;
156
+ if (Math.abs(sum - s.total) > tol)
157
+ bad.push(w + ".total is " + s.total + " but " + what + " sums to " + +sum.toFixed(9) + " (total.of: \"path\" or \"taken\"; total.check: false if the total is something else)");
158
+ }
159
+ }
160
+ states.push(n); st = n;
161
+ });
162
+ var digits = d.total && d.total.digits !== undefined ? d.total.digits : states.reduce(function(m, s){
163
+ if (typeof s.total !== "number") return m;
164
+ var x = String(s.total).split(".")[1];
165
+ return Math.max(m, x ? Math.min(4, x.length) : 0);
166
+ }, 0);
167
+ return (this._plan = {ids: ids, edges: edges, states: states, bad: bad, digits: digits,
168
+ hasFrontier: states.some(function(s){ return s.frontier.length; }), hasTotal: states.some(function(s){ return typeof s.total === "number"; }),
169
+ hasNote: states.some(function(s){ return s.note; })});
170
+ }
171
+ mount(ctx){
172
+ var P = this.props, D = base, self = this, pl = this.plan(), d = this.net, ja = /^ja\b/i.test(ctx.lang || "ja");
173
+ this.ja = ja;
174
+ this.style.display = "block"; this.style.position = "relative";
175
+ var W = this.clientWidth, H = this.clientHeight;
176
+ var svg = this.svg = D.el("svg", {viewBox: "0 0 " + W + " " + H, width: W, height: H, "aria-hidden": "true", style: "display:block;overflow:visible"}, this);
177
+ if (!(P.dur >= 0)){ ctx.report("attr", "[network] dur must be ≥ 0 (got " + this.getAttribute("dur") + "); using 0.6"); P.dur = 0.6; }
178
+ if (!(P.size >= 24)){ ctx.report("attr", "[network] size must be ≥ 24 (got " + this.getAttribute("size") + "); using 24"); P.size = 24; }
179
+ pl.bad.forEach(function(m){ ctx.report("data", "[network] " + m); });
180
+ var fs = P.size, tw = function(s){ return D.textWidth(s, fs, {font: self}); };
181
+ // mtext の記法(*x*_i など)があるときだけ mtext で書く(ない字はこれまでどおり)。幅は記号を除いて測る
182
+ var MARK = /\*[^*\s][^*]*\*|[_^]\S/, plain = function(s){ return s.replace(/\*([^*\s][^*]*)\*/g, "$1").replace(/[_^](\S)/g, "$1"); };
183
+ this.MARK = MARK;
184
+ // 下の帯:1 段目は候補の並びと合計、2 段目はステップの説明
185
+ var rowH = Math.ceil(fs * 1.75), rows = (pl.hasFrontier || pl.hasTotal ? 1 : 0) + (pl.hasNote ? 1 : 0);
186
+ var band = rows ? rows * rowH + 10 : 0;
187
+ // 頂点の大きさ:字の幅 + 余白。短い名前は円、長い名前は角の丸い箱
188
+ var nh = Math.ceil(fs * 1.75), nodes = d.nodes.map(function(n){
189
+ var lab = n.label !== undefined ? n.label : n.id;
190
+ var sh = n.shape || "circle", lw = tw(MARK.test(lab) ? plain(lab) : lab);
191
+ return {n: n, lab: lab, sh: sh, w: sh === "ellipse" ? Math.max(Math.ceil(nh * 1.5), Math.ceil(lw) + 36) : Math.max(nh, Math.ceil(lw) + 24), h: nh};
192
+ });
193
+ var pad = 8, gx0 = pad, gx1 = W - pad, gy0 = pad, gy1 = H - band - pad;
194
+ var hasLoop = Object.keys(pl.edges).some(function(k){ return pl.edges[k].from === pl.edges[k].to; });
195
+ var plateM = (d.plates || []).length ? Math.ceil(fs * 1.3) + 18 : 0, timeRow = d.trellisT ? Math.ceil(fs * 1.5) : 0;
196
+ gy0 += timeRow;
197
+ var mw = Math.max.apply(null, nodes.map(function(o){ return o.w; })) / 2 + 6 + (hasLoop ? nh * 1.6 : 0) + plateM, mh = nh / 2 + 6 + (hasLoop ? nh * 1.6 : 0) + plateM;
198
+ var xs = d.nodes.map(function(n){ return n.x; }), ys = d.nodes.map(function(n){ return n.y; });
199
+ var x0 = Math.min.apply(null, xs), x1 = Math.max.apply(null, xs), y0 = Math.min.apply(null, ys), y1 = Math.max.apply(null, ys);
200
+ var aw = gx1 - gx0 - 2 * mw, ah = gy1 - gy0 - 2 * mh;
201
+ if (aw < nh || ah < nh){
202
+ ctx.report("size", "[network] the element (" + W + "×" + H + " px) is too small for the graph; give it a size, e.g. style=\"height:480px\"");
203
+ aw = Math.max(aw, 1); ah = Math.max(ah, 1);
204
+ }
205
+ var sc = Math.min(x1 > x0 ? aw / (x1 - x0) : Infinity, y1 > y0 ? ah / (y1 - y0) : Infinity);
206
+ if (!isFinite(sc)) sc = 1;
207
+ var ox = gx0 + mw + (aw - (x1 - x0) * sc) / 2, oy = gy0 + mh + (ah - (y1 - y0) * sc) / 2;
208
+ var at = this.at = {};
209
+ nodes.forEach(function(o){ o.x = ox + (o.n.x - x0) * sc; o.y = oy + (o.n.y - y0) * sc; at[o.n.id] = o; });
210
+ // 頂点どうしの重なり
211
+ var gap = 6;
212
+ for (var i = 0; i < nodes.length; i++) for (var j = i + 1; j < nodes.length; j++){
213
+ var a = nodes[i], b = nodes[j];
214
+ if (Math.abs(a.x - b.x) < (a.w + b.w) / 2 + gap && Math.abs(a.y - b.y) < (a.h + b.h) / 2 + gap){
215
+ var need = Math.max(((a.w + b.w) / 2 + gap) / Math.max(1e-9, Math.abs(a.n.x - b.n.x) || 1e-9), ((a.h + b.h) / 2 + gap) / Math.max(1e-9, Math.abs(a.n.y - b.n.y) || 1e-9));
216
+ ctx.report("layout", "[network] nodes " + a.n.id + " and " + b.n.id + " overlap at this size; move them apart (they need about " + Math.ceil(Math.min(need, 1e6) / sc * 100) + "% of their distance) or make the element larger");
217
+ }
218
+ }
219
+ // 辺の形:点の列(頂点の縁から縁まで)。直線、向きの逆の辺もあるときの弧、自己ループ
220
+ var cutAt = function(o, ux, uy){
221
+ if (o.sh === "ellipse") return 1 / Math.sqrt(Math.pow(ux / (o.w / 2), 2) + Math.pow(uy / (o.h / 2), 2));
222
+ if (o.w <= o.h + 0.5 && o.sh !== "box") return o.h / 2;
223
+ var tx = Math.abs(ux) > 1e-9 ? (o.w / 2) / Math.abs(ux) : Infinity, ty = Math.abs(uy) > 1e-9 ? (o.h / 2) / Math.abs(uy) : Infinity;
224
+ return Math.min(tx, ty);
225
+ };
226
+ var rim = function(o, ang){ var ux = Math.cos(ang), uy = Math.sin(ang), c = cutAt(o, ux, uy); return {x: o.x + ux * c, y: o.y + uy * c}; };
227
+ var dirTo = function(o, x, y){ return Math.atan2(y - o.y, x - o.x); };
228
+ // 自己ループの向き:ほかの辺からいちばん離れ、枠の中に収まる向き(上から時計回りに 8 方向)
229
+ var loopExt = nh * 1.25, loopAng = {};
230
+ Object.keys(pl.edges).forEach(function(k){
231
+ var e = pl.edges[k];
232
+ if (e.from !== e.to) return;
233
+ var o = at[e.from], used = [];
234
+ Object.keys(pl.edges).forEach(function(k2){
235
+ var f = pl.edges[k2];
236
+ if (f.from === f.to) return;
237
+ if (f.from === e.from) used.push(dirTo(o, at[f.to].x, at[f.to].y));
238
+ if (f.to === e.from) used.push(dirTo(o, at[f.from].x, at[f.from].y));
239
+ });
240
+ var best = null, bestScore = -1;
241
+ for (var q = 0; q < 8; q++){
242
+ var ang = -Math.PI / 2 + q * Math.PI / 4, r = rim(o, ang), ax = r.x + Math.cos(ang) * loopExt, ay = r.y + Math.sin(ang) * loopExt;
243
+ var fits = ax > nh * 0.5 && ax < W - nh * 0.5 && ay > nh * 0.5 && ay < H - band - nh * 0.5;
244
+ var gapMin = used.reduce(function(m, u){ var dd = Math.abs(((ang - u) % (2 * Math.PI) + 3 * Math.PI) % (2 * Math.PI) - Math.PI); return Math.min(m, dd); }, Math.PI);
245
+ var score = gapMin + (fits ? 10 : 0);
246
+ if (score > bestScore + 1e-9){ bestScore = score; best = ang; }
247
+ }
248
+ loopAng[e.from] = best;
249
+ });
250
+ var geoms = {};
251
+ var geom = this.geom = function(a, b){
252
+ var gk = a + "\u0000" + b;
253
+ if (geoms[gk]) return geoms[gk];
254
+ var A = at[a], B = at[b], pts = [];
255
+ var bez = function(p0, p1, p2, p3){
256
+ for (var i = 0; i <= 24; i++){
257
+ var t = i / 24, u = 1 - t;
258
+ pts.push(p3 ? {x: u * u * u * p0.x + 3 * u * u * t * p1.x + 3 * u * t * t * p2.x + t * t * t * p3.x, y: u * u * u * p0.y + 3 * u * u * t * p1.y + 3 * u * t * t * p2.y + t * t * t * p3.y}
259
+ : {x: u * u * p0.x + 2 * u * t * p1.x + t * t * p2.x, y: u * u * p0.y + 2 * u * t * p1.y + t * t * p2.y});
260
+ }
261
+ };
262
+ if (a === b){
263
+ var th = loopAng[a] !== undefined ? loopAng[a] : -Math.PI / 2, sp = 0.5, r0 = rim(A, th - sp), r1 = rim(A, th + sp);
264
+ var c0 = {x: r0.x + Math.cos(th - sp * 1.4) * loopExt * 1.3, y: r0.y + Math.sin(th - sp * 1.4) * loopExt * 1.3};
265
+ var c1 = {x: r1.x + Math.cos(th + sp * 1.4) * loopExt * 1.3, y: r1.y + Math.sin(th + sp * 1.4) * loopExt * 1.3};
266
+ bez(r0, c0, c1, r1);
267
+ } else if (self.directed && pl.edges[self.key(b, a)] && pl.edges[self.key(a, b)]){
268
+ // 往復の辺:進む向きの右側へふくらむ弧(逆向きの辺は反対側になる)
269
+ var dx = B.x - A.x, dy = B.y - A.y, L = Math.hypot(dx, dy) || 1, bend = Math.min(0.2 * L, nh * 1.6);
270
+ var cx = (A.x + B.x) / 2 - dy / L * bend, cy = (A.y + B.y) / 2 + dx / L * bend;
271
+ bez(rim(A, dirTo(A, cx, cy)), {x: cx, y: cy}, rim(B, dirTo(B, cx, cy)));
272
+ } else {
273
+ var ang2 = Math.atan2(B.y - A.y, B.x - A.x);
274
+ pts.push(rim(A, ang2), rim(B, ang2 + Math.PI));
275
+ }
276
+ return (geoms[gk] = pts);
277
+ };
278
+ var lenOf = function(pts){ var L = 0; for (var i = 1; i < pts.length; i++) L += Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y); return L; };
279
+ // 点の列の先頭から割合 f までの点の列(f = 1 で全部)と、そこでの向き
280
+ var cutPts = this.cutPts = function(pts, f){
281
+ var L = lenOf(pts) * Math.max(0, Math.min(1, f)), out = [pts[0]], acc = 0;
282
+ for (var i = 1; i < pts.length; i++){
283
+ var sl = Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y);
284
+ if (acc + sl >= L){ var r = sl ? (L - acc) / sl : 0; out.push({x: pts[i - 1].x + (pts[i].x - pts[i - 1].x) * r, y: pts[i - 1].y + (pts[i].y - pts[i - 1].y) * r}); return out; }
285
+ acc += sl; out.push(pts[i]);
286
+ }
287
+ return out;
288
+ };
289
+ var pathD = this.pathD = function(pts){ return pts.map(function(p, i){ return (i ? "L" : "M") + p.x.toFixed(1) + " " + p.y.toFixed(1); }).join(""); };
290
+ var at2 = function(pts, f){
291
+ var q = cutPts(pts, f), n = q.length, p = q[n - 1], o = n > 1 ? q[n - 2] : pts[0];
292
+ if (Math.hypot(p.x - o.x, p.y - o.y) < 1e-6){ o = pts[0]; p = pts[1] || pts[0]; }
293
+ var L = Math.hypot(p.x - o.x, p.y - o.y) || 1;
294
+ return {x: q[n - 1].x, y: q[n - 1].y, ux: (p.x - o.x) / L, uy: (p.y - o.y) / L};
295
+ };
296
+ // 板(plate):頂点の組を囲む角の丸い枠、右下の隅に N。いちばん下の層に
297
+ var gPl = D.el("g", {}, svg);
298
+ this.plateLabels = [];
299
+ (d.plates || []).forEach(function(pt){
300
+ var os = (pt.nodes || []).map(function(id){ return at[id]; }).filter(Boolean);
301
+ if (!os.length) return;
302
+ var x0 = Math.min.apply(null, os.map(function(o){ return o.x - o.w / 2; })) - 14, x1 = Math.max.apply(null, os.map(function(o){ return o.x + o.w / 2; })) + 14;
303
+ var y0 = Math.min.apply(null, os.map(function(o){ return o.y - o.h / 2; })) - 14, y1 = Math.max.apply(null, os.map(function(o){ return o.y + o.h / 2; })) + (pt.label ? Math.ceil(fs * 1.3) + 10 : 14);
304
+ D.el("rect", {x: x0.toFixed(1), y: y0.toFixed(1), width: (x1 - x0).toFixed(1), height: (y1 - y0).toFixed(1), rx: 12, fill: "none", stroke: "var(--fg)", "stroke-width": 1.5}, gPl);
305
+ if (pt.label){ var lt = D.el("text", {x: (x1 - 10).toFixed(1), y: (y1 - 10).toFixed(1), "font-size": fs, "text-anchor": "end", fill: "var(--fg)"}, gPl); lt.textContent = pt.label; self.plateLabels.push(lt); }
306
+ });
307
+ // 格子(trellis):列の上に時刻
308
+ if (d.trellisT) for (var tt = 1; tt <= d.trellisT; tt++){
309
+ var col = nodes.filter(function(o){ return /@(\d+)$/.exec(o.n.id) && +/@(\d+)$/.exec(o.n.id)[1] === tt; });
310
+ if (!col.length) continue;
311
+ var ty = Math.min.apply(null, col.map(function(o){ return o.y - o.h / 2; })) - 12, tl = D.el("text", {x: col[0].x.toFixed(1), y: ty.toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--muted)"}, gPl);
312
+ tl.textContent = "t = " + tt;
313
+ }
314
+ var gE = D.el("g", {}, svg), gT = D.el("g", {}, svg), gC = D.el("g", {}, svg), gN = D.el("g", {}, svg), gW = D.el("g", {}, svg), gB = D.el("g", {}, svg);
315
+ var headD = this.headD = function(pts, f, wd){
316
+ var e = at2(pts, f), s = 10 + wd, x = e.x, y = e.y, px = -e.uy, py = e.ux;
317
+ return "M" + x.toFixed(1) + " " + y.toFixed(1) + "L" + (x - e.ux * s + px * s * 0.5).toFixed(1) + " " + (y - e.uy * s + py * s * 0.5).toFixed(1) +
318
+ "L" + (x - e.ux * s - px * s * 0.5).toFixed(1) + " " + (y - e.uy * s - py * s * 0.5).toFixed(1) + "Z";
319
+ };
320
+ var arrow = function(g, pts, col, wd){ return D.el("path", {d: headD(pts, 1, wd), fill: col}, g); };
321
+ // ほかの辺(--line)と重み
322
+ var placed = nodes.map(function(o){ return {x0: o.x - o.w / 2 - 4, x1: o.x + o.w / 2 + 4, y0: o.y - o.h / 2 - 4, y1: o.y + o.h / 2 + 4}; });
323
+ var hit = function(r){ return placed.some(function(q){ return r.x0 < q.x1 && q.x0 < r.x1 && r.y0 < q.y1 && q.y0 < r.y1; }); };
324
+ var inside = function(r){ return r.x0 >= 0 && r.x1 <= W && r.y0 >= 0 && r.y1 <= H - band; };
325
+ var crowded = [];
326
+ this.wlabels = [];
327
+ // data-part:Studio の形の検査(R-geometry)が測る印。頂点の枠(下の 1 枚だけ。訪れた・候補・今の重ねは測らない)とその名前、辺(自分への辺は除く。矢じりは除く)と重み(縁取りあり)。
328
+ // 探索の木・選んだ辺は同じ辺の上に重ねる線なので測らない
329
+ Object.keys(pl.edges).forEach(function(k){
330
+ var e = pl.edges[k], pts = geom(e.from, e.to), eid = String(e.from) + (self.directed ? ">" : "-") + String(e.to), loop0 = e.from === e.to;
331
+ var ge = loop0 ? gE : D.el("g", {"data-part": "edge", "data-part-id": eid, "data-part-from": String(e.from), "data-part-to": String(e.to)}, gE);
332
+ // 双方向の辺(bi:潜在の交絡)は破線で両端に矢じり
333
+ D.el("path", Object.assign({d: pathD(pts), fill: "none", stroke: "var(--line)", "stroke-width": 2.5}, e.bi ? {"stroke-dasharray": "8 6"} : {}, loop0 ? {} : {"data-part-line": ""}), ge);
334
+ if (self.directed || e.bi) arrow(ge, pts, "var(--line)", 2.5);
335
+ if (e.bi) arrow(ge, pts.slice().reverse(), "var(--line)", 2.5);
336
+ if (!P.weights || typeof e.w !== "number") return;
337
+ var s = fmt(e.w, decimals(e.w)), w = tw(s) + 8, h = fs + 6, best = null, loop = e.from === e.to;
338
+ (loop ? [0.5] : [0.5, 0.38, 0.62, 0.28, 0.72]).some(function(f){
339
+ return (loop ? [1, -1, 1.8, -1.8] : [1, -1]).some(function(side){
340
+ var g = at2(pts, f), off = (fs * 0.62 + 4) * side, cx = g.x - g.uy * off, cy = g.y + g.ux * off;
341
+ var r = {x0: cx - w / 2, x1: cx + w / 2, y0: cy - h / 2, y1: cy + h / 2, cx: cx, cy: cy};
342
+ if (!hit(r) && inside(r)){ best = r; return true; }
343
+ return false;
344
+ });
345
+ });
346
+ if (!best){ crowded.push(e.from + (self.directed ? "→" : "–") + e.to); return; }
347
+ placed.push(best);
348
+ var t = D.el("text", Object.assign({x: best.cx.toFixed(1), y: (best.cy + fs * 0.36).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--fg)",
349
+ stroke: "var(--bg)", "stroke-width": 6, "paint-order": "stroke", style: "font-variant-numeric:tabular-nums"}, loop ? {} : {"data-part": "label", "data-part-id": eid, "data-part-of": "edge", "data-part-halo": ""}), gW);
350
+ t.textContent = s;
351
+ self.wlabels.push(t);
352
+ });
353
+ if (crowded.length) ctx.report("layout", "[network] no room for the weight of " + crowded.join(", ") + "; move the nodes apart, make the element larger or set weights=\"false\"");
354
+ // 探索の木(parent)と選んだ辺(take):出てきた組ごとに 1 本ずつ作る
355
+ this.tree = {}; this.chosen = {};
356
+ pl.states.forEach(function(s){
357
+ Object.keys(s.parent).forEach(function(c){
358
+ var p = s.parent[c], k = p + "\u0000" + c;
359
+ if (self.tree[k] || p === c) return;
360
+ var pts = geom(p, c), L = lenOf(pts);
361
+ self.tree[k] = {el: D.el("g", {opacity: 0}, gT)};
362
+ D.el("path", {d: pathD(cutPts(pts, Math.max(0, (L - 8) / L))), fill: "none", stroke: "var(--term)", "stroke-width": 4.5, "stroke-linecap": "round"}, self.tree[k].el);
363
+ arrow(self.tree[k].el, pts, "var(--term)", 4.5);
364
+ });
365
+ Object.keys(s.chosen).forEach(function(k){
366
+ if (self.chosen[k]) return;
367
+ self.chosen[k] = {el: D.el("path", {d: "M0 0", fill: "none", stroke: "var(--term)", "stroke-width": 8, "stroke-linecap": "round", opacity: 0}, gC), a: s.chosen[k][0], b: s.chosen[k][1],
368
+ head: self.directed ? D.el("path", {d: "M0 0", fill: "var(--term)", opacity: 0}, gC) : null};
369
+ });
370
+ });
371
+ // 頂点:塗り(訪れた)、点線の輪(候補)、太い輪(今)、名前
372
+ nodes.forEach(function(o){
373
+ var rect = function(grow, attrs){
374
+ var w = o.w + 2 * grow, h = o.h + 2 * grow;
375
+ var shp = o.sh === "ellipse" ? {rx: (w / 2).toFixed(1), ry: (h / 2).toFixed(1)} : o.sh === "box" ? {rx: 6} : {rx: (h / 2).toFixed(1)};
376
+ return D.el("rect", Object.assign({x: (o.x - w / 2).toFixed(1), y: (o.y - h / 2).toFixed(1), width: w.toFixed(1), height: h.toFixed(1)}, shp, attrs), gN);
377
+ };
378
+ // 観測した変数(observed)は塗る(グラフィカルモデルの習わし)
379
+ var nid = String(o.n.id), nl = {"data-part": "label", "data-part-id": nid, "data-part-of": "box"};
380
+ rect(0, {fill: o.n.observed ? "var(--line)" : "var(--bg)", stroke: "var(--fg)", "stroke-width": 2, "data-part": "box", "data-part-id": nid});
381
+ o.vis = rect(0, {fill: "var(--muted)", opacity: 0});
382
+ o.fr = rect(6, {fill: "none", stroke: "var(--accent2)", "stroke-width": 4, "stroke-dasharray": "8 6", opacity: 0});
383
+ o.cur = rect(4, {fill: "none", stroke: "var(--emph)", "stroke-width": 7, opacity: 0});
384
+ if (MARK.test(o.lab)) D.mtext(gN, o.x, o.y + fs * 0.36, o.lab, Object.assign({"font-size": fs, "text-anchor": "middle", fill: "var(--fg)"}, nl));
385
+ else { var t = D.el("text", Object.assign({x: o.x.toFixed(1), y: (o.y + fs * 0.36).toFixed(1), "font-size": fs, "text-anchor": "middle", fill: "var(--fg)"}, nl), gN); t.textContent = o.lab; }
386
+ });
387
+ this.nodes = nodes;
388
+ // 下の帯
389
+ var by = H - band + 4;
390
+ this.band = {y1: by + rowH / 2 + fs * 0.36, y2: by + rowH * ((pl.hasFrontier || pl.hasTotal) ? 1.5 : 0.5) + fs * 0.36, W: W, g: gB};
391
+ if (pl.hasTotal){
392
+ var tl = d.total && d.total.label !== undefined ? d.total.label : ja ? "合計" : "Total";
393
+ this.totalText = D.el("text", {x: W - 4, y: this.band.y1.toFixed(1), "font-size": fs, "text-anchor": "end", fill: "var(--fg)", style: "font-variant-numeric:tabular-nums", opacity: 0}, gB);
394
+ this.totalLabel = tl;
395
+ var maxs = pl.states.reduce(function(m, s){ return typeof s.total === "number" ? Math.max(m, tw(self.totalString(s.total))) : m; }, 0);
396
+ this.totalW = maxs + 24;
397
+ } else this.totalW = 0;
398
+ if (pl.hasFrontier){
399
+ var kind = KIND[d.frontierKind || "set"];
400
+ this.capText = D.el("text", {x: 4, y: this.band.y1.toFixed(1), "font-size": fs, fill: "var(--fg)"}, gB);
401
+ this.capText.textContent = ja ? kind.ja : kind.en;
402
+ this.capW = tw(this.capText.textContent) + 16;
403
+ if (this.capW + nh + this.totalW > W){ ctx.report("size", "[network] the frontier row has no room (" + W + " px wide)"); }
404
+ var most = Math.max.apply(null, pl.states.map(function(s){ return s.frontier.length; }));
405
+ this.slots = [];
406
+ for (var q = 0; q < most + 1; q++){
407
+ var sg = D.el("g", {opacity: 0}, gB);
408
+ this.slots.push({g: sg, rect: D.el("rect", {x: 0, y: 0, width: 0, height: nh - 8, rx: 6, opacity: 0, fill: "none", stroke: "var(--accent2)", "stroke-width": 3, "stroke-dasharray": "8 6"}, sg),
409
+ text: D.el("text", {x: 0, y: 0, "font-size": fs, "text-anchor": "middle", fill: "var(--fg)"}, sg)});
410
+ }
411
+ }
412
+ if (pl.hasNote){
413
+ this.noteText = D.el("text", {x: 4, y: this.band.y2.toFixed(1), "font-size": fs, fill: "var(--fg)", opacity: 0}, gB);
414
+ // 記法のある説明は、その説明ごとに mtext で作っておき、そのステップで出す
415
+ this.markNotes = {};
416
+ pl.states.forEach(function(st2, k2){ if (st2.note && MARK.test(st2.note)) self.markNotes[k2] = D.mtext(gB, 4, self.band.y2, st2.note, {"font-size": fs, fill: "var(--fg)", opacity: 0}); });
417
+ var long = [];
418
+ pl.states.forEach(function(s, k){ if (s.note && tw(s.note) > W - 8) long.push(k); });
419
+ if (long.length) ctx.report("layout", "[network] the note of step " + long.join(", ") + " is wider than the element (" + W + " px); shorten it (it is cut with …)");
420
+ }
421
+ this.fit = function(s, room){
422
+ if (tw(s) <= room) return s;
423
+ var a = Array.from(s);
424
+ while (a.length && tw(a.join("") + "…") > room) a.pop();
425
+ return a.join("") + "…";
426
+ };
427
+ this.tw = tw;
428
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
429
+ this.setAttribute("role", "img");
430
+ if (!this._aria) this.setAttribute("aria-label", this.summary(ja));
431
+ this.model = {nodes: nodes.map(function(o){ return [o.n.id, +o.x.toFixed(1), +o.y.toFixed(1)]; }), states: pl.states.length};
432
+ function decimals(v){ var x = String(v).split(".")[1]; return x ? Math.min(3, x.length) : 0; }
433
+ }
434
+ totalString(v){
435
+ var u = this.net.total && this.net.total.unit ? this.net.total.unit : "";
436
+ return this.totalLabel + " " + fmt(v, this.plan().digits) + (u ? " " + u : "");
437
+ }
438
+ // 読み上げ:頂点と辺の数、最後に選んだ辺、合計
439
+ summary(ja){
440
+ var pl = this.plan(), d = this.net, last = pl.states[pl.states.length - 1], self = this;
441
+ var ne = Object.keys(pl.edges).length;
442
+ var s = ja ? "グラフ(頂点 " + d.nodes.length + "、辺 " + ne + ")" : "Graph (" + d.nodes.length + " nodes, " + ne + " edges)";
443
+ var ch = Object.keys(last.chosen).map(function(k){ return last.chosen[k].join(self.directed ? "→" : "–"); });
444
+ if (ch.length) s += ja ? "。選んだ辺:" + ch.join("、") : ". Chosen edges: " + ch.join(", ");
445
+ var tr = Object.keys(last.parent).map(function(c){ return last.parent[c] + "→" + c; });
446
+ if (tr.length) s += ja ? "。探索の木:" + tr.join("、") : ". Search tree: " + tr.join(", ");
447
+ if (typeof last.total === "number"){
448
+ var u = d.total && d.total.unit ? d.total.unit : "", lab = d.total && d.total.label !== undefined ? d.total.label : ja ? "合計" : "Total";
449
+ s += (ja ? "。" : ". ") + lab + " " + fmt(last.total, pl.digits) + (u ? " " + u : "");
450
+ }
451
+ return s;
452
+ }
453
+ // ステップ k の時刻:drop が消える(前半)→ take を 1 本ずつ引く。頂点の色は前半で変わる
454
+ timing(k){
455
+ var s = this.plan().states[k], P = this.props;
456
+ if (!s || k === 0) return {fade: 0, start: 0, end: 0};
457
+ var fade = P.dur * 0.5, start = s.drop.length ? fade : 0;
458
+ return {fade: fade, start: start, end: Math.max(fade, start + s.take.length * P.dur)};
459
+ }
460
+ duration(k){ return this.timing(k).end; }
461
+ render(k, t, ctx){
462
+ if (!this.nodes) return;
463
+ var self = this, pl = this.plan(), D = base, P = this.props;
464
+ k = Math.max(0, Math.min(k, pl.states.length - 1));
465
+ var cur = pl.states[k], prev = pl.states[Math.max(0, k - 1)], tm = this.timing(k);
466
+ var e = k === 0 ? 1 : D.prog(t, 0, tm.fade);
467
+ var mix = function(a, b){ return D.lerp(a ? 1 : 0, b ? 1 : 0, e); };
468
+ var inF = function(s, id){ return s.frontier.some(function(f){ return f.id === id; }); };
469
+ this.nodes.forEach(function(o){
470
+ var id = o.n.id;
471
+ o.vis.setAttribute("opacity", (0.35 * mix(prev.visited.indexOf(id) >= 0, cur.visited.indexOf(id) >= 0)).toFixed(3));
472
+ o.fr.setAttribute("opacity", mix(inF(prev, id), inF(cur, id)).toFixed(3));
473
+ o.cur.setAttribute("opacity", mix(prev.current === id, cur.current === id).toFixed(3));
474
+ });
475
+ Object.keys(this.tree).forEach(function(k2){
476
+ var parts = k2.split("\u0000"), was = prev.parent[parts[1]] === parts[0], is = cur.parent[parts[1]] === parts[0];
477
+ self.tree[k2].el.setAttribute("opacity", (k === 0 ? 0 : mix(was, is)).toFixed(3));
478
+ });
479
+ // 選んだ辺:前のステップから残る辺は引いたまま、drop は前半で消え、take は順に端から端へ
480
+ var takeAt = {};
481
+ cur.take.forEach(function(x, j){ takeAt[x.k] = {j: j, a: x.a, b: x.b}; });
482
+ Object.keys(this.chosen).forEach(function(k2){
483
+ var c = self.chosen[k2], el = c.el, a = c.a, b = c.b, f = 0, op = 0;
484
+ if (takeAt[k2] && k > 0){
485
+ a = takeAt[k2].a; b = takeAt[k2].b;
486
+ f = D.prog(t, tm.start + takeAt[k2].j * P.dur, P.dur); op = f > 0 ? 1 : 0;
487
+ } else if (cur.chosen[k2]){
488
+ a = cur.chosen[k2][0]; b = cur.chosen[k2][1]; f = 1; op = 1;
489
+ } else if (prev.chosen[k2] && k > 0){
490
+ a = prev.chosen[k2][0]; b = prev.chosen[k2][1]; f = 1; op = 1 - D.prog(t, 0, tm.fade);
491
+ }
492
+ var pts = self.geom(a, b), L = 0;
493
+ for (var i = 1; i < pts.length; i++) L += Math.hypot(pts[i].x - pts[i - 1].x, pts[i].y - pts[i - 1].y);
494
+ // 向きのあるグラフ:線は矢じりの手前で止め、矢じりを線の先に付ける
495
+ var fl = c.head ? f * Math.max(0, (L - 12) / (L || 1)) : f;
496
+ el.setAttribute("d", f > 0 ? self.pathD(self.cutPts(pts, fl)) : "M0 0");
497
+ el.setAttribute("opacity", op.toFixed(3));
498
+ if (c.head){ c.head.setAttribute("d", f > 0 ? self.headD(pts, f, 8) : "M0 0"); c.head.setAttribute("opacity", op.toFixed(3)); }
499
+ });
500
+ // 合計:前の値から今の値へ数え上げる
501
+ if (this.totalText){
502
+ var has = typeof cur.total === "number", from = typeof prev.total === "number" && k > 0 ? prev.total : has ? cur.total : 0;
503
+ var v = has ? D.lerp(from, cur.total, k === 0 ? 1 : D.prog(t, 0, Math.max(tm.end, 0.3))) : 0;
504
+ this.totalText.textContent = has ? this.totalString(+v.toFixed(pl.digits)) : "";
505
+ this.totalText.setAttribute("opacity", has ? 1 : 0);
506
+ }
507
+ // 候補の並び:今のステップの frontier(前半で入れ替わる。どちらか一方だけを見せる)
508
+ if (this.slots){
509
+ var show = k === 0 ? cur : e < 0.5 ? prev : cur, x = this.capW, room = this.band.W - this.totalW - 4, fsz = P.size;
510
+ var items = show.frontier.map(function(f){ return f.key !== undefined ? f.id + " " + fmt(f.key, decimals(f.key)) : (self.at[f.id] ? self.at[f.id].lab : f.id); });
511
+ var empty = !items.length && k > 0;
512
+ if (empty) items = [this.ja ? "(空)" : "(empty)"];
513
+ var nShow = items.length, widths = items.map(function(s){ return Math.max(self.tw(s) + 20, fsz * 1.4); });
514
+ var more = function(n){ return "…+" + n; };
515
+ while (nShow > 0){
516
+ var used = x, j2;
517
+ for (j2 = 0; j2 < nShow; j2++) used += widths[j2] + 8;
518
+ if (nShow < items.length) used += self.tw(more(items.length - nShow)) + 8;
519
+ if (used <= room) break;
520
+ nShow--;
521
+ }
522
+ var op2 = k === 0 ? 1 : Math.abs(e - 0.5) * 2;
523
+ this.slots.forEach(function(sl, j){
524
+ if (j < nShow){
525
+ sl.rect.setAttribute("x", x.toFixed(1)); sl.rect.setAttribute("y", (self.band.y1 - fsz * 0.36 - (self.nodes[0].h - 8) / 2).toFixed(1)); sl.rect.setAttribute("width", widths[j].toFixed(1));
526
+ sl.rect.setAttribute("opacity", empty ? 0 : 1);
527
+ sl.text.setAttribute("x", (x + widths[j] / 2).toFixed(1)); sl.text.setAttribute("y", self.band.y1.toFixed(1)); sl.text.textContent = items[j];
528
+ sl.g.setAttribute("opacity", op2.toFixed(3)); x += widths[j] + 8;
529
+ } else if (j === nShow && nShow < items.length){
530
+ ["x", "y", "width"].forEach(function(a){ sl.rect.setAttribute(a, 0); });
531
+ sl.rect.setAttribute("opacity", 0);
532
+ sl.text.setAttribute("x", (x + self.tw(more(items.length - nShow)) / 2).toFixed(1)); sl.text.setAttribute("y", self.band.y1.toFixed(1)); sl.text.textContent = more(items.length - nShow);
533
+ sl.g.setAttribute("opacity", op2.toFixed(3));
534
+ } else {
535
+ ["x", "y", "width"].forEach(function(a){ sl.rect.setAttribute(a, 0); });
536
+ sl.rect.setAttribute("opacity", 0); sl.text.setAttribute("x", 0); sl.text.setAttribute("y", 0); sl.text.textContent = ""; sl.g.setAttribute("opacity", 0);
537
+ }
538
+ });
539
+ }
540
+ if (this.noteText){
541
+ var mk = this.markNotes[k], no = cur.note ? (k === 0 ? 1 : D.prog(t, 0, tm.fade)).toFixed(3) : 0;
542
+ this.noteText.textContent = cur.note && !mk ? this.fit(cur.note, this.band.W - 8) : "";
543
+ this.noteText.setAttribute("opacity", mk ? 0 : no);
544
+ for (var mkk in this.markNotes) this.markNotes[mkk].setAttribute("opacity", +mkk === k ? no : 0);
545
+ }
546
+ function decimals(v){ var x = String(v).split(".")[1]; return x ? Math.min(3, x.length) : 0; }
547
+ }
548
+ };
549
+ function fmt(v, dg){
550
+ var s = Math.abs(v).toFixed(dg).split("."), i = s[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
551
+ var neg = v < 0 && +Math.abs(v).toFixed(dg) !== 0;
552
+ return (neg ? "−" : "") + i + (s[1] ? "." + s[1] : "");
553
+ }
554
+ });
@@ -0,0 +1,23 @@
1
+ ---
2
+ summary: Positioning figure: per question, earlier vs this work's answer (unknown dashed), or assumption chips with this work's dropped and added; by step
3
+ steps: answers: questions → earlier answers → arrows and this work (order="row": per row). assumptions: studies → this work kept, dropped → added → yields. order="whole": 1
4
+ props:
5
+ order: build (default), row (answers), whole
6
+ dur: seconds per step
7
+ size: text px (≥ 24)
8
+ example: {"kind": "answers", "rows": [{"q": "Where is the gap?", "before": {"unknown": true, "near": "Between countries [2]"}, "after": "70% between schools", "basis": "3 years, all pupils"}]}
9
+ ---
10
+
11
+ Novelty in an answer or a view (not m-matrix). `kind` in the JSON.
12
+
13
+ - `answers` (default): `rows` 1–3 `{"q", "before": {"text", "by"}, "after", "basis"}`; no earlier answer: `"before": {"unknown": true, "near"}` (dashed, "Unknown")
14
+ - `assumptions`: `studies` 1–3 `{"label", "chips", "result"}`; `self` `{"kept", "dropped", "added", "result"}`; dropped struck, added `--emph`, both labelled
15
+ - This work written, framed; `selfLabel`, `heads` (3) rename
16
+ - Name the nearest work (`by`, `label`). By premise: m-tree `dash`
17
+
18
+ <!-- llm: omit -->
19
+ Notes
20
+
21
+ - Text 28 → 24 px; at 24, no smaller, the size needed is reported. Text wraps to its column, balanced; rows grow to the element's height (≤ 2×)
22
+ - Readable table: the final state, "Unknown (near)", "dropped: " / "added: "
23
+ <!-- llm: end -->