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,243 @@
1
+ // m-matrix 2.0.0: a comparison matrix in two forms (handoff #64).
2
+ // kind "cross" (default): the cross of two axes. Rows are the values of axis 1, columns the values of axis 2 (2 to 4 each);
3
+ // a cell lists the studies that fall there (a citation number or "Author (year)", 1 to 3), "self" marks the cell of this work
4
+ // (written as 本研究 / This work and framed, never colour alone), and an empty cell shows — with a note number; the notes
5
+ // ("trivial", "meaningless", "not yet done") stand under the table. A third axis is a mark after a study's name (†, ‡)
6
+ // explained by "marks". Steps (order "build", default): the axes and the empty grid → the earlier studies → this work's
7
+ // cell, framed → the notes of the empty cells. order "whole": everything at step 1.
8
+ // kind "attributes": rows are studies (this work first), columns their elements (aim, setting, input, output, criterion …),
9
+ // a cell a short text (✓ △ × too). order "whole" (default), "col" (a column per step) or "row" (a row per step);
10
+ // the row marked self is framed at the last step.
11
+ // Headers: a cross table names its axes once (the row axis in the corner, the column axis over its values); the readable
12
+ // table (data-readable, the final state) writes each header as "axis: value". Cells are data-part boxes and their texts
13
+ // labels, for Studio's geometry check (spec §8.4). Text is size px (≥ 24); when the table does not fit at 24 px the part
14
+ // reports size with what it needs. Colours: grid --line, headers --fg bold, this work's frame --emph, notes and dashes --muted.
15
+ egatariParts.define({name: "matrix", version: "2.0.0", requires: {base: "1.3.0"}, element: "m-matrix"}, function(deps){
16
+ "use strict";
17
+ var base = deps.base;
18
+ var T = {ja: {self: "本研究", note: "注", sep: ":", label: "表:", none: "該当なし"},
19
+ en: {self: "This work", note: "Note ", sep: ": ", label: "Table: ", none: "none"}};
20
+ var STR = {type: "string"};
21
+ var CELL = {type: ["array", "object"]};
22
+ return class extends base.MotionElement {
23
+ static partName = "matrix";
24
+ static shape = {
25
+ schema: {type: "object", additionalProperties: false, properties: {
26
+ kind: {type: "string", enum: ["cross", "attributes"]},
27
+ rows: {type: ["object", "array"]},
28
+ cols: {type: ["object", "array"]},
29
+ cells: {type: "array", maxItems: 4, items: {type: "array", maxItems: 4, items: CELL}},
30
+ marks: {type: "array", maxItems: 3, items: {type: "object", additionalProperties: false, required: ["mark", "text"], properties: {mark: STR, text: STR}}},
31
+ self: STR}},
32
+ example: {kind: "cross", rows: {axis: "評価基準", values: ["予測誤差", "ベイズリスク"]}, cols: {axis: "予測の形", values: ["点予測", "分布予測"]},
33
+ cells: [[["[1]", "[2]"], ["[3]"]], [{none: "自明"}, {self: true}]]},
34
+ note: {en: "cross: rows and cols are {\"axis\", \"values\"}; cells[r][c] is a list of study names, {\"self\": true} or {\"none\": \"why it is empty\"}. attributes: cols is a list of names, rows a list of {\"label\", \"cells\", \"self\"?}",
35
+ ja: "cross:rows と cols は {\"axis\", \"values\"}、cells[r][c] は研究の名前の並び、{\"self\": true}、{\"none\": \"空きの理由\"} のどれか。attributes:cols は名前の並び、rows は {\"label\", \"cells\", \"self\"?} の並び"},
36
+ };
37
+ static props = {
38
+ order: {type: "string", default: "", doc: "出し方:cross は build(既定)・whole、attributes は whole(既定)・col・row"},
39
+ dur: {type: "number", default: 0.6, doc: "1 ステップの秒数"},
40
+ size: {type: "number", default: 28, doc: "字の大きさ(px、24 以上。入らなければ 24 まで縮める)"},
41
+ };
42
+ get steps(){
43
+ if (this.getAttribute("steps") !== null) return +this.getAttribute("steps");
44
+ return this.plan().steps;
45
+ }
46
+ // the cells and when each appears; from the data alone
47
+ plan(){
48
+ if (this._plan) return this._plan;
49
+ var d = this.data || {}, bad = [], ja = !/^en\b/i.test(this.closest && this.closest("[lang]") ? this.closest("[lang]").getAttribute("lang") : "ja");
50
+ var L = ja ? T.ja : T.en, selfText = d.self || L.self, kind = d.kind || "cross", order = this.props.order;
51
+ var cells = [], notes = [], grid = {}, steps = 0, selfBox = null;
52
+ var cell = function(r, c, lines, o){ var x = Object.assign({r: r, c: c, lines: lines, step: 0}, o || {}); cells.push(x); grid[r + "," + c] = x; return x; };
53
+ var nr, nc, head;
54
+ if (kind === "cross") {
55
+ var R = d.rows && !Array.isArray(d.rows) ? d.rows : {}, C = d.cols && !Array.isArray(d.cols) ? d.cols : {};
56
+ var rv = Array.isArray(R.values) ? R.values.map(String) : [], cv = Array.isArray(C.values) ? C.values.map(String) : [];
57
+ if (rv.length < 2 || rv.length > 4 || cv.length < 2 || cv.length > 4) bad.push("cross needs 2 to 4 values on each axis (rows.values, cols.values)");
58
+ if (order && order !== "build" && order !== "whole") bad.push("order for cross is build or whole, not " + order);
59
+ var whole = order === "whole";
60
+ // grid: row 0 = the column axis's name over its values, row 1 = the column values; column 0 = the row values
61
+ nr = rv.length + 2; nc = cv.length + 1; head = {rows: 2, cols: 1};
62
+ cell(0, 0, [String(R.axis || "")], {head: true, corner: true, span: [2, 1]});
63
+ cell(0, 1, [String(C.axis || "")], {head: true, span: [1, cv.length]});
64
+ cv.forEach(function(v, j){ cell(1, j + 1, [v], {head: true}); });
65
+ rv.forEach(function(v, i){ cell(i + 2, 0, [v], {head: true}); });
66
+ var cs = Array.isArray(d.cells) ? d.cells : [];
67
+ if (cs.length !== rv.length || cs.some(function(row, i){ return !Array.isArray(row) || row.length !== cv.length; })) bad.push("cells must be " + rv.length + " rows of " + cv.length + " cells (rows.values × cols.values)");
68
+ // build: the studies at 1, this work at 2 (when there is one), the notes at the last step (when there are any)
69
+ var anySelf = cs.some(function(row){ return Array.isArray(row) && row.some(function(v){ return v && typeof v === "object" && !Array.isArray(v) && v.self; }); });
70
+ var anyNote = cs.some(function(row){ return Array.isArray(row) && row.some(function(v){ return v && typeof v === "object" && !Array.isArray(v) && typeof v.none === "string" && v.none; }); });
71
+ var sSelf = whole ? 1 : 2, sNote = whole ? 1 : anySelf ? 3 : 2;
72
+ steps = whole ? 1 : 1 + (anySelf ? 1 : 0) + (anyNote ? 1 : 0);
73
+ rv.forEach(function(_, i){ cv.forEach(function(_, j){
74
+ var v = (cs[i] || [])[j], r = i + 2, c = j + 1, obj = v && typeof v === "object" && !Array.isArray(v);
75
+ if (Array.isArray(v) && v.length) {
76
+ if (v.length > 3) bad.push("cell " + (i + 1) + "," + (j + 1) + " lists " + v.length + " studies; at most 3 (pick the main ones)");
77
+ cell(r, c, v.slice(0, 3).map(String), {step: 1});
78
+ } else if (obj && v.self) {
79
+ if (selfBox) bad.push("only one cell is this work's (self)");
80
+ var x = cell(r, c, [selfText].concat((Array.isArray(v.studies) ? v.studies : []).map(String)), {step: sSelf, self: !selfBox});
81
+ if (!selfBox) selfBox = x;
82
+ } else if (obj && typeof v.none === "string" && v.none) {
83
+ notes.push(v.none);
84
+ cell(r, c, ["— " + L.note + notes.length], {step: sNote, dash: true, note: notes.length});
85
+ } else {
86
+ cell(r, c, ["—"], {step: 1, dash: true});
87
+ }
88
+ }); });
89
+ var marks = Array.isArray(d.marks) ? d.marks : [];
90
+ var below = marks.map(function(m){ return {text: m.mark + " " + m.text, step: 1}; })
91
+ .concat(notes.map(function(t, i){ return {text: L.note + (i + 1) + L.sep + t, step: sNote}; }));
92
+ return (this._plan = {kind: kind, L: L, bad: bad, cells: cells, grid: grid, nr: nr, nc: nc, head: head, steps: steps, selfBox: selfBox, below: below,
93
+ rv: rv, cv: cv, raxis: String(R.axis || ""), caxis: String(C.axis || "")});
94
+ }
95
+ if (kind !== "attributes") bad.push("kind is cross or attributes");
96
+ var cols = Array.isArray(d.cols) ? d.cols.map(String) : [], rows = Array.isArray(d.rows) ? d.rows : [];
97
+ if (cols.length < 1 || cols.length > 6) bad.push("attributes needs 1 to 6 cols");
98
+ if (rows.length < 1 || rows.length > 10) bad.push("attributes needs 1 to 10 rows");
99
+ order = order || "whole";
100
+ if (["whole", "col", "row"].indexOf(order) < 0) { bad.push("order for attributes is whole, col or row, not " + order); order = "whole"; }
101
+ nr = rows.length + 1; nc = cols.length + 1; head = {rows: 1, cols: 1};
102
+ var selfRow = -1;
103
+ rows.forEach(function(r, i){ if (r && r.self && selfRow < 0) selfRow = i; });
104
+ var groups = order === "whole" ? 1 : order === "col" ? cols.length : rows.length;
105
+ steps = groups + (selfRow >= 0 && order !== "whole" ? 1 : 0);
106
+ cell(0, 0, [""], {head: true, corner: true});
107
+ cols.forEach(function(v, j){ cell(0, j + 1, [v], {head: true}); });
108
+ rows.forEach(function(r, i){
109
+ r = r && typeof r === "object" ? r : {};
110
+ var cs = Array.isArray(r.cells) ? r.cells : [];
111
+ if (cs.length !== cols.length) bad.push("row " + (i + 1) + " has " + cs.length + " cells; cols has " + cols.length);
112
+ var at = function(j){ return order === "whole" ? 1 : order === "col" ? j + 1 : i + 1; };
113
+ cell(i + 1, 0, [String(r.label || "")], {head: true, step: order === "row" ? i + 1 : 0, self: i === selfRow});
114
+ cols.forEach(function(_, j){
115
+ var v = cs[j], s = v === undefined || v === null || v === "" ? "—" : String(v);
116
+ cell(i + 1, j + 1, [s], {step: at(j), dash: s === "—"});
117
+ });
118
+ });
119
+ return (this._plan = {kind: kind, L: L, bad: bad, cells: cells, grid: grid, nr: nr, nc: nc, head: head, steps: steps, selfRow: selfRow,
120
+ selfStep: selfRow >= 0 ? (order === "whole" ? 1 : steps) : 0, below: [], cols: cols, rowsLabels: rows.map(function(r){ return String((r || {}).label || ""); })});
121
+ }
122
+ mount(ctx){
123
+ var self = this, P = this.props, D = base, pl = this.plan();
124
+ this.style.display = "block"; this.style.position = "relative";
125
+ var W = this.clientWidth, H = this.clientHeight;
126
+ if (!(P.dur >= 0)) { ctx.report("attr", "[matrix] dur must be ≥ 0; using 0.6"); P.dur = 0.6; }
127
+ if (!(P.size >= 24)) { ctx.report("attr", "[matrix] size must be ≥ 24; using 28"); P.size = 28; }
128
+ pl.bad.forEach(function(m){ ctx.report("data", "[matrix] " + m); });
129
+ if (pl.bad.length && (pl.nr < 2 || pl.nc < 2)) return; // nothing to draw a grid from
130
+ // sizes: the largest font from size down to 24 at which the table fits; else 24 and a size report
131
+ var fit = null;
132
+ for (var fs = Math.round(P.size); fs >= 24 && !fit; fs -= 2) fit = this._fit(fs, W, H);
133
+ if (!fit) {
134
+ var g24 = this._fit(24, W, H, true);
135
+ ctx.report("size", "[matrix] the table needs " + Math.ceil(g24.tableW) + " × " + Math.ceil(g24.needH) + " px at 24 px; the element is " + W + " × " + H + " px (fewer rows or columns, shorter names, or a larger element)");
136
+ fit = g24;
137
+ }
138
+ var G = this.geo = fit, fsz = G.fs;
139
+ 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);
140
+ var gB = D.el("g", {}, svg), gL = D.el("g", {}, svg), gT = D.el("g", {}, svg), gF = D.el("g", {}, svg), gN = D.el("g", {}, svg);
141
+ var xs = G.xs, ys = G.ys, x0 = xs[0], y0 = ys[0], hr = pl.head.rows, hc = pl.head.cols;
142
+ // grid: thick under the header rows and right of the header column; the column-axis row has no vertical lines inside its span
143
+ for (var r = 0; r <= pl.nr; r++) {
144
+ var xa = pl.kind === "cross" && r === 1 ? xs[1] : x0;
145
+ D.el("line", {x1: xa, x2: xs[pl.nc], y1: ys[r], y2: ys[r], stroke: "var(--line)", "stroke-width": r === hr ? 2.5 : 1.2}, gL);
146
+ }
147
+ for (var c = 0; c <= pl.nc; c++) {
148
+ var ya = pl.kind === "cross" && c >= 2 && c < pl.nc ? ys[1] : y0;
149
+ D.el("line", {x1: xs[c], x2: xs[c], y1: ya, y2: ys[pl.nr], stroke: "var(--line)", "stroke-width": c === hc ? 2.5 : 1.2}, gL);
150
+ }
151
+ var lh = Math.ceil(fsz * 1.3), pad = G.pad;
152
+ this.cellEls = pl.cells.map(function(x){
153
+ var sp = x.span || [1, 1], cx0 = xs[x.c], cx1 = xs[x.c + sp[1]], cy0 = ys[x.r], cy1 = ys[x.r + sp[0]];
154
+ var id = "m" + x.r + "-" + x.c, g = D.el("g", {}, gT);
155
+ D.el("rect", {x: cx0, y: cy0, width: cx1 - cx0, height: cy1 - cy0, fill: "none", stroke: "none", "data-part": "box", "data-part-id": id}, gB);
156
+ var left = x.head && x.c === 0, n = x.lines.length, top = (cy0 + cy1) / 2 - (n - 1) * lh / 2 + fsz * 0.36;
157
+ x.lines.forEach(function(s, i){
158
+ var t = D.el("text", {x: (left ? cx0 + pad : (cx0 + cx1) / 2).toFixed(1), y: (top + i * lh).toFixed(1), "font-size": fsz,
159
+ "text-anchor": left ? "start" : "middle", fill: x.dash ? "var(--muted)" : "var(--fg)", "font-weight": x.head || (x.self && i === 0) ? 700 : 400,
160
+ "data-part": "label", "data-part-id": id, "data-part-of": "box"}, g);
161
+ t.textContent = s;
162
+ });
163
+ return {x: x, g: g};
164
+ });
165
+ // this work: the cell (cross) or the row (attributes), framed in --emph
166
+ var fr = null;
167
+ if (pl.selfBox) { var b = pl.selfBox; fr = [xs[b.c] + 3, ys[b.r] + 3, xs[b.c + 1] - xs[b.c] - 6, ys[b.r + 1] - ys[b.r] - 6]; this.frameStep = b.step; }
168
+ else if (pl.selfRow >= 0) { var rr = pl.selfRow + 1; fr = [x0 + 3, ys[rr] + 3, xs[pl.nc] - x0 - 6, ys[rr + 1] - ys[rr] - 6]; this.frameStep = pl.selfStep; }
169
+ this.frame = fr ? D.el("rect", {x: fr[0], y: fr[1], width: fr[2], height: fr[3], rx: 5, fill: "none", stroke: "var(--emph)", "stroke-width": 4}, gF) : null;
170
+ // notes and marks under the table
171
+ this.belowEls = pl.below.map(function(o, i){
172
+ var t = D.el("text", {x: x0.toFixed(1), y: (G.tableBottom + 14 + fsz * 0.9 + i * Math.ceil(fsz * 1.35)).toFixed(1), "font-size": fsz, fill: "var(--fg)"}, gN);
173
+ t.textContent = o.text;
174
+ return {o: o, t: t};
175
+ });
176
+ // the readable table (data-readable): the final state, headers as "axis: value"
177
+ var tbl = document.createElement("table");
178
+ tbl.className = "sr-only"; tbl.setAttribute("data-readable", "");
179
+ tbl.setAttribute("style", "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip-path:inset(50%);border:0");
180
+ var L = pl.L, tr = function(list, th){ var e = document.createElement("tr"); list.forEach(function(s, i){ var td = document.createElement(th || i === 0 ? "th" : "td"); td.textContent = s; e.appendChild(td); }); tbl.appendChild(e); };
181
+ if (pl.kind === "cross") {
182
+ tr([pl.raxis + " \ " + pl.caxis].concat(pl.cv.map(function(v){ return pl.caxis + L.sep + v; })), true);
183
+ pl.rv.forEach(function(v, i){ tr([pl.raxis + L.sep + v].concat(pl.cv.map(function(_, j){ return pl.grid[(i + 2) + "," + (j + 1)].lines.join("、"); }))); });
184
+ if (pl.below.length) { var cap = document.createElement("caption"); cap.textContent = pl.below.map(function(o){ return o.text; }).join(" "); tbl.insertBefore(cap, tbl.firstChild); }
185
+ } else {
186
+ tr([""].concat(pl.cols), true);
187
+ pl.rowsLabels.forEach(function(v, i){ tr([v + (i === pl.selfRow ? "(" + L.self + ")" : "")].concat(pl.cols.map(function(_, j){ return pl.grid[(i + 1) + "," + (j + 1)].lines.join(" "); }))); });
188
+ }
189
+ this.appendChild(tbl);
190
+ if (this._aria === undefined) this._aria = this.getAttribute("aria-label");
191
+ this.setAttribute("role", "img");
192
+ if (!this._aria) this.setAttribute("aria-label", L.label + (pl.kind === "cross" ? pl.raxis + " × " + pl.caxis : pl.cols.join(pl.L === T.ja ? "、" : ", ")));
193
+ }
194
+ // column widths and row heights at font size fs; null when the table does not fit W × H (unless force)
195
+ _fit(fs, W, H, force){
196
+ var pl = this.plan(), D = base, self = this, pad = Math.round(fs * 0.5), lh = Math.ceil(fs * 1.3);
197
+ var tw = function(s, b){ return D.textWidth(s, fs, {font: self}) * (b ? 1.06 : 1); };
198
+ var cw = [], rh = [];
199
+ for (var c = 0; c < pl.nc; c++) cw[c] = fs * 2;
200
+ for (var r = 0; r < pl.nr; r++) rh[r] = Math.ceil(fs * 1.6);
201
+ pl.cells.forEach(function(x){
202
+ if (x.span && x.span[1] > 1) return;
203
+ var w = Math.max.apply(null, x.lines.map(function(s, i){ return tw(s, x.head || (x.self && i === 0)); })) + 2 * pad;
204
+ if (w > cw[x.c]) cw[x.c] = Math.ceil(w);
205
+ var h = Math.ceil(x.lines.length * lh + fs * 0.5);
206
+ if (!(x.span && x.span[0] > 1) && h > rh[x.r]) rh[x.r] = h;
207
+ });
208
+ // value columns of the same width (a matrix reads by its grid), the header column as wide as it needs
209
+ var vmax = Math.max.apply(null, cw.slice(1));
210
+ for (var c2 = 1; c2 < pl.nc; c2++) cw[c2] = vmax;
211
+ var spanW = pl.kind === "cross" ? tw(pl.caxis, true) + 2 * pad : 0;
212
+ var tableW = cw.reduce(function(a, b){ return a + b; }, 0);
213
+ if (spanW > tableW - cw[0]) { var add = (spanW - (tableW - cw[0])) / (pl.nc - 1); for (var c3 = 1; c3 < pl.nc; c3++) cw[c3] += add; tableW = spanW + cw[0]; }
214
+ // spread the value columns over the width the element has, up to 1.4 times what they need
215
+ var room = W - 4 - tableW;
216
+ if (room > 0) { var grow = Math.min(room, (tableW - cw[0]) * 0.4) / (pl.nc - 1); for (var c4 = 1; c4 < pl.nc; c4++) cw[c4] += grow; tableW += grow * (pl.nc - 1); }
217
+ var tableH = rh.reduce(function(a, b){ return a + b; }, 0), belowH = pl.below.length ? 14 + pl.below.length * Math.ceil(fs * 1.35) : 0;
218
+ var needH = tableH + belowH + 8;
219
+ if (!force && (tableW > W - 2 || needH > H)) return null;
220
+ // fill the element's height: the body rows grow, each to at most 1.8 times its height (no wide empty band under a short table)
221
+ if (needH < H) {
222
+ var nb = pl.nr - pl.head.rows, each = Math.min((H - needH) / nb, Math.min.apply(null, rh.slice(pl.head.rows)) * 0.8);
223
+ for (var r2 = pl.head.rows; r2 < pl.nr; r2++) rh[r2] += each;
224
+ tableH += each * nb; needH += each * nb;
225
+ }
226
+ var x0 = Math.max(1, (W - tableW) / 2), xs = [x0], ys = [4];
227
+ cw.forEach(function(w, i){ xs.push(xs[i] + w); });
228
+ rh.forEach(function(h, i){ ys.push(ys[i] + h); });
229
+ return {fs: fs, pad: pad, xs: xs, ys: ys, tableW: tableW, needH: needH, tableBottom: ys[ys.length - 1]};
230
+ }
231
+ duration(k){ return k >= 1 && k <= this.plan().steps ? this.props.dur : 0; }
232
+ render(k, t, ctx){
233
+ if (!this.cellEls) return;
234
+ var D = base, P = this.props, N = this.plan().steps, faint = ctx && (ctx.preview || ctx.mode === "lecture") ? base.previewOpacity(this) : 0;
235
+ k = Math.max(0, Math.min(k, N));
236
+ var e = k === 0 ? 1 : D.prog(t, 0, P.dur);
237
+ var op = function(st){ var v = st === 0 || st < k ? 1 : st > k ? 0 : e; return Math.max(v, st > k ? faint : 0); };
238
+ this.cellEls.forEach(function(o){ o.g.setAttribute("opacity", op(o.x.step).toFixed(3)); });
239
+ if (this.frame) this.frame.setAttribute("opacity", (this.frameStep > k ? 0 : this.frameStep < k ? 1 : e).toFixed(3));
240
+ this.belowEls.forEach(function(o){ o.t.setAttribute("opacity", op(o.o.step).toFixed(3)); });
241
+ }
242
+ };
243
+ });
@@ -0,0 +1,107 @@
1
+ // code-core 1.0.0: shared code drawing for m-code and m-trace (a library part, Egatari spec §6.1). Pure functions of their
2
+ // arguments except wrap, which measures prose with base.textWidth. No DOM is created here and no state is kept.
3
+ // Moved verbatim from m-code 2.1.0 (lines, monoWidth, cut, the colour roles of KEYWORDS / dialect / spans, wrap) so that m-code
4
+ // 2.2.0 draws the same pixels; new in 1.0.0: softWrap (visual rows of a long code line) and windowFor (the lines a moving
5
+ // window shows for a step).
6
+ // returns {MONO, set, lines, monoWidth, cut, dialect, spans, wrap, softWrap, windowFor}
7
+ egatariParts.define({name: "code-core", version: "1.0.1", requires: {base: "1.3.0"}}, function(deps){
8
+ "use strict";
9
+ var base = deps.base, MONO = 'ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace';
10
+ function set(e, a, v){ e.setAttribute(a, String(v)); }
11
+ function lines(s){ return s.replace(/\r\n?/g, "\n").split("\n"); }
12
+ function monoWidth(s, fs){ return [...s].reduce(function(w, ch){ return w + (/[\u0000-\u024f]/.test(ch) ? 0.6 : 1); }, 0) * fs; }
13
+ function cut(s, w, fs){
14
+ if (monoWidth(s, fs) <= w) return s;
15
+ var ch = [...s];
16
+ while (ch.length && monoWidth(ch.join("") + "…", fs) > w) ch.pop();
17
+ return w >= fs ? ch.join("") + "…" : "";
18
+ }
19
+ // Colour roles for code: keywords term, strings accent2, comments muted (theme roles only; the text stays readable without colour).
20
+ var KEYWORDS = {
21
+ python: "False None True and as assert async await break class continue def del elif else except finally for from global if import in is lambda nonlocal not or pass raise return try while with yield",
22
+ js: "async await break case catch class const continue default delete do else export extends false finally for function if import in instanceof let new null of return super switch this throw true try typeof undefined var void while yield",
23
+ r: "if else repeat while function for in next break TRUE FALSE NULL Inf NaN NA return",
24
+ shell: "if then else elif fi case esac for while until do done in function return export local"
25
+ };
26
+ function dialect(lang){ return lang === "javascript" ? "js" : lang === "sh" || lang === "bash" ? "shell" : KEYWORDS[lang] ? lang : ""; }
27
+ // Split each line into [start, end, role] spans: strings (also across lines for Python triple quotes / JS templates),
28
+ // line comments outside strings, keywords outside both. Unknown languages give no spans.
29
+ function spans(program, lang){
30
+ var L = dialect(lang), kw = L ? new Set(KEYWORDS[L].split(" ")) : null, quote = "", triple = false;
31
+ return program.map(function(s){
32
+ var out = [], from = quote ? 0 : -1;
33
+ if (!L) return out;
34
+ for (var i = 0; i < s.length; i++){
35
+ var c = s[i];
36
+ if (quote){
37
+ if (c === "\\"){ i++; continue; }
38
+ if (c === quote && (!triple || s.slice(i, i + 3) === quote.repeat(3))){ i += triple ? 2 : 0; out.push([from, i + 1, "accent2"]); quote = ""; triple = false; }
39
+ } else if (c === '"' || c === "'" || L === "js" && c === "`"){
40
+ from = i; quote = c; triple = L === "python" && s.slice(i, i + 3) === c.repeat(3); if (triple) i += 2;
41
+ } else if (L !== "js" && c === "#" && (L !== "shell" || i === 0 || /\s/.test(s[i - 1])) || L === "js" && s.slice(i, i + 2) === "//"){
42
+ out.push([i, s.length, "muted"]); return out;
43
+ } else if (/[A-Za-z_]/.test(c) && (i === 0 || !/[\w.$]/.test(s[i - 1]))){
44
+ var m = /^[A-Za-z_]\w*/.exec(s.slice(i))[0];
45
+ if (kw.has(m)) out.push([i, i + m.length, "term"]);
46
+ i += m.length - 1;
47
+ }
48
+ }
49
+ if (quote){ out.push([from, s.length, "accent2"]); if (!triple && quote !== "`") quote = ""; }
50
+ return out;
51
+ });
52
+ }
53
+ // Wrap prose on words where possible, falling back to characters for Japanese / long tokens.
54
+ function wrap(s, w, fs, font){
55
+ var out = [];
56
+ lines(s).forEach(function(p){
57
+ var rest = [...p];
58
+ while (rest.length){
59
+ var n = 0;
60
+ while (n < rest.length && base.textWidth(rest.slice(0, n + 1).join(""), fs, {font: font}) <= w) n++;
61
+ n = Math.max(1, n);
62
+ if (n < rest.length){ var space = rest.slice(0, n + 1).lastIndexOf(" "); if (space > 0) n = space; }
63
+ out.push(rest.splice(0, n).join("").trimEnd());
64
+ while (rest[0] === " ") rest.shift();
65
+ }
66
+ if (!p) out.push("");
67
+ });
68
+ return out;
69
+ }
70
+ // Visual rows of one code line (tabs already expanded) that fit `width` px at `fs` px: break after the last space, comma or
71
+ // opening bracket that fits, else at the width. → [{from, to}] character offsets into the line (code points), at least one row.
72
+ function softWrap(s, width, fs){
73
+ var ch = [...s], out = [], from = 0;
74
+ if (!ch.length) return [{from: 0, to: 0}];
75
+ while (from < ch.length){
76
+ var n = 0;
77
+ while (from + n < ch.length && monoWidth(ch.slice(from, from + n + 1).join(""), fs) <= width) n++;
78
+ n = Math.max(1, n);
79
+ if (from + n < ch.length){
80
+ for (var k = n; k > Math.floor(n / 3); k--){ if (/[ ,([{]/.test(ch[from + k - 1])){ n = k; break; } }
81
+ }
82
+ out.push({from: from, to: from + n}); from += n;
83
+ }
84
+ return out;
85
+ }
86
+ // The rows a moving window of `slots` rows shows so that rows ra..rb are visible, centred where possible. A hidden part
87
+ // above or below costs one row for its "⋮" marker. → {f, l, top, bottom, fits}: rows f..l are shown; top / bottom are true when
88
+ // a marker sits above / below them; fits is false when ra..rb is taller than the window (then the window starts at ra).
89
+ function windowFor(n, slots, ra, rb){
90
+ if (n <= slots) return {f: 0, l: n - 1, top: false, bottom: false, fits: true};
91
+ var best = null;
92
+ for (var f = 0; f < n; f++){
93
+ var top = f > 0, room = slots - (top ? 1 : 0), l = f + room - 1, bottom = l < n - 1;
94
+ if (bottom) l -= 1;
95
+ if (l >= n - 1){ l = n - 1; bottom = false; }
96
+ if (l < f) continue;
97
+ // まず表示する範囲を埋める(空いた行が少ない方)、次に中心が近い方
98
+ var unused = slots - (top ? 1 : 0) - (bottom ? 1 : 0) - (l - f + 1), fits = ra >= f && rb <= l, score = unused * 1000 + Math.abs((f + l) / 2 - (ra + rb) / 2);
99
+ if (fits && (!best || score < best.score - 1e-9)) best = {f: f, l: l, top: top, bottom: bottom, fits: true, score: score};
100
+ }
101
+ if (best){ delete best.score; return best; }
102
+ var f2 = Math.max(0, Math.min(ra, n - 1)), top2 = f2 > 0, l2 = Math.min(n - 1, f2 + slots - (top2 ? 1 : 0) - 1), bottom2 = l2 < n - 1;
103
+ if (bottom2) l2 -= 1;
104
+ return {f: f2, l: Math.max(f2, l2), top: top2, bottom: bottom2, fits: false};
105
+ }
106
+ return {MONO: MONO, set: set, lines: lines, monoWidth: monoWidth, cut: cut, dialect: dialect, spans: spans, wrap: wrap, softWrap: softWrap, windowFor: windowFor};
107
+ });
@@ -0,0 +1,31 @@
1
+ ---
2
+ summary: Outcomes → values → distribution
3
+ steps: Outcomes → arrows → groups → bars (4)
4
+ props:
5
+ dur: Motion s
6
+ stagger: Arrow delay s
7
+ digits: Decimals
8
+ size: Text px
9
+ example: {"outcomes":[{"label":"HH","x":2},{"label":"HT","x":1},{"label":"TH","x":1},{"label":"TT","x":0}],"name":"X","unit":"","fractions":true}
10
+ ---
11
+ - `outcomes`: 2–12; `label`, `x`, `p` (default equal; sum ≠ 1 reported)
12
+ - `name` (X), `fractions`
13
+ - `picture`: `dots`, `grapes`, `dice`, `coins`, `balls` (colour names; 11 basic)
14
+
15
+ <!-- llm: omit -->
16
+ For introductory probability. Left: Ω; centre: values; right: distribution. Chips → arrows → shared colours, counts and sums → bars, end labels and total. Final state stands alone; no answer preview.
17
+
18
+ - `outcomes`: 2–12 items; short `label` (≤6 chars advised), finite `x`. Repeated values allowed. Input chip order; numerical axis increases upwards.
19
+ - `p`: optional. All omitted: `1/n`. Mixed: report `data`, missing = 0. Sum outside 1±1e-9 or p outside 0–1: report, retain values. No normalization.
20
+ - `name`: X; `unit`: suffix, default empty. Literal labels.
21
+ - `fractions`: defaults true for equal probabilities. Reduced fractions: denominator ≤10000, error ≤1e-9; otherwise `digits` decimals. Invalid totals stay unrounded.
22
+ - `picture`: draw outcomes: `dots`/`grapes` (x items, 0–15), `dice` (label face 1–6), `coins` (◯ heads, ● tails), `balls` (colour names per outcome `balls` or label characters; 11 basic colours; name shown)
23
+
24
+ Equal probabilities: shown once in the title. Colours cycle series-1..4 by ascending value. Bar scale includes 0–1; extends for invalid data.
25
+
26
+ About 1184×440px for 4 outcomes; rows ≥40px; tight space reports `size`.
27
+
28
+ Fictional grapes: X = berries per bunch.
29
+
30
+ Keep enough height for probabilities below chip labels.
31
+ <!-- llm: end -->