@allyhub/sdk 0.8.0 → 0.10.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 (497) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/NOTICE +46 -49
  3. package/dist/dom.d.ts +1 -209
  4. package/dist/dom.js +1 -1
  5. package/dist/image.d.ts +2 -0
  6. package/dist/image.js +2 -0
  7. package/dist/index.d.ts +1 -21
  8. package/dist/index.js +1 -1
  9. package/dist/media.d.ts +1 -5
  10. package/dist/media.js +1 -1
  11. package/dist/node_modules/@allyhub/audio/dist/levels.d.ts +4 -5
  12. package/dist/node_modules/@allyhub/audio/dist/levels.js +1 -1
  13. package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.d.ts +1 -6
  14. package/dist/node_modules/@allyhub/audio/dist/node/ffmpeg.js +1 -1
  15. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  16. package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
  17. package/dist/node_modules/@allyhub/chart/dist/chart-xml.d.ts +4 -1
  18. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +2 -2
  19. package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +22 -0
  20. package/dist/node_modules/@allyhub/chart/dist/chart.js +1 -1
  21. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  22. package/dist/node_modules/@allyhub/diagnostics/LICENSE +241 -0
  23. package/dist/node_modules/@allyhub/diagnostics/dist/fact.d.ts +37 -0
  24. package/dist/node_modules/@allyhub/diagnostics/dist/fact.js +2 -0
  25. package/dist/node_modules/@allyhub/diagnostics/dist/index.d.ts +4 -0
  26. package/dist/node_modules/@allyhub/diagnostics/dist/index.js +2 -0
  27. package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +43 -0
  28. package/dist/node_modules/@allyhub/diagnostics/dist/problem.js +2 -0
  29. package/dist/node_modules/@allyhub/diagnostics/dist/rules.d.ts +30 -0
  30. package/dist/node_modules/@allyhub/diagnostics/dist/rules.js +2 -0
  31. package/dist/node_modules/@allyhub/diagnostics/package.json +14 -0
  32. package/dist/node_modules/@allyhub/formats/dist/contributed.d.ts +126 -0
  33. package/dist/node_modules/@allyhub/formats/dist/contributed.js +2 -0
  34. package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +1 -1
  35. package/dist/node_modules/@allyhub/formats/dist/data/reference.d.ts +7 -12
  36. package/dist/node_modules/@allyhub/formats/dist/data/reference.js +1 -1
  37. package/dist/node_modules/@allyhub/formats/dist/data/script.d.ts +9 -4
  38. package/dist/node_modules/@allyhub/formats/dist/data/script.js +1 -1
  39. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +107 -83
  40. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  41. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +185 -8
  42. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  43. package/dist/node_modules/@allyhub/formats/dist/data/website.d.ts +2 -1
  44. package/dist/node_modules/@allyhub/formats/dist/data/website.js +1 -1
  45. package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +42 -0
  46. package/dist/node_modules/@allyhub/formats/dist/data/work.js +2 -0
  47. package/dist/node_modules/@allyhub/formats/dist/extension.d.ts +91 -0
  48. package/dist/node_modules/@allyhub/formats/dist/extension.js +2 -0
  49. package/dist/node_modules/@allyhub/formats/dist/files.d.ts +51 -0
  50. package/dist/node_modules/@allyhub/formats/dist/files.js +2 -0
  51. package/dist/node_modules/@allyhub/formats/dist/index.d.ts +5 -1
  52. package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
  53. package/dist/node_modules/@allyhub/formats/dist/items.d.ts +226 -90
  54. package/dist/node_modules/@allyhub/formats/dist/items.js +1 -1
  55. package/dist/node_modules/@allyhub/formats/dist/layout.d.ts +7 -1
  56. package/dist/node_modules/@allyhub/formats/dist/layout.js +1 -1
  57. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +96 -42
  58. package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
  59. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  60. package/dist/node_modules/@allyhub/image-draw/LICENSE +241 -0
  61. package/dist/node_modules/@allyhub/image-draw/dist/context.d.ts +5 -0
  62. package/dist/node_modules/@allyhub/image-draw/dist/context.js +2 -0
  63. package/dist/node_modules/@allyhub/image-draw/dist/contrast.d.ts +13 -0
  64. package/dist/node_modules/@allyhub/image-draw/dist/contrast.js +2 -0
  65. package/dist/node_modules/@allyhub/image-draw/dist/env.d.ts +112 -0
  66. package/dist/node_modules/@allyhub/image-draw/dist/env.js +2 -0
  67. package/dist/node_modules/@allyhub/image-draw/dist/errors.d.ts +20 -0
  68. package/dist/node_modules/@allyhub/image-draw/dist/errors.js +2 -0
  69. package/dist/node_modules/@allyhub/image-draw/dist/fonts.d.ts +110 -0
  70. package/dist/node_modules/@allyhub/image-draw/dist/fonts.js +2 -0
  71. package/dist/node_modules/@allyhub/image-draw/dist/guards.d.ts +32 -0
  72. package/dist/node_modules/@allyhub/image-draw/dist/guards.js +2 -0
  73. package/dist/node_modules/@allyhub/image-draw/dist/hash.d.ts +3 -0
  74. package/dist/node_modules/@allyhub/image-draw/dist/hash.js +2 -0
  75. package/dist/node_modules/@allyhub/image-draw/dist/inspect.d.ts +113 -0
  76. package/dist/node_modules/@allyhub/image-draw/dist/inspect.js +3 -0
  77. package/dist/node_modules/@allyhub/image-draw/dist/layer-style.d.ts +151 -0
  78. package/dist/node_modules/@allyhub/image-draw/dist/layer-style.js +2 -0
  79. package/dist/node_modules/@allyhub/image-draw/dist/paint.d.ts +29 -0
  80. package/dist/node_modules/@allyhub/image-draw/dist/paint.js +2 -0
  81. package/dist/node_modules/@allyhub/image-draw/dist/pictures.d.ts +39 -0
  82. package/dist/node_modules/@allyhub/image-draw/dist/pictures.js +2 -0
  83. package/dist/node_modules/@allyhub/image-draw/dist/plan.d.ts +52 -0
  84. package/dist/node_modules/@allyhub/image-draw/dist/plan.js +2 -0
  85. package/dist/node_modules/@allyhub/image-draw/dist/reads.d.ts +145 -0
  86. package/dist/node_modules/@allyhub/image-draw/dist/reads.js +2 -0
  87. package/dist/node_modules/@allyhub/image-draw/dist/shape-path.d.ts +26 -0
  88. package/dist/node_modules/@allyhub/image-draw/dist/shape-path.js +2 -0
  89. package/dist/node_modules/@allyhub/image-draw/dist/stage.d.ts +56 -0
  90. package/dist/node_modules/@allyhub/image-draw/dist/stage.js +2 -0
  91. package/dist/node_modules/@allyhub/image-draw/dist/styles.d.ts +35 -0
  92. package/dist/node_modules/@allyhub/image-draw/dist/styles.js +2 -0
  93. package/dist/node_modules/@allyhub/image-draw/dist/tone.d.ts +53 -0
  94. package/dist/node_modules/@allyhub/image-draw/dist/tone.js +2 -0
  95. package/dist/node_modules/@allyhub/image-draw/package.json +14 -0
  96. package/dist/node_modules/@allyhub/image-measure/LICENSE +241 -0
  97. package/dist/node_modules/@allyhub/image-measure/dist/contrast.d.ts +43 -0
  98. package/dist/node_modules/@allyhub/image-measure/dist/contrast.js +2 -0
  99. package/dist/node_modules/@allyhub/image-measure/dist/layout.d.ts +186 -0
  100. package/dist/node_modules/@allyhub/image-measure/dist/layout.js +5 -0
  101. package/dist/node_modules/@allyhub/image-measure/package.json +14 -0
  102. package/dist/node_modules/@allyhub/image-sdk/LICENSE +241 -0
  103. package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.d.ts +13 -0
  104. package/dist/node_modules/@allyhub/image-sdk/dist/adjustment.js +2 -0
  105. package/dist/{define.d.ts → node_modules/@allyhub/image-sdk/dist/define.d.ts} +21 -4
  106. package/dist/node_modules/@allyhub/image-sdk/dist/define.js +2 -0
  107. package/dist/node_modules/@allyhub/image-sdk/dist/dom.d.ts +210 -0
  108. package/dist/node_modules/@allyhub/image-sdk/dist/dom.js +2 -0
  109. package/dist/node_modules/@allyhub/image-sdk/dist/fill.d.ts +21 -0
  110. package/dist/node_modules/@allyhub/image-sdk/dist/fill.js +2 -0
  111. package/dist/node_modules/@allyhub/image-sdk/dist/group.d.ts +17 -0
  112. package/dist/node_modules/@allyhub/image-sdk/dist/group.js +2 -0
  113. package/dist/node_modules/@allyhub/image-sdk/dist/index.d.ts +166 -0
  114. package/dist/node_modules/@allyhub/image-sdk/dist/index.js +2 -0
  115. package/dist/node_modules/@allyhub/image-sdk/dist/media.d.ts +6 -0
  116. package/dist/node_modules/@allyhub/image-sdk/dist/media.js +2 -0
  117. package/dist/{messages.d.ts → node_modules/@allyhub/image-sdk/dist/messages.d.ts} +1 -1
  118. package/dist/node_modules/@allyhub/image-sdk/dist/picture.d.ts +59 -0
  119. package/dist/node_modules/@allyhub/image-sdk/dist/picture.js +2 -0
  120. package/dist/{props.d.ts → node_modules/@allyhub/image-sdk/dist/props.d.ts} +4 -4
  121. package/dist/node_modules/@allyhub/image-sdk/dist/shape.d.ts +34 -0
  122. package/dist/node_modules/@allyhub/image-sdk/dist/shape.js +2 -0
  123. package/dist/node_modules/@allyhub/image-sdk/dist/stack.d.ts +16 -0
  124. package/dist/node_modules/@allyhub/image-sdk/dist/stack.js +2 -0
  125. package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.d.ts +38 -0
  126. package/dist/node_modules/@allyhub/image-sdk/dist/text-layer.js +2 -0
  127. package/dist/{written.js → node_modules/@allyhub/image-sdk/dist/written.js} +1 -1
  128. package/dist/node_modules/@allyhub/image-sdk/package.json +19 -0
  129. package/dist/node_modules/@allyhub/measure/LICENSE +241 -0
  130. package/dist/node_modules/@allyhub/measure/dist/compare.d.ts +195 -0
  131. package/dist/node_modules/@allyhub/measure/dist/compare.js +2 -0
  132. package/dist/node_modules/@allyhub/measure/dist/grain.d.ts +8 -0
  133. package/dist/node_modules/@allyhub/measure/dist/grain.js +2 -0
  134. package/dist/node_modules/@allyhub/measure/dist/image.d.ts +16 -0
  135. package/dist/node_modules/@allyhub/measure/dist/image.js +2 -0
  136. package/dist/node_modules/@allyhub/measure/dist/index.d.ts +4 -0
  137. package/dist/node_modules/@allyhub/measure/dist/index.js +2 -0
  138. package/dist/node_modules/@allyhub/measure/package.json +13 -0
  139. package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.d.ts +4 -1
  140. package/dist/node_modules/@allyhub/ooxml/dist/generated/presets.js +1 -1
  141. package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.d.ts +15 -1
  142. package/dist/node_modules/@allyhub/ooxml/dist/geometry/index.js +1 -1
  143. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  144. package/dist/node_modules/@allyhub/piece/LICENSE +241 -0
  145. package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.d.ts +1 -9
  146. package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.js +1 -1
  147. package/dist/node_modules/@allyhub/piece/dist/context.d.ts +39 -0
  148. package/dist/node_modules/@allyhub/piece/dist/context.js +2 -0
  149. package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.d.ts +2 -2
  150. package/dist/node_modules/@allyhub/{video-core → piece}/dist/export.d.ts +27 -10
  151. package/dist/node_modules/@allyhub/piece/dist/export.js +2 -0
  152. package/dist/node_modules/@allyhub/{video-core → piece}/dist/formats.d.ts +12 -68
  153. package/dist/node_modules/@allyhub/piece/dist/formats.js +2 -0
  154. package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +104 -0
  155. package/dist/node_modules/@allyhub/piece/dist/index.d.ts +26 -0
  156. package/dist/node_modules/@allyhub/piece/dist/index.js +2 -0
  157. package/dist/node_modules/@allyhub/piece/dist/layer-style.d.ts +1558 -0
  158. package/dist/node_modules/@allyhub/piece/dist/layer-style.js +2 -0
  159. package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +389 -0
  160. package/dist/node_modules/@allyhub/piece/dist/layer.js +2 -0
  161. package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +437 -0
  162. package/dist/node_modules/@allyhub/piece/dist/layout.js +2 -0
  163. package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.d.ts +1 -1
  164. package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.d.ts +39 -9
  165. package/dist/node_modules/@allyhub/{video-core → piece}/dist/media.js +1 -1
  166. package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.d.ts +6 -0
  167. package/dist/node_modules/@allyhub/piece/dist/names.d.ts +26 -0
  168. package/dist/node_modules/@allyhub/piece/dist/names.js +2 -0
  169. package/dist/node_modules/@allyhub/piece/dist/page/console.d.ts +21 -0
  170. package/dist/node_modules/@allyhub/piece/dist/page/console.js +2 -0
  171. package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +3 -0
  172. package/dist/node_modules/@allyhub/piece/dist/page/index.js +2 -0
  173. package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +4 -0
  174. package/dist/node_modules/@allyhub/piece/dist/page/locate.js +2 -0
  175. package/dist/node_modules/@allyhub/piece/dist/picture.d.ts +62 -0
  176. package/dist/node_modules/@allyhub/piece/dist/picture.js +2 -0
  177. package/dist/node_modules/@allyhub/piece/dist/piece.d.ts +15 -0
  178. package/dist/node_modules/@allyhub/piece/dist/piece.js +2 -0
  179. package/dist/node_modules/@allyhub/{video-core → piece}/dist/script.d.ts +9 -4
  180. package/dist/node_modules/@allyhub/piece/dist/script.js +2 -0
  181. package/dist/node_modules/@allyhub/piece/dist/source.d.ts +131 -0
  182. package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +291 -0
  183. package/dist/node_modules/@allyhub/piece/dist/stage.js +2 -0
  184. package/dist/node_modules/@allyhub/piece/dist/version.d.ts +15 -0
  185. package/dist/node_modules/@allyhub/piece/dist/version.js +2 -0
  186. package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.d.ts +1 -20
  187. package/dist/node_modules/@allyhub/piece/package.json +18 -0
  188. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +271 -0
  189. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  190. package/dist/node_modules/@allyhub/protocol/dist/app.d.ts +3 -10
  191. package/dist/node_modules/@allyhub/protocol/dist/app.js +1 -1
  192. package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +19 -1
  193. package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
  194. package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +337 -0
  195. package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +2 -0
  196. package/dist/node_modules/@allyhub/protocol/dist/cli.d.ts +12 -1
  197. package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
  198. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +155 -0
  199. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  200. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +235 -133
  201. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  202. package/dist/node_modules/@allyhub/protocol/dist/files.d.ts +2 -0
  203. package/dist/node_modules/@allyhub/protocol/dist/files.js +1 -1
  204. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +65 -197
  205. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  206. package/dist/node_modules/@allyhub/protocol/dist/image.d.ts +8 -0
  207. package/dist/node_modules/@allyhub/protocol/dist/image.js +2 -0
  208. package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +6 -0
  209. package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
  210. package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
  211. package/dist/node_modules/@allyhub/protocol/dist/kinds.d.ts +98 -0
  212. package/dist/node_modules/@allyhub/protocol/dist/kinds.js +2 -0
  213. package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +274 -0
  214. package/dist/node_modules/@allyhub/protocol/dist/mail.js +2 -0
  215. package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +77 -91
  216. package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
  217. package/dist/node_modules/@allyhub/protocol/dist/peer.d.ts +59 -0
  218. package/dist/node_modules/@allyhub/protocol/dist/peer.js +2 -0
  219. package/dist/node_modules/@allyhub/protocol/dist/place.d.ts +21 -0
  220. package/dist/node_modules/@allyhub/protocol/dist/place.js +2 -0
  221. package/dist/node_modules/@allyhub/protocol/dist/presence.d.ts +125 -0
  222. package/dist/node_modules/@allyhub/protocol/dist/presence.js +2 -0
  223. package/dist/node_modules/@allyhub/protocol/dist/registry.d.ts +1 -1
  224. package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
  225. package/dist/node_modules/@allyhub/protocol/dist/shape.d.ts +35 -0
  226. package/dist/node_modules/@allyhub/protocol/dist/shape.js +2 -0
  227. package/dist/node_modules/@allyhub/protocol/dist/shares.d.ts +2 -8
  228. package/dist/node_modules/@allyhub/protocol/dist/shares.js +1 -1
  229. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +70 -40
  230. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  231. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +224 -177
  232. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  233. package/dist/node_modules/@allyhub/protocol/package.json +5 -1
  234. package/dist/node_modules/@allyhub/runtimes/dist/bundled.js +1 -1
  235. package/dist/node_modules/@allyhub/runtimes/dist/declared.d.ts +14 -0
  236. package/dist/node_modules/@allyhub/runtimes/dist/declared.js +2 -0
  237. package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.d.ts +15 -0
  238. package/dist/node_modules/@allyhub/runtimes/dist/ffmpeg.js +2 -0
  239. package/dist/node_modules/@allyhub/runtimes/dist/index.d.ts +2 -0
  240. package/dist/node_modules/@allyhub/runtimes/dist/index.js +1 -1
  241. package/dist/node_modules/@allyhub/runtimes/dist/packages.js +3 -3
  242. package/dist/node_modules/@allyhub/runtimes/dist/runtimes.d.ts +1 -0
  243. package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +1 -1
  244. package/dist/node_modules/@allyhub/runtimes/manifest.json +0 -82
  245. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  246. package/dist/node_modules/@allyhub/scenery/dist/define.d.ts +2 -0
  247. package/dist/node_modules/@allyhub/scenery/dist/define.js +1 -1
  248. package/dist/node_modules/@allyhub/scenery/dist/index.d.ts +2 -2
  249. package/dist/node_modules/@allyhub/scenery/dist/index.js +1 -1
  250. package/dist/node_modules/@allyhub/scenery/dist/moire.d.ts +45 -5
  251. package/dist/node_modules/@allyhub/scenery/dist/moire.js +2 -2
  252. package/dist/node_modules/@allyhub/scenery/dist/phone.d.ts +4 -3
  253. package/dist/node_modules/@allyhub/scenery/dist/phone.js +1 -1
  254. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  255. package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
  256. package/dist/node_modules/@allyhub/sheet/dist/api/code.d.ts +4 -4
  257. package/dist/node_modules/@allyhub/sheet/dist/api/code.js +1 -1
  258. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +15 -11
  259. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
  260. package/dist/node_modules/@allyhub/sheet/dist/calc/coerce.js +1 -1
  261. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.d.ts +70 -0
  262. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  263. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.d.ts +6 -0
  264. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/criteria.js +1 -1
  265. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/date.js +1 -1
  266. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.d.ts +3 -1
  267. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/define.js +1 -1
  268. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/info.js +1 -1
  269. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/kernels.js +1 -1
  270. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/lookup.js +1 -1
  271. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/maths.js +1 -1
  272. package/dist/node_modules/@allyhub/sheet/dist/calc/functions/text.js +1 -1
  273. package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.d.ts +9 -0
  274. package/dist/node_modules/@allyhub/sheet/dist/calc/indexes.js +1 -1
  275. package/dist/node_modules/@allyhub/sheet/dist/calc/server.d.ts +1 -1
  276. package/dist/node_modules/@allyhub/sheet/dist/calc/types.d.ts +6 -0
  277. package/dist/node_modules/@allyhub/sheet/dist/calc/types.js +1 -1
  278. package/dist/node_modules/@allyhub/sheet/dist/chart.d.ts +9 -0
  279. package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
  280. package/dist/node_modules/@allyhub/sheet/dist/export.js +1 -1
  281. package/dist/node_modules/@allyhub/sheet/dist/file.d.ts +5 -0
  282. package/dist/node_modules/@allyhub/sheet/dist/file.js +1 -1
  283. package/dist/node_modules/@allyhub/sheet/dist/formula/ast.d.ts +12 -1
  284. package/dist/node_modules/@allyhub/sheet/dist/formula/move.d.ts +5 -1
  285. package/dist/node_modules/@allyhub/sheet/dist/formula/move.js +1 -1
  286. package/dist/node_modules/@allyhub/sheet/dist/formula/parse.js +1 -1
  287. package/dist/node_modules/@allyhub/sheet/dist/formula/print.js +1 -1
  288. package/dist/node_modules/@allyhub/sheet/dist/generated.d.ts +5 -19
  289. package/dist/node_modules/@allyhub/sheet/dist/generated.js +1 -1
  290. package/dist/node_modules/@allyhub/sheet/dist/import.d.ts +3 -1
  291. package/dist/node_modules/@allyhub/sheet/dist/import.js +1 -1
  292. package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +5 -5
  293. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  294. package/dist/node_modules/@allyhub/sheet/dist/inspect.d.ts +88 -3
  295. package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
  296. package/dist/node_modules/@allyhub/sheet/dist/patch.d.ts +1 -1
  297. package/dist/node_modules/@allyhub/sheet/dist/patch.js +1 -1
  298. package/dist/node_modules/@allyhub/sheet/dist/printed.d.ts +19 -0
  299. package/dist/node_modules/@allyhub/sheet/dist/printed.js +2 -0
  300. package/dist/node_modules/@allyhub/sheet/dist/sdk.d.ts +2 -0
  301. package/dist/node_modules/@allyhub/sheet/dist/sdk.js +2 -0
  302. package/dist/node_modules/@allyhub/sheet/dist/values.d.ts +2 -0
  303. package/dist/node_modules/@allyhub/sheet/dist/values.js +1 -1
  304. package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +8 -6
  305. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  306. package/dist/node_modules/@allyhub/sheet/dist/write.js +15 -15
  307. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.d.ts +6 -2
  308. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  309. package/dist/node_modules/@allyhub/sheet/dist/xlsx/formula.js +2 -2
  310. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.d.ts +2 -1
  311. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  312. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +3 -1
  313. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  314. package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.d.ts +7 -1
  315. package/dist/node_modules/@allyhub/sheet/dist/xlsx/sax.js +3 -1
  316. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.d.ts +6 -0
  317. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  318. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.d.ts +1 -1
  319. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  320. package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.d.ts +12 -1
  321. package/dist/node_modules/@allyhub/sheet/dist/xlsx/xml.js +3 -2
  322. package/dist/node_modules/@allyhub/sheet/package.json +5 -1
  323. package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +23 -7
  324. package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
  325. package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +101 -11
  326. package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
  327. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  328. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.d.ts +18 -1
  329. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
  330. package/dist/node_modules/@allyhub/slides-core/dist/code.d.ts +1 -1
  331. package/dist/node_modules/@allyhub/slides-core/dist/connect.d.ts +62 -0
  332. package/dist/node_modules/@allyhub/slides-core/dist/connect.js +2 -0
  333. package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +24 -0
  334. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  335. package/dist/node_modules/@allyhub/slides-core/dist/fact.d.ts +223 -0
  336. package/dist/node_modules/@allyhub/slides-core/dist/fact.js +2 -0
  337. package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +4 -4
  338. package/dist/node_modules/@allyhub/slides-core/dist/file.js +2 -2
  339. package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +2 -0
  340. package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
  341. package/dist/node_modules/@allyhub/slides-core/dist/measure.d.ts +4 -2
  342. package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
  343. package/dist/node_modules/@allyhub/slides-core/dist/merge.d.ts +5 -5
  344. package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
  345. package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +25 -4
  346. package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +1 -1
  347. package/dist/node_modules/@allyhub/slides-core/dist/path.d.ts +1 -1
  348. package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +20 -11
  349. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  350. package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +18 -0
  351. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +2 -0
  352. package/dist/node_modules/@allyhub/slides-core/dist/stage.d.ts +28 -11
  353. package/dist/node_modules/@allyhub/slides-core/dist/units.d.ts +3 -6
  354. package/dist/node_modules/@allyhub/slides-core/dist/units.js +1 -1
  355. package/dist/node_modules/@allyhub/slides-core/package.json +5 -1
  356. package/dist/node_modules/@allyhub/video-core/dist/audio-types.d.ts +1 -2
  357. package/dist/node_modules/@allyhub/video-core/dist/captions.d.ts +1 -10
  358. package/dist/node_modules/@allyhub/video-core/dist/captions.js +1 -1
  359. package/dist/node_modules/@allyhub/video-core/dist/check.d.ts +62 -0
  360. package/dist/node_modules/@allyhub/video-core/dist/check.js +2 -0
  361. package/dist/node_modules/@allyhub/video-core/dist/cut-report.d.ts +2 -2
  362. package/dist/node_modules/@allyhub/video-core/dist/cut-report.js +1 -1
  363. package/dist/node_modules/@allyhub/video-core/dist/edits.d.ts +3 -3
  364. package/dist/node_modules/@allyhub/video-core/dist/edits.js +1 -1
  365. package/dist/node_modules/@allyhub/video-core/dist/fact.d.ts +21 -762
  366. package/dist/node_modules/@allyhub/video-core/dist/fact.js +1 -1
  367. package/dist/node_modules/@allyhub/video-core/dist/footage-motion.d.ts +3 -2
  368. package/dist/node_modules/@allyhub/video-core/dist/footage-motion.js +1 -1
  369. package/dist/node_modules/@allyhub/video-core/dist/index.d.ts +3 -17
  370. package/dist/node_modules/@allyhub/video-core/dist/index.js +1 -1
  371. package/dist/node_modules/@allyhub/video-core/dist/measure.d.ts +72 -423
  372. package/dist/node_modules/@allyhub/video-core/dist/measure.js +1 -4
  373. package/dist/node_modules/@allyhub/video-core/dist/mix-plan.d.ts +44 -0
  374. package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +2 -0
  375. package/dist/node_modules/@allyhub/video-core/dist/motion.d.ts +1 -1
  376. package/dist/node_modules/@allyhub/video-core/dist/piece.d.ts +24 -432
  377. package/dist/node_modules/@allyhub/video-core/dist/piece.js +1 -1
  378. package/dist/node_modules/@allyhub/video-core/dist/placement.d.ts +1 -1
  379. package/dist/node_modules/@allyhub/video-core/dist/schema.d.ts +8 -14
  380. package/dist/node_modules/@allyhub/video-core/dist/schema.js +1 -1
  381. package/dist/node_modules/@allyhub/video-core/dist/script-edit.d.ts +11 -6
  382. package/dist/node_modules/@allyhub/video-core/dist/script-edit.js +1 -1
  383. package/dist/node_modules/@allyhub/video-core/dist/seams.d.ts +2 -3
  384. package/dist/node_modules/@allyhub/video-core/dist/sound-under.d.ts +2 -2
  385. package/dist/node_modules/@allyhub/video-core/dist/sound-under.js +1 -1
  386. package/dist/node_modules/@allyhub/video-core/dist/speech.d.ts +2 -4
  387. package/dist/node_modules/@allyhub/video-core/dist/speech.js +2 -2
  388. package/dist/node_modules/@allyhub/video-core/dist/stage.d.ts +52 -0
  389. package/dist/node_modules/@allyhub/video-core/dist/stage.js +2 -0
  390. package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +18 -136
  391. package/dist/node_modules/@allyhub/video-core/dist/timeline.js +1 -1
  392. package/dist/node_modules/@allyhub/video-core/dist/timing.d.ts +3 -3
  393. package/dist/node_modules/@allyhub/video-core/dist/timing.js +1 -1
  394. package/dist/node_modules/@allyhub/video-core/dist/transcript.d.ts +2 -2
  395. package/dist/node_modules/@allyhub/video-core/dist/transcript.js +1 -1
  396. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  397. package/dist/node_modules/@allyhub/video-sdk/LICENSE +241 -0
  398. package/dist/node_modules/@allyhub/video-sdk/NOTICE +118 -0
  399. package/dist/{free.d.ts → node_modules/@allyhub/video-sdk/dist/free.d.ts} +14 -10
  400. package/dist/node_modules/@allyhub/video-sdk/dist/free.js +2 -0
  401. package/dist/node_modules/@allyhub/video-sdk/dist/index.d.ts +28 -0
  402. package/dist/node_modules/@allyhub/video-sdk/dist/index.js +2 -0
  403. package/dist/{input.d.ts → node_modules/@allyhub/video-sdk/dist/input.d.ts} +76 -22
  404. package/dist/node_modules/@allyhub/video-sdk/dist/input.js +2 -0
  405. package/dist/{module.d.ts → node_modules/@allyhub/video-sdk/dist/module.d.ts} +6 -4
  406. package/dist/node_modules/@allyhub/video-sdk/dist/module.js +2 -0
  407. package/dist/{parts.d.ts → node_modules/@allyhub/video-sdk/dist/parts.d.ts} +15 -6
  408. package/dist/node_modules/@allyhub/video-sdk/dist/parts.js +2 -0
  409. package/dist/{phone.d.ts → node_modules/@allyhub/video-sdk/dist/phone.d.ts} +12 -5
  410. package/dist/node_modules/@allyhub/video-sdk/dist/phone.js +2 -0
  411. package/dist/{piece.d.ts → node_modules/@allyhub/video-sdk/dist/piece.d.ts} +26 -16
  412. package/dist/node_modules/@allyhub/video-sdk/dist/piece.js +2 -0
  413. package/dist/node_modules/@allyhub/video-sdk/dist/route.d.ts +46 -0
  414. package/dist/node_modules/@allyhub/video-sdk/dist/route.js +2 -0
  415. package/dist/node_modules/@allyhub/video-sdk/dist/scenery.d.ts +2 -0
  416. package/dist/node_modules/@allyhub/video-sdk/dist/scenery.js +2 -0
  417. package/dist/node_modules/@allyhub/video-sdk/package.json +19 -0
  418. package/dist/scenery.d.ts +1 -1
  419. package/dist/scenery.js +1 -1
  420. package/dist/sheets.d.ts +1 -1
  421. package/dist/sheets.js +1 -1
  422. package/dist/slides.d.ts +1 -9
  423. package/dist/slides.js +1 -1
  424. package/docs/README.md +10 -6
  425. package/docs/batches.md +5 -5
  426. package/docs/canvas.md +28 -0
  427. package/docs/contract.md +2 -2
  428. package/docs/defaults.md +298 -22
  429. package/docs/docs.md +80 -66
  430. package/docs/footage.md +7 -7
  431. package/docs/image.md +165 -0
  432. package/docs/layers.md +22 -13
  433. package/docs/modeling.md +4 -4
  434. package/docs/pictures.md +65 -0
  435. package/docs/project.md +51 -31
  436. package/docs/scenery.md +14 -15
  437. package/docs/sheets.md +46 -28
  438. package/docs/slides.md +121 -67
  439. package/docs/sound.md +3 -3
  440. package/docs/speech.md +8 -8
  441. package/docs/video.md +16 -13
  442. package/docs/websites.md +4 -4
  443. package/docs/x.md +73 -0
  444. package/package.json +7 -2
  445. package/dist/define.js +0 -2
  446. package/dist/free.js +0 -2
  447. package/dist/input.js +0 -2
  448. package/dist/module.js +0 -2
  449. package/dist/node_modules/@allyhub/formats/dist/data/comments.d.ts +0 -94
  450. package/dist/node_modules/@allyhub/formats/dist/data/comments.js +0 -2
  451. package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package-lock.json +0 -227
  452. package/dist/node_modules/@allyhub/runtimes/pins/onnxruntime-node/package.json +0 -8
  453. package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package-lock.json +0 -105
  454. package/dist/node_modules/@allyhub/runtimes/pins/sherpa-onnx-node/package.json +0 -8
  455. package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package-lock.json +0 -128
  456. package/dist/node_modules/@allyhub/runtimes/pins/tesseract.js/package.json +0 -9
  457. package/dist/node_modules/@allyhub/video-core/dist/export.js +0 -2
  458. package/dist/node_modules/@allyhub/video-core/dist/formats.js +0 -2
  459. package/dist/node_modules/@allyhub/video-core/dist/gen.d.ts +0 -37
  460. package/dist/node_modules/@allyhub/video-core/dist/problem.d.ts +0 -278
  461. package/dist/node_modules/@allyhub/video-core/dist/problem.js +0 -2
  462. package/dist/node_modules/@allyhub/video-core/dist/script.js +0 -2
  463. package/dist/node_modules/@allyhub/video-core/dist/source.d.ts +0 -7
  464. package/dist/parts.js +0 -2
  465. package/dist/phone.js +0 -2
  466. package/dist/piece.js +0 -2
  467. /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.d.ts +0 -0
  468. /package/dist/node_modules/@allyhub/{sheet → formats}/dist/csv.js +0 -0
  469. /package/dist/{fit.d.ts → node_modules/@allyhub/image-sdk/dist/fit.d.ts} +0 -0
  470. /package/dist/{fit.js → node_modules/@allyhub/image-sdk/dist/fit.js} +0 -0
  471. /package/dist/{messages.js → node_modules/@allyhub/image-sdk/dist/messages.js} +0 -0
  472. /package/dist/{props.js → node_modules/@allyhub/image-sdk/dist/props.js} +0 -0
  473. /package/dist/{text.d.ts → node_modules/@allyhub/image-sdk/dist/text.d.ts} +0 -0
  474. /package/dist/{text.js → node_modules/@allyhub/image-sdk/dist/text.js} +0 -0
  475. /package/dist/{written.d.ts → node_modules/@allyhub/image-sdk/dist/written.d.ts} +0 -0
  476. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/anchors.js +0 -0
  477. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/component.d.ts +0 -0
  478. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.d.ts +0 -0
  479. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/console.js +0 -0
  480. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/contrast.js +0 -0
  481. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/gen.js +0 -0
  482. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/look.js +0 -0
  483. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.d.ts +0 -0
  484. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/marks.js +0 -0
  485. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.d.ts +0 -0
  486. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/matrix.js +0 -0
  487. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/messages.js +0 -0
  488. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/source.js +0 -0
  489. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/voice.js +0 -0
  490. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.d.ts +0 -0
  491. /package/dist/node_modules/@allyhub/{video-core → piece}/dist/words.js +0 -0
  492. /package/dist/{anim.d.ts → node_modules/@allyhub/video-sdk/dist/anim.d.ts} +0 -0
  493. /package/dist/{anim.js → node_modules/@allyhub/video-sdk/dist/anim.js} +0 -0
  494. /package/dist/{noise.d.ts → node_modules/@allyhub/video-sdk/dist/noise.d.ts} +0 -0
  495. /package/dist/{noise.js → node_modules/@allyhub/video-sdk/dist/noise.js} +0 -0
  496. /package/dist/{paths.d.ts → node_modules/@allyhub/video-sdk/dist/paths.d.ts} +0 -0
  497. /package/dist/{paths.js → node_modules/@allyhub/video-sdk/dist/paths.js} +0 -0
