allyhub 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (582) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/commands/auth.js +4 -4
  3. package/dist/commands/cloud-tools.js +11 -11
  4. package/dist/commands/dev.js +2 -2
  5. package/dist/commands/frames/compare.js +2 -2
  6. package/dist/commands/frames/piece.js +1 -1
  7. package/dist/commands/frames/report.js +2 -0
  8. package/dist/commands/frames.js +11 -9
  9. package/dist/commands/index.js +1 -1
  10. package/dist/commands/inspect/common.js +4 -2
  11. package/dist/commands/inspect/facts.js +3 -3
  12. package/dist/commands/inspect/layout.js +1 -1
  13. package/dist/commands/orgs.js +2 -2
  14. package/dist/commands/render.js +2 -2
  15. package/dist/help.js +4 -4
  16. package/dist/main.js +8 -7
  17. package/dist/node_modules/@allyhub/3d-extension/dist/stage-routes.js +1 -1
  18. package/dist/node_modules/@allyhub/3d-extension/package.json +34 -2
  19. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  20. package/dist/node_modules/@allyhub/browser/dist/emoji.d.ts +29 -0
  21. package/dist/node_modules/@allyhub/browser/dist/emoji.js +57 -0
  22. package/dist/node_modules/@allyhub/browser/dist/picture.d.ts +18 -0
  23. package/dist/node_modules/@allyhub/browser/dist/picture.js +2 -0
  24. package/dist/node_modules/@allyhub/browser/package.json +9 -1
  25. package/dist/node_modules/@allyhub/build/dist/index.d.ts +1 -0
  26. package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
  27. package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +7 -0
  28. package/dist/node_modules/@allyhub/build/dist/made-notes.d.ts +9 -0
  29. package/dist/node_modules/@allyhub/build/dist/made-notes.js +2 -0
  30. package/dist/node_modules/@allyhub/build/dist/project-tool.d.ts +17 -0
  31. package/dist/node_modules/@allyhub/build/dist/stage-route.d.ts +7 -0
  32. package/dist/node_modules/@allyhub/build/package.json +1 -1
  33. package/dist/node_modules/@allyhub/canvas-extension/package.json +2 -1
  34. package/dist/node_modules/@allyhub/canvas-extension/skills/allyhub/references/canvas.md +4 -24
  35. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  36. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
  37. package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
  38. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  39. package/dist/node_modules/@allyhub/check/package.json +1 -1
  40. package/dist/node_modules/@allyhub/cloud/dist/client.d.ts +10 -0
  41. package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
  42. package/dist/node_modules/@allyhub/cloud/dist/config.d.ts +9 -0
  43. package/dist/node_modules/@allyhub/cloud/dist/config.js +1 -1
  44. package/dist/node_modules/@allyhub/cloud/dist/credentials.d.ts +4 -4
  45. package/dist/node_modules/@allyhub/cloud/dist/credentials.js +2 -2
  46. package/dist/node_modules/@allyhub/cloud/dist/device.d.ts +12 -0
  47. package/dist/node_modules/@allyhub/cloud/dist/device.js +2 -0
  48. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  49. package/dist/node_modules/@allyhub/components/package.json +1 -1
  50. package/dist/node_modules/@allyhub/components/r/callout.json +1 -1
  51. package/dist/node_modules/@allyhub/components/src/callout.ts +98 -13
  52. package/dist/node_modules/@allyhub/dev-server/dist/exports.js +1 -1
  53. package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
  54. package/dist/node_modules/@allyhub/dev-server/dist/inputs.js +2 -0
  55. package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
  56. package/dist/node_modules/@allyhub/dev-server/dist/pages.js +2 -0
  57. package/dist/node_modules/@allyhub/dev-server/dist/ports.js +2 -0
  58. package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
  59. package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
  60. package/dist/node_modules/@allyhub/dev-server/dist/respond.js +2 -0
  61. package/dist/node_modules/@allyhub/dev-server/dist/reveal.js +1 -1
  62. package/dist/node_modules/@allyhub/dev-server/dist/routes.js +1 -1
  63. package/dist/node_modules/@allyhub/dev-server/dist/server.js +2 -2
  64. package/dist/node_modules/@allyhub/dev-server/dist/tools.js +1 -1
  65. package/dist/node_modules/@allyhub/dev-server/dist/watcher.js +1 -1
  66. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  67. package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +7 -0
  68. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  69. package/dist/node_modules/@allyhub/doc/dist/captions.js +1 -1
  70. package/dist/node_modules/@allyhub/doc/dist/docx.js +4 -4
  71. package/dist/node_modules/@allyhub/doc/dist/html.js +51 -92
  72. package/dist/node_modules/@allyhub/doc/dist/model.js +1 -1
  73. package/dist/node_modules/@allyhub/doc/dist/page.js +1 -1
  74. package/dist/node_modules/@allyhub/doc/dist/paper.js +1 -1
  75. package/dist/node_modules/@allyhub/doc/dist/table.js +1 -1
  76. package/dist/node_modules/@allyhub/doc/dist/write.js +22 -22
  77. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  78. package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
  79. package/dist/node_modules/@allyhub/doc-extension/package.json +19 -6
  80. package/dist/node_modules/@allyhub/doc-print/dist/pages.js +5 -5
  81. package/dist/node_modules/@allyhub/doc-print/dist/print.js +10 -10
  82. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  83. package/dist/node_modules/@allyhub/export/dist/export.js +1 -1
  84. package/dist/node_modules/@allyhub/export/package.json +1 -1
  85. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  86. package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
  87. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  88. package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
  89. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +87 -1
  90. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  91. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +89 -0
  92. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  93. package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +20 -0
  94. package/dist/node_modules/@allyhub/formats/dist/note-shape.js +1 -1
  95. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +50 -0
  96. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  97. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  98. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  99. package/dist/node_modules/@allyhub/image-extension/dist/export.js +4 -1
  100. package/dist/node_modules/@allyhub/image-extension/package.json +16 -6
  101. package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +7 -39
  102. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  103. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  104. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  105. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  106. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  107. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  108. package/dist/node_modules/@allyhub/linkedin-extension/LICENSE +241 -0
  109. package/dist/node_modules/@allyhub/linkedin-extension/dist/article-build.js +2 -0
  110. package/dist/node_modules/@allyhub/linkedin-extension/dist/article-kind.js +2 -0
  111. package/dist/node_modules/@allyhub/linkedin-extension/dist/build-plugins.js +2 -0
  112. package/dist/node_modules/@allyhub/linkedin-extension/dist/build.js +5 -0
  113. package/dist/node_modules/@allyhub/linkedin-extension/dist/media.js +2 -0
  114. package/dist/node_modules/@allyhub/linkedin-extension/dist/stage-module.js +82 -0
  115. package/dist/node_modules/@allyhub/linkedin-extension/dist/stage.js +2 -0
  116. package/dist/node_modules/@allyhub/linkedin-extension/dist/workspace.js +2 -0
  117. package/dist/node_modules/@allyhub/linkedin-extension/package.json +287 -0
  118. package/dist/node_modules/@allyhub/linkedin-extension/skills/allyhub/references/linkedin.md +12 -0
  119. package/dist/node_modules/@allyhub/linkedin-model/LICENSE +241 -0
  120. package/dist/node_modules/@allyhub/linkedin-model/dist/article-check.js +5 -0
  121. package/dist/node_modules/@allyhub/linkedin-model/dist/article.js +3 -0
  122. package/dist/node_modules/@allyhub/linkedin-model/dist/check.js +2 -0
  123. package/dist/node_modules/@allyhub/linkedin-model/dist/count.js +3 -0
  124. package/dist/node_modules/@allyhub/linkedin-model/dist/edit.js +3 -0
  125. package/dist/node_modules/@allyhub/linkedin-model/dist/html.js +19 -0
  126. package/dist/node_modules/@allyhub/linkedin-model/dist/index.js +2 -0
  127. package/dist/node_modules/@allyhub/linkedin-model/dist/limits.js +2 -0
  128. package/dist/node_modules/@allyhub/linkedin-model/dist/little.js +2 -0
  129. package/dist/node_modules/@allyhub/linkedin-model/dist/post.js +2 -0
  130. package/dist/node_modules/@allyhub/linkedin-model/dist/requests.js +2 -0
  131. package/dist/node_modules/@allyhub/linkedin-model/package.json +14 -0
  132. package/dist/node_modules/@allyhub/linkedin-view/LICENSE +241 -0
  133. package/dist/node_modules/@allyhub/linkedin-view/dist/article.js +2 -0
  134. package/dist/node_modules/@allyhub/linkedin-view/dist/fold.js +3 -0
  135. package/dist/node_modules/@allyhub/linkedin-view/dist/index.js +2 -0
  136. package/dist/node_modules/@allyhub/linkedin-view/dist/post.js +2 -0
  137. package/dist/node_modules/@allyhub/linkedin-view/dist/stage.js +2 -0
  138. package/dist/node_modules/@allyhub/linkedin-view/dist/text.js +2 -0
  139. package/dist/node_modules/@allyhub/linkedin-view/package.json +21 -0
  140. package/dist/node_modules/@allyhub/linkedin-view/src/style.css +600 -0
  141. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  142. package/dist/node_modules/@allyhub/media/package.json +1 -1
  143. package/dist/node_modules/@allyhub/media-extension/dist/vision/faces.js +1 -1
  144. package/dist/node_modules/@allyhub/media-extension/package.json +7 -4
  145. package/dist/node_modules/@allyhub/model/package.json +1 -1
  146. package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
  147. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  148. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +2 -0
  149. package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +16 -0
  150. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -1
  151. package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
  152. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +14 -1
  153. package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
  154. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +18 -0
  155. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  156. package/dist/node_modules/@allyhub/project/dist/version.js +1 -1
  157. package/dist/node_modules/@allyhub/project/package.json +1 -1
  158. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +140 -0
  159. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  160. package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
  161. package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
  162. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +157 -0
  163. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  164. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +10 -2
  165. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  166. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +101 -186
  167. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  168. package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +1 -0
  169. package/dist/node_modules/@allyhub/protocol/dist/mail.js +1 -1
  170. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +92 -94
  171. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  172. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +17 -0
  173. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  174. package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +7 -0
  175. package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
  176. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +15 -3
  177. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  178. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  179. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  180. package/dist/node_modules/@allyhub/render/dist/encode.js +1 -1
  181. package/dist/node_modules/@allyhub/render/dist/index.js +1 -1
  182. package/dist/node_modules/@allyhub/render/dist/look.js +1 -1
  183. package/dist/node_modules/@allyhub/render/dist/render.js +2 -2
  184. package/dist/node_modules/@allyhub/render/package.json +1 -1
  185. package/dist/node_modules/@allyhub/report-extension/LICENSE +241 -0
  186. package/dist/node_modules/@allyhub/report-extension/dist/build.js +2 -0
  187. package/dist/node_modules/@allyhub/report-extension/dist/check.js +3 -0
  188. package/dist/node_modules/@allyhub/report-extension/dist/cli/find.js +2 -0
  189. package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +5 -0
  190. package/dist/node_modules/@allyhub/report-extension/dist/cli/picture.js +2 -0
  191. package/dist/node_modules/@allyhub/report-extension/dist/export.js +2 -0
  192. package/dist/node_modules/@allyhub/report-extension/dist/inline.js +58 -0
  193. package/dist/node_modules/@allyhub/report-extension/dist/page.js +21 -0
  194. package/dist/node_modules/@allyhub/report-extension/dist/project-tools.js +21 -0
  195. package/dist/node_modules/@allyhub/report-extension/dist/styles.js +5 -0
  196. package/dist/node_modules/@allyhub/report-extension/dist/theme.js +2 -0
  197. package/dist/node_modules/@allyhub/report-extension/dist/tools.js +2 -0
  198. package/dist/node_modules/@allyhub/report-extension/dist/workspace.js +2 -0
  199. package/dist/node_modules/@allyhub/report-extension/package.json +182 -0
  200. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +132 -0
  201. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.css +105 -0
  202. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +17 -0
  203. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/tokens.js +38 -0
  204. package/dist/node_modules/@allyhub/runtime/dist/compose.js +1 -1
  205. package/dist/node_modules/@allyhub/runtime/dist/embed.js +1 -1
  206. package/dist/node_modules/@allyhub/runtime/dist/player/clips.js +1 -1
  207. package/dist/node_modules/@allyhub/runtime/dist/player/player.js +1 -1
  208. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  209. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  210. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  211. package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
  212. package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
  213. package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
  214. package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
  215. package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
  216. package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
  217. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  218. package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.d.ts +7 -0
  219. package/dist/node_modules/@allyhub/scenery-host/dist/layer/grade.js +2 -0
  220. package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.d.ts +4 -3
  221. package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.js +1 -1
  222. package/dist/node_modules/@allyhub/scenery-host/dist/layer/screens.d.ts +1 -1
  223. package/dist/node_modules/@allyhub/scenery-host/dist/layer/screens.js +1 -1
  224. package/dist/node_modules/@allyhub/scenery-host/dist/measure/facts.js +1 -1
  225. package/dist/node_modules/@allyhub/scenery-host/dist/page/screens.d.ts +8 -0
  226. package/dist/node_modules/@allyhub/scenery-host/dist/page/screens.js +1 -1
  227. package/dist/node_modules/@allyhub/scenery-host/dist/viewer.d.ts +6 -0
  228. package/dist/node_modules/@allyhub/scenery-host/dist/viewer.js +1 -1
  229. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  230. package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
  231. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  232. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
  233. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
  234. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.js +1 -1
  235. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
  236. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/kernels.js +1 -1
  237. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
  238. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/maths.js +1 -1
  239. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
  240. package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
  241. package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
  242. package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
  243. package/dist/node_modules/@allyhub/sheet/dist/export.js +2 -4
  244. package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
  245. package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
  246. package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
  247. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  248. package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
  249. package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
  250. package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
  251. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  252. package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
  253. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  254. package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
  255. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  256. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  257. package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.js +3 -1
  258. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  259. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  260. package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
  261. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  262. package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +2 -6
  263. package/dist/node_modules/@allyhub/sheet-extension/package.json +24 -9
  264. package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
  265. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  266. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  267. package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
  268. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  269. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
  270. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  271. package/dist/node_modules/@allyhub/slides-extension/dist/export.js +1 -1
  272. package/dist/node_modules/@allyhub/slides-extension/package.json +22 -16
  273. package/dist/node_modules/@allyhub/slides-pptx/dist/import/code.js +2 -2
  274. package/dist/node_modules/@allyhub/slides-pptx/dist/import/index.js +2 -2
  275. package/dist/node_modules/@allyhub/slides-pptx/dist/read/common.js +1 -1
  276. package/dist/node_modules/@allyhub/slides-pptx/dist/read/shapes.js +1 -1
  277. package/dist/node_modules/@allyhub/slides-pptx/dist/read/text.js +1 -1
  278. package/dist/node_modules/@allyhub/slides-pptx/dist/shapes.js +1 -1
  279. package/dist/node_modules/@allyhub/slides-pptx/dist/text.js +1 -1
  280. package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
  281. package/dist/node_modules/@allyhub/slides-pptx/dist/xml.js +1 -1
  282. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  283. package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
  284. package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
  285. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  286. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  287. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400-italic.css +19 -0
  288. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/400.css +19 -0
  289. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700-italic.css +19 -0
  290. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/700.css +19 -0
  291. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/LICENSE +93 -0
  292. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/cambria.css +76 -0
  293. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-400-italic.woff2 +0 -0
  294. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-400-normal.woff2 +0 -0
  295. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-700-italic.woff2 +0 -0
  296. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-700-normal.woff2 +0 -0
  297. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-400-italic.woff2 +0 -0
  298. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-400-normal.woff2 +0 -0
  299. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-700-italic.woff2 +0 -0
  300. package/dist/node_modules/@allyhub/stage-page/dist/fonts/caladea/files/caladea-latin-ext-700-normal.woff2 +0 -0
  301. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400-italic.css +79 -0
  302. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/400.css +79 -0
  303. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700-italic.css +79 -0
  304. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/700.css +79 -0
  305. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/LICENSE +93 -0
  306. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/courier-new.css +316 -0
  307. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-400-italic.woff2 +0 -0
  308. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-400-normal.woff2 +0 -0
  309. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-700-italic.woff2 +0 -0
  310. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-700-normal.woff2 +0 -0
  311. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-400-italic.woff2 +0 -0
  312. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-400-normal.woff2 +0 -0
  313. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-700-italic.woff2 +0 -0
  314. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-cyrillic-ext-700-normal.woff2 +0 -0
  315. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-400-italic.woff2 +0 -0
  316. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-400-normal.woff2 +0 -0
  317. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-700-italic.woff2 +0 -0
  318. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-700-normal.woff2 +0 -0
  319. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-400-italic.woff2 +0 -0
  320. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-400-normal.woff2 +0 -0
  321. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-700-italic.woff2 +0 -0
  322. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-greek-ext-700-normal.woff2 +0 -0
  323. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-400-italic.woff2 +0 -0
  324. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-400-normal.woff2 +0 -0
  325. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-700-italic.woff2 +0 -0
  326. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-hebrew-700-normal.woff2 +0 -0
  327. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-400-italic.woff2 +0 -0
  328. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-400-normal.woff2 +0 -0
  329. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-700-italic.woff2 +0 -0
  330. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-700-normal.woff2 +0 -0
  331. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-400-italic.woff2 +0 -0
  332. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-400-normal.woff2 +0 -0
  333. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-700-italic.woff2 +0 -0
  334. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-latin-ext-700-normal.woff2 +0 -0
  335. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-400-italic.woff2 +0 -0
  336. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-400-normal.woff2 +0 -0
  337. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-700-italic.woff2 +0 -0
  338. package/dist/node_modules/@allyhub/stage-page/dist/fonts/cousine/files/cousine-vietnamese-700-normal.woff2 +0 -0
  339. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400-italic.css +79 -0
  340. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/400.css +79 -0
  341. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700-italic.css +79 -0
  342. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/700.css +79 -0
  343. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/LICENSE +93 -0
  344. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-400-italic.woff2 +0 -0
  345. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-400-normal.woff2 +0 -0
  346. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-700-italic.woff2 +0 -0
  347. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-700-normal.woff2 +0 -0
  348. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-400-italic.woff2 +0 -0
  349. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-400-normal.woff2 +0 -0
  350. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-700-italic.woff2 +0 -0
  351. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-cyrillic-ext-700-normal.woff2 +0 -0
  352. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-400-italic.woff2 +0 -0
  353. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-400-normal.woff2 +0 -0
  354. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-700-italic.woff2 +0 -0
  355. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-700-normal.woff2 +0 -0
  356. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-400-italic.woff2 +0 -0
  357. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-400-normal.woff2 +0 -0
  358. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-700-italic.woff2 +0 -0
  359. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-greek-ext-700-normal.woff2 +0 -0
  360. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-400-italic.woff2 +0 -0
  361. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-400-normal.woff2 +0 -0
  362. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-700-italic.woff2 +0 -0
  363. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-hebrew-700-normal.woff2 +0 -0
  364. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-400-italic.woff2 +0 -0
  365. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-400-normal.woff2 +0 -0
  366. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-700-italic.woff2 +0 -0
  367. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-700-normal.woff2 +0 -0
  368. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-400-italic.woff2 +0 -0
  369. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-400-normal.woff2 +0 -0
  370. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-700-italic.woff2 +0 -0
  371. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-latin-ext-700-normal.woff2 +0 -0
  372. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-400-italic.woff2 +0 -0
  373. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-400-normal.woff2 +0 -0
  374. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-700-italic.woff2 +0 -0
  375. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/files/tinos-vietnamese-700-normal.woff2 +0 -0
  376. package/dist/node_modules/@allyhub/stage-page/dist/fonts/tinos/times-new-roman.css +316 -0
  377. package/dist/node_modules/@allyhub/stage-page/dist/host.js +1 -1
  378. package/dist/node_modules/@allyhub/stage-page/dist/install.js +1 -1
  379. package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.html +3 -0
  380. package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.js +1 -1
  381. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  382. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +18 -18
  383. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  384. package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
  385. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  386. package/dist/node_modules/@allyhub/video-extension/dist/export.js +1 -1
  387. package/dist/node_modules/@allyhub/video-extension/package.json +17 -4
  388. package/dist/node_modules/@allyhub/video-measure/dist/version.js +1 -1
  389. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  390. package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +1 -1
  391. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  392. package/dist/node_modules/@allyhub/website/package.json +1 -1
  393. package/dist/node_modules/@allyhub/website-extension/dist/held.js +2 -0
  394. package/dist/node_modules/@allyhub/website-extension/dist/preview.js +5 -5
  395. package/dist/node_modules/@allyhub/website-extension/dist/project-tools.js +24 -1
  396. package/dist/node_modules/@allyhub/website-extension/dist/tools.js +1 -1
  397. package/dist/node_modules/@allyhub/website-extension/package.json +49 -2
  398. package/dist/node_modules/@allyhub/x-extension/dist/build.js +4 -3
  399. package/dist/node_modules/@allyhub/x-extension/package.json +43 -15
  400. package/dist/node_modules/@allyhub/x-extension/skills/allyhub/references/x.md +7 -62
  401. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  402. package/dist/node_modules/@allyhub/x-view/dist/article.js +1 -1
  403. package/dist/node_modules/@allyhub/x-view/dist/index.js +1 -1
  404. package/dist/node_modules/@allyhub/x-view/dist/post.js +2 -2
  405. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  406. package/dist/package.json +12 -10
  407. package/dist/text/facts-text.js +5 -5
  408. package/dist/text/index.js +1 -1
  409. package/dist/text/long-text.js +4 -0
  410. package/dist/works.js +1 -1
  411. package/editor-web/assets/{abnfDiagram-WEYOIA3C-CN5PiJYY.js → abnfDiagram-WEYOIA3C-BKmMA6gn.js} +1 -1
  412. package/editor-web/assets/{architecture-WOLXFQ4H-BnvZtQYk.js → architecture-WOLXFQ4H-BEFBgb4k.js} +1 -1
  413. package/editor-web/assets/{architectureDiagram-ZHVYKT53-tkcEcFQ8.js → architectureDiagram-ZHVYKT53-_u5YfCjY.js} +1 -1
  414. package/editor-web/assets/{arrow-up-DTP2yVSU.js → arrow-up-B5rJbBv0.js} +1 -1
  415. package/editor-web/assets/article-BUmD3xtR.js +8 -0
  416. package/editor-web/assets/article-DNioBb3p.js +7 -0
  417. package/editor-web/assets/{audio-lines-Ti8-m7H2.js → audio-lines-CzuzsGjI.js} +1 -1
  418. package/editor-web/assets/{blockDiagram-RJAE7QA3-DhqEIpie.js → blockDiagram-RJAE7QA3-DybfaO3Z.js} +1 -1
  419. package/editor-web/assets/bookmark-Dsd3kHJJ.js +1 -0
  420. package/editor-web/assets/button-eGxLxbv9.js +41 -0
  421. package/editor-web/assets/{c4Diagram-XDPPPE54-Bg9G95tl.js → c4Diagram-XDPPPE54-BfqLHB5i.js} +1 -1
  422. package/editor-web/assets/calc-worker-D2pGis6e.js +45 -0
  423. package/editor-web/assets/channel-TNPgFDrw.js +1 -0
  424. package/editor-web/assets/chart-C37xvZT2.js +1 -0
  425. package/editor-web/assets/chart-no-axes-column-BVkeF_Mr.js +1 -0
  426. package/editor-web/assets/{chunk-2E7WHVMD-C8Ve9lAa.js → chunk-2E7WHVMD-BVp1I_d0.js} +1 -1
  427. package/editor-web/assets/{chunk-4EMNKR2T-BDWwPUnT.js → chunk-4EMNKR2T-CTdgWEMr.js} +1 -1
  428. package/editor-web/assets/{chunk-55XCU76K-BQiNPKgx.js → chunk-55XCU76K-7pnsxeaP.js} +1 -1
  429. package/editor-web/assets/{chunk-7S6XSTFO-QoEt-6jf.js → chunk-7S6XSTFO-Dc0Dvkq7.js} +1 -1
  430. package/editor-web/assets/{chunk-AQDTSKZB-BeuwIv0-.js → chunk-AQDTSKZB-VAILIsfx.js} +1 -1
  431. package/editor-web/assets/{chunk-DSNLSHJZ-BHW7sLAz.js → chunk-DSNLSHJZ-CUDx1Rv5.js} +1 -1
  432. package/editor-web/assets/{chunk-HAGFOTED-bbGED0hu.js → chunk-HAGFOTED-DAoEe-dJ.js} +1 -1
  433. package/editor-web/assets/{chunk-HNE4Q36P-FltWp8yo.js → chunk-HNE4Q36P-g0akya12.js} +1 -1
  434. package/editor-web/assets/{chunk-NQOKRVIF-NeQzr6kH.js → chunk-NQOKRVIF-hTGjzXdJ.js} +1 -1
  435. package/editor-web/assets/{chunk-UHW7PFBP-eA4-WUhn.js → chunk-UHW7PFBP-BgLV8BIJ.js} +1 -1
  436. package/editor-web/assets/{chunk-VQ5W62QI-BPPv325z.js → chunk-VQ5W62QI-Bw19OOSD.js} +1 -1
  437. package/editor-web/assets/{chunk-WQQL4CDK-DOCIz7Te.js → chunk-WQQL4CDK-CMST9dyE.js} +1 -1
  438. package/editor-web/assets/{chunk-YZO67HFG-Dc_ihQJi.js → chunk-YZO67HFG-Bbpu36XF.js} +1 -1
  439. package/editor-web/assets/{chunk-ZAUX2LTX-CoqwCPSm.js → chunk-ZAUX2LTX-C48Ri0Gs.js} +1 -1
  440. package/editor-web/assets/{chunk-ZCHMQSOR-CZUQPkJx.js → chunk-ZCHMQSOR-DN1g01Oe.js} +1 -1
  441. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-DUh9c50k.js → classDiagram-v2-4MYWR3UA-U6jbPr2d.js} +1 -1
  442. package/editor-web/assets/collaborator-B1u2td9m.js +1 -0
  443. package/editor-web/assets/createLucideIcon-GFZ_fxLc.js +1 -0
  444. package/editor-web/assets/{cynefin-EF2NZ3EQ-DUTZiog0.js → cynefin-EF2NZ3EQ-gzkai_7-.js} +1 -1
  445. package/editor-web/assets/{cynefinDiagram-WF24UDRP-oAjpfbrU.js → cynefinDiagram-WF24UDRP-DtSekSr6.js} +1 -1
  446. package/editor-web/assets/{dagre-NK4GIZVX-BrKvKCvb.js → dagre-NK4GIZVX-CiUwYVT6.js} +1 -1
  447. package/editor-web/assets/{diagram-CBK3MWTC-GekVRnmm.js → diagram-CBK3MWTC-r9XHCV-k.js} +1 -1
  448. package/editor-web/assets/{diagram-I5XIIV2D-CDd1VFRT.js → diagram-I5XIIV2D-DxVsDZ34.js} +1 -1
  449. package/editor-web/assets/{diagram-ODIL2UCW-535RISTn.js → diagram-ODIL2UCW-B0eNQoHV.js} +1 -1
  450. package/editor-web/assets/{diagram-PFBEJUXE-MXzzKCGG.js → diagram-PFBEJUXE-C7f2MfJT.js} +1 -1
  451. package/editor-web/assets/{diagram-RJA3I4VV-vKVwkQxY.js → diagram-RJA3I4VV-CSXcnvct.js} +1 -1
  452. package/editor-web/assets/{diagram-TYUNFSNR-UwGAiQLx.js → diagram-TYUNFSNR-DXzOD_ii.js} +1 -1
  453. package/editor-web/assets/dist-BGRwhCQO.js +1 -0
  454. package/editor-web/assets/{dist-9ymlIMhr.js → dist-BW4X7BrF.js} +1 -1
  455. package/editor-web/assets/dist-BgDRE85b.js +2 -0
  456. package/editor-web/assets/dist-Blq5nJnU.js +24 -0
  457. package/editor-web/assets/dist-BuWaZ3Y4.js +274 -0
  458. package/editor-web/assets/dist-C1emZ9wX.js +37 -0
  459. package/editor-web/assets/dist-CC7OeU1e.js +6 -0
  460. package/editor-web/assets/dist-CX-fiPSn.js +38 -0
  461. package/editor-web/assets/dist-C_VvG-_9.js +5 -0
  462. package/editor-web/assets/dist-Ce7HrBxv.js +3 -0
  463. package/editor-web/assets/dist-D2k6w-_a.js +1 -0
  464. package/editor-web/assets/dist-DDv_SbKw.js +84 -0
  465. package/editor-web/assets/dist-DEoEO4zs.js +1 -0
  466. package/editor-web/assets/dist-DlDxxPIP.js +16 -0
  467. package/editor-web/assets/dist-Gz6NDS0J.js +4 -0
  468. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-73yGokYa.js → ebnfDiagram-V4P3TTPT-Cs4YRvDD.js} +1 -1
  469. package/editor-web/assets/{elk-QONTBCTQ-BW6V9y6a.js → elk-QONTBCTQ-Bh3LZ9WI.js} +1 -1
  470. package/editor-web/assets/{erDiagram-KYQIGQAA-BPqIJ22h.js → erDiagram-KYQIGQAA-C4vYTYXp.js} +1 -1
  471. package/editor-web/assets/{eventmodeling-K75KTNOO-_VZ8jvuy.js → eventmodeling-K75KTNOO-BN1kkHWS.js} +1 -1
  472. package/editor-web/assets/flowDiagram-IUGLLWBU-B04NGsyi.js +1 -0
  473. package/editor-web/assets/{ganttDiagram-R7GPNTJY-DZ157JN2.js → ganttDiagram-R7GPNTJY-CA1LkkC5.js} +1 -1
  474. package/editor-web/assets/{gitGraph-VSP46ZUC-fmcNL9bq.js → gitGraph-VSP46ZUC-Dy5tA7dG.js} +1 -1
  475. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-DiZDyksR.js → gitGraphDiagram-PDYL7XHY-hJIB8EkH.js} +1 -1
  476. package/editor-web/assets/hint-B8JpEypy.js +1 -0
  477. package/editor-web/assets/index-CgB5osVc.js +28 -0
  478. package/editor-web/assets/index-Daytem9N.css +2 -0
  479. package/editor-web/assets/{info-OHQRW6UA-V06620kN.js → info-OHQRW6UA-DvzSf7rQ.js} +1 -1
  480. package/editor-web/assets/{infoDiagram-MVDRKAX5-CbIgheWX.js → infoDiagram-MVDRKAX5-BjIMm4Af.js} +1 -1
  481. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-D5oJQPkG.js → ishikawaDiagram-HPEHV2GE-Bpz71S40.js} +1 -1
  482. package/editor-web/assets/{italic-CDhZKo_q.js → italic-D10w8n6C.js} +1 -1
  483. package/editor-web/assets/{journeyDiagram-BOSHW7O7-BZEv6JI4.js → journeyDiagram-BOSHW7O7-DAB-pZjD.js} +1 -1
  484. package/editor-web/assets/{kanban-definition-FNSA4HC5-CLG1R8y_.js → kanban-definition-FNSA4HC5-cYeyh3P6.js} +1 -1
  485. package/editor-web/assets/katex-5Z2zF-9g.js +257 -0
  486. package/editor-web/assets/link-BC5xK1-1.js +1 -0
  487. package/editor-web/assets/{mermaid-parser.core-DxDwXM7z.js → mermaid-parser.core-req5LE0X.js} +3 -3
  488. package/editor-web/assets/{mermaid.core-tU55ZwVG.js → mermaid.core-zFwZug4C.js} +4 -4
  489. package/editor-web/assets/{mindmap-definition-6OY57UG3-CYf4zzAh.js → mindmap-definition-6OY57UG3-TStWb7DG.js} +1 -1
  490. package/editor-web/assets/minus-DaWs5i8B.js +1 -0
  491. package/editor-web/assets/{packet-JDAUHWVQ-DsHeKYNL.js → packet-JDAUHWVQ-smFhVKcB.js} +1 -1
  492. package/editor-web/assets/palette-BIOudGkm.js +1 -0
  493. package/editor-web/assets/{pegDiagram-ECIUJNBX-CQyh6TTa.js → pegDiagram-ECIUJNBX-DvSNRv0-.js} +1 -1
  494. package/editor-web/assets/{pie-XZMESJXO-3vCIvpNB.js → pie-XZMESJXO-qjaGsBZG.js} +1 -1
  495. package/editor-web/assets/{pieDiagram-GNMPY74T-DF5yGBLn.js → pieDiagram-GNMPY74T-Dd9P-Pdc.js} +1 -1
  496. package/editor-web/assets/play-CrMmPghG.js +1 -0
  497. package/editor-web/assets/progress-DE4C5_3x.js +6 -0
  498. package/editor-web/assets/props-form-CsmDBqzy.js +1 -0
  499. package/editor-web/assets/{quadrantDiagram-D57K4MC3-B7pxlDYP.js → quadrantDiagram-D57K4MC3-h2IIKUUA.js} +1 -1
  500. package/editor-web/assets/{radar-ABXABTNO-cpEA41mL.js → radar-ABXABTNO-DlVrSA1d.js} +1 -1
  501. package/editor-web/assets/{railroad-I3PHUGI6-BLyy5R2c.js → railroad-I3PHUGI6-nFbuLAtc.js} +1 -1
  502. package/editor-web/assets/{railroad-abnf-LNEFI6M7-Y-oyol19.js → railroad-abnf-LNEFI6M7-Daj8h2iV.js} +1 -1
  503. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-o58wHZsr.js → railroad-ebnf-DWYD2UWJ-eYJyl5PH.js} +1 -1
  504. package/editor-web/assets/{railroad-peg-JR7BVNR7-CcD3PXZ8.js → railroad-peg-JR7BVNR7-BTRhKZQq.js} +1 -1
  505. package/editor-web/assets/{railroadDiagram-Y72NRBL7-BuCC4eyy.js → railroadDiagram-Y72NRBL7-CeLGUjdp.js} +1 -1
  506. package/editor-web/assets/react-WA6wlt8S.js +1 -0
  507. package/editor-web/assets/{repeat-2-C5PCbNsg.js → repeat-2-VQP1EVOZ.js} +1 -1
  508. package/editor-web/assets/{requirementDiagram-EQYSW5RA-Dp-JFGn4.js → requirementDiagram-EQYSW5RA-Dmk9XRM5.js} +1 -1
  509. package/editor-web/assets/row-BRlEWRrK.js +1 -0
  510. package/editor-web/assets/{sankeyDiagram-SY24JHO5-rYuCqEvw.js → sankeyDiagram-SY24JHO5-Yn4zlrAM.js} +1 -1
  511. package/editor-web/assets/schemas-VikZYZIK.js +1 -0
  512. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-DryW8x6d.js → sequenceDiagram-BLEHNHQU-BTRnp_PW.js} +1 -1
  513. package/editor-web/assets/session-Do9AqS38.js +1 -0
  514. package/editor-web/assets/slides-diTEQ3C5.js +1 -0
  515. package/editor-web/assets/snapshots-BUGlKQIB.js +56 -0
  516. package/editor-web/assets/sound-Bj3o9_Fa.js +1 -0
  517. package/editor-web/assets/split-CNU1RHcX.js +3 -0
  518. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-Bnp0XfpT.js → stateDiagram-v2-A6IESKWZ-kstrRKv2.js} +1 -1
  519. package/editor-web/assets/{strikethrough-DJckA35o.js → strikethrough-CfXx6IYH.js} +1 -1
  520. package/editor-web/assets/{svg-BjM9RazX.js → svg-Cx50MpxK.js} +1 -1
  521. package/editor-web/assets/swatch-WeJD41aW.js +1 -0
  522. package/editor-web/assets/{swimlanes-B3ENRKFQ-BiRRhhbd.js → swimlanes-B3ENRKFQ-DaZsZkeP.js} +1 -1
  523. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CBZAujYY.js +8 -0
  524. package/editor-web/assets/switch-N0G_sbqt.js +1 -0
  525. package/editor-web/assets/syntax-BVsgRJ4I.js +66 -0
  526. package/editor-web/assets/syntax-oWsKBWFw.js +1 -0
  527. package/editor-web/assets/table-B6hVZAMi.js +1 -0
  528. package/editor-web/assets/tabs-DIFDqj-l.js +1 -0
  529. package/editor-web/assets/{textarea-BGtPqZdB.js → textarea-tEWvBY9p.js} +1 -1
  530. package/editor-web/assets/{timeline-definition-JXYKGLGB-D-Q5ZtDF.js → timeline-definition-JXYKGLGB-CLCvY-Yf.js} +1 -1
  531. package/editor-web/assets/{trash-2-Bjj6cWzP.js → trash-2-BP6nqpg2.js} +1 -1
  532. package/editor-web/assets/{treeView-D4JQ5SDB-B6DDatXq.js → treeView-D4JQ5SDB-BmN0gwdC.js} +1 -1
  533. package/editor-web/assets/{treemap-SAJKECNS-D7j5ZhiI.js → treemap-SAJKECNS-DN29G_E_.js} +1 -1
  534. package/editor-web/assets/{undo-2-yOSG766T.js → undo-2-CHR0nvWL.js} +1 -1
  535. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-tkrdKUJB.js → usecaseDiagram-WPOLBNNX-DTRS54cB.js} +1 -1
  536. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-Ch4XbSnD.js → vennDiagram-Q3Y3IDCW-DAAc11Hx.js} +1 -1
  537. package/editor-web/assets/video-BlvmR8BK.js +1 -0
  538. package/editor-web/assets/{wardley-7MLQ67FV-Bynt7qNQ.js → wardley-7MLQ67FV-B-UYkmdB.js} +1 -1
  539. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-DRuSgm_L.js → wardleyDiagram-IVAIDKWA-BmbwCaky.js} +1 -1
  540. package/editor-web/assets/words-D_4T9Adq.js +3 -0
  541. package/editor-web/assets/words-WgdEQdYP.js +2 -0
  542. package/editor-web/assets/{xychartDiagram-4URNHDU4-DctpvfkL.js → xychartDiagram-4URNHDU4-ChAfAq1U.js} +1 -1
  543. package/editor-web/index.html +6 -5
  544. package/package.json +8 -2
  545. package/editor-web/assets/alt-BOVao_9S.js +0 -4
  546. package/editor-web/assets/article-B6YCzhj8.js +0 -73
  547. package/editor-web/assets/calc-worker-B5-fDWnb.js +0 -45
  548. package/editor-web/assets/channel-C26aBI4o.js +0 -1
  549. package/editor-web/assets/chart-BOnxneyw.js +0 -1
  550. package/editor-web/assets/choice-O5nwc2N0.js +0 -1
  551. package/editor-web/assets/collaborator-BJU5qwHd.js +0 -1
  552. package/editor-web/assets/createLucideIcon-B3B95oX5.js +0 -1
  553. package/editor-web/assets/dist-C6NqUEG4.js +0 -16
  554. package/editor-web/assets/dist-C9UGmCG9.js +0 -6
  555. package/editor-web/assets/dist-CAk5bjBm.js +0 -1
  556. package/editor-web/assets/dist-CKyfo5RM.js +0 -340
  557. package/editor-web/assets/dist-CRaWqNwq.js +0 -37
  558. package/editor-web/assets/dist-CwIBc7HQ.js +0 -1
  559. package/editor-web/assets/dist-DXRmkezB.js +0 -38
  560. package/editor-web/assets/dist-EKK5i0dG.js +0 -219
  561. package/editor-web/assets/dist-hHJlpLWo.js +0 -5
  562. package/editor-web/assets/dist-oYKcwWUj.js +0 -4
  563. package/editor-web/assets/dist-shKo7XVN.js +0 -2
  564. package/editor-web/assets/dist-wrKxBrVu.js +0 -24
  565. package/editor-web/assets/flowDiagram-IUGLLWBU-ouDQYiTr.js +0 -1
  566. package/editor-web/assets/hint-_AQWCDMj.js +0 -1
  567. package/editor-web/assets/index-BsstP-cI.js +0 -28
  568. package/editor-web/assets/index-DQRcmxBO.css +0 -2
  569. package/editor-web/assets/minus-Cgmm6ncD.js +0 -1
  570. package/editor-web/assets/progress-0B_TVsPi.js +0 -6
  571. package/editor-web/assets/react-BP46yLMB.js +0 -1
  572. package/editor-web/assets/react-pgBZqVxJ.js +0 -96
  573. package/editor-web/assets/schemas-Ewwjtbf4.js +0 -1
  574. package/editor-web/assets/session-DiI9KYRI.js +0 -1
  575. package/editor-web/assets/slides-CCwgBcGH.js +0 -1
  576. package/editor-web/assets/sound-CqryteNl.js +0 -1
  577. package/editor-web/assets/swatch-DL3HqIjW.js +0 -1
  578. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-BkOls8Tv.js +0 -8
  579. package/editor-web/assets/switch-DltnKqN-.js +0 -1
  580. package/editor-web/assets/syntax-CC6QYhCz.js +0 -1
  581. package/editor-web/assets/tabs-C-re0Kxn.js +0 -1
  582. package/editor-web/assets/video-DXFiCNGc.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{homography as I,matrix3d as N,screenFocus as L,SCENERY_RENDERER_DEFAULTS as B}from"@allyhub/scenery";import{addLayerRule as U,layerShown as _,showLayer as j}from"@allyhub/piece";import{coded as H}from"./state.js";export function blurScreen(t,r){if(!r){t.focus&&(t.surface.style.filter="");return}const e=t.el.parentElement;if(!e)return;if(!t.focus){const o=document.createElementNS(P,"svg");o.setAttribute("width","0"),o.setAttribute("height","0"),o.setAttribute("aria-hidden","true"),Object.assign(o.style,{position:"absolute",left:"0",top:"0"}),e.appendChild(o),D+=1,t.focus={svg:o,id:`ak-screen-focus-${String(D)}`,markup:""}}const n=V(t.focus.id,t.size,r);n!==t.focus.markup&&(t.focus.svg.innerHTML=n,t.focus.markup=n),t.surface.style.filter=`url(#${t.focus.id})`}const P="http://www.w3.org/2000/svg";let D=0;const b=t=>{const r=Math.round(t*1e3)/1e3;return String(Object.is(r,-0)?0:r)};function V(t,r,e){const[n,o]=r,i=[],c=e.sigmas.length>1;c&&i.push(`<defs><linearGradient id="${t}-lg" gradientUnits="userSpaceOnUse" x1="${b(e.from[0])}" y1="${b(e.from[1])}" x2="${b(e.to[0])}" y2="${b(e.to[1])}"><stop offset="0" stop-color="#000"/><stop offset="1" stop-color="#fff"/></linearGradient>`,`<rect id="${t}-r" x="0" y="0" width="${b(n)}" height="${b(o)}" fill="url(#${t}-lg)"/></defs>`),i.push(`<filter id="${t}" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">`),c&&i.push(`<feImage href="#${t}-r" result="g"/>`,'<feColorMatrix in="g" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0" result="w"/>');const f=[];e.sigmas.forEach((g,h)=>{const $=e.weights[h]??[];if(c&&!$.some(S=>S>0))return;const w=c?W(e,$,n,o):void 0,p=w?` x="${b(w[0])}" y="${b(w[1])}" width="${b(w[2])}" height="${b(w[3])}"`:"";let y="SourceGraphic";if(g>=.05&&(i.push(`<feGaussianBlur in="SourceGraphic" stdDeviation="${b(g)}"${p} result="b${String(h)}"/>`),y=`b${String(h)}`),!c){f.push(y);return}i.push(`<feComponentTransfer in="w"${p} result="w${String(h)}"><feFuncA type="table" tableValues="${$.map(b).join(" ")}"/></feComponentTransfer>`,`<feComposite in="${y}" in2="w${String(h)}" operator="arithmetic" k1="1"${p} result="m${String(h)}"/>`),f.push(`m${String(h)}`)});let d=f[0]??"SourceGraphic";return f.slice(1).forEach((g,h)=>{const $=`s${String(h)}`;i.push(`<feComposite in="${d}" in2="${g}" operator="arithmetic" k2="1" k3="1" result="${$}"/>`),d=$}),i.push(`<feColorMatrix in="${d}" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1" result="o"/>`,'<feComposite in="o" in2="SourceAlpha" operator="in"/>',"</filter>"),i.join("")}function W(t,r,e,n){const o=r.length,i=r.findIndex(m=>m>0);let c=o-1;for(;c>0&&!((r[c]??0)>0);)c-=1;const f=Math.max(0,i-1)/(o-1),d=Math.min(o-1,c+1)/(o-1);if(f<=0&&d>=1)return;const g=t.to[0]-t.from[0],h=t.to[1]-t.from[1],$=g*g+h*h;if($<=0)return;const w=m=>((m[0]-t.from[0])*g+(m[1]-t.from[1])*h)/$,p=(m,C)=>{const s=[];return m.forEach((u,a)=>{const l=m[(a+1)%m.length]??u,x=C(u),v=C(l);if(x>=0&&s.push(u),x>=0!=v>=0){const M=x/(x-v);s.push([u[0]+(l[0]-u[0])*M,u[1]+(l[1]-u[1])*M])}}),s};let y=[[0,0],[e,0],[e,n],[0,n]];if(y=p(y,m=>w(m)-f),y=p(y,m=>d-w(m)),y.length===0)return[0,0,0,0];const S=y.map(m=>m[0]),E=y.map(m=>m[1]),O=Math.max(0,Math.floor(Math.min(...S))-1),z=Math.max(0,Math.floor(Math.min(...E))-1),A=Math.min(e,Math.ceil(Math.max(...S))+1),F=Math.min(n,Math.ceil(Math.max(...E))+1);return[O,z,A-O,F-z]}export function screenFocusOf(t,r,e,n){if(!n.dof||!e||!t.page)return;const o=t.page.screens.face(r.mesh);if(!o)return;const i=t.props.scenery.renderer?.focus?.maxRadius??B.focus.maxRadius,c=t.canvas.height/t.px.h;return L({camera:n,corners:[o.point(0,0),o.point(1,0),o.point(1,1),o.point(0,1)],quad:e.corners,size:r.size,frameHeight:t.px.h,levels:t.props.focusLevels,most:2*i/c})}export function mountScreen(t,r,e,n,o,i){const c=document.createElement("div");c.dataset.akScreen=r;const f=([s,u])=>{c.style.width=`${String(s)}px`,c.style.height=`${String(u)}px`};Object.assign(c.style,{position:"absolute",left:"0px",top:"0px",overflow:"hidden",transformOrigin:"0 0",opacity:"0.999",display:"none"});const d=document.createElement("div");Object.assign(d.style,{position:"absolute",inset:"0",background:e.background??"transparent"}),c.appendChild(d),f(e.size),t.appendChild(c);const g=e.time,h=e.start===void 0?void 0:typeof e.start=="number"?e.start:i(e.start),$=h!==void 0||e.cue!==void 0||e.cues!==void 0;let w=(typeof e.cue=="number"?e.cue:0)-(h??0),p;const y=s=>{if(!e.cues)return;const u=Object.entries(e.cues).map(([a,l])=>[typeof l=="number"?l:i(l),s(a.trim())]);u.sort((a,l)=>a[0]-l[0]);for(let a=1;a<u.length;a++){const[l,x]=u[a-1]??[0,0],[v,M]=u[a]??[0,0];if(!(v>l&&M>x))throw new Error(`screen() on "${r}": its cues are not in the same order on both clocks (the screen's ${x.toFixed(3)} s at scenery ${l.toFixed(3)} s, then ${M.toFixed(3)} s at ${v.toFixed(3)} s). Each later moment of the screen plays later.`)}p=u,E.stretches=u.slice(1).map((a,l)=>{const x=u[l]??a;return{from:x[0],to:a[0],video:[x[1],a[1]],speed:Math.round((a[1]-x[1])/(a[0]-x[0])*1e4)/1e4}})},S=s=>{if(p&&p.length>0){const u=p[0]??[0,0];if(s<=u[0])return u[1]+(s-u[0]);for(let l=1;l<p.length;l++){const[x,v]=p[l]??[0,0];if(s<=x){const[M,k]=p[l-1]??[0,0];return k+(s-M)/(x-M)*(v-k)}}const a=p[p.length-1]??[0,0];return a[1]+(s-a[0])}return $?w+s:typeof g=="function"?g(s):(g.from??0)+s},E={mesh:r,spec:e,el:c,surface:d,size:[e.size[0],e.size[1]],timeAt:S,ctx:n,layers:[]};if(e.video){if(!n.video)throw new Error(`This host cannot show a video on the screen "${r}".`);const s=document.createElement("div");return d.appendChild(s),n.wait(n.video(e.video,s).then(u=>{typeof e.cue=="string"&&(w=u.at(e.cue)-(h??0)),y(a=>a.startsWith("@")?u.at(a):Number(a)),E.video=u,E.size=[u.width,u.height],f(E.size)})),E}y(s=>Number(s));const[O,z]=e.size,A=e.dur??(!$&&typeof g=="function"?1/0:S(o(n.layer.end))),F=[0,0,O,z],m=s=>{if(!$&&typeof g=="function")throw new Error(`screen() on "${r}" has a function for its time, which a reference cannot be placed in: give it a start (or { from }) to time its layers by the script.`);return S(o(s))},C=s=>typeof s=="number"?s:m(n.at(s));return E.layers=T(c,()=>e.layers.map((s,u)=>{const a=document.createElement("div");Object.assign(a.style,{position:"absolute",inset:"0"}),j(a,!1),d.appendChild(a);const l=s.at===void 0?0:C(s.at),x=s.until!==void 0?C(s.until):s.dur!==void 0?l+s.dur:A,v={...n,get layoutOnly(){return n.layoutOnly===!0},format:`${O}x${z}`,dims:{width:O,height:z,orient:O>z?"landscape":O<z?"portrait":"square",safe:{top:0,bottom:0,left:0,right:0}},dur:A,words:()=>!$&&typeof g=="function"?[]:n.words().map(k=>({...k,start:m(k.start),end:m(k.end)})),at:C,layer:{start:l,end:x},captions:()=>[],face:()=>{},faces:()=>[],texts:()=>[],covered:[],content:F},M=s.times?R(s.props,s.times,C):s.props;return U(a.ownerDocument),j(a,!0),G(r,s,u,"mount",()=>{s.mount(a,M,v)}),j(a,!1),{spec:s,props:M,el:a,ctx:v,start:l,end:x}})),E}function T(t,r){const e=_(t);j(t,!0);try{return r()}finally{j(t,e)}}function R(t,r,e){if(Array.isArray(t))return t.map(o=>R(o,r,e));if(r===!0)return typeof t=="string"||typeof t=="number"?e(t):t;if(typeof t!="object"||t===null)return t;const n={...t};for(const[o,i]of Object.entries(r))o in n&&n[o]!==void 0&&(n[o]=R(n[o],i,e));return n}export function stackByDepth(t){t.map((e,n)=>({i:n,depth:e.depth??1/0})).sort((e,n)=>n.depth-e.depth||e.i-n.i).forEach(({i:e},n)=>{const o=t[e];o&&(o.el.style.zIndex=String(n))})}export function placeInScenery(t,r,e){const[n,o]=t.size;Object.assign(t.el.style,{display:"block",opacity:"1",width:`${String(n*e)}px`,height:`${String(o*e)}px`}),Object.assign(t.surface.style,{inset:"auto",left:"0px",top:"0px",width:`${String(n)}px`,height:`${String(o)}px`,transformOrigin:"0 0",transform:e===1?"none":`scale(${String(e)})`});const i=r?I(n,o,r.corners):void 0;if(!r||!i||r.angle>=90){t.el.style.transform="scale(0)";return}const c=i.map((f,d)=>d%3===2?f:f/e);t.el.style.transform=N(c.map(f=>Math.round(f*1e9)/1e9))}function G(t,r,e,n,o){try{o()}catch(i){throw H(i,`On the screen "${t}", its layer ${String(e+1)} (${r.component}) failed in ${n}: `)}}export function screenTo(t,r){const e=t.timeAt(r);if(t.video){const n=Math.max(0,t.video.duration-.001),o=Math.min(Math.max(e,0),n);return t.video.seek(o,t.ctx.layoutOnly===!0)}return t.layers.forEach((n,o)=>{const i=e>=n.start&&e<n.end;j(n.el,i),i&&G(t.mesh,n.spec,o,`render at ${e.toFixed(2)} s`,()=>{n.spec.render(n.el,e,n.props,n.ctx)})}),Promise.resolve()}export function drawScreen(t,r,e){const n=e?I(t.size[0],t.size[1],e.corners):void 0;if(!e||!n||e.angle>=90){t.el.style.display="none";return}t.el.style.display="block",t.el.style.transform=N(n.map(i=>Math.round(i*1e9)/1e9));const o=t.timeAt(r);if(t.video){const i=Math.max(0,t.video.duration-.001),c=t.video,f=Math.min(Math.max(o,0),i),d=t.ctx.layoutOnly===!0;t.ctx.wait(Promise.resolve().then(()=>c.seek(f,d)));return}t.layers.forEach((i,c)=>{const f=o>=i.start&&o<i.end;j(i.el,f),f&&G(t.mesh,i.spec,c,`render at ${o.toFixed(2)} s`,()=>{i.spec.render(i.el,o,i.props,i.ctx)})})}export function screenEdge(t,r,e){const n=t.spec.background;if(!r||n===null)return;const[o,i,c,f]=r.corners,d=(y,S)=>Math.hypot(S[0]-y[0],S[1]-y[1]),[g,h]=t.size,$=Math.min(d(o,i)/g,d(f,c)/g,d(o,f)/h,d(i,c)/h),w=Math.min(Math.ceil(e/Math.max($,.001)),Math.max(g,h)),p=`0 0 0 ${String(w)}px ${n}`;t.edge!==p&&(t.el.style.boxShadow=p,t.edge=p)}
