allyhub 0.12.0 → 0.13.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 (363) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/commands/frames/report.js +1 -1
  3. package/dist/commands/frames.js +11 -11
  4. package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
  5. package/dist/node_modules/@allyhub/audio/dist/render.js +1 -1
  6. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  7. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  8. package/dist/node_modules/@allyhub/build/dist/media.js +1 -1
  9. package/dist/node_modules/@allyhub/build/package.json +1 -1
  10. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  11. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  12. package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
  13. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +3 -2
  14. package/dist/node_modules/@allyhub/chart/dist/chart.js +2 -1
  15. package/dist/node_modules/@allyhub/chart/dist/color.js +2 -0
  16. package/dist/node_modules/@allyhub/chart/dist/index.js +1 -1
  17. package/dist/node_modules/@allyhub/chart/dist/svg.js +1 -1
  18. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  19. package/dist/node_modules/@allyhub/check/package.json +1 -1
  20. package/dist/node_modules/@allyhub/cloud/dist/call.js +1 -1
  21. package/dist/node_modules/@allyhub/cloud/dist/records.d.ts +1 -1
  22. package/dist/node_modules/@allyhub/cloud/dist/uploads.d.ts +1 -1
  23. package/dist/node_modules/@allyhub/cloud/dist/uploads.js +1 -1
  24. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  25. package/dist/node_modules/@allyhub/components/package.json +1 -1
  26. package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
  27. package/dist/node_modules/@allyhub/dev-server/dist/server.js +1 -1
  28. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  29. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  30. package/dist/node_modules/@allyhub/doc/package.json +1 -1
  31. package/dist/node_modules/@allyhub/doc-extension/package.json +1 -1
  32. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  33. package/dist/node_modules/@allyhub/export/package.json +1 -1
  34. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  35. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  36. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +130 -0
  37. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.js +1 -1
  38. package/dist/node_modules/@allyhub/formats/dist/data/gen.d.ts +3 -1
  39. package/dist/node_modules/@allyhub/formats/dist/data/gen.js +1 -1
  40. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +512 -166
  41. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  42. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +2523 -136
  43. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  44. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +931 -87
  45. package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
  46. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  47. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  48. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  49. package/dist/node_modules/@allyhub/image-extension/package.json +1 -1
  50. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  51. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  52. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  53. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  54. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  55. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  56. package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -1
  57. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  58. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  59. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  60. package/dist/node_modules/@allyhub/media/dist/run.d.ts +6 -1
  61. package/dist/node_modules/@allyhub/media/dist/run.js +2 -2
  62. package/dist/node_modules/@allyhub/media/package.json +1 -1
  63. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  64. package/dist/node_modules/@allyhub/model/package.json +1 -1
  65. package/dist/node_modules/@allyhub/ooxml/dist/color.js +1 -1
  66. package/dist/node_modules/@allyhub/ooxml/dist/ext.js +1 -1
  67. package/dist/node_modules/@allyhub/ooxml/dist/index.js +1 -1
  68. package/dist/node_modules/@allyhub/ooxml/dist/transform.js +2 -0
  69. package/dist/node_modules/@allyhub/ooxml/package.json +5 -1
  70. package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +4 -4
  71. package/dist/node_modules/@allyhub/piece/dist/media.d.ts +2 -2
  72. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  73. package/dist/node_modules/@allyhub/project/dist/part-keys.js +1 -1
  74. package/dist/node_modules/@allyhub/project/package.json +1 -1
  75. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +35 -0
  76. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  77. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +19 -0
  78. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  79. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +35 -20
  80. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  81. package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +3 -3
  82. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +28 -2
  83. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  84. package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
  85. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +73 -10
  86. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  87. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +9 -9
  88. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  89. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  90. package/dist/node_modules/@allyhub/render/package.json +1 -1
  91. package/dist/node_modules/@allyhub/report-extension/dist/cli/find.js +1 -1
  92. package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +3 -3
  93. package/dist/node_modules/@allyhub/report-extension/dist/cli/picture.js +29 -1
  94. package/dist/node_modules/@allyhub/report-extension/package.json +1 -1
  95. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +11 -4
  96. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.css +6 -2
  97. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +1 -1
  98. package/dist/node_modules/@allyhub/report-extension/styles/allyhub/tokens.js +3 -1
  99. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  100. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  101. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  102. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  103. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  104. package/dist/node_modules/@allyhub/sheet/dist/annotations.js +2 -0
  105. package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
  106. package/dist/node_modules/@allyhub/sheet/dist/api/index.js +1 -1
  107. package/dist/node_modules/@allyhub/sheet/dist/api/rules.js +1 -1
  108. package/dist/node_modules/@allyhub/sheet/dist/api/styles.js +1 -1
  109. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
  110. package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
  111. package/dist/node_modules/@allyhub/sheet/dist/data-tools.js +2 -0
  112. package/dist/node_modules/@allyhub/sheet/dist/edit.js +1 -1
  113. package/dist/node_modules/@allyhub/sheet/dist/fill.js +1 -1
  114. package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
  115. package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.js +1 -1
  116. package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
  117. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  118. package/dist/node_modules/@allyhub/sheet/dist/outline.js +2 -0
  119. package/dist/node_modules/@allyhub/sheet/dist/rich.js +2 -0
  120. package/dist/node_modules/@allyhub/sheet/dist/rules.js +1 -1
  121. package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
  122. package/dist/node_modules/@allyhub/sheet/dist/table-styles.js +1 -1
  123. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  124. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  125. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  126. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  127. package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.js +2 -0
  128. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  129. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  130. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  131. package/dist/node_modules/@allyhub/sheet-extension/package.json +1 -1
  132. package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
  133. package/dist/node_modules/@allyhub/slides-core/dist/api.js +3 -3
  134. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  135. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
  136. package/dist/node_modules/@allyhub/slides-core/dist/check.js +1 -1
  137. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  138. package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
  139. package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.js +2 -0
  140. package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
  141. package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
  142. package/dist/node_modules/@allyhub/slides-core/dist/numbering.js +2 -0
  143. package/dist/node_modules/@allyhub/slides-core/dist/office.js +1 -1
  144. package/dist/node_modules/@allyhub/slides-core/dist/patterns.js +2 -0
  145. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  146. package/dist/node_modules/@allyhub/slides-core/dist/script.js +2 -2
  147. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
  148. package/dist/node_modules/@allyhub/slides-core/dist/table-style.js +2 -0
  149. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  150. package/dist/node_modules/@allyhub/slides-extension/dist/deck-pptx.js +1 -1
  151. package/dist/node_modules/@allyhub/slides-extension/dist/workspace.js +1 -1
  152. package/dist/node_modules/@allyhub/slides-extension/package.json +1 -1
  153. package/dist/node_modules/@allyhub/slides-pptx/dist/audio-icon.js +2 -0
  154. package/dist/node_modules/@allyhub/slides-pptx/dist/import/code.js +3 -3
  155. package/dist/node_modules/@allyhub/slides-pptx/dist/import/index.js +2 -2
  156. package/dist/node_modules/@allyhub/slides-pptx/dist/import/script.js +1 -1
  157. package/dist/node_modules/@allyhub/slides-pptx/dist/read/chart.js +2 -1
  158. package/dist/node_modules/@allyhub/slides-pptx/dist/read/common.js +1 -1
  159. package/dist/node_modules/@allyhub/slides-pptx/dist/read/index.js +2 -2
  160. package/dist/node_modules/@allyhub/slides-pptx/dist/read/shapes.js +1 -1
  161. package/dist/node_modules/@allyhub/slides-pptx/dist/read/table.js +1 -1
  162. package/dist/node_modules/@allyhub/slides-pptx/dist/read/text.js +1 -1
  163. package/dist/node_modules/@allyhub/slides-pptx/dist/read/timing.js +1 -1
  164. package/dist/node_modules/@allyhub/slides-pptx/dist/shapes.js +1 -1
  165. package/dist/node_modules/@allyhub/slides-pptx/dist/table-styles.js +2 -0
  166. package/dist/node_modules/@allyhub/slides-pptx/dist/text.js +1 -1
  167. package/dist/node_modules/@allyhub/slides-pptx/dist/theme.js +1 -1
  168. package/dist/node_modules/@allyhub/slides-pptx/dist/timing.js +1 -1
  169. package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
  170. package/dist/node_modules/@allyhub/slides-pptx/dist/xml.js +2 -2
  171. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  172. package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
  173. package/dist/node_modules/@allyhub/slides-runtime/dist/index.js +1 -1
  174. package/dist/node_modules/@allyhub/slides-runtime/dist/ink.js +1 -1
  175. package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +5 -5
  176. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  177. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  178. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  179. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +101 -49
  180. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  181. package/dist/node_modules/@allyhub/telemetry/dist/errors.js +2 -0
  182. package/dist/node_modules/@allyhub/telemetry/package.json +5 -1
  183. package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +1 -1
  184. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  185. package/dist/node_modules/@allyhub/video-extension/dist/inspect/timeline-text.js +1 -1
  186. package/dist/node_modules/@allyhub/video-extension/package.json +3 -3
  187. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  188. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  189. package/dist/node_modules/@allyhub/website/package.json +1 -1
  190. package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
  191. package/dist/node_modules/@allyhub/x-extension/package.json +1 -1
  192. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  193. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  194. package/dist/package.json +12 -12
  195. package/editor-web/assets/{abnfDiagram-WEYOIA3C-BKmMA6gn.js → abnfDiagram-WEYOIA3C-D70jg8mE.js} +1 -1
  196. package/editor-web/assets/{architecture-WOLXFQ4H-BEFBgb4k.js → architecture-WOLXFQ4H-CrXS3E8e.js} +1 -1
  197. package/editor-web/assets/{architectureDiagram-ZHVYKT53-_u5YfCjY.js → architectureDiagram-ZHVYKT53-JrBljCOx.js} +1 -1
  198. package/editor-web/assets/arrow-down-DzZjFrBL.js +1 -0
  199. package/editor-web/assets/arrow-up-hdmh9LVD.js +1 -0
  200. package/editor-web/assets/{article-BUmD3xtR.js → article-BWrfVMRA.js} +6 -6
  201. package/editor-web/assets/article-hxHjqzV1.js +7 -0
  202. package/editor-web/assets/{audio-lines-CzuzsGjI.js → audio-lines-1s1eRs4Q.js} +1 -1
  203. package/editor-web/assets/{blockDiagram-RJAE7QA3-DybfaO3Z.js → blockDiagram-RJAE7QA3-BzfC1xTS.js} +1 -1
  204. package/editor-web/assets/{bookmark-Dsd3kHJJ.js → bookmark-Dfji3syX.js} +1 -1
  205. package/editor-web/assets/{button-eGxLxbv9.js → button-EftXSfev.js} +1 -1
  206. package/editor-web/assets/{c4Diagram-XDPPPE54-BfqLHB5i.js → c4Diagram-XDPPPE54-s2TpXKgH.js} +1 -1
  207. package/editor-web/assets/calc-worker-jImBXoeb.js +45 -0
  208. package/editor-web/assets/channel-BFbXY6R0.js +1 -0
  209. package/editor-web/assets/chart-BC3kUUDD.js +2 -0
  210. package/editor-web/assets/{chart-no-axes-column-BVkeF_Mr.js → chart-no-axes-column-CJmeYOSo.js} +1 -1
  211. package/editor-web/assets/{chunk-2E7WHVMD-BVp1I_d0.js → chunk-2E7WHVMD-DyE9v6UX.js} +1 -1
  212. package/editor-web/assets/{chunk-4EMNKR2T-CTdgWEMr.js → chunk-4EMNKR2T-CCunMMcT.js} +1 -1
  213. package/editor-web/assets/{chunk-55XCU76K-7pnsxeaP.js → chunk-55XCU76K-CZgJYrN4.js} +1 -1
  214. package/editor-web/assets/{chunk-7S6XSTFO-Dc0Dvkq7.js → chunk-7S6XSTFO-B01FlTFf.js} +1 -1
  215. package/editor-web/assets/{chunk-AQDTSKZB-VAILIsfx.js → chunk-AQDTSKZB-latWUvVu.js} +1 -1
  216. package/editor-web/assets/{chunk-DSNLSHJZ-CUDx1Rv5.js → chunk-DSNLSHJZ-BHFiQInN.js} +1 -1
  217. package/editor-web/assets/{chunk-HAGFOTED-DAoEe-dJ.js → chunk-HAGFOTED-C4hR36ab.js} +1 -1
  218. package/editor-web/assets/{chunk-HNE4Q36P-g0akya12.js → chunk-HNE4Q36P-CNrxiD2Q.js} +1 -1
  219. package/editor-web/assets/{chunk-NQOKRVIF-hTGjzXdJ.js → chunk-NQOKRVIF-DpyEHKEY.js} +1 -1
  220. package/editor-web/assets/{chunk-UHW7PFBP-BgLV8BIJ.js → chunk-UHW7PFBP-SIEJdixh.js} +1 -1
  221. package/editor-web/assets/{chunk-VQ5W62QI-Bw19OOSD.js → chunk-VQ5W62QI-CxWnQRxx.js} +1 -1
  222. package/editor-web/assets/{chunk-WQQL4CDK-CMST9dyE.js → chunk-WQQL4CDK-CbRuCBm6.js} +1 -1
  223. package/editor-web/assets/{chunk-YZO67HFG-Bbpu36XF.js → chunk-YZO67HFG-Cgu-EQvs.js} +1 -1
  224. package/editor-web/assets/{chunk-ZAUX2LTX-C48Ri0Gs.js → chunk-ZAUX2LTX-pAl5CV3o.js} +1 -1
  225. package/editor-web/assets/{chunk-ZCHMQSOR-DN1g01Oe.js → chunk-ZCHMQSOR-Du5hY-FP.js} +1 -1
  226. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-U6jbPr2d.js → classDiagram-v2-4MYWR3UA-CevU94T6.js} +1 -1
  227. package/editor-web/assets/{collaborator-B1u2td9m.js → collaborator-C6IJkcGR.js} +1 -1
  228. package/editor-web/assets/copy-DvOiv9Ra.js +1 -0
  229. package/editor-web/assets/{createLucideIcon-GFZ_fxLc.js → createLucideIcon-REX213UO.js} +1 -1
  230. package/editor-web/assets/{cynefin-EF2NZ3EQ-gzkai_7-.js → cynefin-EF2NZ3EQ-DBHwpMRJ.js} +1 -1
  231. package/editor-web/assets/{cynefinDiagram-WF24UDRP-DtSekSr6.js → cynefinDiagram-WF24UDRP-CxUzpjvG.js} +1 -1
  232. package/editor-web/assets/{dagre-NK4GIZVX-CiUwYVT6.js → dagre-NK4GIZVX-BAJNBDYO.js} +1 -1
  233. package/editor-web/assets/{diagram-CBK3MWTC-r9XHCV-k.js → diagram-CBK3MWTC-BQW9Fbw-.js} +1 -1
  234. package/editor-web/assets/{diagram-I5XIIV2D-DxVsDZ34.js → diagram-I5XIIV2D-DQBROUfn.js} +1 -1
  235. package/editor-web/assets/{diagram-ODIL2UCW-B0eNQoHV.js → diagram-ODIL2UCW-DEoK31qy.js} +1 -1
  236. package/editor-web/assets/{diagram-PFBEJUXE-C7f2MfJT.js → diagram-PFBEJUXE-BTCa2We1.js} +1 -1
  237. package/editor-web/assets/{diagram-RJA3I4VV-CSXcnvct.js → diagram-RJA3I4VV-DNM8qWC3.js} +1 -1
  238. package/editor-web/assets/{diagram-TYUNFSNR-DXzOD_ii.js → diagram-TYUNFSNR-BcKpED4d.js} +1 -1
  239. package/editor-web/assets/dist-90dg0B0d.js +2 -0
  240. package/editor-web/assets/dist-BSPs7tZR.js +1 -0
  241. package/editor-web/assets/dist-CP9XwbBS.js +45 -0
  242. package/editor-web/assets/dist-CRxtC7DG.js +24 -0
  243. package/editor-web/assets/{dist-CC7OeU1e.js → dist-Cmnq14RO.js} +3 -3
  244. package/editor-web/assets/dist-CrZwqOm2.js +1 -0
  245. package/editor-web/assets/dist-CzUWTcvC.js +38 -0
  246. package/editor-web/assets/dist-D2a_y4AE.js +1 -0
  247. package/editor-web/assets/{dist-DDv_SbKw.js → dist-DMZ1VHPK.js} +1 -1
  248. package/editor-web/assets/dist-DYnXIW8F.js +16 -0
  249. package/editor-web/assets/{dist-BuWaZ3Y4.js → dist-Dpet39Yp.js} +30 -30
  250. package/editor-web/assets/dist-Dre4Cwpz.js +1 -0
  251. package/editor-web/assets/dist-RkxskWGK.js +5 -0
  252. package/editor-web/assets/dist-aANR6S2I.js +3 -0
  253. package/editor-web/assets/{dist-Gz6NDS0J.js → dist-qSuFWuVB.js} +3 -3
  254. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-Cs4YRvDD.js → ebnfDiagram-V4P3TTPT-D-1x27Eh.js} +1 -1
  255. package/editor-web/assets/{elk-QONTBCTQ-Bh3LZ9WI.js → elk-QONTBCTQ-BJSCxiTH.js} +1 -1
  256. package/editor-web/assets/{erDiagram-KYQIGQAA-C4vYTYXp.js → erDiagram-KYQIGQAA-C7Q357iD.js} +1 -1
  257. package/editor-web/assets/{eventmodeling-K75KTNOO-BN1kkHWS.js → eventmodeling-K75KTNOO-kXrQLSF5.js} +1 -1
  258. package/editor-web/assets/flowDiagram-IUGLLWBU-GSC4btef.js +1 -0
  259. package/editor-web/assets/{ganttDiagram-R7GPNTJY-CA1LkkC5.js → ganttDiagram-R7GPNTJY-Bt3SRgK7.js} +1 -1
  260. package/editor-web/assets/{gitGraph-VSP46ZUC-Dy5tA7dG.js → gitGraph-VSP46ZUC-DS4CkhfK.js} +1 -1
  261. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-hJIB8EkH.js → gitGraphDiagram-PDYL7XHY-BgfmSVdI.js} +1 -1
  262. package/editor-web/assets/group-pebHQTdP.js +1 -0
  263. package/editor-web/assets/{hint-B8JpEypy.js → hint-BmRKl2nL.js} +1 -1
  264. package/editor-web/assets/index-D8qc_ipi.js +28 -0
  265. package/editor-web/assets/index-DDtZpLDF.css +2 -0
  266. package/editor-web/assets/{info-OHQRW6UA-DvzSf7rQ.js → info-OHQRW6UA-BZjctF3x.js} +1 -1
  267. package/editor-web/assets/{infoDiagram-MVDRKAX5-BjIMm4Af.js → infoDiagram-MVDRKAX5-BAp5oUXk.js} +1 -1
  268. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-Bpz71S40.js → ishikawaDiagram-HPEHV2GE-DGL7ZfUu.js} +1 -1
  269. package/editor-web/assets/{italic-D10w8n6C.js → italic-CtlNOXN9.js} +1 -1
  270. package/editor-web/assets/{journeyDiagram-BOSHW7O7-DAB-pZjD.js → journeyDiagram-BOSHW7O7-DOOoBGx-.js} +1 -1
  271. package/editor-web/assets/{kanban-definition-FNSA4HC5-cYeyh3P6.js → kanban-definition-FNSA4HC5-lbLuUiMW.js} +1 -1
  272. package/editor-web/assets/katex-UWCZofcd.js +257 -0
  273. package/editor-web/assets/{link-BC5xK1-1.js → link-CW2KxKT_.js} +1 -1
  274. package/editor-web/assets/{mermaid-parser.core-req5LE0X.js → mermaid-parser.core-RkCFmJcg.js} +3 -3
  275. package/editor-web/assets/{mermaid.core-zFwZug4C.js → mermaid.core-BVUl-afX.js} +4 -4
  276. package/editor-web/assets/{mindmap-definition-6OY57UG3-TStWb7DG.js → mindmap-definition-6OY57UG3-C3DC4T1J.js} +1 -1
  277. package/editor-web/assets/minus-D1tgAHbU.js +1 -0
  278. package/editor-web/assets/{packet-JDAUHWVQ-smFhVKcB.js → packet-JDAUHWVQ-Bkd6YpX8.js} +1 -1
  279. package/editor-web/assets/{palette-BIOudGkm.js → palette-INFK0Zsr.js} +1 -1
  280. package/editor-web/assets/{pegDiagram-ECIUJNBX-DvSNRv0-.js → pegDiagram-ECIUJNBX-B5Seh4Oe.js} +1 -1
  281. package/editor-web/assets/{pie-XZMESJXO-qjaGsBZG.js → pie-XZMESJXO-BNbb4Q8k.js} +1 -1
  282. package/editor-web/assets/{pieDiagram-GNMPY74T-Dd9P-Pdc.js → pieDiagram-GNMPY74T-_hnbUloZ.js} +1 -1
  283. package/editor-web/assets/play-DvMyq5xW.js +1 -0
  284. package/editor-web/assets/{progress-DE4C5_3x.js → progress-D6wSFdpY.js} +1 -1
  285. package/editor-web/assets/props-form-BfwEi6jW.js +1 -0
  286. package/editor-web/assets/{quadrantDiagram-D57K4MC3-h2IIKUUA.js → quadrantDiagram-D57K4MC3-1rbqW-KO.js} +1 -1
  287. package/editor-web/assets/{radar-ABXABTNO-DlVrSA1d.js → radar-ABXABTNO-BWSnhBSp.js} +1 -1
  288. package/editor-web/assets/{railroad-I3PHUGI6-nFbuLAtc.js → railroad-I3PHUGI6-BNB-OKs1.js} +1 -1
  289. package/editor-web/assets/{railroad-abnf-LNEFI6M7-Daj8h2iV.js → railroad-abnf-LNEFI6M7-BKgidf_B.js} +1 -1
  290. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-eYJyl5PH.js → railroad-ebnf-DWYD2UWJ-CNCnxtHp.js} +1 -1
  291. package/editor-web/assets/{railroad-peg-JR7BVNR7-BTRhKZQq.js → railroad-peg-JR7BVNR7-CyBW6_0o.js} +1 -1
  292. package/editor-web/assets/{railroadDiagram-Y72NRBL7-CeLGUjdp.js → railroadDiagram-Y72NRBL7-Cud3SJ7O.js} +1 -1
  293. package/editor-web/assets/{react-WA6wlt8S.js → react-Bk7NnOLX.js} +1 -1
  294. package/editor-web/assets/{repeat-2-VQP1EVOZ.js → repeat-2-DfPmKp4w.js} +1 -1
  295. package/editor-web/assets/{requirementDiagram-EQYSW5RA-Dmk9XRM5.js → requirementDiagram-EQYSW5RA-BrSCcpqV.js} +1 -1
  296. package/editor-web/assets/{row-BRlEWRrK.js → row-VwyPfa1b.js} +1 -1
  297. package/editor-web/assets/{sankeyDiagram-SY24JHO5-Yn4zlrAM.js → sankeyDiagram-SY24JHO5-rJV4dJFn.js} +1 -1
  298. package/editor-web/assets/scissors-D9WmgvNP.js +1 -0
  299. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-BTRnp_PW.js → sequenceDiagram-BLEHNHQU-CEUuD2n6.js} +1 -1
  300. package/editor-web/assets/{session-Do9AqS38.js → session-DE0fvAcs.js} +1 -1
  301. package/editor-web/assets/sigma-CY2Chbro.js +1 -0
  302. package/editor-web/assets/slides-BgacyjJW.js +1 -0
  303. package/editor-web/assets/{snapshots-BUGlKQIB.js → snapshots-D8TtZp1x.js} +1 -1
  304. package/editor-web/assets/{sound-Bj3o9_Fa.js → sound-DUCxe9eC.js} +1 -1
  305. package/editor-web/assets/split-Cx2MMnC_.js +3 -0
  306. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-kstrRKv2.js → stateDiagram-v2-A6IESKWZ-BRE_C2he.js} +1 -1
  307. package/editor-web/assets/sticky-note-C5qUDHhC.js +1 -0
  308. package/editor-web/assets/{strikethrough-CfXx6IYH.js → strikethrough-DP-7tMz0.js} +1 -1
  309. package/editor-web/assets/svg-nJtFNJ-7.js +1 -0
  310. package/editor-web/assets/{swatch-WeJD41aW.js → swatch-lxK4C8fD.js} +1 -1
  311. package/editor-web/assets/{swimlanes-B3ENRKFQ-DaZsZkeP.js → swimlanes-B3ENRKFQ-BEPqWgVe.js} +1 -1
  312. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-DAcNszZ6.js +8 -0
  313. package/editor-web/assets/{switch-N0G_sbqt.js → switch-DaG6OuAi.js} +1 -1
  314. package/editor-web/assets/{syntax-oWsKBWFw.js → syntax-9LD8MzGy.js} +1 -1
  315. package/editor-web/assets/{syntax-BVsgRJ4I.js → syntax-CLaCSmoi.js} +1 -1
  316. package/editor-web/assets/{table-B6hVZAMi.js → table-CTjNpE4W.js} +1 -1
  317. package/editor-web/assets/tabs-DjhzblAG.js +1 -0
  318. package/editor-web/assets/{textarea-tEWvBY9p.js → textarea-DBwRbOyF.js} +1 -1
  319. package/editor-web/assets/{timeline-definition-JXYKGLGB-CLCvY-Yf.js → timeline-definition-JXYKGLGB-p8Qeg4pS.js} +1 -1
  320. package/editor-web/assets/{trash-2-BP6nqpg2.js → trash-2-DrnRa91l.js} +1 -1
  321. package/editor-web/assets/{treeView-D4JQ5SDB-BmN0gwdC.js → treeView-D4JQ5SDB-C9FTdXKq.js} +1 -1
  322. package/editor-web/assets/{treemap-SAJKECNS-DN29G_E_.js → treemap-SAJKECNS-XAeLVOtI.js} +1 -1
  323. package/editor-web/assets/{undo-2-CHR0nvWL.js → undo-2-DUGGyBdX.js} +1 -1
  324. package/editor-web/assets/{usecaseDiagram-WPOLBNNX-DTRS54cB.js → usecaseDiagram-WPOLBNNX-BV3AMRuH.js} +1 -1
  325. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-DAAc11Hx.js → vennDiagram-Q3Y3IDCW-CJdKcYyA.js} +1 -1
  326. package/editor-web/assets/{video-BlvmR8BK.js → video-He8p6dr6.js} +1 -1
  327. package/editor-web/assets/{wardley-7MLQ67FV-B-UYkmdB.js → wardley-7MLQ67FV-DZh6Mf22.js} +1 -1
  328. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-BmbwCaky.js → wardleyDiagram-IVAIDKWA-XtvKSX-m.js} +1 -1
  329. package/editor-web/assets/{words-D_4T9Adq.js → words-CPHp_0tt.js} +1 -1
  330. package/editor-web/assets/{words-WgdEQdYP.js → words-CjW-1tZI.js} +1 -1
  331. package/editor-web/assets/{xychartDiagram-4URNHDU4-ChAfAq1U.js → xychartDiagram-4URNHDU4-CGkL42sz.js} +1 -1
  332. package/editor-web/assets/zoom-in-C4lxmIDE.js +1 -0
  333. package/editor-web/index.html +6 -6
  334. package/package.json +2 -2
  335. package/editor-web/assets/arrow-up-B5rJbBv0.js +0 -1
  336. package/editor-web/assets/article-DNioBb3p.js +0 -7
  337. package/editor-web/assets/calc-worker-D2pGis6e.js +0 -45
  338. package/editor-web/assets/channel-TNPgFDrw.js +0 -1
  339. package/editor-web/assets/chart-C37xvZT2.js +0 -1
  340. package/editor-web/assets/dist-BGRwhCQO.js +0 -1
  341. package/editor-web/assets/dist-BW4X7BrF.js +0 -1
  342. package/editor-web/assets/dist-BgDRE85b.js +0 -2
  343. package/editor-web/assets/dist-Blq5nJnU.js +0 -24
  344. package/editor-web/assets/dist-C1emZ9wX.js +0 -37
  345. package/editor-web/assets/dist-CX-fiPSn.js +0 -38
  346. package/editor-web/assets/dist-C_VvG-_9.js +0 -5
  347. package/editor-web/assets/dist-Ce7HrBxv.js +0 -3
  348. package/editor-web/assets/dist-D2k6w-_a.js +0 -1
  349. package/editor-web/assets/dist-DEoEO4zs.js +0 -1
  350. package/editor-web/assets/dist-DlDxxPIP.js +0 -16
  351. package/editor-web/assets/flowDiagram-IUGLLWBU-B04NGsyi.js +0 -1
  352. package/editor-web/assets/index-CgB5osVc.js +0 -28
  353. package/editor-web/assets/index-Daytem9N.css +0 -2
  354. package/editor-web/assets/katex-5Z2zF-9g.js +0 -257
  355. package/editor-web/assets/minus-DaWs5i8B.js +0 -1
  356. package/editor-web/assets/play-CrMmPghG.js +0 -1
  357. package/editor-web/assets/props-form-CsmDBqzy.js +0 -1
  358. package/editor-web/assets/schemas-VikZYZIK.js +0 -1
  359. package/editor-web/assets/slides-diTEQ3C5.js +0 -1
  360. package/editor-web/assets/split-CNU1RHcX.js +0 -3
  361. package/editor-web/assets/svg-Cx50MpxK.js +0 -1
  362. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CBZAujYY.js +0 -8
  363. package/editor-web/assets/tabs-DIFDqj-l.js +0 -1
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{inputOf as y,refused as g,writeCells as q}from"./edit.js";import{moveFormula as x}from"./formula/move.js";import{parseFormula as A}from"./formula/parse.js";import{printFormula as C}from"./formula/print.js";import{CellError as E}from"./values.js";const $=t=>t===null?"":typeof t=="string"?`s${t.toLowerCase()}`:t instanceof E?`e${t.code}`:`${typeof t}${String(t)}`;export function uniqueRows(t,o){const i=new Set;return t.map(e=>{const s=(o.length===0?e.map((l,n)=>n):o).map(l=>$(e[l]??null)).join("\0");return i.has(s)?!1:(i.add(s),!0)})}function F(t,o){if(o===0||!t.startsWith("="))return t;const i=A(t);return i.ok?C(x(i.node,o,0)):t}export function removeDuplicates(t,o,i,e,u){const s=t.workbook.sheet(i);if(!s)return{...g("no-sheet"),duplicates:0,unique:0};const l=u.header?e.top+1:e.top,n=e.right-e.left+1,r=[],p=[];for(let f=l;f<=e.bottom;f++)r.push(Array.from({length:n},(m,w)=>o.value(s,f,e.left+w))),p.push(Array.from({length:n},(m,w)=>y(t,s,f,e.left+w)));const c=uniqueRows(r,u.columns.map(f=>f-e.left)),d=[];let h=l;c.forEach((f,m)=>{const w=l+m;f&&(w!==h&&p[m]?.forEach((k,b)=>{d.push({row:h,col:e.left+b,text:F(k,h-w)})}),h+=1)});for(let f=h;f<=e.bottom;f++)for(let m=0;m<n;m++)d.push({row:f,col:e.left+m,text:""});const a=h-l;return{...q(t,i,d),duplicates:c.length-a,unique:a}}export function splitText(t,o){if(o.widths&&o.widths.length>0){const n=[...new Set(o.widths)].filter(c=>c>0).sort((c,d)=>c-d),r=[];let p=0;for(const c of n)r.push(t.slice(p,c).trim()),p=c;return r.push(t.slice(p).trim()),r}const i=o.delimiters??[];if(i.length===0)return[t];const e=[];let u="",s=!1,l=!1;for(let n=0;n<t.length;n++){const r=t.charAt(n);if(o.qualifier&&r===o.qualifier){s&&t.charAt(n+1)===o.qualifier?(u+=r,n+=1):s=!s,l=!1;continue}if(!s&&i.includes(r)){o.consecutive===!0&&l||e.push(u),u="",l=!0;continue}u+=r,l=!1}return e.push(u),e}export function textToColumns(t,o,i,e,u){const s=t.workbook.sheet(i);if(!s)return g("no-sheet");const l=u.destination??{row:e.top,col:e.left},n=[];for(let r=e.top;r<=e.bottom;r++){const p=o.value(s,r,e.left);if(p===null)continue;const c=typeof p=="string"?p:y(t,s,r,e.left);splitText(c,u).forEach((d,h)=>{n.push({row:l.row+r-e.top,col:l.col+h,text:d})})}return n.length===0?g("no-data"):q(t,i,n)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as K,MAX_ROWS as R,cellName as N,columnLetter as C,contains as q,overlaps as O,rangeName as M,readAddress as X,readArea as j}from"./address.js";import{moveFormula as z}from"./formula/move.js";import{parseFormula as D}from"./formula/parse.js";import{printFormula as G}from"./formula/print.js";import{freeColumn as B,duplicated as H,restructure as F,uniqueColumn as I,withColumnsUpTo as A}from"./structure.js";import{readTyped as T}from"./values.js";import{FormulaCell as P,placeKey as V,validName as J}from"./workbook.js";export const BLOCK_CELLS=100;const _=(n,o)=>n.top<=o.top&&n.left<=o.left&&n.bottom>=o.bottom&&n.right>=o.right,S=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o)),Q=n=>S(n,"formula"),b=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o));export const blankEdit=()=>({rows:new Map,cells:[],whole:!1}),refused=n=>({...blankEdit(),refused:n});const v=n=>T(n).formula!==void 0;function Y(n){const o=T(n);return o.formula!==void 0?n:o.value===null?null:o.format!==void 0?n:typeof o.value=="number"||typeof o.value=="boolean"?o.value:n}const Z=n=>n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).filter(([o])=>o!=="value"&&o!=="formula")):{};export class Draft{book;specs=new Map;file;fileChanged=!1;grown=new Map;added=new Map;edit=blankEdit();constructor(o){this.book=o,this.file=o.file}spec(o){let e=this.specs.get(o.index);if(!e){const t=this.file.sheets.findIndex(s=>s.name===o.name);e={...this.file.sheets[t]??{name:o.name}},this.specs.set(o.index,e),this.fileChanged||(this.file={...this.file,sheets:[...this.file.sheets]},this.fileChanged=!0),this.file.sheets[t]=e}return e}table(o,e){const t=this.spec(o),s=[...t.tables??[]],r=s.findIndex(l=>l.name===e.name),i={...s[r]??e.spec};return s[r]=i,t.tables=s,i}rows(o){const e=this.edit.rows.get(o);if(e)return e;const t=[...this.book.rows.get(o)??[]];return this.edit.rows.set(o,t),t}setField(o,e,t,s){const r=this.rows(o),i=[...r[e]??[]];for(;i.length<=t;)i.push("");return i[t]=s,r[e]=i,i}rowsOf(o){return this.grown.get(o)??o.rows}grow(o,e,t){this.grown.set(o,this.rowsOf(o)+1);const s=this.added.get(o)??new Map;s.set(e,t),this.added.set(o,s)}addedAt(o,e,t){for(const[s,r]of this.added){const i=r.get(e);if(i!==void 0&&s.sheet===o&&t>=s.at.col&&t<s.at.col+s.columns.length)return{table:s,record:i}}}finish(){return this.fileChanged&&(this.edit.file=this.file),this.edit}}function ee(n,o,e,t){return o.tables.find(s=>{const r=s.at.row+n.rowsOf(s)+1;if(e!==r)return!1;const i=s.at.col+s.columns.length-1;if(t<s.at.col||t>i)return!1;for(let l=s.at.col;l<=i;l++)if(o.at(e,l)!==void 0)return!1;return!0})}function te(n,o,e){return n.tables.find(t=>{const{top:s,bottom:r,right:i}=t.area;if(e!==i+1||o<s||o>r)return!1;for(let l=s;l<=r;l++)if(n.at(l,e)!==void 0)return!1;return!0})}export const movedTo=(n,o,e)=>{const t=D(n);return t.ok?G(z(t.node,o,e)):n};function E(n,o,e,t,s,r){const i=e.at.row+1,l=n.table(o,e),f=movedTo(r,i-s,0);if(l.columns={...l.columns,[t.name]:{...l.columns?.[t.name],formula:f}},t.csv!==void 0){const c=e.places[s-i];c!==void 0&&n.setField(e.file,c,t.csv,"")}n.edit.whole=!0}function ne(n,o,e,t){const{csv:s}=e;if(s===void 0)return!1;const r=n.rows(o.file);return o.places.some((i,l)=>l!==t&&(r[i]?.[s]??"")!=="")}function oe(n,o,e,t,s){const r=s.trim();if(r==="")return refused("column-name");if(r===t.name)return n.finish();const i=e.columns.filter(c=>c!==t).map(c=>c.name),l=I(i,r),f=F(o,{op:"rename-column",table:e.name,from:t.name,to:l});return{...blankEdit(),file:f.file,rows:new Map(f.rows),whole:!0}}function se(n,o,e,t,s,r){const i=e.columns[s-e.at.col];if(!i)return;const l=t-e.at.row-1;if(v(r)){if(i.formula){E(n,o,e,i,t,r);return}if(!ne(n,e,i,l)){E(n,o,e,i,t,r);return}n.edit.offer={sheet:o.name,row:t,col:s,text:r}}const c=e.places[l];if(c===void 0)return;let d=i.csv;if(d===void 0){if(r==="")return;const w=e.columns.map(p=>p.name);n.edit.rows.set(e.file,A(n.rows(e.file),w,i.index)),n.edit.whole=!0,d=i.index}const a=n.setField(e.file,c,d,r);n.edit.cells.push({sheet:o,row:t,col:s,...r===""&&i.formula?{column:i.formula}:{input:r},record:{table:e,index:l,fields:a}})}function re(n,o,e,t,s){const r=n.rows(o.file),i=Math.max(r[0]?.length??1,1),l=new Array(i).fill(""),f=o.columns[t-o.at.col];f?.csv!==void 0&&(l[f.csv]=s),r.push(l),n.grow(o,e,r.length-1),n.edit.whole=!0}function ie(n,o,e,t,s){const r=n.table(o,e),i=e.columns.map(w=>w.name),l=t===e.at.row,f=l?I(i,s.trim()===""?B(i):s.trim()):B(i);if(n.edit.whole=!0,!l&&v(s)){r.columns={...r.columns,[f]:{formula:movedTo(s,e.at.row+1-t,0)}};return}const c=i.length,d=A(n.rows(e.file),i,c-1),a=d[0];if(a&&a.push(f),d.forEach((w,p)=>{p>0&&w.length>0&&w.push("")}),!l){const w=e.places[t-e.at.row-1],p=w===void 0?void 0:d[w];p&&(p[c]=s)}n.edit.rows.set(e.file,d)}function le(n,o,e,t,s,r,i){n.setField(e,s-t.top,r-t.left,i),n.edit.cells.push({sheet:o,row:s,col:r,input:i})}function fe(n,o,e){return Object.keys(n.spec.cells??{}).some(t=>{if(!t.includes(":"))return!1;const s=j(t);return s!==void 0&&q(s,o,e)})}function ce(n,o,e,t,s){const r=n.spec(o),i=N({row:e,col:t});let l={...r.cells};const f=l[i],c=f===void 0?{}:Z(f),d=Y(s),a=Object.keys(c).length===0;let w;if(d===null){const p=fe(o,e,t);w=!a||p,a&&!p?l=b(l,i):l[i]=a?null:c}else w=!0,l[i]=a?d:{...c,...v(s)?{formula:s}:{value:d}};r.cells=l,Object.keys(l).length===0&&delete r.cells,n.edit.cells.push({sheet:o,row:e,col:t,input:s,key:w?i:null})}export function writeOne(n,o,e,t,s,r){const i=n.addedAt(e,t,s);if(i){const{csv:c}=i.table.columns[s-i.table.at.col]??{};c!==void 0&&n.setField(i.table.file,i.record,c,r);return}const l=e.tableAt(t,s);if(l){const c=l.columns[s-l.at.col];if(t===l.at.row)return c?oe(n,o,l,c,r):void 0;se(n,e,l,t,s,r);return}if(r!==""){const c=ee(n,e,t,s);if(c){re(n,c,t,s,r);return}const d=te(e,t,s);if(d){ie(n,e,d,t,r);return}}const f=e.blockAt(t,s);f?le(n,e,f.file,f.area,t,s,r):ce(n,e,t,s,r)}export function writeCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const{row:r,col:i,text:l}of[...e].sort((f,c)=>f.row-c.row||f.col-c.col)){const f=writeOne(s,n,t,r,i,l);if(f)return f}return s.finish()}export function overwriteColumn(n,o,e,t,s){const r=n.workbook.sheet(o),i=r?.tableAt(e,t);if(!r||!i)return refused("no-sheet");const l=i.columns[t-i.at.col];if(!l)return refused("no-sheet");const f=new Draft(n);E(f,r,i,l,e,s);const{csv:c}=l;if(c!==void 0)for(const d of i.places)f.setField(i.file,d,c,"");return f.finish()}function*ue(n,o){const e=Math.min(o.right,n.columnsUsed-1);for(let t=o.left;t<=e;t++){const[s,r]=n.span(t,o.top,o.bottom);for(let i=s;i<=r;i++)n.at(i,t)!==void 0&&(yield[i,t])}}export function clearCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const r of t.tables){const{top:i,bottom:l}=r.data;if(!(l<i||e.top>i||e.bottom<l))for(const f of r.columns){const c=r.at.col+f.index;if(c<e.left||c>e.right||!f.formula)continue;const d=s.table(t,r),a=r.columns.map(L=>L.name);f.csv===void 0&&s.edit.rows.set(r.file,A(s.rows(r.file),a,f.index));const w=Q(d.columns?.[f.name]??{}),p=b(d.columns??{},f.name);d.columns=Object.keys(w).length>0?{...p,[f.name]:w}:p,Object.keys(d.columns).length===0&&delete d.columns,s.edit.whole=!0}}for(const[r,i]of ue(t,e)){if(t.tableAt(r,i)?.at.row===r)continue;const l=writeOne(s,n,t,r,i,"");if(l)return l}return s.finish()}export function dropKeys(n,o){n.cells&&(n.cells=Object.fromEntries(Object.entries(n.cells).filter(([e])=>{const t=j(e);return!t||!_(o,t)})))}export function fillCells(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");if(!r.tables.some(f=>O(f.area,t))&&!r.blocks.some(f=>O(f.area,t))&&v(s)){const f=new Draft(n),c=f.spec(r);dropKeys(c,t);const d=movedTo(s,t.top-e.row,t.left-e.col),a=M(t);return c.cells={...c.cells,[a]:d},f.edit.whole=!0,f.finish()}const l=[];for(let f=t.top;f<=t.bottom;f++)for(let c=t.left;c<=t.right;c++)f===e.row&&c===e.col||l.push({row:f,col:c,text:v(s)?movedTo(s,f-e.row,c-e.col):s});return writeCells(n,o,l)}export function writeBlockOf(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");const i=new Draft(n),l=i.spec(r);return l.blocks=[...l.blocks??[],{at:N(e),rows:s}],i.edit.rows.set(s,t),i.edit.whole=!0,i.finish()}const $=(n,o)=>Object.keys(o).some(e=>e in n),x=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>!(e in o)));function de(n){if(n===null||typeof n!="object")return n;const o=Object.keys(n);return o.length===1&&o[0]==="value"?n.value??null:o.length===1&&o[0]==="formula"?n.formula??null:n}const me={bold:!1,italic:!1,underline:!1,strike:!1,wrap:!1,align:"general",format:"General",color:"#000000",fill:"#FFFFFF",font:"Calibri",size:11,border:{left:{style:"none"},right:{style:"none"},top:{style:"none"},bottom:{style:"none"}}};function ae(n,o,e,t){for(const[s,r]of Object.entries(n.columns??{})){const i=X(`${s}1`)?.col;if(i!==void 0&&i>=e.left&&i<=e.right&&t in r)return!0}for(const[s,r]of Object.entries(n.rows??{})){const i=Number(s)-1;if(i>=e.top&&i<=e.bottom&&t in r)return!0}return o.tables.some(s=>O(s.area,e)&&s.columns.some(r=>r.spec!==void 0&&t in r.spec&&s.at.col+r.index>=e.left&&s.at.col+r.index<=e.right))}export function setLook(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n);return applyLook(r,s,e,t),r.finish()}export function applyLook(n,o,e,t){const s=n.spec(o);he(n,o,s,e,t),tidied(s)}function he(n,o,e,t,s){if(e.cells){const u={...e.cells},m=[];for(const[g,h]of Object.entries(u)){if(h===null||typeof h!="object"||!$(h,s))continue;const y=j(g);!y||!O(y,t)||(g.includes(":")&&!_(t,y)&&m.push({range:g,...Object.fromEntries(Object.entries(h).filter(([W])=>W in s))}),u[g]=de(x(h,s)))}e.cells=u,m.length>0&&(e.format=[...e.format??[],...m])}const r=e.format??[],i=u=>{const m=j(u.range);return m!==void 0&&O(m,t)},l=r.some(u=>i(u)&&$(u,s)),f=Object.fromEntries(Object.entries(s).filter(([,u])=>u!==void 0)),c=t.top===0&&t.bottom===R-1,d=t.left===0&&t.right===K-1;if(c&&!d&&!l){let u={...e.columns};for(let m=t.left;m<=t.right;m++){const g=C(m),h={...x(u[g]??{},s),...f};u=Object.keys(h).length===0?b(u,g):{...u,[g]:h}}e.columns=u;return}if(d&&!c&&!l){let u={...e.rows};for(let m=t.top;m<=t.bottom;m++){const g=String(m+1),h={...x(u[g]??{},s),...f};u=Object.keys(h).length===0?b(u,g):{...u,[g]:h}}e.rows=u;return}const a=o.tables.find(u=>u.rows>0&&t.top===u.data.top&&t.bottom===u.data.bottom&&t.left>=u.area.left&&t.right<=u.area.right);if(a&&!l){const u=n.table(o,a);let m={...u.columns};for(let g=t.left;g<=t.right;g++){const h=a.columns[g-a.at.col]?.name;if(h===void 0)continue;const y={...x(m[h]??{},s),...f};m=Object.keys(y).length===0?b(m,h):{...m,[h]:y}}u.columns=m,Object.keys(m).length===0&&delete u.columns,n.edit.whole=!0;return}const w=M(t),p=r.find(u=>{const m=j(u.range);return m!==void 0&&M(m)===w}),U=(p?r.slice(r.indexOf(p)+1):[]).some(u=>i(u)&&$(u,s)),k={};for(const[u,m]of Object.entries(s)){const g=r.some(h=>h!==p&&i(h)&&u in h)||ae(e,o,t,u);m!==void 0?k[u]=m:g&&(k[u]=me[u])}if(p&&!U){const u={...x(p,s),...k};e.format=r.flatMap(m=>m!==p?[m]:Object.keys(u).length>1?[u]:[])}else Object.keys(k).length>0&&(e.format=[...r,{range:w,...k}])}export function tidied(n){n.format?.length===0&&delete n.format,n.columns&&Object.keys(n.columns).length===0&&delete n.columns,n.rows&&Object.keys(n.rows).length===0&&delete n.rows,n.cells&&Object.keys(n.cells).length===0&&delete n.cells}export function setColumnWidth(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=C(e),f=S(i.columns?.[l]??{},"width"),c=t===void 0?f:{...f,width:t},d=b(i.columns??{},l);return i.columns=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function setRowHeight(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=String(e+1),f=S(i.rows?.[l]??{},"height"),c=t===void 0?f:{...f,height:t},d=b(i.rows??{},l);return i.rows=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function sheetNameProblem(n,o,e){if(o.trim()===""||o.length>31||/[\\/?*[\]:]/u.test(o)||o.startsWith("'")||o.endsWith("'"))return"sheet-name";const t=n.workbook.sheet(o);if(t&&t.name!==e)return"sheet-taken"}export function renameSheet(n,o,e){const t=sheetNameProblem(n,e,o);if(t)return refused(t);const s=F(n,{op:"rename-sheet",from:o,to:e});return{...blankEdit(),file:s.file,rows:new Map(s.rows),whole:!0}}export function addSheet(n,o,e){const t=sheetNameProblem(n,o);if(t)return refused(t);const s=[...n.file.sheets],r=s.findIndex(i=>i.name===e);return s.splice(r<0?s.length:r+1,0,{name:o}),{...blankEdit(),file:{...n.file,sheets:s},whole:!0}}export function copyName(n,o){for(let e=2;;e++){const t=` (${String(e)})`,s=o.slice(0,31-t.length).trimEnd()+t;if(!n.workbook.sheet(s))return s}}export function duplicateSheet(n,o){const e=H(n,o,copyName(n,o));return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function deleteSheet(n,o){const e=F(n,{op:"delete-sheet",name:o});if(e.refused)return refused(e.refused);const t=we(n.file,e.file);for(const s of t)e.rows.delete(s);return{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0,...t.length===0?{}:{removed:t}}}function we(n,o){const e=s=>s.sheets.flatMap(r=>[...(r.tables??[]).map(i=>i.rows),...(r.blocks??[]).map(i=>i.rows)]),t=new Set(e(o));return[...new Set(e(n))].filter(s=>!t.has(s))}export function moveSheet(n,o,e){const t=[...n.file.sheets],s=t.findIndex(i=>i.name===o),[r]=t.splice(s,1);return r?(t.splice(e,0,r),{...blankEdit(),file:{...n.file,sheets:t},whole:!0}):refused("no-sheet")}export function bandEdit(n,o){const e=F(n,o);return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function defineName(n,o,e,t){if(!J(o)||n.workbook.name(o)||n.workbook.table(o))return refused("name-invalid");const s=(l,f)=>`$${C(f)}$${String(l+1)}`,r=t.top===t.bottom&&t.left===t.right?s(t.top,t.left):`${s(t.top,t.left)}:${s(t.bottom,t.right)}`,i=/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)?e:`'${e.replaceAll("'","''")}'`;return{...blankEdit(),file:{...n.file,names:{...n.file.names,[o]:`=${i}!${r}`}},whole:!0}}export function inputOf(n,o,e,t){const s=o.at(e,t);if(s===void 0)return"";if(s instanceof P)return s.text;const r=o.tableAt(e,t);if(r){const d=r.columns[t-r.at.col];if(e===r.at.row)return d?.name??"";const a=d?.csv===void 0?void 0:r.records[e-r.at.row-1]?.[d.csv];if(a!==void 0)return a}const i=o.blockAt(e,t);if(i){const d=n.rows.get(i.file)?.[e-i.area.top]?.[t-i.area.left];if(d!==void 0)return d}const l=o.keys.get(V(e,t)),f=l===void 0?void 0:o.spec.cells?.[l],c=f!==null&&typeof f=="object"?f.value:f;return c!=null?String(c):typeof s=="object"?s.code:String(s)}export function exceptionsOf(n){const o=[];for(const e of n.columns){const{csv:t}=e;!e.formula||t===void 0||n.records.forEach((s,r)=>{const i=s[t]??"";i!==""&&o.push({row:n.at.row+1+r,col:n.at.col+e.index,column:e.name,text:i})})}return o}
2
+ import{MAX_COLUMNS as P,MAX_ROWS as V,cellName as S,columnLetter as $,contains as J,overlaps as k,rangeName as E,readAddress as Q,readArea as v}from"./address.js";import{moveFormula as Y}from"./formula/move.js";import{parseFormula as Z}from"./formula/parse.js";import{printFormula as ee}from"./formula/print.js";import{freeColumn as K,duplicated as te,restructure as _,uniqueColumn as q,withColumnsUpTo as T}from"./structure.js";import{RUN_FIELDS as ne,joinedRuns as oe,plainRuns as D,runsWithout as se}from"./rich.js";import{CellError as re,readTyped as C}from"./values.js";import{FormulaCell as ie,placeKey as le,runsText as N,validName as X}from"./workbook.js";export const BLOCK_CELLS=100;const z=(n,o)=>n.top<=o.top&&n.left<=o.left&&n.bottom>=o.bottom&&n.right>=o.right,R=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o)),fe=n=>R(n,"formula"),O=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o));export const blankEdit=()=>({rows:new Map,cells:[],whole:!1}),refused=n=>({...blankEdit(),refused:n});const x=n=>C(n).formula!==void 0;function ce(n){const o=C(n);return o.formula!==void 0?n:o.value===null?null:o.format!==void 0?n:typeof o.value=="number"||typeof o.value=="boolean"?o.value:n}const I=n=>n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).filter(([o])=>o!=="value"&&o!=="formula"&&o!=="runs")):{};export class Draft{book;specs=new Map;file;fileChanged=!1;grown=new Map;added=new Map;edit=blankEdit();constructor(o){this.book=o,this.file=o.file}spec(o){let e=this.specs.get(o.index);if(!e){const t=this.file.sheets.findIndex(s=>s.name===o.name);e={...this.file.sheets[t]??{name:o.name}},this.specs.set(o.index,e),this.fileChanged||(this.file={...this.file,sheets:[...this.file.sheets]},this.fileChanged=!0),this.file.sheets[t]=e}return e}table(o,e){const t=this.spec(o),s=[...t.tables??[]],r=s.findIndex(l=>l.name===e.name),i={...s[r]??e.spec};return s[r]=i,t.tables=s,i}rows(o){const e=this.edit.rows.get(o);if(e)return e;const t=[...this.book.rows.get(o)??[]];return this.edit.rows.set(o,t),t}setField(o,e,t,s){const r=this.rows(o),i=[...r[e]??[]];for(;i.length<=t;)i.push("");return i[t]=s,r[e]=i,i}rowsOf(o){return this.grown.get(o)??o.rows}grow(o,e,t){this.grown.set(o,this.rowsOf(o)+1);const s=this.added.get(o)??new Map;s.set(e,t),this.added.set(o,s)}addedAt(o,e,t){for(const[s,r]of this.added){const i=r.get(e);if(i!==void 0&&s.sheet===o&&t>=s.at.col&&t<s.at.col+s.columns.length)return{table:s,record:i}}}finish(){return this.fileChanged&&(this.edit.file=this.file),this.edit}}function ue(n,o,e,t){return o.tables.find(s=>{const r=s.at.row+n.rowsOf(s)+1;if(e!==r)return!1;const i=s.at.col+s.columns.length-1;if(t<s.at.col||t>i)return!1;for(let l=s.at.col;l<=i;l++)if(o.at(e,l)!==void 0)return!1;return!0})}function de(n,o,e){return n.tables.find(t=>{const{top:s,bottom:r,right:i}=t.area;if(e!==i+1||o<s||o>r)return!1;for(let l=s;l<=r;l++)if(n.at(l,e)!==void 0)return!1;return!0})}export const movedTo=(n,o,e)=>{const t=Z(n);return t.ok?ee(Y(t.node,o,e)):n};function U(n,o,e,t,s,r){const i=e.at.row+1,l=n.table(o,e),f=movedTo(r,i-s,0);if(l.columns={...l.columns,[t.name]:{...l.columns?.[t.name],formula:f}},t.csv!==void 0){const c=e.places[s-i];c!==void 0&&n.setField(e.file,c,t.csv,"")}n.edit.whole=!0}function ae(n,o,e,t){const{csv:s}=e;if(s===void 0)return!1;const r=n.rows(o.file);return o.places.some((i,l)=>l!==t&&(r[i]?.[s]??"")!=="")}function me(n,o,e,t,s){const r=s.trim();if(r==="")return refused("column-name");if(r===t.name)return n.finish();const i=e.columns.filter(c=>c!==t).map(c=>c.name),l=q(i,r),f=_(o,{op:"rename-column",table:e.name,from:t.name,to:l});return{...blankEdit(),file:f.file,rows:new Map(f.rows),whole:!0}}function he(n,o,e,t,s,r){const i=e.columns[s-e.at.col];if(!i)return;const l=t-e.at.row-1;if(x(r)){if(i.formula){U(n,o,e,i,t,r);return}if(!ae(n,e,i,l)){U(n,o,e,i,t,r);return}n.edit.offer={sheet:o.name,row:t,col:s,text:r}}const c=e.places[l];if(c===void 0)return;let d=i.csv;if(d===void 0){if(r==="")return;const h=e.columns.map(g=>g.name);n.edit.rows.set(e.file,T(n.rows(e.file),h,i.index)),n.edit.whole=!0,d=i.index}const m=n.setField(e.file,c,d,r);n.edit.cells.push({sheet:o,row:t,col:s,...r===""&&i.formula?{column:i.formula}:{input:r},record:{table:e,index:l,fields:m}})}function we(n,o,e,t,s){const r=n.rows(o.file),i=Math.max(r[0]?.length??1,1),l=new Array(i).fill(""),f=o.columns[t-o.at.col];f?.csv!==void 0&&(l[f.csv]=s),r.push(l),n.grow(o,e,r.length-1),n.edit.whole=!0}function pe(n,o,e,t,s){const r=n.table(o,e),i=e.columns.map(h=>h.name),l=t===e.at.row,f=l?q(i,s.trim()===""?K(i):s.trim()):K(i);if(n.edit.whole=!0,!l&&x(s)){r.columns={...r.columns,[f]:{formula:movedTo(s,e.at.row+1-t,0)}};return}const c=i.length,d=T(n.rows(e.file),i,c-1),m=d[0];if(m&&m.push(f),d.forEach((h,g)=>{g>0&&h.length>0&&h.push("")}),!l){const h=e.places[t-e.at.row-1],g=h===void 0?void 0:d[h];g&&(g[c]=s)}n.edit.rows.set(e.file,d)}function be(n,o,e,t,s,r,i){n.setField(e,s-t.top,r-t.left,i),n.edit.cells.push({sheet:o,row:s,col:r,input:i})}function ge(n,o,e){return Object.keys(n.spec.cells??{}).some(t=>{if(!t.includes(":"))return!1;const s=v(t);return s!==void 0&&J(s,o,e)})}function ye(n,o,e,t,s){const r=n.spec(o),i=S({row:e,col:t});let l={...r.cells};const f=l[i];if(f!==null&&typeof f=="object"&&f.runs!==void 0&&N(f.runs)===s){n.edit.cells.push({sheet:o,row:e,col:t,input:s,key:i});return}const c=f===void 0?{}:I(f),d=ce(s),m=Object.keys(c).length===0;let h;if(d===null){const g=ge(o,e,t);h=!m||g,m&&!g?l=O(l,i):l[i]=m?null:c}else h=!0,l[i]=m?d:{...c,...x(s)?{formula:s}:{value:d}};r.cells=l,Object.keys(l).length===0&&delete r.cells,n.edit.cells.push({sheet:o,row:e,col:t,input:s,key:h?i:null})}export function writeOne(n,o,e,t,s,r){const i=n.addedAt(e,t,s);if(i){const{csv:c}=i.table.columns[s-i.table.at.col]??{};c!==void 0&&n.setField(i.table.file,i.record,c,r);return}const l=e.tableAt(t,s);if(l){const c=l.columns[s-l.at.col];if(t===l.at.row)return c?me(n,o,l,c,r):void 0;he(n,e,l,t,s,r);return}if(r!==""){const c=ue(n,e,t,s);if(c){we(n,c,t,s,r);return}const d=de(e,t,s);if(d){pe(n,e,d,t,r);return}}const f=e.blockAt(t,s);f?be(n,e,f.file,f.area,t,s,r):ye(n,e,t,s,r)}export function setRuns(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");const i=oe(s),l=N(i);if(i.length===0||D(i))return writeCells(n,o,[{row:e,col:t,text:l}]);if(r.tableAt(e,t)||r.blockAt(e,t))return refused("rich-loose");const f=new Draft(n),c=f.spec(r),d=S({row:e,col:t}),m=c.cells?.[d],h=m===void 0?{}:I(m);return c.cells={...c.cells,[d]:{...h,runs:i}},f.edit.cells.push({sheet:r,row:e,col:t,input:l,key:d}),f.finish()}function ke(n,o){if(n===null||typeof n!="object"||!n.runs)return n;const e=se(n.runs,o);if(!D(e))return{...n,runs:e};const t=N(e),s=I(n);return C(t).value===t&&C(t).format===void 0?Object.keys(s).length===0?t:{...s,value:t}:{...s,runs:[{text:t}]}}export function writeCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const{row:r,col:i,text:l}of[...e].sort((f,c)=>f.row-c.row||f.col-c.col)){const f=writeOne(s,n,t,r,i,l);if(f)return f}return s.finish()}export function overwriteColumn(n,o,e,t,s){const r=n.workbook.sheet(o),i=r?.tableAt(e,t);if(!r||!i)return refused("no-sheet");const l=i.columns[t-i.at.col];if(!l)return refused("no-sheet");const f=new Draft(n);U(f,r,i,l,e,s);const{csv:c}=l;if(c!==void 0)for(const d of i.places)f.setField(i.file,d,c,"");return f.finish()}function*G(n,o){const e=Math.min(o.right,n.columnsUsed-1);for(let t=o.left;t<=e;t++){const[s,r]=n.span(t,o.top,o.bottom);for(let i=s;i<=r;i++)n.at(i,t)!==void 0&&(yield[i,t])}}export function clearCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const r of t.tables){const{top:i,bottom:l}=r.data;if(!(l<i||e.top>i||e.bottom<l))for(const f of r.columns){const c=r.at.col+f.index;if(c<e.left||c>e.right||!f.formula)continue;const d=s.table(t,r),m=r.columns.map(y=>y.name);f.csv===void 0&&s.edit.rows.set(r.file,T(s.rows(r.file),m,f.index));const h=fe(d.columns?.[f.name]??{}),g=O(d.columns??{},f.name);d.columns=Object.keys(h).length>0?{...g,[f.name]:h}:g,Object.keys(d.columns).length===0&&delete d.columns,s.edit.whole=!0}}for(const[r,i]of G(t,e)){if(t.tableAt(r,i)?.at.row===r)continue;const l=writeOne(s,n,t,r,i,"");if(l)return l}return s.finish()}export function dropKeys(n,o){n.cells&&(n.cells=Object.fromEntries(Object.entries(n.cells).filter(([e])=>{const t=v(e);return!t||!z(o,t)})))}export function fillCells(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");if(!r.tables.some(f=>k(f.area,t))&&!r.blocks.some(f=>k(f.area,t))&&x(s)){const f=new Draft(n),c=f.spec(r);dropKeys(c,t);const d=movedTo(s,t.top-e.row,t.left-e.col),m=E(t);return c.cells={...c.cells,[m]:d},f.edit.whole=!0,f.finish()}const l=[];for(let f=t.top;f<=t.bottom;f++)for(let c=t.left;c<=t.right;c++)f===e.row&&c===e.col||l.push({row:f,col:c,text:x(s)?movedTo(s,f-e.row,c-e.col):s});return writeCells(n,o,l)}export function writeBlockOf(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");const i=new Draft(n),l=i.spec(r);return l.blocks=[...l.blocks??[],{at:S(e),rows:s}],i.edit.rows.set(s,t),i.edit.whole=!0,i.finish()}const W=(n,o)=>Object.keys(o).some(e=>e in n),L=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>!(e in o)));function Oe(n){if(n===null||typeof n!="object")return n;const o=Object.keys(n);return o.length===1&&o[0]==="value"?n.value??null:o.length===1&&o[0]==="formula"?n.formula??null:n}const je={bold:!1,italic:!1,underline:!1,strike:!1,wrap:!1,locked:!0,hide_formula:!1,align:"general",format:"General",color:"#000000",fill:"#FFFFFF",font:"Calibri",size:11,border:{left:{style:"none"},right:{style:"none"},top:{style:"none"},bottom:{style:"none"}}};function ve(n,o,e,t){for(const[s,r]of Object.entries(n.columns??{})){const i=Q(`${s}1`)?.col;if(i!==void 0&&i>=e.left&&i<=e.right&&t in r)return!0}for(const[s,r]of Object.entries(n.rows??{})){const i=Number(s)-1;if(i>=e.top&&i<=e.bottom&&t in r)return!0}return o.tables.some(s=>k(s.area,e)&&s.columns.some(r=>r.spec!==void 0&&t in r.spec&&s.at.col+r.index>=e.left&&s.at.col+r.index<=e.right))}export function setLook(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n);return applyLook(r,s,e,t),r.finish()}export function applyLook(n,o,e,t){const s=n.spec(o);Ce(n,o,s,e,t),tidied(s)}function Ce(n,o,e,t,s){const r=ne.filter(u=>u in s);if(e.cells&&r.length>0)for(const[u,a]of Object.entries(e.cells)){if(a===null||typeof a!="object"||!a.runs)continue;const w=v(u);w&&k(w,t)&&(e.cells={...e.cells,[u]:ke(a,r)})}if(e.cells){const u={...e.cells},a=[];for(const[w,b]of Object.entries(u)){if(b===null||typeof b!="object"||!W(b,s))continue;const j=v(w);!j||!k(j,t)||(w.includes(":")&&!z(t,j)&&a.push({range:w,...Object.fromEntries(Object.entries(b).filter(([H])=>H in s))}),u[w]=Oe(L(b,s)))}e.cells=u,a.length>0&&(e.format=[...e.format??[],...a])}const i=e.format??[],l=u=>{const a=v(u.range);return a!==void 0&&k(a,t)},f=i.some(u=>l(u)&&W(u,s)),c=Object.fromEntries(Object.entries(s).filter(([,u])=>u!==void 0)),d=t.top===0&&t.bottom===V-1,m=t.left===0&&t.right===P-1;if(d&&!m&&!f){let u={...e.columns};for(let a=t.left;a<=t.right;a++){const w=$(a),b={...L(u[w]??{},s),...c};u=Object.keys(b).length===0?O(u,w):{...u,[w]:b}}e.columns=u;return}if(m&&!d&&!f){let u={...e.rows};for(let a=t.top;a<=t.bottom;a++){const w=String(a+1),b={...L(u[w]??{},s),...c};u=Object.keys(b).length===0?O(u,w):{...u,[w]:b}}e.rows=u;return}const h=o.tables.find(u=>u.rows>0&&t.top===u.data.top&&t.bottom===u.data.bottom&&t.left>=u.area.left&&t.right<=u.area.right);if(h&&!f){const u=n.table(o,h);let a={...u.columns};for(let w=t.left;w<=t.right;w++){const b=h.columns[w-h.at.col]?.name;if(b===void 0)continue;const j={...L(a[b]??{},s),...c};a=Object.keys(j).length===0?O(a,b):{...a,[b]:j}}u.columns=a,Object.keys(a).length===0&&delete u.columns,n.edit.whole=!0;return}const g=E(t),y=i.find(u=>{const a=v(u.range);return a!==void 0&&E(a)===g}),A=(y?i.slice(i.indexOf(y)+1):[]).some(u=>l(u)&&W(u,s)),p={};for(const[u,a]of Object.entries(s)){const w=i.some(b=>b!==y&&l(b)&&u in b)||ve(e,o,t,u);a!==void 0?p[u]=a:w&&(p[u]=je[u])}if(y&&!A){const u={...L(y,s),...p};e.format=i.flatMap(a=>a!==y?[a]:Object.keys(u).length>1?[u]:[])}else Object.keys(p).length>0&&(e.format=[...i,{range:g,...p}])}export function tidied(n){n.format?.length===0&&delete n.format,n.columns&&Object.keys(n.columns).length===0&&delete n.columns,n.rows&&Object.keys(n.rows).length===0&&delete n.rows,n.cells&&Object.keys(n.cells).length===0&&delete n.cells}export function setColumnWidth(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=$(e),f=R(i.columns?.[l]??{},"width"),c=t===void 0?f:{...f,width:t},d=O(i.columns??{},l);return i.columns=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function setRowHeight(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=String(e+1),f=R(i.rows?.[l]??{},"height"),c=t===void 0?f:{...f,height:t},d=O(i.rows??{},l);return i.rows=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function sheetNameProblem(n,o,e){if(o.trim()===""||o.length>31||/[\\/?*[\]:]/u.test(o)||o.startsWith("'")||o.endsWith("'"))return"sheet-name";const t=n.workbook.sheet(o);if(t&&t.name!==e)return"sheet-taken"}export function renameSheet(n,o,e){const t=sheetNameProblem(n,e,o);if(t)return refused(t);const s=_(n,{op:"rename-sheet",from:o,to:e});return{...blankEdit(),file:s.file,rows:new Map(s.rows),whole:!0}}export function addSheet(n,o,e){const t=sheetNameProblem(n,o);if(t)return refused(t);const s=[...n.file.sheets],r=s.findIndex(i=>i.name===e);return s.splice(r<0?s.length:r+1,0,{name:o}),{...blankEdit(),file:{...n.file,sheets:s},whole:!0}}export function copyName(n,o){for(let e=2;;e++){const t=` (${String(e)})`,s=o.slice(0,31-t.length).trimEnd()+t;if(!n.workbook.sheet(s))return s}}export function duplicateSheet(n,o){const e=te(n,o,copyName(n,o));return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function deleteSheet(n,o){const e=_(n,{op:"delete-sheet",name:o});if(e.refused)return refused(e.refused);const t=xe(n.file,e.file);for(const s of t)e.rows.delete(s);return{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0,...t.length===0?{}:{removed:t}}}function xe(n,o){const e=s=>s.sheets.flatMap(r=>[...(r.tables??[]).map(i=>i.rows),...(r.blocks??[]).map(i=>i.rows)]),t=new Set(e(o));return[...new Set(e(n))].filter(s=>!t.has(s))}export function moveSheet(n,o,e){const t=[...n.file.sheets],s=t.findIndex(i=>i.name===o),[r]=t.splice(s,1);return r?(t.splice(e,0,r),{...blankEdit(),file:{...n.file,sheets:t},whole:!0}):refused("no-sheet")}export function bandEdit(n,o){const e=_(n,o);return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function defineName(n,o,e,t){if(!X(o)||n.workbook.name(o)||n.workbook.table(o))return refused("name-invalid");const s=(l,f)=>`$${$(f)}$${String(l+1)}`,r=t.top===t.bottom&&t.left===t.right?s(t.top,t.left):`${s(t.top,t.left)}:${s(t.bottom,t.right)}`,i=/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)?e:`'${e.replaceAll("'","''")}'`;return{...blankEdit(),file:{...n.file,names:{...n.file.names,[o]:`=${i}!${r}`}},whole:!0}}export function inputOf(n,o,e,t){const s=o.at(e,t);if(s===void 0)return"";if(s instanceof ie)return s.text;const r=o.tableAt(e,t);if(r){const d=r.columns[t-r.at.col];if(e===r.at.row)return d?.name??"";const m=d?.csv===void 0?void 0:r.records[e-r.at.row-1]?.[d.csv];if(m!==void 0)return m}const i=o.blockAt(e,t);if(i){const d=n.rows.get(i.file)?.[e-i.area.top]?.[t-i.area.left];if(d!==void 0)return d}const l=o.keys.get(le(e,t)),f=l===void 0?void 0:o.spec.cells?.[l],c=f!==null&&typeof f=="object"?f.value:f;return c!=null?String(c):typeof s=="object"?s.code:String(s)}export function exceptionsOf(n){const o=[];for(const e of n.columns){const{csv:t}=e;!e.formula||t===void 0||n.records.forEach((s,r)=>{const i=s[t]??"";i!==""&&o.push({row:n.at.row+1+r,col:n.at.col+e.index,column:e.name,text:i})})}return o}function Le(n){const o=new Set([...n.file.sheets.flatMap(e=>(e.tables??[]).map(t=>t.name)),...Object.keys(n.file.names??{})].map(e=>e.toLowerCase()));for(let e=1;;e++){const t=`Table${String(e)}`;if(!o.has(t.toLowerCase()))return t}}export function makeTable(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");if(s.tables.some(p=>k(p.area,e)))return refused("table-overlap");const r=e.right-e.left+1,i=(p,u)=>inputOf(n,s,p,u);if(!t.header){if(e.top===0)return refused("table-room");for(let p=0;p<r;p++)if(i(e.top-1,e.left+p)!=="")return refused("table-room")}const l=new Draft(n),f=new Set,c=Array.from({length:r},(p,u)=>{const a=t.header?i(e.top,e.left+u).trim():"";let w=a===""?`Column${String(u+1)}`:a;for(let b=2;f.has(w.toLowerCase());b++)w=`${a===""?`Column${String(u+1)}`:a}${String(b)}`;return f.add(w.toLowerCase()),w}),d=t.header?e.top+1:e.top,m=[];for(let p=d;p<=e.bottom;p++)m.push(Array.from({length:r},(u,a)=>i(p,e.left+a)));for(const[p,u]of G(s,e)){const a=writeOne(l,n,s,p,u,"");if(a)return a}const h=Le(n),g=new Set([...n.rows.keys(),...l.edit.rows.keys()].map(p=>p.toLowerCase()));let y=`data/${h.toLowerCase()}.csv`;for(let p=2;g.has(y);p++)y=`data/${h.toLowerCase()}-${String(p)}.csv`;l.edit.rows.set(y,[c,...m]);const M=l.spec(s),A=t.header?e.top:e.top-1;return M.tables=[...M.tables??[],{name:h,at:S({row:A,col:e.left}),rows:y,...t.style!==void 0&&t.style!=="TableStyleMedium2"?{style:t.style}:{}}],l.edit.whole=!0,l.finish()}export function setTableStyle(n,o,e,t){const s=n.workbook.sheet(o),r=s?.tables.find(f=>f.name===e);if(!s||!r)return refused("no-sheet");const i=new Draft(n),l=i.table(s,r);return t==="TableStyleMedium2"?delete l.style:l.style=t,i.edit.whole=!0,i.finish()}export function setTableOptions(n,o,e,t){const s=n.workbook.sheet(o),r=s?.tables.find(f=>f.name===e);if(!s||!r)return refused("no-sheet");const i=new Draft(n),l=i.table(s,r);return t.banded_rows!==void 0&&(t.banded_rows?delete l.banded_rows:l.banded_rows=!1),t.banded_columns!==void 0&&(t.banded_columns?l.banded_columns=!0:delete l.banded_columns),t.first_column!==void 0&&(t.first_column?l.first_column=!0:delete l.first_column),t.last_column!==void 0&&(t.last_column?l.last_column=!0:delete l.last_column),i.edit.whole=!0,i.finish()}function F(n,o){return o===void 0?n.names:n.sheets.find(e=>e.name===o)?.names}function B(n,o,e){const t=Object.keys(e).length===0?void 0:e;if(o===void 0){const s={...n};return t?s.names=t:delete s.names,s}return{...n,sheets:n.sheets.map(s=>{if(s.name!==o)return s;const r={...s};return t?r.names=t:delete r.names,r})}}export function setName(n,o){const e=o.name.trim(),t=o.was!==void 0&&o.was.name.toLowerCase()!==e.toLowerCase(),s=Object.keys(F(n.file,o.scope)??{}).some(d=>d.toLowerCase()===e.toLowerCase()&&!(d.toLowerCase()===o.was?.name.toLowerCase()&&o.was.scope===o.scope));if(!X(e)||s||n.workbook.table(e))return refused("name-invalid");const r=o.value.trim(),i=C(r).value,l=r.startsWith("=")||i instanceof re?r:i,f=t&&o.was?bandEdit(n,{op:"rename-name",from:o.was.name,to:e}):void 0;if(f?.refused)return f;let c=f?.file??n.file;if(o.was){const d={...F(c,o.was.scope)};for(const m of Object.keys(d))m.toLowerCase()===o.was.name.toLowerCase()&&(d[m]=null);c=B(c,o.was.scope,Object.fromEntries(Object.entries(d).filter(([,m])=>m!==null)))}return c=B(c,o.scope,{...F(c,o.scope),[e]:l}),{...blankEdit(),file:c,rows:f?.rows??new Map,whole:!0}}export function deleteName(n,o,e){const t=F(n.file,e)??{},s=Object.fromEntries(Object.entries(t).filter(([r])=>r.toLowerCase()!==o.toLowerCase()));return{...blankEdit(),file:B(n.file,e,s),whole:!0}}
@@ -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 X,contains as v,overlaps as A,rangeName as Y}from"./address.js";import{rectangles as N}from"./api/rectangles.js";import{Draft as E,applyLook as R,blankEdit as I,clearCells as Z,dropKeys as tt,inputOf as U,movedTo as W,refused as x,writeCells as ot,writeOne as et}from"./edit.js";import{relativeKey as nt}from"./formula/move.js";import{parseFormula as q}from"./formula/parse.js";import{printFormula as st}from"./formula/print.js";import{mapNode as rt}from"./formula/walk.js";import{restructure as it}from"./structure.js";import{seriesAfter as lt}from"./series.js";import{readTyped as ct}from"./values.js";import{workbookOf as ft}from"./workbook.js";const K=n=>ct(n).formula!==void 0;function ut(n,e,t){const o=q(n);return o.ok?nt(o.node,e,t):void 0}const at=(n,e)=>!n.tables.some(t=>A(t.area,e))&&!n.blocks.some(t=>A(t.area,e));function pt(n,e,t,o){if(n.some(r=>K(r.text))){const r=n.length;return e.map((f,l)=>{const a=t?n[((r-1-l)%r+r)%r]:n[l%r],b=a?.text??"";return{...f,text:a?W(b,f.row-a.row,f.col-a.col):b}})}const s=lt(n.map(r=>r.text),e.length,{mode:o,back:t});return e.map((r,f)=>({...r,text:s[f]??""}))}const G=["bold","italic","underline","strike","font","size","color","fill","align","valign","wrap","shrink","indent","rotation","border","format"];export const NO_LOOK=Object.fromEntries(G.map(n=>[n,void 0]));export function copyLooks(n,e,t,o){const i=new Map;for(const s of o){const r=e.lookAt(s.from.row,s.from.col),f=t.lookAt(s.to.row,s.to.col);if(JSON.stringify(r)===JSON.stringify(f))continue;const l=JSON.stringify(r),a=i.get(l);a?a.places.push(s.to):i.set(l,{look:r,places:[s.to]})}for(const{look:s,places:r}of i.values()){const f={};for(const l of G)f[l]=s[l];for(const l of N(r))R(n,t,l,f)}}export function autoFill(n,e,t,o,i="auto"){const s=n.workbook.sheet(e);if(!s)return x("no-sheet");const r=o.bottom>t.bottom||o.top<t.top,f=o.top<t.top||o.left<t.left,l=new E(n),a=r?{first:t.left,last:t.right}:{first:t.top,last:t.bottom},b=new Map,g=(u,w)=>{const k=`${String(u)}:${String(w)}`;let m=b.get(k);return m===void 0&&(m=U(n,s,u,w),b.set(k,m)),m},L=(t.bottom-t.top+1)*(t.right-t.left+1),y=new Set;for(let u=t.top;u<=t.bottom;u++)for(let w=t.left;w<=t.right;w++){const k=g(u,w);K(k)&&y.add(ut(k,u,w)??"")}if(y.size===1&&L>0&&at(s,o)&&wt(g,t)){const u=l.spec(s);return tt(u,o),u.cells={...u.cells,[Y(o)]:W(g(t.top,t.left),o.top-t.top,o.left-t.left)},l.edit.whole=!0,H(l,s,t,o,r),l.finish()}for(let u=a.first;u<=a.last;u++){const w=[];if(r)for(let p=t.top;p<=t.bottom;p++)w.push({row:p,col:u,text:g(p,u)});else for(let p=t.left;p<=t.right;p++)w.push({row:u,col:p,text:g(u,p)});const k=[],m=f?r?t.top-1:t.left-1:r?t.bottom+1:t.right+1,O=r?f?o.top:o.bottom:f?o.left:o.right,T=f?-1:1;for(let p=m;f?p>=O:p<=O;p+=T)k.push(r?{row:p,col:u}:{row:u,col:p});for(const p of pt(w,k,f,i))et(l,n,s,p.row,p.col,p.text)}return H(l,s,t,o,r),l.finish()}function wt(n,e){for(let t=e.top;t<=e.bottom;t++)for(let o=e.left;o<=e.right;o++)if(!K(n(t,o)))return!1;return!0}function H(n,e,t,o,i){const s=[],r=t.bottom-t.top+1,f=t.right-t.left+1;for(let l=o.top;l<=o.bottom;l++)for(let a=o.left;a<=o.right;a++){if(v(t,l,a))continue;const b=i?t.top+((l-t.top)%r+r)%r:l,g=i?a:t.left+((a-t.left)%f+f)%f;s.push({from:{row:b,col:g},to:{row:l,col:a}})}copyLooks(n,e,e,s)}export function pasteLooks(n,e,t,o){const i=n.workbook.sheet(e),s=n.workbook.sheet(t);if(!i||!s)return x("no-sheet");const r=new E(n);return copyLooks(r,i,s,o),r.finish()}export function fillDownTo(n,e){const t=(o,i)=>i>=0&&n.at(o,i)!==void 0;for(const o of[e.left-1,e.right+1]){if(!t(e.bottom,o)&&!t(e.bottom+1,o))continue;let i=e.bottom;for(;t(i+1,o);)i+=1;if(i>e.bottom)return i}}function dt(n,e,t){if(!K(n))return n;const o=q(n);if(!o.ok)return n;const i=rt(o.node,s=>s.kind!=="ref"?s:s.sheet===void 0?{...s,sheet:e}:s.sheet.toLowerCase()!==t.toLowerCase()||s.lastSheet!==void 0?s:Object.fromEntries(Object.entries(s).filter(([r])=>r!=="sheet")));return st(i)}function ht(n){const e=I();e.whole=!0;for(const t of n){t.file&&(e.file=t.file);for(const[o,i]of t.rows)e.rows.set(o,i)}return e}function S(n,e){const t=e.file??n.file,o=new Map(n.rows);for(const[i,s]of e.rows)o.set(i,s);return{file:t,rows:o,workbook:ft({file:t,rows:i=>o.get(i)})}}export function moveCells(n,e,t,o,i){const s=n.workbook.sheet(e),r=n.workbook.sheet(o);if(!s||!r)return x("no-sheet");const f=i.row-t.top,l=i.col-t.left;if(f===0&&l===0&&s===r)return I();const a={top:i.row,left:i.col,bottom:t.bottom+f,right:t.right+l},b=s.tables.filter(c=>v(t,c.area.top,c.area.left)&&v(t,c.area.bottom,c.area.right));for(const c of s.tables)if(!b.includes(c)&&A(c.area,t)&&t.top<=c.at.row)return x("table-move");if(b.length>0&&s!==r)return x("table-move");for(const c of r.tables)if(!b.includes(c)&&A(c.area,a)&&a.top<=c.at.row)return x("table-move");const g={op:"move-cells",sheet:e,area:t,rows:f,columns:l,...s===r?{}:{to:o}},L=it(n,g),y={...I(),file:L.file,rows:new Map(L.rows)},u=S(n,y),w=u.workbook.sheet(e),k=u.workbook.sheet(o);if(!w||!k)return x("no-sheet");const m=[],O=[],T=Math.min(t.right,w.columnsUsed-1),p=Math.min(t.bottom,w.lastRow),P=(c,d)=>b.some(h=>v(h.area,c,d));for(let c=t.top;c<=p;c++)for(let d=t.left;d<=T;d++)if(!P(c,d)){if(w.at(c,d)!==void 0){const h=U(u,w,c,d);m.push({row:c+f,col:d+l,text:s===r?h:dt(h,e,o)})}O.push({from:{row:c,col:d},to:{row:c+f,col:d+l}})}const F=Z(u,e,t);if(F.refused!==void 0)return F;const M=S(u,F),j=[y,F];let z=M;if(b.length>0){const c=new E(M),d=M.workbook.sheet(e);if(!d)return x("no-sheet");for(const J of b){const B=d.tables.find(V=>V.name===J.name);if(!B)continue;const Q=c.table(d,B);Q.at=X({row:J.at.row+f,col:J.at.col+l})}const h=c.finish();j.push(h),z=S(M,h)}const C=ot(z,o,m);if(C.refused!==void 0)return C;j.push(C);const D=S(z,C),_=D.workbook.sheet(e),$=D.workbook.sheet(o);if(_&&$){const c=new E(D);copyLooks(c,w,$,O);const d=O.map(h=>h.from).filter(h=>!(s===r&&v(a,h.row,h.col))&&Object.keys(w.lookAt(h.row,h.col)).length>0);for(const h of N(d))R(c,_,h,NO_LOOK);j.push(c.finish())}return ht(j)}
2
+ import{MAX_COLUMNS as et,MAX_ROWS as nt,cellName as W,contains as U,overlaps as T,rangeName as st}from"./address.js";import{rectangles as X}from"./api/rectangles.js";import{Draft as z,applyLook as $,blankEdit as D,clearCells as G,dropKeys as rt,inputOf as B,movedTo as H,refused as M,writeCells as P,writeOne as it}from"./edit.js";import{relativeKey as ct}from"./formula/move.js";import{parseFormula as Q}from"./formula/parse.js";import{printFormula as lt}from"./formula/print.js";import{mapNode as ft}from"./formula/walk.js";import{restructure as V}from"./structure.js";import{seriesAfter as ut}from"./series.js";import{readTyped as pt}from"./values.js";import{workbookOf as dt}from"./workbook.js";const J=s=>pt(s).formula!==void 0;function wt(s,e,t){const o=Q(s);return o.ok?ct(o.node,e,t):void 0}const ht=(s,e)=>!s.tables.some(t=>T(t.area,e))&&!s.blocks.some(t=>T(t.area,e));function at(s,e,t,o){if(s.some(r=>J(r.text))){const r=s.length;return e.map((f,i)=>{const p=t?s[((r-1-i)%r+r)%r]:s[i%r],h=p?.text??"";return{...f,text:p?H(h,f.row-p.row,f.col-p.col):h}})}const n=ut(s.map(r=>r.text),e.length,{mode:o,back:t});return e.map((r,f)=>({...r,text:n[f]??""}))}const Y=["bold","italic","underline","strike","font","size","color","fill","align","valign","wrap","shrink","indent","rotation","border","locked","hide_formula","format"];export const NO_LOOK=Object.fromEntries(Y.map(s=>[s,void 0]));export function copyLooks(s,e,t,o){const c=new Map;for(const n of o){const r=e.lookAt(n.from.row,n.from.col),f=t.lookAt(n.to.row,n.to.col);if(JSON.stringify(r)===JSON.stringify(f))continue;const i=JSON.stringify(r),p=c.get(i);p?p.places.push(n.to):c.set(i,{look:r,places:[n.to]})}for(const{look:n,places:r}of c.values()){const f={};for(const i of Y)f[i]=n[i];for(const i of X(r))$(s,t,i,f)}}export function autoFill(s,e,t,o,c="auto"){const n=s.workbook.sheet(e);if(!n)return M("no-sheet");const r=o.bottom>t.bottom||o.top<t.top,f=o.top<t.top||o.left<t.left,i=new z(s),p=r?{first:t.left,last:t.right}:{first:t.top,last:t.bottom},h=new Map,y=(u,d)=>{const x=`${String(u)}:${String(d)}`;let v=h.get(x);return v===void 0&&(v=B(s,n,u,d),h.set(x,v)),v},L=(t.bottom-t.top+1)*(t.right-t.left+1),m=new Set;for(let u=t.top;u<=t.bottom;u++)for(let d=t.left;d<=t.right;d++){const x=y(u,d);J(x)&&m.add(wt(x,u,d)??"")}if(m.size===1&&L>0&&ht(n,o)&&bt(y,t)){const u=i.spec(n);return rt(u,o),u.cells={...u.cells,[st(o)]:H(y(t.top,t.left),o.top-t.top,o.left-t.left)},i.edit.whole=!0,Z(i,n,t,o,r),i.finish()}for(let u=p.first;u<=p.last;u++){const d=[];if(r)for(let w=t.top;w<=t.bottom;w++)d.push({row:w,col:u,text:y(w,u)});else for(let w=t.left;w<=t.right;w++)d.push({row:u,col:w,text:y(u,w)});const x=[],v=f?r?t.top-1:t.left-1:r?t.bottom+1:t.right+1,A=r?f?o.top:o.bottom:f?o.left:o.right,E=f?-1:1;for(let w=v;f?w>=A:w<=A;w+=E)x.push(r?{row:w,col:u}:{row:u,col:w});for(const w of at(d,x,f,c))it(i,s,n,w.row,w.col,w.text)}return Z(i,n,t,o,r),i.finish()}function bt(s,e){for(let t=e.top;t<=e.bottom;t++)for(let o=e.left;o<=e.right;o++)if(!J(s(t,o)))return!1;return!0}function Z(s,e,t,o,c){const n=[],r=t.bottom-t.top+1,f=t.right-t.left+1;for(let i=o.top;i<=o.bottom;i++)for(let p=o.left;p<=o.right;p++){if(U(t,i,p))continue;const h=c?t.top+((i-t.top)%r+r)%r:i,y=c?p:t.left+((p-t.left)%f+f)%f;n.push({from:{row:h,col:y},to:{row:i,col:p}})}copyLooks(s,e,e,n)}export function pasteLooks(s,e,t,o){const c=s.workbook.sheet(e),n=s.workbook.sheet(t);if(!c||!n)return M("no-sheet");const r=new z(s);return copyLooks(r,c,n,o),r.finish()}export function fillDownTo(s,e){const t=(o,c)=>c>=0&&s.at(o,c)!==void 0;for(const o of[e.left-1,e.right+1]){if(!t(e.bottom,o)&&!t(e.bottom+1,o))continue;let c=e.bottom;for(;t(c+1,o);)c+=1;if(c>e.bottom)return c}}function gt(s,e,t){if(!J(s))return s;const o=Q(s);if(!o.ok)return s;const c=ft(o.node,n=>n.kind!=="ref"?n:n.sheet===void 0?{...n,sheet:e}:n.sheet.toLowerCase()!==t.toLowerCase()||n.lastSheet!==void 0?n:Object.fromEntries(Object.entries(n).filter(([r])=>r!=="sheet")));return lt(c)}function N(s){const e=D();e.whole=!0;for(const t of s){t.file&&(e.file=t.file);for(const[o,c]of t.rows)e.rows.set(o,c)}return e}function _(s,e){const t=e.file??s.file,o=new Map(s.rows);for(const[c,n]of e.rows)o.set(c,n);return{file:t,rows:o,workbook:dt({file:t,rows:c=>o.get(c)})}}export function moveCells(s,e,t,o,c){const n=s.workbook.sheet(e),r=s.workbook.sheet(o);if(!n||!r)return M("no-sheet");const f=c.row-t.top,i=c.col-t.left;if(f===0&&i===0&&n===r)return D();const p={top:c.row,left:c.col,bottom:t.bottom+f,right:t.right+i},h=n.tables.filter(l=>U(t,l.area.top,l.area.left)&&U(t,l.area.bottom,l.area.right));for(const l of n.tables)if(!h.includes(l)&&T(l.area,t)&&t.top<=l.at.row)return M("table-move");if(h.length>0&&n!==r)return M("table-move");for(const l of r.tables)if(!h.includes(l)&&T(l.area,p)&&p.top<=l.at.row)return M("table-move");const y={op:"move-cells",sheet:e,area:t,rows:f,columns:i,...n===r?{}:{to:o}},L=V(s,y),m={...D(),file:L.file,rows:new Map(L.rows)},u=_(s,m),d=u.workbook.sheet(e),x=u.workbook.sheet(o);if(!d||!x)return M("no-sheet");const v=[],A=[],E=Math.min(t.right,d.columnsUsed-1),w=Math.min(t.bottom,d.lastRow),K=(l,b)=>h.some(g=>U(g.area,l,b));for(let l=t.top;l<=w;l++)for(let b=t.left;b<=E;b++)if(!K(l,b)){if(d.at(l,b)!==void 0){const g=B(u,d,l,b);v.push({row:l+f,col:b+i,text:n===r?g:gt(g,e,o)})}A.push({from:{row:l,col:b},to:{row:l+f,col:b+i}})}const S=G(u,e,t);if(S.refused!==void 0)return S;const C=_(u,S),j=[m,S];let R=C;if(h.length>0){const l=new z(C),b=C.workbook.sheet(e);if(!b)return M("no-sheet");for(const I of h){const q=b.tables.find(ot=>ot.name===I.name);if(!q)continue;const tt=l.table(b,q);tt.at=W({row:I.at.row+f,col:I.at.col+i})}const g=l.finish();j.push(g),R=_(C,g)}const F=P(R,o,v);if(F.refused!==void 0)return F;j.push(F);const a=_(R,F),O=a.workbook.sheet(e),k=a.workbook.sheet(o);if(O&&k){const l=new z(a);copyLooks(l,d,k,A);const b=A.map(g=>g.from).filter(g=>!(n===r&&U(p,g.row,g.col))&&Object.keys(d.lookAt(g.row,g.col)).length>0);for(const g of X(b))$(l,O,g,NO_LOOK);j.push(l.finish())}return N(j)}export function shiftCells(s,e,t,o){const c=s.workbook.sheet(e);if(!c)return M("no-sheet");const n=o==="down"||o==="up",r=o==="down"||o==="right",f=n?t.bottom-t.top+1:t.right-t.left+1,i=n?{...t,bottom:Math.max(t.bottom,c.lastRow)}:{...t,right:Math.max(t.right,c.columnsUsed-1)},p=n?{...t,bottom:nt-1}:{...t,right:et-1};if(c.tables.some(a=>T(a.area,p)))return M("table-shift");if(c.merges.some(a=>T(a,p)))return M("merge-shift");const h=V(s,{op:"shift-cells",sheet:e,rows:n,insert:r,at:n?t.top:t.left,count:f,first:n?t.left:t.top,last:n?t.right:t.bottom});if(h.refused!==void 0)return M(h.refused);const y={...D(),file:h.file,rows:new Map(h.rows)},L=_(s,y),m=L.workbook.sheet(e);if(!m)return M("no-sheet");const u=r?f:-f,d=r?i:n?{...i,top:t.bottom+1}:{...i,left:t.right+1},x=Math.min(i.bottom,m.lastRow),v=Math.min(i.right,m.columnsUsed-1),A=[],E=[],w=new Set;for(let a=d.top;a<=Math.min(d.bottom,x);a++)for(let O=d.left;O<=Math.min(d.right,v);O++){const k=n?{row:a+u,col:O}:{row:a,col:O+u};m.at(a,O)!==void 0&&A.push({...k,text:B(L,m,a,O)}),E.push({from:{row:a,col:O},to:k}),w.add(W(k))}const K=G(L,e,i);if(K.refused!==void 0)return K;const S=_(L,K),C=P(S,e,A);if(C.refused!==void 0)return C;const j=_(S,C),R=[y,K,C],F=j.workbook.sheet(e);if(F){const a=new z(j);copyLooks(a,m,F,E);const O=[];for(let k=i.top;k<=x;k++)for(let l=i.left;l<=v;l++)!w.has(W({row:k,col:l}))&&Object.keys(m.lookAt(k,l)).length>0&&O.push({row:k,col:l});for(const k of X(O))$(a,F,k,NO_LOOK);R.push(a.finish())}return N(R)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import"./address.js";import{compareForSort as C}from"./sort.js";import{shownValue as h}from"./format.js";import{choicesIn as x}from"./validate.js";const g=(o,e,r,t)=>h(e.value(o,r,t),o.lookAt(r,t).format),b=(o,e)=>{if(e==="")return o.blanks===!0;const r=e.toLowerCase();return o.values?.some(t=>t.toLowerCase()===r)===!0};function v(o,e,r,t){const s=o.validations.length===0?void 0:o.validationAt(e,r);return s?.spec.multiple===!0?x(t,s.spec):[t]}function k(o,e,r,t,s){for(const[n,u]of r.columns){if(n===s)continue;const f=g(o,e,t,n);if(f===""){if(u.blanks!==!0)return!1;continue}if(!v(o,t,n,f).some(a=>b(u,a)))return!1}return!0}export function filteredRows(o,e){const r=new Set;for(const t of o.filters){if(t.columns.size===0)continue;const{top:s,bottom:n}=t.area,u=Math.min(n,o.lastRow);for(let f=s+1;f<=u;f++)k(o,e,t,f)||r.add(f)}return r}export function filterChoices(o,e,r,t){const s=r.columns.get(t),n=new Map;let u=0;const{top:f,bottom:a}=r.area,i=Math.min(a,o.lastRow);for(let l=f+1;l<=i;l++){if(!k(o,e,r,l,t))continue;const c=g(o,e,l,t);if(c===""){u+=1;continue}const d=v(o,l,t,c);for(const m of d){const p=m.toLowerCase(),w=n.get(p);w?w.count+=1:n.set(p,{text:m,count:1,on:s===void 0||b(s,m),value:d.length>1?m:e.value(o,l,t)})}}return{values:[...n.values()].sort((l,c)=>C(l.value,c.value)),blanks:u===0?void 0:{count:u,on:s===void 0||s.blanks===!0}}}export function regionAround(o,e){const r=(n,u)=>n>=0&&u>=0&&(o.at(n,u)!==void 0||o.spillAt(n,u)!==void 0),t={top:e.row,left:e.col,bottom:e.row,right:e.col};for(let n=!0;n;){n=!1;const u=a=>{for(let i=t.left-1;i<=t.right+1;i++)if(r(a,i))return!0;return!1},f=a=>{for(let i=t.top-1;i<=t.bottom+1;i++)if(r(i,a))return!0;return!1};u(t.top-1)&&(t.top-=1,n=!0),u(t.bottom+1)&&(t.bottom+=1,n=!0),f(t.left-1)&&(t.left-=1,n=!0),f(t.right+1)&&(t.right+=1,n=!0)}return t.top===t.bottom&&t.left===t.right&&!r(t.top,t.left)?void 0:t}
2
+ import"./address.js";import{hasWildcard as q,wildcard as M}from"./calc/functions/criteria.js";import{compareForSort as T}from"./sort.js";import{shownValue as L}from"./format.js";import{choicesIn as E}from"./validate.js";const g=(e,n,o,t)=>L(n.value(e,o,t),e.lookAt(o,t).format),v=(e,n)=>{if(n==="")return e.blanks===!0;const o=n.toLowerCase();return e.values?.some(t=>t.toLowerCase()===o)===!0},h=e=>e.values!==void 0||e.blanks!==void 0,O=(e,n)=>!h(e)||v(e,n);function C(e,n,o,t){const r=e.validations.length===0?void 0:e.validationAt(n,o);return r?.spec.multiple===!0?E(t,r.spec):[t]}function A(e,n,o){const{operator:t}=e,r=e.value;if(typeof r=="number"&&typeof n=="number")switch(t){case"equal":return n===r;case"notEqual":return n!==r;case"greaterThan":return n>r;case"greaterThanOrEqual":return n>=r;case"lessThan":return n<r;case"lessThanOrEqual":return n<=r}const a=String(r);if(t==="equal"||t==="notEqual"){const m=q(a)?M(a)(o):o.toLowerCase()===a.toLowerCase();return t==="equal"?m:!m}if(o==="")return!1;const i=o.toLowerCase().localeCompare(a.toLowerCase());switch(t){case"greaterThan":return i>0;case"greaterThanOrEqual":return i>=0;case"lessThan":return i<0;case"lessThanOrEqual":return i<=0}}function R(e,n,o,t,r){const{top:a}=o.area,i=Math.min(o.area.bottom,e.lastRow),m=()=>{const s=[];for(let u=a+1;u<=i;u++){const d=n.value(e,u,t);typeof d=="number"&&s.push(d)}return s};if(r.values!==void 0||r.blanks!==void 0)return s=>{const u=g(e,n,s,t);return u===""?r.blanks===!0:C(e,s,t,u).some(d=>v(r,d))};const p=r.conditions;if(p)return s=>{const u=n.value(e,s,t),d=g(e,n,s,t),c=p.map(f=>A(f,u,d));return r.or===!0?c.some(Boolean):c.every(Boolean)};const l=r.top;if(l){const s=m().sort((c,f)=>l.bottom===!0?c-f:f-c),u=l.percent===!0?Math.max(1,Math.floor(s.length*l.count/100)):Math.round(l.count),d=s[Math.min(u,s.length)-1];return c=>{const f=n.value(e,c,t);return typeof f!="number"||d===void 0?!1:l.bottom===!0?f<=d:f>=d}}if(r.average){const s=m(),u=s.reduce((c,f)=>c+f,0)/Math.max(1,s.length),d=r.average==="above";return c=>{const f=n.value(e,c,t);return typeof f=="number"&&(d?f>u:f<u)}}const b=r.color;return b?s=>{const u=e.lookAt(s,t);return b.fill!==void 0?typeof u.fill=="string"&&u.fill.toUpperCase()===b.fill.toUpperCase():b.font!==void 0?(u.color??"#000000").toUpperCase()===b.font.toUpperCase():!0}:()=>!0}function k(e,n,o,t){return[...o.columns].filter(([r])=>r!==t).map(([r,a])=>R(e,n,o,r,a))}const y=(e,n)=>e.every(o=>o(n));export function filteredRows(e,n){const o=new Set;for(const t of e.filters){if(t.columns.size===0)continue;const{top:r,bottom:a}=t.area,i=Math.min(a,e.lastRow),m=k(e,n,t);for(let p=r+1;p<=i;p++)y(m,p)||o.add(p)}return o}export function filterChoices(e,n,o,t){const r=o.columns.get(t),a=new Map;let i=0;const{top:m,bottom:p}=o.area,l=Math.min(p,e.lastRow),b=k(e,n,o,t);for(let s=m+1;s<=l;s++){if(!y(b,s))continue;const u=g(e,n,s,t);if(u===""){i+=1;continue}const d=C(e,s,t,u);for(const c of d){const f=c.toLowerCase(),w=a.get(f);w?w.count+=1:a.set(f,{text:c,count:1,on:r===void 0||O(r,c),value:d.length>1?c:n.value(e,s,t)})}}return{values:[...a.values()].sort((s,u)=>T(s.value,u.value)),blanks:i===0?void 0:{count:i,on:r===void 0||r.blanks===!0||!h(r)}}}export function regionAround(e,n){const o=(a,i)=>a>=0&&i>=0&&(e.at(a,i)!==void 0||e.spillAt(a,i)!==void 0),t={top:n.row,left:n.col,bottom:n.row,right:n.col};for(let a=!0;a;){a=!1;const i=p=>{for(let l=t.left-1;l<=t.right+1;l++)if(o(p,l))return!0;return!1},m=p=>{for(let l=t.top-1;l<=t.bottom+1;l++)if(o(l,p))return!0;return!1};i(t.top-1)&&(t.top-=1,a=!0),i(t.bottom+1)&&(t.bottom+=1,a=!0),m(t.left-1)&&(t.left-=1,a=!0),m(t.right+1)&&(t.right+=1,a=!0)}return t.top===t.bottom&&t.left===t.right&&!o(t.top,t.left)?void 0:t}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as b,MAX_ROWS as M}from"../address.js";import{mapNode as S}from"./walk.js";const u=(r,n)=>r?.toLowerCase()===n?.toLowerCase(),k=(r,n,s)=>r.index>=n?{...r,index:r.index+s}:r;function O(r,n,s){if(r.index<n)return r;if(r.index>=n+s)return{...r,index:r.index-s}}function R(r,n,s,i){const o=r.index<=n.index?r:n,e=o===r?n:r,t=k(o,s,i),c=e.index>=s?{...e,index:e.index+i}:e;return o===r?[t,c]:[c,t]}function C(r,n,s,i){const o=r.index<=n.index?r:n,e=o===r?n:r,t=s+i-1;if(o.index>=s&&e.index<=t)return;const c=o.index<s?o:o.index>t?{...o,index:o.index-i}:{...o,index:s},a=e.index<s?e:e.index>t?{...e,index:e.index-i}:{...e,index:s-1};return o===r?[c,a]:[a,c]}function x(r){return{kind:"error",code:"#REF!",...r.sheet===void 0?{}:{sheet:r.sheet}}}const h={kind:"error",code:"#REF!"};function E(r,n,s){if(!u(r.sheet??s,n.sheet)||r.lastSheet!==void 0)return r;const{col:i,row:o}=r;if(i===void 0||o===void 0)return r;const e=r.col2??i,t=r.row2??o,{area:c,rows:a,columns:d,to:m}=n;if(!(Math.min(i.index,e.index)>=c.left&&Math.max(i.index,e.index)<=c.right&&Math.min(o.index,t.index)>=c.top&&Math.max(o.index,t.index)<=c.bottom))return r;const f=(l,p)=>({...l,index:l.index+p}),w={...r,col:f(i,d),row:f(o,a),...r.col2?{col2:f(r.col2,d)}:{},...r.row2?{row2:f(r.row2,a)}:{}};return m===void 0?w:u(m,s)?Object.fromEntries(Object.entries(w).filter(([l])=>l!=="sheet")):{...w,sheet:m}}function g(r,n,s){if(!u(r.sheet??s,n.sheet)||r.lastSheet!==void 0)return r;const i=n.op==="insert-rows"||n.op==="delete-rows",o=i?r.row:r.col,e=i?r.row2:r.col2;if(o===void 0)return r;const t=i?["row","row2"]:["col","col2"],c=n.op==="insert-rows"||n.op==="insert-columns",a=i?M:b;if(e===void 0){const m=c?k(o,n.at,n.count):O(o,n.at,n.count);return!m||m.index>=a?x(r):m===o?r:{...r,[t[0]]:m}}const d=c?R(o,e,n.at,n.count):C(o,e,n.at,n.count);return!d||d[0].index>=a||d[1].index>=a?x(r):d[0]===o&&d[1]===e?r:{...r,[t[0]]:d[0],[t[1]]:d[1]}}export function rewriteFormula(r,n,s,i){const o=(e,t)=>e===void 0?i===void 0||u(i,t):u(e,t);return S(r,e=>{switch(n.op){case"rename-sheet":return(e.kind==="ref"||e.kind==="name"||e.kind==="error")&&u(e.sheet,n.from)?{...e,sheet:n.to}:e.kind==="ref"&&u(e.lastSheet,n.from)?{...e,lastSheet:n.to}:e;case"rename-table":return e.kind==="structured"&&u(e.table,n.from)?{...e,table:n.to}:e;case"delete-sheet":return e.kind==="ref"&&u(e.sheet,n.name)||e.kind==="ref"&&u(e.lastSheet,n.name)?x(e):e.kind==="name"&&u(e.sheet,n.name)?h:e;case"delete-table":return e.kind==="structured"&&u(e.table,n.name)||e.kind==="name"&&u(e.name,n.name)?h:e;case"delete-column":return e.kind==="structured"&&o(e.table,n.table)&&e.columns.some(t=>u(t,n.name))?h:e;case"rename-column":return e.kind==="structured"&&o(e.table,n.table)&&e.columns.some(t=>u(t,n.from))?{...e,columns:e.columns.map(t=>u(t,n.from)?n.to:t)}:e;case"rename-name":return e.kind==="name"&&u(e.name,n.from)?{...e,name:n.to}:e.kind==="call"&&u(e.name,n.from)?{...e,name:n.to.toUpperCase(),written:n.to}:e;case"move-cells":return e.kind==="ref"?E(e,n,s):e;default:return e.kind==="ref"?g(e,n,s):e}})}
2
+ import{MAX_COLUMNS as M,MAX_ROWS as S}from"../address.js";import{mapNode as O}from"./walk.js";const c=(n,r)=>n?.toLowerCase()===r?.toLowerCase(),k=(n,r,t)=>n.index>=r?{...n,index:n.index+t}:n;function R(n,r,t){if(n.index<r)return n;if(n.index>=r+t)return{...n,index:n.index-t}}function C(n,r,t,s){const o=n.index<=r.index?n:r,e=o===n?r:n,u=k(o,t,s),i=e.index>=t?{...e,index:e.index+s}:e;return o===n?[u,i]:[i,u]}function E(n,r,t,s){const o=n.index<=r.index?n:r,e=o===n?r:n,u=t+s-1;if(o.index>=t&&e.index<=u)return;const i=o.index<t?o:o.index>u?{...o,index:o.index-s}:{...o,index:t},a=e.index<t?e:e.index>u?{...e,index:e.index-s}:{...e,index:t-1};return o===n?[i,a]:[a,i]}function x(n){return{kind:"error",code:"#REF!",...n.sheet===void 0?{}:{sheet:n.sheet}}}const h={kind:"error",code:"#REF!"};function g(n,r,t){if(!c(n.sheet??t,r.sheet)||n.lastSheet!==void 0)return n;const{col:s,row:o}=n;if(s===void 0||o===void 0)return n;const e=n.col2??s,u=n.row2??o,{area:i,rows:a,columns:d,to:f}=r;if(!(Math.min(s.index,e.index)>=i.left&&Math.max(s.index,e.index)<=i.right&&Math.min(o.index,u.index)>=i.top&&Math.max(o.index,u.index)<=i.bottom))return n;const l=(m,b)=>({...m,index:m.index+b}),w={...n,col:l(s,d),row:l(o,a),...n.col2?{col2:l(n.col2,d)}:{},...n.row2?{row2:l(n.row2,a)}:{}};return f===void 0?w:c(f,t)?Object.fromEntries(Object.entries(w).filter(([m])=>m!=="sheet")):{...w,sheet:f}}function p(n,r,t){if(!c(n.sheet??t,r.sheet)||n.lastSheet!==void 0)return n;const s=r.op==="insert-rows"||r.op==="delete-rows",o=s?n.row:n.col,e=s?n.row2:n.col2;if(o===void 0)return n;const u=s?["row","row2"]:["col","col2"],i=r.op==="insert-rows"||r.op==="insert-columns",a=s?S:M;if(e===void 0){const f=i?k(o,r.at,r.count):R(o,r.at,r.count);return!f||f.index>=a?x(n):f===o?n:{...n,[u[0]]:f}}const d=i?C(o,e,r.at,r.count):E(o,e,r.at,r.count);return!d||d[0].index>=a||d[1].index>=a?x(n):d[0]===o&&d[1]===e?n:{...n,[u[0]]:d[0],[u[1]]:d[1]}}function F(n,r,t){const s=r.rows?n.col:n.row,o=(r.rows?n.col2:n.row2)??s;if(s===void 0||o===void 0||Math.min(s.index,o.index)<r.first||Math.max(s.index,o.index)>r.last)return n;const e=r.rows?r.insert?"insert-rows":"delete-rows":r.insert?"insert-columns":"delete-columns";return p(n,{op:e,sheet:r.sheet,at:r.at,count:r.count},t)}export function rewriteFormula(n,r,t,s){const o=(e,u)=>e===void 0?s===void 0||c(s,u):c(e,u);return O(n,e=>{switch(r.op){case"rename-sheet":return(e.kind==="ref"||e.kind==="name"||e.kind==="error")&&c(e.sheet,r.from)?{...e,sheet:r.to}:e.kind==="ref"&&c(e.lastSheet,r.from)?{...e,lastSheet:r.to}:e;case"rename-table":return e.kind==="structured"&&c(e.table,r.from)?{...e,table:r.to}:e;case"delete-sheet":return e.kind==="ref"&&c(e.sheet,r.name)||e.kind==="ref"&&c(e.lastSheet,r.name)?x(e):e.kind==="name"&&c(e.sheet,r.name)?h:e;case"delete-table":return e.kind==="structured"&&c(e.table,r.name)||e.kind==="name"&&c(e.name,r.name)?h:e;case"delete-column":return e.kind==="structured"&&o(e.table,r.table)&&e.columns.some(u=>c(u,r.name))?h:e;case"rename-column":return e.kind==="structured"&&o(e.table,r.table)&&e.columns.some(u=>c(u,r.from))?{...e,columns:e.columns.map(u=>c(u,r.from)?r.to:u)}:e;case"rename-name":return e.kind==="name"&&c(e.name,r.from)?{...e,name:r.to}:e.kind==="call"&&c(e.name,r.from)?{...e,name:r.to.toUpperCase(),written:r.to}:e;case"move-cells":return e.kind==="ref"?g(e,r,t):e;case"shift-cells":return e.kind==="ref"?F(e,r,t):e;default:return e.kind==="ref"?p(e,r,t):e}})}
@@ -1,6 +1,6 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{formatColor as O,isValidFormat as P}from"numfmt";import{cellName as T,columnLetter as _}from"./address.js";import{chartDef as U,chartPlace as k,chartSize as q,chartSvg as V}from"./chart.js";import{fileCells as K,isPicture as Y,pictureHeight as X,pictureSize as Z}from"./files.js";import{generalForms as J,shownValue as Q}from"./format.js";import{DEFAULT_COLUMN_WIDTH as tt,DEFAULT_ROW_HEIGHT as D,columnHidden as N,columnWidth as M,pageTitleCols as et,pageTitleRows as nt,rowHeight as st,rowHidden as H,paginate as it,usedWithCharts as ot}from"./paginate.js";import{Rules as rt,iconShape as lt}from"./rules.js";import{tableStyleLook as at,tableStyleOf as dt}from"./table-style.js";import{CellError as ct}from"./values.js";import{placeKey as I}from"./workbook.js";export{tt as DEFAULT_COLUMN_WIDTH,D as DEFAULT_ROW_HEIGHT};const ht={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},ft=o=>{let t="";for(let e=0;e<o.length;e+=32768)t+=String.fromCharCode(...o.subarray(e,e+32768));return btoa(t)},v=o=>o.replace(/[&<>"]/gu,t=>ht[t]??t),gt={thin:"1px solid",medium:"2px solid",thick:"3px solid",double:"3px double",hair:"1px dotted",dotted:"1px dotted",dashed:"1px dashed",dashDot:"1px dashed",dashDotDot:"1px dashed",mediumDashed:"2px dashed",mediumDashDot:"2px dashed",mediumDashDotDot:"2px dashed",slantDashDot:"2px dashed"},pt={left:"left",center:"center",right:"right",justify:"justify",distributed:"justify",centerContinuous:"center",fill:"left"},ut={top:"top",center:"middle",justify:"middle",distributed:"middle"};function mt(o){if(typeof o=="number")return"right";if(typeof o=="boolean"||o instanceof ct)return"center"}const $t={up:"▲","up-right":"◥",right:"▶","down-right":"◢",down:"▼",circle:"●",flag:"⚑",check:"✔",bang:"!",cross:"✖",triangle:"▲",diamond:"◆",bars:"▮",quarter:"◔"};function wt(o){const{shape:t,color:e,level:i}=lt(o.set,o.index),l=($t[t]??"●").repeat(t==="bars"?i??1:1);return`<span style="float:left;color:${e}">${l}</span>`}function bt(o,t,e){const i=[];o.bold===!0&&i.push("font-weight:bold"),o.italic===!0&&i.push("font-style:italic");const l=[o.underline?"underline":"",o.strike===!0?"line-through":""].filter(Boolean);l.length>0&&i.push(`text-decoration:${l.join(" ")}`),o.font!==void 0&&i.push(`font-family:"${o.font.replace(/["\\]/gu,"")}",var(--font)`),o.size!==void 0&&i.push(`font-size:${String(o.size)}pt`);const r=(typeof t=="number"&&e!==void 0&&P(e)?O(e,t)??void 0:void 0)??o.color;typeof r=="string"&&i.push(`color:${r}`);const{fill:d}=o;if(typeof d=="string")i.push(`background:${d}`);else if(d){const s=d.color??d.background;s!==void 0&&i.push(`background:${s}`)}const f=(o.align===void 0||o.align==="general"?void 0:pt[o.align])??mt(t);f!==void 0&&i.push(`text-align:${f}`);const c=o.valign===void 0?void 0:ut[o.valign];c!==void 0&&i.push(`vertical-align:${c}`),o.wrap===!0&&i.push("white-space:pre-wrap","overflow-wrap:anywhere"),o.indent!==void 0&&i.push(`padding-left:${String(3+o.indent*9)}px`);for(const s of["left","right","top","bottom"]){const n=o.border?.[s];n&&n.style!=="none"&&i.push(`border-${s}:${gt[n.style]??"1px solid"} ${n.color??"#000"}`)}return i.join(";")}class L{names=new Map;of(t){if(t==="")return"";let e=this.names.get(t);return e||(e=`s${String(this.names.size)}`,this.names.set(t,e)),e}css(){return[...this.names].map(([t,e])=>`.${e}{${t}}`).join(`
3
- `)}}class W{calc;sheet;rules;read;drawnFiles;bands=new Map;svgs=new Map;constructor(t,e,i){this.calc=t,this.sheet=e,this.read=i,this.rules=e.conditions.length>0?new rt(e,t):void 0}files(){if(this.drawnFiles)return this.drawnFiles;const t=new Map,e=new Map,i=this.read;for(const{row:l,col:r,paths:d,column:f}of i?K(this.sheet,this.calc):[]){const c=X(f),s=d.map(n=>{const a=Y(n)?i?.(n):void 0,h=a&&Z(a);return!a||!h?v(n):(e.set(l,Math.max(e.get(l)??0,c)),`<img src="data:image/${h.type};base64,${ft(a)}" alt="${v(n)}" style="height:${String(c)}px">`)});t.set(I(l,r),s.join(" "))}return this.drawnFiles={cells:t,rows:e},this.drawnFiles}height(t){return this.sheet.spec.rows?.[String(t+1)]?.height??this.files().rows.get(t)??D}band(t,e){if(e===t.at.row)return;let i=this.bands.get(t);if(!i){i=new Map;let l=0;for(let r=t.at.row+1;r<=t.area.bottom;r++)H(this.calc,this.sheet,r)||i.set(r,l++);this.bands.set(t,i)}return i.get(e)??0}cell(t,e,i,l,r){const{sheet:d}=this,f=this.calc.value(d,t,e),c=this.rules?.at(t,e),s=d.lookAt(t,e),n=d.tableAt(t,e),a=n&&dt(n),h=n&&a?at(a,n,t,e,this.band(n,t)):void 0,g={...h,...s,...c?.look,...c?.scale===void 0?{}:{fill:c.scale}};(h?.border||s.border)&&(g.border={...h?.border,...s.border,...c?.look?.border});const w=g.format;let m=bt(g,f,w);if(c?.bar){const C=`${String(Math.round(c.bar.share*100))}%`;m=[m,`background:linear-gradient(90deg,${c.bar.color} ${C},transparent ${C})`].filter(Boolean).join(";")}const p=this.files().cells.get(I(t,e)),y=c?.icon?wt(c.icon):"",x=p??(c?.bare===!0?"":v(Q(f,w))),b=typeof f=="string"&&g.wrap!==!0&&l&&!i,S=typeof f=="number"&&!p&&y===""&&x!=="",F=S&&(w===void 0||w==="General"),j=[r.of(m),b?"over":"",S?"n":""].filter(Boolean).join(" ");return`<td${[j===""?"":` class="${j}"`,F?` data-g="${v(J(f).slice(1).join(" "))}"`:"",i&&i.rows>1?` rowspan="${String(i.rows)}"`:"",i&&i.cols>1?` colspan="${String(i.cols)}"`:""].join("")}>${y}${x}</td>`}spans(t,e){const i=new Map,l=new Set;for(const r of this.sheet.merges){const d=t.filter(n=>n>=r.top&&n<=r.bottom),f=e.filter(n=>n>=r.left&&n<=r.right),[c]=d,[s]=f;if(!(c===void 0||s===void 0)){for(const n of d)for(const a of f)l.add(`${String(n)}:${String(a)}`);l.delete(`${String(c)}:${String(s)}`),i.set(`${String(c)}:${String(s)}`,{rows:d.length,cols:f.length})}}return{spans:i,covered:l}}table(t,e,i,l){const{sheet:r}=this,{spans:d,covered:f}=this.spans(t,e),c=e.map(h=>M(r,h)),s=l.headings?B:0,n=c.reduce((h,g)=>h+g,0)+s,a=[`<table class="${l.className??""}" style="width:${String(n)}px"><colgroup>`,l.headings?`<col style="width:${String(s)}px">`:"",...c.map(h=>`<col style="width:${String(h)}px">`),"</colgroup>"];l.headings&&a.push(`<thead><tr><th></th>${e.map(h=>`<th>${_(h)}</th>`).join("")}</tr></thead>`),a.push("<tbody>");for(const h of t)a.push(`<tr style="height:${String(this.height(h))}px">`),l.headings&&a.push(`<th>${String(h+1)}</th>`),e.forEach((g,w)=>{const m=`${String(h)}:${String(g)}`;if(f.has(m))return;const p=e[w+1],y=p!==void 0&&r.at(h,p)===void 0&&!f.has(`${String(h)}:${String(p)}`);a.push(this.cell(h,g,d.get(m),y,i))}),a.push("</tr>");return a.push("</tbody></table>"),{html:a.join(""),width:n}}svg(t){let e=this.svgs.get(t);if(e===void 0){const{width:i,height:l}=q(t.spec);e=V(U(this.calc,this.sheet,t),i,l,{font:"var(--font)"}),this.svgs.set(t,e)}return e}charts(t,e,i){const{sheet:l}=this;if(l.charts.length===0||t.length===0||e.length===0)return"";const r=(s,n)=>{const a=new Map;let h=0;for(const g of s)a.set(g,h),h+=n(g);return{at:a,sum:h}},d=r(t,s=>this.height(s)),f=r(e,s=>M(l,s)),c=(s,n,a,h)=>{const g=s[0]??0;if(a<g){let m=0;for(let p=a;p<g;p++)m-=h(p);return m}const w=s.find(m=>m>=a);return w===void 0?1/0:n.get(w)??0};return l.charts.map(s=>{const n=k(s.spec,h=>c(t,d.at,h,g=>H(this.calc,l,g)?0:st(l,g)),h=>c(e,f.at,h,g=>N(l,g)?0:M(l,g)));return n.left<f.sum&&n.left+n.width>0&&n.top<d.sum&&n.top+n.height>0?`<div class="chart" style="left:${String(i.left+n.left)}px;top:${String(i.top+n.top)}px">${this.svg(s)}</div>`:""}).join("")}}const B=44,yt=`
2
+ import{formatColor as O,isValidFormat as P}from"numfmt";import{cellName as T,columnLetter as k}from"./address.js";import{linkAt as _}from"./annotations.js";import{chartDef as U,chartPlace as q,chartSize as V,chartSvg as K}from"./chart.js";import{fileCells as Y,isPicture as X,pictureHeight as Z,pictureSize as J}from"./files.js";import{generalForms as Q,shownValue as tt}from"./format.js";import{DEFAULT_COLUMN_WIDTH as et,DEFAULT_ROW_HEIGHT as F,columnHidden as N,columnWidth as R,pageTitleCols as nt,pageTitleRows as st,rowHeight as it,rowHidden as E,paginate as ot,usedWithCharts as rt}from"./paginate.js";import{Rules as lt,iconShape as at}from"./rules.js";import{tableStyleLook as dt,tableStyleOf as ct}from"./table-style.js";import{CellError as ht}from"./values.js";import{placeKey as I}from"./workbook.js";export{et as DEFAULT_COLUMN_WIDTH,F as DEFAULT_ROW_HEIGHT};const ft={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},pt=n=>{let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t)},x=n=>n.replace(/[&<>"]/gu,t=>ft[t]??t),gt={thin:"1px solid",medium:"2px solid",thick:"3px solid",double:"3px double",hair:"1px dotted",dotted:"1px dotted",dashed:"1px dashed",dashDot:"1px dashed",dashDotDot:"1px dashed",mediumDashed:"2px dashed",mediumDashDot:"2px dashed",mediumDashDotDot:"2px dashed",slantDashDot:"2px dashed"},ut={left:"left",center:"center",right:"right",justify:"justify",distributed:"justify",centerContinuous:"center",fill:"left"},mt={top:"top",center:"middle",justify:"middle",distributed:"middle"};function $t(n){if(typeof n=="number")return"right";if(typeof n=="boolean"||n instanceof ht)return"center"}const bt={up:"▲","up-right":"◥",right:"▶","down-right":"◢",down:"▼",circle:"●",flag:"⚑",check:"✔",bang:"!",cross:"✖",triangle:"▲",diamond:"◆",bars:"▮",quarter:"◔"};function wt(n){const{shape:t,color:e,level:o}=at(n.set,n.index),l=(bt[t]??"●").repeat(t==="bars"?o??1:1);return`<span style="float:left;color:${e}">${l}</span>`}function yt(n){const t=[];if(n.bold!==void 0&&t.push(`font-weight:${n.bold?"bold":"normal"}`),n.italic!==void 0&&t.push(`font-style:${n.italic?"italic":"normal"}`),n.underline!==void 0||n.strike!==void 0){const l=[n.underline!==void 0&&n.underline!==!1?"underline":"",n.strike===!0?"line-through":""].filter(Boolean);t.push(`text-decoration:${l.length>0?l.join(" "):"none"}`)}n.font!==void 0&&t.push(`font-family:"${n.font.replace(/["\\]/gu,"")}",var(--font)`),n.size!==void 0&&t.push(`font-size:${String(n.size)}pt`),n.color!==void 0&&t.push(`color:${n.color}`);const e=x(n.text),o=n.script==="superscript"?`<sup>${e}</sup>`:n.script==="subscript"?`<sub>${e}</sub>`:e;return t.length===0&&n.script===void 0?e:`<span${t.length===0?"":` style="${t.join(";")}"`}>${o}</span>`}function xt(n,t,e){const o=[];n.bold===!0&&o.push("font-weight:bold"),n.italic===!0&&o.push("font-style:italic");const l=[n.underline?"underline":"",n.strike===!0?"line-through":""].filter(Boolean);l.length>0&&o.push(`text-decoration:${l.join(" ")}`),n.font!==void 0&&o.push(`font-family:"${n.font.replace(/["\\]/gu,"")}",var(--font)`),n.size!==void 0&&o.push(`font-size:${String(n.size)}pt`);const r=(typeof t=="number"&&e!==void 0&&P(e)?O(e,t)??void 0:void 0)??n.color;typeof r=="string"&&o.push(`color:${r}`);const{fill:a}=n;if(typeof a=="string")o.push(`background:${a}`);else if(a){const i=a.color??a.background;i!==void 0&&o.push(`background:${i}`)}const f=(n.align===void 0||n.align==="general"?void 0:ut[n.align])??$t(t);f!==void 0&&o.push(`text-align:${f}`);const c=n.valign===void 0?void 0:mt[n.valign];c!==void 0&&o.push(`vertical-align:${c}`),n.wrap===!0&&o.push("white-space:pre-wrap","overflow-wrap:anywhere"),n.indent!==void 0&&o.push(`padding-left:${String(3+n.indent*9)}px`);for(const i of["left","right","top","bottom"]){const s=n.border?.[i];s&&s.style!=="none"&&o.push(`border-${i}:${gt[s.style]??"1px solid"} ${s.color??"#000"}`)}return o.join(";")}class L{names=new Map;of(t){if(t==="")return"";let e=this.names.get(t);return e||(e=`s${String(this.names.size)}`,this.names.set(t,e)),e}css(){return[...this.names].map(([t,e])=>`.${e}{${t}}`).join(`
3
+ `)}}class W{calc;sheet;rules;read;drawnFiles;bands=new Map;svgs=new Map;constructor(t,e,o){this.calc=t,this.sheet=e,this.read=o,this.rules=e.conditions.length>0?new lt(e,t):void 0}files(){if(this.drawnFiles)return this.drawnFiles;const t=new Map,e=new Map,o=this.read;for(const{row:l,col:r,paths:a,column:f}of o?Y(this.sheet,this.calc):[]){const c=Z(f),i=a.map(s=>{const d=X(s)?o?.(s):void 0,h=d&&J(d);return!d||!h?x(s):(e.set(l,Math.max(e.get(l)??0,c)),`<img src="data:image/${h.type};base64,${pt(d)}" alt="${x(s)}" style="height:${String(c)}px">`)});t.set(I(l,r),i.join(" "))}return this.drawnFiles={cells:t,rows:e},this.drawnFiles}height(t){return this.sheet.spec.rows?.[String(t+1)]?.height??this.files().rows.get(t)??F}band(t,e){if(e===t.at.row)return;let o=this.bands.get(t);if(!o){o=new Map;let l=0;for(let r=t.at.row+1;r<=t.area.bottom;r++)E(this.calc,this.sheet,r)||o.set(r,l++);this.bands.set(t,o)}return o.get(e)??0}cell(t,e,o,l,r){const{sheet:a}=this,f=this.calc.value(a,t,e),c=this.rules?.at(t,e),i=a.lookAt(t,e),s=a.tableAt(t,e),d=s&&ct(s),h=s&&d?dt(d,s,t,e,this.band(s,t)):void 0,p={...h,...i,...c?.look,...c?.scale===void 0?{}:{fill:c.scale}};(h?.border||i.border)&&(p.border={...h?.border,...i.border,...c?.look?.border});const w=p.format;let $=xt(p,f,w);if(c?.bar){const v=`${String(Math.round(c.bar.share*100))}%`;$=[$,`background:linear-gradient(90deg,${c.bar.color} ${v},transparent ${v})`].filter(Boolean).join(";")}const u=this.files().cells.get(I(t,e)),y=c?.icon?wt(c.icon):"",S=typeof f=="string"?a.runsAt(t,e):void 0,b=u??(c?.bare===!0?"":S?S.map(yt).join(""):x(tt(f,w))),C=typeof f=="string"&&p.wrap!==!0&&l&&!o,A=typeof f=="number"&&!u&&y===""&&b!=="",M=A&&(w===void 0||w==="General"),z=[r.of($),C?"over":"",A?"n":""].filter(Boolean).join(" "),D=[z===""?"":` class="${z}"`,M?` data-g="${x(Q(f).slice(1).join(" "))}"`:"",o&&o.rows>1?` rowspan="${String(o.rows)}"`:"",o&&o.cols>1?` colspan="${String(o.cols)}"`:""].join(""),j=A?void 0:_(a.spec,t,e)?.to,g=j!==void 0&&/^(?:https?:|mailto:)/iu.test(j)&&b!==""?`<a href="${x(j)}" style="color:inherit;text-decoration:inherit">${b}</a>`:b;return`<td${D}>${y}${g}</td>`}spans(t,e){const o=new Map,l=new Set;for(const r of this.sheet.merges){const a=t.filter(s=>s>=r.top&&s<=r.bottom),f=e.filter(s=>s>=r.left&&s<=r.right),[c]=a,[i]=f;if(!(c===void 0||i===void 0)){for(const s of a)for(const d of f)l.add(`${String(s)}:${String(d)}`);l.delete(`${String(c)}:${String(i)}`),o.set(`${String(c)}:${String(i)}`,{rows:a.length,cols:f.length})}}return{spans:o,covered:l}}table(t,e,o,l){const{sheet:r}=this,{spans:a,covered:f}=this.spans(t,e),c=e.map(h=>R(r,h)),i=l.headings?B:0,s=c.reduce((h,p)=>h+p,0)+i,d=[`<table class="${l.className??""}" style="width:${String(s)}px"><colgroup>`,l.headings?`<col style="width:${String(i)}px">`:"",...c.map(h=>`<col style="width:${String(h)}px">`),"</colgroup>"];l.headings&&d.push(`<thead><tr><th></th>${e.map(h=>`<th>${k(h)}</th>`).join("")}</tr></thead>`),d.push("<tbody>");for(const h of t)d.push(`<tr style="height:${String(this.height(h))}px">`),l.headings&&d.push(`<th>${String(h+1)}</th>`),e.forEach((p,w)=>{const $=`${String(h)}:${String(p)}`;if(f.has($))return;const u=e[w+1],y=u!==void 0&&r.at(h,u)===void 0&&!f.has(`${String(h)}:${String(u)}`);d.push(this.cell(h,p,a.get($),y,o))}),d.push("</tr>");return d.push("</tbody></table>"),{html:d.join(""),width:s}}svg(t){let e=this.svgs.get(t);if(e===void 0){const{width:o,height:l}=V(t.spec);e=K(U(this.calc,this.sheet,t),o,l,{font:"var(--font)"}),this.svgs.set(t,e)}return e}charts(t,e,o){const{sheet:l}=this;if(l.charts.length===0||t.length===0||e.length===0)return"";const r=(i,s)=>{const d=new Map;let h=0;for(const p of i)d.set(p,h),h+=s(p);return{at:d,sum:h}},a=r(t,i=>this.height(i)),f=r(e,i=>R(l,i)),c=(i,s,d,h)=>{const p=i[0]??0;if(d<p){let $=0;for(let u=d;u<p;u++)$-=h(u);return $}const w=i.find($=>$>=d);return w===void 0?1/0:s.get(w)??0};return l.charts.map(i=>{const s=q(i.spec,h=>c(t,a.at,h,p=>E(this.calc,l,p)?0:it(l,p)),h=>c(e,f.at,h,p=>N(l,p)?0:R(l,p)));return s.left<f.sum&&s.left+s.width>0&&s.top<a.sum&&s.top+s.height>0?`<div class="chart" style="left:${String(o.left+s.left)}px;top:${String(o.top+s.top)}px">${this.svg(i)}</div>`:""}).join("")}}const B=44,vt=`
4
4
  (() => {
5
5
  const fit = () => {
6
6
  const cells = Array.from(document.querySelectorAll("td.n"));
@@ -23,24 +23,24 @@ import{formatColor as O,isValidFormat as P}from"numfmt";import{cellName as T,col
23
23
  };
24
24
  window.allyhubReady = new Promise((r) => addEventListener("load", r, { once: true })).then(() => document.fonts.ready).then(fit);
25
25
  })();
26
- `;function G(o,t,e){return`<!doctype html><html><head><meta charset="utf-8"><style>
27
- ${o.css??""}
28
- :root{--font:${o.font===void 0?"":`"${o.font}",`}Carlito,Calibri,"Noto Sans SC",Arial,sans-serif}
26
+ `;function G(n,t,e){return`<!doctype html><html><head><meta charset="utf-8"><style>
27
+ ${n.css??""}
28
+ :root{--font:${n.font===void 0?"":`"${n.font}",`}Carlito,Calibri,"Noto Sans SC",Arial,sans-serif}
29
29
  *{box-sizing:border-box}
30
30
  html,body{margin:0;background:#fff;color:#000}
31
31
  body{font:11pt/1.2 var(--font)}
32
32
  table{table-layout:fixed;border-collapse:collapse}
33
- td,th{height:${String(D)}px;padding:0 3px;overflow:hidden;white-space:pre;vertical-align:bottom}
33
+ td,th{height:${String(F)}px;padding:0 3px;overflow:hidden;white-space:pre;vertical-align:bottom}
34
34
  td.over{overflow:visible}
35
35
  .chart{position:absolute;line-height:0}
36
36
  .grid td{border:1px solid #e3e3e3}
37
37
  .edged th{border:1px solid #e3e3e3;background:#f5f5f5;color:#555;font-weight:normal;text-align:center;vertical-align:middle;font-size:9pt}
38
38
  ${t}
39
- </style><script>${yt}<\/script></head><body>${e}</body></html>`}export function sheetHtml(o,t={}){const e=t.sheets??o.wb.sheets.filter(s=>s.spec.hidden!==!0),i=new L,l=[];let r=0;const d=e.length>1&&t.area===void 0,f=e.map(s=>{const n=new W(o,s,t.file),a=t.area??ot(s)??{top:0,left:0,bottom:0,right:0},h=[];for(let b=a.top;b<=a.bottom;b++)H(o,s,b)||h.push(b);const g=[];for(let b=a.left;b<=a.right;b++)N(s,b)||g.push(b);const w=h.slice(0,t.rows??h.length),m=g.slice(0,t.columns??g.length);if(w.length<h.length||m.length<g.length){const b=w[w.length-1]??a.top,S=m[m.length-1]??a.left;l.push(`${s.name}: drew ${T({row:a.top,col:a.left})}:${T({row:b,col:S})} of ${String(h.length)} rows and ${String(g.length)} columns`)}const p=t.headings===!0,y=n.table(w,m,i,{headings:p,className:p?s.spec.gridlines===!1?"edged":"edged grid":""});r=Math.max(r,y.width);const x=n.charts(w,m,{left:p?B:0,top:p?D:0});return`<section class="sheet">${d?`<h2>${v(s.name)}</h2>`:""}<div class="book">${y.html}${x}</div></section>`});return{html:G(t,`h2{font:bold 12pt var(--font);margin:0 0 8px}
39
+ </style><script>${vt}<\/script></head><body>${e}</body></html>`}export function sheetHtml(n,t={}){const e=t.sheets??n.wb.sheets.filter(i=>i.spec.hidden!==!0),o=new L,l=[];let r=0;const a=e.length>1&&t.area===void 0,f=e.map(i=>{const s=new W(n,i,t.file),d=t.area??rt(i)??{top:0,left:0,bottom:0,right:0},h=[];for(let b=d.top;b<=d.bottom;b++)E(n,i,b)||h.push(b);const p=[];for(let b=d.left;b<=d.right;b++)N(i,b)||p.push(b);const w=h.slice(0,t.rows??h.length),$=p.slice(0,t.columns??p.length);if(w.length<h.length||$.length<p.length){const b=w[w.length-1]??d.top,C=$[$.length-1]??d.left;l.push(`${i.name}: drew ${T({row:d.top,col:d.left})}:${T({row:b,col:C})} of ${String(h.length)} rows and ${String(p.length)} columns`)}const u=t.headings===!0,y=s.table(w,$,o,{headings:u,className:u?i.spec.gridlines===!1?"edged":"edged grid":""});r=Math.max(r,y.width);const S=s.charts(w,$,{left:u?B:0,top:u?F:0});return`<section class="sheet">${a?`<h2>${x(i.name)}</h2>`:""}<div class="book">${y.html}${S}</div></section>`});return{html:G(t,`h2{font:bold 12pt var(--font);margin:0 0 8px}
40
40
  .sheet+.sheet{margin-top:24px}
41
41
  .book{position:relative;width:max-content;overflow:hidden}
42
- ${i.css()}`,f.join("")),width:r,cut:l}}const z=o=>String(o).padStart(2,"0");export function headerFooterHtml(o,t){let e="",i=0;const l=d=>{e+=`<span style="${d}">`,i++},r={B:"font-weight:bold",I:"font-style:italic",U:"text-decoration:underline",E:"text-decoration:underline double",S:"text-decoration:line-through",X:"vertical-align:super;font-size:smaller",Y:"vertical-align:sub;font-size:smaller"};for(let d=0;d<o.length;d++){const f=o[d]??"";if(f!=="&"){e+=v(f);continue}const c=o[d+1]??"",s=c.toUpperCase();if(d++,c==="&")e+="&amp;";else if(s==="P"||s==="N"){const n=/^[+-]\d+/u.exec(o.slice(d+1)),a=s==="P"?t.page:t.pages;e+=String(a+(n?Number(n[0]):0)),n&&(d+=n[0].length)}else if(s==="D")e+=`${String(t.date.getFullYear())}-${z(t.date.getMonth()+1)}-${z(t.date.getDate())}`;else if(s==="T")e+=`${z(t.date.getHours())}:${z(t.date.getMinutes())}`;else if(s==="F"||s==="Z")e+=v(t.file);else if(s==="A")e+=v(t.sheet);else{if(s==="G")continue;if(r[s]!==void 0)l(r[s]);else if(c==='"'){const n=o.indexOf('"',d+1),[a="",h=""]=o.slice(d+1,n<0?o.length:n).split(",");d=n<0?o.length:n;const g=[a==="-"||a===""?"":`font-family:"${a.replace(/["\\]/gu,"")}",var(--font)`,/bold/iu.test(h)?"font-weight:bold":"",/italic/iu.test(h)?"font-style:italic":""].filter(Boolean).join(";");g!==""&&l(g)}else if(/\d/u.test(c)){const n=/^\d+/u.exec(o.slice(d))?.[0]??c;d+=n.length-1,l(`font-size:${n}pt`)}else if(s==="K"){const n=o.slice(d+1,d+7);d+=6,/^[0-9A-Fa-f]{6}$/u.test(n)&&l(`color:#${n}`)}}}return e+"</span>".repeat(i)}const u=o=>`${String(Math.round(o*1e3)/1e3)}px`;export class SheetPrint{job;calc;drawers=new Map;file;constructor(t,e={}){this.calc=t,this.file=e.file,this.job=it(t,{...e.sheets?{sheets:e.sheets}:{},height:(i,l)=>this.drawer(i).height(l)})}drawer(t){let e=this.drawers.get(t);return e||(e=new W(this.calc,t,this.file),this.drawers.set(t,e)),e}html(t,e,i){const l=new L,r=new Map,d=[];for(const c of this.job.pages.slice(t,e)){const{of:s}=c,n=`${u(s.paper.width)} ${u(s.paper.height)}`;let a=r.get(n);a===void 0&&(a=`paper${String(r.size)}`,r.set(n,a)),d.push(this.page(c,l,a,i))}const f=[...r].map(([c,s])=>`@page ${s}{size:${c};margin:0}`).join(`
43
- `);return G(i,`${f}
42
+ ${o.css()}`,f.join("")),width:r,cut:l}}const H=n=>String(n).padStart(2,"0");export function headerFooterHtml(n,t){let e="",o=0;const l=a=>{e+=`<span style="${a}">`,o++},r={B:"font-weight:bold",I:"font-style:italic",U:"text-decoration:underline",E:"text-decoration:underline double",S:"text-decoration:line-through",X:"vertical-align:super;font-size:smaller",Y:"vertical-align:sub;font-size:smaller"};for(let a=0;a<n.length;a++){const f=n[a]??"";if(f!=="&"){e+=x(f);continue}const c=n[a+1]??"",i=c.toUpperCase();if(a++,c==="&")e+="&amp;";else if(i==="P"||i==="N"){const s=/^[+-]\d+/u.exec(n.slice(a+1)),d=i==="P"?t.page:t.pages;e+=String(d+(s?Number(s[0]):0)),s&&(a+=s[0].length)}else if(i==="D")e+=`${String(t.date.getFullYear())}-${H(t.date.getMonth()+1)}-${H(t.date.getDate())}`;else if(i==="T")e+=`${H(t.date.getHours())}:${H(t.date.getMinutes())}`;else if(i==="F"||i==="Z")e+=x(t.file);else if(i==="A")e+=x(t.sheet);else{if(i==="G")continue;if(r[i]!==void 0)l(r[i]);else if(c==='"'){const s=n.indexOf('"',a+1),[d="",h=""]=n.slice(a+1,s<0?n.length:s).split(",");a=s<0?n.length:s;const p=[d==="-"||d===""?"":`font-family:"${d.replace(/["\\]/gu,"")}",var(--font)`,/bold/iu.test(h)?"font-weight:bold":"",/italic/iu.test(h)?"font-style:italic":""].filter(Boolean).join(";");p!==""&&l(p)}else if(/\d/u.test(c)){const s=/^\d+/u.exec(n.slice(a))?.[0]??c;a+=s.length-1,l(`font-size:${s}pt`)}else if(i==="K"){const s=n.slice(a+1,a+7);a+=6,/^[0-9A-Fa-f]{6}$/u.test(s)&&l(`color:#${s}`)}}}return e+"</span>".repeat(o)}const m=n=>`${String(Math.round(n*1e3)/1e3)}px`;export class SheetPrint{job;calc;drawers=new Map;file;constructor(t,e={}){this.calc=t,this.file=e.file,this.job=ot(t,{...e.sheets?{sheets:e.sheets}:{},height:(o,l)=>this.drawer(o).height(l)})}drawer(t){let e=this.drawers.get(t);return e||(e=new W(this.calc,t,this.file),this.drawers.set(t,e)),e}html(t,e,o){const l=new L,r=new Map,a=[];for(const c of this.job.pages.slice(t,e)){const{of:i}=c,s=`${m(i.paper.width)} ${m(i.paper.height)}`;let d=r.get(s);d===void 0&&(d=`paper${String(r.size)}`,r.set(s,d)),a.push(this.page(c,l,d,o))}const f=[...r].map(([c,i])=>`@page ${i}{size:${c};margin:0}`).join(`
43
+ `);return G(o,`${f}
44
44
  .page{position:relative;overflow:hidden;break-after:page}
45
45
  .page:last-child{break-after:auto}
46
46
  .body,.charts{position:absolute;overflow:hidden}
@@ -49,4 +49,4 @@ ${i.css()}`,f.join("")),width:r,cut:l}}const z=o=>String(o).padStart(2,"0");expo
49
49
  .hf>div{flex:1 1 0;overflow:visible}
50
50
  .hf>.c{text-align:center}
51
51
  .hf>.r{text-align:right}
52
- ${l.css()}`,d.join(""))}page(t,e,i,l){const{of:r}=t,d=this.drawer(r.sheet),{margins:f,scale:c}=r,s=nt(t),n=et(t),a=r.rows.slice(t.down.from,t.down.to),h=r.cols.slice(t.across.from,t.across.to),g=d.table([...s,...a],[...n,...h],e,{headings:!1}),w=s.reduce(($,A)=>$+d.height(A),0),m=n.reduce(($,A)=>$+M(r.sheet,A),0),p=r.rowAt[t.down.from]??0,y=r.colAt[t.across.from]??0,x=(r.rowAt[t.down.to]??0)-p,b=(r.colAt[t.across.to]??0)-y,S=r.charts.filter($=>$.left<y+b&&$.left+$.width>y&&$.top<p+x&&$.top+$.height>p).map($=>`<div class="chart" style="left:${u($.left-y)};top:${u($.top-p)}">${d.svg($.chart)}</div>`).join(""),F=S===""?"":`<div class="charts" style="left:${u(m)};top:${u(w)};width:${u(b)};height:${u(x)}">${S}</div>`,j=r.paper.width-f.left-f.right,R=r.paper.height-f.top-f.bottom,C={page:t.number,pages:this.job.pages.length,sheet:r.sheet.name,file:l.name,date:l.date},E=($,A)=>$?`<div class="hf" style="left:${u(f.left)};right:${u(f.right)};${A}"><div>${headerFooterHtml($.left??"",C)}</div><div class="c">${headerFooterHtml($.center??"",C)}</div><div class="r">${headerFooterHtml($.right??"",C)}</div></div>`:"";return`<section class="page" style="page:${i};width:${u(r.paper.width)};height:${u(r.paper.height)}">`+E(r.header,`top:${u(f.header)}`)+`<div class="body" style="left:${u(f.left)};top:${u(f.top)};width:${u(j)};height:${u(R)}"><div class="scaled" style="width:${u(j/c)};height:${u(R/c)}${c===1?"":`;transform:scale(${String(c)})`}">`+g.html+F+"</div></div>"+E(r.footer,`bottom:${u(f.footer)}`)+"</section>"}}
52
+ ${l.css()}`,a.join(""))}page(t,e,o,l){const{of:r}=t,a=this.drawer(r.sheet),{margins:f,scale:c}=r,i=st(t),s=nt(t),d=r.rows.slice(t.down.from,t.down.to),h=r.cols.slice(t.across.from,t.across.to),p=a.table([...i,...d],[...s,...h],e,{headings:!1}),w=i.reduce((g,v)=>g+a.height(v),0),$=s.reduce((g,v)=>g+R(r.sheet,v),0),u=r.rowAt[t.down.from]??0,y=r.colAt[t.across.from]??0,S=(r.rowAt[t.down.to]??0)-u,b=(r.colAt[t.across.to]??0)-y,C=r.charts.filter(g=>g.left<y+b&&g.left+g.width>y&&g.top<u+S&&g.top+g.height>u).map(g=>`<div class="chart" style="left:${m(g.left-y)};top:${m(g.top-u)}">${a.svg(g.chart)}</div>`).join(""),A=C===""?"":`<div class="charts" style="left:${m($)};top:${m(w)};width:${m(b)};height:${m(S)}">${C}</div>`,M=r.paper.width-f.left-f.right,z=r.paper.height-f.top-f.bottom,D={page:t.number,pages:this.job.pages.length,sheet:r.sheet.name,file:l.name,date:l.date},j=(g,v)=>g?`<div class="hf" style="left:${m(f.left)};right:${m(f.right)};${v}"><div>${headerFooterHtml(g.left??"",D)}</div><div class="c">${headerFooterHtml(g.center??"",D)}</div><div class="r">${headerFooterHtml(g.right??"",D)}</div></div>`:"";return`<section class="page" style="page:${o};width:${m(r.paper.width)};height:${m(r.paper.height)}">`+j(r.header,`top:${m(f.header)}`)+`<div class="body" style="left:${m(f.left)};top:${m(f.top)};width:${m(M)};height:${m(z)}"><div class="scaled" style="width:${m(M/c)};height:${m(z/c)}${c===1?"":`;transform:scale(${String(c)})`}">`+p.html+A+"</div></div>"+j(r.footer,`bottom:${m(f.footer)}`)+"</section>"}}
@@ -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{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,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,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{TABLE_STYLES}from"./table-styles.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"./rich.js";export*from"./annotations.js";export*from"./arrange.js";export*from"./outline.js";export*from"./data-tools.js";export{NO_LOOK,autoFill,copyLooks,fillDownTo,moveCells,pasteLooks,shiftCells}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";
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{columnIndex as y,columnLetter as g}from"./address.js";import{Draft as j,refused as w}from"./edit.js";const k=(e,t)=>e==="rows"?Number(t)-1:y(t),x=(e,t)=>e==="rows"?String(t+1):g(t);function h(e,t){const o=new Map,s=(t==="rows"?e.rows:e.columns)??{};for(const[l,i]of Object.entries(s)){const n=k(t,l);n!==void 0&&Number.isInteger(n)&&n>=0&&o.set(n,i)}return o}export function outlineDepth(e,t){let o=0;for(const s of h(e,t).values())o=Math.max(o,s.level??0);return o}export function outlineGroups(e,t){const o=h(e,t),s=[...o].filter(([,n])=>(n.level??0)>0).map(([n])=>n).sort((n,r)=>n-r),l=[],i=outlineDepth(e,t);for(let n=1;n<=i;n++){let r,u=-2;const c=()=>{if(r===void 0)return;let f=!0;for(let d=r;d<=u;d++)o.get(d)?.hidden!==!0&&(f=!1);l.push({level:n,from:r,to:u,collapsed:f}),r=void 0};for(const f of s)(o.get(f)?.level??0)<n||(f!==u+1&&c(),r??=f,u=f);c()}return l}export function summaryOf(e,t,o){return(t==="rows"?e.outline?.summary_below!==!1:e.outline?.summary_right!==!1)?o.to+1:Math.max(0,o.from-1)}function a(e,t,o,s,l){const i=e.workbook.sheet(t);if(!i)return w("no-sheet");const n=new j(e),r=n.spec(i),u=(o==="rows"?r.rows:r.columns)??{},c=new Map(Object.entries(u));for(const d of l){const m=x(o,d),b=s(d,c.get(m)??{}),p=Object.fromEntries(Object.entries(b).filter(([,O])=>O!==void 0));Object.keys(p).length===0?c.delete(m):c.set(m,p)}const f=c.size===0?void 0:Object.fromEntries(c);return o==="rows"?f?r.rows=f:delete r.rows:f?r.columns=f:delete r.columns,n.finish()}const v=(e,t)=>Array.from({length:t-e+1},(o,s)=>e+s);export function groupBands(e,t,o,s,l,i){return a(e,t,o,(n,r)=>{const u=Math.max(0,Math.min(7,(r.level??0)+i));return{...r,level:u===0?void 0:u,hidden:u===0&&(r.level??0)>0?void 0:r.hidden}},v(s,l))}export function showGroup(e,t,o,s,l){return a(e,t,o,(i,n)=>({...n,hidden:l?void 0:!0}),v(s.from,s.to))}export function showLevel(e,t,o,s){const l=e.workbook.sheet(t);if(!l)return w("no-sheet");const i=[...h(l.spec,o)].filter(([,n])=>(n.level??0)>0).map(([n])=>n);return a(e,t,o,(n,r)=>({...r,hidden:(r.level??0)>=s?!0:void 0}),i)}
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ export const RUN_FIELDS=["bold","italic","underline","strike","font","size","color","script"];export function runLook(o){return Object.fromEntries(Object.entries(o).filter(([t])=>t!=="text"))}const p=(o,t)=>RUN_FIELDS.every(e=>o[e]===t[e]);function a(o){const t={text:o.text};for(const e of RUN_FIELDS)o[e]!==void 0&&(t[e]=o[e]);return t}export function joinedRuns(o){const t=[];for(const e of o){if(e.text==="")continue;const r=t[t.length-1];r&&p(runLook(r),runLook(e))?t[t.length-1]={...r,text:r.text+e.text}:t.push(a(e))}return t}export const plainRuns=o=>o.every(t=>RUN_FIELDS.every(e=>t[e]===void 0));function f(o,t){const e=[];let r=0;for(const n of o){const s=r+n.text.length;t>r&&t<s?(e.push({...n,text:n.text.slice(0,t-r)}),e.push({...n,text:n.text.slice(t-r)})):e.push(n),r=s}return e}export function formatRuns(o,t,e,r){const n=f(f(o,t),e);let s=0;return joinedRuns(n.map(i=>{const c=s+i.text.length,l=s>=t&&c<=e;if(s=c,!l)return i;const x=Object.entries(r).filter(([,u])=>u!==void 0);return Object.fromEntries([...Object.entries(i).filter(([u])=>!(u in r)),...x])}))}export function runsWithout(o,t){const e=new Set(t);return joinedRuns(o.map(r=>Object.fromEntries(Object.entries(r).filter(([n])=>!e.has(n)))))}export function runAt(o,t){let e=0;for(const r of o){const n=e+r.text.length;if(t>e&&t<=n||t===0&&e===0&&r.text!=="")return r;e=n}return o[o.length-1]}function h(o,t,e){const r=[];let n=0;for(const s of o){const i=n+s.text.length,c=Math.max(t,n),l=Math.min(e,i);c<l&&r.push({...s,text:s.text.slice(c-n,l-n)}),n=i}return r}export function retextRuns(o,t){const e=o.map(c=>c.text).join("");if(e===t)return[...o];const r=Math.min(e.length,t.length);let n=0;for(;n<r&&e[n]===t[n];)n+=1;let s=0;for(;s<r-n&&e[e.length-1-s]===t[t.length-1-s];)s+=1;const i=runAt(o,e.length-s>n?n+1:n);return joinedRuns([...h(o,0,n),{...i?runLook(i):{},text:t.slice(n,t.length-s)},...h(o,e.length-s,e.length)])}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{contains as A}from"./address.js";import{toBool as S}from"./calc/coerce.js";import{CellError as l,Matrix as y,readTyped as k}from"./values.js";const d=.1,E=.9,x={3:[0,33,67],4:[0,25,50,75],5:[0,20,40,60,80]},w=s=>{if(!(s===null||s==="")&&!(s instanceof l))return typeof s=="string"?`s${s.toLowerCase()}`:`${typeof s}${String(s)}`},B=s=>Math.round(s).toString(16).padStart(2,"0");export function colorBetween(s,t,r){const i=(e,n)=>Number.parseInt(e.slice(n,n+2),16),o=e=>B(i(s,e)+(i(t,e)-i(s,e))*r);return`#${o(1)}${o(3)}${o(5)}`.toUpperCase()}export function compareValues(s,t){const r=e=>typeof e=="number"||e===null?0:typeof e=="string"?1:typeof e=="boolean"?2:3,i=r(s),o=r(t);if(i!==o)return i-o;if(i===0)return(s??0)-(t??0);if(i===1){const e=s.toLowerCase(),n=t.toLowerCase();return e<n?-1:e>n?1:0}return s===t?0:s===!0?1:-1}export function holds(s,t,r,i){if(t instanceof l)return!1;const o=()=>compareValues(t,r);switch(s){case"equal":return o()===0;case"notEqual":return o()!==0;case"greaterThan":return o()>0;case"lessThan":return o()<0;case"greaterThanOrEqual":return o()>=0;case"lessThanOrEqual":return o()<=0;default:{const e=o()>=0&&compareValues(t,i)<=0;return s==="notBetween"?!e:e}}}const M=s=>s===null||s instanceof l?"":typeof s=="boolean"?s?"TRUE":"FALSE":String(s);function C(s,t,r){if(t instanceof l)return!1;const i=M(t).toLowerCase(),o=r.toLowerCase();switch(s){case"notContains":return!i.includes(o);case"beginsWith":return i.startsWith(o);case"endsWith":return i.endsWith(o);default:return i.includes(o)}}function F(s){if(s.type==="dataBar"||s.type==="colorScale"||s.type==="iconSet")return;const t={};return s.bold!==void 0&&(t.bold=s.bold),s.italic!==void 0&&(t.italic=s.italic),s.underline!==void 0&&(t.underline=s.underline),s.strike!==void 0&&(t.strike=s.strike),s.color!==void 0&&(t.color=s.color),s.fill!==void 0&&(t.fill=s.fill),s.border!==void 0&&(t.border=s.border),t}function L(s,t){const r=(s.length-1)*t,i=Math.floor(r),o=Math.ceil(r),e=s[i]??0,n=s[o]??e;return e+(n-e)*(r-i)}export class Rules{sheet;calc;measured=new Map;constructor(t,r){this.sheet=t,this.calc=r}measure(t){const r=this.measured.get(t);if(r)return r;const i=[],o=new Map;for(const n of t.areas)this.eachIn(n,c=>{typeof c=="number"&&i.push(c);const a=w(c);a!==void 0&&o.set(a,(o.get(a)??0)+1)});const e={numbers:i,sorted:[...i].sort((n,c)=>n-c),counts:o};return this.measured.set(t,e),e}eachIn(t,r){const{sheet:i,calc:o}=this,e=Math.min(t.right,i.columnsUsed-1);for(let n=t.left;n<=e;n++){const[c,a]=i.span(n,t.top,t.bottom);for(let u=c;u<=a;u++){const f=o.value(i,u,n);f!==null&&r(f)}}}boundAt(t,r,i,o){if(r===void 0)return null;if(typeof r=="number")return r;if(!r.startsWith("=")){const c=k(r);return c.formula===void 0?c.value:r}const e=t.formulas.find(c=>c.text===r);if(!e)return null;const n=this.calc.evaluateAt(e,this.sheet,i,o);return n instanceof y?n.at(0,0):n}stopAt(t,r,i,o,e){const{sorted:n}=this.measure(t),c=n[0]??0,a=n[n.length-1]??0,u=this.boundAt(t,r.value,i,o),f=typeof u=="number"?u:void 0;switch(r.at){case"min":return c;case"max":return a;case"percent":return c+(a-c)*(f??e)/100;case"percentile":return L(n,(f??e)/100);default:return f??e}}whether(t,r,i,o){const{spec:e}=t;switch(e.type){case"cellIs":return holds(e.operator,r,this.boundAt(t,e.formula[0],i,o),this.boundAt(t,e.formula[1],i,o));case"containsText":return C(e.operator,r,e.text);case"duplicateValues":case"uniqueValues":{const n=w(r);if(n===void 0)return!1;const c=this.measure(t).counts.get(n)??0;return e.type==="duplicateValues"?c>1:c===1}case"top10":{if(typeof r!="number")return!1;const{sorted:n}=this.measure(t),c=e.percent===!0?Math.max(1,Math.floor(n.length*e.rank/100)):e.rank,a=e.bottom===!0?n[Math.min(c,n.length)-1]:n[Math.max(n.length-c,0)];return a===void 0?!1:e.bottom===!0?r<=a:r>=a}case"aboveAverage":{if(typeof r!="number")return!1;const{numbers:n}=this.measure(t);if(n.length===0)return!1;const c=n.reduce((a,u)=>a+u,0)/n.length;return e.equal===!0&&r===c?!0:e.below===!0?r<c:r>c}case"expression":{const[n]=t.formulas;if(!n)return!1;const c=this.calc.evaluateAt(n,this.sheet,i,o),a=c instanceof y?c.at(0,0):c;return S(a)===!0}default:return!1}}scale(t,r,i,o,e){const n=r.stops.map((u,f)=>({at:this.stopAt(t,u,o,e,f*100/(r.stops.length-1)),color:u.color})),[c]=n,a=n[n.length-1];if(!(!c||!a)){if(i<=c.at)return c.color;if(i>=a.at)return a.color;for(let u=1;u<n.length;u++){const f=n[u-1],h=n[u];if(f&&h&&i<=h.at)return colorBetween(f.color,h.color,h.at===f.at?1:(i-f.at)/(h.at-f.at))}return a.color}}bar(t,r,i,o,e){const n=this.stopAt(t,r.min??{at:"min"},o,e,0),c=this.stopAt(t,r.max??{at:"max"},o,e,100);if(c<=n)return d;const a=Math.min(1,Math.max(0,(i-n)/(c-n)));return d+(E-d)*a}icon(t,r,i,o,e){const n=Number.parseInt(r.icons,10),c=r.stops??(x[n]??[]).map(u=>({at:"percent",value:u}));let a=0;return c.forEach((u,f)=>{i>=this.stopAt(t,u,o,e,0)&&(a=f)}),r.reverse===!0?n-1-a:a}at(t,r){const{sheet:i,calc:o}=this;if(i.conditions.length===0)return;const e=o.value(i,t,r);let n;for(const c of i.conditions){if(!c.areas.some(u=>A(u,t,r)))continue;const{spec:a}=c;if(a.type==="dataBar"||a.type==="colorScale"||a.type==="iconSet"){if(typeof e!="number")continue;if(n??={},a.type==="dataBar")n.bar??={share:this.bar(c,a,e,t,r),color:a.color},a.show===!1&&(n.bare=!0);else if(a.type==="colorScale"){const u=this.scale(c,a,e,t,r);u!==void 0&&(n.scale??=u)}else n.icon??={set:a.icons,index:this.icon(c,a,e,t,r)},a.show===!1&&(n.bare=!0);if(a.stop===!0)break;continue}if(this.whether(c,e,t,r)&&(n??={},n.look={...F(a),...n.look},a.stop===!0))break}return n}}const m="#00A651",g="#FFC000",b="#E03C32",p="#7F7F7F",T="#000000",R="#2F75B5",O=s=>s===3?[b,g,m]:s===4?[T,b,g,m]:[b,"#ED7D31",g,"#92D050",m];export function iconShape(s,t){const r=Number.parseInt(s,10),o=O(r)[t]??p,e=s.slice(1);return e.startsWith("Arrows")?{shape:(r===3?["down","right","up"]:r===4?["down","down-right","up-right","up"]:["down","down-right","right","up-right","up"])[t]??"right",color:e==="ArrowsGray"?p:o}:e==="Flags"?{shape:"flag",color:o}:e==="Signs"?{shape:t===0?"diamond":t===1?"triangle":"circle",color:o}:e.startsWith("Symbols")?{shape:t===0?"cross":t===1?"bang":"check",color:o}:e==="Rating"?{shape:"bars",color:R,level:t+1}:e==="Quarters"?{shape:"quarter",color:p,level:t}:e==="RedToBlack"?{shape:"circle",color:["#000000","#7F7F7F","#F4B6B6","#E03C32"][t]??p}:{shape:"circle",color:o}}
2
+ import{contains as A}from"./address.js";import{toBool as S}from"./calc/coerce.js";import{CellError as l,Matrix as y,readTyped as k}from"./values.js";const d=.1,E=.9,x={3:[0,33,67],4:[0,25,50,75],5:[0,20,40,60,80]},w=s=>{if(!(s===null||s==="")&&!(s instanceof l))return typeof s=="string"?`s${s.toLowerCase()}`:`${typeof s}${String(s)}`},B=s=>Math.round(s).toString(16).padStart(2,"0");export function colorBetween(s,t,r){const i=(e,n)=>Number.parseInt(e.slice(n,n+2),16),o=e=>B(i(s,e)+(i(t,e)-i(s,e))*r);return`#${o(1)}${o(3)}${o(5)}`.toUpperCase()}export function compareValues(s,t){const r=e=>typeof e=="number"||e===null?0:typeof e=="string"?1:typeof e=="boolean"?2:3,i=r(s),o=r(t);if(i!==o)return i-o;if(i===0)return(s??0)-(t??0);if(i===1){const e=s.toLowerCase(),n=t.toLowerCase();return e<n?-1:e>n?1:0}return s===t?0:s===!0?1:-1}export function holds(s,t,r,i){if(t instanceof l)return!1;const o=()=>compareValues(t,r);switch(s){case"equal":return o()===0;case"notEqual":return o()!==0;case"greaterThan":return o()>0;case"lessThan":return o()<0;case"greaterThanOrEqual":return o()>=0;case"lessThanOrEqual":return o()<=0;default:{const e=o()>=0&&compareValues(t,i)<=0;return s==="notBetween"?!e:e}}}const M=s=>s===null||s instanceof l?"":typeof s=="boolean"?s?"TRUE":"FALSE":String(s);function C(s,t,r){if(t instanceof l)return!1;const i=M(t).toLowerCase(),o=r.toLowerCase();switch(s){case"notContains":return!i.includes(o);case"beginsWith":return i.startsWith(o);case"endsWith":return i.endsWith(o);default:return i.includes(o)}}function F(s){if(s.type==="dataBar"||s.type==="colorScale"||s.type==="iconSet")return;const t={};return s.bold!==void 0&&(t.bold=s.bold),s.italic!==void 0&&(t.italic=s.italic),s.underline!==void 0&&(t.underline=s.underline),s.strike!==void 0&&(t.strike=s.strike),s.color!==void 0&&(t.color=s.color),s.fill!==void 0&&(t.fill=s.fill),s.border!==void 0&&(t.border=s.border),s.format!==void 0&&(t.format=s.format),t}function L(s,t){const r=(s.length-1)*t,i=Math.floor(r),o=Math.ceil(r),e=s[i]??0,n=s[o]??e;return e+(n-e)*(r-i)}export class Rules{sheet;calc;measured=new Map;constructor(t,r){this.sheet=t,this.calc=r}measure(t){const r=this.measured.get(t);if(r)return r;const i=[],o=new Map;for(const n of t.areas)this.eachIn(n,c=>{typeof c=="number"&&i.push(c);const a=w(c);a!==void 0&&o.set(a,(o.get(a)??0)+1)});const e={numbers:i,sorted:[...i].sort((n,c)=>n-c),counts:o};return this.measured.set(t,e),e}eachIn(t,r){const{sheet:i,calc:o}=this,e=Math.min(t.right,i.columnsUsed-1);for(let n=t.left;n<=e;n++){const[c,a]=i.span(n,t.top,t.bottom);for(let f=c;f<=a;f++){const u=o.value(i,f,n);u!==null&&r(u)}}}boundAt(t,r,i,o){if(r===void 0)return null;if(typeof r=="number")return r;if(!r.startsWith("=")){const c=k(r);return c.formula===void 0?c.value:r}const e=t.formulas.find(c=>c.text===r);if(!e)return null;const n=this.calc.evaluateAt(e,this.sheet,i,o);return n instanceof y?n.at(0,0):n}stopAt(t,r,i,o,e){const{sorted:n}=this.measure(t),c=n[0]??0,a=n[n.length-1]??0,f=this.boundAt(t,r.value,i,o),u=typeof f=="number"?f:void 0;switch(r.at){case"min":return c;case"max":return a;case"percent":return c+(a-c)*(u??e)/100;case"percentile":return L(n,(u??e)/100);default:return u??e}}whether(t,r,i,o){const{spec:e}=t;switch(e.type){case"cellIs":return holds(e.operator,r,this.boundAt(t,e.formula[0],i,o),this.boundAt(t,e.formula[1],i,o));case"containsText":return C(e.operator,r,e.text);case"duplicateValues":case"uniqueValues":{const n=w(r);if(n===void 0)return!1;const c=this.measure(t).counts.get(n)??0;return e.type==="duplicateValues"?c>1:c===1}case"top10":{if(typeof r!="number")return!1;const{sorted:n}=this.measure(t),c=e.percent===!0?Math.max(1,Math.floor(n.length*e.rank/100)):e.rank,a=e.bottom===!0?n[Math.min(c,n.length)-1]:n[Math.max(n.length-c,0)];return a===void 0?!1:e.bottom===!0?r<=a:r>=a}case"aboveAverage":{if(typeof r!="number")return!1;const{numbers:n}=this.measure(t);if(n.length===0)return!1;const c=n.reduce((a,f)=>a+f,0)/n.length;return e.equal===!0&&r===c?!0:e.below===!0?r<c:r>c}case"expression":{const[n]=t.formulas;if(!n)return!1;const c=this.calc.evaluateAt(n,this.sheet,i,o),a=c instanceof y?c.at(0,0):c;return S(a)===!0}default:return!1}}scale(t,r,i,o,e){const n=r.stops.map((f,u)=>({at:this.stopAt(t,f,o,e,u*100/(r.stops.length-1)),color:f.color})),[c]=n,a=n[n.length-1];if(!(!c||!a)){if(i<=c.at)return c.color;if(i>=a.at)return a.color;for(let f=1;f<n.length;f++){const u=n[f-1],h=n[f];if(u&&h&&i<=h.at)return colorBetween(u.color,h.color,h.at===u.at?1:(i-u.at)/(h.at-u.at))}return a.color}}bar(t,r,i,o,e){const n=this.stopAt(t,r.min??{at:"min"},o,e,0),c=this.stopAt(t,r.max??{at:"max"},o,e,100);if(c<=n)return d;const a=Math.min(1,Math.max(0,(i-n)/(c-n)));return d+(E-d)*a}icon(t,r,i,o,e){const n=Number.parseInt(r.icons,10),c=r.stops??(x[n]??[]).map(f=>({at:"percent",value:f}));let a=0;return c.forEach((f,u)=>{i>=this.stopAt(t,f,o,e,0)&&(a=u)}),r.reverse===!0?n-1-a:a}at(t,r){const{sheet:i,calc:o}=this;if(i.conditions.length===0)return;const e=o.value(i,t,r);let n;for(const c of i.conditions){if(!c.areas.some(f=>A(f,t,r)))continue;const{spec:a}=c;if(a.type==="dataBar"||a.type==="colorScale"||a.type==="iconSet"){if(typeof e!="number")continue;if(n??={},a.type==="dataBar")n.bar??={share:this.bar(c,a,e,t,r),color:a.color},a.show===!1&&(n.bare=!0);else if(a.type==="colorScale"){const f=this.scale(c,a,e,t,r);f!==void 0&&(n.scale??=f)}else n.icon??={set:a.icons,index:this.icon(c,a,e,t,r)},a.show===!1&&(n.bare=!0);if(a.stop===!0)break;continue}if(this.whether(c,e,t,r)&&(n??={},n.look={...F(a),...n.look},a.stop===!0))break}return n}}const m="#00A651",g="#FFC000",b="#E03C32",p="#7F7F7F",T="#000000",R="#2F75B5",O=s=>s===3?[b,g,m]:s===4?[T,b,g,m]:[b,"#ED7D31",g,"#92D050",m];export function iconShape(s,t){const r=Number.parseInt(s,10),o=O(r)[t]??p,e=s.slice(1);return e.startsWith("Arrows")?{shape:(r===3?["down","right","up"]:r===4?["down","down-right","up-right","up"]:["down","down-right","right","up-right","up"])[t]??"right",color:e==="ArrowsGray"?p:o}:e==="Flags"?{shape:"flag",color:o}:e==="Signs"?{shape:t===0?"diamond":t===1?"triangle":"circle",color:o}:e.startsWith("Symbols")?{shape:t===0?"cross":t===1?"bang":"check",color:o}:e==="Rating"?{shape:"bars",color:R,level:t+1}:e==="Quarters"?{shape:"quarter",color:p,level:t}:e==="RedToBlack"?{shape:"circle",color:["#000000","#7F7F7F","#F4B6B6","#E03C32"][t]??p}:{shape:"circle",color:o}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{TABLE_STYLES as S}from"./table-styles.js";export const DEFAULT_TABLE_STYLE="TableStyleMedium2",tableStyleOf=e=>e.spec.style==="none"?void 0:S[e.spec.style??DEFAULT_TABLE_STYLE];export function tableStyleLook(e,m,d,u,b){const{area:n}=m,t={},i={},r=(o,p)=>{if(!o)return;o.bold!==void 0&&(t.bold=o.bold),o.color!==void 0&&(t.color=o.color),o.fill!==void 0&&(t.fill=o.fill);const c=o.border;if(!c)return;const l=(s,L)=>{const h=p[s]?c[s]:c[L];h&&(i[s]=h)};l("left","vertical"),l("right","vertical"),l("top","horizontal"),l("bottom","horizontal")},f={left:u===n.left,right:u===n.right};return r(e.whole,{...f,top:d===n.top,bottom:d===n.bottom}),b===void 0?r(e.header,{...f,top:!0,bottom:!0}):r(b%2===0?e.stripe:e.stripe2,{...f,top:!0,bottom:!0}),Object.keys(i).length>0&&(t.border=i),t}
2
+ import{TABLE_STYLES as S}from"./table-styles.js";export const DEFAULT_TABLE_STYLE="TableStyleMedium2",tableStyleOf=o=>o.spec.style==="none"?void 0:S[o.spec.style??DEFAULT_TABLE_STYLE];export function tableStyleLook(o,h,p,i,c){const{area:e}=h,r={},u={},n=(t,g)=>{if(!t)return;t.bold!==void 0&&(r.bold=t.bold),t.color!==void 0&&(r.color=t.color),t.fill!==void 0&&(r.fill=t.fill);const m=t.border;if(!m)return;const l=(b,L)=>{const a=g[b]?m[b]:m[L];a&&(u[b]=a)};l("left","vertical"),l("right","vertical"),l("top","horizontal"),l("bottom","horizontal")},s={left:i===e.left,right:i===e.right},_={top:p===e.top,bottom:p===e.bottom},d={left:!0,right:!0,..._},f=h.spec;return n(o.whole,{...s,..._}),f.banded_columns===!0&&n((i-e.left)%2===0?o.column:o.column2,d),c!==void 0&&f.banded_rows!==!1&&n(c%2===0?o.stripe:o.stripe2,{...s,top:!0,bottom:!0}),f.last_column===!0&&i===e.right&&n(o.last,d),f.first_column===!0&&i===e.left&&n(o.first,d),c===void 0&&n(o.header,{...s,top:!0,bottom:!0}),Object.keys(u).length>0&&(r.border=u),r}