@@ -1,36 +1,22 @@
1
- import { type SheetFile, type SheetWorksheet } from "@allyhub/formats";
1
+ import { type SheetFile, type SheetWorksheet, type GeneratedSheets } from "@allyhub/formats";
2
2
  import type { BookEdit } from "./edit.js";
3
3
  /** Where a generated CSV file is named, so it never stands for one on disk. */
4
4
  export declare const GENERATED = "sheet.ts/";
5
- export interface GeneratedSheets {
6
- /** The sheets it makes, in the order it made them, as sheet.yaml would hold them. */
7
- sheets: SheetWorksheet[];
8
- /** Names it defines. */
9
- names?: NonNullable<SheetFile["names"]>;
10
- /** Its tables' and blocks' rows, as CSV text, by the paths its sheets name. */
11
- csv: Record<string, string>;
12
- /** Numbers it typed that neither its data nor its code holds. */
13
- typed?: {
14
- sheet: string;
15
- cell: string;
16
- value: number;
17
- }[];
18
- }
19
5
  export interface MergedFile {
20
6
  file: SheetFile;
21
7
  /** How many of its sheets, the first ones, are sheet.yaml's. */
22
8
  own: number;
23
- /** Names that are sheet.ts's. */
9
+ /** Names that are the code's. */
24
10
  names: ReadonlySet<string>;
25
- /** Sheets sheet.ts makes that sheet.yaml holds: sheet.yaml's stand. */
11
+ /** Sheets the code makes that sheet.yaml holds: sheet.yaml's stand. */
26
12
  ordinary: string[];
27
13
  }
28
- /** sheet.yaml with what sheet.ts makes after it. */
14
+ /** sheet.yaml with what its code makes after it. */
29
15
  export declare function withGenerated(file: SheetFile, generated: GeneratedSheets | undefined): MergedFile;
30
16
  /**
31
17
  * A generated sheet as an ordinary one: its spec in sheet.yaml and its rows in
32
18
  * CSV files of their own, where `taken` says no file stands. From then on
33
- * sheet.yaml holds that name, so what sheet.ts makes of it is left out; taking
19
+ * sheet.yaml holds that name, so what the code makes of it is left out; taking
34
20
  * the sheet out of sheet.yaml gives it back to the code.
35
21
  */