2
+ import{homography as I,matrix3d as N,screenFocus as L,SCENERY_RENDERER_DEFAULTS as B}from"@allyhub/scenery";import{addLayerRule as U,layerShown as _,showLayer as j}from"@allyhub/piece";import{coded as H}from"./state.js";export function blurScreen(t,i){if(!i){t.focus&&(t.surface.style.filter="");return}const e=t.el.parentElement;if(!e)return;if(!t.focus){const o=document.createElementNS(P,"svg");o.setAttribute("width","0"),o.setAttribute("height","0"),o.setAttribute("aria-hidden","true"),Object.assign(o.style,{position:"absolute",left:"0",top:"0"}),e.appendChild(o),D+=1,t.focus={svg:o,id:`ak-screen-focus-${String(D)}`,markup:""}}const n=V(t.focus.id,t.size,i);n!==t.focus.markup&&(t.focus.svg.innerHTML=n,t.focus.markup=n),t.surface.style.filter=`url(#${t.focus.id})`}const P="http://www.w3.org/2000/svg";let D=0;const S=t=>{const i=Math.round(t*1e3)/1e3;return String(Object.is(i,-0)?0:i)};function V(t,i,e){const[n,o]=i,r=[],a=e.sigmas.length>1;a&&r.push(`<defs><linearGradient id="${t}-lg" gradientUnits="userSpaceOnUse" x1="${S(e.from[0])}" y1="${S(e.from[1])}" x2="${S(e.to[0])}" y2="${S(e.to[1])}"><stop offset="0" stop-color="#000"/><stop offset="1" stop-color="#fff"/></linearGradient>`,`<rect id="${t}-r" x="0" y="0" width="${S(n)}" height="${S(o)}" fill="url(#${t}-lg)"/></defs>`),r.push(`<filter id="${t}" x="0" y="0" width="1" height="1" color-interpolation-filters="sRGB">`),a&&r.push(`<feImage href="#${t}-r" result="g"/>`,'<feColorMatrix in="g" type="matrix" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0" result="w"/>');const p=[];e.sigmas.forEach((l,d)=>{const y=e.weights[d]??[];if(a&&!y.some(b=>b>0))return;const w=a?W(e,y,n,o):void 0,m=w?` x="${S(w[0])}" y="${S(w[1])}" width="${S(w[2])}" height="${S(w[3])}"`:"";let $="SourceGraphic";if(l>=.05&&(r.push(`<feGaussianBlur in="SourceGraphic" stdDeviation="${S(l)}"${m} result="b${String(d)}"/>`),$=`b${String(d)}`),!a){p.push($);return}r.push(`<feComponentTransfer in="w"${m} result="w${String(d)}"><feFuncA type="table" tableValues="${y.map(S).join(" ")}"/></feComponentTransfer>`,`<feComposite in="${$}" in2="w${String(d)}" operator="arithmetic" k1="1"${m} result="m${String(d)}"/>`),p.push(`m${String(d)}`)});let f=p[0]??"SourceGraphic";return p.slice(1).forEach((l,d)=>{const y=`s${String(d)}`;r.push(`<feComposite in="${f}" in2="${l}" operator="arithmetic" k2="1" k3="1" result="${y}"/>`),f=y}),r.push(`<feColorMatrix in="${f}" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1" result="o"/>`,'<feComposite in="o" in2="SourceAlpha" operator="in"/>',"</filter>"),r.join("")}function W(t,i,e,n){const o=i.length,r=i.findIndex(g=>g>0);let a=o-1;for(;a>0&&!((i[a]??0)>0);)a-=1;const p=Math.max(0,r-1)/(o-1),f=Math.min(o-1,a+1)/(o-1);if(p<=0&&f>=1)return;const l=t.to[0]-t.from[0],d=t.to[1]-t.from[1],y=l*l+d*d;if(y<=0)return;const w=g=>((g[0]-t.from[0])*l+(g[1]-t.from[1])*d)/y,m=(g,C)=>{const s=[];return g.forEach((u,c)=>{const h=g[(c+1)%g.length]??u,x=C(u),E=C(h);if(x>=0&&s.push(u),x>=0!=E>=0){const M=x/(x-E);s.push([u[0]+(h[0]-u[0])*M,u[1]+(h[1]-u[1])*M])}}),s};let $=[[0,0],[e,0],[e,n],[0,n]];if($=m($,g=>w(g)-p),$=m($,g=>f-w(g)),$.length===0)return[0,0,0,0];const b=$.map(g=>g[0]),v=$.map(g=>g[1]),O=Math.max(0,Math.floor(Math.min(...b))-1),z=Math.max(0,Math.floor(Math.min(...v))-1),A=Math.min(e,Math.ceil(Math.max(...b))+1),F=Math.min(n,Math.ceil(Math.max(...v))+1);return[O,z,A-O,F-z]}export function screenFocusOf(t,i,e,n){if(!n.dof||!e||!t.page)return;const o=t.page.screens.face(i.mesh);if(!o)return;const r=t.props.scenery.renderer?.focus?.maxRadius??B.focus.maxRadius,a=t.canvas.height/t.px.h;return L({camera:n,corners:[o.point(0,0),o.point(1,0),o.point(1,1),o.point(0,1)],quad:e.corners,size:i.size,frameHeight:t.px.h,levels:t.props.focusLevels,most:2*r/a})}export function mountScreen(t,i,e,n,o,r){const a=document.createElement("div");a.dataset.akScreen=i;const p=([s,u])=>{a.style.width=`${String(s)}px`,a.style.height=`${String(u)}px`};Object.assign(a.style,{position:"absolute",left:"0px",top:"0px",overflow:"hidden",transformOrigin:"0 0",opacity:"0.999",display:"none"});const f=document.createElement("div");Object.assign(f.style,{position:"absolute",inset:"0",background:e.background??"transparent"}),a.appendChild(f),p(e.size),t.appendChild(a);const l=e.time,d=e.start===void 0?void 0:typeof e.start=="number"?e.start:r(e.start),y=d!==void 0||e.cue!==void 0||e.cues!==void 0;let w=(typeof e.cue=="number"?e.cue:0)-(d??0),m;const $=s=>{if(!e.cues)return;const u=Object.entries(e.cues).map(([c,h])=>[typeof h=="number"?h:r(h),s(c.trim())]);u.sort((c,h)=>c[0]-h[0]);for(let c=1;c<u.length;c++){const[h,x]=u[c-1]??[0,0],[E,M]=u[c]??[0,0];if(!(E>h&&M>x))throw new Error(`screen() on "${i}": its cues are not in the same order on both clocks (the screen's ${x.toFixed(3)} s at scenery ${h.toFixed(3)} s, then ${M.toFixed(3)} s at ${E.toFixed(3)} s). Each later moment of the screen plays later.`)}m=u,v.stretches=u.slice(1).map((c,h)=>{const x=u[h]??c;return{from:x[0],to:c[0],video:[x[1],c[1]],speed:Math.round((c[1]-x[1])/(c[0]-x[0])*1e4)/1e4}})},b=s=>{if(m&&m.length>0){const u=m[0]??[0,0];if(s<=u[0])return u[1]+(s-u[0]);for(let h=1;h<m.length;h++){const[x,E]=m[h]??[0,0];if(s<=x){const[M,k]=m[h-1]??[0,0];return k+(s-M)/(x-M)*(E-k)}}const c=m[m.length-1]??[0,0];return c[1]+(s-c[0])}return y?w+s:typeof l=="function"?l(s):(l.from??0)+s},v={mesh:i,spec:e,el:a,surface:f,size:[e.size[0],e.size[1]],timeAt:b,ctx:n,layers:[]};if(e.video){if(!n.video)throw new Error(`This host cannot show a video on the screen "${i}".`);const s=document.createElement("div");return f.appendChild(s),n.wait(n.video(e.video,s).then(u=>{typeof e.cue=="string"&&(w=u.at(e.cue)-(d??0)),$(c=>c.startsWith("@")?u.at(c):Number(c)),v.video=u,v.size=[u.width,u.height],p(v.size)})),v}$(s=>Number(s));const[O,z]=e.size,A=e.dur??(!y&&typeof l=="function"?1/0:b(o(n.layer.end))),F=[0,0,O,z],g=s=>{if(!y&&typeof l=="function")throw new Error(`screen() on "${i}" has a function for its time, which a reference cannot be placed in: give it a start (or { from }) to time its layers by the script.`);return b(o(s))},C=s=>typeof s=="number"?s:g(n.at(s));return v.layers=T(a,()=>e.layers.map((s,u)=>{const c=document.createElement("div");Object.assign(c.style,{position:"absolute",inset:"0"}),j(c,!1),f.appendChild(c);const h=s.at===void 0?0:C(s.at),x=s.until!==void 0?C(s.until):s.dur!==void 0?h+s.dur:A,E={...n,get layoutOnly(){return n.layoutOnly===!0},format:`${O}x${z}`,dims:{width:O,height:z,orient:O>z?"landscape":O<z?"portrait":"square",safe:{top:0,bottom:0,left:0,right:0}},dur:A,words:()=>!y&&typeof l=="function"?[]:n.words().map(k=>({...k,start:g(k.start),end:g(k.end)})),at:C,layer:{start:h,end:x},captions:()=>[],face:()=>{},faces:()=>[],texts:()=>[],covered:[],content:F},M=s.times?R(s.props,s.times,C):s.props;return U(c.ownerDocument),j(c,!0),G(i,s,u,"mount",()=>{s.mount(c,M,E)}),j(c,!1),{spec:s,props:M,el:c,ctx:E,start:h,end:x}})),v}function T(t,i){const e=_(t);j(t,!0);try{return i()}finally{j(t,e)}}function R(t,i,e){if(Array.isArray(t))return t.map(o=>R(o,i,e));if(i===!0)return typeof t=="string"||typeof t=="number"?e(t):t;if(typeof t!="object"||t===null)return t;const n={...t};for(const[o,r]of Object.entries(i))o in n&&n[o]!==void 0&&(n[o]=R(n[o],r,e));return n}export function stackByDepth(t){t.map((e,n)=>({i:n,depth:e.depth??1/0})).sort((e,n)=>n.depth-e.depth||e.i-n.i).forEach(({i:e},n)=>{const o=t[e];o&&(o.el.style.zIndex=String(n))})}export function placeInScenery(t,i,e,n=0){const[o,r]=t.size;Y(t,e,n),Object.assign(t.el.style,{display:"block",opacity:"1",width:`${String(o*e)}px`,height:`${String(r*e)}px`}),Object.assign(t.surface.style,{inset:"auto",left:"0px",top:"0px",width:`${String(o)}px`,height:`${String(r)}px`,transformOrigin:"0 0",transform:e===1?"none":`scale(${String(e)})`});const a=i?I(o,r,i.corners):void 0;if(!i||!a||i.angle>=90){t.el.style.transform="scale(0)";return}const p=a.map((f,l)=>l%3===2?f:f/e);t.el.style.transform=N(p.map(f=>Math.round(f*1e9)/1e9))}function Y(t,i,e){let n=t.surface.querySelector(":scope > [data-panel-mesh]");if(e<=0){n?.remove();return}n||(n=document.createElement("div"),n.dataset.panelMesh="",Object.assign(n.style,{position:"absolute",inset:"0",pointerEvents:"none",zIndex:"2147483647"}),t.surface.appendChild(n));const o=3/i,r=o/3,a=Math.min(1,e),p=a*(2/3),f=(l,d)=>`repeating-linear-gradient(${String(l)}deg, rgba(0,0,0,${d.toFixed(3)}) 0 ${String(r)}px, transparent ${String(r)}px ${String(o)}px)`;n.style.background=`${f(0,a)}, ${f(90,p)}`}function G(t,i,e,n,o){try{o()}catch(r){throw H(r,`On the screen "${t}", its layer ${String(e+1)} (${i.component}) failed in ${n}: `)}}export function screenTo(t,i){const e=t.timeAt(i);if(t.video){const n=Math.max(0,t.video.duration-.001),o=Math.min(Math.max(e,0),n);return t.video.seek(o,t.ctx.layoutOnly===!0)}return t.layers.forEach((n,o)=>{const r=e>=n.start&&e<n.end;j(n.el,r),r&&G(t.mesh,n.spec,o,`render at ${e.toFixed(2)} s`,()=>{n.spec.render(n.el,e,n.props,n.ctx)})}),Promise.resolve()}export function drawScreen(t,i,e){const n=e?I(t.size[0],t.size[1],e.corners):void 0;if(!e||!n||e.angle>=90){t.el.style.display="none";return}t.el.style.display="block",t.el.style.transform=N(n.map(r=>Math.round(r*1e9)/1e9));const o=t.timeAt(i);if(t.video){const r=Math.max(0,t.video.duration-.001),a=t.video,p=Math.min(Math.max(o,0),r),f=t.ctx.layoutOnly===!0;t.ctx.wait(Promise.resolve().then(()=>a.seek(p,f)));return}t.layers.forEach((r,a)=>{const p=o>=r.start&&o<r.end;j(r.el,p),p&&G(t.mesh,r.spec,a,`render at ${o.toFixed(2)} s`,()=>{r.spec.render(r.el,o,r.props,r.ctx)})})}export function screenEdge(t,i,e){const n=t.spec.background;if(!i||n===null)return;const[o,r,a,p]=i.corners,f=($,b)=>Math.hypot(b[0]-$[0],b[1]-$[1]),[l,d]=t.size,y=Math.min(f(o,r)/l,f(p,a)/l,f(o,p)/d,f(r,a)/d),w=Math.min(Math.ceil(e/Math.max(y,.001)),Math.max(l,d)),m=`0 0 0 ${String(w)}px ${n}`;t.edge!==m&&(t.el.style.boxShadow=m,t.edge=m)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{blurDiameter as re}from"@allyhub/scenery";import{motionOf as ie}from"@allyhub/scenery";import{moireBand as ce,moireCamera as de,moireScreen as le}from"@allyhub/scenery";import{apply as me,homography as he,screenOnFrame as fe}from"@allyhub/scenery";import{drawnCamera as pe}from"../page/page.js";import{clearanceOf as ue,measure as ge,nearPlaneOf as ye,solidsOf as be}from"./index.js";const w=(n,t,r)=>n?{least:t<n.least?t:n.least,leastAt:t<n.least?r:n.leastAt,most:t>n.most?t:n.most,mostAt:t>n.most?r:n.mostAt}:{least:t,leastAt:r,most:t,mostAt:r},Z=n=>n?Math.min(1,n.scale):1;function L(n,t){const r=new Map,h=[];for(const u of n)for(const g of u.keys){const m=r.get(g);m&&u.t-m.to<=t*1.5?m.to=u.t:(m&&h.push({key:g,...m}),r.set(g,{from:u.t,to:u.t}))}for(const[u,g]of r)h.push({key:u,...g});return h}export async function layerFacts(n,t){const r={layer:t.layer,start:t.start,end:t.end},h=[],u=t.sceneryAt(0),g=t.scenery===!1?{contacts:[],support:[],health:[]}:await ge(n,{t:u,near:.01,tolerance:.001,samples:400,grid:5,all:!1,volume:!0},t.time),m=n.bake.state;t.scenery!==!1&&m.digest!==""&&h.push({kind:"scenery-bake",data:{...r,laid:m.laid!==null,asked:m.asked,digest:m.digest,renderer:m.renderer,...m.laid?{bakedOn:m.laid.renderer}:{},...t.file===void 0?{}:{file:t.file}}});for(const e of g.contacts){const a=Math.max(e.depth?.aInB??0,e.depth?.bInA??0);h.push({kind:"scenery-contact",data:{...r,a:e.a,b:e.b,crossing:e.crossing,touching:e.touching,...e.gap!==void 0?{gap:e.gap}:{},...e.area!==void 0?{area:e.area}:{},...e.curve?{curve:e.curve.length}:{},...e.within?{within:e.within}:{},...e.depth?{depth:a}:{},...e.lift?{lift:{a:e.lift.a,b:e.lift.b}}:{},...e.volume!==void 0?{volume:e.volume}:{},...e.volumeMissing?{volumeMissing:e.volumeMissing}:{},...e.missing?{missing:e.missing}:{}}})}for(const e of g.support)h.push({kind:"scenery-support",data:{...r,object:e.path,gap:e.gap,sunk:e.sunk,on:e.on.map(a=>a.path),footprintShare:e.footprintShare,...e.margin!==void 0?{margin:e.margin}:{},nothingBelow:e.nothingBelow}});for(const e of g.health)e.closed&&e.degenerate===0&&!e.selfIntersections||h.push({kind:"mesh-health",data:{...r,object:e.path,triangles:e.triangles,closed:e.closed,openEdges:e.openEdges,nonManifoldEdges:e.nonManifoldEdges,degenerate:e.degenerate,selfIntersections:e.selfIntersections}});const B=t.fps??30,E=1/B,N=t.end-t.start,G=[],H=[],J=[],K=new Map;let O;const Q=Math.max(1,Math.round(B/10));let P;const f=t.frame??[1080,1920],T=[Math.max(64,Math.round(f[0]/4)),Math.max(64,Math.round(f[1]/4))],U=(t.screens??[]).map(e=>({mesh:e.mesh,size:e.size,shown:[],samples:[],...e.stretches?{stretches:e.stretches}:{},...e.text===void 0?{}:{text:e.text},...e.pixels?{pixels:e.pixels}:{},...e.drawn?{drawn:e.drawn}:{}}));for(let e=0,a=0;a<=N+1e-9;e++,a=e*E){const d=t.sceneryAt(a),te=n.stateFrom(t.camera,d,t.aspect,t.time),R=n.aim(te,t.aspect),o=R.resolved,D=pe(R),l=Math.round((t.start+a)*1e6)/1e6;if(G.push({t:l,position:o.position,forward:o.forward,up:o.up,right:o.right,lens:o.lens,yaw:D.yaw,pitch:D.pitch,roll:D.roll,...o.target?{target:o.target}:{}}),e%Q!==0)continue;for(const s of U){const y=n.screens.quad(s.mesh,o,f),W=y!==void 0&&y.angle<90;if(s.shown.push({t:l,keys:W?["shown"]:[]}),!y||!W)continue;const b=fe(s.size[0],s.size[1],y.corners,f,y.angle);s.share=w(s.share,b.share,l);const ne=w(s.scale,b.scale.least,l);s.scale=w(ne,b.scale.most,l),s.angle=w(s.angle,b.angle,l);const X=o.dof?n.screens.face(s.mesh):void 0;if(X&&o.dof){const c=[[0,0],[1,0],[1,1],[0,1]].map(([I,S])=>{const z=X.point(I,S).map((A,v)=>A-(o.position[v]??0));return(z[0]??0)*o.forward[0]+(z[1]??0)*o.forward[1]+(z[2]??0)*o.forward[2]}),j=Math.min(...c),F=Math.max(...c),C=c.map(I=>re(o,I,f[1])),k=o.dof.focus>=j&&o.dof.focus<=F;s.blur=w(s.blur,k?0:Math.min(...C),l),s.blur=w(s.blur,Math.max(...C),l)}if(t.sensor){const c=n.screens.face(s.mesh),j=de(o,t.output??f,f[1],t.sensor,t.box?[t.box[0],t.box[1]]:[0,0]),F=c?le({quad:y.corners,corners:[c.point(0,0),c.point(1,0),c.point(1,1),c.point(0,1)],size:s.size,camera:o,...s.pixels?{panel:s.pixels}:{}}):void 0,C=he(s.size[0],s.size[1],y.corners);let k={depth:0,period:1/0};if(F&&C)for(let S=1;S<8;S++)for(let z=1;z<12;z++){const A=me(C,s.size[0]*z/12,s.size[1]*S/8);if(A[0]<0||A[1]<0||A[0]>f[0]||A[1]>f[1])continue;const v=ce(F,j,A);v&&v.depth>k.depth&&(k=v)}const I=s.moire?.most??-1;s.moire=w(s.moire,k.depth,l),k.depth>I&&Number.isFinite(k.period)&&(s.moirePeriod=k.period)}const x=await n.screens.hidden(s.mesh,R,T[0],T[1]);if(x){const c=s.hidden?.most??-1;s.hidden=w(s.hidden,x.hidden,l),x.hidden>c&&(s.by=x.by)}const[oe,ae]=t.box??[0,0],Y=c=>Math.round(c*10)/10;s.samples.push({t:l,corners:y.corners.map(([c,j])=>[Y(c+oe),Y(j+ae)]),share:b.share,scale:[b.scale.least,b.scale.most],angle:b.angle,...x?{hidden:Math.round(x.hidden*1e4)/1e4}:{}})}P&&n.animated&&P.refresh();const se=P??=be(n),M=ue(se,o.position,ye(o));M.nearest&&(!O||M.nearest.distance<O.distance)&&(O={object:M.nearest.path,distance:M.nearest.distance,t:l});for(const s of M.inside)K.set(s.path,s.closed);J.push({t:l,keys:M.inside.map(s=>s.path)}),H.push({t:l,keys:M.nearCut})}const q=E*Q,_=L(J,q),$=L(H,q);h.push({kind:"camera-clearance",data:{...r,...O?{nearest:O}:{},inside:_.map(e=>({object:e.key,closed:K.get(e.key)??!1,from:e.from,to:e.to})),nearCut:$.map(e=>({object:e.key,from:e.from,to:e.to}))}});for(const e of U){const a=d=>({least:Math.round(d.least*1e4)/1e4,leastAt:d.leastAt,most:Math.round(d.most*1e4)/1e4,mostAt:d.mostAt});h.push({kind:"scenery-screen",data:{...r,screen:e.mesh,size:[e.size[0],e.size[1]],frame:[f[0],f[1]],shown:L(e.shown,q).map(d=>({from:d.from,to:d.to})),...e.share?{share:a(e.share)}:{},...e.scale?{scale:a(e.scale)}:{},...e.angle?{angle:a(e.angle)}:{},...e.blur?{blur:a(e.blur)}:{},...e.moire?{moire:{...a(e.moire),...e.moirePeriod!==void 0?{period:Math.round(e.moirePeriod*10)/10}:{}}}:{},...e.hidden?{hidden:{...a(e.hidden),by:e.by??[]}}:{},samples:e.samples,...e.stretches?{stretches:[...e.stretches]}:{},...e.drawn?{drawn:e.drawn}:{},...e.text!==void 0&&e.scale?{text:{size:e.text,onFrame:[Math.round(e.text*e.scale.least*Z(e.drawn)*100)/100,Math.round(e.text*e.scale.most*Z(e.drawn)*100)/100]}}:{}}})}const ee=n.cutsOf(t.camera,t.time),V=[];for(const e of ee)for(let a=0,d=0;d<=N+1e-9;a++,d=a*E)if(t.sceneryAt(d)>=e){V.push(Math.round((t.start+d)*1e6)/1e6);break}const i=ie(G,V),p=e=>({peak:e.peak,at:e.at});return h.push({kind:"camera-motion",data:{...r,fps:B,length:i.length,peaks:{truck:p(i.truck),pedestal:p(i.pedestal),dolly:p(i.dolly),pan:p(i.pan),tilt:p(i.tilt),roll:p(i.roll),zoom:p(i.zoom),speed:p(i.speed),turn:p(i.turn),acceleration:p(i.acceleration),jerk:p(i.jerk)},smoothness:i.smoothness,step:i.step,...i.cuts.length>0?{cuts:i.cuts}:{}}}),n.pose(u,t.time),h}
2
+ import{blurDiameter as ie}from"@allyhub/scenery";import{motionOf as ce}from"@allyhub/scenery";import{moireBand as de,moireCamera as le,moireScreen as me}from"@allyhub/scenery";import{apply as he,homography as fe,screenOnFrame as pe}from"@allyhub/scenery";import{drawnCamera as ue}from"../page/page.js";import{clearanceOf as ge,measure as ye,nearPlaneOf as be,solidsOf as ke}from"./index.js";const k=(n,t,r)=>n?{least:t<n.least?t:n.least,leastAt:t<n.least?r:n.leastAt,most:t>n.most?t:n.most,mostAt:t>n.most?r:n.mostAt}:{least:t,leastAt:r,most:t,mostAt:r},_=n=>n?Math.min(1,n.scale):1;function L(n,t){const r=new Map,h=[];for(const u of n)for(const g of u.keys){const m=r.get(g);m&&u.t-m.to<=t*1.5?m.to=u.t:(m&&h.push({key:g,...m}),r.set(g,{from:u.t,to:u.t}))}for(const[u,g]of r)h.push({key:u,...g});return h}export async function layerFacts(n,t){const r={layer:t.layer,start:t.start,end:t.end},h=[],u=t.sceneryAt(0),g=t.scenery===!1?{contacts:[],support:[],health:[]}:await ye(n,{t:u,near:.01,tolerance:.001,samples:400,grid:5,all:!1,volume:!0},t.time),m=n.bake.state;t.scenery!==!1&&m.digest!==""&&h.push({kind:"scenery-bake",data:{...r,laid:m.laid!==null,asked:m.asked,digest:m.digest,renderer:m.renderer,...m.laid?{bakedOn:m.laid.renderer}:{},...t.file===void 0?{}:{file:t.file}}});for(const e of g.contacts){const a=Math.max(e.depth?.aInB??0,e.depth?.bInA??0);h.push({kind:"scenery-contact",data:{...r,a:e.a,b:e.b,crossing:e.crossing,touching:e.touching,...e.gap!==void 0?{gap:e.gap}:{},...e.area!==void 0?{area:e.area}:{},...e.curve?{curve:e.curve.length}:{},...e.within?{within:e.within}:{},...e.depth?{depth:a}:{},...e.lift?{lift:{a:e.lift.a,b:e.lift.b}}:{},...e.volume!==void 0?{volume:e.volume}:{},...e.volumeMissing?{volumeMissing:e.volumeMissing}:{},...e.missing?{missing:e.missing}:{}}})}for(const e of g.support)h.push({kind:"scenery-support",data:{...r,object:e.path,gap:e.gap,sunk:e.sunk,on:e.on.map(a=>a.path),footprintShare:e.footprintShare,...e.margin!==void 0?{margin:e.margin}:{},nothingBelow:e.nothingBelow}});for(const e of g.health)e.closed&&e.degenerate===0&&!e.selfIntersections||h.push({kind:"mesh-health",data:{...r,object:e.path,triangles:e.triangles,closed:e.closed,openEdges:e.openEdges,nonManifoldEdges:e.nonManifoldEdges,degenerate:e.degenerate,selfIntersections:e.selfIntersections}});const B=t.fps??30,E=1/B,N=t.end-t.start,G=[],H=[],J=[],K=new Map;let O;const Q=Math.max(1,Math.round(B/10));let P;const f=t.frame??[1080,1920],T=[Math.max(64,Math.round(f[0]/4)),Math.max(64,Math.round(f[1]/4))],U=(t.screens??[]).map(e=>({mesh:e.mesh,size:e.size,shown:[],samples:[],...e.stretches?{stretches:e.stretches}:{},...e.text===void 0?{}:{text:e.text},...e.pixels?{pixels:e.pixels}:{},...e.drawn?{drawn:e.drawn}:{}}));for(let e=0,a=0;a<=N+1e-9;e++,a=e*E){const d=t.sceneryAt(a),se=n.stateFrom(t.camera,d,t.aspect,t.time),R=n.aim(se,t.aspect),o=R.resolved,D=ue(R),l=Math.round((t.start+a)*1e6)/1e6;if(G.push({t:l,position:o.position,forward:o.forward,up:o.up,right:o.right,lens:o.lens,yaw:D.yaw,pitch:D.pitch,roll:D.roll,...o.target?{target:o.target}:{}}),e%Q!==0)continue;for(const s of U){const y=n.screens.quad(s.mesh,o,f),W=n.screens.share(s.mesh,o,f),X=W>0&&(y===void 0||y.angle<90);if(s.shown.push({t:l,keys:X?["shown"]:[]}),!X||(s.share=k(s.share,W,l),!y))continue;const M=pe(s.size[0],s.size[1],y.corners,f,y.angle),oe=k(s.scale,M.scale.least,l);s.scale=k(oe,M.scale.most,l),s.angle=k(s.angle,M.angle,l);const Y=o.dof?n.screens.face(s.mesh):void 0;if(Y&&o.dof){const c=[[0,0],[1,0],[1,1],[0,1]].map(([I,S])=>{const z=Y.point(I,S).map((A,v)=>A-(o.position[v]??0));return(z[0]??0)*o.forward[0]+(z[1]??0)*o.forward[1]+(z[2]??0)*o.forward[2]}),j=Math.min(...c),F=Math.max(...c),C=c.map(I=>ie(o,I,f[1])),b=o.dof.focus>=j&&o.dof.focus<=F;s.blur=k(s.blur,b?0:Math.min(...C),l),s.blur=k(s.blur,Math.max(...C),l)}if(t.sensor){const c=n.screens.face(s.mesh),j=le(o,t.output??f,f[1],t.sensor,t.box?[t.box[0],t.box[1]]:[0,0]),F=c?me({quad:y.corners,corners:[c.point(0,0),c.point(1,0),c.point(1,1),c.point(0,1)],size:s.size,camera:o,...s.pixels?{panel:s.pixels}:{}}):void 0,C=fe(s.size[0],s.size[1],y.corners);let b={depth:0,period:1/0};if(F&&C)for(let S=1;S<8;S++)for(let z=1;z<12;z++){const A=he(C,s.size[0]*z/12,s.size[1]*S/8);if(A[0]<0||A[1]<0||A[0]>f[0]||A[1]>f[1])continue;const v=de(F,j,A);v&&v.depth>b.depth&&(b=v)}const I=s.moire?.most??-1;s.moire=k(s.moire,b.depth,l),b.depth>I&&Number.isFinite(b.period)&&(s.moirePeriod=b.period)}const x=await n.screens.hidden(s.mesh,R,T[0],T[1]);if(x){const c=s.hidden?.most??-1;s.hidden=k(s.hidden,x.hidden,l),x.hidden>c&&(s.by=x.by)}const[ae,re]=t.box??[0,0],Z=c=>Math.round(c*10)/10;s.samples.push({t:l,corners:y.corners.map(([c,j])=>[Z(c+ae),Z(j+re)]),share:M.share,scale:[M.scale.least,M.scale.most],angle:M.angle,...x?{hidden:Math.round(x.hidden*1e4)/1e4}:{}})}P&&n.animated&&P.refresh();const ne=P??=ke(n),w=ge(ne,o.position,be(o));w.nearest&&(!O||w.nearest.distance<O.distance)&&(O={object:w.nearest.path,distance:w.nearest.distance,t:l});for(const s of w.inside)K.set(s.path,s.closed);J.push({t:l,keys:w.inside.map(s=>s.path)}),H.push({t:l,keys:w.nearCut})}const q=E*Q,$=L(J,q),ee=L(H,q);h.push({kind:"camera-clearance",data:{...r,...O?{nearest:O}:{},inside:$.map(e=>({object:e.key,closed:K.get(e.key)??!1,from:e.from,to:e.to})),nearCut:ee.map(e=>({object:e.key,from:e.from,to:e.to}))}});for(const e of U){const a=d=>({least:Math.round(d.least*1e4)/1e4,leastAt:d.leastAt,most:Math.round(d.most*1e4)/1e4,mostAt:d.mostAt});h.push({kind:"scenery-screen",data:{...r,screen:e.mesh,size:[e.size[0],e.size[1]],frame:[f[0],f[1]],shown:L(e.shown,q).map(d=>({from:d.from,to:d.to})),...e.share?{share:a(e.share)}:{},...e.scale?{scale:a(e.scale)}:{},...e.angle?{angle:a(e.angle)}:{},...e.blur?{blur:a(e.blur)}:{},...e.moire?{moire:{...a(e.moire),...e.moirePeriod!==void 0?{period:Math.round(e.moirePeriod*10)/10}:{}}}:{},...e.hidden?{hidden:{...a(e.hidden),by:e.by??[]}}:{},samples:e.samples,...e.stretches?{stretches:[...e.stretches]}:{},...e.drawn?{drawn:e.drawn}:{},...e.text!==void 0&&e.scale?{text:{size:e.text,onFrame:[Math.round(e.text*e.scale.least*_(e.drawn)*100)/100,Math.round(e.text*e.scale.most*_(e.drawn)*100)/100]}}:{}}})}const te=n.cutsOf(t.camera,t.time),V=[];for(const e of te)for(let a=0,d=0;d<=N+1e-9;a++,d=a*E)if(t.sceneryAt(d)>=e){V.push(Math.round((t.start+d)*1e6)/1e6);break}const i=ce(G,V),p=e=>({peak:e.peak,at:e.at});return h.push({kind:"camera-motion",data:{...r,fps:B,length:i.length,peaks:{truck:p(i.truck),pedestal:p(i.pedestal),dolly:p(i.dolly),pan:p(i.pan),tilt:p(i.tilt),roll:p(i.roll),zoom:p(i.zoom),speed:p(i.speed),turn:p(i.turn),acceleration:p(i.acceleration),jerk:p(i.jerk)},smoothness:i.smoothness,step:i.step,...i.cuts.length>0?{cuts:i.cuts}:{}}}),n.pose(u,t.time),h}
@@ -126,6 +126,14 @@ export declare class Screens {
126
126
  * Undefined while a corner is behind the camera (the screen is then not
127
127
  * shown).
128
128
  */
129
+ /**
130
+ * The share of a w × h frame a screen's face covers, seen from a camera:
131
+ * its face cut where it passes behind the near plane, so a screen the
132
+ * camera is right up against (a corner behind it, which `quad` leaves
133
+ * undefined) fills the frame as it does. 0 when none of it is in front,
134
+ * or the camera sees its back.
135
+ */
136
+ share(name: string, camera: ResolvedCamera, frame: readonly [number, number]): number;
129
137
  quad(name: string, camera: ResolvedCamera, frame: readonly [number, number]): ScreenQuad | undefined;
130
138
  /**
131
139
  * How much of a screen what is in front of it hides from a camera, drawn
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{Color as S,Float32BufferAttribute as D,Mesh as L,PerspectiveCamera as F,Vector3 as f,WebGLRenderer as W}from"three";import{project as G,shownCentre as $}from"@allyhub/scenery";import{reflectsAreaLights as q}from"../bake/apply.js";import{SceneryError as A}from"../errors.js";import{countable as P,seenFrom as R}from"../idbuffer.js";import{readTextureLevel as k}from"../measure/screen-readback.js";import{paths as H,vec as C}from"../scene.js";import{SCREEN_LIGHT_DEFAULTS as B,ScreenLight as I}from"../screen-light.js";import{ScreenPictures as V,canDrawElements as _}from"../screen-picture.js";import{length as E,normalize as N,sub as O}from"../vec.js";function Q(l,e){const i=l.brightness??e,n=typeof l.color=="string"?new S(l.color):l.color?new S(...l.color):new S(1,1,1);return[n.r*i,n.g*i,n.b*i]}function U(l){return(e,i)=>{let n=0;for(let t=0;t<l.length;t++){const r=l[t],s=l[(t+1)%l.length];if(!r||!s)return!1;const o=(s[0]-r[0])*(i-r[1])-(s[1]-r[1])*(e-r[0]);if(o===0)continue;const c=o>0?1:-1;if(n===0)n=c;else if(c!==n)return!1}return!0}}function T(l){let e;return l.traverse(i=>{!e&&i instanceof L&&(e=i)}),e}export class Screens{scene;renderer;object;mustObject;report;timers;pictures;lit=new Map;light=new I(q);mapped=new WeakSet;constructor(e){this.scene=e.scene,this.renderer=e.renderer,this.object=e.object,this.mustObject=e.mustObject,this.report=e.report,this.timers=e.timers}get drawsElements(){return this.renderer instanceof W&&_()}get canvas(){return this.pictures?.host??this.renderer.domElement}picture(e){return this.pictures?.get(e)}owns(e){return this.pictures?.owns(e)??!1}factorOf(e){return this.pictures?.factorOf(e)}adopt(e){this.pictures?.adopt(e)}frame(e,i){this.pictures?.frame(e,i)}show(e,i,n={}){if(!(this.renderer instanceof W))throw new A("build",`A screen drawn in the scenery ("${e}") needs the WebGL renderer.`);this.pictures??=new V(this.renderer,(t,r)=>{this.report({kind:"screen",level:"error",message:`The screen "${t}", drawn in the scenery, cannot show its element as it is: ${r}.`})}),this.pictures.show(e,i,n),this.lit.set(e,n.light===!1?!1:{cells:[...n.light?.cells??B.cells],specular:n.light?.specular??B.specular,base:(()=>{const t=n.light?.base??B.base;return t?Q(t,n.brightness??1):null})()})}async paint(e,i=5e3){if(!this.pictures)return;const n=this.renderer.domElement;if(e&&(n.width!==e[0]||n.height!==e[1])&&this.renderer.setSize(e[0],e[1],!1),!await this.pictures.paint(this.timers,i))throw new A("build",`A screen drawn in the scenery was not painted within ${String(i)} ms (Chrome's HTML-in-Canvas): its picture would be the last moment's.`)}read(e,i,n){const t=this.pictures?.get(e);if(!t)return"it is not drawn in the scenery";if(!t.size)return"its picture was never copied into its texture";if(!(this.renderer instanceof W))return"its scenery is not drawn with WebGL";if(n)return"the scenery's WebGL context was lost";let r;try{r=k(this.renderer.getContext(),t.texture.sourceTexture,i)}finally{this.renderer.resetState()}return typeof r=="string"?r:{...r,element:t.element}}repaint(e){const i=this.pictures?.get(e);i&&(i.dirty=!0)}mapToFace(e,i){const n=this.face(e);if(!n)return;const t=new f(...n.point(0,0)),r=new f(...n.point(1,0)).sub(t),s=new f(...n.point(0,1)).sub(t),o=r.lengthSq(),c=s.lengthSq(),p=new f;for(const x of i){const u=x.geometry;if(this.mapped.has(u))continue;const h=u.getAttribute("position"),d=new Float32Array(h.count*2);x.updateWorldMatrix(!0,!1);for(let m=0;m<h.count;m++)p.fromBufferAttribute(h,m).applyMatrix4(x.matrixWorld).sub(t),d[m*2]=p.dot(r)/o,d[m*2+1]=p.dot(s)/c;u.setAttribute("uv",new D(d,2)),this.mapped.add(u)}}lightBy(e){const i=this.pictures,n=[];for(const t of e){const r=this.lit.get(t),s=i?.get(t),o=this.face(t);if(r===!1||r===void 0||!s?.size||!o)continue;const c=new f(...o.point(0,0));n.push({picture:s.texture,size:s.size,corner:c,across:new f(...o.point(1,0)).sub(c),down:new f(...o.point(0,1)).sub(c),brightness:s.brightness,cells:r.cells,specular:r.specular,...r.base?{base:r.base}:{}})}this.light.set(n),n.length!==0&&this.scene.traverse(t=>{if(!(t instanceof L))return;const r=Array.isArray(t.material)?t.material:[t.material];for(const s of r)s.isMeshStandardMaterial&&s.userData.screenLight!==!1&&!i?.owns(s)&&this.light.patch(s)})}face(e){const i=this.object(e);if(!i)return;const n=T(i);if(!n)return;const t=n.geometry;t.boundingBox||t.computeBoundingBox();const r=t.boundingBox;if(!r)return;n.updateWorldMatrix(!0,!1);const s=n.matrixWorld,o=(d,m)=>C(new f(r.min.x+(r.max.x-r.min.x)*d,r.max.y-(r.max.y-r.min.y)*m,r.max.z).applyMatrix4(s)),c=o(0,0),p=o(1,0),x=o(0,1),u=O(p,c),h=O(x,c);return{point:o,center:o(.5,.5),normal:C(new f(0,0,1).transformDirection(s)),up:N([-h[0],-h[1],-h[2]]),width:E(u),height:E(h)}}quad(e,i,n){const t=T(this.mustObject(e));if(!t)throw new A("name",`The screen "${e}" has no mesh to show content on.`);const r=t.geometry;r.boundingBox||r.computeBoundingBox();const s=r.boundingBox;if(!s)return;const o=[];let c=0;for(const[v,z]of[[s.min.x,s.max.y],[s.max.x,s.max.y],[s.max.x,s.min.y],[s.min.x,s.min.y]]){const j=new f(v,z,s.max.z).applyMatrix4(t.matrixWorld),M=G(i,[j.x,j.y,j.z]);if(!(M.depth>i.near))return;c=Math.max(c,M.depth),o.push([(M.x+1)/2*n[0],(1-M.y)/2*n[1]])}const[p,x,u,h]=o;if(!p||!x||!u||!h)return;const d=[p,x,u,h],[m,w]=$(d,n)??[.5,.5],y=new f(s.min.x+(s.max.x-s.min.x)*m,s.max.y-(s.max.y-s.min.y)*w,s.max.z).applyMatrix4(t.matrixWorld),b=new f(0,0,1).transformDirection(t.matrixWorld),g=new f(...i.position).sub(y).normalize(),a=Math.acos(Math.max(-1,Math.min(1,b.dot(g))))*180/Math.PI;return{corners:d,angle:a,depth:c}}async hidden(e,i,n,t){const r=this.mustObject(e),s=H(this.scene),o=P(this.scene,s,!0);o.some(a=>a.object===r)||o.push({object:r,name:e,path:s.get(r)??e});const c=this.quad(e,i.resolved,[n,t]);if(!c)return;const p=c.corners.map(a=>a[0]),x=c.corners.map(a=>a[1]),u=Math.max(0,Math.floor(Math.min(...p))),h=Math.max(0,Math.floor(Math.min(...x))),d=Math.min(n,Math.ceil(Math.max(...p))),m=Math.min(t,Math.ceil(Math.max(...x)));if(d<=u||m<=h)return;let w=i.camera;if(i.camera instanceof F){const a=i.camera.clone();a.setViewOffset(n,t,u,h,d-u,m-h),a.far=Math.min(a.far,c.depth*1.001+.001),a.updateProjectionMatrix(),w=a}const y=U(c.corners),b=w!==i.camera,[g]=await R(this.renderer,this.scene,w,o,b?d-u:n,b?m-h:t,{by:!0,of:new Set([r]),region:b?(a,v)=>y(a+u,v+h):y});if(!(!g||g.pixels===0&&g.hidden===0))return{hidden:g.hidden,by:(g.by??[]).map(a=>({object:a.path,share:a.share}))}}}
2
+ import{Color as W,Float32BufferAttribute as F,Mesh as O,PerspectiveCamera as D,Vector3 as f,WebGLRenderer as S}from"three";import{clipToFrame as G,project as A,shownCentre as $}from"@allyhub/scenery";import{reflectsAreaLights as P}from"../bake/apply.js";import{SceneryError as L}from"../errors.js";import{countable as k,seenFrom as R}from"../idbuffer.js";import{readTextureLevel as H}from"../measure/screen-readback.js";import{paths as I,vec as T}from"../scene.js";import{SCREEN_LIGHT_DEFAULTS as z,ScreenLight as V}from"../screen-light.js";import{ScreenPictures as _,canDrawElements as N}from"../screen-picture.js";import{length as C,normalize as Q,sub as q}from"../vec.js";function U(b,e){const i=b.brightness??e,n=typeof b.color=="string"?new W(b.color):b.color?new W(...b.color):new W(1,1,1);return[n.r*i,n.g*i,n.b*i]}function J(b){return(e,i)=>{let n=0;for(let r=0;r<b.length;r++){const s=b[r],t=b[(r+1)%b.length];if(!s||!t)return!1;const o=(t[0]-s[0])*(i-s[1])-(t[1]-s[1])*(e-s[0]);if(o===0)continue;const h=o>0?1:-1;if(n===0)n=h;else if(h!==n)return!1}return!0}}function E(b){let e;return b.traverse(i=>{!e&&i instanceof O&&(e=i)}),e}export class Screens{scene;renderer;object;mustObject;report;timers;pictures;lit=new Map;light=new V(P);mapped=new WeakSet;constructor(e){this.scene=e.scene,this.renderer=e.renderer,this.object=e.object,this.mustObject=e.mustObject,this.report=e.report,this.timers=e.timers}get drawsElements(){return this.renderer instanceof S&&N()}get canvas(){return this.pictures?.host??this.renderer.domElement}picture(e){return this.pictures?.get(e)}owns(e){return this.pictures?.owns(e)??!1}factorOf(e){return this.pictures?.factorOf(e)}adopt(e){this.pictures?.adopt(e)}frame(e,i){this.pictures?.frame(e,i)}show(e,i,n={}){if(!(this.renderer instanceof S))throw new L("build",`A screen drawn in the scenery ("${e}") needs the WebGL renderer.`);this.pictures??=new _(this.renderer,(r,s)=>{this.report({kind:"screen",level:"error",message:`The screen "${r}", drawn in the scenery, cannot show its element as it is: ${s}.`})}),this.pictures.show(e,i,n),this.lit.set(e,n.light===!1?!1:{cells:[...n.light?.cells??z.cells],specular:n.light?.specular??z.specular,base:(()=>{const r=n.light?.base??z.base;return r?U(r,n.brightness??1):null})()})}async paint(e,i=5e3){if(!this.pictures)return;const n=this.renderer.domElement;if(e&&(n.width!==e[0]||n.height!==e[1])&&this.renderer.setSize(e[0],e[1],!1),!await this.pictures.paint(this.timers,i))throw new L("build",`A screen drawn in the scenery was not painted within ${String(i)} ms (Chrome's HTML-in-Canvas): its picture would be the last moment's.`)}read(e,i,n){const r=this.pictures?.get(e);if(!r)return"it is not drawn in the scenery";if(!r.size)return"its picture was never copied into its texture";if(!(this.renderer instanceof S))return"its scenery is not drawn with WebGL";if(n)return"the scenery's WebGL context was lost";let s;try{s=H(this.renderer.getContext(),r.texture.sourceTexture,i)}finally{this.renderer.resetState()}return typeof s=="string"?s:{...s,element:r.element}}repaint(e){const i=this.pictures?.get(e);i&&(i.dirty=!0)}mapToFace(e,i){const n=this.face(e);if(!n)return;const r=new f(...n.point(0,0)),s=new f(...n.point(1,0)).sub(r),t=new f(...n.point(0,1)).sub(r),o=s.lengthSq(),h=t.lengthSq(),x=new f;for(const p of i){const l=p.geometry;if(this.mapped.has(l))continue;const u=l.getAttribute("position"),g=new Float32Array(u.count*2);p.updateWorldMatrix(!0,!1);for(let d=0;d<u.count;d++)x.fromBufferAttribute(u,d).applyMatrix4(p.matrixWorld).sub(r),g[d*2]=x.dot(s)/o,g[d*2+1]=x.dot(t)/h;l.setAttribute("uv",new F(g,2)),this.mapped.add(l)}}lightBy(e){const i=this.pictures,n=[];for(const r of e){const s=this.lit.get(r),t=i?.get(r),o=this.face(r);if(s===!1||s===void 0||!t?.size||!o)continue;const h=new f(...o.point(0,0));n.push({picture:t.texture,size:t.size,corner:h,across:new f(...o.point(1,0)).sub(h),down:new f(...o.point(0,1)).sub(h),brightness:t.brightness,cells:s.cells,specular:s.specular,...s.base?{base:s.base}:{}})}this.light.set(n),n.length!==0&&this.scene.traverse(r=>{if(!(r instanceof O))return;const s=Array.isArray(r.material)?r.material:[r.material];for(const t of s)t.isMeshStandardMaterial&&t.userData.screenLight!==!1&&!i?.owns(t)&&this.light.patch(t)})}face(e){const i=this.object(e);if(!i)return;const n=E(i);if(!n)return;const r=n.geometry;r.boundingBox||r.computeBoundingBox();const s=r.boundingBox;if(!s)return;n.updateWorldMatrix(!0,!1);const t=n.matrixWorld,o=(g,d)=>T(new f(s.min.x+(s.max.x-s.min.x)*g,s.max.y-(s.max.y-s.min.y)*d,s.max.z).applyMatrix4(t)),h=o(0,0),x=o(1,0),p=o(0,1),l=q(x,h),u=q(p,h);return{point:o,center:o(.5,.5),normal:T(new f(0,0,1).transformDirection(t)),up:Q([-u[0],-u[1],-u[2]]),width:C(l),height:C(u)}}share(e,i,n){const r=E(this.mustObject(e)),s=r?.geometry;if(!r||!s)return 0;s.boundingBox||s.computeBoundingBox();const t=s.boundingBox;if(!t)return 0;const o=new f((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,t.max.z).applyMatrix4(r.matrixWorld);if(new f(0,0,1).transformDirection(r.matrixWorld).dot(new f(...i.position).sub(o))<=0)return 0;const x=[[t.min.x,t.max.y],[t.max.x,t.max.y],[t.max.x,t.min.y],[t.min.x,t.min.y]].map(([c,w])=>{const m=new f(c,w,t.max.z).applyMatrix4(r.matrixWorld);return[m.x,m.y,m.z]}),p=i.near,l=c=>A(i,c).depth,u=[];if(x.forEach((c,w)=>{const m=x[(w+1)%x.length]??c,a=l(c),M=l(m);if(a>=p&&u.push(c),a>=p!=M>=p){const j=(p-a)/(M-a);u.push([c[0]+(m[0]-c[0])*j,c[1]+(m[1]-c[1])*j,c[2]+(m[2]-c[2])*j])}}),u.length<3)return 0;const g=u.map(c=>{const w=A(i,c);return[(w.x+1)/2*n[0],(1-w.y)/2*n[1]]}),d=G(g,n[0],n[1]);let y=0;return d.forEach((c,w)=>{const m=d[(w+1)%d.length]??c;y+=c[0]*m[1]-m[0]*c[1]}),Math.min(1,Math.abs(y)/2/(n[0]*n[1]))}quad(e,i,n){const r=E(this.mustObject(e));if(!r)throw new L("name",`The screen "${e}" has no mesh to show content on.`);const s=r.geometry;s.boundingBox||s.computeBoundingBox();const t=s.boundingBox;if(!t)return;const o=[];let h=0;for(const[M,j]of[[t.min.x,t.max.y],[t.max.x,t.max.y],[t.max.x,t.min.y],[t.min.x,t.min.y]]){const B=new f(M,j,t.max.z).applyMatrix4(r.matrixWorld),v=A(i,[B.x,B.y,B.z]);if(!(v.depth>i.near))return;h=Math.max(h,v.depth),o.push([(v.x+1)/2*n[0],(1-v.y)/2*n[1]])}const[x,p,l,u]=o;if(!x||!p||!l||!u)return;const g=[x,p,l,u],[d,y]=$(g,n)??[.5,.5],c=new f(t.min.x+(t.max.x-t.min.x)*d,t.max.y-(t.max.y-t.min.y)*y,t.max.z).applyMatrix4(r.matrixWorld),w=new f(0,0,1).transformDirection(r.matrixWorld),m=new f(...i.position).sub(c).normalize(),a=Math.acos(Math.max(-1,Math.min(1,w.dot(m))))*180/Math.PI;return{corners:g,angle:a,depth:h}}async hidden(e,i,n,r){const s=this.mustObject(e),t=I(this.scene),o=k(this.scene,t,!0);o.some(a=>a.object===s)||o.push({object:s,name:e,path:t.get(s)??e});const h=this.quad(e,i.resolved,[n,r]);if(!h)return;const x=h.corners.map(a=>a[0]),p=h.corners.map(a=>a[1]),l=Math.max(0,Math.floor(Math.min(...x))),u=Math.max(0,Math.floor(Math.min(...p))),g=Math.min(n,Math.ceil(Math.max(...x))),d=Math.min(r,Math.ceil(Math.max(...p)));if(g<=l||d<=u)return;let y=i.camera;if(i.camera instanceof D){const a=i.camera.clone();a.setViewOffset(n,r,l,u,g-l,d-u),a.far=Math.min(a.far,h.depth*1.001+.001),a.updateProjectionMatrix(),y=a}const c=J(h.corners),w=y!==i.camera,[m]=await R(this.renderer,this.scene,y,o,w?g-l:n,w?d-u:r,{by:!0,of:new Set([s]),region:w?(a,M)=>c(a+l,M+u):c});if(!(!m||m.pixels===0&&m.hidden===0))return{hidden:m.hidden,by:(m.by??[]).map(a=>({object:a.path,share:a.share}))}}}
@@ -38,6 +38,12 @@ export interface PickedObject {
38
38
  size: [number, number, number];
39
39
  /** Where the pointer met it, world space, m. */
40
40
  point: [number, number, number];
41
+ /**
42
+ * Its box as the camera sees it: the outline round its eight corners, in
43
+ * px of the viewer (its edge for a person who picks it; its silhouette is
44
+ * later). None where a corner is behind the camera.
45
+ */
46
+ screen?: [number, number][];
41
47
  }
42
48
  /** What the viewer tells the page that embeds it. */
43
49
  export type ViewerEvent = {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{Box3 as xt,Mesh as wt,PerspectiveCamera as ht,Raycaster as bt,Vector2 as vt,Vector3 as h}from"three";import{fitCamera as Mt}from"@allyhub/scenery";import{ownFrame as kt,ownTimers as q}from"./clock.js";import{SceneryPage as Et}from"./page/page.js";const U=i=>{kt(i)},z=()=>q.now();export const VIEWER_DEFAULTS={orbitSpeed:.3,maxElevation:89,dollyPerNotch:.12,minDistance:.02,maxDistance:200,lens:30,flyMs:450,wheelRestMs:150,fill:.8,clickSlop:4,marks:!0,markColor:"#1471e2"};const Q=i=>i*Math.PI/180,pt=i=>[Math.round(i.x*1e3)/1e3,Math.round(i.y*1e3)/1e3,Math.round(i.z*1e3)/1e3],_=i=>i*180/Math.PI;function zt(i,u){const M=Math.hypot(36,24)/Math.hypot(u,1);return _(2*Math.atan(M/(2*i)))}function G(i){const u=Q(i.elevation),c=Q(i.azimuth);return new h(i.target.x+i.distance*Math.cos(u)*Math.sin(c),i.target.y+i.distance*Math.sin(u),i.target.z+i.distance*Math.cos(u)*Math.cos(c))}function D(i,u){const c=i.clone().sub(u),M=Math.max(c.length(),1e-4);return{target:u.clone(),azimuth:_(Math.atan2(c.x,c.z)),elevation:_(Math.asin(Math.max(-1,Math.min(1,c.y/M)))),distance:M}}function Ct(i){const u=[];for(let c=i;c?.parent;c=c.parent)c.name&&u.unshift(c);return u}const St=(i,u)=>i.length===u.length&&i.every((c,M)=>c===u[M]);function T(i){return new xt().setFromObject(i)}export async function startViewer(i,u,c,M={},x=()=>{},Y){const p={...VIEWER_DEFAULTS,...M},g=await Et.open(i,u),H=()=>0;g.pose(0,H);const d=g.renderer.domElement;d.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab",getComputedStyle(c).position==="static"&&(c.style.position="relative"),c.style.overflow="hidden",c.appendChild(d);const J=t=>{const e=document.createElement("div");e.style.cssText=`position:absolute;pointer-events:none;border:1.5px ${t?"dashed":"solid"} ${p.markColor};border-radius:4px;display:none`;const n=document.createElement("div");return n.style.cssText=`position:absolute;left:-1px;bottom:100%;margin-bottom:4px;font:12px/1.3 system-ui,sans-serif;color:#fff;background:${p.markColor};padding:2px 6px;border-radius:4px;white-space:nowrap`,e.appendChild(n),c.appendChild(e),{box:e,label:n}},mt=J(!0),ut=J(!1),O=T(g.scene),Z=O.isEmpty()?new h:O.getCenter(new h),ft=O.isEmpty()?1:Math.max(O.getSize(new h).length()/2,.05);let s={target:Z,azimuth:25,elevation:20,distance:ft*2.4};const $=g.named.cameras,tt=Object.keys($)[0];let w=new ht(40,1,.01,500);const C=()=>{const t=c.getBoundingClientRect();return{w:Math.max(1,t.width),h:Math.max(1,t.height)}},et=t=>{const e=$[t];if(!e)return;const{w:n,h:a}=C(),o=g.aim(e,n/a),r=o.camera.position.clone(),l=new h(0,0,-1).applyQuaternion(o.camera.quaternion),m=typeof e.target=="string"?new h(...g.pointOf(e.target)):Array.isArray(e.target)?new h(...e.target):r.clone().add(l.multiplyScalar(Math.max(r.distanceTo(Z),.1)));return D(r,m)};Y?s=D(new h(...Y.position),new h(...Y.target)):tt&&(s=et(tt)??s);let y=[],v=[],X=!1;const yt=t=>{const e=t[t.length-1];if(!e)return null;const n=T(e);if(n.isEmpty())return null;const{w:a,h:o}=C();let r=1/0,l=1/0,m=-1/0,b=-1/0;for(let S=0;S<8;S++){const j=new h(S&1?n.max.x:n.min.x,S&2?n.max.y:n.min.y,S&4?n.max.z:n.min.z).project(w);if(j.z>1)return null;r=Math.min(r,(j.x+1)/2*a),l=Math.min(l,(1-j.y)/2*o),m=Math.max(m,(j.x+1)/2*a),b=Math.max(b,(1-j.y)/2*o)}const A=4,W=Math.max(0,r-A),K=Math.max(0,l-A),lt=Math.min(a,m+A),dt=Math.min(o,b+A);return lt<=W||dt<=K?null:{x:W,y:K,width:lt-W,height:dt-K}},nt=(t,e)=>{const n=yt(e);return!n||!p.marks?(t.box.style.display="none",n):(t.box.style.display="block",t.box.style.left=`${String(n.x)}px`,t.box.style.top=`${String(n.y)}px`,t.box.style.width=`${String(n.width)}px`,t.box.style.height=`${String(n.height)}px`,t.label.textContent=e.map(a=>a.name).join(" › "),n)},I=()=>{X=!1;const{w:t,h:e}=C(),n=Math.min(window.devicePixelRatio||1,2),a=z();w=new ht(zt(p.lens,t/e),t/e,Math.max(.005,s.distance/500),Math.max(50,s.distance*50)),w.position.copy(G(s)),w.lookAt(s.target),w.updateMatrixWorld(!0),g.pose(0,H),g.drawer.inPlace(w,Math.round(t*n),Math.round(e*n)),d.style.width="100%",d.style.height="100%";const o=nt(mt,St(v,y)?[]:v),r=nt(ut,y);x({type:"place",hover:o,select:r}),x({type:"drawn",ms:z()-a})},k=()=>{X||(X=!0,U(I))};let P=0;const L=t=>{const e={...s,target:s.target.clone()},n=++P,a=z();let o=t.azimuth-e.azimuth;o=((o+180)%360+360)%360-180;const r=()=>{if(n!==P)return;const l=Math.min(1,(z()-a)/p.flyMs),m=l<.5?4*l*l*l:1-(-2*l+2)**3/2;s={target:e.target.clone().lerp(t.target,m),azimuth:e.azimuth+o*m,elevation:e.elevation+(t.elevation-e.elevation)*m,distance:e.distance*(t.distance/e.distance)**m},I(),l<1?U(r):R()};U(r)},R=()=>{x({type:"camera",camera:{position:pt(G(s)),target:pt(s.target),lens:p.lens},framed:E.length>0})},ot=new bt,F=(t,e)=>{const n=c.getBoundingClientRect(),a=new vt((t-n.left)/n.width*2-1,-((e-n.top)/n.height)*2+1);ot.setFromCamera(a,w);const o=ot.intersectObject(g.scene,!0);for(const r of o){if(!(r.object instanceof wt)||!r.object.visible)continue;let l=!0;for(let b=r.object;b;b=b.parent)b.visible||(l=!1);if(!l)continue;const m=Ct(r.object);if(m.length>0)return{path:m,point:r.point}}return null},B=(t,e)=>{const n=t[t.length-1]??g.scene,a=T(n).getSize(new h),o=r=>Math.round(r*1e3)/1e3;return{path:t.map(r=>r.name),name:n.name,size:[o(a.x),o(a.y),o(a.z)],point:[o(e.x),o(e.y),o(e.z)]}},N=t=>t.slice(0,1);let f;d.addEventListener("contextmenu",t=>{t.preventDefault()}),d.addEventListener("pointerdown",t=>{d.setPointerCapture(t.pointerId),P++,f={x:t.clientX,y:t.clientY,moved:!1,pan:t.button===2||t.button===1||t.shiftKey,id:t.pointerId},d.style.cursor="grabbing"}),d.addEventListener("pointermove",t=>{if(f?.id===t.pointerId){const a=t.clientX-f.x,o=t.clientY-f.y;if(!f.moved&&Math.hypot(a,o)<p.clickSlop)return;if(f.moved=!0,f.x=t.clientX,f.y=t.clientY,f.pan){const{h:r}=C(),l=2*s.distance*Math.tan(Q(w.fov)/2)/r,m=new h().setFromMatrixColumn(w.matrixWorld,0),b=new h().setFromMatrixColumn(w.matrixWorld,1);s.target.add(m.multiplyScalar(-a*l)),s.target.add(b.multiplyScalar(o*l))}else s.azimuth-=a*p.orbitSpeed,s.elevation=Math.max(-p.maxElevation,Math.min(p.maxElevation,s.elevation+o*p.orbitSpeed));k();return}const e=F(t.clientX,t.clientY),n=e?N(e.path):[];(n.length!==v.length||n.some((a,o)=>a!==v[o]))&&(v=n,d.style.cursor=v.length?"pointer":"grab",x({type:"hover",object:e&&n.length?B(n,e.point):null}),k())});const at=t=>{if(f?.id!==t.pointerId)return;const e=!f.moved&&!f.pan,n=f.moved;if(f=void 0,d.style.cursor=v.length?"pointer":"grab",n&&R(),!e)return;const a=F(t.clientX,t.clientY);y=a?N(a.path):[],x({type:"select",object:a&&y.length?B(y,a.point):null}),k()};d.addEventListener("pointerup",at),d.addEventListener("pointercancel",at),d.addEventListener("pointerleave",()=>{v.length&&(v=[],x({type:"hover",object:null}),k())});let it;const rt=(t,e)=>{P++;const n=t/100*(e?4:1);s.distance=Math.max(p.minDistance,Math.min(p.maxDistance,s.distance*(1+p.dollyPerNotch)**n)),k(),q.clearTimeout(it),it=q.setTimeout(R,p.wheelRestMs)};d.addEventListener("wheel",t=>{t.preventDefault(),rt(t.deltaY,t.ctrlKey)},{passive:!1}),new ResizeObserver(k).observe(c);const E=[],V=t=>{const e=T(t);if(e.isEmpty())return;const n=e.getCenter(new h),{w:a,h:o}=C(),r=s.target.clone().sub(G(s));let l;try{const m=Mt({boxes:[{min:e.min.toArray(),max:e.max.toArray()}],aspect:a/o,direction:r.toArray(),aim:n.toArray(),lens:p.lens,fill:p.fill,near:Math.max(.005,e.getSize(new h).length()/500)});l=new h(...m.position)}catch{return}E.push({...s,target:s.target.clone()}),L(D(l,n))},st=t=>{const e=[];let n=g.scene;for(const a of t){let o;if(n.traverse(r=>{!o&&r!==n&&r.name===a&&(o=r)}),!o)return[];e.push(o),n=o}return e},ct=t=>{switch(t.type){case"camera":{const e=et(t.name);e&&(E.push({...s,target:s.target.clone()}),L(e));return}case"view":{E.push({...s,target:s.target.clone()}),L(D(new h(...t.position),new h(...t.target)));return}case"wheel":rt(t.deltaY,t.ctrlKey);return;case"frame":{const e=st(t.path).pop();e&&V(e);return}case"shot":{I();const e=document.createElement("canvas");e.width=d.width,e.height=d.height;const n=e.getContext("2d");n&&(n.fillStyle=getComputedStyle(document.body).backgroundColor,n.fillRect(0,0,e.width,e.height),n.drawImage(d,0,0)),x({type:"shot",picture:e.toDataURL("image/webp",.9)});return}case"pick":{const e=F(t.x,t.y);x({type:"picked",id:t.id,object:e?B(e.path,e.point):null});return}case"back":{const e=E.pop();e&&L(e);return}case"select":y=t.path?st(t.path):[],k();return}};window.addEventListener("keydown",t=>{if(t.key==="Escape")E.length?ct({type:"back"}):y.length&&(y=y.slice(0,-1),x({type:"select",object:null}),k());else if((t.key==="f"||t.key==="F")&&y.length){const e=y[y.length-1];e&&V(e)}}),d.addEventListener("dblclick",t=>{const e=F(t.clientX,t.clientY),n=e?N(e.path).pop():void 0;n&&V(n)});const gt=z();return I(),x({type:"ready",cameras:Object.keys($),ms:z()-gt}),R(),{command:ct}}
2
+ import{Box3 as wt,Mesh as bt,PerspectiveCamera as ht,Raycaster as Mt,Vector2 as vt,Vector3 as p}from"three";import{fitCamera as kt}from"@allyhub/scenery";import{ownFrame as zt,ownTimers as q}from"./clock.js";import{SceneryPage as Et}from"./page/page.js";const U=c=>{zt(c)},S=()=>q.now();export const VIEWER_DEFAULTS={orbitSpeed:.3,maxElevation:89,dollyPerNotch:.12,minDistance:.02,maxDistance:200,lens:30,flyMs:450,wheelRestMs:150,fill:.8,clickSlop:4,marks:!0,markColor:"#1471e2"};const Q=c=>c*Math.PI/180,pt=c=>[Math.round(c.x*1e3)/1e3,Math.round(c.y*1e3)/1e3,Math.round(c.z*1e3)/1e3],_=c=>c*180/Math.PI;function Ct(c,f){const k=Math.hypot(36,24)/Math.hypot(f,1);return _(2*Math.atan(k/(2*c)))}function G(c){const f=Q(c.elevation),d=Q(c.azimuth);return new p(c.target.x+c.distance*Math.cos(f)*Math.sin(d),c.target.y+c.distance*Math.sin(f),c.target.z+c.distance*Math.cos(f)*Math.cos(d))}function Y(c,f){const d=c.clone().sub(f),k=Math.max(d.length(),1e-4);return{target:f.clone(),azimuth:_(Math.atan2(d.x,d.z)),elevation:_(Math.asin(Math.max(-1,Math.min(1,d.y/k)))),distance:k}}function St(c){const f=[];for(let d=c;d?.parent;d=d.parent)d.name&&f.unshift(d);return f}const jt=(c,f)=>c.length===f.length&&c.every((d,k)=>d===f[k]);function P(c){return new wt().setFromObject(c)}export async function startViewer(c,f,d,k={},M=()=>{},$){const u={...VIEWER_DEFAULTS,...k},w=await Et.open(c,f),H=()=>0;w.pose(0,H);const h=w.renderer.domElement;h.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab",getComputedStyle(d).position==="static"&&(d.style.position="relative"),d.style.overflow="hidden",d.appendChild(h);const J=t=>{const e=document.createElement("div");e.style.cssText=`position:absolute;pointer-events:none;border:1.5px ${t?"dashed":"solid"} ${u.markColor};border-radius:4px;display:none`;const n=document.createElement("div");return n.style.cssText=`position:absolute;left:-1px;bottom:100%;margin-bottom:4px;font:12px/1.3 system-ui,sans-serif;color:#fff;background:${u.markColor};padding:2px 6px;border-radius:4px;white-space:nowrap`,e.appendChild(n),d.appendChild(e),{box:e,label:n}},mt=J(!0),ut=J(!1),R=P(w.scene),Z=R.isEmpty()?new p:R.getCenter(new p),ft=R.isEmpty()?1:Math.max(R.getSize(new p).length()/2,.05);let l={target:Z,azimuth:25,elevation:20,distance:ft*2.4};const B=w.named.cameras,tt=Object.keys(B)[0];let b=new ht(40,1,.01,500);const j=()=>{const t=d.getBoundingClientRect();return{w:Math.max(1,t.width),h:Math.max(1,t.height)}},et=t=>{const e=B[t];if(!e)return;const{w:n,h:r}=j(),a=w.aim(e,n/r),s=a.camera.position.clone(),o=new p(0,0,-1).applyQuaternion(a.camera.quaternion),i=typeof e.target=="string"?new p(...w.pointOf(e.target)):Array.isArray(e.target)?new p(...e.target):s.clone().add(o.multiplyScalar(Math.max(s.distanceTo(Z),.1)));return Y(s,i)};$?l=Y(new p(...$.position),new p(...$.target)):tt&&(l=et(tt)??l);let x=[],v=[],N=!1;const yt=t=>{const e=t[t.length-1];if(!e)return null;const n=P(e);if(n.isEmpty())return null;const{w:r,h:a}=j();let s=1/0,o=1/0,i=-1/0,m=-1/0;for(let O=0;O<8;O++){const I=new p(O&1?n.max.x:n.min.x,O&2?n.max.y:n.min.y,O&4?n.max.z:n.min.z).project(b);if(I.z>1)return null;s=Math.min(s,(I.x+1)/2*r),o=Math.min(o,(1-I.y)/2*a),i=Math.max(i,(I.x+1)/2*r),m=Math.max(m,(1-I.y)/2*a)}const g=4,C=Math.max(0,s-g),K=Math.max(0,o-g),lt=Math.min(r,i+g),dt=Math.min(a,m+g);return lt<=C||dt<=K?null:{x:C,y:K,width:lt-C,height:dt-K}},nt=(t,e)=>{const n=yt(e);return!n||!u.marks?(t.box.style.display="none",n):(t.box.style.display="block",t.box.style.left=`${String(n.x)}px`,t.box.style.top=`${String(n.y)}px`,t.box.style.width=`${String(n.width)}px`,t.box.style.height=`${String(n.height)}px`,t.label.textContent=e.map(r=>r.name).join(" › "),n)},F=()=>{N=!1;const{w:t,h:e}=j(),n=Math.min(window.devicePixelRatio||1,2),r=S();b=new ht(Ct(u.lens,t/e),t/e,Math.max(.005,l.distance/500),Math.max(50,l.distance*50)),b.position.copy(G(l)),b.lookAt(l.target),b.updateMatrixWorld(!0),w.pose(0,H),w.drawer.inPlace(b,Math.round(t*n),Math.round(e*n)),h.style.width="100%",h.style.height="100%";const a=nt(mt,jt(v,x)?[]:v),s=nt(ut,x);M({type:"place",hover:a,select:s}),M({type:"drawn",ms:S()-r})},z=()=>{N||(N=!0,U(F))};let L=0;const A=t=>{const e={...l,target:l.target.clone()},n=++L,r=S();let a=t.azimuth-e.azimuth;a=((a+180)%360+360)%360-180;const s=()=>{if(n!==L)return;const o=Math.min(1,(S()-r)/u.flyMs),i=o<.5?4*o*o*o:1-(-2*o+2)**3/2;l={target:e.target.clone().lerp(t.target,i),azimuth:e.azimuth+a*i,elevation:e.elevation+(t.elevation-e.elevation)*i,distance:e.distance*(t.distance/e.distance)**i},F(),o<1?U(s):D()};U(s)},D=()=>{M({type:"camera",camera:{position:pt(G(l)),target:pt(l.target),lens:u.lens},framed:E.length>0})},ot=new Mt,T=(t,e)=>{const n=d.getBoundingClientRect(),r=new vt((t-n.left)/n.width*2-1,-((e-n.top)/n.height)*2+1);ot.setFromCamera(r,b);const a=ot.intersectObject(w.scene,!0);for(const s of a){if(!(s.object instanceof bt)||!s.object.visible)continue;let o=!0;for(let m=s.object;m;m=m.parent)m.visible||(o=!1);if(!o)continue;const i=St(s.object);if(i.length>0)return{path:i,point:s.point}}return null},X=(t,e)=>{const n=t[t.length-1]??w.scene,r=P(n).getSize(new p),a=o=>Math.round(o*1e3)/1e3,s=gt(P(n));return{path:t.map(o=>o.name),name:n.name,size:[a(r.x),a(r.y),a(r.z)],point:[a(e.x),a(e.y),a(e.z)],...s?{screen:s}:{}}},gt=t=>{const e=d.getBoundingClientRect(),n=[];for(const o of[t.min.x,t.max.x])for(const i of[t.min.y,t.max.y])for(const m of[t.min.z,t.max.z]){const g=new p(o,i,m).project(b);if(!Number.isFinite(g.x)||!Number.isFinite(g.y)||g.z>1)return;n.push([(g.x+1)/2*e.width,(1-g.y)/2*e.height])}n.sort((o,i)=>o[0]-i[0]||o[1]-i[1]);const r=(o,i,m)=>(i[0]-o[0])*(m[1]-o[1])-(i[1]-o[1])*(m[0]-o[0]),a=o=>{const i=[];for(const m of o){for(;i.length>=2;){const g=i.at(-2),C=i.at(-1);if(!g||!C||r(g,C,m)>0)break;i.pop()}i.push(m)}return i.pop(),i},s=[...a(n),...a([...n].reverse())];return s.length>=3?s.map(([o,i])=>[Math.round(o*10)/10,Math.round(i*10)/10]):void 0},V=t=>t.slice(0,1);let y;h.addEventListener("contextmenu",t=>{t.preventDefault()}),h.addEventListener("pointerdown",t=>{h.setPointerCapture(t.pointerId),L++,y={x:t.clientX,y:t.clientY,moved:!1,pan:t.button===2||t.button===1||t.shiftKey,id:t.pointerId},h.style.cursor="grabbing"}),h.addEventListener("pointermove",t=>{if(y?.id===t.pointerId){const r=t.clientX-y.x,a=t.clientY-y.y;if(!y.moved&&Math.hypot(r,a)<u.clickSlop)return;if(y.moved=!0,y.x=t.clientX,y.y=t.clientY,y.pan){const{h:s}=j(),o=2*l.distance*Math.tan(Q(b.fov)/2)/s,i=new p().setFromMatrixColumn(b.matrixWorld,0),m=new p().setFromMatrixColumn(b.matrixWorld,1);l.target.add(i.multiplyScalar(-r*o)),l.target.add(m.multiplyScalar(a*o))}else l.azimuth-=r*u.orbitSpeed,l.elevation=Math.max(-u.maxElevation,Math.min(u.maxElevation,l.elevation+a*u.orbitSpeed));z();return}const e=T(t.clientX,t.clientY),n=e?V(e.path):[];(n.length!==v.length||n.some((r,a)=>r!==v[a]))&&(v=n,h.style.cursor=v.length?"pointer":"grab",M({type:"hover",object:e&&n.length?X(n,e.point):null}),z())});const at=t=>{if(y?.id!==t.pointerId)return;const e=!y.moved&&!y.pan,n=y.moved;if(y=void 0,h.style.cursor=v.length?"pointer":"grab",n&&D(),!e)return;const r=T(t.clientX,t.clientY);x=r?V(r.path):[],M({type:"select",object:r&&x.length?X(x,r.point):null}),z()};h.addEventListener("pointerup",at),h.addEventListener("pointercancel",at),h.addEventListener("pointerleave",()=>{v.length&&(v=[],M({type:"hover",object:null}),z())});let it;const rt=(t,e)=>{L++;const n=t/100*(e?4:1);l.distance=Math.max(u.minDistance,Math.min(u.maxDistance,l.distance*(1+u.dollyPerNotch)**n)),z(),q.clearTimeout(it),it=q.setTimeout(D,u.wheelRestMs)};h.addEventListener("wheel",t=>{t.preventDefault(),rt(t.deltaY,t.ctrlKey)},{passive:!1}),new ResizeObserver(z).observe(d);const E=[],W=t=>{const e=P(t);if(e.isEmpty())return;const n=e.getCenter(new p),{w:r,h:a}=j(),s=l.target.clone().sub(G(l));let o;try{const i=kt({boxes:[{min:e.min.toArray(),max:e.max.toArray()}],aspect:r/a,direction:s.toArray(),aim:n.toArray(),lens:u.lens,fill:u.fill,near:Math.max(.005,e.getSize(new p).length()/500)});o=new p(...i.position)}catch{return}E.push({...l,target:l.target.clone()}),A(Y(o,n))},st=t=>{const e=[];let n=w.scene;for(const r of t){let a;if(n.traverse(s=>{!a&&s!==n&&s.name===r&&(a=s)}),!a)return[];e.push(a),n=a}return e},ct=t=>{switch(t.type){case"camera":{const e=et(t.name);e&&(E.push({...l,target:l.target.clone()}),A(e));return}case"view":{E.push({...l,target:l.target.clone()}),A(Y(new p(...t.position),new p(...t.target)));return}case"wheel":rt(t.deltaY,t.ctrlKey);return;case"frame":{const e=st(t.path).pop();e&&W(e);return}case"shot":{F();const e=document.createElement("canvas");e.width=h.width,e.height=h.height;const n=e.getContext("2d");n&&(n.fillStyle=getComputedStyle(document.body).backgroundColor,n.fillRect(0,0,e.width,e.height),n.drawImage(h,0,0)),M({type:"shot",picture:e.toDataURL("image/webp",.9)});return}case"pick":{const e=T(t.x,t.y);M({type:"picked",id:t.id,object:e?X(e.path,e.point):null});return}case"back":{const e=E.pop();e&&A(e);return}case"select":x=t.path?st(t.path):[],z();return}};window.addEventListener("keydown",t=>{if(t.key==="Escape")E.length?ct({type:"back"}):x.length&&(x=x.slice(0,-1),M({type:"select",object:null}),z());else if((t.key==="f"||t.key==="F")&&x.length){const e=x[x.length-1];e&&W(e)}}),h.addEventListener("dblclick",t=>{const e=T(t.clientX,t.clientY),n=e?V(e.path).pop():void 0;n&&W(n)});const xt=S();return F(),M({type:"ready",cameras:Object.keys(B),ms:S()-xt}),D(),{command:ct}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/scenery-host",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{parseValue as d}from"numfmt";import{CellError as f,ERR as s,Matrix as x,numberText as h,readTyped as M}from"../values.js";export function numberOfText(e){if(!/\d/u.test(e))return;const r=M(e.trim());if(typeof r.value=="number")return r.value;if(e.trim()==="")return;const t=d(e);return typeof t?.value=="number"?t.value:void 0}export function toNumber(e){return typeof e=="number"?e:e==null?0:typeof e=="boolean"?e?1:0:e instanceof f?e:numberOfText(e)??s.VALUE}export function toText(e){return typeof e=="string"?e:e==null?"":typeof e=="number"?h(e):typeof e=="boolean"?e?"TRUE":"FALSE":e}export function toBool(e){if(typeof e=="boolean")return e;if(e==null)return!1;if(typeof e=="number")return e!==0;if(e instanceof f)return e;const r=e.trim().toUpperCase();return r==="TRUE"?!0:r==="FALSE"?!1:s.VALUE}const m=e=>typeof e=="number"?0:typeof e=="string"?1:2;export const sameNumber=(e,r)=>e===r?!0:Math.abs(e-r)>1e-13*Math.max(Math.abs(e),Math.abs(r))?!1:Number(e.toPrecision(15))===Number(r.toPrecision(15));export function compare(e,r){const t=e??(typeof r=="string"?"":typeof r=="boolean"?!1:0),n=r??(typeof e=="string"?"":typeof e=="boolean"?!1:0),o=m(t),c=m(n);if(o!==c)return o<c?-1:1;if(typeof t=="number"&&typeof n=="number")return sameNumber(t,n)?0:t<n?-1:1;if(typeof t=="string"&&typeof n=="string"){const a=t.toUpperCase(),u=n.toUpperCase();return a===u?0:a<u?-1:1}return t===n?0:t===!1?-1:1}export const finite=e=>Number.isFinite(e)?e:s.NUM;export function snap(e,r,t){return Math.abs(e)<=Math.max(Math.abs(r),Math.abs(t))*89e-17?0:e}export function arithmetic(e,r,t){const n=toNumber(r);if(n instanceof f)return n;const o=toNumber(t);if(o instanceof f)return o;switch(e){case"+":return finite(snap(n+o,n,o));case"-":return finite(snap(n-o,n,o));case"*":return finite(n*o);case"/":return o===0?s.DIV0:finite(n/o);default:return n===0&&o===0?s.NUM:n===0&&o<0?s.DIV0:finite(n**o)}}export function binary(e,r,t){if(r instanceof f)return r;if(t instanceof f)return t;switch(e){case"&":{const n=toText(r);if(n instanceof f)return n;const o=toText(t);return o instanceof f?o:`${n}${o}`}case"=":return compare(r,t)===0;case"<>":return compare(r,t)!==0;case"<":return compare(r,t)<0;case"<=":return compare(r,t)<=0;case">":return compare(r,t)>0;case">=":return compare(r,t)>=0;default:return arithmetic(e,r,t)}}export function mapBoth(e,r,t){const n=Math.max(e.rows,r.rows),o=Math.max(e.cols,r.cols),c=new Array(n*o),a=(u,i,l)=>{const p=u.rows===1?0:i,y=u.cols===1?0:l;return p<u.rows&&y<u.cols?u.at(p,y):void 0};for(let u=0;u<n;u++)for(let i=0;i<o;i++){const l=a(e,u,i),p=a(r,u,i);c[u*o+i]=l===void 0||p===void 0?s.NA:t(l,p)}return new x(n,o,c)}
2
+ import{parseValue as x}from"numfmt";import{CellError as f,ERR as i,Matrix as h,numberText as M,readTyped as b}from"../values.js";const l=new Map,w=5e4;export function numberOfText(e){if(!/\d/u.test(e))return;if(l.has(e))return l.get(e);l.size>=w&&l.clear();const r=E(e);return l.set(e,r),r}function E(e){const r=b(e.trim());if(typeof r.value=="number")return r.value;if(e.trim()==="")return;const t=x(e);return typeof t?.value=="number"?t.value:void 0}export function toNumber(e){return typeof e=="number"?e:e==null?0:typeof e=="boolean"?e?1:0:e instanceof f?e:numberOfText(e)??i.VALUE}export function toText(e){return typeof e=="string"?e:e==null?"":typeof e=="number"?M(e):typeof e=="boolean"?e?"TRUE":"FALSE":e}export function toBool(e){if(typeof e=="boolean")return e;if(e==null)return!1;if(typeof e=="number")return e!==0;if(e instanceof f)return e;const r=e.trim().toUpperCase();return r==="TRUE"?!0:r==="FALSE"?!1:i.VALUE}const y=e=>typeof e=="number"?0:typeof e=="string"?1:2;export const sameNumber=(e,r)=>e===r?!0:Math.abs(e-r)>1e-13*Math.max(Math.abs(e),Math.abs(r))?!1:Number(e.toPrecision(15))===Number(r.toPrecision(15));export function compare(e,r){const t=e??(typeof r=="string"?"":typeof r=="boolean"?!1:0),n=r??(typeof e=="string"?"":typeof e=="boolean"?!1:0),o=y(t),c=y(n);if(o!==c)return o<c?-1:1;if(typeof t=="number"&&typeof n=="number")return sameNumber(t,n)?0:t<n?-1:1;if(typeof t=="string"&&typeof n=="string"){const a=t.toUpperCase(),u=n.toUpperCase();return a===u?0:a<u?-1:1}return t===n?0:t===!1?-1:1}export const finite=e=>Number.isFinite(e)?e:i.NUM;export function snap(e,r,t){return Math.abs(e)<=Math.max(Math.abs(r),Math.abs(t))*89e-17?0:e}export function arithmetic(e,r,t){const n=toNumber(r);if(n instanceof f)return n;const o=toNumber(t);if(o instanceof f)return o;switch(e){case"+":return finite(snap(n+o,n,o));case"-":return finite(snap(n-o,n,o));case"*":return finite(n*o);case"/":return o===0?i.DIV0:finite(n/o);default:return n===0&&o===0?i.NUM:n===0&&o<0?i.DIV0:finite(n**o)}}export function binary(e,r,t){if(r instanceof f)return r;if(t instanceof f)return t;switch(e){case"&":{const n=toText(r);if(n instanceof f)return n;const o=toText(t);return o instanceof f?o:`${n}${o}`}case"=":return compare(r,t)===0;case"<>":return compare(r,t)!==0;case"<":return compare(r,t)<0;case"<=":return compare(r,t)<=0;case">":return compare(r,t)>0;case">=":return compare(r,t)>=0;default:return arithmetic(e,r,t)}}export function mapBoth(e,r,t){const n=Math.max(e.rows,r.rows),o=Math.max(e.cols,r.cols),c=new Array(n*o),a=(u,s,d)=>{const p=u.rows===1?0:s,m=u.cols===1?0:d;return p<u.rows&&m<u.cols?u.at(p,m):void 0};for(let u=0;u<n;u++)for(let s=0;s<o;s++){const d=a(e,u,s),p=a(r,u,s);c[u*o+s]=d===void 0||p===void 0?i.NA:t(d,p)}return new h(n,o,c)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as E,MAX_ROWS as k,overlaps as O}from"../address.js";import{CellError as m,ERR as h,Matrix as p,serialOfDate as _}from"../values.js";import{filteredRows as B}from"../filter.js";import{FormulaCell as y,SharedFormula as I}from"../workbook.js";import{analyse as z}from"./analyse.js";import{Graph as T}from"./graph.js";import{fromWire as G,matrixFromWire as D,matrixToWire as W,toWire as P}from"./remote.js";import{RangeCache as U}from"./indexes.js";import{binary as S,mapBoth as H,toNumber as q}from"./coerce.js";import{FUNCTIONS as v}from"./functions/index.js";import{fillsGroup as j,paramAt as X}from"./functions/define.js";import{Lambda as M,MISSING as F,Missing as x,Reference as u,Union as b}from"./types.js";export function seededRandom(l){let t=2166136261;for(let e=0;e<l.length;e++)t=Math.imul(t^l.charCodeAt(e),16777619);return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const Y=new Set,Z=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,$=2e3,N=12,J=(l,t)=>!l||!t?l===t:l.rows!==t.rows||l.cols!==t.cols?!1:l.data.every((e,s)=>e===t.data[s]),K=(l,t)=>l.row<t.row||l.row===t.row&&l.col<t.col;export class Calc{cycles=[];computed=0;nowSerial;random;pass=0;stack=[];inCycle=new Set;namesAt=new Set;graph=new T({readsOf:t=>this.readsOf(t),readsAt:(t,e,s,n)=>this.readsAt(t,e,s,n)});graphMade=!1;reports;replica;settled=new Set;moved=[];unsettled=new Set;hiddenBy=new Map;volatiles=new Set;indexes=new U;results=new U;wb;constructor(t,e={}){this.wb=t;const{now:s,random:n}=e;this.reports=e.report===!0,this.replica=e.replica===!0,this.nowSerial=()=>_(s??new Date),this.random=n??Math.random;for(const o of t.sheets)o.expand()}allCells(){return this.wb.sheets.flatMap(t=>[...t.formulas])}filtered(t){return this.hiddenBy.get(t)??Y}calculate(){if(this.replica){for(const e of this.wb.sheets)e.clearSpills();for(const e of this.allCells())e.state=0;return this}this.hiddenBy.clear(),this.indexes.clear(),this.results.clear();for(const e of this.wb.sheets)e.clearSpills();this.moved=[],this.unsettled.clear();const t=this.allCells();for(const e of t)e.state=1;return this.cycles=[],this.inCycle.clear(),this.run(t),this.applyFilters(t),this}applyFilters(t){for(const e of this.wb.sheets){if(e.filters.every(n=>n.columns.size===0))continue;const s=B(e,this);s.size>0&&this.hiddenBy.set(e,s)}if(this.hiddenBy.size!==0&&t.some(e=>Z.test(e.shared.text))){for(const e of t)e.state=1;this.cycles=[],this.inCycle.clear(),this.run([...t])}}value(t,e,s){return this.read(t,e,s)}read(t,e,s){const n=t.at(e,s);return n===void 0?this.ghost(t,e,s):typeof n!="object"||n instanceof m?n:(n.state===1?this.compute(n):n.state===2&&this.circular(n),n.value)}ghost(t,e,s){const n=t.spillAt(e,s);if(!n)return null;if(n.state===1)this.compute(n);else if(n.state===2)return this.circular(n),null;const{array:o}=n;return o&&t.spillAt(e,s)===n?o.at(e-n.row,s-n.col):null}circular(t){const e=this.stack.indexOf(t),s=e<0?[t]:this.stack.slice(e);s.some(n=>this.inCycle.has(n))||this.cycles.push(s);for(const n of s)this.inCycle.add(n)}forget(t,e){this.indexes.changed(t,e),this.results.changed(t,e)}run(t){for(const e of t){const{sheet:s,row:n,col:o}=e;this.forget(s,{top:n,left:o,bottom:n,right:o}),e.spill&&this.forget(s,e.spill)}this.computed=0;for(const e of this.order(t))e.state===1&&this.compute(e);this.spread()}spread(){for(let t=0;this.moved.length>0;t++){const e=this.moved;if(this.moved=[],t>=N*2)break;if(t>=N)for(const{sheet:o,area:r}of e)for(const i of o.spillsIn(r))this.unsettled.add(i);this.build();const s=new Set,n=[...this.unsettled];for(const{sheet:o,area:r}of e)n.push(...this.readersIn(o,r),...o.blockedBy(r));for(;;){const o=n.pop();if(!o)break;s.has(o)||(s.add(o),n.push(...this.readers(o.sheet,o.row,o.col)))}if(s.size!==0){for(const o of s)o.state=1,this.inCycle.delete(o);this.cycles=this.cycles.filter(o=>!o.some(r=>s.has(r))),this.indexes.clear(),this.results.clear();for(const o of this.order([...s]))o.state===1&&this.compute(o)}}for(const t of this.wb.sheets)t.tighten()}spillOut(t,e){const{sheet:s,row:n,col:o}=t,r={top:n,left:o,bottom:n+e.rows-1,right:o+e.cols-1},i=s.spillsIn(r).filter(c=>c!==t);if(r.bottom>=k||r.right>=E||s.holds(r,t)||s.tables.some(c=>O(c.area,r))||s.merges.some(c=>O(c,r))||i.some(c=>K(c,t)))return s.blockSpill(t,r),!1;for(const c of i)this.evict(c,r);return s.placeSpill(t,r),!0}evict(t,e){const{sheet:s,spill:n}=t;n&&(s.clearSpill(t),s.blockSpill(t,e),t.array=void 0,t.value=h.SPILL,this.moved.push({sheet:s,area:n}),this.reports&&this.settled.add(t))}analysisOf(t){return t.analysis??=z(this.wb,t)}readsOf(t){const e=[],s=V(t);for(const n of this.analysisOf(t.shared).reads){const o=n.kind==="ref"?this.resolveRef(n,s):this.structured(n,s);o instanceof u?e.push(o):o instanceof b&&e.push(...o.parts)}return e}readsAt(t,e,s,n){const o={sheet:e,row:s,col:n,dr:s-t.row,dc:n-t.col},r=[];for(const i of this.analysisOf(t).reads){const a=i.kind==="ref"?this.resolveRef(i,o):this.structured(i,o);a instanceof u?r.push(a):a instanceof b?r.push(...a.parts):r.push(void 0)}return r}readsOfFormula(t,e){const s=[],n={sheet:e,row:t.row,col:t.col,dr:0,dc:0};for(const o of this.analysisOf(t).reads){const r=o.kind==="ref"?this.resolveRef(o,n):this.structured(o,n);r instanceof u?s.push(r):r instanceof b&&s.push(...r.parts)}return s}order(t){this.pass+=1;const{pass:e}=this,s=[],n=new Set,o=[],r=i=>{i.mark=e,o.push({cell:i,reads:this.pending(i,n),next:0})};for(const i of t)if(i.mark!==e)for(r(i);;){const a=o[o.length-1];if(!a)break;const c=a.reads[a.next];a.next+=1,c===void 0?(s.push(a.cell),o.pop()):c.mark!==e&&c.state===1&&r(c)}return s}pending(t,e){const s=[];for(const n of this.readsOf(t)){const{sheet:o}=n;if(n.single){const i=o.at(n.top,n.left);i instanceof y&&s.push(i);continue}if(e.has(n.key))continue;e.add(n.key);const r=Math.min(n.right,o.columnsUsed-1);for(let i=n.left;i<=r;i++){if(!o.hasFormulas(i))continue;const[a,c]=o.span(i,n.top,n.bottom);for(let f=a;f<=c;f++){const d=o.at(f,i);d instanceof y&&s.push(d)}}}return s}compute(t){if(this.stack.length>=$){t.value=h.CALC,t.state=0;return}t.state=2,this.stack.push(t),this.computed+=1;const{node:e}=t.shared,s=e?this.top(this.eval(e,V(t))):h.NAME;this.stack.pop(),this.unsettled.has(t)&&!this.inCycle.has(t)&&(this.inCycle.add(t),this.cycles.push([t])),this.settleResult(t,s),t.state=0,this.reports&&this.settled.add(t)}settleResult(t,e){const{sheet:s}=t,n=t.spill,o=t.array;if(s.clearSpill(t),t.array=void 0,e instanceof p){const i=tt(e);i.rows*i.cols<=1||this.spillOut(t,i)?(t.array=i,t.value=i.at(0,0)??0):t.value=h.SPILL}else t.value=e;this.inCycle.has(t)&&(s.clearSpill(t),t.value=h.CYCLE,t.array=void 0);const r=t.spill;(!J(o,t.array)||!Q(n,r))&&(n&&this.moved.push({sheet:s,area:n}),r&&this.moved.push({sheet:s,area:r}))}top(t){const e=this.flat(t);return e===null?0:e}flat(t){return t instanceof u?t.single?this.read(t.sheet,t.top,t.left):this.matrix(t):t instanceof b?h.VALUE:t instanceof M?h.CALC:t instanceof x?null:t}matrix(t){const e=t.bottom===k-1?Math.min(t.bottom,t.sheet.lastRow):t.bottom,s=t.right===E-1?Math.min(t.right,t.sheet.columnsUsed-1):t.right,n=Math.max(0,e-t.top+1),o=Math.max(0,s-t.left+1),r=new Array(n*o);for(let i=0;i<n;i++)for(let a=0;a<o;a++)r[i*o+a]=this.read(t.sheet,t.top+i,t.left+a);return new p(n,o,r)}each(t,e){const{sheet:s}=t,n=Math.min(t.right,s.columnsUsed-1);for(let o=t.left;o<=n;o++){const[r,i]=s.span(o,t.top,t.bottom);for(let a=r;a<=i;a++){const c=s.at(a,o);if(c===void 0){s.spillAt(a,o)&&e(this.read(s,a,o),a,o);continue}e(typeof c=="object"&&!(c instanceof m)?this.read(s,a,o):c,a,o)}}}evaluate(t,e){const{node:s}=t;return s?this.top(this.eval(s,{sheet:e,row:t.row,col:t.col,dr:0,dc:0})):h.NAME}evaluateAt(t,e,s,n){const{node:o}=t;return o?this.top(this.eval(o,{sheet:e,row:s,col:n,dr:s-t.row,dc:n-t.col})):h.NAME}bound(t,e,s){const n=t.abs?t.index:t.index+e;return n<0||n>=s?void 0:n}resolveRef(t,e){const s=t.sheet===void 0?e.sheet:this.wb.sheet(t.sheet);if(!s)return h.REF;let n=0,o=E-1,r=0,i=k-1;if(t.col){const a=this.bound(t.col,e.dc,E),c=this.bound(t.col2??t.col,e.dc,E);if(a===void 0||c===void 0)return h.REF;n=Math.min(a,c),o=Math.max(a,c)}if(t.row){const a=this.bound(t.row,e.dr,k),c=this.bound(t.row2??t.row,e.dr,k);if(a===void 0||c===void 0)return h.REF;r=Math.min(a,c),i=Math.max(a,c)}if(t.lastSheet!==void 0){const a=this.wb.sheet(t.lastSheet);if(!a)return h.REF;const[c,f]=[Math.min(s.index,a.index),Math.max(s.index,a.index)];return new b(this.wb.sheets.slice(c,f+1).map(d=>new u(d,r,n,i,o)))}return new u(s,r,n,i,o)}structured(t,e){const s=t.table===void 0?e.sheet.tableAt(e.row,e.col):this.wb.table(t.table);return s?et(s,t,e):t.table===void 0?h.REF:h.NAME}nameValue(t,e,s){const n=t.toLowerCase();if(s===void 0)for(let c=e.scope;c;c=c.parent){const f=c.names.get(n);if(f!==void 0)return f}const o=s===void 0?e.sheet:this.wb.sheet(s);if(!o)return h.REF;const r=this.wb.name(t,o);if(r){if(!r.formula)return r.value??null;const{node:c}=r.formula;if(!c)return h.NAME;if(this.namesAt.has(n))return h.CYCLE;this.namesAt.add(n);try{return this.eval(c,{sheet:e.sheet,row:0,col:0,dr:0,dc:0})}finally{this.namesAt.delete(n)}}const i=this.wb.table(t);if(i){const{top:c,left:f,bottom:d,right:g}=i.data;return new u(i.sheet,c,f,d,g)}const a=v.get(t.toUpperCase());return a&&a.kind!=="lazy"?st(a,t,e):h.NAME}intersect(t,e){return!(t instanceof u)||t.single?t:t.cols===1&&e.row>=t.top&&e.row<=t.bottom?new u(t.sheet,e.row,t.left,e.row,t.left):t.rows===1&&e.col>=t.left&&e.col<=t.right?new u(t.sheet,t.top,e.col,t.top,e.col):h.VALUE}unary(t,e){const s=this.flat(t);return s instanceof p?new p(s.rows,s.cols,s.data.map(e)):e(s)}operate(t,e,s){const n=this.flat(e),o=this.flat(s);if(n instanceof p||o instanceof p){const r=(i,a)=>S(t,i,a);return H(n instanceof p?n:new p(1,1,[n]),o instanceof p?o:new p(1,1,[o]),r)}return S(t,n,o)}rangeOf(t,e){return t instanceof m?t:e instanceof m?e:!(t instanceof u)||!(e instanceof u)||t.sheet!==e.sheet?h.REF:new u(t.sheet,Math.min(t.top,e.top),Math.min(t.left,e.left),Math.max(t.bottom,e.bottom),Math.max(t.right,e.right))}intersection(t,e){if(t instanceof m)return t;if(e instanceof m)return e;if(!(t instanceof u)||!(e instanceof u))return h.REF;const s=Math.max(t.top,e.top),n=Math.max(t.left,e.left),o=Math.min(t.bottom,e.bottom),r=Math.min(t.right,e.right);return t.sheet!==e.sheet||s>o||n>r?h.NULL:new u(t.sheet,s,n,o,r)}union(t,e){if(t instanceof m)return t;if(e instanceof m)return e;const s=o=>o instanceof u?[o]:o instanceof b?o.parts:[],n=[...s(t),...s(e)];return n.length===0?h.VALUE:new b(n)}eval(t,e){switch(t.kind){case"number":case"string":case"boolean":return t.value;case"error":return m.of(t.code);case"missing":return F;case"ref":return this.resolveRef(t,e);case"structured":return this.structured(t,e);case"name":return this.nameValue(t.name,e,t.sheet);case"paren":return this.eval(t.arg,e);case"unary":{const s=this.eval(t.arg,e);return t.op==="@"?this.intersect(s,e):t.op==="+"?s:this.unary(s,n=>S("*",n,-1))}case"postfix":{const s=this.eval(t.arg,e);if(t.op==="%")return this.unary(s,n=>S("/",n,100));if(s instanceof u&&s.single){const n=s.sheet.at(s.top,s.left);if(n instanceof y){this.read(s.sheet,s.top,s.left);const{spill:o}=n;if(o)return new u(s.sheet,o.top,o.left,o.bottom,o.right);if(n.array)return s}}return h.REF}case"binary":{const s=this.eval(t.left,e),n=this.eval(t.right,e);return t.op===":"?this.rangeOf(s,n):t.op===" "?this.intersection(s,n):t.op===","?this.union(s,n):this.operate(t.op,s,n)}case"array":return new p(t.rows.length,t.rows[0]?.length??0,t.rows.flatMap(s=>s.map(n=>{const o=this.eval(n,e);return o instanceof p||o instanceof u||o instanceof b||o instanceof M||o instanceof x?h.VALUE:o})));case"invoke":{const s=this.eval(t.callee,e);return s instanceof M?this.invoke(s,t.args,e):s instanceof m?s:h.VALUE}case"call":return this.call(t.name,t.args,e)}}invoke(t,e,s){return this.apply(t,e.map(n=>this.eval(n,s)))}apply(t,e){if(t.named!==void 0){const n=v.get(t.named);return!n||n.kind==="lazy"?h.NAME:e.length<n.min||e.length>n.max?h.VALUE:this.applyFunction(n,e,t.frame)}if(e.length>t.params.length)return h.VALUE;const s=new Map;return t.params.forEach((n,o)=>{s.set(n,e[o]??F)}),this.eval(t.body,{...t.frame,scope:{names:s,...t.frame.scope?{parent:t.frame.scope}:{}}})}call(t,e,s){const n=v.get(t);if(!n){const o=this.nameValue(t,s);return o instanceof M?this.invoke(o,e,s):h.NAME}return e.length<n.min||e.length>n.max?h.VALUE:n.kind==="lazy"?n.call(e,{calc:this,frame:s}):this.applyFunction(n,e.map(o=>this.eval(o,s)),s)}applyFunction(t,e,s){const n={calc:this,frame:s};if(t.kind==="lazy")return h.VALUE;if(t.kind==="raw")return j(t.params,e.length)?this.over(e,r=>X(t.params,r)==="value",r=>t.call(r,n)):h.VALUE;const o=t.errors===!0;return this.over(e,()=>!0,r=>{const i=r.map(a=>a instanceof x?void 0:a);if(!o){for(const a of i)if(a instanceof m)return a}return t.call(...i)})}over(t,e,s){const n=[],o=new Map;for(const[f,d]of t.entries()){if(!e(f)||d instanceof x){n.push(d);continue}const g=this.flat(d);g instanceof p&&o.set(f,g),n.push(g)}if(o.size===0)return s(n);const r=[...o.values()],i=Math.max(...r.map(f=>f.rows)),a=Math.max(...r.map(f=>f.cols));if(i===0||a===0)return h.CALC;const c=new Array(i*a);for(let f=0;f<i;f++)for(let d=0;d<a;d++){const g=n.map((C,A)=>{const w=o.get(A);if(!w)return C;const L=w.rows===1?0:f,R=w.cols===1?0:d;return L<w.rows&&R<w.cols?w.at(L,R):h.NA});c[f*a+d]=this.element(s(g))}return new p(i,a,c)}element(t){const e=this.flat(t);return e instanceof p?e.rows>0&&e.cols>0?e.at(0,0):h.CALC:e}scalar(t,e){if(t instanceof x)return null;if(t instanceof u){const s=this.intersect(t,e);return s instanceof u?this.read(s.sheet,s.top,s.left):h.VALUE}return t instanceof p?t.at(0,0):t instanceof b||t instanceof M?h.VALUE:t}recalculate(){if(this.replica)return this;const t=this.allCells().filter(e=>this.analysisOf(e.shared).volatile);return this.mark(t),this}build(){if(this.graphMade)return;this.graphMade=!0;const t=this.allCells();for(const e of t)this.analysisOf(e.shared).volatile&&this.volatiles.add(e);this.graph.build(t)}addEdges(t){this.analysisOf(t.shared).volatile&&this.volatiles.add(t),this.graph.add(t)}removeEdges(t){this.volatiles.delete(t),this.graph.remove(t)}readersIn(t,e){return this.graph.readersIn(t,e)}readers(t,e,s){return this.build(),this.graph.readers(t,e,s)}precedents(t){return this.readsOf(t)}mark(t){this.build();const e=new Set(t),s=[...t];for(;;){const n=s.pop();if(!n)break;for(const o of this.readers(n.sheet,n.row,n.col))e.has(o)||(e.add(o),s.push(o))}this.settle(e)}settle(t){for(const e of t)e.state=1,this.inCycle.delete(e);this.cycles=this.cycles.filter(e=>!e.some(s=>t.has(s))),this.run([...t])}set(t,e,s,n){const o=typeof n=="string"&&n.length>1&&n.startsWith("=")?new y(new I(n,e,s,{file:""}),t,e,s):void 0;this.change([{sheet:t,row:e,col:s,slot:o??n??void 0}])}prepare(){this.build()}change(t){if(this.replica){for(const{sheet:o,row:r,col:i,slot:a}of t){const c=o.at(r,i);c instanceof y&&o.clearSpill(c),o.replace(r,i,a),a instanceof y&&(a.state=0)}return}this.build();const e=new Set,s=[...this.unsettled];this.unsettled.clear();const n=new Set;for(const{sheet:o,row:r,col:i,slot:a}of t){const c=o.at(r,i);c instanceof y&&(n.add(c),this.inCycle.delete(c),this.removeEdges(c),e.delete(c),c.spill&&this.moved.push({sheet:o,area:c.spill}),o.clearSpill(c));const f=o.spillAt(r,i);f&&s.push(f),s.push(...o.blockedBy({top:r,left:i,bottom:r,right:i})),o.replace(r,i,a),this.forget(o,{top:r,left:i,bottom:r,right:i}),a instanceof y&&(this.addEdges(a),e.add(a))}n.size>0&&(this.cycles=this.cycles.filter(o=>!o.some(r=>n.has(r))));for(const{sheet:o,row:r,col:i}of t)s.push(...this.readers(o,r,i));for(s.push(...this.volatiles);;){const o=s.pop();if(!o)break;e.has(o)||(e.add(o),s.push(...this.readers(o.sheet,o.row,o.col)))}this.settle(e)}setName(t,e){const s=this.wb.name(t);if(!s)throw new Error(`There is no name ${t}.`);s.value=e,delete s.formula;const n=t.toLowerCase();this.mark(this.allCells().filter(o=>this.analysisOf(o.shared).names.has(n)))}takeComputed(){const t=[];for(const e of this.settled)t.push({sheet:e.sheet.index,row:e.row,col:e.col,value:P(e.value),...e.array?{array:W(e.array)}:{},...e.spill?{spill:e.spill}:{},...e.blocked?{blocked:e.blocked}:{}});return this.settled.clear(),{cells:t,cycles:this.cycles.map(e=>e.map(s=>({sheet:s.sheet.index,row:s.row,col:s.col}))),hidden:[...this.hiddenBy].map(([e,s])=>({sheet:e.index,rows:[...s]}))}}receive(t){for(const s of t.cells){const n=this.wb.sheets[s.sheet],o=n?.at(s.row,s.col);!n||!(o instanceof y)||(n.clearSpill(o),o.value=G(s.value),o.array=s.array?D(s.array):void 0,s.spill&&n.placeSpill(o,s.spill),s.blocked&&n.blockSpill(o,s.blocked),o.state=0)}this.cycles=t.cycles.flatMap(s=>{const n=s.flatMap(o=>{const r=this.wb.sheets[o.sheet]?.at(o.row,o.col);return r instanceof y?[r]:[]});return n.length>0?[n]:[]});const e=new Map(this.hiddenBy);this.hiddenBy.clear();for(const{sheet:s,rows:n}of t.hidden){const o=this.wb.sheets[s];if(!o)continue;const r=e.get(o),i=r?.size===n.length&&n.every(a=>r.has(a));this.hiddenBy.set(o,i?r:new Set(n))}for(const s of this.wb.sheets)s.tighten()}numberOf(t){return q(t)}}const Q=(l,t)=>l?.top===t?.top&&l?.left===t?.left&&l?.bottom===t?.bottom&&l?.right===t?.right;function tt(l){return l.data.some(t=>t===null)?new p(l.rows,l.cols,l.data.map(t=>t??0)):l}function V(l){return{sheet:l.sheet,row:l.row,col:l.col,dr:l.row-l.shared.row,dc:l.col-l.shared.col}}function et(l,t,e){const{sheet:s}=l,n=l.area;let o=n.left,r=n.right;const[i,a]=t.columns;if(i!==void 0){const A=l.column(i),w=a===void 0?A:l.column(a);if(!A||!w)return h.REF;o=n.left+Math.min(A.index,w.index),r=n.left+Math.max(A.index,w.index)}if(t.thisRow)return e.sheet!==s||e.row<=n.top||e.row>n.bottom?h.VALUE:new u(s,e.row,o,e.row,r);const c=t.sections;if(c.includes("#Totals"))return h.REF;const f=c.includes("#All")||c.includes("#Headers"),d=c.length===0||c.includes("#All")||c.includes("#Data"),g=f?n.top:n.top+1,C=d?n.bottom:n.top;return new u(s,g,o,C,r)}function st(l,t,e){return new M([],{kind:"call",name:l.name,written:t,args:[]},e,l.name)}
2
+ import{MAX_COLUMNS as v,MAX_ROWS as C,overlaps as N}from"../address.js";import{CellError as b,ERR as h,Matrix as m,serialOfDate as G}from"../values.js";import{filteredRows as W}from"../filter.js";import{FormulaCell as k,SharedFormula as P}from"../workbook.js";import{analyse as q}from"./analyse.js";import{Graph as H}from"./graph.js";import{fromWire as $,matrixFromWire as j,matrixToWire as K,toWire as X}from"./remote.js";import{RangeCache as U}from"./indexes.js";import{binary as O,mapBoth as Y,toNumber as Z}from"./coerce.js";import{FUNCTIONS as _}from"./functions/index.js";import{fillsGroup as J,paramAt as Q}from"./functions/define.js";import{Lambda as S,MISSING as T,Missing as L,Reference as d,Union as x,pushAll as M}from"./types.js";export function seededRandom(l){let t=2166136261;for(let e=0;e<l.length;e++)t=Math.imul(t^l.charCodeAt(e),16777619);return()=>{t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}const tt=new Set,et=/\b(?:SUBTOTAL|AGGREGATE)\(/iu,I=2e3,st=50,nt=1024;class V extends Error{cell;constructor(t){super("computed first"),this.cell=t}}const B=12;export const ITERATION_DEFAULTS={max_iterations:100,max_change:.001};function ot(l,t){return typeof l=="number"&&typeof t=="number"?Math.abs(t-l):l===t||l instanceof b&&t instanceof b&&l.code===t.code?0:1/0}const it=(l,t)=>!l||!t?l===t:l.rows!==t.rows||l.cols!==t.cols?!1:l.data.every((e,s)=>e===t.data[s]),rt=(l,t)=>l.row<t.row||l.row===t.row&&l.col<t.col;export class Calc{cycles=[];computed=0;iterated;nowSerial;random;pass=0;lambdaSlots=0;stack=[];inCycle=new Set;looping=new Set;tablesOf;inTables=!1;loop=new Set;around=new Set;namesAt=new Set;graph=new H({readsOf:t=>this.readsOf(t),readsAt:(t,e,s,o)=>this.readsAt(t,e,s,o)});graphMade=!1;reports;replica;settled=new Set;moved=[];unsettled=new Set;hiddenBy=new Map;volatiles=new Set;indexes=new U;results=new U;wb;constructor(t,e={}){this.wb=t;const{now:s,random:o}=e;this.reports=e.report===!0,this.replica=e.replica===!0,this.nowSerial=()=>G(s??new Date),this.random=o??Math.random;for(const n of t.sheets)n.expand()}allCells(){return this.wb.sheets.flatMap(t=>[...t.formulas])}filtered(t){return this.hiddenBy.get(t)??tt}calculate(){if(this.replica){for(const e of this.wb.sheets)e.clearSpills();for(const e of this.allCells())e.state=0;return this}this.hiddenBy.clear(),this.indexes.clear(),this.results.clear();for(const e of this.wb.sheets)e.clearSpills();this.moved=[],this.unsettled.clear();const t=this.allCells();for(const e of t)e.state=1;return this.cycles=[],this.inCycle.clear(),this.looping.clear(),this.loop=new Set,this.around.clear(),this.tablesOf=void 0,this.iterated=void 0,this.run(t),this.applyFilters(t),this}iteration(){const t=this.wb.file.iteration;if(t!==void 0)return{max_iterations:(t===!0?void 0:t.max_iterations)??ITERATION_DEFAULTS.max_iterations,max_change:(t===!0?void 0:t.max_change)??ITERATION_DEFAULTS.max_change}}applyFilters(t){for(const e of this.wb.sheets){if(e.filters.every(o=>o.columns.size===0))continue;const s=W(e,this);s.size>0&&this.hiddenBy.set(e,s)}if(this.hiddenBy.size!==0&&t.some(e=>et.test(e.shared.text))){for(const e of t)e.state=1;this.cycles=[],this.inCycle.clear(),this.run([...t])}}value(t,e,s){return this.read(t,e,s)}read(t,e,s){const o=t.at(e,s);return o===void 0?this.ghost(t,e,s):typeof o!="object"||o instanceof b?o:(o.state===1?this.computeNow(o):o.state===2&&this.circular(o),o.value)}ghost(t,e,s){const o=t.spillAt(e,s);if(!o)return null;if(o.state===1)this.computeNow(o);else if(o.state===2)return this.circular(o),null;const{array:n}=o;return n&&t.spillAt(e,s)===o?n.at(e-o.row,s-o.col):null}circular(t){const e=this.stack.indexOf(t),s=e<0?[t]:this.stack.slice(e);if(this.iteration()){for(const o of s)this.looping.add(o);return}s.some(o=>this.inCycle.has(o))||this.cycles.push(s);for(const o of s)this.inCycle.add(o)}forget(t,e){this.indexes.changed(t,e),this.results.changed(t,e)}run(t){for(const e of t){const{sheet:s,row:o,col:n}=e;this.forget(s,{top:o,left:n,bottom:o,right:n}),e.spill&&this.forget(s,e.spill)}t.some(e=>this.loop.has(e))&&(this.iterated=void 0),this.computed=0;for(const e of this.order(t))e.state===1&&this.computeNow(e);this.spread(),this.iterate(),this.tables()}tableCells(){if(this.tablesOf)return this.tablesOf;const t=new Map;for(const e of this.allCells())if(R(e.shared.node)){const s=t.get(e.shared);s?s.push(e):t.set(e.shared,[e])}return this.tablesOf=t,t}tables(){if(this.replica||this.inTables)return;const t=this.tableCells();if(t.size!==0){this.inTables=!0;try{const e=[];for(const[n,i]of t)this.table(n,i),e.push(...i);const s=new Set(e),o=new Set;for(const n of e)for(const i of this.readers(n.sheet,n.row,n.col))s.has(i)||o.add(i);o.size>0&&this.mark([...o])}finally{this.inTables=!1}}}operations(t){const e=new Map,s=(n,i)=>{const r=n===void 0?void 0:this.eval(n,i);return r instanceof d&&r.single?r:void 0},o=t.map(n=>{const i=n.shared.node;if(i?.kind!=="call")return h.REF;const r=F(n),a=s(i.args[0],r);if(!a)return h.REF;const c=[];for(let f=1;f+1<i.args.length;f+=2){const u=s(i.args[f],r),w=s(i.args[f+1],r);if(!u||!w)return h.REF;const E=`${String(u.sheet.index)}:${String(u.top)}:${String(u.left)}`;e.has(E)||e.set(E,{sheet:u.sheet,row:u.top,col:u.left,slot:u.sheet.at(u.top,u.left)});const A=this.read(w.sheet,w.top,w.left);c.push({sheet:u.sheet,row:u.top,col:u.left,slot:A??void 0})}return this.change(c),this.read(a.sheet,a.top,a.left)});e.size>0&&this.change([...e.values()]),t.forEach((n,i)=>{n.value=o[i]??null,this.reports&&this.settled.add(n)})}table(t,e){const[s]=e,o=t.node;if(!s||o?.kind!=="call")return;if(o.args.length>2){this.operations(e);return}const{sheet:n}=s,i=t.row,r=t.col,a={sheet:n,row:i,col:r,dr:0,dc:0},c=p=>{if(p===void 0||p.kind==="missing")return null;const g=this.eval(p,a);return g instanceof d&&g.single?g:void 0},f=c(o.args[0]),u=c(o.args[1]),w=p=>{for(const g of e)g.value=p,this.reports&&this.settled.add(g)};if(f===void 0||u===void 0||f===null&&u===null||i===0||r===0){w(h.REF);return}const A=[f,u].filter(p=>p!==null).map(p=>({sheet:p.sheet,row:p.top,col:p.left,slot:p.sheet.at(p.top,p.left)})),y=e.map(p=>{const g=[];f&&g.push({sheet:f.sheet,row:f.top,col:f.left,slot:this.read(n,i-1,p.col)??void 0}),u&&g.push({sheet:u.sheet,row:u.top,col:u.left,slot:this.read(n,p.row,r-1)??void 0}),this.change(g);const[z,D]=f&&u?[i-1,r-1]:u?[i-1,p.col]:[p.row,r-1];return this.read(n,z,D)});this.change(A),e.forEach((p,g)=>{p.value=y[g]??null,this.reports&&this.settled.add(p)})}iterate(){const t=this.iteration();if(!t||this.looping.size===0){this.looping.clear();return}for(const i of this.looping)this.around.add(i);const e=this.downstream([...this.looping]),s=[...e];let o=1,n=1/0;for(;o<t.max_iterations;){const i=s.map(r=>r.value);this.looping.clear(),this.indexes.clear(),this.results.clear();for(const r of s)r.state=1;for(const r of this.order(s))r.state===1&&this.compute(r);if(o+=1,n=0,s.forEach((r,a)=>{n=Math.max(n,ot(i[a]??null,r.value))}),n<t.max_change)break}this.looping.clear(),this.spread(),this.looping.clear(),this.loop=e,this.iterated={cells:s.length,iterations:o,change:n}}iterates(t){return this.loop.has(t)}circularCells(){return[...this.around]}downstream(t){const e=new Set(t),s=[...t];for(;;){const o=s.pop();if(!o)break;for(const n of this.readers(o.sheet,o.row,o.col))e.has(n)||(e.add(n),s.push(n))}return e}spread(){for(let t=0;this.moved.length>0;t++){const e=this.moved;if(this.moved=[],t>=B*2)break;if(t>=B)for(const{sheet:n,area:i}of e)for(const r of n.spillsIn(i))this.unsettled.add(r);this.build();const s=new Set,o=[...this.unsettled];for(const{sheet:n,area:i}of e)M(o,this.readersIn(n,i)),M(o,n.blockedBy(i));for(;;){const n=o.pop();if(!n)break;s.has(n)||(s.add(n),M(o,this.readers(n.sheet,n.row,n.col)))}if(s.size!==0){for(const n of s)n.state=1,this.inCycle.delete(n);this.cycles=this.cycles.filter(n=>!n.some(i=>s.has(i))),this.indexes.clear(),this.results.clear();for(const n of this.order([...s]))n.state===1&&this.computeNow(n)}}for(const t of this.wb.sheets)t.tighten()}spillOut(t,e){const{sheet:s,row:o,col:n}=t,i={top:o,left:n,bottom:o+e.rows-1,right:n+e.cols-1},r=s.spillsIn(i).filter(c=>c!==t);if(i.bottom>=C||i.right>=v||s.holds(i,t)||s.tables.some(c=>N(c.area,i))||s.merges.some(c=>N(c,i))||r.some(c=>rt(c,t)))return s.blockSpill(t,i),!1;for(const c of r)this.evict(c,i);return s.placeSpill(t,i),!0}evict(t,e){const{sheet:s,spill:o}=t;o&&(s.clearSpill(t),s.blockSpill(t,e),t.array=void 0,t.value=h.SPILL,this.moved.push({sheet:s,area:o}),this.reports&&this.settled.add(t))}analysisOf(t){return t.analysis??=q(this.wb,t)}readsOf(t){const e=[],s=F(t);for(const o of this.analysisOf(t.shared).reads){const n=o.kind==="ref"?this.resolveRef(o,s):this.structured(o,s);n instanceof d?e.push(n):n instanceof x&&e.push(...n.parts)}return e}readsAt(t,e,s,o){const n={sheet:e,row:s,col:o,dr:s-t.row,dc:o-t.col},i=[];for(const r of this.analysisOf(t).reads){const a=r.kind==="ref"?this.resolveRef(r,n):this.structured(r,n);a instanceof d?i.push(a):a instanceof x?i.push(...a.parts):i.push(void 0)}return i}readsOfFormula(t,e){const s=[],o={sheet:e,row:t.row,col:t.col,dr:0,dc:0};for(const n of this.analysisOf(t).reads){const i=n.kind==="ref"?this.resolveRef(n,o):this.structured(n,o);i instanceof d?s.push(i):i instanceof x&&s.push(...i.parts)}return s}order(t){this.pass+=1;const{pass:e}=this,s=[],o=new Set,n=[],i=r=>{r.mark=e,n.push({cell:r,reads:this.pending(r,o),next:0})};for(const r of t)if(r.mark!==e)for(i(r);;){const a=n[n.length-1];if(!a)break;const c=a.reads[a.next];a.next+=1,c===void 0?(s.push(a.cell),n.pop()):c.mark!==e&&c.state===1&&i(c)}return s}pending(t,e){const s=[];for(const o of this.readsOf(t)){const{sheet:n}=o;if(o.single){const r=n.at(o.top,o.left);r instanceof k&&s.push(r);continue}if(e.has(o.key))continue;e.add(o.key);const i=Math.min(o.right,n.columnsUsed-1);for(let r=o.left;r<=i;r++){if(!n.hasFormulas(r))continue;const[a,c]=n.span(r,o.top,o.bottom);for(let f=a;f<=c;f++){const u=n.at(f,r);u instanceof k&&s.push(u)}}}return s}computeNow(t){if(this.stack.length>0){if(this.stack.length>=st&&this.stack.length<I)throw new V(t);this.compute(t);return}const e=[t],s=new Set([t]);for(;e.length>0;){const o=e[e.length-1];if(o===void 0)break;if(o.state!==1){e.pop();continue}try{this.compute(o),e.pop()}catch(n){if(!(n instanceof V))throw n;for(const i of this.stack)i.state=1;if(this.stack.length=0,s.has(n.cell)){n.cell.value=h.CALC,n.cell.state=0;continue}s.add(n.cell),e.push(n.cell)}}}compute(t){if(this.stack.length>=I){t.value=h.CALC,t.state=0;return}t.state=2,this.stack.push(t),this.computed+=1;const{node:e}=t.shared,s=R(e)?t.value:e?this.top(this.eval(e,F(t))):h.NAME;this.stack.pop(),this.unsettled.has(t)&&!this.inCycle.has(t)&&(this.inCycle.add(t),this.cycles.push([t])),this.settleResult(t,s),t.state=0,this.reports&&this.settled.add(t)}settleResult(t,e){const{sheet:s}=t,o=t.spill,n=t.array;if(s.clearSpill(t),t.array=void 0,e instanceof m){const r=ct(e);r.rows*r.cols<=1||this.spillOut(t,r)?(t.array=r,t.value=r.at(0,0)??0):t.value=h.SPILL}else t.value=e;this.inCycle.has(t)&&(s.clearSpill(t),t.value=h.CYCLE,t.array=void 0);const i=t.spill;(!it(n,t.array)||!at(o,i))&&(o&&this.moved.push({sheet:s,area:o}),i&&this.moved.push({sheet:s,area:i}))}top(t){const e=this.flat(t);return e===null?0:e}flat(t){return t instanceof d?t.single?this.read(t.sheet,t.top,t.left):this.matrix(t):t instanceof x?h.VALUE:t instanceof S?h.CALC:t instanceof L?null:t}matrix(t){const e=t.bottom===C-1?Math.min(t.bottom,t.sheet.lastRow):t.bottom,s=t.right===v-1?Math.min(t.right,t.sheet.columnsUsed-1):t.right,o=Math.max(0,e-t.top+1),n=Math.max(0,s-t.left+1),i=new Array(o*n);for(let r=0;r<o;r++)for(let a=0;a<n;a++)i[r*n+a]=this.read(t.sheet,t.top+r,t.left+a);return new m(o,n,i)}each(t,e){const{sheet:s}=t,o=Math.min(t.right,s.columnsUsed-1);for(let n=t.left;n<=o;n++){const[i,r]=s.span(n,t.top,t.bottom);for(let a=i;a<=r;a++){const c=s.at(a,n);if(c===void 0){s.spillAt(a,n)&&e(this.read(s,a,n),a,n);continue}e(typeof c=="object"&&!(c instanceof b)?this.read(s,a,n):c,a,n)}}}evaluate(t,e){const{node:s}=t;return s?this.top(this.eval(s,{sheet:e,row:t.row,col:t.col,dr:0,dc:0})):h.NAME}evaluateAt(t,e,s,o){const{node:n}=t;return n?this.top(this.eval(n,{sheet:e,row:s,col:o,dr:s-t.row,dc:o-t.col})):h.NAME}bound(t,e,s){const o=t.abs?t.index:t.index+e;return o<0||o>=s?void 0:o}resolveRef(t,e){const s=t.sheet===void 0?e.sheet:this.wb.sheet(t.sheet);if(!s)return h.REF;let o=0,n=v-1,i=0,r=C-1;if(t.col){const a=this.bound(t.col,e.dc,v),c=this.bound(t.col2??t.col,e.dc,v);if(a===void 0||c===void 0)return h.REF;o=Math.min(a,c),n=Math.max(a,c)}if(t.row){const a=this.bound(t.row,e.dr,C),c=this.bound(t.row2??t.row,e.dr,C);if(a===void 0||c===void 0)return h.REF;i=Math.min(a,c),r=Math.max(a,c)}if(t.lastSheet!==void 0){const a=this.wb.sheet(t.lastSheet);if(!a)return h.REF;const[c,f]=[Math.min(s.index,a.index),Math.max(s.index,a.index)];return new x(this.wb.sheets.slice(c,f+1).map(u=>new d(u,i,o,r,n)))}return new d(s,i,o,r,n)}structured(t,e){const s=t.table===void 0?e.sheet.tableAt(e.row,e.col):this.wb.table(t.table);return s?lt(s,t,e):t.table===void 0?h.REF:h.NAME}nameValue(t,e,s){const o=t.toLowerCase();if(s===void 0)for(let c=e.scope;c;c=c.parent){const f=c.names.get(o);if(f!==void 0)return f}const n=s===void 0?e.sheet:this.wb.sheet(s);if(!n)return h.REF;const i=this.wb.name(t,n);if(i){if(!i.formula)return i.value??null;const{node:c}=i.formula;if(!c)return h.NAME;if(this.namesAt.has(o))return h.CYCLE;this.namesAt.add(o);try{return this.eval(c,{sheet:e.sheet,row:0,col:0,dr:0,dc:0})}finally{this.namesAt.delete(o)}}const r=this.wb.table(t);if(r){const{top:c,left:f,bottom:u,right:w}=r.data;return new d(r.sheet,c,f,u,w)}const a=_.get(t.toUpperCase());return a&&a.kind!=="lazy"?ht(a,t,e):h.NAME}intersect(t,e){return!(t instanceof d)||t.single?t:t.cols===1&&e.row>=t.top&&e.row<=t.bottom?new d(t.sheet,e.row,t.left,e.row,t.left):t.rows===1&&e.col>=t.left&&e.col<=t.right?new d(t.sheet,t.top,e.col,t.top,e.col):h.VALUE}unary(t,e){const s=this.flat(t);return s instanceof m?new m(s.rows,s.cols,s.data.map(e)):e(s)}operate(t,e,s){const o=this.flat(e),n=this.flat(s);if(o instanceof m||n instanceof m){const i=(r,a)=>O(t,r,a);return Y(o instanceof m?o:new m(1,1,[o]),n instanceof m?n:new m(1,1,[n]),i)}return O(t,o,n)}rangeOf(t,e){return t instanceof b?t:e instanceof b?e:!(t instanceof d)||!(e instanceof d)||t.sheet!==e.sheet?h.REF:new d(t.sheet,Math.min(t.top,e.top),Math.min(t.left,e.left),Math.max(t.bottom,e.bottom),Math.max(t.right,e.right))}intersection(t,e){if(t instanceof b)return t;if(e instanceof b)return e;if(!(t instanceof d)||!(e instanceof d))return h.REF;const s=Math.max(t.top,e.top),o=Math.max(t.left,e.left),n=Math.min(t.bottom,e.bottom),i=Math.min(t.right,e.right);return t.sheet!==e.sheet||s>n||o>i?h.NULL:new d(t.sheet,s,o,n,i)}union(t,e){if(t instanceof b)return t;if(e instanceof b)return e;const s=n=>n instanceof d?[n]:n instanceof x?n.parts:[],o=[...s(t),...s(e)];return o.length===0?h.VALUE:new x(o)}eval(t,e){switch(t.kind){case"number":case"string":case"boolean":return t.value;case"error":return b.of(t.code);case"missing":return T;case"ref":return this.resolveRef(t,e);case"structured":return this.structured(t,e);case"name":return this.nameValue(t.name,e,t.sheet);case"paren":return this.eval(t.arg,e);case"unary":{const s=this.eval(t.arg,e);return t.op==="@"?this.intersect(s,e):t.op==="+"?s:this.unary(s,o=>O("*",o,-1))}case"postfix":{const s=this.eval(t.arg,e);if(t.op==="%")return this.unary(s,o=>O("/",o,100));if(s instanceof d&&s.single){const o=s.sheet.at(s.top,s.left);if(o instanceof k){this.read(s.sheet,s.top,s.left);const{spill:n}=o;if(n)return new d(s.sheet,n.top,n.left,n.bottom,n.right);if(o.array)return s}}return h.REF}case"binary":{const s=this.eval(t.left,e),o=this.eval(t.right,e);return t.op===":"?this.rangeOf(s,o):t.op===" "?this.intersection(s,o):t.op===","?this.union(s,o):this.operate(t.op,s,o)}case"array":return new m(t.rows.length,t.rows[0]?.length??0,t.rows.flatMap(s=>s.map(o=>{const n=this.eval(o,e);return n instanceof m||n instanceof d||n instanceof x||n instanceof S||n instanceof L?h.VALUE:n})));case"invoke":{const s=this.eval(t.callee,e);return s instanceof S?this.invoke(s,t.args,e):s instanceof b?s:h.VALUE}case"call":return this.call(t.name,t.args,e)}}invoke(t,e,s){return this.apply(t,e.map(o=>this.eval(o,s)))}apply(t,e){if(t.named!==void 0){const n=_.get(t.named);return!n||n.kind==="lazy"?h.NAME:e.length<n.min||e.length>n.max?h.VALUE:this.applyFunction(n,e,t.frame)}if(e.length>t.params.length)return h.VALUE;const s=t.params.length+1;if(this.lambdaSlots+s>nt)return h.NUM;const o=new Map;t.params.forEach((n,i)=>{o.set(n,e[i]??T)}),this.lambdaSlots+=s;try{return this.eval(t.body,{...t.frame,scope:{names:o,...t.frame.scope?{parent:t.frame.scope}:{}}})}finally{this.lambdaSlots-=s}}call(t,e,s){const o=_.get(t);if(!o){const n=this.nameValue(t,s);return n instanceof S?this.invoke(n,e,s):h.NAME}return e.length<o.min||e.length>o.max?h.VALUE:o.kind==="lazy"?o.call(e,{calc:this,frame:s}):this.applyFunction(o,e.map(n=>this.eval(n,s)),s)}applyFunction(t,e,s){const o={calc:this,frame:s};if(t.kind==="lazy")return h.VALUE;if(t.kind==="raw")return J(t.params,e.length)?this.over(e,i=>Q(t.params,i)==="value",i=>t.call(i,o)):h.VALUE;const n=t.errors===!0;return this.over(e,()=>!0,i=>{const r=i.map(a=>a instanceof L?void 0:a);if(!n){for(const a of r)if(a instanceof b)return a}return t.call(...r)})}over(t,e,s){const o=[],n=new Map;for(const[f,u]of t.entries()){if(!e(f)||u instanceof L){o.push(u);continue}const w=this.flat(u);w instanceof m&&n.set(f,w),o.push(w)}if(n.size===0)return s(o);const i=[...n.values()],r=Math.max(...i.map(f=>f.rows)),a=Math.max(...i.map(f=>f.cols));if(r===0||a===0)return h.CALC;const c=new Array(r*a);for(let f=0;f<r;f++)for(let u=0;u<a;u++){const w=o.map((E,A)=>{const y=n.get(A);if(!y)return E;const p=y.rows===1?0:f,g=y.cols===1?0:u;return p<y.rows&&g<y.cols?y.at(p,g):h.NA});c[f*a+u]=this.element(s(w))}return new m(r,a,c)}element(t){const e=this.flat(t);return e instanceof m?e.rows>0&&e.cols>0?e.at(0,0):h.CALC:e}scalar(t,e){if(t instanceof L)return null;if(t instanceof d){const s=this.intersect(t,e);return s instanceof d?this.read(s.sheet,s.top,s.left):h.VALUE}return t instanceof m?t.at(0,0):t instanceof x||t instanceof S?h.VALUE:t}recalculate(){if(this.replica)return this;const t=this.allCells().filter(e=>this.analysisOf(e.shared).volatile);return this.mark(t),this}build(){if(this.graphMade)return;this.graphMade=!0;const t=this.allCells();for(const e of t)this.analysisOf(e.shared).volatile&&this.volatiles.add(e);this.graph.build(t)}addEdges(t){this.analysisOf(t.shared).volatile&&this.volatiles.add(t),this.graph.add(t)}removeEdges(t){this.volatiles.delete(t),this.graph.remove(t)}readersIn(t,e){return this.graph.readersIn(t,e)}readers(t,e,s){return this.build(),this.graph.readers(t,e,s)}precedents(t){return this.readsOf(t)}mark(t){this.build();const e=new Set(t),s=[...t];for(;;){const o=s.pop();if(!o)break;for(const n of this.readers(o.sheet,o.row,o.col))e.has(n)||(e.add(n),s.push(n))}this.settle(e)}settle(t){for(const e of t)e.state=1,this.inCycle.delete(e);this.cycles=this.cycles.filter(e=>!e.some(s=>t.has(s))),this.run([...t])}set(t,e,s,o){const n=typeof o=="string"&&o.length>1&&o.startsWith("=")?new k(new P(o,e,s,{file:""}),t,e,s):void 0;this.change([{sheet:t,row:e,col:s,slot:n??o??void 0}])}prepare(){this.build()}change(t){if(this.replica){for(const{sheet:n,row:i,col:r,slot:a}of t){const c=n.at(i,r);c instanceof k&&n.clearSpill(c),n.replace(i,r,a),a instanceof k&&(a.state=0)}return}this.build();const e=new Set,s=[...this.unsettled];this.unsettled.clear();const o=new Set;for(const{sheet:n,row:i,col:r,slot:a}of t){const c=n.at(i,r);(c instanceof k&&R(c.shared.node)||a instanceof k&&R(a.shared.node))&&(this.tablesOf=void 0),c instanceof k&&(o.add(c),this.inCycle.delete(c),this.removeEdges(c),e.delete(c),c.spill&&this.moved.push({sheet:n,area:c.spill}),n.clearSpill(c));const f=n.spillAt(i,r);f&&s.push(f),s.push(...n.blockedBy({top:i,left:r,bottom:i,right:r})),n.replace(i,r,a),this.forget(n,{top:i,left:r,bottom:i,right:r}),a instanceof k&&(this.addEdges(a),e.add(a))}o.size>0&&(this.cycles=this.cycles.filter(n=>!n.some(i=>o.has(i))));for(const{sheet:n,row:i,col:r}of t)M(s,this.readers(n,i,r));for(M(s,this.volatiles);;){const n=s.pop();if(!n)break;e.has(n)||(e.add(n),M(s,this.readers(n.sheet,n.row,n.col)))}this.settle(e)}setName(t,e){const s=this.wb.name(t);if(!s)throw new Error(`There is no name ${t}.`);s.value=e,delete s.formula;const o=t.toLowerCase();this.mark(this.allCells().filter(n=>this.analysisOf(n.shared).names.has(o)))}takeComputed(){const t=[];for(const e of this.settled)t.push({sheet:e.sheet.index,row:e.row,col:e.col,value:X(e.value),...e.array?{array:K(e.array)}:{},...e.spill?{spill:e.spill}:{},...e.blocked?{blocked:e.blocked}:{}});return this.settled.clear(),{cells:t,cycles:this.cycles.map(e=>e.map(s=>({sheet:s.sheet.index,row:s.row,col:s.col}))),hidden:[...this.hiddenBy].map(([e,s])=>({sheet:e.index,rows:[...s]}))}}receive(t){for(const s of t.cells){const o=this.wb.sheets[s.sheet],n=o?.at(s.row,s.col);!o||!(n instanceof k)||(o.clearSpill(n),n.value=$(s.value),n.array=s.array?j(s.array):void 0,s.spill&&o.placeSpill(n,s.spill),s.blocked&&o.blockSpill(n,s.blocked),n.state=0)}this.cycles=t.cycles.flatMap(s=>{const o=s.flatMap(n=>{const i=this.wb.sheets[n.sheet]?.at(n.row,n.col);return i instanceof k?[i]:[]});return o.length>0?[o]:[]});const e=new Map(this.hiddenBy);this.hiddenBy.clear();for(const{sheet:s,rows:o}of t.hidden){const n=this.wb.sheets[s];if(!n)continue;const i=e.get(n),r=i?.size===o.length&&o.every(a=>i.has(a));this.hiddenBy.set(n,r?i:new Set(o))}for(const s of this.wb.sheets)s.tighten()}numberOf(t){return Z(t)}}const at=(l,t)=>l?.top===t?.top&&l?.left===t?.left&&l?.bottom===t?.bottom&&l?.right===t?.right;function ct(l){return l.data.some(t=>t===null)?new m(l.rows,l.cols,l.data.map(t=>t??0)):l}function R(l){return l?.kind==="call"&&l.name==="TABLE"}function F(l){return{sheet:l.sheet,row:l.row,col:l.col,dr:l.row-l.shared.row,dc:l.col-l.shared.col}}function lt(l,t,e){const{sheet:s}=l,o=l.area;let n=o.left,i=o.right;const[r,a]=t.columns;if(r!==void 0){const A=l.column(r),y=a===void 0?A:l.column(a);if(!A||!y)return h.REF;n=o.left+Math.min(A.index,y.index),i=o.left+Math.max(A.index,y.index)}if(t.thisRow)return e.sheet!==s||e.row<=o.top||e.row>o.bottom?h.VALUE:new d(s,e.row,n,e.row,i);const c=t.sections;if(c.includes("#Totals"))return h.REF;const f=c.includes("#All")||c.includes("#Headers"),u=c.length===0||c.includes("#All")||c.includes("#Data"),w=f?o.top:o.top+1,E=u?o.bottom:o.top;return new d(s,w,n,E,i)}function ht(l,t,e){return new S([],{kind:"call",name:l.name,written:t,args:[]},e,l.name)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{CellError as l,ERR as I}from"../../values.js";import{compare as R,numberOfText as S,sameNumber as b}from"../coerce.js";import{Missing as T,Reference as A}from"../types.js";import{indexKeyOf as k}from"../indexes.js";import{cellsOf as h,raw as p}from"./define.js";export function indexKey(e){if(typeof e=="number")return`n${String(Number(e.toPrecision(15)))}`;if(typeof e=="string")return`t${e.toUpperCase()}`;if(typeof e=="boolean")return e?"bT":"bF"}export function wildcard(e){let r="";for(let t=0;t<e.length;t++){const o=e.charAt(t);o==="~"&&/[*?~]/u.test(e.charAt(t+1))?(t+=1,r+=e.charAt(t).replace(/[*?]/u,"\\$&")):o==="*"?r+="[\\s\\S]*":o==="?"?r+="[\\s\\S]":r+=o.replace(/[.+^${}()|[\]\\/-]/gu,"\\$&")}const n=new RegExp(`^${r}$`,"iu");return t=>n.test(t)}export const hasWildcard=e=>/[*?~]/u.test(e);function g(e){return r=>{if(typeof r=="number")return b(r,e);if(typeof r!="string")return!1;const n=S(r);return n!==void 0&&b(n,e)}}function w(e,r){const n=t=>e===">"?t>0:e===">="?t>=0:e==="<"?t<0:t<=0;return t=>typeof t==typeof r&&n(R(t,r))}export function criterion(e){if(e===null)return{test:g(0),key:"n0"};if(typeof e=="number")return{test:g(e),key:`n${String(Number(e.toPrecision(15)))}`};if(typeof e=="boolean")return{test:s=>s===e,key:e?"bT":"bF"};if(e instanceof l)return{test:s=>s===e};const r=/^(<>|>=|<=|=|>|<)/u.exec(e),n=r?.[1]??"=",t=r?e.slice(n.length):e,o=s=>s===null;if(t==="")return n==="="?{test:r?o:s=>s===null||s===""}:n==="<>"?{test:s=>s!==null}:{test:()=>!1};const i=S(t),c=/^(?:TRUE|FALSE)$/iu.test(t)?t.toUpperCase()==="TRUE":void 0,f=i??c;if(n==="="||n==="<>"){let s,u;if(i!==void 0)s=g(i),u=indexKey(i);else if(c!==void 0)s=d=>d===c,u=indexKey(c);else if(t.startsWith("#"))s=d=>d instanceof l&&d.code===t.toUpperCase();else if(hasWildcard(t)){const d=wildcard(t);s=m=>typeof m=="string"&&d(m)}else{const d=t.toUpperCase();s=m=>typeof m=="string"&&m.toUpperCase()===d,u=indexKey(t)}return n==="="?u===void 0?{test:s}:{test:s,key:u}:{test:d=>!s(d)}}return{test:w(n,f??t)}}function O(e,r){const n=e.reference;if(!(n?.cols!==1||e.rows<64))return r.calc.indexes.of(k("crit",n),[n],()=>{const t=new Map,o=(i,c)=>{if(i===void 0)return;const f=t.get(i);f?f.push(c):t.set(i,[c])};for(let i=0;i<e.rows;i++){const c=e.at(i,0);if(o(indexKey(c),i),typeof c=="string"){const f=S(c);f!==void 0&&o(indexKey(f),i)}}return t})}function F(e,r){const n=r.calc.scalar(e,r.frame);return criterion(n)}function $(e,r){const n=[];for(let o=0;o+1<e.length;o+=2){const i=h(e[o],r);if(i instanceof l)return i;const c=F(e[o+1],r);if(c instanceof l)return c;n.push({cells:i,crit:c})}const t=n[0]?.cells;return t&&n.some(o=>!x(o.cells,t))?I.VALUE:n}const x=(e,r)=>e.cols===r.cols&&(e.reference?.rows??e.rows)===(r.reference?.rows??r.rows);function E(e,r,n){const t=e[0];if(!t)return;let o,i;for(const f of e){if(f.crit.key===void 0)continue;const s=O(f.cells,r);if(!s)continue;const u=s.get(f.crit.key)??[];(o===void 0||u.length<o.length)&&(o=u,i=f)}if(o!==void 0){const f=e.filter(s=>s!==i);for(const s of o)f.every(u=>u.crit.test(u.cells.at(s,0)))&&n(s,0);return}const c=Math.max(...e.map(f=>f.cells.rows));for(let f=0;f<c;f++)for(let s=0;s<t.cells.cols;s++)e.every(u=>u.crit.test(u.cells.at(f,s)))&&n(f,s)}function V(e,r){return e instanceof A?(e.rows-r.rows)*e.cols:0}function M(e,r,n,t){let o;return E(r,n,(i,c)=>{if(o)return;const f=e.at(i,c);f instanceof l?o=f:typeof f=="number"&&t(f)}),o}function G(e,r){const n=h(e[0],r);if(n instanceof l)return n;const t=e[2];return t===void 0?n:h(t,r)}const C=e=>(r,n)=>{const t=h(r[0],n);if(t instanceof l)return t;const o=F(r[1],n);if(o instanceof l)return o;const i=G(r,n);if(i instanceof l)return i;const c=[];return M(i,[{cells:t,crit:o}],n,s=>{c.push(s)})??e(c)},y=e=>(r,n)=>{const t=h(r[0],n);if(t instanceof l)return t;const o=$(r.slice(1),n);if(o instanceof l)return o;const i=o[0]?.cells;if(i&&!x(t,i))return I.VALUE;const c=[];return M(t,o,n,s=>{c.push(s)})??e(c)},a=(e,r)=>(n,t)=>{const o=[],i=[e];for(const u of n)if(u instanceof A)o.push(u),i.push(`r${u.key}`);else if(u instanceof T)i.push("-");else if(u instanceof l)i.push(`e${u.code}`);else if(u===null||typeof u!="object")i.push(`${typeof u}:${String(u)}`);else return r(n,t);if(o.length===0)return r(n,t);const c=i.join("\0"),f=t.calc.results.get(c);if(f!==void 0)return f;const s=r(n,t);return(s===null||typeof s!="object"||s instanceof l)&&t.calc.results.set(c,o,s),s},U=e=>e.reduce((r,n)=>r+n,0),N=e=>e.length===0?I.DIV0:U(e)/e.length,j=e=>e.length===0?0:e.reduce((r,n)=>n<r?n:r),v=e=>e.length===0?0:e.reduce((r,n)=>n>r?n:r);p("SUMIF","rv?r",a("SUMIF",C(U))),p("AVERAGEIF","rv?r",a("AVERAGEIF",C(N))),p("SUMIFS","r(rv)",a("SUMIFS",y(U))),p("AVERAGEIFS","r(rv)",a("AVERAGEIFS",y(N))),p("MINIFS","r(rv)",a("MINIFS",y(j))),p("MAXIFS","r(rv)",a("MAXIFS",y(v))),p("COUNTIF","rv",a("COUNTIF",(e,r)=>{const n=h(e[0],r);if(n instanceof l)return n;const t=F(e[1],r);if(t instanceof l)return t;let o=0;return E([{cells:n,crit:t}],r,()=>{o+=1}),o+(t.test(null)?V(e[0],n):0)})),p("COUNTIFS","(rv)",a("COUNTIFS",(e,r)=>{const n=$(e,r);if(n instanceof l)return n;let t=0;return E(n,r,()=>{t+=1}),t}));
2
+ import{CellError as l,ERR as g}from"../../values.js";import{compare as O,numberOfText as A,sameNumber as b}from"../coerce.js";import{Missing as C,Reference as T}from"../types.js";import{indexKeyOf as w}from"../indexes.js";import{cellsOf as h,raw as p}from"./define.js";export function indexKey(e){if(typeof e=="number")return`n${String(Number(e.toPrecision(15)))}`;if(typeof e=="string")return`t${e.toUpperCase()}`;if(typeof e=="boolean")return e?"bT":"bF"}const y=new Map,k=1e4;export function wildcard(e){const n=y.get(e);if(n)return n;y.size>=k&&y.clear();const t=V(e);return y.set(e,t),t}function V(e){let n="";for(let r=0;r<e.length;r++){const o=e.charAt(r);o==="~"&&/[*?~]/u.test(e.charAt(r+1))?(r+=1,n+=e.charAt(r).replace(/[*?]/u,"\\$&")):o==="*"?n+="[\\s\\S]*":o==="?"?n+="[\\s\\S]":n+=o.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&")}const t=new RegExp(`^${n}$`,"iu");return r=>t.test(r)}export const hasWildcard=e=>/[*?~]/u.test(e);export function literalOf(e){let n="";for(let t=0;t<e.length;t++){const r=e.charAt(t);if(r==="~"&&/[*?~]/u.test(e.charAt(t+1)))t+=1,n+=e.charAt(t);else{if(r==="*"||r==="?")return;n+=r}}return n}function I(e){return n=>{if(typeof n=="number")return b(n,e);if(typeof n!="string")return!1;const t=A(n);return t!==void 0&&b(t,e)}}function G(e,n){const t=r=>e===">"?r>0:e===">="?r>=0:e==="<"?r<0:r<=0;return r=>typeof r==typeof n&&t(O(r,n))}export function criterion(e){if(e===null)return{test:I(0),key:"n0"};if(typeof e=="number")return{test:I(e),key:`n${String(Number(e.toPrecision(15)))}`};if(typeof e=="boolean")return{test:s=>s===e,key:e?"bT":"bF"};if(e instanceof l)return{test:s=>s===e};const n=/^(<>|>=|<=|=|>|<)/u.exec(e),t=n?.[1]??"=",r=n?e.slice(t.length):e,o=s=>s===null;if(r==="")return t==="="?{test:n?o:s=>s===null||s===""}:t==="<>"?{test:s=>s!==null}:{test:()=>!1};const i=A(r),c=/^(?:TRUE|FALSE)$/iu.test(r)?r.toUpperCase()==="TRUE":void 0,f=i??c;if(t==="="||t==="<>"){let s,u;if(i!==void 0)s=I(i),u=indexKey(i);else if(c!==void 0)s=d=>d===c,u=indexKey(c);else if(r.startsWith("#"))s=d=>d instanceof l&&d.code===r.toUpperCase();else if(hasWildcard(r)){const d=wildcard(r);s=m=>typeof m=="string"&&d(m)}else{const d=r.toUpperCase();s=m=>typeof m=="string"&&m.toUpperCase()===d,u=indexKey(r)}return t==="="?u===void 0?{test:s}:{test:s,key:u}:{test:d=>!s(d)}}return{test:G(t,f??r)}}function P(e,n){const t=e.reference;if(!(t?.cols!==1||e.rows<64))return n.calc.indexes.ofRepeated(w("crit",t),[t],()=>{const r=new Map,o=(i,c)=>{if(i===void 0)return;const f=r.get(i);f?f.push(c):r.set(i,[c])};for(let i=0;i<e.rows;i++){const c=e.at(i,0);if(o(indexKey(c),i),typeof c=="string"){const f=A(c);f!==void 0&&o(indexKey(f),i)}}return r})}function E(e,n){const t=n.calc.scalar(e,n.frame);return criterion(t)}function x(e,n){const t=[];for(let o=0;o+1<e.length;o+=2){const i=h(e[o],n);if(i instanceof l)return i;const c=E(e[o+1],n);if(c instanceof l)return c;t.push({cells:i,crit:c})}const r=t[0]?.cells;return r&&t.some(o=>!M(o.cells,r))?g.VALUE:t}const M=(e,n)=>e.cols===n.cols&&(e.reference?.rows??e.rows)===(n.reference?.rows??n.rows);function F(e,n,t){const r=e[0];if(!r)return;let o,i;for(const f of e){if(f.crit.key===void 0)continue;const s=P(f.cells,n);if(!s)continue;const u=s.get(f.crit.key)??[];(o===void 0||u.length<o.length)&&(o=u,i=f)}if(o!==void 0){const f=e.filter(s=>s!==i);for(const s of o)f.every(u=>u.crit.test(u.cells.at(s,0)))&&t(s,0);return}const c=Math.max(...e.map(f=>f.cells.rows));for(let f=0;f<c;f++)for(let s=0;s<r.cells.cols;s++)e.every(u=>u.crit.test(u.cells.at(f,s)))&&t(f,s)}function j(e,n){return e instanceof T?(e.rows-n.rows)*e.cols:0}function R(e,n,t,r){let o;return F(n,t,(i,c)=>{if(o)return;const f=e.at(i,c);f instanceof l?o=f:typeof f=="number"&&r(f)}),o}function v(e,n){const t=h(e[0],n);if(t instanceof l)return t;const r=e[2];return r===void 0?t:h(r,n)}const $=e=>(n,t)=>{const r=h(n[0],t);if(r instanceof l)return r;const o=E(n[1],t);if(o instanceof l)return o;const i=v(n,t);if(i instanceof l)return i;const c=[];return R(i,[{cells:r,crit:o}],t,s=>{c.push(s)})??e(c)},S=e=>(n,t)=>{const r=h(n[0],t);if(r instanceof l)return r;const o=x(n.slice(1),t);if(o instanceof l)return o;const i=o[0]?.cells;if(i&&!M(r,i))return g.VALUE;const c=[];return R(r,o,t,s=>{c.push(s)})??e(c)},a=(e,n)=>(t,r)=>{const o=[],i=[e];for(const u of t)if(u instanceof T)o.push(u),i.push(`r${u.key}`);else if(u instanceof C)i.push("-");else if(u instanceof l)i.push(`e${u.code}`);else if(u===null||typeof u!="object")i.push(`${typeof u}:${String(u)}`);else return n(t,r);if(o.length===0)return n(t,r);const c=i.join("\0"),f=r.calc.results.get(c);if(f!==void 0)return f;const s=n(t,r);return(s===null||typeof s!="object"||s instanceof l)&&r.calc.results.set(c,o,s),s},U=e=>e.reduce((n,t)=>n+t,0),N=e=>e.length===0?g.DIV0:U(e)/e.length,L=e=>e.length===0?0:e.reduce((n,t)=>t<n?t:n),z=e=>e.length===0?0:e.reduce((n,t)=>t>n?t:n);p("SUMIF","rv?r",a("SUMIF",$(U))),p("AVERAGEIF","rv?r",a("AVERAGEIF",$(N))),p("SUMIFS","r(rv)",a("SUMIFS",S(U))),p("AVERAGEIFS","r(rv)",a("AVERAGEIFS",S(N))),p("MINIFS","r(rv)",a("MINIFS",S(L))),p("MAXIFS","r(rv)",a("MAXIFS",S(z))),p("COUNTIF","rv",a("COUNTIF",(e,n)=>{const t=h(e[0],n);if(t instanceof l)return t;const r=E(e[1],n);if(r instanceof l)return r;let o=0;return F([{cells:t,crit:r}],n,()=>{o+=1}),o+(r.test(null)?j(e[0],t):0)})),p("COUNTIFS","(rv)",a("COUNTIFS",(e,n)=>{const t=x(e,n);if(t instanceof l)return t;let r=0;return F(t,n,()=>{r+=1}),r}));
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{parseDate as B,parseTime as H,parseValue as S}from"numfmt";import{CellError as c,ERR as i,dateOf as h,serialOf as U}from"../../values.js";import{toBool as X,toNumber as m,toText as T}from"../coerce.js";import{Missing as O}from"../types.js";import{number as I,numbersOf as Y,raw as p,scalar as l}from"./define.js";const j=2958465,d=r=>{const n=m(r);return n instanceof c?n:n<0||n>=j+1?i.NUM:Math.floor(n)},b=r=>r%4===0&&r%100!==0||r%400===0,A=(r,n)=>n===2?b(r)?29:28:[4,6,9,11].includes(n)?30:31,V=r=>r.month===2&&r.day===A(r.year,2);l("DATE",3,3,I((r=0,n=1,e=1)=>{const t=Math.trunc(r);if(t<0||t>9999)return i.NUM;const o=U(t<1900?t+1900:t,Math.trunc(n),Math.trunc(e));return o<0?i.NUM:o})),l("TIME",3,3,I((r=0,n=0,e=0)=>{const t=Math.trunc(r)*3600+Math.trunc(n)*60+Math.trunc(e);return t<0?i.NUM:t%86400/86400})),l("YEAR",1,1,r=>{const n=d(r);return n instanceof c?n:h(n).year}),l("MONTH",1,1,r=>{const n=d(r);return n instanceof c?n:h(n).month}),l("DAY",1,1,r=>{const n=d(r);return n instanceof c?n:h(n).day});const R=r=>{const n=m(r);return n instanceof c?n:n<0?i.NUM:Math.round((n-Math.floor(n))*86400)%86400};l("HOUR",1,1,r=>{const n=R(r);return n instanceof c?n:Math.floor(n/3600)}),l("MINUTE",1,1,r=>{const n=R(r);return n instanceof c?n:Math.floor(n/60)%60}),l("SECOND",1,1,r=>{const n=R(r);return n instanceof c?n:n%60}),l("DATEVALUE",1,1,r=>{const n=T(r);if(n instanceof c)return n;const e=B(n)??S(n);return typeof e?.value=="number"?Math.floor(e.value):i.VALUE}),l("TIMEVALUE",1,1,r=>{const n=T(r);if(n instanceof c)return n;const e=H(n)??S(n);return typeof e?.value!="number"?i.VALUE:e.value-Math.floor(e.value)});const D=r=>(r%7+6)%7;l("WEEKDAY",1,2,(r,n)=>{const e=d(r);if(e instanceof c)return e;const t=n==null?1:m(n);if(t instanceof c)return t;const o=D(e);return t===1?o+1:t===2?(o+6)%7+1:t===3?(o+6)%7:t>=11&&t<=17?(o+7-(t-10)%7)%7+1:i.NUM});const W=r=>{const n=(D(r)+6)%7,e=r-n+3,{year:t}=h(e);return Math.floor((e-U(t,1,1))/7)+1};l("ISOWEEKNUM",1,1,r=>{const n=d(r);return n instanceof c?n:W(n)}),l("WEEKNUM",1,2,(r,n)=>{const e=d(r);if(e instanceof c)return e;const t=n==null?1:m(n);if(t instanceof c)return t;if(t===21)return W(e);const o=t===1?0:t===2?1:t>=11&&t<=17?(t-10)%7:-1;if(o<0)return i.NUM;const a=U(h(e).year,1,1),s=(D(a)+7-o)%7;return Math.floor((e-a+s)/7)+1});const L=(r,n)=>{const{year:e,month:t,day:o}=h(r),a=e*12+t-1+n,s=Math.floor(a/12),f=a-s*12+1;return U(s,f,Math.min(o,A(s,f)))};l("EDATE",2,2,(r,n)=>{const e=d(r),t=m(n);if(e instanceof c)return e;if(t instanceof c)return t;const o=L(e,Math.trunc(t));return o<0?i.NUM:o}),l("EOMONTH",2,2,(r,n)=>{const e=d(r),t=m(n);if(e instanceof c)return e;if(t instanceof c)return t;const o=h(L(e,Math.trunc(t))),a=U(o.year,o.month,A(o.year,o.month));return a<0?i.NUM:a}),l("DAYS",2,2,(r,n)=>{const e=d(r),t=d(n);return e instanceof c?e:t instanceof c?t:e-t}),l("DATEDIF",3,3,(r,n,e)=>{const t=d(r),o=d(n),a=T(e);if(t instanceof c)return t;if(o instanceof c)return o;if(a instanceof c)return a;if(t>o)return i.NUM;const s=h(t),f=h(o),u=(f.year-s.year)*12+f.month-s.month-(f.day<s.day?1:0);switch(a.toUpperCase()){case"D":return o-t;case"M":return u;case"Y":return Math.floor(u/12);case"YM":return u%12;case"MD":{if(f.day>=s.day)return f.day-s.day;const y=f.month===1?12:f.month-1,N=f.month===1?f.year-1:f.year;return A(N,y)-s.day+f.day}case"YD":{const y=f.year-s.year-(u%12<0?1:0),N=Math.floor(u/12),M=L(t,N*12);return y>=0?o-M:i.NUM}default:return i.NUM}});function _(r,n,e){const t=h(r),o=h(n);let a=t.day,s=o.day,f=o.month,u=o.year;return e?(a=Math.min(a,30),s=Math.min(s,30)):(a===A(t.year,t.month)&&(a=30),s===31&&(a<30?(s=1,f+=1,f>12&&(f=1,u+=1)):s=30)),(u-t.year)*360+(f-t.month)*30+s-a}l("DAYS360",2,3,(r,n,e)=>{const t=d(r),o=d(n),a=e===void 0?!1:X(e);return t instanceof c?t:o instanceof c?o:a instanceof c?a:_(t,o,a)});export function yearFrac(r,n,e){const[t,o]=r<=n?[r,n]:[n,r],a=h(t),s=h(o),f=o-t;switch(e){case 0:{let u=a.day,y=s.day;return V(a)&&(V(s)&&(y=30),u=30),y===31&&u>=30&&(y=30),u===31&&(u=30),((s.year-a.year)*360+(s.month-a.month)*30+y-u)/360}case 2:return f/360;case 3:return f/365;case 4:return _(t,o,!0)/360;default:{if(a.year===s.year||s.year===a.year+1&&(a.month>s.month||a.month===s.month&&a.day>=s.day)){let M;if(a.year===s.year)M=b(a.year);else{const E=w=>b(w)?U(w,2,29):1/0;M=E(a.year)>=t&&E(a.year)<=o||E(s.year)>=t&&E(s.year)<=o}return f/(M?366:365)}const y=s.year-a.year+1,N=U(s.year+1,1,1)-U(a.year,1,1);return f/(N/y)}}}l("YEARFRAC",2,3,(r,n,e)=>{const t=d(r),o=d(n),a=e==null?0:m(e);if(t instanceof c)return t;if(o instanceof c)return o;if(a instanceof c)return a;const s=Math.trunc(a);return s<0||s>4?i.NUM:yearFrac(t,o,s)});function k(r){const n=(...t)=>[0,1,2,3,4,5,6].map(o=>t.includes(o));if(r==null)return n(0,6);if(typeof r=="string"){if(!/^[01]{7}$/u.test(r)||r==="1111111")return i.VALUE;const t=r.split("").map(o=>o==="1");return[t[6]??!1,...t.slice(0,6)]}const e=m(r);return e instanceof c?e:e>=1&&e<=7?n((e+5)%7,(e+6)%7):e>=11&&e<=17?n(e-11):i.NUM}function K(r,n){if(r===void 0||r instanceof O)return new Set;const e=Y([r],n);return e instanceof c?e:new Set(e.map(t=>Math.floor(t)))}function P(r,n,e,t){const o=r<=n?1:-1;let a=0;for(let s=r;o>0?s<=n:s>=n;s+=o)e[D(s)]!==!0&&!t.has(s)&&(a+=o);return a}function $(r,n,e,t){if(e.every(Boolean))return i.VALUE;const o=n<0?-1:1;let a=r;for(let s=Math.abs(n);s>0;)a+=o,e[D(a)]!==!0&&!t.has(a)&&(s-=1);return a<0?i.NUM:a}const x=r=>(n,e)=>{const t=d(e.calc.scalar(n[0],e.frame)),o=d(e.calc.scalar(n[1],e.frame));if(t instanceof c)return t;if(o instanceof c)return o;const a=r?n[2]:void 0,s=k(a===void 0||a instanceof O?void 0:e.calc.scalar(a,e.frame));if(s instanceof c)return s;const f=K(n[r?3:2],e);return f instanceof c?f:P(t,o,s,f)},F=r=>(n,e)=>{const t=d(e.calc.scalar(n[0],e.frame)),o=m(e.calc.scalar(n[1],e.frame));if(t instanceof c)return t;if(o instanceof c)return o;const a=r?n[2]:void 0,s=k(a===void 0||a instanceof O?void 0:e.calc.scalar(a,e.frame));if(s instanceof c)return s;const f=K(n[r?3:2],e);return f instanceof c?f:$(t,Math.trunc(o),s,f)};p("NETWORKDAYS","vv?r",x(!1)),p("NETWORKDAYS.INTL","vv?vr",x(!0)),p("WORKDAY","vv?r",F(!1)),p("WORKDAY.INTL","vv?vr",F(!0)),p("NOW","",(r,n)=>n.calc.nowSerial(),{volatile:!0}),p("TODAY","",(r,n)=>Math.floor(n.calc.nowSerial()),{volatile:!0});function g(r,n,e){const t=e[0]??0;let o=0;return n.forEach((a,s)=>{o+=a/(1+r)**(((e[s]??t)-t)/365)}),o}const C=(r,n)=>{const e=Y([r[0]],n);if(e instanceof c)return e;const t=Y([r[1]],n);return t instanceof c?t:e.length!==t.length||e.length===0?i.NUM:{values:e,dates:t.map(Math.floor)}};p("XNPV","vrr",(r,n)=>{const e=m(n.calc.scalar(r[0],n.frame));if(e instanceof c)return e;const t=C(r.slice(1),n);return t instanceof c?t:e<=0?i.NUM:g(e,t.values,t.dates)}),p("XIRR","rr?v",(r,n)=>{const e=C(r,n);if(e instanceof c)return e;const{values:t,dates:o}=e;if(!t.some(u=>u>0)||!t.some(u=>u<0))return i.NUM;const a=r[2]===void 0||r[2]instanceof O?.1:m(n.calc.scalar(r[2],n.frame));if(a instanceof c)return a;const s=o[0]??0;let f=a;for(let u=0;u<100;u++){let y=0,N=0;t.forEach((E,w)=>{const v=((o[w]??s)-s)/365;y+=E/(1+f)**v,N-=v*E/(1+f)**(v+1)});const M=f-y/N;if(!Number.isFinite(M))return i.NUM;if(Math.abs(M-f)<1e-10)return M;f=M<=-1?(f-1)/2:M}return i.NUM});
2
+ import{parseDate as B,parseTime as H,parseValue as L}from"numfmt";import{CellError as c,ERR as u,dateOf as h,serialOf as p}from"../../values.js";import{toBool as X,toNumber as m,toText as T}from"../coerce.js";import{Missing as v}from"../types.js";import{eachRow as g,number as S,numbersOf as j,raw as U,scalar as l}from"./define.js";const P=2958465,y=e=>{const n=m(e);return n instanceof c?n:n<0||n>=P+1?u.NUM:Math.floor(n)},Y=e=>e%4===0&&e%100!==0||e%400===0,A=(e,n)=>n===2?Y(e)?29:28:[4,6,9,11].includes(n)?30:31,I=e=>e.month===2&&e.day===A(e.year,2);l("DATE",3,3,S((e=0,n=1,r=1)=>{const t=Math.trunc(e);if(t<0||t>9999)return u.NUM;const o=p(t<1900?t+1900:t,Math.trunc(n),Math.trunc(r));return o<0?u.NUM:o})),l("TIME",3,3,S((e=0,n=0,r=0)=>{const t=Math.trunc(e)*3600+Math.trunc(n)*60+Math.trunc(r);return t<0?u.NUM:t%86400/86400})),l("YEAR",1,1,e=>{const n=y(e);return n instanceof c?n:h(n).year}),l("MONTH",1,1,e=>{const n=y(e);return n instanceof c?n:h(n).month}),l("DAY",1,1,e=>{const n=y(e);return n instanceof c?n:h(n).day});const b=e=>{const n=m(e);return n instanceof c?n:n<0?u.NUM:Math.round((n-Math.floor(n))*86400)%86400};l("HOUR",1,1,e=>{const n=b(e);return n instanceof c?n:Math.floor(n/3600)}),l("MINUTE",1,1,e=>{const n=b(e);return n instanceof c?n:Math.floor(n/60)%60}),l("SECOND",1,1,e=>{const n=b(e);return n instanceof c?n:n%60}),l("DATEVALUE",1,1,e=>{const n=T(e);if(n instanceof c)return n;const r=B(n)??L(n);return typeof r?.value=="number"?Math.floor(r.value):u.VALUE}),l("TIMEVALUE",1,1,e=>{const n=T(e);if(n instanceof c)return n;const r=H(n)??L(n);return typeof r?.value!="number"?u.VALUE:r.value-Math.floor(r.value)});const D=e=>(e%7+6)%7;l("WEEKDAY",1,2,(e,n)=>{const r=y(e);if(r instanceof c)return r;const t=n==null?1:m(n);if(t instanceof c)return t;const o=D(r);return t===1?o+1:t===2?(o+6)%7+1:t===3?(o+6)%7:t>=11&&t<=17?(o+7-(t-10)%7)%7+1:u.NUM});const V=e=>{const n=(D(e)+6)%7,r=e-n+3,{year:t}=h(r);return Math.floor((r-p(t,1,1))/7)+1};l("ISOWEEKNUM",1,1,e=>{const n=y(e);return n instanceof c?n:V(n)}),l("WEEKNUM",1,2,(e,n)=>{const r=y(e);if(r instanceof c)return r;const t=n==null?1:m(n);if(t instanceof c)return t;if(t===21)return V(r);const o=t===1?0:t===2?1:t>=11&&t<=17?(t-10)%7:-1;if(o<0)return u.NUM;const a=p(h(r).year,1,1),s=(D(a)+7-o)%7;return Math.floor((r-a+s)/7)+1});const R=(e,n)=>{const{year:r,month:t,day:o}=h(e),a=r*12+t-1+n,s=Math.floor(a/12),f=a-s*12+1;return p(s,f,Math.min(o,A(s,f)))};l("EDATE",2,2,(e,n)=>{const r=y(e),t=m(n);if(r instanceof c)return r;if(t instanceof c)return t;const o=R(r,Math.trunc(t));return o<0?u.NUM:o}),l("EOMONTH",2,2,(e,n)=>{const r=y(e),t=m(n);if(r instanceof c)return r;if(t instanceof c)return t;const o=h(R(r,Math.trunc(t))),a=p(o.year,o.month,A(o.year,o.month));return a<0?u.NUM:a}),l("DAYS",2,2,(e,n)=>{const r=y(e),t=y(n);return r instanceof c?r:t instanceof c?t:r-t}),l("DATEDIF",3,3,(e,n,r)=>{const t=y(e),o=y(n),a=T(r);if(t instanceof c)return t;if(o instanceof c)return o;if(a instanceof c)return a;if(t>o)return u.NUM;const s=h(t),f=h(o),i=(f.year-s.year)*12+f.month-s.month-(f.day<s.day?1:0);switch(a.toUpperCase()){case"D":return o-t;case"M":return i;case"Y":return Math.floor(i/12);case"YM":return i%12;case"MD":{if(f.day>=s.day)return f.day-s.day;const d=f.month===1?12:f.month-1,N=f.month===1?f.year-1:f.year;return A(N,d)-s.day+f.day}case"YD":{const d=f.year-s.year-(i%12<0?1:0),N=Math.floor(i/12),M=R(t,N*12);return d>=0?o-M:u.NUM}default:return u.NUM}});function W(e,n,r){const t=h(e),o=h(n);let a=t.day,s=o.day,f=o.month,i=o.year;return r?(a=Math.min(a,30),s=Math.min(s,30)):(a===A(t.year,t.month)&&(a=30),s===31&&(a<30?(s=1,f+=1,f>12&&(f=1,i+=1)):s=30)),(i-t.year)*360+(f-t.month)*30+s-a}l("DAYS360",2,3,(e,n,r)=>{const t=y(e),o=y(n),a=r===void 0?!1:X(r);return t instanceof c?t:o instanceof c?o:a instanceof c?a:W(t,o,a)});export function yearFrac(e,n,r){const[t,o]=e<=n?[e,n]:[n,e],a=h(t),s=h(o),f=o-t;switch(r){case 0:{let i=a.day,d=s.day;return I(a)&&(I(s)&&(d=30),i=30),d===31&&i>=30&&(d=30),i===31&&(i=30),((s.year-a.year)*360+(s.month-a.month)*30+d-i)/360}case 2:return f/360;case 3:return f/365;case 4:return W(t,o,!0)/360;default:{if(a.year===s.year||s.year===a.year+1&&(a.month>s.month||a.month===s.month&&a.day>=s.day)){let M;if(a.year===s.year)M=Y(a.year);else{const E=w=>Y(w)?p(w,2,29):1/0;M=E(a.year)>=t&&E(a.year)<=o||E(s.year)>=t&&E(s.year)<=o}return f/(M?366:365)}const d=s.year-a.year+1,N=p(s.year+1,1,1)-p(a.year,1,1);return f/(N/d)}}}l("YEARFRAC",2,3,(e,n,r)=>{const t=y(e),o=y(n),a=r==null?0:m(r);if(t instanceof c)return t;if(o instanceof c)return o;if(a instanceof c)return a;const s=Math.trunc(a);return s<0||s>4?u.NUM:yearFrac(t,o,s)});function _(e){const n=(...t)=>[0,1,2,3,4,5,6].map(o=>t.includes(o));if(e==null)return n(0,6);if(typeof e=="string"){if(!/^[01]{7}$/u.test(e)||e==="1111111")return u.VALUE;const t=e.split("").map(o=>o==="1");return[t[6]??!1,...t.slice(0,6)]}const r=m(e);return r instanceof c?r:r>=1&&r<=7?n((r+5)%7,(r+6)%7):r>=11&&r<=17?n(r-11):u.NUM}function k(e,n){if(e===void 0||e instanceof v)return new Set;const r=j([e],n);return r instanceof c?r:new Set(r.map(t=>Math.floor(t)))}function $(e,n,r,t){const o=e<=n?1:-1;let a=0;for(let s=e;o>0?s<=n:s>=n;s+=o)r[D(s)]!==!0&&!t.has(s)&&(a+=o);return a}function q(e,n,r,t){if(r.every(Boolean))return u.VALUE;const o=n<0?-1:1;let a=e;for(let s=Math.abs(n);s>0;)a+=o,r[D(a)]!==!0&&!t.has(a)&&(s-=1);return a<0?u.NUM:a}const K=e=>(n,r)=>{const t=y(r.calc.scalar(n[0],r.frame)),o=y(r.calc.scalar(n[1],r.frame));if(t instanceof c)return t;if(o instanceof c)return o;const a=e?n[2]:void 0,s=_(a===void 0||a instanceof v?void 0:r.calc.scalar(a,r.frame));if(s instanceof c)return s;const f=k(n[e?3:2],r);return f instanceof c?f:$(t,o,s,f)},x=e=>(n,r)=>{const t=y(r.calc.scalar(n[0],r.frame)),o=m(r.calc.scalar(n[1],r.frame));if(t instanceof c)return t;if(o instanceof c)return o;const a=e?n[2]:void 0,s=_(a===void 0||a instanceof v?void 0:r.calc.scalar(a,r.frame));if(s instanceof c)return s;const f=k(n[e?3:2],r);return f instanceof c?f:q(t,Math.trunc(o),s,f)};U("NETWORKDAYS","vv?r",K(!1)),U("NETWORKDAYS.INTL","vv?vr",K(!0)),U("WORKDAY","vv?r",x(!1)),U("WORKDAY.INTL","vv?vr",x(!0)),U("NOW","",(e,n)=>n.calc.nowSerial(),{volatile:!0}),U("TODAY","",(e,n)=>Math.floor(n.calc.nowSerial()),{volatile:!0});function z(e,n,r){const t=r[0]??0;let o=0;return n.forEach((a,s)=>{o+=a/(1+e)**(((r[s]??t)-t)/365)}),o}const F=(e,n)=>{const r=[];return g([e],n,t=>r.push(t)),r},C=(e,n)=>{const r=F(e[0],n),t=F(e[1],n);if(r.length!==t.length)return u.NUM;const o=[],a=[];for(const[s,f]of r.entries()){const i=t[s]??null;if(f instanceof c)return f;if(i instanceof c)return i;if(typeof f=="number"){if(typeof i!="number")return u.VALUE;o.push(f),a.push(Math.floor(i))}}return o.length===0?u.NUM:{values:o,dates:a}};U("XNPV","vrr",(e,n)=>{const r=m(n.calc.scalar(e[0],n.frame));if(r instanceof c)return r;const t=C(e.slice(1),n);return t instanceof c?t:r<=0?u.NUM:z(r,t.values,t.dates)}),U("XIRR","rr?v",(e,n)=>{const r=C(e,n);if(r instanceof c)return r;const{values:t,dates:o}=r;if(!t.some(i=>i>0)||!t.some(i=>i<0))return u.NUM;const a=e[2]===void 0||e[2]instanceof v?.1:m(n.calc.scalar(e[2],n.frame));if(a instanceof c)return a;const s=o[0]??0;let f=a;for(let i=0;i<100;i++){let d=0,N=0;t.forEach((E,w)=>{const O=((o[w]??s)-s)/365;d+=E/(1+f)**O,N-=O*E/(1+f)**(O+1)});const M=f-d/N;if(!Number.isFinite(M))return u.NUM;if(Math.abs(M-f)<1e-10)return M;f=M<=-1?(f-1)/2:M}return u.NUM});
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{CellError as l,ERR as a,Matrix as i}from"../../values.js";import{toBool as w,toNumber as c,toText as A}from"../coerce.js";import{Lambda as h,Missing as p,Reference as g,Union as x}from"../types.js";export const FUNCTIONS=new Map;const d=255;export const many=d;export function signature(e){const r=/^([vr?]*)(?:\(([vr]+)\))?$/u.exec(e),t=r?.[1];if(t===void 0||(t.match(/\?/gu)??[]).length>1)throw new Error(`"${e}" is not a signature.`);const o=m=>Array.from({length:m.length},(y,b)=>m.charAt(b)==="v"?"value":"whole"),n=o(t.replace("?","")),f=o(r?.[2]??""),s=t.indexOf("?"),u=s>=0?s:n.length+f.length;return{fixed:n,group:f,min:u,max:f.length>0?d:n.length}}export function paramAt(e,r){return r<e.fixed.length?e.fixed[r]??"whole":e.group.length===0?"whole":e.group[(r-e.fixed.length)%e.group.length]??"whole"}export function fillsGroup(e,r){return e.group.length===0||r<=e.fixed.length?!0:(r-e.fixed.length)%e.group.length===0}export function scalar(e,r,t,o,n={}){FUNCTIONS.set(e,{name:e,min:r,max:t,kind:"scalar",call:o,from:n.from??"allyhub",...n.errors===!0?{errors:!0}:{},...n.volatile===!0?{volatile:!0}:{}})}export function raw(e,r,t,o={}){const{min:n,max:f,fixed:s,group:u}=signature(r);FUNCTIONS.set(e,{name:e,min:n,max:f,kind:"raw",params:{fixed:s,group:u},call:t,from:o.from??"allyhub",...o.volatile===!0?{volatile:!0}:{}})}export function lazy(e,r,t,o){FUNCTIONS.set(e,{name:e,min:r,max:t,kind:"lazy",call:o,from:"allyhub"})}export function alias(e,r){const t=FUNCTIONS.get(r);t&&FUNCTIONS.set(e,{...t,name:e})}export function cellsOf(e,r){if(e instanceof l)return e;if(e instanceof x)return a.VALUE;if(e instanceof g){const o=Math.min(e.bottom,e.sheet.lastRow);return{rows:Math.max(0,o-e.top+1),cols:e.cols,at:(n,f)=>r.calc.read(e.sheet,e.top+n,e.left+f),reference:e}}if(e instanceof i)return{rows:e.rows,cols:e.cols,at:(o,n)=>e.at(o,n)};if(e instanceof h)return a.VALUE;const t=e instanceof p?null:e;return{rows:1,cols:1,at:()=>t}}export function eachArg(e,r,t){for(const o of e)if(o instanceof g)r.calc.each(o,n=>{t(n,!1)});else if(o instanceof x)for(const n of o.parts)r.calc.each(n,f=>{t(f,!1)});else if(o instanceof i)for(const n of o.data)n!==null&&t(n,!1);else o instanceof p?t(null,!0):o instanceof h?t(a.VALUE,!0):t(o,!0)}export function eachRow(e,r,t){const o=n=>{for(const f of r.calc.matrix(n).data)t(f,!1)};for(const n of e)if(n instanceof g)o(n);else if(n instanceof x)n.parts.forEach(o);else if(n instanceof i)for(const f of n.data)t(f,!1);else n instanceof p?t(null,!0):n instanceof h?t(a.VALUE,!0):t(n,!0)}export function numbersOf(e,r){const t=[];let o;return eachArg(e,r,(n,f)=>{if(!o){if(n instanceof l)o=n;else if(typeof n=="number")t.push(n);else if(f){const s=c(n);s instanceof l?o=s:t.push(s)}}}),o??t}export function numbersOfA(e,r){const t=[];let o;return eachArg(e,r,(n,f)=>{if(!o)if(n instanceof l)o=n;else if(typeof n=="number")t.push(n);else if(typeof n=="boolean")t.push(n?1:0);else if(f){const s=c(n);s instanceof l?o=s:t.push(s)}else typeof n=="string"&&t.push(0)}),o??t}export const number=e=>(...r)=>{const t=[];for(const o of r){const n=c(o);if(n instanceof l)return n;t.push(n)}return e(...t)};export function textArg(e){return A(e)}export function boolArg(e,r){return e==null?r:w(e)}export function numberArg(e,r){return e===void 0?r:c(e)}
2
+ import{CellError as a,ERR as l,Matrix as i}from"../../values.js";import{toBool as w,toNumber as c,toText as A}from"../coerce.js";import{Lambda as h,Missing as p,Reference as g,Union as x}from"../types.js";export const FUNCTIONS=new Map;const d=255;export const many=d;export function signature(e){const r=/^([vr?]*)(?:\(([vr]+)\))?$/u.exec(e),t=r?.[1];if(t===void 0||(t.match(/\?/gu)??[]).length>1)throw new Error(`"${e}" is not a signature.`);const o=m=>Array.from({length:m.length},(y,b)=>m.charAt(b)==="v"?"value":"whole"),n=o(t.replace("?","")),f=o(r?.[2]??""),s=t.indexOf("?"),u=s>=0?s:n.length+f.length;return{fixed:n,group:f,min:u,max:f.length>0?d:n.length}}export function paramAt(e,r){return r<e.fixed.length?e.fixed[r]??"whole":e.group.length===0?"whole":e.group[(r-e.fixed.length)%e.group.length]??"whole"}export function fillsGroup(e,r){return e.group.length===0||r<=e.fixed.length?!0:(r-e.fixed.length)%e.group.length===0}export function scalar(e,r,t,o,n={}){FUNCTIONS.set(e,{name:e,min:r,max:t,kind:"scalar",call:o,from:n.from??"allyhub",...n.errors===!0?{errors:!0}:{},...n.volatile===!0?{volatile:!0}:{}})}export function raw(e,r,t,o={}){const{min:n,max:f,fixed:s,group:u}=signature(r);FUNCTIONS.set(e,{name:e,min:n,max:f,kind:"raw",params:{fixed:s,group:u},call:t,from:o.from??"allyhub",...o.volatile===!0?{volatile:!0}:{}})}export function lazy(e,r,t,o){FUNCTIONS.set(e,{name:e,min:r,max:t,kind:"lazy",call:o,from:"allyhub"})}export function alias(e,r){const t=FUNCTIONS.get(r);t&&FUNCTIONS.set(e,{...t,name:e})}export function cellsOf(e,r){if(e instanceof a)return e;if(e instanceof x)return l.VALUE;if(e instanceof g){const o=Math.min(e.bottom,e.sheet.lastRow);return{rows:Math.max(0,o-e.top+1),cols:e.cols,at:(n,f)=>r.calc.read(e.sheet,e.top+n,e.left+f),reference:e}}if(e instanceof i)return{rows:e.rows,cols:e.cols,at:(o,n)=>e.at(o,n),array:e};if(e instanceof h)return l.VALUE;const t=e instanceof p?null:e;return{rows:1,cols:1,at:()=>t}}export function eachArg(e,r,t){for(const o of e)if(o instanceof g)r.calc.each(o,n=>{t(n,!1)});else if(o instanceof x)for(const n of o.parts)r.calc.each(n,f=>{t(f,!1)});else if(o instanceof i)for(const n of o.data)n!==null&&t(n,!1);else o instanceof p?t(null,!0):o instanceof h?t(l.VALUE,!0):t(o,!0)}export function eachRow(e,r,t){const o=n=>{for(const f of r.calc.matrix(n).data)t(f,!1)};for(const n of e)if(n instanceof g)o(n);else if(n instanceof x)n.parts.forEach(o);else if(n instanceof i)for(const f of n.data)t(f,!1);else n instanceof p?t(null,!0):n instanceof h?t(l.VALUE,!0):t(n,!0)}export function numbersOf(e,r){const t=[];let o;return eachArg(e,r,(n,f)=>{if(!o){if(n instanceof a)o=n;else if(typeof n=="number")t.push(n);else if(f){const s=c(n);s instanceof a?o=s:t.push(s)}}}),o??t}export function numbersOfA(e,r){const t=[];let o;return eachArg(e,r,(n,f)=>{if(!o)if(n instanceof a)o=n;else if(typeof n=="number")t.push(n);else if(typeof n=="boolean")t.push(n?1:0);else if(f){const s=c(n);s instanceof a?o=s:t.push(s)}else typeof n=="string"&&t.push(0)}),o??t}export const number=e=>(...r)=>{const t=[];for(const o of r){const n=c(o);if(n instanceof a)return n;t.push(n)}return e(...t)};export function textArg(e){return A(e)}export function boolArg(e,r){return e==null?r:w(e)}export function numberArg(e,r){return e===void 0?r:c(e)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{cellName as N}from"../../address.js";import{CellError as s,ERR as n,Matrix as R}from"../../values.js";import{FormulaCell as p}from"../../workbook.js";import{toNumber as L,toText as d}from"../coerce.js";import{Lambda as I,Reference as l,Union as y}from"../types.js";import{lazy as u,raw as m,scalar as c}from"./define.js";const f=(e,r)=>{c(e,1,1,t=>r(t),{errors:!0})};f("ISBLANK",e=>e==null),f("ISNUMBER",e=>typeof e=="number"),f("ISTEXT",e=>typeof e=="string"),f("ISNONTEXT",e=>typeof e!="string"),f("ISLOGICAL",e=>typeof e=="boolean"),f("ISERROR",e=>e instanceof s),f("ISERR",e=>e instanceof s&&e!==n.NA),f("ISNA",e=>e===n.NA);const E=(e,r)=>{const t=L(e);return t instanceof s?t:Math.abs(Math.trunc(t))%2===r};c("ISEVEN",1,1,e=>E(e,0)),c("ISODD",1,1,e=>E(e,1)),c("N",1,1,e=>typeof e=="number"?e:typeof e=="boolean"?e?1:0:e instanceof s?e:0,{errors:!0}),m("NA","",()=>n.NA),m("TYPE","r",(e,r)=>{const t=r.calc.flat(e[0]);return t instanceof R?64:typeof t=="number"||t===null?1:typeof t=="string"?2:typeof t=="boolean"?4:16});const S=[n.NULL,n.DIV0,n.VALUE,n.REF,n.NAME,n.NUM,n.NA];c("ERROR.TYPE",1,1,e=>{const r=e instanceof s?S.indexOf(e):-1;return r<0?n.NA:r+1},{errors:!0}),u("ISREF",1,1,(e,r)=>{const t=e[0];if(!t)return!1;const o=r.calc.eval(t,r.frame);return o instanceof l||o instanceof y});const A=e=>e instanceof l?e.sheet.at(e.top,e.left):void 0;u("ISFORMULA",1,1,(e,r)=>{const t=e[0];if(!t)return n.VALUE;const o=r.calc.eval(t,r.frame);return o instanceof I?n.VALUE:A(o)instanceof p}),u("FORMULATEXT",1,1,(e,r)=>{const t=e[0];if(!t)return n.VALUE;const o=A(r.calc.eval(t,r.frame));return o instanceof p?o.text:n.NA}),m("CELL","v?r",(e,r)=>{const t=d(r.calc.scalar(e[0],r.frame));if(t instanceof s)return t;const o=e[1],a=o instanceof l?o:new l(r.frame.sheet,r.frame.row,r.frame.col,r.frame.row,r.frame.col),i=r.calc.read(a.sheet,a.top,a.left);switch(t.toLowerCase()){case"row":return a.top+1;case"col":return a.left+1;case"address":return N({row:a.top,col:a.left}).replace(/^([A-Z]+)(\d+)$/u,"$$$1$$$2");case"contents":return i;case"type":return i===null?"b":typeof i=="string"?"l":"v";default:return n.VALUE}});
2
+ import{cellName as N}from"../../address.js";import{CellError as s,ERR as n,Matrix as R}from"../../values.js";import{FormulaCell as E}from"../../workbook.js";import{toNumber as L,toText as d}from"../coerce.js";import{Lambda as I,Reference as l,Union as y}from"../types.js";import{lazy as m,raw as i,scalar as c}from"./define.js";const f=(e,r)=>{c(e,1,1,t=>r(t),{errors:!0})};f("ISBLANK",e=>e==null),f("ISNUMBER",e=>typeof e=="number"),f("ISTEXT",e=>typeof e=="string"),f("ISNONTEXT",e=>typeof e!="string"),f("ISLOGICAL",e=>typeof e=="boolean"),f("ISERROR",e=>e instanceof s),f("ISERR",e=>e instanceof s&&e!==n.NA),f("ISNA",e=>e===n.NA);const p=(e,r)=>{const t=L(e);return t instanceof s?t:Math.abs(Math.trunc(t))%2===r};c("ISEVEN",1,1,e=>p(e,0)),c("ISODD",1,1,e=>p(e,1)),c("N",1,1,e=>typeof e=="number"?e:typeof e=="boolean"?e?1:0:e instanceof s?e:0,{errors:!0}),i("NA","",()=>n.NA),i("TYPE","r",(e,r)=>{const t=r.calc.flat(e[0]);return t instanceof R?64:typeof t=="number"||t===null?1:typeof t=="string"?2:typeof t=="boolean"?4:16});const S=[n.NULL,n.DIV0,n.VALUE,n.REF,n.NAME,n.NUM,n.NA];c("ERROR.TYPE",1,1,e=>{const r=e instanceof s?S.indexOf(e):-1;return r<0?n.NA:r+1},{errors:!0}),m("ISREF",1,1,(e,r)=>{const t=e[0];if(!t)return!1;const o=r.calc.eval(t,r.frame);return o instanceof l||o instanceof y});const A=e=>e instanceof l?e.sheet.at(e.top,e.left):void 0;m("ISFORMULA",1,1,(e,r)=>{const t=e[0];if(!t)return n.VALUE;const o=r.calc.eval(t,r.frame);return o instanceof I?n.VALUE:A(o)instanceof E}),m("FORMULATEXT",1,1,(e,r)=>{const t=e[0];if(!t)return n.VALUE;const o=A(r.calc.eval(t,r.frame));return o instanceof E?o.text:n.NA}),i("CELL","v?r",(e,r)=>{const t=d(r.calc.scalar(e[0],r.frame));if(t instanceof s)return t;const o=e[1],a=o instanceof l?o:new l(r.frame.sheet,r.frame.row,r.frame.col,r.frame.row,r.frame.col),u=r.calc.read(a.sheet,a.top,a.left);switch(t.toLowerCase()){case"row":return a.top+1;case"col":return a.left+1;case"address":return N({row:a.top,col:a.left}).replace(/^([A-Z]+)(\d+)$/u,"$$$1$$$2");case"contents":return u;case"type":return u===null?"b":typeof u=="string"?"l":"v";default:return n.VALUE}}),i("TABLE","?rrrrr",()=>n.NA);