36
22
  export declare function ordinarySheet(book: {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{SHEET_CODE as v,SHEET_DATA as w}from"@allyhub/formats";import{readCsv as d}from"./csv.js";export const GENERATED=`${v}/`;const l=e=>e.toLowerCase();export function withGenerated(e,n){const a=e.sheets.length;if(!n)return{file:e,own:a,names:new Set,ordinary:[]};const m=new Set(e.sheets.map(s=>l(s.name))),t=n.sheets.filter(s=>!m.has(l(s.name))),c=n.sheets.filter(s=>m.has(l(s.name))).map(s=>s.name),f=new Set(Object.keys(e.names??{}).map(l)),r=Object.entries(n.names??{}).filter(([s])=>!f.has(l(s)));return{file:{...e,sheets:[...e.sheets,...t],...r.length===0?{}:{names:{...e.names,...Object.fromEntries(r)}}},own:a,names:new Set(r.map(([s])=>s)),ordinary:c}}const b=e=>[...(e.tables??[]).map(n=>n.rows),...(e.blocks??[]).map(n=>n.rows)],E=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/gu,"");export function ordinarySheet(e,n,a,m=()=>!1){const t=n.sheets.find(o=>l(o.name)===l(a));if(!t)return{rows:new Map,cells:[],whole:!1,refused:"no-sheet"};const c=new Map,f=new Map;for(const o of b(t)){const p=n.csv[o];if(p===void 0)continue;const h=E(`${t.name} ${o.split("/").pop()??""}`).replace(/-csv$/u,"");let u=`${w}/${h}.csv`;for(let i=2;m(u)||c.has(u);i++)u=`${w}/${h}-${String(i)}.csv`;f.set(o,u),c.set(u,d(p).records.map(i=>i.end===i.start?[]:i.fields))}const r=o=>f.get(o)??o,s=structuredClone(t);for(const o of s.tables??[])o.rows=r(o.rows);for(const o of s.blocks??[])o.rows=r(o.rows);return{file:{...e.file,sheets:[...e.file.sheets,s]},rows:c,cells:[],whole:!0}}export function typedNumbers(e,n){const a=[],m=t=>typeof t=="number"?t:t!==null&&typeof t=="object"?t.value:void 0;for(const t of e){for(const[c,f]of Object.entries(t.cells??{})){const r=m(f);typeof r=="number"&&a.push({sheet:t.name,cell:c,value:r})}for(const c of b(t))d(n[c]??"").records.forEach(f=>{for(const r of f.fields){const s=Number(r);r.trim()!==""&&Number.isFinite(s)&&a.push({sheet:t.name,file:c,value:s})}})}return a}
2
+ import"@allyhub/formats";import{readCsv as w}from"@allyhub/formats";import{CODE as b}from"./file.js";export const GENERATED=`${b}/`;const l=e=>e.toLowerCase();export function withGenerated(e,n){const a=e.sheets.length;if(!n)return{file:e,own:a,names:new Set,ordinary:[]};const m=new Set(e.sheets.map(s=>l(s.name))),t=n.sheets.filter(s=>!m.has(l(s.name))),c=n.sheets.filter(s=>m.has(l(s.name))).map(s=>s.name),f=new Set(Object.keys(e.names??{}).map(l)),r=Object.entries(n.names??{}).filter(([s])=>!f.has(l(s)));return{file:{...e,sheets:[...e.sheets,...t],...r.length===0?{}:{names:{...e.names,...Object.fromEntries(r)}}},own:a,names:new Set(r.map(([s])=>s)),ordinary:c}}const d=e=>[...(e.tables??[]).map(n=>n.rows),...(e.blocks??[]).map(n=>n.rows)],v=e=>e.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-|-$/gu,"");export function ordinarySheet(e,n,a,m=()=>!1){const t=n.sheets.find(o=>l(o.name)===l(a));if(!t)return{rows:new Map,cells:[],whole:!1,refused:"no-sheet"};const c=new Map,f=new Map;for(const o of d(t)){const u=n.csv[o];if(u===void 0)continue;const h=v(`${t.name} ${o.split("/").pop()??""}`).replace(/-csv$/u,"");let p=`${h}.csv`;for(let i=2;m(p)||c.has(p);i++)p=`${h}-${String(i)}.csv`;f.set(o,p),c.set(p,w(u).records.map(i=>i.end===i.start?[]:i.fields))}const r=o=>f.get(o)??o,s=structuredClone(t);for(const o of s.tables??[])o.rows=r(o.rows);for(const o of s.blocks??[])o.rows=r(o.rows);return{file:{...e.file,sheets:[...e.file.sheets,s]},rows:c,cells:[],whole:!0}}export function typedNumbers(e,n){const a=[],m=t=>typeof t=="number"?t:t!==null&&typeof t=="object"?t.value:void 0;for(const t of e){for(const[c,f]of Object.entries(t.cells??{})){const r=m(f);typeof r=="number"&&a.push({sheet:t.name,cell:c,value:r})}for(const c of d(t))w(n[c]??"").records.forEach(f=>{for(const r of f.fields){const s=Number(r);r.trim()!==""&&Number.isFinite(s)&&a.push({sheet:t.name,file:c,value:s})}})}return a}
@@ -7,5 +7,7 @@ export interface ImportedSheet {
7
7
  rows: number;
8
8
  }
9
9
  /** A sheet of a file's rows; `name` is what its table and title are called. */
10
- export declare function importRows(name: string, text: string, delimiter: "," | "\t"): ImportedSheet;
10
+ export declare function importRows(name: string, text: string, delimiter: "," | "\t",
11
+ /** Whether a file is beside the sheet's file already, by its path from its folder: the rows take another name. */
12
+ taken?: (path: string) => boolean): ImportedSheet;
11
13
  //# sourceMappingURL=import.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{readCsv as m,writeCsv as c}from"./csv.js";import{validName as p}from"./workbook.js";import{writeYaml as w}from"./write.js";const f=r=>{const e=r.replace(/[^\p{L}\p{N}_]+/gu,"_").replace(/^_+|_+$/gu,"");return p(e)?e:`t_${e||"rows"}`};export function importRows(r,e,n){const t=m(e,n),o=t.problems[0];if(o)throw new Error(`line ${String(o.line)}: ${o.message}`);const s=t.records.map(i=>i.fields);if(s.length===0)throw new Error("the file holds no rows");const a=f(r),l=`data/${a.toLowerCase()}.csv`;return{text:w({title:r,sheets:[{name:"Sheet1",freeze:"A2",tables:[{name:a,at:"A1",rows:l}]}]}),path:l,csv:n===","&&t.dialect.finalNewline?e:c(s),rows:s.length-1}}
2
+ import{readCsv as p,writeCsv as w}from"@allyhub/formats";import{validName as f}from"./workbook.js";import{writeYaml as h}from"./write.js";const g=r=>{const e=r.replace(/[^\p{L}\p{N}_]+/gu,"_").replace(/^_+|_+$/gu,"");return f(e)?e:`t_${e||"rows"}`};export function importRows(r,e,a,c=()=>!1){const s=p(e,a),n=s.problems[0];if(n)throw new Error(`line ${String(n.line)}: ${n.message}`);const l=s.records.map(o=>o.fields);if(l.length===0)throw new Error("the file holds no rows");const i=g(r),m=i.toLowerCase();let t=`${m}.csv`;for(let o=2;c(t);o++)t=`${m}-${String(o)}.csv`;return{text:h({title:r,sheets:[{name:"Sheet1",freeze:"A2",tables:[{name:i,at:"A1",rows:t}]}]}),path:t,csv:a===","&&s.dialect.finalNewline?e:w(l),rows:l.length-1}}
@@ -1,12 +1,12 @@
1
1
  export * from "./address.js";
2
- export { DEFAULT_DIALECT, csvField, csvRecord, csvRows, fromTsv, readCsv, toTsv, writeCsv, type CsvDialect, type CsvProblem, type CsvRecord, type ParsedCsv, } from "./csv.js";
3
2
  export { patchCsv } from "./patch.js";
3
+ export { printedFacts, printedLines, type PrintedFacts } from "./printed.js";
4
4
  export * from "./values.js";
5
5
  export * from "./workbook.js";
6
6
  export * from "./calc/remote.js";
7
7
  export * from "./calc/server.js";
8
- export { dataFilesOf, readSheetFile, type SheetProblem } from "./file.js";
9
- export { GENERATED, ordinarySheet, typedNumbers, withGenerated, type GeneratedSheets, type MergedFile, } from "./generated.js";
8
+ export { CODE as SHEET_CODE, ENTRY as SHEET_ENTRY, codeOf, dataFilesOf, readSheetFile, type SheetProblem, } from "./file.js";
9
+ export { GENERATED, ordinarySheet, typedNumbers, withGenerated, type MergedFile, } from "./generated.js";
10
10
  export { applyScenario, cellOfName, scenarioNames, scenariosByCell, type ScenarioCell, type SheetScenarios, } from "./scenario.js";
11
11
  export { fileCells, hasFiles, isPicture, pictureHeight, pictureSize, type FileCell, } from "./files.js";
12
12
  export * from "./formula/ast.js";
@@ -14,7 +14,7 @@ export { parseFormula } from "./formula/parse.js";
14
14
  export { printFormula, sheetPrefix } from "./formula/print.js";
15
15
  export { moveFormula } from "./formula/move.js";
16
16
  export { rewriteFormula, type StructureEdit } from "./formula/rewrite.js";
17
- export { Calc, seededRandom, type CalcOptions, type CellChange, } from "./calc/engine.js";
17
+ export { Calc, ITERATION_DEFAULTS, seededRandom, type CalcOptions, type CellChange, type Iterated, } from "./calc/engine.js";
18
18
  export { analyse, type Analysis } from "./calc/analyse.js";
19
19
  export { FUNCTIONS } from "./calc/functions/index.js";
20
20
  export { Reference } from "./calc/types.js";
@@ -37,6 +37,6 @@ export { Rules, colorBetween, compareValues, holds, iconShape, type IconShape, t
37
37
  export { choicesIn, invalidCells, joinChoices, listValues, separatorOf, valid, type InvalidCell, } from "./validate.js";
38
38
  export { freeColumn, restructure, tableShape, uniqueColumn, withColumnsUpTo, type BookValues, type RefusedEdit, type Restructured, type TableShape, } from "./structure.js";
39
39
  export { SHEET_CHART_DEFAULTS, chartAfter, chartDataRange, chartDef, chartOfRange, chartPlace, chartSize, chartSvg, readDataRange, type ChartSvgOptions, type NewChart, } from "./chart.js";
40
- export { INSPECT_DEFAULTS, SHEET_FACT_KINDS, inspectWorkbook, type InspectOptions, type SheetFactKind, type SheetFinding, } from "./inspect.js";
40
+ export { INSPECT_DEFAULTS, SHEET_FACT_KINDS, inspectWorkbook, type InspectOptions, type SheetFactData, type SheetFactKind, type SheetFinding, } from "./inspect.js";
41
41
  export { DIFF_DEFAULTS, diffWorkbooks, type CellChange as DiffCell, type DiffKind, type DiffOptions, type DiffSide, type SheetDiff, type TableDiff, type WorkbookDiff, } from "./diff.js";
42
42
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export*from"./address.js";export{DEFAULT_DIALECT,csvField,csvRecord,csvRows,fromTsv,readCsv,toTsv,writeCsv}from"./csv.js";export{patchCsv}from"./patch.js";export*from"./values.js";export*from"./workbook.js";export*from"./calc/remote.js";export*from"./calc/server.js";export{dataFilesOf,readSheetFile}from"./file.js";export{GENERATED,ordinarySheet,typedNumbers,withGenerated}from"./generated.js";export{applyScenario,cellOfName,scenarioNames,scenariosByCell}from"./scenario.js";export{fileCells,hasFiles,isPicture,pictureHeight,pictureSize}from"./files.js";export*from"./formula/ast.js";export{parseFormula}from"./formula/parse.js";export{printFormula,sheetPrefix}from"./formula/print.js";export{moveFormula}from"./formula/move.js";export{rewriteFormula}from"./formula/rewrite.js";export{Calc,seededRandom}from"./calc/engine.js";export{analyse}from"./calc/analyse.js";export{FUNCTIONS}from"./calc/functions/index.js";export{Reference}from"./calc/types.js";export{checkWorkbook,placeName}from"./check.js";export{csvOf,csvText,dataValue,excelNumber,jsonOf,markdownOf,tableRows}from"./export.js";export{generalForms,generalText,isDateCode,shownColor,shownValue}from"./format.js";export{DEFAULT_COLUMN_WIDTH,DEFAULT_ROW_HEIGHT,headerFooterHtml,sheetHtml,SheetPrint}from"./html.js";export{PAPERS,PRINT_DEFAULTS,paginate}from"./paginate.js";export{DEFAULT_TABLE_STYLE,tableStyleLook,tableStyleOf}from"./table-style.js";export{PROFILE_TOP,profileTable}from"./profile.js";export{importRows}from"./import.js";export{patchYaml,writeYaml}from"./write.js";export*from"./edit.js";export*from"./arrange.js";export{NO_LOOK,autoFill,copyLooks,fillDownTo,moveCells,pasteLooks}from"./fill.js";export{seriesAfter}from"./series.js";export{compareForSort,hasHeader,sortCells,sortedOrder,sortedRows}from"./sort.js";export{filterChoices,filteredRows,regionAround}from"./filter.js";export{Rules,colorBetween,compareValues,holds,iconShape}from"./rules.js";export{choicesIn,invalidCells,joinChoices,listValues,separatorOf,valid}from"./validate.js";export{freeColumn,restructure,tableShape,uniqueColumn,withColumnsUpTo}from"./structure.js";export{SHEET_CHART_DEFAULTS,chartAfter,chartDataRange,chartDef,chartOfRange,chartPlace,chartSize,chartSvg,readDataRange}from"./chart.js";export{INSPECT_DEFAULTS,SHEET_FACT_KINDS,inspectWorkbook}from"./inspect.js";export{DIFF_DEFAULTS,diffWorkbooks}from"./diff.js";
2
+ export*from"./address.js";export{patchCsv}from"./patch.js";export{printedFacts,printedLines}from"./printed.js";export*from"./values.js";export*from"./workbook.js";export*from"./calc/remote.js";export*from"./calc/server.js";export{CODE as SHEET_CODE,ENTRY as SHEET_ENTRY,codeOf,dataFilesOf,readSheetFile}from"./file.js";export{GENERATED,ordinarySheet,typedNumbers,withGenerated}from"./generated.js";export{applyScenario,cellOfName,scenarioNames,scenariosByCell}from"./scenario.js";export{fileCells,hasFiles,isPicture,pictureHeight,pictureSize}from"./files.js";export*from"./formula/ast.js";export{parseFormula}from"./formula/parse.js";export{printFormula,sheetPrefix}from"./formula/print.js";export{moveFormula}from"./formula/move.js";export{rewriteFormula}from"./formula/rewrite.js";export{Calc,ITERATION_DEFAULTS,seededRandom}from"./calc/engine.js";export{analyse}from"./calc/analyse.js";export{FUNCTIONS}from"./calc/functions/index.js";export{Reference}from"./calc/types.js";export{checkWorkbook,placeName}from"./check.js";export{csvOf,csvText,dataValue,excelNumber,jsonOf,markdownOf,tableRows}from"./export.js";export{generalForms,generalText,isDateCode,shownColor,shownValue}from"./format.js";export{DEFAULT_COLUMN_WIDTH,DEFAULT_ROW_HEIGHT,headerFooterHtml,sheetHtml,SheetPrint}from"./html.js";export{PAPERS,PRINT_DEFAULTS,paginate}from"./paginate.js";export{DEFAULT_TABLE_STYLE,tableStyleLook,tableStyleOf}from"./table-style.js";export{PROFILE_TOP,profileTable}from"./profile.js";export{importRows}from"./import.js";export{patchYaml,writeYaml}from"./write.js";export*from"./edit.js";export*from"./arrange.js";export{NO_LOOK,autoFill,copyLooks,fillDownTo,moveCells,pasteLooks}from"./fill.js";export{seriesAfter}from"./series.js";export{compareForSort,hasHeader,sortCells,sortedOrder,sortedRows}from"./sort.js";export{filterChoices,filteredRows,regionAround}from"./filter.js";export{Rules,colorBetween,compareValues,holds,iconShape}from"./rules.js";export{choicesIn,invalidCells,joinChoices,listValues,separatorOf,valid}from"./validate.js";export{freeColumn,restructure,tableShape,uniqueColumn,withColumnsUpTo}from"./structure.js";export{SHEET_CHART_DEFAULTS,chartAfter,chartDataRange,chartDef,chartOfRange,chartPlace,chartSize,chartSvg,readDataRange}from"./chart.js";export{INSPECT_DEFAULTS,SHEET_FACT_KINDS,inspectWorkbook}from"./inspect.js";export{DIFF_DEFAULTS,diffWorkbooks}from"./diff.js";
@@ -1,5 +1,90 @@
1
- import type { SheetFactData } from "@allyhub/formats";
2
- import type { Calc } from "./calc/engine.js";
1
+ import { type Calc } from "./calc/engine.js";
2
+ /**
3
+ * What each kind of a workbook's facts measures: `allyhub inspect`'s, never
4
+ * problems. Each kind is the sheet extension's (its manifest's
5
+ * `contributes.facts`, with what it says).
6
+ */
7
+ export interface SheetFactData {
8
+ /** A cell whose value is an error. */
9
+ "sheet-error": {
10
+ sheet: string;
11
+ cell: string;
12
+ code: string;
13
+ formula?: string;
14
+ /** None of what it reads is an error: the error starts here. */
15
+ origin: boolean;
16
+ };
17
+ /** Numbers written into a formula. */
18
+ "sheet-number": {
19
+ sheet: string;
20
+ /** The cell its formula is written for. */
21
+ cell: string;
22
+ /** How many cells hold this formula. */
23
+ cells: number;
24
+ formula: string;
25
+ /** Each number, and the operator or function it is given to. */
26
+ numbers: {
27
+ value: number;
28
+ in: string;
29
+ }[];
30
+ };
31
+ /** A cell between neighbours that agree, unlike them. */
32
+ "sheet-unlike": {
33
+ sheet: string;
34
+ cell: string;
35
+ /** What it holds: its formula, or its value. */
36
+ holds: string;
37
+ /** What the neighbours hold, as the first of them reads. */
38
+ neighbour: string;
39
+ along: "column" | "row";
40
+ /** How many cells together read alike either side. */
41
+ run: number;
42
+ };
43
+ /** A cell of a calculated column set apart from its formula. */
44
+ "sheet-exception": {
45
+ sheet: string;
46
+ table: string;
47
+ column: string;
48
+ cell: string;
49
+ text: string;
50
+ };
51
+ /** An input nothing reads. */
52
+ "sheet-unused": {
53
+ /** A defined name, a typed cell, or a table's column (with --all). */
54
+ what: "name" | "cell" | "column";
55
+ name: string;
56
+ sheet?: string;
57
+ value?: string;
58
+ };
59
+ /** A cell that breaks its data validation. */
60
+ "sheet-invalid": {
61
+ sheet: string;
62
+ cell: string;
63
+ value: string | number | boolean | null;
64
+ rule: string;
65
+ range: string;
66
+ };
67
+ /** A number the sheet's code typed that neither its data nor its code holds: what it computed, where a formula should. */
68
+ "sheet-typed": {
69
+ sheet: string;
70
+ cell: string;
71
+ value: number;
72
+ };
73
+ /** A sheet its code makes and sheet.yaml holds too: sheet.yaml's stands. */
74
+ "sheet-ordinary": {
75
+ sheet: string;
76
+ };
77
+ /** What iterative calculation did with the workbook's circular references. */
78
+ "sheet-iteration": {
79
+ /** Formula cells computed each round: those around a circular reference and what reads them. */
80
+ cells: number;
81
+ iterations: number;
82
+ max_iterations: number;
83
+ /** The most a value moved in the last round; null where one changed kind (a number to an error). */
84
+ change: number | null;
85
+ max_change: number;
86
+ };
87
+ }
3
88
  export type SheetFactKind = keyof SheetFactData;
4
89
  export type SheetFinding = {
5
90
  [K in SheetFactKind]: {
@@ -7,7 +92,7 @@ export type SheetFinding = {
7
92
  data: SheetFactData[K];
8
93
  };
9
94
  }[SheetFactKind];
10
- export declare const SHEET_FACT_KINDS: readonly ["sheet-error", "sheet-number", "sheet-unlike", "sheet-exception", "sheet-unused", "sheet-invalid", "sheet-typed", "sheet-ordinary"];
95
+ export declare const SHEET_FACT_KINDS: readonly ["sheet-error", "sheet-number", "sheet-unlike", "sheet-exception", "sheet-unused", "sheet-invalid", "sheet-typed", "sheet-ordinary", "sheet-iteration"];
11
96
  export interface InspectOptions {
12
97
  /** Numbers a formula may hold and not be said: what any formula has. */
13
98
  plain?: readonly number[];
@@ -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 g}from"./address.js";import"./calc/types.js";import{analyse as y}from"./calc/analyse.js";import{dataValue as S}from"./export.js";import{shownValue as x}from"./format.js";import{relativeKey as _}from"./formula/move.js";import{exceptionsOf as C}from"./edit.js";import{invalidCells as F}from"./validate.js";import{CellError as E}from"./values.js";import{FormulaCell as v}from"./workbook.js";export const SHEET_FACT_KINDS=["sheet-error","sheet-number","sheet-unlike","sheet-exception","sheet-unused","sheet-invalid","sheet-typed","sheet-ordinary"],INSPECT_DEFAULTS={plain:[0,1,-1],around:1};function w(o){const s=new Map;for(const t of o.formulas){const n=s.get(t.shared);n?(n.count+=1,(t.row<n.first.row||t.row===n.first.row&&t.col<n.first.col)&&(n.first=t)):s.set(t.shared,{shared:t.shared,first:t,count:1})}return[...s.values()].sort((t,n)=>t.first.row-n.first.row||t.first.col-n.first.col)}function k(o,s,t){switch(o.kind){case"number":t.push({value:o.value,in:s});return;case"unary":o.op==="-"&&o.arg.kind==="number"?t.push({value:-o.arg.value,in:s}):k(o.arg,o.op,t);return;case"postfix":k(o.arg,o.op,t);return;case"paren":k(o.arg,s,t);return;case"binary":k(o.left,o.op,t),k(o.right,o.op,t);return;case"array":for(const n of o.rows)for(const l of n)k(l,"{}",t);return;case"call":for(const n of o.args)k(n,o.name,t);return;case"invoke":k(o.callee,s,t);for(const n of o.args)k(n,"LAMBDA",t);return;default:return}}function N(o,s){const t={error:!1};for(const n of o.precedents(s))if(o.each(n,l=>{l instanceof E&&(t.error=!0)}),t.error)return!1;return!0}const b=new WeakMap;function A(o){const s=b.get(o);if(s!==void 0)return s;const t=o.node?_(o.node,o.row,o.col):o.text;return b.set(o,t),t}const I=(o,s)=>o instanceof v?o.text:x(o,s);function M(o,s,t){const n=[],l=(r,e)=>{if(r<0||e<0)return;const u=o.at(r,e);return u instanceof v?A(u.shared):void 0},c=(r,e,u,i)=>{const f=u==="column"?1:0,a=u==="row"?1:0,h=o.at(r,e);if(h===void 0||h instanceof v&&A(h.shared)===i)return;for(let d=1;d<=s;d++)if(l(r-f*d,e-a*d)!==i||l(r+f*d,e+a*d)!==i)return;if(t.has(r*16384+e))return;let m=s*2;for(let d=s+1;l(r-f*d,e-a*d)===i;d++)m+=1;for(let d=s+1;l(r+f*d,e+a*d)===i;d++)m+=1;const p=o.at(r-f,e-a);n.push({sheet:o.name,cell:g({row:r,col:e}),holds:I(h,o.lookAt(r,e).format),neighbour:p instanceof v?p.text:"",along:u,run:m})};for(const r of o.formulas){const e=A(r.shared);c(r.row+1,r.col,"column",e),c(r.row,r.col+1,"row",e)}return n.sort((r,e)=>T(r.cell,e.cell))}const T=(o,s)=>o.length-s.length||o.localeCompare(s,"en",{numeric:!0});function R(o,s){const t=[],n=(c,r)=>{c&&t.push(...o.readsOfFormula(c,r))};for(const c of s.sheets){for(const r of c.conditions)for(const e of r.formulas)n(e,c);for(const r of c.validations)for(const e of r.formulas)n(e,c);for(const r of c.charts){n(r.title,c),n(r.categories,c);for(const e of r.series)n(e.values,c),n(e.x,c),n(e.name,c)}}const l=s.sheets[0];if(l){for(const c of s.checks)n(c.formula,l);for(const c of s.names.values())n(c.formula,l)}return t}function D(o){const s=new Set,t=n=>{if(n)for(const l of y(o,n).names)s.add(l)};for(const n of o.sheets){for(const{shared:l}of w(n))t(l);for(const l of n.conditions)l.formulas.forEach(t);for(const l of n.validations)l.formulas.forEach(t);for(const l of n.charts){t(l.title),t(l.categories);for(const c of l.series)t(c.values),t(c.x),t(c.name)}}for(const n of o.checks)t(n.formula);return s}function K(o,s,t){const n=[],l=D(s);for(const e of s.names.values())l.has(e.name.toLowerCase())||n.push({what:"name",name:e.name,value:e.formula?.text??x(e.value??null)});const c=R(o,s),r=(e,u,i)=>c.some(f=>f.sheet===e&&u>=f.top&&u<=f.bottom&&i>=f.left&&i<=f.right)||o.readers(e,u,i).length>0;for(const e of s.sheets){for(let u=0;u<e.columnsUsed;u++){const[i,f]=e.span(u,0,Number.MAX_SAFE_INTEGER);for(let a=i;a<=f;a++){const h=e.at(a,u);typeof h=="number"&&(e.tableAt(a,u)||e.blockAt(a,u)||r(e,a,u)||n.push({what:"cell",sheet:e.name,name:g({row:a,col:u}),value:x(h,e.lookAt(a,u).format)}))}}if(t)for(const u of e.tables)for(const i of u.columns){const f=u.at.col+i.index,{top:a,bottom:h}=u.data;let m=!1;for(let p=a;p<=h&&!m;p++)m=r(e,p,f);m||n.push({what:"column",sheet:e.name,name:`${u.name}[${i.name}]`})}}return n}export function inspectWorkbook(o,s={}){const{wb:t}=o,n=new Set(s.plain??INSPECT_DEFAULTS.plain),l=Math.max(1,s.around??INSPECT_DEFAULTS.around),c=s.all===!0,r=[];for(const e of t.sheets){const u=[...e.formulas].sort((f,a)=>f.row-a.row||f.col-a.col);for(const f of u){const{value:a}=f;a instanceof E&&r.push({kind:"sheet-error",data:{sheet:e.name,cell:g(f),code:a.code,formula:f.text,origin:N(o,f)}})}for(let f=0;f<e.columnsUsed;f++){const[a,h]=e.span(f,0,Number.MAX_SAFE_INTEGER);for(let m=a;m<=h;m++){const p=e.at(m,f);p instanceof E&&r.push({kind:"sheet-error",data:{sheet:e.name,cell:g({row:m,col:f}),code:p.code,origin:!0}})}}for(const{shared:f,first:a,count:h}of w(e)){if(!f.node)continue;const m=[];k(f.node,"=",m);const p=c?m:m.filter(d=>!n.has(d.value));p.length>0&&r.push({kind:"sheet-number",data:{sheet:e.name,cell:g(a),cells:h,formula:a.text,numbers:p}})}const i=new Set;for(const f of e.tables)for(const a of C(f))i.add(a.row*16384+a.col),r.push({kind:"sheet-exception",data:{sheet:e.name,table:f.name,column:a.column,cell:g(a),text:a.text}});for(const f of M(e,l,i))r.push({kind:"sheet-unlike",data:f})}for(const e of K(o,t,c))r.push({kind:"sheet-unused",data:e});for(const e of F(t,o))r.push({kind:"sheet-invalid",data:{sheet:e.sheet,cell:g(e),value:S(e.value,void 0),rule:e.type,range:e.range}});for(const e of t.generated?.typed??[])t.sheet(e.sheet)?.generated===!0&&r.push({kind:"sheet-typed",data:e});for(const e of t.ordinary)r.push({kind:"sheet-ordinary",data:{sheet:e}});return r}
2
+ import{cellName as k}from"./address.js";import"./calc/types.js";import{analyse as F}from"./calc/analyse.js";import{ITERATION_DEFAULTS as b}from"./calc/engine.js";import{dataValue as N}from"./export.js";import{shownValue as E}from"./format.js";import{relativeKey as T}from"./formula/move.js";import{exceptionsOf as C}from"./edit.js";import{invalidCells as I}from"./validate.js";import{CellError as _}from"./values.js";import{FormulaCell as v}from"./workbook.js";export const SHEET_FACT_KINDS=["sheet-error","sheet-number","sheet-unlike","sheet-exception","sheet-unused","sheet-invalid","sheet-typed","sheet-ordinary","sheet-iteration"],INSPECT_DEFAULTS={plain:[0,1,-1],around:1};function w(e){const a=new Map;for(const t of e.formulas){const n=a.get(t.shared);n?(n.count+=1,(t.row<n.first.row||t.row===n.first.row&&t.col<n.first.col)&&(n.first=t)):a.set(t.shared,{shared:t.shared,first:t,count:1})}return[...a.values()].sort((t,n)=>t.first.row-n.first.row||t.first.col-n.first.col)}function g(e,a,t){switch(e.kind){case"number":t.push({value:e.value,in:a});return;case"unary":e.op==="-"&&e.arg.kind==="number"?t.push({value:-e.arg.value,in:a}):g(e.arg,e.op,t);return;case"postfix":g(e.arg,e.op,t);return;case"paren":g(e.arg,a,t);return;case"binary":g(e.left,e.op,t),g(e.right,e.op,t);return;case"array":for(const n of e.rows)for(const l of n)g(l,"{}",t);return;case"call":for(const n of e.args)g(n,e.name,t);return;case"invoke":g(e.callee,a,t);for(const n of e.args)g(n,"LAMBDA",t);return;default:return}}function M(e,a){const t={error:!1};for(const n of e.precedents(a))if(e.each(n,l=>{l instanceof _&&(t.error=!0)}),t.error)return!1;return!0}const y=new WeakMap;function A(e){const a=y.get(e);if(a!==void 0)return a;const t=e.node?T(e.node,e.row,e.col):e.text;return y.set(e,t),t}const R=(e,a)=>e instanceof v?e.text:E(e,a);function D(e,a,t){const n=[],l=(r,o)=>{if(r<0||o<0)return;const i=e.at(r,o);return i instanceof v?A(i.shared):void 0},c=(r,o,i,s)=>{const h=i==="column"?1:0,d=i==="row"?1:0,f=e.at(r,o);if(f===void 0||f instanceof v&&A(f.shared)===s)return;for(let m=1;m<=a;m++)if(l(r-h*m,o-d*m)!==s||l(r+h*m,o+d*m)!==s)return;if(t.has(r*16384+o))return;let u=a*2;for(let m=a+1;l(r-h*m,o-d*m)===s;m++)u+=1;for(let m=a+1;l(r+h*m,o+d*m)===s;m++)u+=1;const p=e.at(r-h,o-d);n.push({sheet:e.name,cell:k({row:r,col:o}),holds:R(f,e.lookAt(r,o).format),neighbour:p instanceof v?p.text:"",along:i,run:u})};for(const r of e.formulas){const o=A(r.shared);c(r.row+1,r.col,"column",o),c(r.row,r.col+1,"row",o)}return n.sort((r,o)=>L(r.cell,o.cell))}const L=(e,a)=>e.length-a.length||e.localeCompare(a,"en",{numeric:!0});function U(e,a){const t=[],n=(c,r)=>{c&&t.push(...e.readsOfFormula(c,r))};for(const c of a.sheets){for(const r of c.conditions)for(const o of r.formulas)n(o,c);for(const r of c.validations)for(const o of r.formulas)n(o,c);for(const r of c.charts){n(r.title,c),n(r.categories,c);for(const o of r.series)n(o.values,c),n(o.x,c),n(o.name,c)}}const l=a.sheets[0];if(l){for(const c of a.checks)n(c.formula,l);for(const c of a.names.values())n(c.formula,l)}return t}function K(e){const a=new Set,t=n=>{if(n)for(const l of F(e,n).names)a.add(l)};for(const n of e.sheets){for(const{shared:l}of w(n))t(l);for(const l of n.conditions)l.formulas.forEach(t);for(const l of n.validations)l.formulas.forEach(t);for(const l of n.charts){t(l.title),t(l.categories);for(const c of l.series)t(c.values),t(c.x),t(c.name)}}for(const n of e.checks)t(n.formula);return a}function O(e,a,t){const n=[],l=K(a);for(const o of a.names.values())l.has(o.name.toLowerCase())||n.push({what:"name",name:o.name,value:o.formula?.text??E(o.value??null)});const c=U(e,a),r=(o,i,s)=>c.some(h=>h.sheet===o&&i>=h.top&&i<=h.bottom&&s>=h.left&&s<=h.right)||e.readers(o,i,s).length>0;for(const o of a.sheets){for(let i=0;i<o.columnsUsed;i++){const[s,h]=o.span(i,0,Number.MAX_SAFE_INTEGER);for(let d=s;d<=h;d++){const f=o.at(d,i);typeof f=="number"&&(o.tableAt(d,i)||o.blockAt(d,i)||r(o,d,i)||n.push({what:"cell",sheet:o.name,name:k({row:d,col:i}),value:E(f,o.lookAt(d,i).format)}))}}if(t)for(const i of o.tables)for(const s of i.columns){const h=i.at.col+s.index,{top:d,bottom:f}=i.data;let u=!1;for(let p=d;p<=f&&!u;p++)u=r(o,p,h);u||n.push({what:"column",sheet:o.name,name:`${i.name}[${s.name}]`})}}return n}export function inspectWorkbook(e,a={}){const{wb:t}=e,n=new Set(a.plain??INSPECT_DEFAULTS.plain),l=Math.max(1,a.around??INSPECT_DEFAULTS.around),c=a.all===!0,r=[];for(const s of t.sheets){const h=[...s.formulas].sort((f,u)=>f.row-u.row||f.col-u.col);for(const f of h){const{value:u}=f;u instanceof _&&r.push({kind:"sheet-error",data:{sheet:s.name,cell:k(f),code:u.code,formula:f.text,origin:M(e,f)}})}for(let f=0;f<s.columnsUsed;f++){const[u,p]=s.span(f,0,Number.MAX_SAFE_INTEGER);for(let m=u;m<=p;m++){const x=s.at(m,f);x instanceof _&&r.push({kind:"sheet-error",data:{sheet:s.name,cell:k({row:m,col:f}),code:x.code,origin:!0}})}}for(const{shared:f,first:u,count:p}of w(s)){if(!f.node)continue;const m=[];g(f.node,"=",m);const x=c?m:m.filter(S=>!n.has(S.value));x.length>0&&r.push({kind:"sheet-number",data:{sheet:s.name,cell:k(u),cells:p,formula:u.text,numbers:x}})}const d=new Set;for(const f of s.tables)for(const u of C(f))d.add(u.row*16384+u.col),r.push({kind:"sheet-exception",data:{sheet:s.name,table:f.name,column:u.column,cell:k(u),text:u.text}});for(const f of D(s,l,d))r.push({kind:"sheet-unlike",data:f})}for(const s of O(e,t,c))r.push({kind:"sheet-unused",data:s});for(const s of I(t,e))r.push({kind:"sheet-invalid",data:{sheet:s.sheet,cell:k(s),value:N(s.value,void 0),rule:s.type,range:s.range}});for(const s of t.generated?.typed??[])t.sheet(s.sheet)?.generated===!0&&r.push({kind:"sheet-typed",data:s});for(const s of t.ordinary)r.push({kind:"sheet-ordinary",data:{sheet:s}});const{iterated:o}=e,{iteration:i}=t.file;if(o&&i!==void 0){const s=i===!0?{}:i;r.push({kind:"sheet-iteration",data:{cells:o.cells,iterations:o.iterations,max_iterations:s.max_iterations??b.max_iterations,change:Number.isFinite(o.change)?o.change:null,max_change:s.max_change??b.max_change}})}return r}
@@ -1,4 +1,4 @@
1
- import { type ParsedCsv } from "./csv.js";
1
+ import { type ParsedCsv } from "@allyhub/formats";
2
2
  /** The file `csv` was read from, written again with `rows`, its first the header. */
3
3
  export declare function patchCsv(csv: ParsedCsv, rows: readonly (readonly string[])[]): string;
4
4
  //# sourceMappingURL=patch.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{csvRecord as y}from"./csv.js";const k=(c,t)=>{if(c.length===0)return"";const n=[];for(let o=0;o<t;o++)n.push(c[o]??"");return n.join("\0")},b=(c,t)=>k(c.end===c.start?[]:c.fields,t);export function patchCsv(c,t){const{dialect:n,records:o,source:u}=c,a=t.reduce((e,l)=>Math.max(e,l.length),0);if(t.length===0)return n.bom?"\uFEFF":"";const g=new Map;for(const e of o)g.set(e.fields,e);const h=new Set,i=new Array(t.length);t.forEach((e,l)=>{const s=g.get(e);s&&!h.has(s)&&(h.add(s),i[l]=u.slice(s.start,s.end))});let r;t.forEach((e,l)=>{if(i[l]!==void 0)return;if(!r){r=new Map;for(const f of o){if(h.has(f)||f.fields.length>a)continue;const m=b(f,a),p=r.get(m);p?p.push(f):r.set(m,[f])}}const s=r.get(k(e,a))?.shift();if(s){i[l]=u.slice(s.start,s.end);return}const d=[...e];for(;d.length<a;)d.push("");i[l]=e.length===0?"":y(d,n.delimiter)});const w=n.finalNewline||i[i.length-1]==="";return`${n.bom?"\uFEFF":""}${i.join(n.newline)}${w?n.newline:""}`}
2
+ import{csvRecord as y}from"@allyhub/formats";const k=(c,t)=>{if(c.length===0)return"";const n=[];for(let o=0;o<t;o++)n.push(c[o]??"");return n.join("\0")},b=(c,t)=>k(c.end===c.start?[]:c.fields,t);export function patchCsv(c,t){const{dialect:n,records:o,source:u}=c,a=t.reduce((e,l)=>Math.max(e,l.length),0);if(t.length===0)return n.bom?"\uFEFF":"";const g=new Map;for(const e of o)g.set(e.fields,e);const h=new Set,i=new Array(t.length);t.forEach((e,l)=>{const s=g.get(e);s&&!h.has(s)&&(h.add(s),i[l]=u.slice(s.start,s.end))});let r;t.forEach((e,l)=>{if(i[l]!==void 0)return;if(!r){r=new Map;for(const f of o){if(h.has(f)||f.fields.length>a)continue;const m=b(f,a),p=r.get(m);p?p.push(f):r.set(m,[f])}}const s=r.get(k(e,a))?.shift();if(s){i[l]=u.slice(s.start,s.end);return}const d=[...e];for(;d.length<a;)d.push("");i[l]=e.length===0?"":y(d,n.delimiter)});const w=n.finalNewline||i[i.length-1]==="";return`${n.bom?"\uFEFF":""}${i.join(n.newline)}${w?n.newline:""}`}
@@ -0,0 +1,19 @@
1
+ import type { Calc } from "./calc/engine.js";
2
+ export interface PrintedFacts {
3
+ sheet: string;
4
+ /** Pages across and down, and the scale it prints at (1 is 100%). */
5
+ across: number;
6
+ down: number;
7
+ scale: number;
8
+ /** Cells whose text its column, and the empty cells after it, cannot hold. */
9
+ cut: string[];
10
+ /** Cells whose number is wider than its column: Excel shows ####. */
11
+ hashed: string[];
12
+ /** Cells holding a number of 1,000 or more with no number format. */
13
+ unformatted: string[];
14
+ }
15
+ /** Each printed sheet's facts. */
16
+ export declare function printedFacts(calc: Calc): PrintedFacts[];
17
+ /** A render's lines on how a workbook prints and shows: every sheet's pages, then what its columns cut, show as #### or leave unformatted. */
18
+ export declare function printedLines(file: string, calc: Calc): string[];
19
+ //# sourceMappingURL=printed.d.ts.map
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{cellName as x}from"./address.js";import{shownValue as A}from"./format.js";import{paginate as j}from"./paginate.js";const y=7,D=5,S=11,E=1e3,d=6,b=(n,r)=>Math.max(0,(n-D)/y)*(S/r);export function printedFacts(n){return j(n).sheets.map(e=>{const{sheet:o}=e,t={sheet:o.name,across:e.across.length,down:e.down.length,scale:e.scale,cut:[],hashed:[],unformatted:[]},i=new Map(e.cols.map((s,u)=>[s,e.widths[u]??0]));for(const s of e.rows)for(const[u,h]of e.cols.entries()){const a=n.value(o,s,h);if(a===null||a===""||o.mergeAt(s,h)!==void 0)continue;const c=o.lookAt(s,h),l=x({row:s,col:h});if(typeof a=="number"&&Math.abs(a)>=E&&(c.format===void 0||c.format==="General")&&t.unformatted.push(l),c.wrap===!0||c.shrink===!0)continue;const $=Array.from(A(a,c.format)).length,w=c.size??S;if(typeof a=="number"){$>b(i.get(h)??0,w)&&t.hashed.push(l);continue}let g=i.get(h)??0;for(let m=u+1;m<e.cols.length;m++){const p=e.cols[m]??0;if(!M(n,o,s,p))break;g+=i.get(p)??0}$>b(g,w)&&t.cut.push(l)}return t})}const M=(n,r,e,o)=>{const t=n.value(r,e,o);return t===null||t===""},f=n=>n.length<=d?n.join(", "):`${n.slice(0,d).join(", ")} and ${String(n.length-d)} more`;export function printedLines(n,r){const e=printedFacts(r),o=[`${n}: as it prints, ${e.map(t=>`${t.sheet} ${String(t.across*t.down)} page${t.across*t.down===1?"":"s"} (${String(t.across)} across, ${String(t.down)} down, at ${String(Math.round(t.scale*100))}%)`).join("; ")}.`];for(const t of e)t.cut.length>0&&o.push(`${n}: ${t.sheet}: ${String(t.cut.length)} cell${t.cut.length===1?"'s":"s'"} text longer than its column and the empty cells after it hold, cut where the next cell starts: ${f(t.cut)}.`),t.hashed.length>0&&o.push(`${n}: ${t.sheet}: ${String(t.hashed.length)} number${t.hashed.length===1?"":"s"} wider than its column, which Excel shows as ####: ${f(t.hashed)}.`),t.unformatted.length>0&&o.push(`${n}: ${t.sheet}: ${String(t.unformatted.length)} number${t.unformatted.length===1?"":"s"} of 1,000 or more with no number format, shown as Excel's General shows them, with no separators (as a year is written): ${f(t.unformatted)}.`);return o}
@@ -0,0 +1,2 @@
1
+ export { Alignment, AreaChart, AutoFilter, BLOCK_CELLS, BarChart, Comment, Image, PageMargins, PageSetup, Border, CAPABILITIES, Cell, CellIsRule, ChartBase, Color, ColorScaleRule, ColumnDimension, ConditionalFormattingList, DataBarRule, DataLabelList, DataValidation, DataValidationList, DefinedName, DefinedNameDict, DifferentialStyle, DoughnutChart, Font, FormulaRule, GraphicalProperties, IconSetRule, Legend, LineChart, LineProperties, Marker, NumericAxis, PatternFill, PieChart, Reference, RowDimension, Rule, Scaling, ScatterChart, Series, Side, Table, TableList, TextAxis, Workbook, Worksheet, column_index_from_string, coordinate_to_tuple, get_column_letter, load_workbook, range_boundaries, workbook, type AlignmentOptions, type BarChartOptions, type BorderOptions, type CellIsRuleOptions, type CellValue, type SheetCodeBuild, type SheetCodeContext, type ChartData, type ColorScaleRuleOptions, type DataBarRuleOptions, type DataValidationOptions, type DifferentialStyleOptions, type FontOptions, type FormulaRuleOptions, type LoadOptions, type PatternFillOptions, type ReferenceOptions, type RuleOptions, type SeriesOptions, type SideOptions, type TableInput, type TableOptions, } from "./api/index.js";
2
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ export{Alignment,AreaChart,AutoFilter,BLOCK_CELLS,BarChart,Comment,Image,PageMargins,PageSetup,Border,CAPABILITIES,Cell,CellIsRule,ChartBase,Color,ColorScaleRule,ColumnDimension,ConditionalFormattingList,DataBarRule,DataLabelList,DataValidation,DataValidationList,DefinedName,DefinedNameDict,DifferentialStyle,DoughnutChart,Font,FormulaRule,GraphicalProperties,IconSetRule,Legend,LineChart,LineProperties,Marker,NumericAxis,PatternFill,PieChart,Reference,RowDimension,Rule,Scaling,ScatterChart,Series,Side,Table,TableList,TextAxis,Workbook,Worksheet,column_index_from_string,coordinate_to_tuple,get_column_letter,load_workbook,range_boundaries,workbook}from"./api/index.js";
@@ -55,6 +55,8 @@ export interface Typed {
55
55
  /** The formula's text, the = included, when it is one. */
56
56
  formula?: string;
57
57
  format?: string;
58
+ /** What a formula's cell holds before it is computed: where iterative calculation starts. */
59
+ start?: Scalar;
58
60
  }
59
61
  /**
60
62
  * Text as Excel reads what is typed: a number (a percent, grouped thousands
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export class CellError{static all=new Map;code;constructor(t){this.code=t}static of(t){let n=CellError.all.get(t);return n||(n=new CellError(t),CellError.all.set(t,n)),n}toString(){return this.code}toJSON(){return this.code}}export const ERR={NULL:CellError.of("#NULL!"),DIV0:CellError.of("#DIV/0!"),VALUE:CellError.of("#VALUE!"),REF:CellError.of("#REF!"),NAME:CellError.of("#NAME?"),NUM:CellError.of("#NUM!"),NA:CellError.of("#N/A"),SPILL:CellError.of("#SPILL!"),CALC:CellError.of("#CALC!"),CYCLE:CellError.of("#CYCLE!")};const $=["#NULL!","#DIV/0!","#VALUE!","#REF!","#NAME?","#NUM!","#N/A","#GETTING_DATA","#SPILL!","#CALC!","#CYCLE!"];export function errorOf(e){const t=e.toUpperCase(),n=$.find(r=>r===t);return n===void 0?void 0:CellError.of(n)}export class Matrix{rows;cols;data;constructor(t,n,r){this.rows=t,this.cols=n,this.data=r}at(t,n){return this.data[t*this.cols+n]??null}}const i=864e5,p=25569;function y(e){const t=e+p;return t<61?t-1:t}function M(e){const t=Math.floor(e);if(t!==60)return(t<60?t+1:t)-p}export function serialOf(e,t,n){const r=new Date(Date.UTC(2e3,t-1,1));return r.setUTCFullYear(r.getUTCFullYear()-2e3+e),y(Math.floor(r.getTime()/i))+n-1}export function dateOf(e){const t=M(e);if(t===void 0)return{year:1900,month:2,day:29};if(Math.floor(e)===0)return{year:1900,month:1,day:0};const n=new Date(t*i);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate()}}export function serialOfDate(e){const t=e.getTime(),n=Math.floor(t/i);return y(n)+(t-n*i)/i}export function dateOfSerial(e){const t=M(e);if(t===void 0)return;const n=e-Math.floor(e);return new Date(t*i+Math.round(n*i))}const a=(e,t=2)=>String(e).padStart(t,"0");export function isoOfSerial(e){const{year:t,month:n,day:r}=dateOf(e),s=`${a(t,4)}-${a(n)}-${a(r)}`,o=Math.round((e-Math.floor(e))*86400);if(o===0)return s;const u=o%60;return`${s}T${a(Math.floor(o/3600))}:${a(Math.floor(o/60)%60)}${u===0?"":`:${a(u)}`}`}export function numberText(e){if(e===0)return"0";const t=Number(e.toPrecision(15)),n=Math.floor(Math.log10(Math.abs(t)));if(n>=15||n<-10){const[s="",o="0"]=t.toExponential().split("e"),u=Number(o);return`${s}E${u<0?"-":"+"}${a(Math.abs(u))}`}const r=String(t);return r.includes("e")?t.toFixed(Math.min(20,Math.abs(n)+15)).replace(/0+$/u,""):r}const N=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u,E=/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d+)?$/u,L=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,b=e=>/^[+-]?\d+$/u.test(e)&&e.replace(/^[+-]?0*/u,"").length>15;function A(e){const t=L.exec(e);if(!t)return;const[n,r,s]=[Number(t[1]),Number(t[2]),Number(t[3])],o=serialOf(n,r,s),u=dateOf(o);if(u.month!==r||u.day!==s)return;if(t[4]===void 0)return{value:o,format:"yyyy-mm-dd"};const[f,d,m]=[Number(t[4]),Number(t[5]),Number(t[6]??0)];if(f>23||d>59||m>59)return;const c=t[7];let h=0;if(c!==void 0&&c!=="Z"){const l=c.replace(":","");h=(l.startsWith("-")?1:-1)*(Number(l.slice(1,3))*60+Number(l.slice(3,5)))/1440}return{value:o+(f*3600+d*60+m)/86400+h,format:t[6]===void 0?"yyyy-mm-dd hh:mm":"yyyy-mm-dd hh:mm:ss"}}function U(e){const t=/^(\d{1,4}):([0-5]?\d)(?::([0-5]?\d))?(?:\s*([AaPp])[Mm]?)?$/u.exec(e)??/^(\d{1,2})()()\s*([AaPp])[Mm]?$/u.exec(e);if(!t)return;const n=Number(t[1]),r=t[2]===void 0||t[2]===""?0:Number(t[2]),s=t[3]===void 0||t[3]===""?0:Number(t[3]),o=t[4]?.toUpperCase();if(o!==void 0)return n<1||n>12?void 0:{value:((n%12+(o==="P"?12:0))*3600+r*60+s)/86400,format:t[3]?"h:mm:ss AM/PM":"h:mm AM/PM"};const u=(n*3600+r*60+s)/86400;return n>=24?{value:u,format:"[h]:mm:ss"}:{value:u,format:t[3]?"h:mm:ss":"h:mm"}}export function readTyped(e){if(e==="")return{value:null};if(e.startsWith("'"))return{value:e.slice(1)};if(e.length>1&&e.startsWith("="))return{value:null,formula:e};const t=e.trim();if(t==="")return{value:e};const n=t.toUpperCase();if(n==="TRUE")return{value:!0};if(n==="FALSE")return{value:!1};if(N.test(t))return b(t)?{value:e}:{value:Number(t)};if(t.endsWith("%")){const d=t.slice(0,-1).trim();if(N.test(d))return{value:Number(d)/100,format:d.includes(".")?"0.00%":"0%"}}if(E.test(t))return{value:Number(t.replaceAll(",","")),format:t.includes(".")?"#,##0.00":"#,##0"};const r=/^([+-]?)\$(\d[\d,]*(?:\.\d+)?)$/u.exec(t),s=r?.[2]?.replaceAll(",","");if(r&&s!==void 0)return{value:+`${r[1]??""}${s}`,format:t.includes(".")?"$#,##0.00":"$#,##0"};const o=A(t);if(o)return o;const u=U(t);if(u)return u;const f=errorOf(t);return f?{value:f}:{value:e}}export function writeTyped(e){if(e===null)return"";if(typeof e=="number"){const n=String(e);return b(n)?e.toExponential():n}if(typeof e=="boolean")return e?"TRUE":"FALSE";if(e instanceof CellError)return e.code;const t=readTyped(e);return t.value===e&&t.formula===void 0?e:`'${e}`}
2
+ export class CellError{static all=new Map;code;constructor(t){this.code=t}static of(t){let n=CellError.all.get(t);return n||(n=new CellError(t),CellError.all.set(t,n)),n}toString(){return this.code}toJSON(){return this.code}}export const ERR={NULL:CellError.of("#NULL!"),DIV0:CellError.of("#DIV/0!"),VALUE:CellError.of("#VALUE!"),REF:CellError.of("#REF!"),NAME:CellError.of("#NAME?"),NUM:CellError.of("#NUM!"),NA:CellError.of("#N/A"),SPILL:CellError.of("#SPILL!"),CALC:CellError.of("#CALC!"),CYCLE:CellError.of("#CYCLE!")};const $=["#NULL!","#DIV/0!","#VALUE!","#REF!","#NAME?","#NUM!","#N/A","#GETTING_DATA","#SPILL!","#CALC!","#CYCLE!"];export function errorOf(e){const t=e.toUpperCase(),n=$.find(r=>r===t);return n===void 0?void 0:CellError.of(n)}export class Matrix{rows;cols;data;constructor(t,n,r){this.rows=t,this.cols=n,this.data=r}at(t,n){return this.data[t*this.cols+n]??null}}const c=864e5,p=25569;function M(e){const t=e+p;return t<61?t-1:t}function y(e){const t=Math.floor(e);if(t!==60)return(t<60?t+1:t)-p}export function serialOf(e,t,n){const r=new Date(Date.UTC(2e3,t-1,1));return r.setUTCFullYear(r.getUTCFullYear()-2e3+e),M(Math.floor(r.getTime()/c))+n-1}export function dateOf(e){const t=y(e);return t===void 0?{year:1900,month:2,day:29}:Math.floor(e)===0?{year:1900,month:1,day:0}:E(t)}function E(e){const t=e+719468,n=Math.floor(t/146097),r=t-n*146097,u=Math.floor((r-Math.floor(r/1460)+Math.floor(r/36524)-Math.floor(r/146096))/365),o=r-(365*u+Math.floor(u/4)-Math.floor(u/100)),s=Math.floor((5*o+2)/153),f=o-Math.floor((153*s+2)/5)+1,i=s<10?s+3:s-9;return{year:u+n*400+(i<=2?1:0),month:i,day:f}}export function serialOfDate(e){const t=e.getTime(),n=Math.floor(t/c);return M(n)+(t-n*c)/c}export function dateOfSerial(e){const t=y(e);if(t===void 0)return;const n=e-Math.floor(e);return new Date(t*c+Math.round(n*c))}const a=(e,t=2)=>String(e).padStart(t,"0");export function isoOfSerial(e){const{year:t,month:n,day:r}=dateOf(e),u=`${a(t,4)}-${a(n)}-${a(r)}`,o=Math.round((e-Math.floor(e))*86400);if(o===0)return u;const s=o%60;return`${u}T${a(Math.floor(o/3600))}:${a(Math.floor(o/60)%60)}${s===0?"":`:${a(s)}`}`}export function numberText(e){if(e===0)return"0";const t=Number(e.toPrecision(15)),n=Math.floor(Math.log10(Math.abs(t)));if(n>=15||n<-10){const[u="",o="0"]=t.toExponential().split("e"),s=Number(o);return`${u}E${s<0?"-":"+"}${a(Math.abs(s))}`}const r=String(t);return r.includes("e")?t.toFixed(Math.min(20,Math.abs(n)+15)).replace(/0+$/u,""):r}const N=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/u,L=/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d+)?$/u,A=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/u,b=e=>/^[+-]?\d+$/u.test(e)&&e.replace(/^[+-]?0*/u,"").length>15;function U(e){const t=A.exec(e);if(!t)return;const[n,r,u]=[Number(t[1]),Number(t[2]),Number(t[3])],o=serialOf(n,r,u),s=dateOf(o);if(s.month!==r||s.day!==u)return;if(t[4]===void 0)return{value:o,format:"yyyy-mm-dd"};const[f,i,m]=[Number(t[4]),Number(t[5]),Number(t[6]??0)];if(f>23||i>59||m>59)return;const d=t[7];let h=0;if(d!==void 0&&d!=="Z"){const l=d.replace(":","");h=(l.startsWith("-")?1:-1)*(Number(l.slice(1,3))*60+Number(l.slice(3,5)))/1440}return{value:o+(f*3600+i*60+m)/86400+h,format:t[6]===void 0?"yyyy-mm-dd hh:mm":"yyyy-mm-dd hh:mm:ss"}}function C(e){const t=/^(\d{1,4}):([0-5]?\d)(?::([0-5]?\d))?(?:\s*([AaPp])[Mm]?)?$/u.exec(e)??/^(\d{1,2})()()\s*([AaPp])[Mm]?$/u.exec(e);if(!t)return;const n=Number(t[1]),r=t[2]===void 0||t[2]===""?0:Number(t[2]),u=t[3]===void 0||t[3]===""?0:Number(t[3]),o=t[4]?.toUpperCase();if(o!==void 0)return n<1||n>12?void 0:{value:((n%12+(o==="P"?12:0))*3600+r*60+u)/86400,format:t[3]?"h:mm:ss AM/PM":"h:mm AM/PM"};const s=(n*3600+r*60+u)/86400;return n>=24?{value:s,format:"[h]:mm:ss"}:{value:s,format:t[3]?"h:mm:ss":"h:mm"}}export function readTyped(e){if(e==="")return{value:null};if(e.startsWith("'"))return{value:e.slice(1)};if(e.length>1&&e.startsWith("="))return{value:null,formula:e};const t=e.trim();if(t==="")return{value:e};const n=t.toUpperCase();if(n==="TRUE")return{value:!0};if(n==="FALSE")return{value:!1};if(N.test(t))return b(t)?{value:e}:{value:Number(t)};if(t.endsWith("%")){const i=t.slice(0,-1).trim();if(N.test(i))return{value:Number(i)/100,format:i.includes(".")?"0.00%":"0%"}}if(L.test(t))return{value:Number(t.replaceAll(",","")),format:t.includes(".")?"#,##0.00":"#,##0"};const r=/^([+-]?)\$(\d[\d,]*(?:\.\d+)?)$/u.exec(t),u=r?.[2]?.replaceAll(",","");if(r&&u!==void 0)return{value:+`${r[1]??""}${u}`,format:t.includes(".")?"$#,##0.00":"$#,##0"};const o=U(t);if(o)return o;const s=C(t);if(s)return s;const f=errorOf(t);return f?{value:f}:{value:e}}export function writeTyped(e){if(e===null)return"";if(typeof e=="number"){const n=String(e);return b(n)?e.toExponential():n}if(typeof e=="boolean")return e?"TRUE":"FALSE";if(e instanceof CellError)return e.code;const t=readTyped(e);return t.value===e&&t.formula===void 0?e:`'${e}`}
@@ -1,7 +1,7 @@
1
1
  import type { SheetChart, SheetConditional, SheetFile, SheetFilesColumn, SheetFilterColumn, SheetFormatEntry, SheetTable, SheetTableColumn, SheetValidation, SheetWorksheet } from "@allyhub/formats";
2
2
  import { rangeName, type Area, type Place } from "./address.js";
3
3
  import { type SheetProblem, type YamlPath } from "./file.js";
4
- import { type GeneratedSheets } from "./generated.js";
4
+ import { type GeneratedSheets } from "@allyhub/formats";
5
5
  import type { Node, ParseError } from "./formula/ast.js";
6
6
  import { CellError, type Matrix, type Scalar } from "./values.js";
7
7
  /** Where a value is written. */
@@ -135,6 +135,8 @@ interface Fill {
135
135
  shared?: SharedFormula;
136
136
  value?: Scalar;
137
137
  format?: string;
138
+ /** What its formula's cells hold before they are computed. */
139
+ start?: Scalar;
138
140
  }
139
141
  export declare const placeKey: (row: number, col: number) => number;
140
142
  export declare class Worksheet {
@@ -160,7 +162,7 @@ export declare class Worksheet {
160
162
  /** Names that hold on this sheet alone, over the workbook's, in lower case. */
161
163
  readonly names: Map<string, DefinedName>;
162
164
  freeze: Place | undefined;
163
- /** sheet.ts makes it: what is on it is not changed by hand. */
165
+ /** The sheet's code makes it: what is on it is not changed by hand. */
164
166
  generated: boolean;
165
167
  private readonly grid;
166
168
  private expanded;
@@ -266,9 +268,9 @@ export declare class Workbook {
266
268
  private readonly bySheet;
267
269
  private readonly byTable;
268
270
  file: SheetFile;
269
- /** What sheet.ts makes: `file` holds it too. */
271
+ /** What the sheet's code makes: `file` holds it too. */
270
272
  readonly generated: GeneratedSheets | undefined;
271
- /** Sheets sheet.ts makes that sheet.yaml holds: sheet.yaml's stand. */
273
+ /** Sheets the code makes that sheet.yaml holds: sheet.yaml's stand. */
272
274
  ordinary: readonly string[];
273
275
  constructor(file: SheetFile, generated?: GeneratedSheets);
274
276
  /** sheet.yaml after an edit that changed no sheet, table or fill: the looks and the keys. */
@@ -291,7 +293,7 @@ export interface WorkbookFiles {
291
293
  text: string;
292
294
  /** A file's text, from the sheet's folder; undefined when it is not there. */
293
295
  read: (path: string) => string | undefined;
294
- /** What its sheet.ts makes. */
296
+ /** What its code makes. */
295
297
  generated?: GeneratedSheets | undefined;
296
298
  /** Whether a file is there, from the sheet's folder: what a `files` column names is looked for. */
297
299
  exists?: ((path: string) => boolean) | undefined;
@@ -301,7 +303,7 @@ export interface WorkbookValues {
301
303
  file: SheetFile;
302
304
  /** A CSV file's rows, from the sheet's folder; undefined when it is not there. */
303
305
  rows: (path: string) => CsvRows | undefined;
304
- /** What its sheet.ts makes. */
306
+ /** What its code makes. */
305
307
  generated?: GeneratedSheets | undefined;
306
308
  }
307
309
  export interface ReadWorkbook {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{SHEET_CODE as C,SHEET_SEPARATOR as P}from"@allyhub/formats";import{MAX_ROWS as B,cellName as H,columnIndex as z,columnLetter as j,contains as y,overlaps as v,rangeName as U,readAddress as x,readArea as $,readAreas as _}from"./address.js";import{readCsv as R}from"./csv.js";import{ENTRY as E,readSheetFile as D}from"./file.js";import{withGenerated as O}from"./generated.js";import{moveFormula as G}from"./formula/move.js";import{parseFormula as X}from"./formula/parse.js";import{printFormula as Y}from"./formula/print.js";import{readTyped as S}from"./values.js";export class SharedFormula{node;error;analysis;text;row;col;source;constructor(e,t,s,n){this.text=e,this.row=t,this.col=s,this.source=n;const i=X(e);i.ok?this.node=i.node:this.error=i.error}}export class FormulaCell{value=null;array;spill;blocked;state=1;mark=0;shared;sheet;row;col;constructor(e,t,s,n){this.shared=e,this.sheet=t,this.row=s,this.col=n}get moved(){const{node:e,row:t,col:s}=this.shared;if(!e)throw new Error(`${this.shared.text} does not parse.`);return G(e,this.row-t,this.col-s)}get text(){const{node:e,text:t,row:s,col:n}=this.shared;return!e||s===this.row&&n===this.col?t:Y(this.moved)}}class Z{columns=[];firsts=[];lasts=[];formulas=[];get(e,t){return this.columns[t]?.[e]}set(e,t,s){let n=this.columns[t];n||(n=[],this.columns[t]=n,this.firsts[t]=e,this.lasts[t]=e),n[e]instanceof FormulaCell&&(this.formulas[t]=(this.formulas[t]??1)-1),s instanceof FormulaCell&&(this.formulas[t]=(this.formulas[t]??0)+1),n[e]=s,e<(this.firsts[t]??e)&&(this.firsts[t]=e),e>(this.lasts[t]??e)&&(this.lasts[t]=e)}get width(){return this.columns.length}holds(e,t,s){const n=Math.min(e.right,this.columns.length-1);for(let i=e.left;i<=n;i++){const a=this.columns[i];if(!a)continue;const r=Math.min(e.bottom,this.last(i));for(let o=Math.max(e.top,this.first(i));o<=r;o++)if(a[o]!==void 0&&!(o===t&&i===s))return!0}return!1}first(e){return this.firsts[e]??1/0}last(e){return this.lasts[e]??-1}hasFormulas(e){return(this.formulas[e]??0)>0}}export class Table{columns=[];rows=0;lines=[];places=[];records=[];name;sheet;at;file;spec;constructor(e,t,s,n,i){this.name=e,this.sheet=t,this.at=s,this.file=n,this.spec=i}get area(){return{top:this.at.row,left:this.at.col,bottom:this.at.row+this.rows,right:this.at.col+Math.max(this.columns.length,1)-1}}get data(){const e=this.area;return{...e,top:e.top+1}}column(e){const t=e.toLowerCase();return this.columns.find(s=>s.name.toLowerCase()===t)}}export const placeKey=(l,e)=>l*16384+e;function T(l,e){l.bottom=Math.max(l.bottom,e.bottom),l.right=Math.max(l.right,e.right);for(let t=e.left;t<=e.right;t++){const s=l.columns.get(t);l.columns.set(t,[Math.min(s?.[0]??e.top,e.top),Math.max(s?.[1]??e.bottom,e.bottom)])}}export class Worksheet{tables=[];blocks=[];merges=[];formulas=new Set;implied=new Map;keys=new Map;fills=[];blanks=new Set;conditions=[];validations=[];filters=[];charts=[];names=new Map;freeze;generated=!1;grid=new Z;expanded=!1;lowest=-1;ghosts=new Map;spills=new Set;stopped=new Set;reach;lookAreas;name;index;spec;constructor(e,t,s){this.name=e,this.index=t,this.spec=s}respec(e){const t=e.charts!==this.spec.charts;this.spec=e,this.lookAreas=void 0,t&&(this.charts.length=0,e.charts?.forEach((s,n)=>{const i=W(s,n,[],()=>{});i&&this.charts.push(i)}))}put(e,t,s){s instanceof FormulaCell&&this.formulas.add(s),this.grid.set(e,t,s),e>this.lowest&&(this.lowest=e)}replace(e,t,s){this.expand();const n=this.grid.get(e,t);n instanceof FormulaCell&&this.formulas.delete(n),s instanceof FormulaCell&&this.formulas.add(s),this.grid.set(e,t,s),e>this.lowest&&(this.lowest=e)}expand(){if(!this.expanded){this.expanded=!0;for(let e=this.fills.length-1;e>=0;e--){const t=this.fills[e];if(!t)continue;const{area:s,shared:n,value:i,format:a}=t;for(let r=s.top;r<=s.bottom;r++)for(let o=s.left;o<=s.right;o++)this.grid.get(r,o)===void 0&&(this.blanks.has(placeKey(r,o))||(n?this.put(r,o,new FormulaCell(n,this,r,o)):i!=null&&(this.put(r,o,i),a!==void 0&&this.implied.set(placeKey(r,o),a))))}}}at(e,t){return this.expand(),this.grid.get(e,t)}spillAt(e,t){return this.ghosts.size===0?void 0:this.ghosts.get(placeKey(e,t))}holds(e,t){return this.expand(),this.grid.holds(e,t.row,t.col)}spillsIn(e){if(this.spills.size===0)return[];if((e.bottom-e.top+1)*(e.right-e.left+1)>=this.spills.size)return[...this.spills].filter(n=>n.spill!==void 0&&v(n.spill,e));const s=new Set;for(let n=e.top;n<=e.bottom;n++)for(let i=e.left;i<=e.right;i++){const a=this.ghosts.get(placeKey(n,i));a&&s.add(a)}return[...s]}blockedBy(e){if(this.stopped.size===0)return[];const t=[];for(const s of this.stopped)s.blocked&&v(s.blocked,e)&&t.push(s);return t}placeSpill(e,t){e.spill=t,this.spills.add(e);for(let s=t.top;s<=t.bottom;s++)for(let n=t.left;n<=t.right;n++)(s!==e.row||n!==e.col)&&this.ghosts.set(placeKey(s,n),e);this.reach&&T(this.reach,t)}blockSpill(e,t){e.blocked=t,this.stopped.add(e)}clearSpill(e){const t=e.spill;if(t)for(let s=t.top;s<=t.bottom;s++)for(let n=t.left;n<=t.right;n++)this.ghosts.get(placeKey(s,n))===e&&this.ghosts.delete(placeKey(s,n));e.spill=void 0,e.blocked=void 0,this.spills.delete(e),this.stopped.delete(e)}clearSpills(){for(const e of[...this.spills,...this.stopped])e.spill=void 0,e.blocked=void 0;this.spills.clear(),this.stopped.clear(),this.ghosts.clear(),this.reach=void 0}tighten(){this.reach=void 0}spillReach(){if(this.reach)return this.reach;const e={columns:new Map,bottom:-1,right:-1};for(const{spill:t}of this.spills)t&&T(e,t);return this.reach=e,e}hasFormulas(e){return this.expand(),this.grid.hasFormulas(e)}span(e,t,s){this.expand();const n=this.grid.first(e),i=this.grid.last(e);if(this.spills.size===0)return[Math.max(t,n),Math.min(s,i)];const[a,r]=this.spillReach().columns.get(e)??[1/0,-1];return[Math.max(t,Math.min(n,a)),Math.min(s,Math.max(i,r))]}get columnsUsed(){return this.expand(),this.spills.size===0?this.grid.width:Math.max(this.grid.width,this.spillReach().right+1)}get lastRow(){return this.expand(),this.spills.size===0?this.lowest:Math.max(this.lowest,this.spillReach().bottom)}get used(){const e=this.lastRow,t=this.columnsUsed-1;return e<0||t<0?void 0:{top:0,left:0,bottom:e,right:t}}tableAt(e,t){return this.tables.find(s=>y(s.area,e,t))}blockAt(e,t){return this.blocks.find(s=>y(s.area,e,t))}looks(){if(this.lookAreas)return this.lookAreas;const e=[];for(const s of this.spec.format??[]){const n=$(s.range);n&&e.push({area:n,entry:s})}const t=[];for(const[s,n]of Object.entries(this.spec.cells??{})){if(!s.includes(":")||n===null||typeof n!="object")continue;const i=$(s);i&&t.push({area:i,entry:n})}return this.lookAreas={formats:e,ranges:t},this.lookAreas}styledAreas(){const{formats:e,ranges:t}=this.looks();return[...e,...t.filter(s=>Object.keys(s.entry).some(n=>F.has(n)))]}lookAt(e,t){const s={},n=c=>{if(c)for(const[b,w]of Object.entries(c))F.has(b)&&w!==void 0&&(s[b]=b==="border"?{...s.border,...w}:w)},i=this.implied.get(placeKey(e,t));i!==void 0&&(s.format=i);const a=this.ghosts.size===0?void 0:this.spillAt(e,t),r=a&&this.lookAt(a.row,a.col).format;r!==void 0&&(s.format=r),this.spec.columns&&n(this.spec.columns[j(t)]),this.spec.rows&&n(this.spec.rows[String(e+1)]);const o=this.tableAt(e,t);o&&e>o.at.row&&n(o.columns[t-o.at.col]?.spec);const{formats:f,ranges:h}=this.looks();for(const c of f)y(c.area,e,t)&&n(c.entry);for(const c of h)y(c.area,e,t)&&n(c.entry);const d=this.keys.get(placeKey(e,t)),g=d===void 0?void 0:this.spec.cells?.[d];if(g!==null&&typeof g=="object"&&n(g),s.border){const c=Object.entries(s.border).filter(([,b])=>b?.style!=="none");c.length===0?delete s.border:s.border=Object.fromEntries(c)}return s}mergeAt(e,t){return this.merges.find(s=>y(s,e,t))}validationAt(e,t){return this.validations.find(s=>s.areas.some(n=>y(n,e,t)))}filterHeadAt(e,t){return this.filters.find(s=>e===s.area.top&&t>=s.area.left&&t<=s.area.right)}filterAt(e,t){return this.filters.find(s=>y(s.area,e,t))}filesAt(e,t){const s=this.tableAt(e,t);if(s&&e>s.at.row){const n=s.columns[t-s.at.col]?.spec?.files;if(n!==void 0)return n}return s?.at.row===e?void 0:this.spec.columns?.[j(t)]?.files}}export const filesSeparator=l=>(typeof l=="object"?l.separator:void 0)??P;export function filesIn(l,e){const t=filesSeparator(e);return l.split(t.trim()===""?t:t.trim()).map(s=>s.trim()).filter(s=>s!=="")}const F=new Set(["bold","italic","underline","strike","font","size","color","fill","align","valign","wrap","shrink","indent","rotation","border","format"]);export class Workbook{title;sheets=[];names=new Map;checks=[];bySheet=new Map;byTable=new Map;file;generated;ordinary=[];constructor(e,t){this.file=e,this.title=e.title,this.generated=t}respec(e){this.file=O(e,this.generated).file,this.title=e.title,this.sheets.forEach(t=>{const s=e.sheets.find(n=>n.name===t.name);s&&t.respec(s)})}sheet(e){return this.bySheet.get(e.toLowerCase())}table(e){return this.byTable.get(e.toLowerCase())}name(e,t){const s=e.toLowerCase();return(t?.names.size?t.names.get(s):void 0)??this.names.get(s)}definitions(e){const t=e.toLowerCase(),s=[],n=this.names.get(t);n&&s.push(n);for(const i of this.sheets){const a=i.names.get(t);a&&s.push(a)}return s}get tables(){return[...this.byTable.values()]}addSheet(e){this.sheets.push(e),this.bySheet.set(e.name.toLowerCase(),e)}addTable(e){e.sheet.tables.push(e),this.byTable.set(e.name.toLowerCase(),e)}sourceOf(e,t,s){if(e.generated)return{file:C};const n=this.sheets.indexOf(e),i=e.tableAt(t,s);if(i){const o=i.columns[s-i.at.col],f=t-i.at.row-1,h=o?.csv!==void 0&&(i.records[f]?.[o.csv]??"")!=="";return f>=0&&o?.formula&&!h?o.formula.source:{file:i.file,line:f<0?1:i.lines[f]??1}}const a=e.blockAt(t,s);if(a)return{file:a.file,line:a.lines[t-a.area.top]??1};const r=e.keys.get(placeKey(t,s));if(r!==void 0)return{file:E,path:["sheets",n,"cells",r]};for(const o of Object.keys(e.spec.cells??{})){if(!o.includes(":"))continue;const f=$(o);if(f&&y(f,t,s))return{file:E,path:["sheets",n,"cells",o]}}}}export const MAX_FILL_CELLS=5e6;const q=/^[\p{L}_\\][\p{L}\p{N}_.\\?]*$/u;export function validName(l){return q.test(l)&&x(l)===void 0&&!/^(?:TRUE|FALSE)$/iu.test(l)&&!/^[Rr](?:\d+)?(?:[Cc]\d*)?$/u.test(l)&&!/^[Cc]\d*$/u.test(l)}const M="made",k=l=>l[0]===M?C:E;class N{problems=[];wb;read_;lineOf;own;madeNames;constructor(e,t,s,n,i){this.wb=e,this.read_=t,this.lineOf=s,this.own=n,this.madeNames=i}yaml(e,t){const s=this.lineOf(e);this.problems.push({file:k(e),...s===void 0?{}:{line:s},message:t})}sheetPath(e){return e<this.own?["sheets",e]:[M,"sheets",e-this.own]}read(){const{file:e}=this.wb;e.sheets.forEach((t,s)=>{const n=this.sheetPath(s);if(this.wb.sheet(t.name)){this.yaml([...n,"name"],`two sheets are named ${t.name}`);return}(/[\\/?*[\]:]/u.test(t.name)||t.name.length>31)&&this.yaml([...n,"name"],`${t.name} cannot be a sheet's name: at most 31 characters, none of \\ / ? * [ ] :`);const i=new Worksheet(t.name,this.wb.sheets.length,t);i.generated=s>=this.own,this.wb.addSheet(i)}),this.names();for(const[t,s]of e.sheets.entries()){const n=this.wb.sheets[t];n?.spec===s&&this.sheet(n,this.sheetPath(t))}e.checks?.forEach((t,s)=>{const n={file:E,path:["checks",s,"formula"]};this.wb.checks.push({name:t.name,formula:new SharedFormula(t.formula,0,0,n),source:n})})}names(){const{file:e}=this.wb;this.namesOf(e.names,e.hidden_names,t=>this.madeNames.has(t)?[M,"names",t]:["names",t],this.wb.names,void 0),e.sheets.forEach((t,s)=>{const n=this.wb.sheets[s];n?.spec===t&&this.namesOf(t.names,t.hidden_names,i=>[...this.sheetPath(s),"names",i],n.names,n)})}namesOf(e,t,s,n,i){const a=new Set(t?.map(r=>r.toLowerCase()));for(const[r,o]of Object.entries(e??{})){const f=s(r);if(!validName(r)){this.yaml(f,`${r} cannot be a name`);continue}const h={file:k(f),path:f},d=typeof o=="string"&&o.startsWith("=")?{name:r,formula:new SharedFormula(o,0,0,h),source:h}:{name:r,value:typeof o=="string"?S(o).value:o,source:h};i&&(d.sheet=i),a.has(r.toLowerCase())&&(d.hidden=!0),n.set(r.toLowerCase(),d)}}sheet(e,t){const{spec:s}=e;if(s.freeze!==void 0){const n=x(s.freeze);n?e.freeze=n:this.yaml([...t,"freeze"],`${s.freeze} is not a cell`)}s.tables?.forEach((n,i)=>{this.table(e,n,[...t,"tables",i])});for(const[n,i]of e.tables.entries())for(const a of e.tables.slice(n+1))v(i.area,a.area)&&this.problems.push({file:E,message:`tables ${i.name} and ${a.name} overlap on ${e.name}`});s.blocks?.forEach((n,i)=>{this.block(e,n.at,n.rows,[...t,"blocks",i])}),this.cells(e,s.cells??{},[...t,"cells"]),s.merges?.forEach((n,i)=>{const a=$(n);a?e.merges.push(a):this.yaml([...t,"merges",i],`${n} is not a range`)}),s.format?.forEach((n,i)=>{$(n.range)||this.yaml([...t,"format",i,"range"],`${n.range} is not a range`)}),s.conditional?.forEach((n,i)=>{this.condition(e,n,[...t,"conditional",i])}),s.validations?.forEach((n,i)=>{this.validation(e,n,[...t,"validations",i])}),this.filters(e,t),s.charts?.forEach((n,i)=>{this.chart(e,n,i,[...t,"charts",i])});for(const n of Object.keys(s.columns??{}))z(n)===void 0&&this.yaml([...t,"columns",n],`${n} is not a column`);for(const n of Object.keys(s.rows??{}))(!/^[1-9]\d*$/u.test(n)||Number(n)>B)&&this.yaml([...t,"rows",n],`${n} is not a row`)}chart(e,t,s,n){const i=W(t,s,n,(a,r)=>{this.yaml(a,r)});i&&e.charts.push(i)}bound(e,t,s){if(!(typeof e!="string"||!e.startsWith("=")||e.length<2))return new SharedFormula(e,t?.top??0,t?.left??0,{file:k(s),path:s})}condition(e,t,s){const n=_(t.range);if(!n){this.yaml([...s,"range"],`${t.range} is not a range`);return}const[i]=n,a=[],r=(o,f)=>{const h=this.bound(o,i,f);h&&a.push(h)};if(t.type==="expression"){const o=t.formula.startsWith("=")?t.formula:`=${t.formula}`;r(o,[...s,"formula"])}if(t.type==="cellIs"&&t.formula.forEach((o,f)=>{r(o,[...s,"formula",f])}),t.type==="dataBar")for(const o of["min","max"])r(t[o]?.value,[...s,o,"value"]);(t.type==="colorScale"||t.type==="iconSet")&&t.stops?.forEach((o,f)=>{r(o.value,[...s,"stops",f,"value"])}),e.conditions.push({spec:t,areas:n,formulas:a})}validation(e,t,s){const n=_(t.range);if(!n){this.yaml([...s,"range"],`${t.range} is not a range`);return}const i=(t.formula??[]).map((o,f)=>this.bound(o,n[0],[...s,"formula",f])),a=t.formula?.length??0,r=t.type!=="list"&&t.type!=="custom"&&(t.operator===void 0||t.operator==="between"||t.operator==="notBetween");!(t.type==="list"&&t.values!==void 0)&&a<(r?2:1)&&this.yaml(s,`a ${t.type} validation needs its bounds`),e.validations.push({spec:t,areas:n,formulas:i})}filters(e,t){const{spec:s}=e;if(s.filter){const n=[...t,"filter"],i=$(s.filter.range);if(!i)this.yaml([...n,"range"],`${s.filter.range} is not a range`);else{const a=new Map;for(const[o,f]of Object.entries(s.filter.columns??{})){const h=z(o);h===void 0||h<i.left||h>i.right?this.yaml([...n,"columns",o],`${o} is not a column of ${s.filter.range}`):a.set(h,f)}const r=e.tables.find(o=>v(o.area,i));r&&this.yaml(n,`a filter over table ${r.name}: a table has its own`),e.filters.push({area:i,columns:a})}}e.tables.forEach((n,i)=>{const{filter:a}=n.spec;if(a===!1)return;const r=new Map;for(const[o,f]of Object.entries(a?.columns??{})){const h=n.column(o);h?r.set(n.at.col+h.index,f):this.yaml([...t,"tables",i,"filter","columns",o],`table ${n.name} has no column ${o}`)}e.filters.push({area:n.area,table:n,columns:r})})}csv(e,t,s){const n=this.read_(e);return n||this.yaml(t,`${s}: ${e} is not there`),n}overlapping(e,t){const s=e.tables.find(i=>v(i.area,t));if(s)return`table ${s.name}`;const n=e.blocks.find(i=>v(i.area,t));return n?`the block of ${n.file}`:void 0}typed(e,t,s,n,i){if(n.formula!==void 0){const a=new SharedFormula(n.formula,t,s,i);e.put(t,s,new FormulaCell(a,e,t,s));return}n.value!==null&&(e.put(t,s,n.value),n.format!==void 0&&e.implied.set(placeKey(t,s),n.format))}table(e,t,s){const n=x(t.at);if(!n){this.yaml([...s,"at"],`${t.at} is not a cell`);return}if(!validName(t.name)){this.yaml([...s,"name"],`${t.name} cannot be a table's name`);return}if(this.wb.table(t.name)){this.yaml([...s,"name"],`two tables are named ${t.name}`);return}this.wb.name(t.name)&&this.yaml([...s,"name"],`${t.name} is a defined name and a table's`);const i=new Table(t.name,e,n,t.rows,t),a=this.csv(t.rows,[...s,"rows"],`table ${t.name}`),r=a?.rows??[],o=a?.lines??[],f=r[0],h=o[0]??1,d=new Set,g=f?.length===0?[""]:f??[];g.forEach((u,m)=>{const p=u.trim();p===""&&this.problems.push({file:t.rows,line:h,message:`column ${String(m+1)} has no name`}),d.has(p.toLowerCase())&&this.problems.push({file:t.rows,line:h,message:`two columns are named ${p}`}),d.add(p.toLowerCase()),i.columns.push({name:p,index:i.columns.length,csv:m})});for(const[u,m]of Object.entries(t.columns??{})){const p=i.column(u),A=p??{name:u,index:i.columns.length};p||(m.formula===void 0&&this.yaml([...s,"columns",u],`table ${t.name} has no column ${u}`),i.columns.push(A)),A.spec=m}const c=g.length;for(let u=1;u<r.length;u++){const m=r[u];if(!m||m.length===0)continue;const p=o[u]??u+1;i.places.push(u),i.records.push(m),i.lines.push(p),m.length>c&&this.problems.push({file:t.rows,line:p,message:`this row has ${String(m.length)} fields and the header ${String(c)}`})}i.rows=i.records.length;const b=this.overlapping(e,i.area);b&&this.yaml(s,`table ${t.name} overlaps ${b} on ${e.name}`),this.wb.addTable(i),this.tableKey(i,s);const w=n.row+1;i.columns.forEach(u=>{const m=n.col+u.index;e.put(n.row,m,u.name);const p=u.spec?.formula;p!==void 0&&(u.formula=new SharedFormula(p,w,m,{file:k(s),path:[...s,"columns",u.name,"formula"]}),i.rows>0&&e.fills.push({area:{top:w,left:m,bottom:w+i.rows-1,right:m},shared:u.formula})),u.csv!==void 0&&i.records.forEach((A,L)=>{this.typed(e,w+L,m,S(A[u.csv??0]??""),{file:t.rows,line:i.lines[L]??1})})})}tableKey(e,t){const{key:s}=e.spec;if(s===void 0)return;const n=e.column(s);if(n?.csv===void 0){this.yaml([...t,"key"],`table ${e.name} has no column ${s} in ${e.file}`);return}const i=new Set;e.records.forEach((a,r)=>{const o=a[n.csv??0]??"",f=e.lines[r]??1;o===""?this.problems.push({file:e.file,line:f,message:`this row has no ${s}, table ${e.name}'s key`}):i.has(o)&&this.problems.push({file:e.file,line:f,message:`two rows have the key ${o}`}),i.add(o)})}block(e,t,s,n){const i=x(t);if(!i){this.yaml([...n,"at"],`${t} is not a cell`);return}const a=this.csv(s,[...n,"rows"],"a block");if(!a)return;const r=a.rows,o=r.map((g,c)=>a.lines[c]??c+1),f=r.reduce((g,c)=>Math.max(g,c.length),1),h={top:i.row,left:i.col,bottom:i.row+Math.max(r.length,1)-1,right:i.col+f-1},d=this.overlapping(e,h);d&&this.yaml(n,`the block of ${s} overlaps ${d} on ${e.name}`),e.blocks.push({area:h,file:s,lines:o}),r.forEach((g,c)=>{g.forEach((b,w)=>{this.typed(e,i.row+c,i.col+w,S(b),{file:s,line:o[c]??c+1})})})}cells(e,t,s){const n=[];for(const[i,a]of Object.entries(t)){const r=[...s,i],o=$(i);if(!o){this.yaml(r,`${i} is not a cell or a range`);continue}const f=this.overlapping(e,o);if(f&&this.yaml(r,`${i} overlaps ${f}`),i.includes(":")){const h=(o.bottom-o.top+1)*(o.right-o.left+1);h>MAX_FILL_CELLS?this.yaml(r,`${i} is ${String(h)} cells`):this.fill(e,o,a,r)}else n.push([i,a,{row:o.top,col:o.left}])}for(const[i,a,r]of n){const o=[...s,i],f=K(a),h=placeKey(r.row,r.col);e.keys.set(h,i),f.value===null&&f.formula===void 0&&e.blanks.add(h),this.typed(e,r.row,r.col,f,{file:k(o),path:o});const d=a!==null&&typeof a=="object"?a.name:void 0;d!==void 0&&this.cellName(e,r,d,o)}}cellName(e,t,s,n){if(!validName(s)){this.yaml(n,`${s} cannot be a name`);return}if(this.wb.name(s)){this.yaml(n,`two places are named ${s}`);return}const i={file:k(n),path:n},a=H(t).replace(/^([A-Z]+)(\d+)$/u,"$$$1$$$2"),r=`='${e.name.replaceAll("'","''")}'!${a}`;this.wb.names.set(s.toLowerCase(),{name:s,formula:new SharedFormula(r,0,0,i),source:i})}fill(e,t,s,n){const i=K(s),a={file:k(n),path:n};e.fills.push(i.formula===void 0?{area:t,value:i.value,...i.format===void 0?{}:{format:i.format}}:{area:t,shared:new SharedFormula(i.formula,t.top,t.left,a)})}}function W(l,e,t,s){const n=x(l.at);if(!n){s([...t,"at"],`${l.at} is not a cell`);return}const i=(o,f)=>{const h=new SharedFormula(chartFormula(o),0,0,{file:k(f),path:f});return h.node&&!I(h.node)&&s(f,`${o} is not a range or a table's column`),h},a=(o,f)=>o?.startsWith("=")===!0?i(o,f):void 0,r=a(l.title,[...t,"title"]);return{spec:l,at:n,index:e,...l.categories===void 0?{}:{categories:i(l.categories,[...t,"categories"])},...r?{title:r}:{},series:l.series.map((o,f)=>{const h=[...t,"series",f],d=a(o.name,[...h,"name"]);return{values:i(o.values,[...h,"values"]),...o.x===void 0?{}:{x:i(o.x,[...h,"x"])},...d?{name:d}:{}}})}}export const chartFormula=l=>l.startsWith("=")?l:`=${l}`;function I(l){switch(l.kind){case"error":case"ref":case"structured":case"name":return!0;case"paren":case"postfix":return I(l.arg);case"binary":return l.op===":"||l.op===",";default:return!1}}function K(l){if(l===null)return{value:null};if(typeof l=="string")return S(l);if(typeof l!="object")return{value:l};if(l.formula!==void 0)return{value:null,formula:l.formula.startsWith("=")?l.formula:`=${l.formula}`};const{value:e}=l;return typeof e=="string"?S(e):{value:e??null}}export function readWorkbook(l){const e=D(l.text),t=r=>r[0]===M?void 0:e.lineOf(r);if(!e.file)return{problems:e.problems,lineOf:t};const s=O(e.file,l.generated),n=new Workbook(s.file,l.generated);n.ordinary=s.ordinary;const i=[],a=new N(n,r=>{const o=l.generated?.csv[r]??l.read(r);if(o===void 0)return;const f=R(o);for(const h of f.problems)i.push({file:r,line:h.line,message:h.message});return{rows:f.records.map(h=>h.end===h.start?[]:h.fields),lines:f.records.map(h=>h.line)}},t,s.own,s.names);return a.read(),{workbook:n,problems:[...i,...a.problems],lineOf:t}}export function workbookOf(l){const e=O(l.file,l.generated),t=new Workbook(e.file,l.generated);return t.ordinary=e.ordinary,new N(t,s=>{const n=l.generated?.csv[s];if(n!==void 0)return{rows:R(n).records.map(a=>a.end===a.start?[]:a.fields),lines:[]};const i=l.rows(s);return i&&{rows:i,lines:[]}},()=>{},e.own,e.names).read(),t}export{U as rangeName};
2
+ import{SHEET_SEPARATOR as P}from"@allyhub/formats";import{MAX_ROWS as B,cellName as U,columnIndex as C,columnLetter as z,contains as y,overlaps as v,rangeName as D,readAddress as E,readArea as $,readAreas as j}from"./address.js";import{readCsv as _}from"@allyhub/formats";import{CODE as R,ENTRY as A,readSheetFile as G}from"./file.js";import{withGenerated as O}from"./generated.js";import"@allyhub/formats";import{moveFormula as H}from"./formula/move.js";import{parseFormula as X}from"./formula/parse.js";import{printFormula as Y}from"./formula/print.js";import{readTyped as x}from"./values.js";export class SharedFormula{node;error;analysis;text;row;col;source;constructor(e,t,s,n){this.text=e,this.row=t,this.col=s,this.source=n;const i=X(e);i.ok?this.node=i.node:this.error=i.error}}export class FormulaCell{value=null;array;spill;blocked;state=1;mark=0;shared;sheet;row;col;constructor(e,t,s,n){this.shared=e,this.sheet=t,this.row=s,this.col=n}get moved(){const{node:e,row:t,col:s}=this.shared;if(!e)throw new Error(`${this.shared.text} does not parse.`);return H(e,this.row-t,this.col-s)}get text(){const{node:e,text:t,row:s,col:n}=this.shared;return!e||s===this.row&&n===this.col?t:Y(this.moved)}}class Z{columns=[];firsts=[];lasts=[];formulas=[];get(e,t){return this.columns[t]?.[e]}set(e,t,s){let n=this.columns[t];n||(n=[],this.columns[t]=n,this.firsts[t]=e,this.lasts[t]=e),n[e]instanceof FormulaCell&&(this.formulas[t]=(this.formulas[t]??1)-1),s instanceof FormulaCell&&(this.formulas[t]=(this.formulas[t]??0)+1),n[e]=s,e<(this.firsts[t]??e)&&(this.firsts[t]=e),e>(this.lasts[t]??e)&&(this.lasts[t]=e)}get width(){return this.columns.length}holds(e,t,s){const n=Math.min(e.right,this.columns.length-1);for(let i=e.left;i<=n;i++){const r=this.columns[i];if(!r)continue;const a=Math.min(e.bottom,this.last(i));for(let o=Math.max(e.top,this.first(i));o<=a;o++)if(r[o]!==void 0&&!(o===t&&i===s))return!0}return!1}first(e){return this.firsts[e]??1/0}last(e){return this.lasts[e]??-1}hasFormulas(e){return(this.formulas[e]??0)>0}}export class Table{columns=[];rows=0;lines=[];places=[];records=[];name;sheet;at;file;spec;constructor(e,t,s,n,i){this.name=e,this.sheet=t,this.at=s,this.file=n,this.spec=i}get area(){return{top:this.at.row,left:this.at.col,bottom:this.at.row+this.rows,right:this.at.col+Math.max(this.columns.length,1)-1}}get data(){const e=this.area;return{...e,top:e.top+1}}column(e){const t=e.toLowerCase();return this.columns.find(s=>s.name.toLowerCase()===t)}}export const placeKey=(l,e)=>l*16384+e;function F(l,e){l.bottom=Math.max(l.bottom,e.bottom),l.right=Math.max(l.right,e.right);for(let t=e.left;t<=e.right;t++){const s=l.columns.get(t);l.columns.set(t,[Math.min(s?.[0]??e.top,e.top),Math.max(s?.[1]??e.bottom,e.bottom)])}}export class Worksheet{tables=[];blocks=[];merges=[];formulas=new Set;implied=new Map;keys=new Map;fills=[];blanks=new Set;conditions=[];validations=[];filters=[];charts=[];names=new Map;freeze;generated=!1;grid=new Z;expanded=!1;lowest=-1;ghosts=new Map;spills=new Set;stopped=new Set;reach;lookAreas;name;index;spec;constructor(e,t,s){this.name=e,this.index=t,this.spec=s}respec(e){const t=e.charts!==this.spec.charts;this.spec=e,this.lookAreas=void 0,t&&(this.charts.length=0,e.charts?.forEach((s,n)=>{const i=W(s,n,[],()=>{});i&&this.charts.push(i)}))}put(e,t,s){s instanceof FormulaCell&&this.formulas.add(s),this.grid.set(e,t,s),e>this.lowest&&(this.lowest=e)}replace(e,t,s){this.expand();const n=this.grid.get(e,t);n instanceof FormulaCell&&this.formulas.delete(n),s instanceof FormulaCell&&this.formulas.add(s),this.grid.set(e,t,s),e>this.lowest&&(this.lowest=e)}expand(){if(!this.expanded){this.expanded=!0;for(let e=this.fills.length-1;e>=0;e--){const t=this.fills[e];if(!t)continue;const{area:s,shared:n,value:i,format:r,start:a}=t;for(let o=s.top;o<=s.bottom;o++)for(let f=s.left;f<=s.right;f++)if(this.grid.get(o,f)===void 0&&!this.blanks.has(placeKey(o,f)))if(n){const h=new FormulaCell(n,this,o,f);a!==void 0&&(h.value=a),this.put(o,f,h)}else i!=null&&(this.put(o,f,i),r!==void 0&&this.implied.set(placeKey(o,f),r))}}}at(e,t){return this.expand(),this.grid.get(e,t)}spillAt(e,t){return this.ghosts.size===0?void 0:this.ghosts.get(placeKey(e,t))}holds(e,t){return this.expand(),this.grid.holds(e,t.row,t.col)}spillsIn(e){if(this.spills.size===0)return[];if((e.bottom-e.top+1)*(e.right-e.left+1)>=this.spills.size)return[...this.spills].filter(n=>n.spill!==void 0&&v(n.spill,e));const s=new Set;for(let n=e.top;n<=e.bottom;n++)for(let i=e.left;i<=e.right;i++){const r=this.ghosts.get(placeKey(n,i));r&&s.add(r)}return[...s]}blockedBy(e){if(this.stopped.size===0)return[];const t=[];for(const s of this.stopped)s.blocked&&v(s.blocked,e)&&t.push(s);return t}placeSpill(e,t){e.spill=t,this.spills.add(e);for(let s=t.top;s<=t.bottom;s++)for(let n=t.left;n<=t.right;n++)(s!==e.row||n!==e.col)&&this.ghosts.set(placeKey(s,n),e);this.reach&&F(this.reach,t)}blockSpill(e,t){e.blocked=t,this.stopped.add(e)}clearSpill(e){const t=e.spill;if(t)for(let s=t.top;s<=t.bottom;s++)for(let n=t.left;n<=t.right;n++)this.ghosts.get(placeKey(s,n))===e&&this.ghosts.delete(placeKey(s,n));e.spill=void 0,e.blocked=void 0,this.spills.delete(e),this.stopped.delete(e)}clearSpills(){for(const e of[...this.spills,...this.stopped])e.spill=void 0,e.blocked=void 0;this.spills.clear(),this.stopped.clear(),this.ghosts.clear(),this.reach=void 0}tighten(){this.reach=void 0}spillReach(){if(this.reach)return this.reach;const e={columns:new Map,bottom:-1,right:-1};for(const{spill:t}of this.spills)t&&F(e,t);return this.reach=e,e}hasFormulas(e){return this.expand(),this.grid.hasFormulas(e)}span(e,t,s){this.expand();const n=this.grid.first(e),i=this.grid.last(e);if(this.spills.size===0)return[Math.max(t,n),Math.min(s,i)];const[r,a]=this.spillReach().columns.get(e)??[1/0,-1];return[Math.max(t,Math.min(n,r)),Math.min(s,Math.max(i,a))]}get columnsUsed(){return this.expand(),this.spills.size===0?this.grid.width:Math.max(this.grid.width,this.spillReach().right+1)}get lastRow(){return this.expand(),this.spills.size===0?this.lowest:Math.max(this.lowest,this.spillReach().bottom)}get used(){const e=this.lastRow,t=this.columnsUsed-1;return e<0||t<0?void 0:{top:0,left:0,bottom:e,right:t}}tableAt(e,t){return this.tables.find(s=>y(s.area,e,t))}blockAt(e,t){return this.blocks.find(s=>y(s.area,e,t))}looks(){if(this.lookAreas)return this.lookAreas;const e=[];for(const s of this.spec.format??[]){const n=$(s.range);n&&e.push({area:n,entry:s})}const t=[];for(const[s,n]of Object.entries(this.spec.cells??{})){if(!s.includes(":")||n===null||typeof n!="object")continue;const i=$(s);i&&t.push({area:i,entry:n})}return this.lookAreas={formats:e,ranges:t},this.lookAreas}styledAreas(){const{formats:e,ranges:t}=this.looks();return[...e,...t.filter(s=>Object.keys(s.entry).some(n=>N.has(n)))]}lookAt(e,t){const s={},n=c=>{if(c)for(const[b,w]of Object.entries(c))N.has(b)&&w!==void 0&&(s[b]=b==="border"?{...s.border,...w}:w)},i=this.implied.get(placeKey(e,t));i!==void 0&&(s.format=i);const r=this.ghosts.size===0?void 0:this.spillAt(e,t),a=r&&this.lookAt(r.row,r.col).format;a!==void 0&&(s.format=a),this.spec.columns&&n(this.spec.columns[z(t)]),this.spec.rows&&n(this.spec.rows[String(e+1)]);const o=this.tableAt(e,t);o&&e>o.at.row&&n(o.columns[t-o.at.col]?.spec);const{formats:f,ranges:h}=this.looks();for(const c of f)y(c.area,e,t)&&n(c.entry);for(const c of h)y(c.area,e,t)&&n(c.entry);const d=this.keys.get(placeKey(e,t)),g=d===void 0?void 0:this.spec.cells?.[d];if(g!==null&&typeof g=="object"&&n(g),s.border){const c=Object.entries(s.border).filter(([,b])=>b?.style!=="none");c.length===0?delete s.border:s.border=Object.fromEntries(c)}return s}mergeAt(e,t){return this.merges.find(s=>y(s,e,t))}validationAt(e,t){return this.validations.find(s=>s.areas.some(n=>y(n,e,t)))}filterHeadAt(e,t){return this.filters.find(s=>e===s.area.top&&t>=s.area.left&&t<=s.area.right)}filterAt(e,t){return this.filters.find(s=>y(s.area,e,t))}filesAt(e,t){const s=this.tableAt(e,t);if(s&&e>s.at.row){const n=s.columns[t-s.at.col]?.spec?.files;if(n!==void 0)return n}return s?.at.row===e?void 0:this.spec.columns?.[z(t)]?.files}}export const filesSeparator=l=>(typeof l=="object"?l.separator:void 0)??P;export function filesIn(l,e){const t=filesSeparator(e);return l.split(t.trim()===""?t:t.trim()).map(s=>s.trim()).filter(s=>s!=="")}const N=new Set(["bold","italic","underline","strike","font","size","color","fill","align","valign","wrap","shrink","indent","rotation","border","format"]);export class Workbook{title;sheets=[];names=new Map;checks=[];bySheet=new Map;byTable=new Map;file;generated;ordinary=[];constructor(e,t){this.file=e,this.title=e.title,this.generated=t}respec(e){this.file=O(e,this.generated).file,this.title=e.title,this.sheets.forEach(t=>{const s=e.sheets.find(n=>n.name===t.name);s&&t.respec(s)})}sheet(e){return this.bySheet.get(e.toLowerCase())}table(e){return this.byTable.get(e.toLowerCase())}name(e,t){const s=e.toLowerCase();return(t?.names.size?t.names.get(s):void 0)??this.names.get(s)}definitions(e){const t=e.toLowerCase(),s=[],n=this.names.get(t);n&&s.push(n);for(const i of this.sheets){const r=i.names.get(t);r&&s.push(r)}return s}get tables(){return[...this.byTable.values()]}addSheet(e){this.sheets.push(e),this.bySheet.set(e.name.toLowerCase(),e)}addTable(e){e.sheet.tables.push(e),this.byTable.set(e.name.toLowerCase(),e)}sourceOf(e,t,s){if(e.generated)return{file:R};const n=this.sheets.indexOf(e),i=e.tableAt(t,s);if(i){const o=i.columns[s-i.at.col],f=t-i.at.row-1,h=o?.csv!==void 0&&(i.records[f]?.[o.csv]??"")!=="";return f>=0&&o?.formula&&!h?o.formula.source:{file:i.file,line:f<0?1:i.lines[f]??1}}const r=e.blockAt(t,s);if(r)return{file:r.file,line:r.lines[t-r.area.top]??1};const a=e.keys.get(placeKey(t,s));if(a!==void 0)return{file:A,path:["sheets",n,"cells",a]};for(const o of Object.keys(e.spec.cells??{})){if(!o.includes(":"))continue;const f=$(o);if(f&&y(f,t,s))return{file:A,path:["sheets",n,"cells",o]}}}}export const MAX_FILL_CELLS=5e6;const q=/^[\p{L}_\\][\p{L}\p{N}_.\\?]*$/u;export function validName(l){return q.test(l)&&E(l)===void 0&&!/^(?:TRUE|FALSE)$/iu.test(l)&&!/^[Rr](?:\d+)?(?:[Cc]\d*)?$/u.test(l)&&!/^[Cc]\d*$/u.test(l)}const M="made",k=l=>l[0]===M?R:A;class T{problems=[];wb;read_;lineOf;own;madeNames;constructor(e,t,s,n,i){this.wb=e,this.read_=t,this.lineOf=s,this.own=n,this.madeNames=i}yaml(e,t){const s=this.lineOf(e);this.problems.push({file:k(e),...s===void 0?{}:{line:s},message:t})}sheetPath(e){return e<this.own?["sheets",e]:[M,"sheets",e-this.own]}read(){const{file:e}=this.wb;e.sheets.forEach((t,s)=>{const n=this.sheetPath(s);if(this.wb.sheet(t.name)){this.yaml([...n,"name"],`two sheets are named ${t.name}`);return}(/[\\/?*[\]:]/u.test(t.name)||t.name.length>31)&&this.yaml([...n,"name"],`${t.name} cannot be a sheet's name: at most 31 characters, none of \\ / ? * [ ] :`);const i=new Worksheet(t.name,this.wb.sheets.length,t);i.generated=s>=this.own,this.wb.addSheet(i)}),this.names();for(const[t,s]of e.sheets.entries()){const n=this.wb.sheets[t];n?.spec===s&&this.sheet(n,this.sheetPath(t))}e.checks?.forEach((t,s)=>{const n={file:A,path:["checks",s,"formula"]};this.wb.checks.push({name:t.name,formula:new SharedFormula(t.formula,0,0,n),source:n})})}names(){const{file:e}=this.wb;this.namesOf(e.names,e.hidden_names,t=>this.madeNames.has(t)?[M,"names",t]:["names",t],this.wb.names,void 0),e.sheets.forEach((t,s)=>{const n=this.wb.sheets[s];n?.spec===t&&this.namesOf(t.names,t.hidden_names,i=>[...this.sheetPath(s),"names",i],n.names,n)})}namesOf(e,t,s,n,i){const r=new Set(t?.map(a=>a.toLowerCase()));for(const[a,o]of Object.entries(e??{})){const f=s(a);if(!validName(a)){this.yaml(f,`${a} cannot be a name`);continue}const h={file:k(f),path:f},d=typeof o=="string"&&o.startsWith("=")?{name:a,formula:new SharedFormula(o,0,0,h),source:h}:{name:a,value:typeof o=="string"?x(o).value:o,source:h};i&&(d.sheet=i),r.has(a.toLowerCase())&&(d.hidden=!0),n.set(a.toLowerCase(),d)}}sheet(e,t){const{spec:s}=e;if(s.freeze!==void 0){const n=E(s.freeze);n?e.freeze=n:this.yaml([...t,"freeze"],`${s.freeze} is not a cell`)}s.tables?.forEach((n,i)=>{this.table(e,n,[...t,"tables",i])});for(const[n,i]of e.tables.entries())for(const r of e.tables.slice(n+1))v(i.area,r.area)&&this.problems.push({file:A,message:`tables ${i.name} and ${r.name} overlap on ${e.name}`});s.blocks?.forEach((n,i)=>{this.block(e,n.at,n.rows,[...t,"blocks",i])}),this.cells(e,s.cells??{},[...t,"cells"]),s.merges?.forEach((n,i)=>{const r=$(n);r?e.merges.push(r):this.yaml([...t,"merges",i],`${n} is not a range`)}),s.format?.forEach((n,i)=>{$(n.range)||this.yaml([...t,"format",i,"range"],`${n.range} is not a range`)}),s.conditional?.forEach((n,i)=>{this.condition(e,n,[...t,"conditional",i])}),s.validations?.forEach((n,i)=>{this.validation(e,n,[...t,"validations",i])}),this.filters(e,t),s.charts?.forEach((n,i)=>{this.chart(e,n,i,[...t,"charts",i])});for(const n of Object.keys(s.columns??{}))C(n)===void 0&&this.yaml([...t,"columns",n],`${n} is not a column`);for(const n of Object.keys(s.rows??{}))(!/^[1-9]\d*$/u.test(n)||Number(n)>B)&&this.yaml([...t,"rows",n],`${n} is not a row`)}chart(e,t,s,n){const i=W(t,s,n,(r,a)=>{this.yaml(r,a)});i&&e.charts.push(i)}bound(e,t,s){if(!(typeof e!="string"||!e.startsWith("=")||e.length<2))return new SharedFormula(e,t?.top??0,t?.left??0,{file:k(s),path:s})}condition(e,t,s){const n=j(t.range);if(!n){this.yaml([...s,"range"],`${t.range} is not a range`);return}const[i]=n,r=[],a=(o,f)=>{const h=this.bound(o,i,f);h&&r.push(h)};if(t.type==="expression"){const o=t.formula.startsWith("=")?t.formula:`=${t.formula}`;a(o,[...s,"formula"])}if(t.type==="cellIs"&&t.formula.forEach((o,f)=>{a(o,[...s,"formula",f])}),t.type==="dataBar")for(const o of["min","max"])a(t[o]?.value,[...s,o,"value"]);(t.type==="colorScale"||t.type==="iconSet")&&t.stops?.forEach((o,f)=>{a(o.value,[...s,"stops",f,"value"])}),e.conditions.push({spec:t,areas:n,formulas:r})}validation(e,t,s){const n=j(t.range);if(!n){this.yaml([...s,"range"],`${t.range} is not a range`);return}const i=(t.formula??[]).map((o,f)=>this.bound(o,n[0],[...s,"formula",f])),r=t.formula?.length??0,a=t.type!=="list"&&t.type!=="custom"&&(t.operator===void 0||t.operator==="between"||t.operator==="notBetween");!(t.type==="list"&&t.values!==void 0)&&r<(a?2:1)&&this.yaml(s,`a ${t.type} validation needs its bounds`),e.validations.push({spec:t,areas:n,formulas:i})}filters(e,t){const{spec:s}=e;if(s.filter){const n=[...t,"filter"],i=$(s.filter.range);if(!i)this.yaml([...n,"range"],`${s.filter.range} is not a range`);else{const r=new Map;for(const[o,f]of Object.entries(s.filter.columns??{})){const h=C(o);h===void 0||h<i.left||h>i.right?this.yaml([...n,"columns",o],`${o} is not a column of ${s.filter.range}`):r.set(h,f)}const a=e.tables.find(o=>v(o.area,i));a&&this.yaml(n,`a filter over table ${a.name}: a table has its own`),e.filters.push({area:i,columns:r})}}e.tables.forEach((n,i)=>{const{filter:r}=n.spec;if(r===!1)return;const a=new Map;for(const[o,f]of Object.entries(r?.columns??{})){const h=n.column(o);h?a.set(n.at.col+h.index,f):this.yaml([...t,"tables",i,"filter","columns",o],`table ${n.name} has no column ${o}`)}e.filters.push({area:n.area,table:n,columns:a})})}csv(e,t,s){const n=this.read_(e);return n||this.yaml(t,`${s}: ${e} is not there`),n}overlapping(e,t){const s=e.tables.find(i=>v(i.area,t));if(s)return`table ${s.name}`;const n=e.blocks.find(i=>v(i.area,t));return n?`the block of ${n.file}`:void 0}typed(e,t,s,n,i){if(n.formula!==void 0){const r=new SharedFormula(n.formula,t,s,i),a=new FormulaCell(r,e,t,s);n.start!==void 0&&(a.value=n.start),e.put(t,s,a);return}n.value!==null&&(e.put(t,s,n.value),n.format!==void 0&&e.implied.set(placeKey(t,s),n.format))}table(e,t,s){const n=E(t.at);if(!n){this.yaml([...s,"at"],`${t.at} is not a cell`);return}if(!validName(t.name)){this.yaml([...s,"name"],`${t.name} cannot be a table's name`);return}if(this.wb.table(t.name)){this.yaml([...s,"name"],`two tables are named ${t.name}`);return}this.wb.name(t.name)&&this.yaml([...s,"name"],`${t.name} is a defined name and a table's`);const i=new Table(t.name,e,n,t.rows,t),r=this.csv(t.rows,[...s,"rows"],`table ${t.name}`),a=r?.rows??[],o=r?.lines??[],f=a[0],h=o[0]??1,d=new Set,g=f?.length===0?[""]:f??[];g.forEach((u,m)=>{const p=u.trim();p===""&&this.problems.push({file:t.rows,line:h,message:`column ${String(m+1)} has no name`}),d.has(p.toLowerCase())&&this.problems.push({file:t.rows,line:h,message:`two columns are named ${p}`}),d.add(p.toLowerCase()),i.columns.push({name:p,index:i.columns.length,csv:m})});for(const[u,m]of Object.entries(t.columns??{})){const p=i.column(u),S=p??{name:u,index:i.columns.length};p||(m.formula===void 0&&this.yaml([...s,"columns",u],`table ${t.name} has no column ${u}`),i.columns.push(S)),S.spec=m}const c=g.length;for(let u=1;u<a.length;u++){const m=a[u];if(!m||m.length===0)continue;const p=o[u]??u+1;i.places.push(u),i.records.push(m),i.lines.push(p),m.length>c&&this.problems.push({file:t.rows,line:p,message:`this row has ${String(m.length)} fields and the header ${String(c)}`})}i.rows=i.records.length;const b=this.overlapping(e,i.area);b&&this.yaml(s,`table ${t.name} overlaps ${b} on ${e.name}`),this.wb.addTable(i),this.tableKey(i,s);const w=n.row+1;i.columns.forEach(u=>{const m=n.col+u.index;e.put(n.row,m,u.name);const p=u.spec?.formula;p!==void 0&&(u.formula=new SharedFormula(p,w,m,{file:k(s),path:[...s,"columns",u.name,"formula"]}),i.rows>0&&e.fills.push({area:{top:w,left:m,bottom:w+i.rows-1,right:m},shared:u.formula})),u.csv!==void 0&&i.records.forEach((S,L)=>{this.typed(e,w+L,m,x(S[u.csv??0]??""),{file:t.rows,line:i.lines[L]??1})})})}tableKey(e,t){const{key:s}=e.spec;if(s===void 0)return;const n=e.column(s);if(n?.csv===void 0){this.yaml([...t,"key"],`table ${e.name} has no column ${s} in ${e.file}`);return}const i=new Set;e.records.forEach((r,a)=>{const o=r[n.csv??0]??"",f=e.lines[a]??1;o===""?this.problems.push({file:e.file,line:f,message:`this row has no ${s}, table ${e.name}'s key`}):i.has(o)&&this.problems.push({file:e.file,line:f,message:`two rows have the key ${o}`}),i.add(o)})}block(e,t,s,n){const i=E(t);if(!i){this.yaml([...n,"at"],`${t} is not a cell`);return}const r=this.csv(s,[...n,"rows"],"a block");if(!r)return;const a=r.rows,o=a.map((g,c)=>r.lines[c]??c+1),f=a.reduce((g,c)=>Math.max(g,c.length),1),h={top:i.row,left:i.col,bottom:i.row+Math.max(a.length,1)-1,right:i.col+f-1},d=this.overlapping(e,h);d&&this.yaml(n,`the block of ${s} overlaps ${d} on ${e.name}`),e.blocks.push({area:h,file:s,lines:o}),a.forEach((g,c)=>{g.forEach((b,w)=>{this.typed(e,i.row+c,i.col+w,x(b),{file:s,line:o[c]??c+1})})})}cells(e,t,s){const n=[];for(const[i,r]of Object.entries(t)){const a=[...s,i],o=$(i);if(!o){this.yaml(a,`${i} is not a cell or a range`);continue}const f=this.overlapping(e,o);if(f&&this.yaml(a,`${i} overlaps ${f}`),i.includes(":")){const h=(o.bottom-o.top+1)*(o.right-o.left+1);h>MAX_FILL_CELLS?this.yaml(a,`${i} is ${String(h)} cells`):this.fill(e,o,r,a)}else n.push([i,r,{row:o.top,col:o.left}])}for(const[i,r,a]of n){const o=[...s,i],f=K(r),h=placeKey(a.row,a.col);e.keys.set(h,i),f.value===null&&f.formula===void 0&&e.blanks.add(h),this.typed(e,a.row,a.col,f,{file:k(o),path:o});const d=r!==null&&typeof r=="object"?r.name:void 0;d!==void 0&&this.cellName(e,a,d,o)}}cellName(e,t,s,n){if(!validName(s)){this.yaml(n,`${s} cannot be a name`);return}if(this.wb.name(s)){this.yaml(n,`two places are named ${s}`);return}const i={file:k(n),path:n},r=U(t).replace(/^([A-Z]+)(\d+)$/u,"$$$1$$$2"),a=`='${e.name.replaceAll("'","''")}'!${r}`;this.wb.names.set(s.toLowerCase(),{name:s,formula:new SharedFormula(a,0,0,i),source:i})}fill(e,t,s,n){const i=K(s),r={file:k(n),path:n};e.fills.push(i.formula===void 0?{area:t,value:i.value,...i.format===void 0?{}:{format:i.format}}:{area:t,shared:new SharedFormula(i.formula,t.top,t.left,r),...i.start===void 0?{}:{start:i.start}})}}function W(l,e,t,s){const n=E(l.at);if(!n){s([...t,"at"],`${l.at} is not a cell`);return}const i=(o,f)=>{const h=new SharedFormula(chartFormula(o),0,0,{file:k(f),path:f});return h.node&&!I(h.node)&&s(f,`${o} is not a range or a table's column`),h},r=(o,f)=>o?.startsWith("=")===!0?i(o,f):void 0,a=r(l.title,[...t,"title"]);return{spec:l,at:n,index:e,...l.categories===void 0?{}:{categories:i(l.categories,[...t,"categories"])},...a?{title:a}:{},series:l.series.map((o,f)=>{const h=[...t,"series",f],d=r(o.name,[...h,"name"]);return{values:i(o.values,[...h,"values"]),...o.x===void 0?{}:{x:i(o.x,[...h,"x"])},...d?{name:d}:{}}})}}export const chartFormula=l=>l.startsWith("=")?l:`=${l}`;function I(l){switch(l.kind){case"error":case"ref":case"structured":case"name":return!0;case"paren":case"postfix":return I(l.arg);case"binary":return l.op===":"||l.op===",";default:return!1}}function K(l){if(l===null)return{value:null};if(typeof l=="string")return x(l);if(typeof l!="object")return{value:l};if(l.formula!==void 0)return{value:null,formula:l.formula.startsWith("=")?l.formula:`=${l.formula}`,...l.start===void 0?{}:{start:typeof l.start=="string"?x(l.start).value:l.start}};const{value:e}=l;return typeof e=="string"?x(e):{value:e??null}}export function readWorkbook(l){const e=G(l.text),t=a=>a[0]===M?void 0:e.lineOf(a);if(!e.file)return{problems:e.problems,lineOf:t};const s=O(e.file,l.generated),n=new Workbook(s.file,l.generated);n.ordinary=s.ordinary;const i=[],r=new T(n,a=>{const o=l.generated?.csv[a]??l.read(a);if(o===void 0)return;const f=_(o);for(const h of f.problems)i.push({file:a,line:h.line,message:h.message});return{rows:f.records.map(h=>h.end===h.start?[]:h.fields),lines:f.records.map(h=>h.line)}},t,s.own,s.names);return r.read(),{workbook:n,problems:[...i,...r.problems],lineOf:t}}export function workbookOf(l){const e=O(l.file,l.generated),t=new Workbook(e.file,l.generated);return t.ordinary=e.ordinary,new T(t,s=>{const n=l.generated?.csv[s];if(n!==void 0)return{rows:_(n).records.map(r=>r.end===r.start?[]:r.fields),lines:[]};const i=l.rows(s);return i&&{rows:i,lines:[]}},()=>{},e.own,e.names).read(),t}export{D as rangeName};