allyhub 0.19.0 → 0.20.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 (699) hide show
  1. package/dist/commands/align.js +1 -1
  2. package/dist/commands/check.js +1 -1
  3. package/dist/commands/cloud-tools.js +1 -1
  4. package/dist/commands/cloud.js +1 -1
  5. package/dist/commands/dev.js +5 -5
  6. package/dist/commands/export.js +3 -0
  7. package/dist/commands/frames/doc.js +1 -1
  8. package/dist/commands/frames/piece.js +1 -1
  9. package/dist/commands/frames/sheet.js +1 -1
  10. package/dist/commands/frames.js +9 -9
  11. package/dist/commands/index.js +1 -1
  12. package/dist/commands/inspect/combos.js +1 -1
  13. package/dist/commands/inspect/common.js +2 -2
  14. package/dist/commands/inspect/facts.js +2 -2
  15. package/dist/commands/migrate.js +3 -0
  16. package/dist/commands/skills.js +3 -3
  17. package/dist/commands/upgrade.js +5 -0
  18. package/dist/commands.json +1 -1
  19. package/dist/help.js +3 -3
  20. package/dist/main.js +8 -7
  21. package/dist/node_modules/@allyhub/3d-extension/package.json +2 -2
  22. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  23. package/dist/node_modules/@allyhub/blocks/LICENSE +241 -0
  24. package/dist/node_modules/@allyhub/blocks/dist/alt.js +2 -0
  25. package/dist/node_modules/@allyhub/blocks/dist/elements.js +2 -0
  26. package/dist/node_modules/@allyhub/blocks/dist/flow-resolve.js +2 -0
  27. package/dist/node_modules/@allyhub/blocks/dist/flow-table.js +2 -0
  28. package/dist/node_modules/@allyhub/blocks/dist/format.js +2 -0
  29. package/dist/node_modules/@allyhub/blocks/dist/gantt.js +2 -0
  30. package/dist/node_modules/@allyhub/blocks/dist/grids.js +2 -0
  31. package/dist/node_modules/@allyhub/blocks/dist/html.js +75 -0
  32. package/dist/node_modules/@allyhub/blocks/dist/icons.generated.js +2 -0
  33. package/dist/node_modules/@allyhub/blocks/dist/icons.js +2 -0
  34. package/dist/node_modules/@allyhub/blocks/dist/index.js +2 -0
  35. package/dist/node_modules/@allyhub/blocks/dist/layout.js +2 -0
  36. package/dist/node_modules/@allyhub/blocks/dist/look.js +2 -0
  37. package/dist/node_modules/@allyhub/blocks/dist/measure.js +3 -0
  38. package/dist/node_modules/@allyhub/blocks/dist/model.js +2 -0
  39. package/dist/node_modules/@allyhub/blocks/dist/page.js +2 -0
  40. package/dist/node_modules/@allyhub/blocks/dist/palette.js +2 -0
  41. package/dist/node_modules/@allyhub/blocks/dist/path.js +2 -0
  42. package/dist/node_modules/@allyhub/blocks/dist/resolve.js +2 -0
  43. package/dist/node_modules/@allyhub/blocks/dist/samples.js +2 -0
  44. package/dist/node_modules/@allyhub/blocks/dist/sankey.js +2 -0
  45. package/dist/node_modules/@allyhub/blocks/dist/svg.js +2 -0
  46. package/dist/node_modules/@allyhub/blocks/dist/tidy.js +2 -0
  47. package/dist/node_modules/@allyhub/blocks/dist/trees.js +2 -0
  48. package/dist/node_modules/@allyhub/blocks/package.json +19 -0
  49. package/dist/node_modules/@allyhub/browser/dist/html.js +1 -1
  50. package/dist/node_modules/@allyhub/browser/package.json +1 -1
  51. package/dist/node_modules/@allyhub/build/dist/fonts.js +9 -3
  52. package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
  53. package/dist/node_modules/@allyhub/build/dist/inspect-view.js +1 -1
  54. package/dist/node_modules/@allyhub/build/dist/migrate.js +2 -0
  55. package/dist/node_modules/@allyhub/build/dist/prepare.js +3 -3
  56. package/dist/node_modules/@allyhub/build/dist/work.js +3 -3
  57. package/dist/node_modules/@allyhub/build/package.json +5 -1
  58. package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
  59. package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
  60. package/dist/node_modules/@allyhub/chart/dist/chart-file.js +2 -1
  61. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +4 -3
  62. package/dist/node_modules/@allyhub/chart/dist/chart.js +4 -2
  63. package/dist/node_modules/@allyhub/chart/dist/chartex-xml.js +4 -0
  64. package/dist/node_modules/@allyhub/chart/dist/classic.js +2 -0
  65. package/dist/node_modules/@allyhub/chart/dist/embedded.js +2 -2
  66. package/dist/node_modules/@allyhub/chart/dist/extended.js +2 -0
  67. package/dist/node_modules/@allyhub/chart/dist/index.js +1 -1
  68. package/dist/node_modules/@allyhub/chart/dist/svg.js +1 -1
  69. package/dist/node_modules/@allyhub/chart/dist/tree.js +2 -0
  70. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  71. package/dist/node_modules/@allyhub/check/dist/check.js +1 -1
  72. package/dist/node_modules/@allyhub/check/package.json +1 -1
  73. package/dist/node_modules/@allyhub/cloud/dist/blobs.js +1 -1
  74. package/dist/node_modules/@allyhub/cloud/dist/call.js +4 -4
  75. package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
  76. package/dist/node_modules/@allyhub/cloud/dist/storage.js +2 -0
  77. package/dist/node_modules/@allyhub/cloud/dist/uploads.js +2 -2
  78. package/dist/node_modules/@allyhub/cloud/package.json +1 -1
  79. package/dist/node_modules/@allyhub/components/package.json +1 -1
  80. package/dist/node_modules/@allyhub/dev-server/dist/background.js +1 -1
  81. package/dist/node_modules/@allyhub/dev-server/dist/item-process.js +2 -0
  82. package/dist/node_modules/@allyhub/dev-server/dist/item-worker.js +2 -0
  83. package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
  84. package/dist/node_modules/@allyhub/dev-server/dist/pages.js +20 -1
  85. package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
  86. package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
  87. package/dist/node_modules/@allyhub/dev-server/dist/server.js +2 -2
  88. package/dist/node_modules/@allyhub/dev-server/dist/tools.js +1 -1
  89. package/dist/node_modules/@allyhub/dev-server/dist/validate.js +2 -2
  90. package/dist/node_modules/@allyhub/dev-server/dist/writer.js +3 -3
  91. package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
  92. package/dist/node_modules/@allyhub/diagnostics/dist/rules.js +1 -1
  93. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  94. package/dist/node_modules/@allyhub/doc/dist/blocks.js +2 -0
  95. package/dist/node_modules/@allyhub/doc/dist/chart.js +1 -1
  96. package/dist/node_modules/@allyhub/doc/dist/color.js +1 -1
  97. package/dist/node_modules/@allyhub/doc/dist/docx-read.js +12 -0
  98. package/dist/node_modules/@allyhub/doc/dist/docx.js +5 -4
  99. package/dist/node_modules/@allyhub/doc/dist/html.js +83 -48
  100. package/dist/node_modules/@allyhub/doc/dist/index.js +1 -1
  101. package/dist/node_modules/@allyhub/doc/dist/markdown.js +1 -1
  102. package/dist/node_modules/@allyhub/doc/dist/merges.js +2 -0
  103. package/dist/node_modules/@allyhub/doc/dist/model.js +1 -1
  104. package/dist/node_modules/@allyhub/doc/dist/numbering.js +2 -0
  105. package/dist/node_modules/@allyhub/doc/dist/omml.js +3 -0
  106. package/dist/node_modules/@allyhub/doc/dist/page.js +2 -1
  107. package/dist/node_modules/@allyhub/doc/dist/paper.js +1 -1
  108. package/dist/node_modules/@allyhub/doc/dist/parse.js +5 -4
  109. package/dist/node_modules/@allyhub/doc/dist/redline.js +2 -0
  110. package/dist/node_modules/@allyhub/doc/dist/revisions.js +2 -0
  111. package/dist/node_modules/@allyhub/doc/dist/shapes.js +4 -0
  112. package/dist/node_modules/@allyhub/doc/dist/styles.js +2 -0
  113. package/dist/node_modules/@allyhub/doc/dist/table.js +1 -1
  114. package/dist/node_modules/@allyhub/doc/dist/write.js +65 -39
  115. package/dist/node_modules/@allyhub/doc/package.json +5 -1
  116. package/dist/node_modules/@allyhub/doc-extension/dist/build.js +2 -2
  117. package/dist/node_modules/@allyhub/doc-extension/dist/cli/find.js +1 -1
  118. package/dist/node_modules/@allyhub/doc-extension/dist/cli/import.js +3 -0
  119. package/dist/node_modules/@allyhub/doc-extension/dist/cli/index.js +1 -1
  120. package/dist/node_modules/@allyhub/doc-extension/dist/cli/styles.js +4 -0
  121. package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
  122. package/dist/node_modules/@allyhub/doc-extension/dist/inspect.js +1 -1
  123. package/dist/node_modules/@allyhub/doc-extension/dist/project-tools.js +1 -1
  124. package/dist/node_modules/@allyhub/doc-extension/dist/tools.js +1 -1
  125. package/dist/node_modules/@allyhub/doc-extension/package.json +22 -2
  126. package/dist/node_modules/@allyhub/doc-print/dist/drawn.js +4 -4
  127. package/dist/node_modules/@allyhub/doc-print/dist/index.js +1 -1
  128. package/dist/node_modules/@allyhub/doc-print/dist/layout.js +8 -7
  129. package/dist/node_modules/@allyhub/doc-print/dist/print.js +22 -16
  130. package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
  131. package/dist/node_modules/@allyhub/export/dist/export.js +1 -1
  132. package/dist/node_modules/@allyhub/export/package.json +1 -1
  133. package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
  134. package/dist/node_modules/@allyhub/extension-host/dist/points.js +1 -1
  135. package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
  136. package/dist/node_modules/@allyhub/formats/dist/data/blocks-flow.js +2 -0
  137. package/dist/node_modules/@allyhub/formats/dist/data/blocks.d.ts +146 -0
  138. package/dist/node_modules/@allyhub/formats/dist/data/blocks.js +2 -0
  139. package/dist/node_modules/@allyhub/formats/dist/data/cell-styles.d.ts +9 -0
  140. package/dist/node_modules/@allyhub/formats/dist/data/cell-styles.js +2 -0
  141. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +47 -40
  142. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.js +1 -1
  143. package/dist/node_modules/@allyhub/formats/dist/data/diagram-kinds.d.ts +6 -0
  144. package/dist/node_modules/@allyhub/formats/dist/data/diagram-kinds.js +2 -0
  145. package/dist/node_modules/@allyhub/formats/dist/data/diagrams.d.ts +29 -0
  146. package/dist/node_modules/@allyhub/formats/dist/data/diagrams.js +2 -0
  147. package/dist/node_modules/@allyhub/formats/dist/data/faces.d.ts +18 -0
  148. package/dist/node_modules/@allyhub/formats/dist/data/faces.js +1 -1
  149. package/dist/node_modules/@allyhub/formats/dist/data/page-data.d.ts +59 -0
  150. package/dist/node_modules/@allyhub/formats/dist/data/page-data.js +2 -0
  151. package/dist/node_modules/@allyhub/formats/dist/data/reference.d.ts +1 -1
  152. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +698 -258
  153. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  154. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +14104 -2167
  155. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  156. package/dist/node_modules/@allyhub/formats/dist/data/themes.d.ts +82 -0
  157. package/dist/node_modules/@allyhub/formats/dist/data/themes.js +2 -0
  158. package/dist/node_modules/@allyhub/formats/dist/data/tokens.d.ts +67 -0
  159. package/dist/node_modules/@allyhub/formats/dist/data/tokens.js +2 -0
  160. package/dist/node_modules/@allyhub/formats/dist/data/work.d.ts +42 -0
  161. package/dist/node_modules/@allyhub/formats/dist/data/work.js +1 -1
  162. package/dist/node_modules/@allyhub/formats/dist/index.d.ts +7 -0
  163. package/dist/node_modules/@allyhub/formats/dist/index.js +1 -1
  164. package/dist/node_modules/@allyhub/formats/dist/items.d.ts +12 -3
  165. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +3260 -290
  166. package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
  167. package/dist/node_modules/@allyhub/formats/dist/tolerant.d.ts +45 -0
  168. package/dist/node_modules/@allyhub/formats/dist/tolerant.js +2 -0
  169. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  170. package/dist/node_modules/@allyhub/html-extension/dist/project-tools.js +21 -9
  171. package/dist/node_modules/@allyhub/html-extension/dist/tools.js +1 -1
  172. package/dist/node_modules/@allyhub/html-extension/markup/allyhub.yaml +2 -0
  173. package/dist/node_modules/@allyhub/html-extension/markup/markup.json +14 -4
  174. package/dist/node_modules/@allyhub/html-extension/markup/pages/budget.html +22 -1
  175. package/dist/node_modules/@allyhub/html-extension/package.json +9 -1
  176. package/dist/node_modules/@allyhub/i18n/package.json +1 -1
  177. package/dist/node_modules/@allyhub/image-draw/dist/fonts.js +1 -1
  178. package/dist/node_modules/@allyhub/image-draw/dist/inspect.js +2 -2
  179. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  180. package/dist/node_modules/@allyhub/image-extension/dist/build-plugins.js +1 -1
  181. package/dist/node_modules/@allyhub/image-extension/dist/cli.js +1 -1
  182. package/dist/node_modules/@allyhub/image-extension/package.json +2 -2
  183. package/dist/node_modules/@allyhub/image-extension/skills/allyhub/references/images.md +1 -1
  184. package/dist/node_modules/@allyhub/image-measure/dist/layout.js +2 -2
  185. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  186. package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
  187. package/dist/node_modules/@allyhub/image-render/package.json +1 -1
  188. package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
  189. package/dist/node_modules/@allyhub/image-sdk/dist/block.js +2 -0
  190. package/dist/node_modules/@allyhub/image-sdk/dist/blocks.js +2 -0
  191. package/dist/node_modules/@allyhub/image-sdk/dist/index.js +1 -1
  192. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  193. package/dist/node_modules/@allyhub/jobs/package.json +1 -1
  194. package/dist/node_modules/@allyhub/linkedin-extension/package.json +1 -3
  195. package/dist/node_modules/@allyhub/linkedin-extension/skills/allyhub/references/linkedin.md +3 -3
  196. package/dist/node_modules/@allyhub/linkedin-model/package.json +1 -1
  197. package/dist/node_modules/@allyhub/linkedin-view/package.json +1 -1
  198. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  199. package/dist/node_modules/@allyhub/media/package.json +1 -1
  200. package/dist/node_modules/@allyhub/media-extension/dist/analyses/faces.js +1 -1
  201. package/dist/node_modules/@allyhub/media-extension/dist/asr/transcribe.js +1 -1
  202. package/dist/node_modules/@allyhub/media-extension/dist/ocr/text.js +1 -1
  203. package/dist/node_modules/@allyhub/media-extension/dist/vision/faces.js +1 -1
  204. package/dist/node_modules/@allyhub/media-extension/dist/vision/index-media.js +3 -2
  205. package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
  206. package/dist/node_modules/@allyhub/model/package.json +1 -1
  207. package/dist/node_modules/@allyhub/office-extension/markup/csv/allyhub.yaml +2 -0
  208. package/dist/node_modules/@allyhub/office-extension/markup/csv/markup.json +1 -1
  209. package/dist/node_modules/@allyhub/office-extension/markup/document/allyhub.yaml +2 -0
  210. package/dist/node_modules/@allyhub/office-extension/markup/presentation/allyhub.yaml +2 -0
  211. package/dist/node_modules/@allyhub/office-extension/markup/workbook/allyhub.yaml +2 -0
  212. package/dist/node_modules/@allyhub/office-extension/markup/workbook/markup.json +1 -1
  213. package/dist/node_modules/@allyhub/office-extension/package.json +1 -1
  214. package/dist/node_modules/@allyhub/ooxml/dist/ext.js +1 -1
  215. package/dist/node_modules/@allyhub/ooxml/dist/mce.js +1 -1
  216. package/dist/node_modules/@allyhub/ooxml/dist/node.js +1 -1
  217. package/dist/node_modules/@allyhub/ooxml/dist/ns.js +1 -1
  218. package/dist/node_modules/@allyhub/ooxml/dist/opc.js +1 -1
  219. package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
  220. package/dist/node_modules/@allyhub/piece/dist/export.d.ts +1 -1
  221. package/dist/node_modules/@allyhub/piece/dist/layout.d.ts +2 -0
  222. package/dist/node_modules/@allyhub/piece/dist/look.d.ts +10 -2
  223. package/dist/node_modules/@allyhub/piece/dist/look.js +1 -1
  224. package/dist/node_modules/@allyhub/piece/dist/media.d.ts +8 -2
  225. package/dist/node_modules/@allyhub/piece/dist/script.js +1 -1
  226. package/dist/node_modules/@allyhub/piece/dist/source.d.ts +3 -0
  227. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  228. package/dist/node_modules/@allyhub/project/dist/media-index.js +1 -1
  229. package/dist/node_modules/@allyhub/project/package.json +1 -1
  230. package/dist/node_modules/@allyhub/protocol/dist/cli.js +1 -1
  231. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  232. package/dist/node_modules/@allyhub/protocol/dist/events.js +1 -1
  233. package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
  234. package/dist/node_modules/@allyhub/protocol/dist/kinds.js +1 -1
  235. package/dist/node_modules/@allyhub/protocol/dist/page-frame.js +2 -0
  236. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  237. package/dist/node_modules/@allyhub/registry/package.json +1 -1
  238. package/dist/node_modules/@allyhub/render/package.json +1 -1
  239. package/dist/node_modules/@allyhub/runtime/dist/footage.js +1 -1
  240. package/dist/node_modules/@allyhub/runtime/package.json +1 -1
  241. package/dist/node_modules/@allyhub/runtimes/dist/packages.js +2 -2
  242. package/dist/node_modules/@allyhub/runtimes/dist/runtimes.js +3 -3
  243. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  244. package/dist/node_modules/@allyhub/scaffold/dist/index.js +12 -8
  245. package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
  246. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  247. package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
  248. package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
  249. package/dist/node_modules/@allyhub/sheet/dist/api/charts.js +1 -1
  250. package/dist/node_modules/@allyhub/sheet/dist/api/index.js +1 -1
  251. package/dist/node_modules/@allyhub/sheet/dist/api/styles.js +1 -1
  252. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
  253. package/dist/node_modules/@allyhub/sheet/dist/calc/engine.js +1 -1
  254. package/dist/node_modules/@allyhub/sheet/dist/calc/server.js +1 -1
  255. package/dist/node_modules/@allyhub/sheet/dist/cell-styles.js +2 -0
  256. package/dist/node_modules/@allyhub/sheet/dist/chart.js +1 -1
  257. package/dist/node_modules/@allyhub/sheet/dist/check.js +1 -1
  258. package/dist/node_modules/@allyhub/sheet/dist/file.js +2 -2
  259. package/dist/node_modules/@allyhub/sheet/dist/heatmap.js +2 -0
  260. package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
  261. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  262. package/dist/node_modules/@allyhub/sheet/dist/inspect.js +1 -1
  263. package/dist/node_modules/@allyhub/sheet/dist/paginate.js +1 -1
  264. package/dist/node_modules/@allyhub/sheet/dist/printed.js +1 -1
  265. package/dist/node_modules/@allyhub/sheet/dist/sdk.js +1 -1
  266. package/dist/node_modules/@allyhub/sheet/dist/sparklines.js +2 -0
  267. package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
  268. package/dist/node_modules/@allyhub/sheet/dist/table-styles.js +1 -1
  269. package/dist/node_modules/@allyhub/sheet/dist/theme.js +2 -0
  270. package/dist/node_modules/@allyhub/sheet/dist/tiles.js +2 -0
  271. package/dist/node_modules/@allyhub/sheet/dist/units.js +2 -0
  272. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  273. package/dist/node_modules/@allyhub/sheet/dist/write.js +14 -14
  274. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  275. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  276. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  277. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  278. package/dist/node_modules/@allyhub/sheet/dist/xlsx/theme.js +1 -1
  279. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  280. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  281. package/dist/node_modules/@allyhub/sheet-extension/dist/build.js +1 -1
  282. package/dist/node_modules/@allyhub/sheet-extension/dist/cli/sheet.js +7 -7
  283. package/dist/node_modules/@allyhub/sheet-extension/dist/code.js +1 -1
  284. package/dist/node_modules/@allyhub/sheet-extension/dist/evaluate.js +2 -2
  285. package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +2 -2
  286. package/dist/node_modules/@allyhub/sheet-extension/dist/inspect.js +2 -2
  287. package/dist/node_modules/@allyhub/sheet-extension/dist/migrations.js +4 -0
  288. package/dist/node_modules/@allyhub/sheet-extension/dist/project-tools.js +1 -1
  289. package/dist/node_modules/@allyhub/sheet-extension/dist/tools.js +1 -1
  290. package/dist/node_modules/@allyhub/sheet-extension/package.json +7 -3
  291. package/dist/node_modules/@allyhub/slides-core/dist/api.js +2 -2
  292. package/dist/node_modules/@allyhub/slides-core/dist/blocks.js +2 -0
  293. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  294. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
  295. package/dist/node_modules/@allyhub/slides-core/dist/code.js +1 -1
  296. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  297. package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
  298. package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
  299. package/dist/node_modules/@allyhub/slides-core/dist/measure.js +1 -1
  300. package/dist/node_modules/@allyhub/slides-core/dist/model.js +1 -1
  301. package/dist/node_modules/@allyhub/slides-core/dist/office-layouts.js +2 -0
  302. package/dist/node_modules/@allyhub/slides-core/dist/office.js +1 -1
  303. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  304. package/dist/node_modules/@allyhub/slides-core/dist/script.js +2 -2
  305. package/dist/node_modules/@allyhub/slides-core/dist/styles/brief.js +2 -0
  306. package/dist/node_modules/@allyhub/slides-core/dist/styles/editorial.js +2 -0
  307. package/dist/node_modules/@allyhub/slides-core/dist/styles/index.js +2 -0
  308. package/dist/node_modules/@allyhub/slides-core/dist/styles/kit.js +2 -0
  309. package/dist/node_modules/@allyhub/slides-core/dist/styles/layouts.js +2 -0
  310. package/dist/node_modules/@allyhub/slides-core/dist/styles/pitch.js +2 -0
  311. package/dist/node_modules/@allyhub/slides-core/dist/styles/stage.js +2 -0
  312. package/dist/node_modules/@allyhub/slides-core/dist/styles/tiles.js +2 -0
  313. package/dist/node_modules/@allyhub/slides-core/dist/theme.js +1 -1
  314. package/dist/node_modules/@allyhub/slides-core/dist/units.js +1 -1
  315. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  316. package/dist/node_modules/@allyhub/slides-extension/dist/check.js +1 -1
  317. package/dist/node_modules/@allyhub/slides-extension/dist/cli/slides.js +2 -2
  318. package/dist/node_modules/@allyhub/slides-extension/dist/deck-fonts.js +1 -1
  319. package/dist/node_modules/@allyhub/slides-extension/dist/project-tools.js +1 -1
  320. package/dist/node_modules/@allyhub/slides-extension/package.json +24 -1
  321. package/dist/node_modules/@allyhub/slides-pptx/dist/charts.js +1 -1
  322. package/dist/node_modules/@allyhub/slides-pptx/dist/fonts.js +1 -1
  323. package/dist/node_modules/@allyhub/slides-pptx/dist/image-size.js +2 -0
  324. package/dist/node_modules/@allyhub/slides-pptx/dist/import/code.js +3 -3
  325. package/dist/node_modules/@allyhub/slides-pptx/dist/import/index.js +7 -2
  326. package/dist/node_modules/@allyhub/slides-pptx/dist/import/names.js +1 -1
  327. package/dist/node_modules/@allyhub/slides-pptx/dist/import/script.js +1 -1
  328. package/dist/node_modules/@allyhub/slides-pptx/dist/index.js +1 -1
  329. package/dist/node_modules/@allyhub/slides-pptx/dist/mtx.js +2 -0
  330. package/dist/node_modules/@allyhub/slides-pptx/dist/read/chart.js +3 -2
  331. package/dist/node_modules/@allyhub/slides-pptx/dist/read/chartex.js +3 -0
  332. package/dist/node_modules/@allyhub/slides-pptx/dist/read/common.js +1 -1
  333. package/dist/node_modules/@allyhub/slides-pptx/dist/read/index.js +2 -2
  334. package/dist/node_modules/@allyhub/slides-pptx/dist/read/shapes.js +1 -1
  335. package/dist/node_modules/@allyhub/slides-pptx/dist/read/table.js +1 -1
  336. package/dist/node_modules/@allyhub/slides-pptx/dist/read/text.js +1 -1
  337. package/dist/node_modules/@allyhub/slides-pptx/dist/read/timing.js +1 -1
  338. package/dist/node_modules/@allyhub/slides-pptx/dist/shapes.js +1 -1
  339. package/dist/node_modules/@allyhub/slides-pptx/dist/text.js +1 -1
  340. package/dist/node_modules/@allyhub/slides-pptx/dist/write.js +2 -2
  341. package/dist/node_modules/@allyhub/slides-pptx/dist/xml.js +3 -2
  342. package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
  343. package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +2 -2
  344. package/dist/node_modules/@allyhub/slides-runtime/dist/load.js +1 -1
  345. package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
  346. package/dist/node_modules/@allyhub/stage/package.json +1 -1
  347. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/LICENSE +93 -0
  348. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-400-italic.woff2 +0 -0
  349. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-400-normal.woff2 +0 -0
  350. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-700-italic.woff2 +0 -0
  351. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-700-normal.woff2 +0 -0
  352. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-ext-400-italic.woff2 +0 -0
  353. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-ext-400-normal.woff2 +0 -0
  354. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-ext-700-italic.woff2 +0 -0
  355. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/files/archivo-latin-ext-700-normal.woff2 +0 -0
  356. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-400-italic.css +1 -0
  357. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-400.css +1 -0
  358. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-700-italic.css +1 -0
  359. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-700.css +1 -0
  360. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-ext-400-italic.css +1 -0
  361. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-ext-400.css +1 -0
  362. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-ext-700-italic.css +1 -0
  363. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo/latin-ext-700.css +1 -0
  364. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo-black/LICENSE +93 -0
  365. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo-black/files/archivo-black-latin-400-normal.woff2 +0 -0
  366. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo-black/files/archivo-black-latin-ext-400-normal.woff2 +0 -0
  367. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo-black/latin-400.css +1 -0
  368. package/dist/node_modules/@allyhub/stage-page/dist/fonts/archivo-black/latin-ext-400.css +1 -0
  369. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/LICENSE +93 -0
  370. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-400-italic.woff2 +0 -0
  371. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  372. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-700-italic.woff2 +0 -0
  373. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-700-normal.woff2 +0 -0
  374. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-ext-400-italic.woff2 +0 -0
  375. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-ext-400-normal.woff2 +0 -0
  376. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-ext-700-italic.woff2 +0 -0
  377. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/files/ibm-plex-sans-latin-ext-700-normal.woff2 +0 -0
  378. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-400-italic.css +1 -0
  379. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-400.css +1 -0
  380. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-700-italic.css +1 -0
  381. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-700.css +1 -0
  382. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-ext-400-italic.css +1 -0
  383. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-ext-400.css +1 -0
  384. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-ext-700-italic.css +1 -0
  385. package/dist/node_modules/@allyhub/stage-page/dist/fonts/ibm-plex-sans/latin-ext-700.css +1 -0
  386. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/LICENSE +93 -0
  387. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-400-italic.woff2 +0 -0
  388. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-400-normal.woff2 +0 -0
  389. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-700-italic.woff2 +0 -0
  390. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-700-normal.woff2 +0 -0
  391. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-ext-400-italic.woff2 +0 -0
  392. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-ext-400-normal.woff2 +0 -0
  393. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-ext-700-italic.woff2 +0 -0
  394. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/files/inter-latin-ext-700-normal.woff2 +0 -0
  395. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-400-italic.css +1 -0
  396. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-400.css +1 -0
  397. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-700-italic.css +1 -0
  398. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-700.css +1 -0
  399. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-ext-400-italic.css +1 -0
  400. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-ext-400.css +1 -0
  401. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-ext-700-italic.css +1 -0
  402. package/dist/node_modules/@allyhub/stage-page/dist/fonts/inter-static/latin-ext-700.css +1 -0
  403. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/LICENSE +93 -0
  404. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-400-italic.woff2 +0 -0
  405. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-400-normal.woff2 +0 -0
  406. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-700-italic.woff2 +0 -0
  407. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-700-normal.woff2 +0 -0
  408. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-ext-400-italic.woff2 +0 -0
  409. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-ext-400-normal.woff2 +0 -0
  410. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-ext-700-italic.woff2 +0 -0
  411. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/files/newsreader-latin-ext-700-normal.woff2 +0 -0
  412. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-400-italic.css +1 -0
  413. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-400.css +1 -0
  414. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-700-italic.css +1 -0
  415. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-700.css +1 -0
  416. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-ext-400-italic.css +1 -0
  417. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-ext-400.css +1 -0
  418. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-ext-700-italic.css +1 -0
  419. package/dist/node_modules/@allyhub/stage-page/dist/fonts/newsreader/latin-ext-700.css +1 -0
  420. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/LICENSE +93 -0
  421. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-400-italic.woff2 +0 -0
  422. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-400-normal.woff2 +0 -0
  423. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-700-italic.woff2 +0 -0
  424. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-700-normal.woff2 +0 -0
  425. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-ext-400-italic.woff2 +0 -0
  426. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-ext-400-normal.woff2 +0 -0
  427. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-ext-700-italic.woff2 +0 -0
  428. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/files/plus-jakarta-sans-latin-ext-700-normal.woff2 +0 -0
  429. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-400-italic.css +1 -0
  430. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-400.css +1 -0
  431. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-700-italic.css +1 -0
  432. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-700.css +1 -0
  433. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-ext-400-italic.css +1 -0
  434. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-ext-400.css +1 -0
  435. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-ext-700-italic.css +1 -0
  436. package/dist/node_modules/@allyhub/stage-page/dist/fonts/plus-jakarta-sans/latin-ext-700.css +1 -0
  437. package/dist/node_modules/@allyhub/stage-page/dist/host.js +1 -1
  438. package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.html +42 -0
  439. package/dist/node_modules/@allyhub/stage-page/dist/style-faces.js +2 -0
  440. package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
  441. package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +96 -92
  442. package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
  443. package/dist/node_modules/@allyhub/telemetry/dist/limit.js +2 -0
  444. package/dist/node_modules/@allyhub/telemetry/package.json +5 -1
  445. package/dist/node_modules/@allyhub/text-extension/markup/allyhub.yaml +2 -0
  446. package/dist/node_modules/@allyhub/text-extension/markup-file/allyhub.yaml +2 -0
  447. package/dist/node_modules/@allyhub/text-extension/package.json +1 -1
  448. package/dist/node_modules/@allyhub/video-core/dist/footage-motion.js +1 -1
  449. package/dist/node_modules/@allyhub/video-core/dist/measure.js +1 -1
  450. package/dist/node_modules/@allyhub/video-core/dist/seams.js +1 -1
  451. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  452. package/dist/node_modules/@allyhub/video-extension/dist/cli/reference-text.js +1 -1
  453. package/dist/node_modules/@allyhub/video-extension/dist/inspect/index.js +1 -1
  454. package/dist/node_modules/@allyhub/video-extension/dist/inspect/joins.js +1 -1
  455. package/dist/node_modules/@allyhub/video-extension/dist/inspect/loop.js +3 -0
  456. package/dist/node_modules/@allyhub/video-extension/package.json +2 -25
  457. package/dist/node_modules/@allyhub/video-measure/dist/check.js +2 -2
  458. package/dist/node_modules/@allyhub/video-measure/dist/index.js +1 -1
  459. package/dist/node_modules/@allyhub/video-measure/dist/seams.js +1 -1
  460. package/dist/node_modules/@allyhub/video-measure/dist/version.js +1 -1
  461. package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
  462. package/dist/node_modules/@allyhub/video-sdk/dist/free.js +1 -1
  463. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  464. package/dist/node_modules/@allyhub/website/dist/index.js +1 -1
  465. package/dist/node_modules/@allyhub/website/dist/website.js +2 -2
  466. package/dist/node_modules/@allyhub/website/package.json +1 -1
  467. package/dist/node_modules/@allyhub/website-extension/package.json +3 -3
  468. package/dist/node_modules/@allyhub/x-extension/package.json +1 -3
  469. package/dist/node_modules/@allyhub/x-extension/skills/allyhub/references/x.md +3 -3
  470. package/dist/node_modules/@allyhub/x-model/package.json +1 -1
  471. package/dist/node_modules/@allyhub/x-view/package.json +1 -1
  472. package/dist/package.json +14 -14
  473. package/dist/self-upgrade.js +2 -0
  474. package/dist/text/batch-text.js +1 -1
  475. package/dist/text/facts-text.js +5 -5
  476. package/dist/text/format.js +2 -2
  477. package/dist/update-notice.js +3 -0
  478. package/dist/version.js +1 -1
  479. package/dist/works.js +1 -1
  480. package/editor-web/assets/{abnfDiagram-WEYOIA3C-DYaMS_BB.js → abnfDiagram-WEYOIA3C-BkVJMd53.js} +1 -1
  481. package/editor-web/assets/{architecture-WOLXFQ4H-g_Tjfl_y.js → architecture-WOLXFQ4H-C6rnaynZ.js} +1 -1
  482. package/editor-web/assets/{architectureDiagram-ZHVYKT53-CqdhofOL.js → architectureDiagram-ZHVYKT53-D3vrh8LK.js} +1 -1
  483. package/editor-web/assets/arrow-down-D-QZrqcz.js +1 -0
  484. package/editor-web/assets/arrow-up-B1zjKUHX.js +1 -0
  485. package/editor-web/assets/article-DHf6mOY_.js +7 -0
  486. package/editor-web/assets/article-Dns1-Xh-.js +3 -0
  487. package/editor-web/assets/{audio-lines-PZj77e7t.js → audio-lines-BFoW_IeO.js} +1 -1
  488. package/editor-web/assets/bar-button-CKPfx2AB.js +1 -0
  489. package/editor-web/assets/{blockDiagram-RJAE7QA3-Bc-28Bci.js → blockDiagram-RJAE7QA3-BKngt8H7.js} +1 -1
  490. package/editor-web/assets/{browser-C9NP0ZYz.js → browser-DEGNhKTV.js} +1 -1
  491. package/editor-web/assets/{c4Diagram-XDPPPE54-CTGJb8FB.js → c4Diagram-XDPPPE54-j7sUELqF.js} +1 -1
  492. package/editor-web/assets/calc-worker-Cr4a0xmt.js +168 -0
  493. package/editor-web/assets/channel-CVWSV3su.js +1 -0
  494. package/editor-web/assets/{chart-no-axes-column-Be0lFcGF.js → chart-no-axes-column-Dyy25XZ_.js} +1 -1
  495. package/editor-web/assets/chip-Bn_9JRRG.js +1 -0
  496. package/editor-web/assets/{chunk-2E7WHVMD-B2MPOVTU.js → chunk-2E7WHVMD-BXa-uRSi.js} +1 -1
  497. package/editor-web/assets/{chunk-4EMNKR2T-BUV1ZHP0.js → chunk-4EMNKR2T-B3ntcsZN.js} +1 -1
  498. package/editor-web/assets/{chunk-55XCU76K-BZlpspL5.js → chunk-55XCU76K-AMvnFwUg.js} +1 -1
  499. package/editor-web/assets/{chunk-7S6XSTFO-CpKeisWE.js → chunk-7S6XSTFO-BA6esfFu.js} +1 -1
  500. package/editor-web/assets/{chunk-AQDTSKZB-BJqwAPyo.js → chunk-AQDTSKZB-BT_vANXs.js} +1 -1
  501. package/editor-web/assets/{chunk-DSNLSHJZ-D6oPWl_W.js → chunk-DSNLSHJZ-DoUgmzGB.js} +1 -1
  502. package/editor-web/assets/{chunk-HAGFOTED-B5pk4MZF.js → chunk-HAGFOTED-DtnIrCZb.js} +1 -1
  503. package/editor-web/assets/{chunk-HNE4Q36P-DHbSPvxQ.js → chunk-HNE4Q36P-BlPwQx3_.js} +1 -1
  504. package/editor-web/assets/{chunk-NQOKRVIF-CcL_GcRA.js → chunk-NQOKRVIF-D2r7jp2r.js} +1 -1
  505. package/editor-web/assets/{chunk-UHW7PFBP-YgiOL6XE.js → chunk-UHW7PFBP-Cmc0_F5o.js} +1 -1
  506. package/editor-web/assets/{chunk-VQ5W62QI-p14b4UYc.js → chunk-VQ5W62QI-nJSMqAr0.js} +1 -1
  507. package/editor-web/assets/{chunk-WQQL4CDK-BWW0x-XH.js → chunk-WQQL4CDK-Btq2nbF6.js} +1 -1
  508. package/editor-web/assets/{chunk-YZO67HFG-oG3qd68C.js → chunk-YZO67HFG-DTbcCoGt.js} +1 -1
  509. package/editor-web/assets/{chunk-ZAUX2LTX-CpcheH0u.js → chunk-ZAUX2LTX-DVwkg-2N.js} +1 -1
  510. package/editor-web/assets/{chunk-ZCHMQSOR-cWQvLl1w.js → chunk-ZCHMQSOR-BV39jOOE.js} +1 -1
  511. package/editor-web/assets/{classDiagram-v2-4MYWR3UA-7PG7YcdU.js → classDiagram-v2-4MYWR3UA-Cj74-fhM.js} +1 -1
  512. package/editor-web/assets/code-Ch6AB5bZ.js +1 -0
  513. package/editor-web/assets/collaborator-XiHOxwGM.js +1 -0
  514. package/editor-web/assets/{copy-CuJSs0nI.js → copy-SoaMYqsN.js} +1 -1
  515. package/editor-web/assets/{createLucideIcon-lm_6n8YT.js → createLucideIcon-euu7Wcd9.js} +1 -1
  516. package/editor-web/assets/{cynefin-EF2NZ3EQ-CtcknEQ_.js → cynefin-EF2NZ3EQ-C0CkiipV.js} +1 -1
  517. package/editor-web/assets/{cynefinDiagram-WF24UDRP-Ca7VIsjN.js → cynefinDiagram-WF24UDRP-hdsnJ4cI.js} +1 -1
  518. package/editor-web/assets/{dagre-NK4GIZVX-BzcSLtsr.js → dagre-NK4GIZVX-CC7WSgaK.js} +1 -1
  519. package/editor-web/assets/deck-DQpNIS2p.js +1 -0
  520. package/editor-web/assets/{diagram-CBK3MWTC-DpRmTGlG.js → diagram-CBK3MWTC-DmaVm13J.js} +1 -1
  521. package/editor-web/assets/{diagram-I5XIIV2D-BTrs_AX8.js → diagram-I5XIIV2D-De8jqp7b.js} +1 -1
  522. package/editor-web/assets/{diagram-ODIL2UCW-CkIVjPqH.js → diagram-ODIL2UCW-B5pBTulX.js} +1 -1
  523. package/editor-web/assets/{diagram-PFBEJUXE-BlFMbAG1.js → diagram-PFBEJUXE-BYsXg5_w.js} +1 -1
  524. package/editor-web/assets/{diagram-RJA3I4VV-D3f8VJ-D.js → diagram-RJA3I4VV-DZ8f6bYe.js} +1 -1
  525. package/editor-web/assets/{diagram-TYUNFSNR-Bbpngj6F.js → diagram-TYUNFSNR-qXHUsauD.js} +1 -1
  526. package/editor-web/assets/dist--z0ZHp4T.js +16 -0
  527. package/editor-web/assets/dist-9kuRjUTN.js +41 -0
  528. package/editor-web/assets/dist-B3rd02Cg.js +6 -0
  529. package/editor-web/assets/dist-B5GOGGEe.js +1 -0
  530. package/editor-web/assets/dist-Bx6q9kCu.js +1 -0
  531. package/editor-web/assets/dist-C4hHtrJr.js +1 -0
  532. package/editor-web/assets/dist-CCXJewsi.js +19 -0
  533. package/editor-web/assets/dist-CfK2BLl8.js +4 -0
  534. package/editor-web/assets/dist-Cmux3oJ_.js +1 -0
  535. package/editor-web/assets/dist-Cspf85KV.js +6 -0
  536. package/editor-web/assets/dist-DA72-4WB.js +82 -0
  537. package/editor-web/assets/{dist-DruvDNQe.js → dist-DAhe-kFC.js} +5 -5
  538. package/editor-web/assets/dist-DIJnhQFK.js +9 -0
  539. package/editor-web/assets/dist-DOrGo1GD.js +19 -0
  540. package/editor-web/assets/{dist-Bd8IxQPP.js → dist-DQ6RpEJD.js} +2 -2
  541. package/editor-web/assets/dist-DjiCHlSu.js +35 -0
  542. package/editor-web/assets/dist-Do4a40Wn.js +19 -0
  543. package/editor-web/assets/dist-FKEWS3Co.js +547 -0
  544. package/editor-web/assets/dist-QKd2i6kG.js +5 -0
  545. package/editor-web/assets/dist-SGnOfLhx.js +24 -0
  546. package/editor-web/assets/dist-VmVB7tl4.js +3 -0
  547. package/editor-web/assets/{docx-draw-CoK1oqQD.js → docx-draw-L54blreB.js} +1 -1
  548. package/editor-web/assets/{ebnfDiagram-V4P3TTPT-BaKj-yL6.js → ebnfDiagram-V4P3TTPT-B7-IfVI-.js} +1 -1
  549. package/editor-web/assets/{elk-QONTBCTQ-Cn2qv1_U.js → elk-QONTBCTQ-Gj_WaeBn.js} +1 -1
  550. package/editor-web/assets/{erDiagram-KYQIGQAA-Bd7AEIDo.js → erDiagram-KYQIGQAA-BDF6Qoqx.js} +1 -1
  551. package/editor-web/assets/esm-PQD5Pn8a.js +21 -0
  552. package/editor-web/assets/{eventmodeling-K75KTNOO-Sfp7_461.js → eventmodeling-K75KTNOO-elxVXXEe.js} +1 -1
  553. package/editor-web/assets/{file-question-mark-DlIjUK37.js → file-question-mark-PeZgyqkK.js} +1 -1
  554. package/editor-web/assets/flowDiagram-IUGLLWBU-B-25n8zE.js +1 -0
  555. package/editor-web/assets/{ganttDiagram-R7GPNTJY-CBqcGdHI.js → ganttDiagram-R7GPNTJY-CEogW3jW.js} +1 -1
  556. package/editor-web/assets/{gitGraph-VSP46ZUC-WTokXKTW.js → gitGraph-VSP46ZUC-Bh9cRWFa.js} +1 -1
  557. package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-BIWZHD9q.js → gitGraphDiagram-PDYL7XHY-BQAvdM_V.js} +1 -1
  558. package/editor-web/assets/{group-BdrTp7gi.js → group-DwM2yqU8.js} +1 -1
  559. package/editor-web/assets/hint-CbwoSBMw.js +1 -0
  560. package/editor-web/assets/index-CXisi0Cj.css +2 -0
  561. package/editor-web/assets/index-wMlfx8aT.js +28 -0
  562. package/editor-web/assets/{info-OHQRW6UA-COC6G-_J.js → info-OHQRW6UA-CdPrqere.js} +1 -1
  563. package/editor-web/assets/{infoDiagram-MVDRKAX5-DpaqdKBD.js → infoDiagram-MVDRKAX5-uwIMeP44.js} +1 -1
  564. package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-Dyn2MAy1.js → ishikawaDiagram-HPEHV2GE-rtfvqK7E.js} +1 -1
  565. package/editor-web/assets/iso-UwGLGD3F.js +1 -0
  566. package/editor-web/assets/{italic-zw4_eUNF.js → italic-BV7iHxoP.js} +1 -1
  567. package/editor-web/assets/{journeyDiagram-BOSHW7O7-DeSVfmm7.js → journeyDiagram-BOSHW7O7-mmhfIyVG.js} +1 -1
  568. package/editor-web/assets/{kanban-definition-FNSA4HC5-Bfg0lj7B.js → kanban-definition-FNSA4HC5-Fe7jBsi-.js} +1 -1
  569. package/editor-web/assets/{link-DopSU3aa.js → link-CFOv3nz-.js} +1 -1
  570. package/editor-web/assets/{mermaid-parser.core-CyhovuYE.js → mermaid-parser.core-BxOSjBH9.js} +3 -3
  571. package/editor-web/assets/{mermaid.core-Dx1fBVUG.js → mermaid.core-BOln9YdH.js} +4 -4
  572. package/editor-web/assets/{mindmap-definition-6OY57UG3-QEU2HF_m.js → mindmap-definition-6OY57UG3-M3Q1LOtO.js} +1 -1
  573. package/editor-web/assets/minus-ngE8owxs.js +1 -0
  574. package/editor-web/assets/{packet-JDAUHWVQ-ReJTa_hw.js → packet-JDAUHWVQ-Dbb0TUG6.js} +1 -1
  575. package/editor-web/assets/{pegDiagram-ECIUJNBX-Bo1jFrvb.js → pegDiagram-ECIUJNBX-BZMRpSFC.js} +1 -1
  576. package/editor-web/assets/{pie-XZMESJXO-BrtYafNA.js → pie-XZMESJXO-Ctm9XdKp.js} +1 -1
  577. package/editor-web/assets/{pieDiagram-GNMPY74T-Cj0zQqs_.js → pieDiagram-GNMPY74T-cGbs5ZTl.js} +1 -1
  578. package/editor-web/assets/progress-DZQTiRLv.js +6 -0
  579. package/editor-web/assets/{quadrantDiagram-D57K4MC3-D5npDAVn.js → quadrantDiagram-D57K4MC3-BUe_zsxT.js} +1 -1
  580. package/editor-web/assets/{radar-ABXABTNO-C8RDrRqi.js → radar-ABXABTNO-CCmKtqLs.js} +1 -1
  581. package/editor-web/assets/{railroad-I3PHUGI6-ebDrmYTK.js → railroad-I3PHUGI6-k-yhjhjA.js} +1 -1
  582. package/editor-web/assets/{railroad-abnf-LNEFI6M7-BxKuqg6V.js → railroad-abnf-LNEFI6M7-B-PvntB3.js} +1 -1
  583. package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-DOclnfpr.js → railroad-ebnf-DWYD2UWJ-Ds2rua1h.js} +1 -1
  584. package/editor-web/assets/{railroad-peg-JR7BVNR7-DN0A1fpq.js → railroad-peg-JR7BVNR7-jNZ2wEp2.js} +1 -1
  585. package/editor-web/assets/{railroadDiagram-Y72NRBL7-B3PjoVWw.js → railroadDiagram-Y72NRBL7-CTqSQ15w.js} +1 -1
  586. package/editor-web/assets/react-Byupo4pA.js +1 -0
  587. package/editor-web/assets/replace-CLLMtF4e.js +1 -0
  588. package/editor-web/assets/{requirementDiagram-EQYSW5RA-DLdzkQk5.js → requirementDiagram-EQYSW5RA-CUblhR5M.js} +1 -1
  589. package/editor-web/assets/ribbon-DajdQ_Ya.js +1 -0
  590. package/editor-web/assets/row-Bei9HNEe.js +1 -0
  591. package/editor-web/assets/{sankeyDiagram-SY24JHO5-Dip4Piv_.js → sankeyDiagram-SY24JHO5-nSz6zDX3.js} +1 -1
  592. package/editor-web/assets/schemas-C21MyseF.js +1 -0
  593. package/editor-web/assets/{iso-DoC-ZoBr.js → schemas-DlRAoVtq.js} +1 -1
  594. package/editor-web/assets/{scissors-B_xOiUhd.js → scissors-m6QcoEf2.js} +1 -1
  595. package/editor-web/assets/search-D75Bi2GU.js +1 -0
  596. package/editor-web/assets/{sequenceDiagram-BLEHNHQU-QnPcoybL.js → sequenceDiagram-BLEHNHQU-DxTpOYuo.js} +1 -1
  597. package/editor-web/assets/{session-DMlLCFWg.js → session-BhClkDyr.js} +1 -1
  598. package/editor-web/assets/{sigma-DSUsJhMn.js → sigma-B4AWtnVA.js} +1 -1
  599. package/editor-web/assets/snapshots-DwGHDN3t.js +1 -0
  600. package/editor-web/assets/sound-DkR3qxSt.js +1 -0
  601. package/editor-web/assets/split-DBAbwPZ5.js +3 -0
  602. package/editor-web/assets/{square-arrow-out-up-right-DF5dvsSp.js → square-arrow-out-up-right-1NqFsNDe.js} +1 -1
  603. package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-D103CiMX.js → stateDiagram-v2-A6IESKWZ-C3e14iHY.js} +1 -1
  604. package/editor-web/assets/{sticky-note-BdkIu5_D.js → sticky-note-s4QfzaBB.js} +1 -1
  605. package/editor-web/assets/surface-CIF0Ae0z.js +1 -0
  606. package/editor-web/assets/swatch-BUzr_XmH.js +1 -0
  607. package/editor-web/assets/{swimlanes-B3ENRKFQ-y4gCqEoa.js → swimlanes-B3ENRKFQ-DPPdzNzu.js} +1 -1
  608. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-B8n3zOw_.js +8 -0
  609. package/editor-web/assets/switch-DrZxoPQS.js +1 -0
  610. package/editor-web/assets/{syntax-CU_WPKxt.js → syntax-emXV4DnN.js} +1 -1
  611. package/editor-web/assets/table-BW43XXVd.js +1 -0
  612. package/editor-web/assets/tabs-BwU2E7bU.js +1 -0
  613. package/editor-web/assets/text-wrap-Baus6l-V.js +1 -0
  614. package/editor-web/assets/textarea-BX_ax3X8.js +1 -0
  615. package/editor-web/assets/{timeline-definition-JXYKGLGB-BMp76v4V.js → timeline-definition-JXYKGLGB-DRTJ1_Er.js} +1 -1
  616. package/editor-web/assets/tolerant-DM9s0Mt1.js +1 -0
  617. package/editor-web/assets/{treeView-D4JQ5SDB-Q_GYyk0b.js → treeView-D4JQ5SDB-BYJ_m-i5.js} +1 -1
  618. package/editor-web/assets/{treemap-SAJKECNS-B5lRWdQB.js → treemap-SAJKECNS-BcU6I6Rg.js} +1 -1
  619. package/editor-web/assets/type-CvZ0HZsV.js +41 -0
  620. package/editor-web/assets/{undo-2-C47jrRp5.js → undo-2-DCbMWoug.js} +1 -1
  621. package/editor-web/assets/{usecaseDiagram-WPOLBNNX--QRllA-U.js → usecaseDiagram-WPOLBNNX-YV92pS4o.js} +1 -1
  622. package/editor-web/assets/{vennDiagram-Q3Y3IDCW-CzkATPA3.js → vennDiagram-Q3Y3IDCW-oAvfHZtf.js} +1 -1
  623. package/editor-web/assets/video-SJvDRCJK.js +1 -0
  624. package/editor-web/assets/{wardley-7MLQ67FV-BXzwcdJa.js → wardley-7MLQ67FV-BLNiqxtt.js} +1 -1
  625. package/editor-web/assets/{wardleyDiagram-IVAIDKWA-BQvC8Agx.js → wardleyDiagram-IVAIDKWA-SppgC6xW.js} +1 -1
  626. package/editor-web/assets/{whole-word-D3ZAtnkw.js → whole-word-C9TkGBCY.js} +1 -1
  627. package/editor-web/assets/{words-CaUHhQHf.js → words-BUlNNuH2.js} +3 -3
  628. package/editor-web/assets/words-zMedmPWc.js +3 -0
  629. package/editor-web/assets/workbook-BZKYx4WB.js +41 -0
  630. package/editor-web/assets/{xychartDiagram-4URNHDU4-aY-lsD5o.js → xychartDiagram-4URNHDU4-BHMn_jwJ.js} +1 -1
  631. package/editor-web/assets/{zoom-in-PgsC94hP.js → zoom-in-yAGKspfC.js} +1 -1
  632. package/editor-web/index.html +9 -8
  633. package/package.json +3 -3
  634. package/CHANGELOG.md +0 -251
  635. package/dist/commands/render.js +0 -3
  636. package/dist/node_modules/@allyhub/video-extension/dist/inspect/motion.js +0 -4
  637. package/dist/node_modules/@allyhub/video-measure/dist/still.js +0 -2
  638. package/editor-web/assets/arrow-down-B8VUPCGi.js +0 -1
  639. package/editor-web/assets/arrow-up-Ds4juY8X.js +0 -1
  640. package/editor-web/assets/article-8evPh712.js +0 -3
  641. package/editor-web/assets/article-BhRtWYMd.js +0 -7
  642. package/editor-web/assets/bar-button-J9vbfzTx.js +0 -1
  643. package/editor-web/assets/calc-worker-oEIqrrTM.js +0 -45
  644. package/editor-web/assets/channel-wIj_OqDm.js +0 -1
  645. package/editor-web/assets/chart-amT4lgX3.js +0 -2
  646. package/editor-web/assets/chart-file-dGiRgFcH.js +0 -1
  647. package/editor-web/assets/code-CD-CbJG9.js +0 -1
  648. package/editor-web/assets/collaborator-BU4qU7O3.js +0 -1
  649. package/editor-web/assets/deck-C7fN0Qtn.js +0 -1
  650. package/editor-web/assets/dist-3iovns9K.js +0 -16
  651. package/editor-web/assets/dist-BkHnbOEj.js +0 -4
  652. package/editor-web/assets/dist-BvOrNcK-.js +0 -19
  653. package/editor-web/assets/dist-CEIszq39.js +0 -1
  654. package/editor-web/assets/dist-CU5RbLNH.js +0 -1
  655. package/editor-web/assets/dist-CWZj8IAm.js +0 -1
  656. package/editor-web/assets/dist-C_Mtrnif.js +0 -17
  657. package/editor-web/assets/dist-CdqpwdCV.js +0 -24
  658. package/editor-web/assets/dist-CjT76RAw.js +0 -43
  659. package/editor-web/assets/dist-CpzEn9T8.js +0 -6
  660. package/editor-web/assets/dist-CrFYWl5-.js +0 -3
  661. package/editor-web/assets/dist-D3C6FyrO.js +0 -82
  662. package/editor-web/assets/dist-D4eBFGVL.js +0 -1
  663. package/editor-web/assets/dist-DTcjb3cP.js +0 -18
  664. package/editor-web/assets/dist-D_WSM29I.js +0 -17
  665. package/editor-web/assets/dist-Dp_9ISjP.js +0 -531
  666. package/editor-web/assets/dist-J-tPYKGS.js +0 -5
  667. package/editor-web/assets/dist-YW8hS4IM.js +0 -9
  668. package/editor-web/assets/esm-Cjv8ogpP.js +0 -21
  669. package/editor-web/assets/file-exclamation-point-_L3ElCJ5.js +0 -1
  670. package/editor-web/assets/flowDiagram-IUGLLWBU-BlVUglzw.js +0 -1
  671. package/editor-web/assets/hint-rlht0uxG.js +0 -1
  672. package/editor-web/assets/index-BQWZnyAQ.js +0 -28
  673. package/editor-web/assets/index-Dvh1t1om.css +0 -2
  674. package/editor-web/assets/minus-CbPnUIOy.js +0 -1
  675. package/editor-web/assets/progress-CwKcXARv.js +0 -6
  676. package/editor-web/assets/props-form-BpSXbrSF.js +0 -1
  677. package/editor-web/assets/react-Edyoga_4.js +0 -1
  678. package/editor-web/assets/row-C_svyL8o.js +0 -1
  679. package/editor-web/assets/schemas-CQ_UU8-Z.js +0 -1
  680. package/editor-web/assets/search-Ba2BbT6T.js +0 -1
  681. package/editor-web/assets/slides-7xWhREpt.js +0 -1
  682. package/editor-web/assets/snapshots-BLX4NTQC.js +0 -1
  683. package/editor-web/assets/sound-bTlco_K3.js +0 -1
  684. package/editor-web/assets/split-tFGKk-x8.js +0 -3
  685. package/editor-web/assets/strikethrough-BwXWi4zg.js +0 -1
  686. package/editor-web/assets/surface-DtCjIlrq.js +0 -1
  687. package/editor-web/assets/svg-CWIBMIQ9.js +0 -1
  688. package/editor-web/assets/swatch-DhztHwPU.js +0 -1
  689. package/editor-web/assets/swimlanesDiagram-AYQRV4AK-DKzB_wSf.js +0 -8
  690. package/editor-web/assets/switch-8MU4Nfxe.js +0 -1
  691. package/editor-web/assets/table-DRbddzx0.js +0 -1
  692. package/editor-web/assets/tabs-CuEawka3.js +0 -1
  693. package/editor-web/assets/tag-CIfWT8B_.js +0 -1
  694. package/editor-web/assets/text-align-start-Cic2-TLh.js +0 -1
  695. package/editor-web/assets/textarea-D7TnPwv1.js +0 -1
  696. package/editor-web/assets/video-D0uTbHWx.js +0 -1
  697. package/editor-web/assets/words-XlXG79Ur.js +0 -3
  698. package/editor-web/assets/workbook-CiCXkjmN.js +0 -45
  699. package/editor-web/assets/x-DlhyIKuu.js +0 -41
@@ -1,4 +1,4 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{randomBytes as q}from"node:crypto";import{mkdir as $,readFile as O,readdir as I,rename as x,rm as N,stat as j,writeFile as A}from"node:fs/promises";import{dirname as g,extname as B,join as h,posix as C}from"node:path";import D from"write-file-atomic";import{listWork as H,moveEdits as z,movedPath as P,unlistedWork as M}from"@allyhub/build";import{CACHE_DIR as K,TRASH_DIR as f,WORK_FILE as S,WorkItemSchema as X}from"@allyhub/formats";import{RPC_ERROR as d,RpcError as p}from"@allyhub/protocol";import{DELETED_FILE as Y,emptyTrashOlderThan as G,hasErrorCode as Q,shortNameOf as V,utcStampOf as Z}from"./deletion.js";import{current as F,fileIn as m,pathProblem as J,versionOf as b}from"./paths.js";import{writeProblems as tt}from"./validate.js";export const UPLOAD_MAX_BYTES=200*1024*1024,LIST_LIMIT=5e3;const et=[K,f];function it(v){const i=(v.split(/[/\\]/u).pop()??"").replace(/\p{Cc}/gu,"").replace(/^\.+/u,"").trim();return i===""?"file":i}export class Writer{root;kinds;wrote;writable;queue=Promise.resolve();constructor(t,i,n=()=>{},o=()=>Promise.resolve()){this.root=t,this.kinds=i,this.wrote=n,this.writable=o}serial(t){const i=async()=>(await this.writable(),t()),n=this.queue.then(i,i);return this.queue=n.catch(()=>{}),n}async read(t){const i=await F(await m(this.root,t));return i?{text:i.bytes.toString("utf8"),version:i.version}:{text:"",version:null}}write(t,i,n,o){return this.serial(async()=>{const s=await m(this.root,t,{write:!0}),a=await F(s),w=a?.version??null;if(w!==n)throw new p(d.conflict,`${t} changed since it was read.`,{text:a?.bytes.toString("utf8")??"",version:w});const c=await tt(t,i,this.kinds,this.root);if(c.length>0)throw new p(d.invalid,`${t} would not be a file AllyHub can read: ${c[0]??""}`,{problems:c});const r=b(i);return r===w||(await $(g(s),{recursive:!0}),await D(s,i),this.wrote([{path:t,version:r,text:i}],o)),r})}upload(t,i,n,o){return n.length>UPLOAD_MAX_BYTES?Promise.reject(new p(d.invalid,`${i} is larger than ${String(UPLOAD_MAX_BYTES/1024/1024)} MB.`)):this.serial(async()=>{const s=it(i),a=B(s),w=s.slice(0,s.length-a.length);for(let c=1;;c++){const r=c===1?s:`${w}-${String(c)}${a}`,e=t===""?r:`${t}/${r}`,u=await m(this.root,e,{write:!0});if(!await y(u))return await $(g(u),{recursive:!0}),await A(u,n,{flag:"wx"}),this.wrote([{path:e,version:b(n)}],o),e}})}move(t,i,n){return this.serial(async()=>{const o=await m(this.root,t,{write:!0}),s=await m(this.root,i,{write:!0});if(i===t||i.startsWith(`${t}/`))throw new p(d.invalid,`${t} cannot move into itself.`);if(!await y(o))throw new p(d.notFound,`There is no ${t}.`);if(await y(s))throw new p(d.conflict,`${i} is taken.`,{text:"",version:null});const a=await z(this.root,t,i);for(const e of a)await D(h(this.root,e.path),e.text);const w=await R(t,o);await $(g(s),{recursive:!0}),await x(o,s);const c=w.map(e=>({path:e,version:null}));for(const e of w){const u=P(e,t,i);c.push({path:u,version:(await F(h(this.root,u)))?.version??null})}const r=a.map(e=>P(e.path,t,i));for(const e of a)P(e.path,t,i)===e.path&&c.push({path:e.path,version:b(e.text)});return this.wrote(c,n),r})}remove(t,i){return this.serial(async()=>{const n=await m(this.root,t,{write:!0});if(!await y(n))throw new p(d.notFound,`There is no ${t}.`);const o=await R(t,n),s=`${String(Date.now())}-${q(4).toString("hex")}`,a=h(this.root,f,s,...t.split("/"));await $(g(a),{recursive:!0}),await x(n,a);const w=o.map(k=>({path:k,version:null})),c=h(this.root,S),r=await O(c,"utf8").catch(()=>{}),e=r===void 0?void 0:M(r,t);e!==void 0&&(await D(c,e.text),w.push({path:S,version:b(e.text)}));const u={path:t,removed:Date.now(),...e===void 0?{}:{listed:e.items}};return await A(h(this.root,f,`${s}.json`),`${JSON.stringify(u)}
3
- `),this.wrote(w,i),s})}moveToTrashAndUnlist(t,i){return this.serial(async()=>{const n=await t.planNow(),{item:o,name:s,kind:a,entry:w}=n,c=(t.now??(()=>new Date))();await G(this.root,t.keptDays,c);const r=`${Z(c)}-${V(o)}`;let e=`${f}/${r}`;for(let l=2;await y(h(this.root,e));l++)e=`${f}/${r}-${String(l)}`;const u=h(this.root,S),k=await O(u,"utf8").catch(l=>{if(!Q(l,"ENOENT"))throw l}),T=k===void 0?void 0:M(k,w),W=[];try{for(const l of n.moves){const E=await m(this.root,l,{write:!0}),L=h(this.root,e,...l.split("/"));await $(g(L),{recursive:!0}),await x(E,L),W.push(l)}}catch(l){for(const E of W.reverse())await x(h(this.root,e,...E.split("/")),h(this.root,...E.split("/")));throw await N(h(this.root,e),{recursive:!0,force:!0}),l}const U={deletedAt:c.toISOString(),item:o,name:s,...a===void 0?{}:{kind:a},listed:T?.entries??[],files:n.moves.map(l=>({path:l}))};await $(h(this.root,e),{recursive:!0}),await A(h(this.root,e,Y),`${JSON.stringify(U,null,2)}
4
- `);const _=n.moves.map(l=>({path:l,version:null}));return T!==void 0&&(await D(u,T.text),_.push({path:S,version:b(T.text)})),this.wrote(_,i),{plan:n,trash:e,moved:n.moves}})}async trash(){const t=h(this.root,f),i=await I(t).catch(()=>[]),n=[];for(const o of i){if(!o.endsWith(".json"))continue;const s=await O(h(t,o),"utf8").then(a=>JSON.parse(a)).catch(()=>{});typeof s?.path!="string"||typeof s.removed!="number"||J(s.path)!==void 0||n.push({id:o.slice(0,-5),path:s.path,removed:s.removed})}return n.sort((o,s)=>s.removed-o.removed)}restore(t,i){return this.serial(async()=>{const n=(await this.trash()).find(e=>e.id===t);if(!n)throw new p(d.notFound,`Nothing in the bin is ${t}.`);const o=await m(this.root,n.path,{write:!0});if(await y(o))throw new p(d.conflict,`${n.path} is there again: move it before putting this back.`,{text:"",version:null});const s=h(this.root,f,t,...n.path.split("/")),a=await O(h(this.root,f,`${t}.json`),"utf8").then(e=>JSON.parse(e).listed).catch(()=>{});await $(g(o),{recursive:!0}),await x(s,o),await N(h(this.root,f,t),{recursive:!0,force:!0}),await N(h(this.root,f,`${t}.json`),{force:!0});const w=await R(n.path,o),c=(Array.isArray(a)?a:[]).flatMap(e=>{const u=X.safeParse(e);return u.success?[u.data]:[]});for(const e of c)await H(this.root,e);c.length>0&&w.push(S);const r=[];for(const e of w)r.push({path:e,version:(await F(h(this.root,e)))?.version??null});return this.wrote(r,i),n.path})}async list(t){const i=t===""?this.root:await m(this.root,t),n=[],o=[],s=async(a,w)=>{const c=await I(a,{withFileTypes:!0}).catch(()=>[]);for(const r of c.sort((e,u)=>e.name.localeCompare(u.name))){if(n.length>=LIST_LIMIT)return;const e=w===""?r.name:`${w}/${r.name}`;if(J(e)===void 0&&!(et.some(u=>e===u)&&!(t===e||t.startsWith(`${e}/`)))){if(r.isDirectory())o.push(e),await s(h(a,r.name),e);else if(r.isFile()){const u=await j(h(a,r.name)).catch(()=>{});u&&n.push({path:e,size:u.size,modified:u.mtimeMs})}}}};return await s(i,t),{files:n,dirs:o}}}const y=v=>j(v).then(()=>!0,()=>!1);async function R(v,t){const i=await j(t).catch(()=>{});if(!i)return[];if(!i.isDirectory())return[v];const n=[],o=await I(t,{recursive:!0,withFileTypes:!0});for(const s of o)s.isFile()&&n.push(C.join(v,C.relative(t.split("\\").join("/"),h(s.parentPath,s.name).split("\\").join("/"))));return n}
2
+ import{randomBytes as q}from"node:crypto";import{mkdir as $,readFile as I,readdir as F,rename as b,rm as N,stat as j,writeFile as A}from"node:fs/promises";import{dirname as g,extname as B,join as h,posix as C}from"node:path";import O from"write-file-atomic";import{listWork as H,moveEdits as z,movedPath as P,unlistedWork as M}from"@allyhub/build";import{CACHE_DIR as K,TRASH_DIR as f,WORK_FILE as x,WorkItemSchema as X}from"@allyhub/formats";import{RPC_ERROR as d,RpcError as p}from"@allyhub/protocol";import{DELETED_FILE as Y,emptyTrashOlderThan as G,hasErrorCode as Q,shortNameOf as V,utcStampOf as Z}from"./deletion.js";import{current as D,fileIn as m,pathProblem as J,versionOf as S}from"./paths.js";import{writeProblems as tt}from"./validate.js";export const UPLOAD_MAX_BYTES=200*1024*1024,LIST_LIMIT=5e3;const et=[K,f];function it(v){const i=(v.split(/[/\\]/u).pop()??"").replace(/\p{Cc}/gu,"").replace(/^\.+/u,"").trim();return i===""?"file":i}export class Writer{root;kinds;wrote;writable;unreadableIn;queue=Promise.resolve();constructor(t,i,n=()=>{},r=()=>Promise.resolve(),s){this.root=t,this.kinds=i,this.wrote=n,this.writable=r,this.unreadableIn=s}serial(t){const i=async()=>(await this.writable(),t()),n=this.queue.then(i,i);return this.queue=n.catch(()=>{}),n}async read(t){const i=await D(await m(this.root,t));return i?{text:i.bytes.toString("utf8"),version:i.version}:{text:"",version:null}}write(t,i,n,r){return this.serial(async()=>{const s=await m(this.root,t,{write:!0}),a=await D(s),l=a?.version??null;if(l!==n)throw new p(d.conflict,`${t} changed since it was read.`,{text:a?.bytes.toString("utf8")??"",version:l});const c=await tt(t,i,this.kinds,this.root,this.unreadableIn);if(c.length>0)throw new p(d.invalid,`${t} would not be a file AllyHub can read: ${c[0]??""}`,{problems:c});const o=S(i);return o===l||(await $(g(s),{recursive:!0}),await O(s,i),this.wrote([{path:t,version:o,text:i}],r)),o})}upload(t,i,n,r){return n.length>UPLOAD_MAX_BYTES?Promise.reject(new p(d.invalid,`${i} is larger than ${String(UPLOAD_MAX_BYTES/1024/1024)} MB.`)):this.serial(async()=>{const s=it(i),a=B(s),l=s.slice(0,s.length-a.length);for(let c=1;;c++){const o=c===1?s:`${l}-${String(c)}${a}`,e=t===""?o:`${t}/${o}`,u=await m(this.root,e,{write:!0});if(!await y(u))return await $(g(u),{recursive:!0}),await A(u,n,{flag:"wx"}),this.wrote([{path:e,version:S(n)}],r),e}})}move(t,i,n){return this.serial(async()=>{const r=await m(this.root,t,{write:!0}),s=await m(this.root,i,{write:!0});if(i===t||i.startsWith(`${t}/`))throw new p(d.invalid,`${t} cannot move into itself.`);if(!await y(r))throw new p(d.notFound,`There is no ${t}.`);if(await y(s))throw new p(d.conflict,`${i} is taken.`,{text:"",version:null});const a=await z(this.root,t,i);for(const e of a)await O(h(this.root,e.path),e.text);const l=await R(t,r);await $(g(s),{recursive:!0}),await b(r,s);const c=l.map(e=>({path:e,version:null}));for(const e of l){const u=P(e,t,i);c.push({path:u,version:(await D(h(this.root,u)))?.version??null})}const o=a.map(e=>P(e.path,t,i));for(const e of a)P(e.path,t,i)===e.path&&c.push({path:e.path,version:S(e.text)});return this.wrote(c,n),o})}remove(t,i){return this.serial(async()=>{const n=await m(this.root,t,{write:!0});if(!await y(n))throw new p(d.notFound,`There is no ${t}.`);const r=await R(t,n),s=`${String(Date.now())}-${q(4).toString("hex")}`,a=h(this.root,f,s,...t.split("/"));await $(g(a),{recursive:!0}),await b(n,a);const l=r.map(k=>({path:k,version:null})),c=h(this.root,x),o=await I(c,"utf8").catch(()=>{}),e=o===void 0?void 0:M(o,t);e!==void 0&&(await O(c,e.text),l.push({path:x,version:S(e.text)}));const u={path:t,removed:Date.now(),...e===void 0?{}:{listed:e.items}};return await A(h(this.root,f,`${s}.json`),`${JSON.stringify(u)}
3
+ `),this.wrote(l,i),s})}moveToTrashAndUnlist(t,i){return this.serial(async()=>{const n=await t.planNow(),{item:r,name:s,kind:a,entry:l}=n,c=(t.now??(()=>new Date))();await G(this.root,t.keptDays,c);const o=`${Z(c)}-${V(r)}`;let e=`${f}/${o}`;for(let w=2;await y(h(this.root,e));w++)e=`${f}/${o}-${String(w)}`;const u=h(this.root,x),k=await I(u,"utf8").catch(w=>{if(!Q(w,"ENOENT"))throw w}),T=k===void 0?void 0:M(k,l),W=[];try{for(const w of n.moves){const E=await m(this.root,w,{write:!0}),L=h(this.root,e,...w.split("/"));await $(g(L),{recursive:!0}),await b(E,L),W.push(w)}}catch(w){for(const E of W.reverse())await b(h(this.root,e,...E.split("/")),h(this.root,...E.split("/")));throw await N(h(this.root,e),{recursive:!0,force:!0}),w}const U={deletedAt:c.toISOString(),item:r,name:s,...a===void 0?{}:{kind:a},listed:T?.entries??[],files:n.moves.map(w=>({path:w}))};await $(h(this.root,e),{recursive:!0}),await A(h(this.root,e,Y),`${JSON.stringify(U,null,2)}
4
+ `);const _=n.moves.map(w=>({path:w,version:null}));return T!==void 0&&(await O(u,T.text),_.push({path:x,version:S(T.text)})),this.wrote(_,i),{plan:n,trash:e,moved:n.moves}})}async trash(){const t=h(this.root,f),i=await F(t).catch(()=>[]),n=[];for(const r of i){if(!r.endsWith(".json"))continue;const s=await I(h(t,r),"utf8").then(a=>JSON.parse(a)).catch(()=>{});typeof s?.path!="string"||typeof s.removed!="number"||J(s.path)!==void 0||n.push({id:r.slice(0,-5),path:s.path,removed:s.removed})}return n.sort((r,s)=>s.removed-r.removed)}restore(t,i){return this.serial(async()=>{const n=(await this.trash()).find(e=>e.id===t);if(!n)throw new p(d.notFound,`Nothing in the bin is ${t}.`);const r=await m(this.root,n.path,{write:!0});if(await y(r))throw new p(d.conflict,`${n.path} is there again: move it before putting this back.`,{text:"",version:null});const s=h(this.root,f,t,...n.path.split("/")),a=await I(h(this.root,f,`${t}.json`),"utf8").then(e=>JSON.parse(e).listed).catch(()=>{});await $(g(r),{recursive:!0}),await b(s,r),await N(h(this.root,f,t),{recursive:!0,force:!0}),await N(h(this.root,f,`${t}.json`),{force:!0});const l=await R(n.path,r),c=(Array.isArray(a)?a:[]).flatMap(e=>{const u=X.safeParse(e);return u.success?[u.data]:[]});for(const e of c)await H(this.root,e,this.kinds);c.length>0&&l.push(x);const o=[];for(const e of l)o.push({path:e,version:(await D(h(this.root,e)))?.version??null});return this.wrote(o,i),n.path})}async list(t){const i=t===""?this.root:await m(this.root,t),n=[],r=[],s=async(a,l)=>{const c=await F(a,{withFileTypes:!0}).catch(()=>[]);for(const o of c.sort((e,u)=>e.name.localeCompare(u.name))){if(n.length>=LIST_LIMIT)return;const e=l===""?o.name:`${l}/${o.name}`;if(J(e)===void 0&&!(et.some(u=>e===u)&&!(t===e||t.startsWith(`${e}/`)))){if(o.isDirectory())r.push(e),await s(h(a,o.name),e);else if(o.isFile()){const u=await j(h(a,o.name)).catch(()=>{});u&&n.push({path:e,size:u.size,modified:u.mtimeMs})}}}};return await s(i,t),{files:n,dirs:r}}}const y=v=>j(v).then(()=>!0,()=>!1);async function R(v,t){const i=await j(t).catch(()=>{});if(!i)return[];if(!i.isDirectory())return[v];const n=[],r=await F(t,{recursive:!0,withFileTypes:!0});for(const s of r)s.isFile()&&n.push(C.join(v,C.relative(t.split("\\").join("/"),h(s.parentPath,s.name).split("\\").join("/"))));return n}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/dev-server",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export const CORE="allyhub",CORE_RULES=[{code:"AK-M001",level:"error",rule:"The fields of video(), presentation() or defineComponent do not match the format"},{code:"AK-M002",level:"error",rule:"The project's list (allyhub.yaml) cannot be read, or names a kind not loaded or a file not there"},{code:"AK-M003",level:"error",rule:"The project's list names two pieces by one id"},{code:"AK-M004",level:"error",rule:"The project has no pieces"},{code:"AK-M006",level:"error",rule:"A messages file does not match the format"},{code:"AK-M007",level:"error",rule:"A script file does not match the format"},{code:"AK-M011",level:"error",rule:"A deck names no slides file or script, or its slides file is not there, does not match the format, or names a layout, a prop, a file or a video item the deck does not have"},{code:"AK-M012",level:"error",rule:"A sheet's code reads the clock or a random number, reaches outside the project, or does not make the same sheets twice"},{code:"AK-M016",level:"error",rule:"An item uses another item's made file that is not there: no such item in the work list, no type both kinds take, or an item using itself"},{code:"AK-B001",level:"error",rule:"Two pieces have the same id"},{code:"AK-B003",level:"error",rule:"The build made a network request"},{code:"AK-B004",level:"error",rule:"The build timed out, or its result is over the size limit"},{code:"AK-B005",level:"error",rule:"An import of a file outside the project, or of a package not declared in package.json"},{code:"AK-B006",level:"error",rule:"An import of an @allyhub/sdk entry point that does not exist"},{code:"AK-B008",level:"error",rule:"The project's @allyhub/sdk is another version than the allyhub that builds it"},{code:"AK-B009",level:"error",rule:"The project's package.json declares AllyHub, but its packages are not installed"},{code:"AK-D002",level:"error",rule:"The same frame has different pixels when drawn in order and out of order"},{code:"AK-N003",level:"error",rule:"The sandbox blocked a request at run time"},{code:"AK-A001",level:"error",rule:"A referenced media or data file does not exist"},{code:"AK-P003",level:"error",rule:"A moment did not finish drawing within the piece's seekLimit (default 30 seconds): work a layer waits for (ctx.wait) or a picture it shows never settled"},{code:"AK-R001",level:"error",rule:"An unhandled exception was thrown at run time"},{code:"AK-X001",level:"error",rule:"The matrix's slots, structures, rules or combos name something that does not exist, or a combo lacks a slot of its structure"},{code:"AK-X002",level:"error",rule:"The matrix's rules leave no combination to make, or rule out a combo matrix.combos names"},{code:"AK-X004",level:"error",rule:"Two chosen combos are the same, or more alike than the matrix's differ allows"},{code:"AK-X006",level:"error",rule:"A combo is longer than its output's maxDuration"},{code:"AK-L002",level:"warn",rule:"Text overflows the frame or is clipped"},{code:"AK-L006",level:"warn",rule:"Text is drawn in a fallback font, or in a bold or italic the font does not have"}];const r=new Map(CORE_RULES.map(e=>[e.code,{extension:CORE,...e}]));export function declareRules(e,t){const s=[];for(const o of t){const l=r.get(o.code);if(l&&l.extension!==e){s.push(`${o.code} is ${l.extension===CORE?"the core's":`${l.extension}'s`} rule already.`);continue}r.set(o.code,{extension:e,code:o.code,level:o.level,rule:o.rule})}return s}export function declareAll(e){return e.flatMap(t=>declareRules(t.extension,[t]))}export const ruleOf=e=>r.get(e),isRule=e=>r.has(e),declaredRules=()=>[...r.values()];
2
+ export const CORE="allyhub",CORE_RULES=[{code:"AK-M001",level:"error",rule:"The fields of video(), presentation() or defineComponent do not match the format"},{code:"AK-M002",level:"error",rule:"The project's list (allyhub.yaml) cannot be read, records no versions or a format older than its kind's, or names a kind not loaded or a file not there"},{code:"AK-M003",level:"error",rule:"The project's list names two pieces by one id"},{code:"AK-M004",level:"error",rule:"The project has no pieces"},{code:"AK-M006",level:"error",rule:"A messages file does not match the format"},{code:"AK-M007",level:"error",rule:"A script file does not match the format"},{code:"AK-M011",level:"error",rule:"A deck names no slides file or script, or its slides file is not there, does not match the format, or names a layout, a prop, a file or a video item the deck does not have"},{code:"AK-M012",level:"error",rule:"A sheet's code reads the clock or a random number, reaches outside the project, or does not make the same sheets twice"},{code:"AK-M016",level:"error",rule:"An item uses another item's made file that is not there: no such item in the work list, no type both kinds take, or an item using itself"},{code:"AK-B001",level:"error",rule:"Two pieces have the same id"},{code:"AK-B003",level:"error",rule:"The build made a network request"},{code:"AK-B004",level:"error",rule:"The build timed out, or its result is over the size limit"},{code:"AK-B005",level:"error",rule:"An import of a file outside the project, or of a package not declared in package.json"},{code:"AK-B006",level:"error",rule:"An import of an @allyhub/sdk entry point that does not exist"},{code:"AK-B008",level:"error",rule:"The project's @allyhub/sdk is another version than the allyhub that builds it"},{code:"AK-B009",level:"error",rule:"The project's package.json declares AllyHub, but its packages are not installed"},{code:"AK-D002",level:"error",rule:"The same frame has different pixels when drawn in order and out of order"},{code:"AK-N003",level:"error",rule:"The sandbox blocked a request at run time"},{code:"AK-A001",level:"error",rule:"A referenced media or data file does not exist"},{code:"AK-P003",level:"error",rule:"A moment did not finish drawing within the piece's seekLimit (default 30 seconds): work a layer waits for (ctx.wait) or a picture it shows never settled"},{code:"AK-R001",level:"error",rule:"An unhandled exception was thrown at run time"},{code:"AK-X001",level:"error",rule:"The matrix's slots, structures, rules or combos name something that does not exist, or a combo lacks a slot of its structure"},{code:"AK-X002",level:"error",rule:"The matrix's rules leave no combination to make, or rule out a combo matrix.combos names"},{code:"AK-X004",level:"error",rule:"Two chosen combos are the same, or more alike than the matrix's differ allows"},{code:"AK-X006",level:"error",rule:"A combo is longer than its output's maxDuration"},{code:"AK-L002",level:"warn",rule:"Text overflows the frame or is clipped"},{code:"AK-L006",level:"warn",rule:"Text is drawn in a fallback font, or in a bold or italic the font does not have"}];const r=new Map(CORE_RULES.map(e=>[e.code,{extension:CORE,...e}]));export function declareRules(e,t){const s=[];for(const o of t){const l=r.get(o.code);if(l&&l.extension!==e){s.push(`${o.code} is ${l.extension===CORE?"the core's":`${l.extension}'s`} rule already.`);continue}r.set(o.code,{extension:e,code:o.code,level:o.level,rule:o.rule})}return s}export function declareAll(e){return e.flatMap(t=>declareRules(t.extension,[t]))}export const ruleOf=e=>r.get(e),isRule=e=>r.has(e),declaredRules=()=>[...r.values()];
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allyhub/diagnostics",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{blockAlt as f,blockDataTable as m,blockFromFile as s,blockSvg as l,iconPaths as p,paletteOf as g}from"@allyhub/blocks";import{shownPath as u,TONE_COLORS as k,toneOf as h}from"@allyhub/formats";import{chartTheme as c}from"./chart.js";import{PAPER as o,tint as b}from"./paper.js";export const LIBRARY_TAGS={Icon:{kind:"icon"},Progress:{kind:"progress"},Timeline:{kind:"timeline",item:"Milestone"},Steps:{kind:"steps",item:"Step"},Person:{kind:"person"},People:{kind:"people",item:"Person"},RiskMatrix:{kind:"risk_matrix",item:"Entry"},Sankey:{kind:"sankey",item:"Flow"},Gantt:{kind:"gantt",item:"Task"},OrgChart:{kind:"org_chart"},IssueTree:{kind:"issue_tree"},DecisionTree:{kind:"decision_tree"},Fishbone:{kind:"fishbone"},Matrix:{kind:"matrix"},Marimekko:{kind:"marimekko"},Heatmap:{kind:"heatmap"},SmallMultiples:{kind:"small_multiples"}};export function libraryBlockTable(i,r={}){const{def:e}=libraryDef(i,r),t=e===void 0?void 0:m(e,r.lang);if(!(t===void 0||t.rows.length===0))return{type:"table",rows:[t.columns,...t.rows].map(n=>n.map(d=>[{text:d,styles:{}}]))}}export const DOC_BLOCK_SCALE=.75;export function docBlockPalette(i={}){return g({text:o.ink,body:o.ink,muted:o.lead,ground:o.sheet,surface:o.sheet,well:o.stone,rule:o.rule,"rule-strong":o.ruleStrong},{theme:c(i),font:"Carlito, Calibri, Arial, sans-serif"})}export function libraryFields(i){return i.items===void 0?{...i.props}:{...i.props,items:i.items.map(r=>({...r.props}))}}export function libraryDef(i,r={}){const e=LIBRARY_TAGS[i.tag];if(e===void 0)return{problems:[`<${i.tag}> is not a block`]};const t=r.data,n=s(e.kind,libraryFields(i),{...t===void 0?{}:{data:t,shown:a=>t(u(a))},...r.base===void 0?{}:{base:r.base}}),d=n.problems.map(a=>`${a.path.length>0?`${a.path.join(".")}: `:""}${a.message}`);return n.block===void 0?{problems:d}:{def:n.block,problems:d}}export function libraryBlockSvg(i,r,e={}){const{def:t,problems:n}=libraryDef(i,e);if(t===void 0)return{problems:n};const d=f(t,e.lang);return{svg:l(t,{width:r*.75},docBlockPalette(e.page),{flow:!0,scale:DOC_BLOCK_SCALE,label:d,...e.id===void 0?{}:{id:e.id},...e.lang===void 0?{}:{lang:e.lang}}),alt:d,problems:n}}export function docStatsDef(i,r={}){const e=i.stats.map(n=>({value:n.value,label:n.label,...n.delta===void 0?{}:{delta:n.delta},...n.note===void 0?{}:{note:n.note},...n.downIsGood===!0?{good:"down"}:{},...n.status===void 0?{}:{status:n.status},...n.target===void 0?{}:{target:n.target},...n.trend===void 0?{}:{trend:n.trend},...n.icon===void 0?{}:{icon:n.icon}})),t=r.data;return s("stats",e,{...t===void 0?{}:{data:t,shown:n=>t(u(n))}}).block}export function docStatsSvg(i,r,e={}){const t=docStatsDef(i,e);if(t!==void 0)return l(t,{width:r*.75},docBlockPalette(e.page),{flow:!0,scale:DOC_BLOCK_SCALE,...e.id===void 0?{}:{id:e.id},...e.lang===void 0?{}:{lang:e.lang}})}export function inlineIconSvg(i,r){if(!/^[a-z][a-z0-9-]*$/iu.test(i))return;const e=p(i);if(e!==void 0)return`<svg class="icon" viewBox="0 0 24 24" width="1.15em" height="1.15em" fill="none" stroke="${r}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e.map(t=>`<path d="${t}"/>`).join("")}</svg>`}export function calloutTone(i,r={}){if(i===void 0)return;const e=h(i,"callout");if(e===void 0)return;if(e==="accent1"){const d=c(r).accent1;return{bg:b(d,.14),fg:o.ink,mark:d,icon:"message-square-warning"}}const t=k[e],n={info:"info",good:"circle-check",warning:"triangle-alert",bad:"octagon-alert"};return{bg:t.tint,fg:t.ink,mark:t.mark,...n[e]===void 0?{}:{icon:n[e]}}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chartOfFile as R,chartSvg as F,isBar as S,isRound as A,isScatter as C,variesOf as D}from"@allyhub/chart";import{hex as H}from"./color.js";import{CHART_PALETTE as N,PAPER as v,accentPalette as B,tint as M}from"./paper.js";import{COMPONENT_ASPECT as P,COMPONENT_WIDTH as $}from"./component.js";export{CHART_PALETTE}from"./paper.js";const z={gray:"#8B8A85",brown:"#9A6B4B",red:"#D6403A",orange:"#EB6834",yellow:"#EDA100",green:"#1BAF7A",blue:"#2A78D6",purple:"#8A5CD6",pink:"#E87BA4"},w=v.lead,O={grid:v.rule,axis:v.ruleMid};export const CHART_BARS={gap:80,overlap:-8},CHART_TEXT={size:10,title:13},chartColor=e=>{const t=H(e,z);return t===void 0?void 0:`#${t}`},CHART_SECOND_TONE=.55;export function chartTheme(e={},t=[]){const[r=N[0],...i]=B(e.accent===void 0?void 0:chartColor(e.accent)),n=[r,r,...i];t.slice(0,n.length).forEach((m,s)=>{const u=chartColor(m);u!==void 0&&(n[s]=u)}),t.length<2&&(n[1]=M(n[0]??r,CHART_SECOND_TONE));const[a,d,f,g,o,h]=n;return{dk1:w,lt1:"#FFFFFF",dk2:"#37352F",lt2:"#EFEFED",accent1:a,accent2:d,accent3:f,accent4:g,accent5:o,accent6:h,hlink:a,folHlink:a}}export const SMOOTHED=new Set(["line","line-markers","scatter-lines"]),ROUND_FRAME={width:560,aspect:.6};export function chartFrame(e,t=$){const r=e.kind!==void 0&&A(e.kind),i=e.width??(r?Math.min(t,ROUND_FRAME.width):t);return{width:i,height:e.height??Math.round(i*(r?ROUND_FRAME.aspect:P))}}function L(e){const t=e.trim().replace(/,/gu,"");if(t==="")return null;const r=Number(t);return Number.isFinite(r)?r:void 0}function W(e,t){const r=C(e.kind),i=e.labels,n=e.min!==void 0||e.max!==void 0||e.format!==void 0?{...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.format===void 0?{}:{format:e.format}}:void 0,a={...i===void 0?{}:{labels:{...i.includes("value")?{value:!0}:{},...i.includes("percentage")?{percentage:!0}:{},...i.includes("category")?{category:!0}:{},...i.includes("series")?{series:!0}:{},...e.format===void 0?{}:{format:e.format}}},...n===void 0?{}:{value_axis:n},...A(e.kind)?{vary_by_categories:!0}:{}};if(e.table===void 0)return e.data===void 0||e.categories===void 0?void 0:{type:e.kind,data:e.data,categories:e.categories,series:e.series??[],...a};const[d=[],...f]=e.table,g=Math.max(0,...e.table.map(s=>s.length)),o=(s,u)=>s[u]??"",h=s=>f.map((u,l)=>{const x=L(o(u,s));return x===void 0?(t.push(`row ${String(l+1)} of its table: "${o(u,s)}" under ${o(d,s)||`column ${String(s+1)}`} is not a number`),null):x}),m=Array.from({length:Math.max(0,g-1)},(s,u)=>{const l=u+1;return{name:o(d,l)||`Series ${String(l)}`,values:h(l),...r?{x:h(0)}:{}}});if(m.length!==0)return{type:e.kind,...r?{}:{categories:f.map(s=>o(s,0))},series:m,...a}}function j(e,t){if(e.legend!=="none")return e.legend!==void 0?e.legend:A(e.kind)?"right":t.series.length>1?"top":void 0}export function docChart(e,t={}){const r=[],i=W(e,r);if(!i)return{problems:[...r,"it has no numbers to draw"]};const n=R(i,{title:e.title,base:t.base??"",rows:c=>{const p=t.data?.(c);if(p===void 0)throw new Error("there is no such file or table");return p},problem:c=>r.push(c)});if(!n)return{problems:r};const a=j(e,n),d=chartTheme(t.page,e.colors),f=[d.accent1,d.accent2,d.accent3,d.accent4,d.accent5,d.accent6],g=c=>({rgb:f[c%f.length]??"#000000"}),o=n.series.length===1&&!A(e.kind)&&(e.colors?.length??0)>1?(e.colors??[]).map(chartColor):void 0,h=o!==void 0||D(n),m=C(e.kind),s=e.table===void 0?e.categories:e.table[0]?.[0],u=n.series.length===1?n.series[0]?.name:void 0,l={gridline_color:{rgb:O.grid},line_color:{rgb:O.axis}},x=S(e.kind),y=e.kind.endsWith("-clustered"),T={...n,category_axis:{...l,...n.category_axis,...m&&s!==void 0&&s!==""?{title:s}:{}},value_axis:{...l,...n.value_axis,...m&&u!==void 0&&u!==""?{title:u}:{}},...x&&n.gap_width===void 0?{gap_width:CHART_BARS.gap}:{},...y&&n.series.length>1&&n.overlap===void 0?{overlap:CHART_BARS.overlap}:{},series:n.series.map((c,p)=>{const _=h||c.color!==void 0?c:{...c,color:g(p)};return e.smooth&&SMOOTHED.has(e.kind)?{..._,smooth:!0}:_}),...o!==void 0?{vary_by_categories:!0}:{},...h?{category_colors:n.categories.map((c,p)=>{const _=o?.[p%o.length];return _===void 0?g(o===void 0?p:0):{rgb:_}})}:{},...a===void 0?{}:{legend:a},font_size:CHART_TEXT.size,title_size:CHART_TEXT.title,font_color:{rgb:w}};return a===void 0&&delete T.legend,{chart:T,problems:r}}export function chartWords(e,t){if(e.alt!==void 0)return e.alt;const r=t?.series.map(n=>n.name).join(", ")??"",i=[e.title,r].filter(n=>n!==void 0&&n!=="");return i.length>0?i.join(": "):"Chart"}const E={ink:"#D4D3CF",grid:"#3A3936",axis:"#5C5B57"};export function docChartSvg(e,t={}){const r=docChart(e,t),{problems:i}=r;if(!r.chart)return{problems:i};const n=g=>({...g,gridline_color:{rgb:E.grid},line_color:{rgb:E.axis}}),a=t.dark===!0?{...r.chart,font_color:{rgb:E.ink},value_axis:n(r.chart.value_axis),category_axis:n(r.chart.category_axis)}:r.chart,{width:d,height:f}=chartFrame(e,t.room);return{svg:F(a,d,f,{colors:chartTheme(t.page,e.colors),paper:"none",edge:"none",...t.font===void 0?{}:{font:t.font},label:chartWords(e,a)}),problems:i}}
2
+ import{chartOfFile as R,chartSvg as S,isBar as F,isHierarchical as D,isRound as E,isScatter as y,variesOf as H}from"@allyhub/chart";import{colorsOfTheme as N}from"@allyhub/formats";import{hex as B}from"./color.js";import{CHART_PALETTE as M,PAPER as T,accentPalette as P,tint as $}from"./paper.js";import{COMPONENT_ASPECT as z,COMPONENT_WIDTH as L}from"./component.js";export{CHART_PALETTE}from"./paper.js";const q={gray:"#8B8A85",brown:"#9A6B4B",red:"#D6403A",orange:"#EB6834",yellow:"#EDA100",green:"#1BAF7A",blue:"#2A78D6",purple:"#8A5CD6",pink:"#E87BA4"},C=T.lead,O={grid:T.rule,axis:T.ruleMid};export const CHART_BARS={gap:80,overlap:-8},CHART_TEXT={size:10,title:13},chartColor=e=>{const t=B(e,q);return t===void 0?void 0:`#${t}`},CHART_SECOND_TONE=.55;export function chartTheme(e={},t=[]){if(e.theme!==void 0){const f={...N(e.theme)},i=e.accent===void 0?void 0:f[e.accent.trim()]??chartColor(e.accent);i!==void 0&&(f.accent1=i);const a=["accent1","accent2","accent3","accent4","accent5","accent6"];return t.slice(0,a.length).forEach((l,_)=>{const v=chartColor(l),x=a[_];v!==void 0&&x!==void 0&&(f[x]=v)}),{...f,dk1:C}}const[r=M[0],...s]=P(e.accent===void 0?void 0:chartColor(e.accent)),n=[r,r,...s];t.slice(0,n.length).forEach((f,i)=>{const a=chartColor(f);a!==void 0&&(n[i]=a)}),t.length<2&&(n[1]=$(n[0]??r,CHART_SECOND_TONE));const[u,c,g,o,d,h]=n;return{dk1:C,lt1:"#FFFFFF",dk2:"#37352F",lt2:"#EFEFED",accent1:u,accent2:c,accent3:g,accent4:o,accent5:d,accent6:h,hlink:u,folHlink:u}}export const SMOOTHED=new Set(["line","line-markers","scatter-lines"]),ROUND_FRAME={width:560,aspect:.6};export function chartFrame(e,t=L){const r=e.kind!==void 0&&E(e.kind),s=e.width??(r?Math.min(t,ROUND_FRAME.width):t);return{width:s,height:e.height??Math.round(s*(r?ROUND_FRAME.aspect:z))}}function W(e){const t=e.trim().replace(/,/gu,"");if(t==="")return null;const r=Number(t);return Number.isFinite(r)?r:void 0}function j(e,t){const r=y(e.kind),s=e.labels,n=e.min!==void 0||e.max!==void 0||e.format!==void 0?{...e.min===void 0?{}:{min:e.min},...e.max===void 0?{}:{max:e.max},...e.format===void 0?{}:{format:e.format}}:void 0,u={...s===void 0?{}:{labels:{...s.includes("value")?{value:!0}:{},...s.includes("percentage")?{percentage:!0}:{},...s.includes("category")?{category:!0}:{},...s.includes("series")?{series:!0}:{},...e.format===void 0?{}:{format:e.format}}},...n===void 0?{}:{value_axis:n},...E(e.kind)?{vary_by_categories:!0}:{},...e.totals===void 0?{}:{totals:e.totals},...e.quartiles===void 0?{}:{quartiles:e.quartiles}};if(e.table===void 0)return e.data===void 0||e.categories===void 0?void 0:{type:e.kind,data:e.data,categories:e.categories,series:e.series??[],...u};const[c=[],...g]=e.table,o=Math.max(0,...e.table.map(i=>i.length)),d=(i,a)=>i[a]??"",h=i=>g.map((a,l)=>{const _=W(d(a,i));return _===void 0?(t.push(`row ${String(l+1)} of its table: "${d(a,i)}" under ${d(c,i)||`column ${String(i+1)}`} is not a number`),null):_});if(e.kind==="bubble"&&o>=3)return{type:e.kind,series:[{name:d(c,1)||"Series 1",x:h(0),values:h(1),sizes:h(2)}],...u};if(D(e.kind)&&o>=2)return{type:e.kind,categories:g.map(i=>Array.from({length:o-1},(a,l)=>d(i,l))),series:[{name:d(c,o-1)||"Series 1",values:h(o-1)}],...u};const f=Array.from({length:Math.max(0,o-1)},(i,a)=>{const l=a+1;return{name:d(c,l)||`Series ${String(l)}`,values:h(l),...r?{x:h(0)}:{}}});if(f.length!==0)return{type:e.kind,...r?{}:{categories:g.map(i=>d(i,0))},series:f,...u}}function I(e,t){if(e.legend!=="none")return e.legend!==void 0?e.legend:E(e.kind)?"right":t.series.length>1?"top":void 0}export function docChart(e,t={}){const r=[],s=j(e,r);if(!s)return{problems:[...r,"it has no numbers to draw"]};const n=R(s,{title:e.title,base:t.base??"",rows:m=>{const p=t.data?.(m);if(p===void 0)throw new Error("there is no such file or table");return p},problem:m=>r.push(m)});if(!n)return{problems:r};const u=I(e,n),c=chartTheme(t.page,e.colors),g=[c.accent1,c.accent2,c.accent3,c.accent4,c.accent5,c.accent6],o=m=>({rgb:g[m%g.length]??"#000000"}),d=n.series.length===1&&!E(e.kind)&&(e.colors?.length??0)>1?(e.colors??[]).map(chartColor):void 0,h=d!==void 0||H(n),f=y(e.kind),i=e.table===void 0?e.categories:e.table[0]?.[0],a=n.series.length===1?n.series[0]?.name:void 0,l={gridline_color:{rgb:O.grid},line_color:{rgb:O.axis}},_=F(e.kind),v=e.kind.endsWith("-clustered"),x={...n,category_axis:{...l,...n.category_axis,...f&&i!==void 0&&i!==""?{title:i}:{}},value_axis:{...l,...n.value_axis,...f&&a!==void 0&&a!==""?{title:a}:{}},..._&&n.gap_width===void 0?{gap_width:CHART_BARS.gap}:{},...v&&n.series.length>1&&n.overlap===void 0?{overlap:CHART_BARS.overlap}:{},series:n.series.map((m,p)=>{const A=h||m.color!==void 0?m:{...m,color:o(p)};return e.smooth&&SMOOTHED.has(e.kind)?{...A,smooth:!0}:A}),...d!==void 0?{vary_by_categories:!0}:{},...h?{category_colors:n.categories.map((m,p)=>{const A=d?.[p%d.length];return A===void 0?o(d===void 0?p:0):{rgb:A}})}:{},...u===void 0?{}:{legend:u},font_size:CHART_TEXT.size,title_size:CHART_TEXT.title,font_color:{rgb:C}};return u===void 0&&delete x.legend,{chart:x,problems:r}}export function chartWords(e,t){if(e.alt!==void 0)return e.alt;const r=t?.series.map(n=>n.name).join(", ")??"",s=[e.title,r].filter(n=>n!==void 0&&n!=="");return s.length>0?s.join(": "):"Chart"}const w={ink:"#D4D3CF",grid:"#3A3936",axis:"#5C5B57"};export function docChartSvg(e,t={}){const r=docChart(e,t),{problems:s}=r;if(!r.chart)return{problems:s};const n=o=>({...o,gridline_color:{rgb:w.grid},line_color:{rgb:w.axis}}),u=t.dark===!0?{...r.chart,font_color:{rgb:w.ink},value_axis:n(r.chart.value_axis),category_axis:n(r.chart.category_axis)}:r.chart,{width:c,height:g}=chartFrame(e,t.room);return{svg:S(u,c,g,{colors:chartTheme(t.page,e.colors),paper:"none",edge:"none",...t.font===void 0?{}:{font:t.font},label:chartWords(e,u)}),problems:s}}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- export const TEXT_COLORS={gray:"#9b9a97",brown:"#64473a",red:"#e03e3e",orange:"#d9730d",yellow:"#dfab01",green:"#4d6461",blue:"#0b6e99",purple:"#6940a5",pink:"#ad1a72"},BACKGROUNDS={gray:"#ebeced",brown:"#e9e5e3",red:"#fbe4e4",orange:"#f6e9d9",yellow:"#fbf3db",green:"#ddedea",blue:"#ddebf1",purple:"#eae4f2",pink:"#f4dfeb"};function p(r,f,e){const o=f*Math.min(e,1-e),n=t=>{const a=(t+r/30)%12;return 255*(e-o*Math.max(-1,Math.min(a-3,9-a,1)))};return[n(0),n(8),n(4)]}export function hex(r,f){if(r===void 0)return;const e=(f[r]??r).trim().toLowerCase(),o=/^#([0-9a-f])([0-9a-f])([0-9a-f])f?$/.exec(e);if(o)return o.slice(1).map(s=>s+s).join("").toUpperCase();const n=/^#([0-9a-f]{6})([0-9a-f]{2})?$/.exec(e);if(n?.[1]!==void 0)return n[1].toUpperCase();const t=/^(rgb|hsl)a?\(([^)]*)\)$/.exec(e),[a=NaN,d=NaN,i=NaN]=(t?.[2]??"").split(/[\s,/]+/).filter(Boolean).map(Number.parseFloat);return!t||[a,d,i].some(Number.isNaN)?void 0:(t[1]==="rgb"?[a,d,i]:p(a,d/100,i/100)).map(s=>Math.round(Math.min(255,Math.max(0,s))).toString(16).padStart(2,"0")).join("").toUpperCase()}
2
+ import{NAMED_COLORS as m,namedColorColors as p}from"@allyhub/formats";export const TEXT_COLORS=Object.fromEntries(m.map(t=>[t,p(t).mark])),BACKGROUNDS=Object.fromEntries(m.map(t=>[t,p(t).tint]));function u(t,i,e){const a=i*Math.min(e,1-e),n=o=>{const r=(o+t/30)%12;return 255*(e-a*Math.max(-1,Math.min(r-3,9-r,1)))};return[n(0),n(8),n(4)]}export function hex(t,i){if(t===void 0)return;const e=(i[t]??t).trim().toLowerCase(),a=/^#([0-9a-f])([0-9a-f])([0-9a-f])f?$/.exec(e);if(a)return a.slice(1).map(s=>s+s).join("").toUpperCase();const n=/^#([0-9a-f]{6})([0-9a-f]{2})?$/.exec(e);if(n?.[1]!==void 0)return n[1].toUpperCase();const o=/^(rgb|hsl)a?\(([^)]*)\)$/.exec(e),[r=NaN,c=NaN,f=NaN]=(o?.[2]??"").split(/[\s,/]+/).filter(Boolean).map(Number.parseFloat);return!o||[r,c,f].some(Number.isNaN)?void 0:(o[1]==="rgb"?[r,c,f]:u(r,c/100,f/100)).map(s=>Math.round(Math.min(255,Math.max(0,s))).toString(16).padStart(2,"0")).join("").toUpperCase()}
@@ -0,0 +1,12 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{strFromU8 as bn,unzipSync as kn}from"fflate";import{withinZip as Sn}from"@allyhub/formats";import{Package as On,applyMce as vn,NAMESPACES as Ke,attrOf as f,parseXml as Pn}from"@allyhub/ooxml";import{FORMAT_KEYS as xn}from"./model.js";import{CHINESE_SIZES as Mn,PAGE_FONTS as Cn,PAPERS as En,WATERMARK_COLOR as Nn}from"./page.js";import{BUILT_IN_STYLES as Tn,NORMAL as Ce,TABLE_GRID as en,TITLE_STYLE as Le,headingStyle as nn,pickProps as $n}from"./styles.js";import{alignsOf as In,columnLetters as Rn}from"./merges.js";import{imageSize as An}from"image-size";import{laidWidths as Ln}from"./table.js";import{chartFrame as Fn}from"./chart.js";import{PAPER as jn}from"./paper.js";import{DRAWN_CODE as _e}from"./math.js";import{headingAnchors as _n}from"./html.js";import{drawShapes as zn}from"./shapes.js";import{ommlParaToLatex as tn,ommlToLatex as Dn}from"./omml.js";import{LIST_NUMBERING as Un,NUMBER_FORMATS as Bn}from"./numbering.js";import{frontMatterOf as Hn,writeBlocks as Jn}from"./write.js";export const GATHER_DEFAULT=3;const ze=1440/25.4,ve=9525,Wn=new Map([["normal",Ce],["title",Le],["quote","Quote"],["intense quote","Quote"],["list paragraph","List Paragraph"],["caption","Caption"],...[1,2,3,4,5,6].map(d=>[`heading ${String(d)}`,nn(d)])]),sn=new Map(Object.entries(Bn).map(([d,t])=>[t,d])),on=new Map([["calibri","sans"],["calibri light","sans"],["aptos","sans"],["cambria","serif"],["times new roman","times"],["courier new","mono"],["consolas","mono"],["simsun","song"],["宋体","song"],["simhei","hei"],["黑体","hei"],["fangsong","fangsong"],["仿宋","fangsong"],["仿宋_gb2312","fangsong"],["kaiti","kai"],["楷体","kai"],["楷体_gb2312","kai"],["方正小标宋简体","xiaobiaosong"]]),Gn={yellow:"yellow",green:"green",cyan:"blue",magenta:"pink",blue:"blue",red:"red",darkBlue:"blue",darkCyan:"blue",darkGreen:"green",darkMagenta:"purple",darkRed:"red",darkYellow:"brown",darkGray:"gray",lightGray:"gray",black:"gray"},Z=(d,t)=>d?.children.filter(n=>n.key===t)??[],r=(d,t)=>d?.children.find(n=>n.key===t),A=d=>d===void 0?void 0:f(d,"w:val"),Pe=d=>{if(d===void 0)return;const t=A(d);return t===void 0||!["0","false","off","none"].includes(t)},De=d=>{const t=Y(d,"asvg:svgBlip");return t===void 0?void 0:f(t,"r:embed")},ae=(d,t)=>d===void 0?void 0:f(d,t),T=d=>{if(d===void 0)return;const t=Number(d);return Number.isFinite(t)?t:void 0};class rn{pkg;doc;styles=new Map;numbering=new Map;footnotes=new Map;lost=new Map;files=new Map;theme={};used=new Set;normalSize=11;pictures=0;saved=new Map;made=new Map;numberedLists=new Map;tableStyles=new Map;tableStyle(t){const n=this.styles.get(t);if(n?.type==="table")return n.name===en?en:(this.tableStyles.has(n.name)||this.tableStyles.set(n.name,{type:"table",...this.tableProps(n)}),n.name)}tableProps(t){const n=[];let e=t;for(;e!==void 0&&!n.includes(e);)n.push(e),e=e.basedOn===void 0?void 0:this.styles.get(e.basedOn);const i={},s=(o,a)=>{const c=o===void 0?void 0:f(o,a);return c===void 0||c==="auto"||!/^[0-9a-f]{6}$/iu.test(c)?void 0:`#${c.toUpperCase()}`};for(const o of n.reverse()){const a=r(r(o.el,"w:tblPr"),"w:tblBorders");if(a!==void 0){const c=g=>{const m=ae(r(a,g),"w:val");return m!==void 0&&!["nil","none"].includes(m)};i.borders=c("w:insideV")?"all":c("w:insideH")?"rows":["w:top","w:bottom","w:left","w:right"].some(c)?"outside":"none";const l=["w:top","w:insideH","w:bottom","w:left"].map(g=>s(r(a,g),"w:color")).find(g=>g!==void 0);l!==void 0&&(i.borderColor=l)}for(const c of Z(o.el,"w:tblStylePr")){const l=f(c,"w:type"),g=s(r(r(c,"w:tcPr"),"w:shd"),"w:fill");if(l==="firstRow"){g!==void 0&&(i.headBg=g);const m=r(c,"w:rPr"),x=Pe(r(m,"w:b"));x!==void 0&&(i.headBold=x);const p=s(r(m,"w:color"),"w:val");p!==void 0&&(i.headColor=p)}else l==="band1Horz"&&g!==void 0&&(i.banded=g)}}return i}notes=new Map;toc=!1;openComments=new Set;options;constructor(t,n,e){if(this.options=n,this.pkg=new On(kn(t,{filter:Sn(e)})),this.doc=this.pkg.relOfType("","officeDocument")?.target??"word/document.xml",this.pkg.parts[this.doc]===void 0)throw new Error(`it has no document (${this.doc})`)}xml(t,{mce:n=!0}={}){if(t===void 0)return;const e=this.pkg.parts[t];if(e===void 0)return;const i=Pn(bn(e));return n&&vn(i,{understood:[Ke.wps,Ke.wpg]}),i}partOf(t){return this.pkg.relOfType(this.doc,t)?.target}commentIds;commentId(t){if(this.commentIds===void 0){this.commentIds=new Map;const s=this.partOf("comments");for(const o of Z(s===void 0?void 0:this.xml(s,{mce:!1}),"w:comment")){const a=f(o,"w:id")??"";this.commentIds.has(a)||this.commentIds.set(a,`c${String(this.commentIds.size)}`)}}const n=t??"",e=this.commentIds.get(n);if(e!==void 0)return e;const i=`c${String(this.commentIds.size)}`;return this.commentIds.set(n,i),i}lose(t,n=1){this.lost.set(t,(this.lost.get(t)??0)+n)}readStyles(){const t=this.xml(this.partOf("styles"));for(const o of Z(t,"w:style")){const a=f(o,"w:styleId")??"",c=A(r(o,"w:name"))??a,l=f(o,"w:type")??"paragraph",g=A(r(o,"w:basedOn")),m=A(r(o,"w:next")),x=r(o,"w:pPr"),p=r(o,"w:rPr");this.styles.set(a,{id:a,name:Wn.get(c.toLowerCase())??c,type:l,...g===void 0?{}:{basedOn:g},...m===void 0?{}:{next:m},...x===void 0?{}:{pPr:x},...p===void 0?{}:{rPr:p},el:o})}const n=r(t,"w:docDefaults"),e=T(A(r(r(r(n,"w:rPrDefault"),"w:rPr"),"w:sz"))),i=[...this.styles.values()].find(o=>o.name===Ce),s=T(A(r(i?.rPr,"w:sz")));this.normalSize=(s??e??22)/2,this.defaults=n}defaults;readTheme(){const t=this.xml(this.partOf("theme")),n=r(r(t,"a:themeElements"),"a:fontScheme"),e=a=>ae(r(r(n,a),"a:latin"),"typeface"),i=n===void 0?void 0:e("a:majorFont"),s=n===void 0?void 0:e("a:minorFont");i!==void 0&&(this.theme.major=i),s!==void 0&&(this.theme.minor=s);const o=r(r(t,"a:themeElements"),"a:clrScheme");for(const a of o?.children??[]){const c=a.key.replace(/^a:/u,""),l=r(a,"a:srgbClr"),g=r(a,"a:sysClr"),m=l!==void 0?f(l,"val"):g!==void 0?f(g,"lastClr"):void 0;m!==void 0&&this.colors.set(c,m)}}styledParagraph(t){const n=[...this.styles.entries()].find(([,o])=>o.name==="Normal"&&o.type==="paragraph")?.[0],e=[],i=new Set;for(let o=t??n;o!==void 0&&!i.has(o);o=this.styles.get(o)?.basedOn){i.add(o);const a=this.styles.get(o);a!==void 0&&e.unshift(a)}const s={...this.paragraphProps(r(r(this.defaults,"w:pPrDefault"),"w:pPr"))};for(const o of e)Object.assign(s,this.paragraphProps(o.pPr));return s}styledRun(t){const n=[...this.styles.entries()].find(([,a])=>a.name==="Normal"&&a.type==="paragraph")?.[0],e=[],i=new Set;for(let a=t??n;a!==void 0&&!i.has(a);a=this.styles.get(a)?.basedOn)i.add(a),e.unshift(this.styles.get(a)?.rPr);e.unshift(r(r(this.defaults,"w:rPrDefault"),"w:rPr"));const s={},o=new Set;for(const a of e){Object.assign(s,this.runProps(a));const c=r(a,"w:rFonts");for(const l of["w:ascii","w:hAnsi","w:eastAsia","w:cs"]){const g=c===void 0?void 0:f(c,l);g!==void 0&&o.add(g)}}return{...typeof s.font=="string"?{font:s.font}:{},...s.color===void 0?{}:{color:s.color},faces:o}}colors=new Map;watermark;keep(t,n){let e=++this.pictures,i=`${this.options.name}-${String(e)}.${n}`;for(;this.options.taken?.(i)===!0||this.files.has(i);)e=++this.pictures,i=`${this.options.name}-${String(e)}.${n}`;return this.files.set(i,t),i}pictureBytes(t,n){const e=this.pkg.rel(n,t)?.target;if(e===void 0)return;const i=this.pkg.bytes(e),s=(e.split(".").pop()??"").toLowerCase(),o=s==="jpg"||s==="jpeg"?"image/jpeg":s==="svg"?"image/svg+xml":["png","gif","webp","bmp"].includes(s)?`image/${s}`:void 0;return i===void 0||o===void 0?void 0:{bytes:i,type:o}}readNumbering(){const t=this.xml(this.partOf("numbering")),n=new Map;for(const e of Z(t,"w:abstractNum")){const i=new Map;for(const s of Z(e,"w:lvl")){const o=A(r(s,"w:numFmt"))??"decimal";i.set(T(f(s,"w:ilvl"))??0,{bullet:o==="bullet"||o==="none",start:T(A(r(s,"w:start")))??1,format:o,text:A(r(s,"w:lvlText"))??"",legal:Pe(r(s,"w:isLgl"))===!0})}n.set(f(e,"w:abstractNumId")??"",i)}for(const e of Z(t,"w:num")){const i=n.get(A(r(e,"w:abstractNumId"))??"");i&&this.numbering.set(f(e,"w:numId")??"",i)}}readNotes(){for(const[t,n]of[["footnotes","w:footnote"],["endnotes","w:endnote"]]){const e=this.xml(this.partOf(t));for(const i of Z(e,n)){const s=f(i,"w:type");s==="separator"||s==="continuationSeparator"||this.footnotes.set(`${t==="endnotes"?"e":""}${f(i,"w:id")??""}`,Z(i,"w:p"))}}}styleName(t){if(t!==void 0)return this.styles.get(t)?.name}headingLevel(t){const n=new Set;let e=t;for(;e!==void 0&&!n.has(e);){n.add(e);const i=this.styles.get(e);if(i===void 0)return;const s=/^Heading ([1-9])$/u.exec(i.name);if(s)return Number(s[1]);const o=T(A(r(i.pPr,"w:outlineLvl")));if(o!==void 0&&o>=0&&o<9)return o+1;e=i.basedOn}}fontOf(t){if(t===void 0)return;const n=c=>{const l=f(t,c);return l===void 0?void 0:l.startsWith("major")?this.theme.major:this.theme.minor},e=f(t,"w:ascii")??f(t,"w:hAnsi")??n("w:asciiTheme"),i=f(t,"w:eastAsia")??n("w:eastAsiaTheme"),s=c=>c?.split(";")[0],o=c=>c===void 0?void 0:on.get(c.toLowerCase()),a=[s(e),s(i)].find(c=>c!==void 0&&c.trim()!=="");return o(s(e))??o(s(i))??a?.trim()}runProps(t){if(t===void 0)return{};const n={},e=this.fontOf(r(t,"w:rFonts"));e!==void 0&&(n.font=e);const i=T(A(r(t,"w:sz")));i!==void 0&&(n.size=Yn(i/2));const s=D=>Pe(r(t,D)),o=s("w:b");o!==void 0&&(n.bold=o);const a=s("w:i");a!==void 0&&(n.italic=a);const c=r(t,"w:u");c!==void 0&&(n.underline=A(c)!=="none");const l=s("w:strike")??s("w:dstrike");l!==void 0&&(n.strike=l);const g=s("w:caps");g!==void 0&&(n.caps=g);const m=s("w:smallCaps");m!==void 0&&(n.smallCaps=m);const x=A(r(t,"w:color"));x!==void 0&&x!=="auto"&&/^[0-9a-f]{6}$/iu.test(x)&&(n.color=`#${x.toUpperCase()}`);const p=A(r(t,"w:highlight")),k=ae(r(t,"w:shd"),"w:fill");p!==void 0&&p!=="none"?n.background=Gn[p]??p:k!==void 0&&k!=="auto"&&/^[0-9a-f]{6}$/iu.test(k)&&(n.background=`#${k.toUpperCase()}`);const y=T(A(r(t,"w:spacing")));return y!==void 0&&y!==0&&(n.letterSpacing=y/20),n}paragraphProps(t){if(t===void 0)return{};const n={},e=A(r(t,"w:jc"));e==="center"?n.align="center":e==="right"||e==="end"?n.align="right":e==="both"||e==="distribute"?n.align="justify":(e==="left"||e==="start")&&(n.align="left");const i=m=>Math.round(m/(this.normalSize*20)*100)/100,s=r(t,"w:ind");if(s!==void 0){const m=T(f(s,"w:left")??f(s,"w:start")),x=T(f(s,"w:right")??f(s,"w:end")),p=T(f(s,"w:firstLine")),k=T(f(s,"w:hanging")),y=T(f(s,"w:firstLineChars"));m!==void 0&&m!==0&&(n.indent=i(m)),x!==void 0&&x!==0&&(n.indentRight=i(x)),y!==void 0&&y!==0?n.firstLine=y/100:p!==void 0&&p!==0?n.firstLine=i(p):k!==void 0&&k!==0&&(n.firstLine=-i(k))}const o=r(t,"w:spacing");if(o!==void 0){const m=T(f(o,"w:before")),x=T(f(o,"w:after")),p=T(f(o,"w:line")),k=f(o,"w:lineRule")??"auto";m!==void 0&&(n.spaceBefore=m/20),x!==void 0&&(n.spaceAfter=x/20),p!==void 0&&p>0&&(n.lineHeight=k==="auto"?Math.round(p/240*100)/100:`${String(p/20)}pt`)}const a=m=>Pe(r(t,m)),c=a("w:keepNext");c!==void 0&&(n.keepNext=c);const l=a("w:keepLines");l!==void 0&&(n.keepLines=l);const g=a("w:pageBreakBefore");return g!==void 0&&(n.pageBreakBefore=g),n}revisionOf(t){const n=f(t,"w:author")?.trim()??"",e=n===""?"Unknown":n,i=f(t,"w:date"),s=i!==void 0&&!Number.isNaN(Date.parse(i)),o=i?.replace(/\.0+Z$/u,"Z"),a=this.moves.get(t);return{author:e,...s&&o!==void 0?{date:o}:{},...a===void 0?{}:{move:a}}}moves=new WeakMap;nameMoves(t){const n=new Map,e={from:void 0,to:void 0},i=[...t.children].reverse();for(let s=i.pop();s!==void 0;s=i.pop()){const o=s.key==="w:moveFromRangeStart"||s.key==="w:moveFromRangeEnd"?"from":s.key==="w:moveToRangeStart"||s.key==="w:moveToRangeEnd"?"to":void 0;if(o!==void 0){const a=f(s,"w:id")??"";if(s.key.endsWith("Start")){const c=f(s,"w:name")??`move${a}`;n.set(`${o}:${a}`,c),e[o]=c}else n.has(`${o}:${a}`)&&(n.delete(`${o}:${a}`),e[o]=void 0);continue}s.key==="w:moveFrom"&&e.from!==void 0&&this.moves.set(s,e.from),s.key==="w:moveTo"&&e.to!==void 0&&this.moves.set(s,e.to);for(let a=s.children.length-1;a>=0;a--){const c=s.children[a];c!==void 0&&i.push(c)}}}picture(t,n){const e=this.pkg.rel(n,t)?.target;if(e===void 0)return;const i=this.saved.get(e);if(i!==void 0)return i;const s=this.pkg.bytes(e),o=(e.split(".").pop()??"").toLowerCase();if(s===void 0)return;if(!["png","jpg","jpeg","gif","svg","webp","bmp"].includes(o)){this.lose(`a picture as ${o.toUpperCase()}, which a page cannot show`);return}let a=++this.pictures,c=`${this.options.name}-${String(a)}.${o}`;for(;this.options.taken?.(c)===!0||this.files.has(c);)a=++this.pictures,c=`${this.options.name}-${String(a)}.${o}`;return this.files.set(c,s),this.saved.set(e,c),c}}function Yn(d){const t=Object.entries(Mn).find(([,n])=>n===d)?.[0];return d===12||d===11||d===10.5||t===void 0?d:t}const Vn=/^(Frame Contents|Table Contents|Table Heading)$/u,qn=/^(.+ Char|line number|Bibliography|Default Paragraph Font|No List|Table Normal|Normal Table|Hyperlink|FollowedHyperlink|(foot|end)note (reference|text)|annotation (reference|text|subject)|Balloon Text|header|footer|toc \d|TOC Heading|caption|List Paragraph)$/iu;export function templateStyles(d,t){const n=new rn(d,{name:"template"},t);n.readStyles(),n.readTheme(),n.readNumbering();for(const[e,i]of n.styles)qn.test(i.name)||(i.type==="table"?n.tableStyle(e):(i.type==="paragraph"||i.type==="character")&&n.used.add(i.name));return{styles:ln(n),lost:[...n.lost].map(([e,i])=>i===1?e:`${e} (${String(i)})`)}}export function importDocx(d,t,n){const e=new rn(d,t,n);e.readStyles(),e.readTheme(),e.readNumbering(),e.readNotes();const i=e.xml(e.doc),s=r(i,"w:body");if(s===void 0)throw new Error("its document has no body");e.nameMoves(s);const o=[];let a;const c=[],l=new Map,g=new Map,m=new Set,x=(u,h,w,v,N)=>{const F=(b,O,E)=>{if(b===""||a!==void 0&&!a.result||a?.toc===!0)return;const C=[a,...c].find(I=>I?.run!==void 0);if(C?.run!==void 0){C.run.text+=b;return}const P=w.at(-1);if(P!==void 0&&P.note===void 0&&P.field===void 0&&P.href===E&&JSON.stringify(P.styles)===JSON.stringify(O)){P.text+=b;return}w.push({text:b,styles:{...O},...E===void 0?{}:{href:E}})};for(const b of u)switch(b.key){case"w:r":{const O={...dn(e,r(b,"w:rPr")),...e.openComments.size>0?{comments:[...e.openComments]}:{}};h.href!==void 0&&(delete O.color,delete O.underline);const E={...h.styles,...O};for(const C of b.children)switch(C.key){case"w:t":case"w:delText":F(C.text,E,h.href);break;case"w:tab":F(" ",E,h.href);break;case"w:br":case"w:cr":f(C,"w:type")==="page"?v.push({type:"pagebreak"}):F(`
3
+ `,E,h.href);break;case"w:noBreakHyphen":F("‑",E,h.href);break;case"w:softHyphen":F("­",E,h.href);break;case"w:sym":{const P=f(C,"w:char");P!==void 0&&F(String.fromCodePoint(parseInt(P,16)&65535),E,h.href);break}case"w:footnoteReference":case"w:endnoteReference":{const P=`${C.key==="w:endnoteReference"?"e":""}${f(C,"w:id")??""}`,I=`n${String(e.notes.size+1)}`;e.notes.set(P,e.notes.get(P)??I),w.push({text:e.notes.get(P)??I,styles:{},note:e.notes.get(P)??I});break}case"w:drawing":case"w:pict":p(C,v,N);break;case"w:fldChar":{const P=f(C,"w:fldCharType");if(P==="begin")c.push(a),a={instr:"",result:!1,toc:!1};else if(P==="separate"&&a!==void 0){if(a.result=!0,a.toc=/^\s*TOC\b/u.test(a.instr),a.toc&&!e.toc){e.toc=!0;const Q=Number(/\\o\s+"\d+-(\d+)"/u.exec(a.instr)?.[1]),z=Math.min(Q,6);v.push({type:"toc",...Number.isInteger(z)&&z>=1&&z!==3?{levels:z}:{}})}const I=Ue(a.instr);I!==void 0&&!c.some(Q=>Q?.run)&&(a.run={text:"",styles:{...E},field:I},w.push(a.run))}else if(P==="end"){const I=a===void 0||a.result?void 0:Ue(a.instr);I!==void 0&&!c.some(Q=>Q?.run)&&w.push({text:"",styles:{...E},field:I}),a=c.pop()}break}case"w:instrText":a!==void 0&&(a.instr+=C.text);break;case"w:rPr":case"w:lastRenderedPageBreak":break;case"w:object":e.lose("an embedded object (OLE)");break;default:break}break}case"w:hyperlink":{const O=f(b,"r:id"),E=f(b,"w:anchor"),P=(O===void 0?void 0:e.pkg.rel(N,O)?.target)??(E===void 0?void 0:`#${E}`);x(b.children,{...h,...P===void 0?{}:{href:P}},w,v,N);break}case"w:ins":case"w:moveTo":x(b.children,{...h,styles:{...h.styles,inserted:e.revisionOf(b)}},w,v,N);break;case"w:del":case"w:moveFrom":x(b.children,{...h,styles:{...h.styles,deleted:e.revisionOf(b)}},w,v,N);break;case"w:fldSimple":{const O=f(b,"w:instr")??"",E=Ue(O);if(/^\s*TOC\b/u.test(O))e.toc||(e.toc=!0,v.push({type:"toc"}));else if(E!==void 0&&a===void 0){const C=[];x(b.children,h,C,v,N),w.push({text:C.map(P=>P.text).join(""),styles:{...h.styles,...C[0]?.styles??{}},field:E})}else x(b.children,h,w,v,N);break}case"w:smartTag":case"w:customXml":case"w:dir":case"w:bdo":x(b.children,h,w,v,N);break;case"w:sdt":x(r(b,"w:sdtContent")?.children??[],h,w,v,N);break;case"m:oMathPara":v.push({type:"code",language:_e.math,code:tn(b)});break;case"m:oMath":{const O={type:"code",language:_e.math,code:Dn(b)};m.add(O),v.push(O);break}case"w:commentRangeStart":e.openComments.add(e.commentId(f(b,"w:id")));break;case"w:commentRangeEnd":e.openComments.delete(e.commentId(f(b,"w:id")));break;case"w:pPr":case"w:bookmarkStart":case"w:bookmarkEnd":case"w:proofErr":case"w:permStart":case"w:permEnd":break;default:break}},p=(u,h,w)=>{const v=Y(u,"wp:anchor")!==void 0,N=Y(u,"a:blip")??Y(u,"v:imagedata"),F=N===void 0?void 0:De(N)??f(N,"r:embed")??f(N,"r:id"),b=Y(u,"c:chart");if(b!==void 0){const ie=e.pkg.rel(w,f(b,"r:id"))?.target,W=ie===void 0?void 0:et(e,ie);if(W===void 0||typeof W=="string"){e.lose(W??"a chart, left out (its numbers are in the file's workbook)");return}const R=Y(u,"wp:extent"),se=T(R===void 0?void 0:f(R,"cx")),re=T(R===void 0?void 0:f(R,"cy")),he=Y(u,"wp:docPr"),G=he===void 0?void 0:f(he,"descr"),Se=[W.title,W.table?.[0]?.slice(1).join(", ")].filter(Me=>Me!==void 0&&Me!==""),M=Se.length>0?Se.join(": "):"Chart",X=G===void 0||G.trim()===M?void 0:G,de=se===void 0?void 0:Math.round(se/ve),ye=re===void 0?void 0:Math.round(re/ve),ce=Fn(W,y()),xe=de!==void 0&&ye!==void 0&&Math.abs(de-ce.width)<=1&&Math.abs(ye-ce.height)<=1;h.push({...W,...de===void 0||xe?{}:{width:de},...ye===void 0||xe?{}:{height:ye},...X===void 0||X.trim()===""?{}:{alt:X.replace(/\s+/gu," ").trim()}});return}const O=Y(u,"wpg:wgp")!==void 0,E=Y(u,"wps:wsp")!==void 0&&Y(u,"w:txbxContent")===void 0;let C;if(O||E){const ie=zn(u,{scheme:W=>e.colors.get(W),picture:W=>e.pictureBytes(W,w),textSize:e.normalSize,lose:W=>{e.lose(W)}});if(ie===void 0){e.lose(O?"a group of shapes, left out":"a shape, left out");return}C=e.keep(new TextEncoder().encode(ie.svg),"svg")}const P=C===void 0?Y(u,"w:txbxContent"):void 0;if(P===void 0&&F===void 0&&C===void 0)return;const I=Y(u,"wp:anchor"),Q=I!==void 0&&["wp:wrapSquare","wp:wrapTight","wp:wrapThrough"].some(ie=>r(I,ie)!==void 0),z=I!==void 0&&!Q&&(r(I,"wp:wrapNone")!==void 0||f(I,"behindDoc")==="1")?k(I):void 0;let ee;if(I!==void 0&&Q){const ie=r(I,"wp:positionH"),W=r(ie,"wp:align")?.text.trim(),R=T(r(ie,"wp:posOffset")?.text.trim());ee=W==="right"||W==="outside"?"right":W==="left"||W==="inside"?"left":R!==void 0&&R>27e5?"right":"left"}else v&&z===void 0&&e.lose(P===void 0?"a picture in front of, behind or between the words, set in its line":"a text box in front of, behind or between the words, set in its line");const ne=Y(u,"wp:extent"),U=T(ne===void 0?void 0:f(ne,"cx"));if(P!==void 0){const ie=D(P.children,w),W=U===void 0?void 0:Math.round(U/ve),R=ee===void 0&&z===void 0&&W!==void 0&&W>=y()*.95;h.push({type:"textbox",...ee===void 0?{}:{float:ee},...z,...W===void 0||W<1||R?{}:{width:W},...ie.length>0?{children:ie}:{}});return}const le=C??(F===void 0?void 0:e.picture(F,w));if(le===void 0)return;const j=Y(u,"wp:docPr"),ge=(j===void 0?void 0:f(j,"descr")??f(j,"title"))?.replace(/\s+/gu," ").trim();h.push({type:"image",src:`./${le}`,...ge===void 0||ge===""?{}:{alt:ge},...U===void 0||st(e,le,Math.round(U/ve),y())?{}:{width:Math.max(1,Math.round(U/ve))},...ee===void 0?{}:{float:ee},...z})},k=u=>{const h=r(s,"w:sectPr"),w=r(h,"w:pgMar"),v=te=>Math.abs(T(ae(w,te))??1440)/15,N=(T(ae(r(h,"w:pgSz"),"w:w"))??12240)/15,F=r(u,"wp:extent"),b=(T(ae(F,"cx"))??0)/ve,O=y(),E=r(u,"wp:positionH"),C=ae(E,"relativeFrom"),P=r(E,"wp:align")?.text.trim(),I=(T(r(E,"wp:posOffset")?.text.trim())??0)/ve,Q=C==="page"?N:O,z=C==="page"?0:v("w:left"),ee=P==="center"?z+(Q-b)/2:P==="right"||P==="outside"?z+Q-b:P==="left"||P==="inside"?z:z+I,ne=r(u,"wp:positionV"),U=ae(ne,"relativeFrom"),le=T(r(ne,"wp:posOffset")?.text.trim()),j=(U==="paragraph"||U==="line")&&r(ne,"wp:align")===void 0;return j||e.lose("a picture over or under the words placed down the page, not from its paragraph: set at its paragraph's top"),{wrap:f(u,"behindDoc")==="1"?"behind":"front",x:Math.round(ee-v("w:left")),y:j&&le!==void 0?Math.round(le/ve):0}},y=()=>{const u=r(s,"w:sectPr"),h=T(ae(r(u,"w:pgSz"),"w:w"))??12240,w=r(u,"w:pgMar"),v=N=>Math.abs(T(ae(w,N))??1440);return(h-v("w:left")-v("w:right"))/15},D=(u,h)=>{const w=[];for(const v of u)v.key==="w:p"?w.push(..._(v,h)):v.key==="w:tbl"?w.push({block:H(v,h)}):v.key==="w:sdt"&&w.push(...D(r(v,"w:sdtContent")?.children??[],h).map(N=>({block:N})));return un(w,e)},_=(u,h)=>{const w=r(u,"w:pPr"),v=A(r(w,"w:pStyle")),N=r(w,"w:rPr"),F=r(N,"w:ins")??r(N,"w:moveTo"),b=r(N,"w:del")??r(N,"w:moveFrom"),O=r(w,"w:pPrChange"),E=[],C=[],P=a?.toc===!0;x(u.children,{styles:{}},E,C,h);const I=e.styledRun(v);for(const M of E){const X=M.styles.font;X!==void 0&&(X===I.font||I.faces.has(X))&&delete M.styles.font,M.styles.color!==void 0&&M.styles.color.toUpperCase()===I.color?.toUpperCase()&&delete M.styles.color}if(P&&(a?.toc===!0||E.every(M=>M.text.trim()==="")))return C.map(M=>({block:M}));const Q=e.paragraphProps(w),z=e.styleName(v),ee=e.headingLevel(v),ne=r(w,"w:numPr")??Qn(e,v),U=A(r(ne,"w:numId")),le=T(A(r(ne,"w:ilvl")))??0;let j;const te=Fe(E);if(te.some(M=>M.text.trim()!==""))for(const M of C)m.has(M)&&e.lose("an equation in a line of words, set on a line of its own");if(ee!==void 0)ee>6&&e.lose("a heading below level 6, read as a heading 6"),j={type:"heading",level:Math.min(ee,6),content:te};else if(z===Le&&o.length===0)j={type:"heading",level:1,content:te};else if(z==="Quote")j={type:"quote",content:te};else if(U!==void 0&&U!=="0"&&e.numbering.has(U)){const M=e.numbering.get(U)?.get(le);M?.bullet===!1&&e.numberedLists.set(U,(e.numberedLists.get(U)??0)+1),j=M?.bullet===!1?{type:"numbered",content:te}:{type:"bullet",content:te}}else j={type:"paragraph",content:te};const ge=z===void 0||z===Ce||Vn.test(z)||ee!==void 0||z==="Quote"||z==="List Paragraph"||z===Le&&j.type==="heading"?void 0:z;ge!==void 0&&e.used.add(ge);const ie={align:"left",spaceBefore:0,spaceAfter:0,...e.styledParagraph(v)},R={...Object.fromEntries(Object.entries(Q).filter(([M,X])=>JSON.stringify(X)!==JSON.stringify(ie[M]))),...ge===void 0?{}:{style:ge}};if(Object.keys(R).length>0&&"content"in j&&(j={...j,look:R}),O!==void 0&&"content"in j){const M=r(O,"w:pPr"),X=e.styleName(A(r(M,"w:pStyle"))),de=X===void 0||X===Ce||X==="Quote"||X==="List Paragraph"||e.headingLevel(A(r(M,"w:pStyle")))!==void 0?void 0:X;j={...j,formatted:{...e.revisionOf(O),was:{...e.paragraphProps(M),...de===void 0?{}:{style:de}}}}}const se=M=>te.length>0&&te.every(X=>X.styles[M]!==void 0);if(F!==void 0&&se("inserted"))j={...an(j,"inserted"),revision:{kind:"inserted",...e.revisionOf(F)}};else if(b!==void 0&&se("deleted"))j={...an(j,"deleted"),revision:{kind:"deleted",...e.revisionOf(b)}};else if((F!==void 0||b!==void 0)&&["paragraph","heading","bullet","numbered","check"].includes(j.type)){const M=b??F;M!==void 0&&(j={...j,mark:{kind:b===void 0?"inserted":"deleted",...e.revisionOf(M)}})}const re=[],he=te.length===0,G=typeof Q.lineHeight=="string"&&parseFloat(Q.lineHeight)<2;if(he&&G&&C.length===0)return[];(!he||C.length===0)&&re.push({block:j,...U!==void 0&&j.type!=="paragraph"&&(j.type==="bullet"||j.type==="numbered")?{list:{numId:U,level:le}}:{}});const Se=M=>(M.type==="image"||M.type==="textbox")&&(M.float!==void 0||M.wrap!==void 0);re.unshift(...C.filter(Se).map(M=>({block:M})));for(const M of C.filter(X=>!Se(X)))re.push({block:M});return re},H=(u,h)=>{const w=Z(r(u,"w:tblGrid"),"w:gridCol").map(R=>T(f(R,"w:w"))??0),v={nested:!1},N={},F=[],b=new Map,O=[],E=[],C=Z(u,"w:tr").map((R,se)=>{let re=0;const he=r(r(R,"w:trPr"),"w:trHeight"),G=T(ae(he,"w:val"));E.push(G!==void 0&&G>0&&ae(he,"w:hRule")!=="auto"?Math.round(G/15):null);const Se=[];return O.push(Se),Z(R,"w:tc").flatMap(M=>{const X=r(M,"w:tcPr"),de=Math.max(1,T(A(r(X,"w:gridSpan")))??1),ye=r(X,"w:vMerge"),ce=re;re+=de;const xe=A(r(X,"w:vAlign")),Me=ye!==void 0&&A(ye)!=="restart"?b.get(ce):void 0,yn=Me!==void 0?O[Me.row]?.[Me.col]??"top":xe==="center"||xe==="both"?"center":xe==="bottom"?"bottom":"top";for(let B=ce;B<ce+de;B++)Se[B]=yn;const Re=()=>Array.from({length:de},()=>[]);if(ye!==void 0&&A(ye)!=="restart"){const B=b.get(ce);if(B!==void 0)return B.rows+=1,Re()}if(ye!==void 0&&A(ye)==="restart"){const B={row:se,col:ce,rows:1,cols:de};F.push(B);for(let Oe=ce;Oe<ce+de;Oe++)b.set(Oe,B)}else{for(let B=ce;B<ce+de;B++)b.delete(B);de>1&&F.push({row:se,col:ce,rows:1,cols:de})}if(M.children.some(B=>B.key==="w:tbl"||B.key==="w:p"&&(Y(B,"w:drawing")!==void 0||Y(B,"w:pict")!==void 0||Y(B,"m:oMathPara")!==void 0||r(r(B,"w:pPr"),"w:numPr")!==void 0))){const B=D(M.children,h).filter(me=>me.type!=="pagebreak"?!0:(e.lose("a page break in a table's cell, left out"),!1));if(B.every(me=>me.type==="paragraph"&&(me.children?.length??0)===0)){const me=[];for(const je of B)je.type==="paragraph"&&je.content.length>0&&(me.length>0&&me.push({text:`
4
+ `,styles:{}}),me.push(...je.content));return[me,...Re().slice(1)]}return N[`${Rn(ce)}${String(se+1)}`]=B,[[],...Re().slice(1)]}const Ae=[];return M.children.forEach(B=>{if(B.key==="w:tbl"&&(v.nested=!0),B.key!=="w:p")return;const Oe=[],me=[];x(B.children,{styles:{}},Oe,me,h),me.length>0&&e.lose("a picture or break in a table's cell, left out"),Ae.length>0&&Oe.length>0&&Ae.push({text:`
5
+ `,styles:{}}),Ae.push(...Fe(Oe))}),[Ae,...Re().slice(1)]})}),P=F.filter(R=>R.rows*R.cols>1);v.nested&&e.lose("a table in a table's cell, left out");const I=A(r(r(u,"w:tblPr"),"w:tblStyle")),Q=I===void 0?void 0:e.tableStyle(I),z=Pe(r(r(Z(u,"w:tr")[0],"w:trPr"),"w:tblHeader"))===!0,ee=w.reduce((R,se)=>R+se,0),ne=Math.round(e.normalSize*.9*2)/2,U=Q===void 0?void 0:e.tableStyles.get(Q),le=e.styledRun(),te={type:"table",rows:C.map((R,se)=>R.map(re=>re.map(he=>{const G={...he.styles};return G.size===ne&&delete G.size,G.font!==void 0&&(G.font===le.font||le.faces.has(G.font))&&delete G.font,G.color!==void 0&&G.color.toUpperCase()===le.color?.toUpperCase()&&delete G.color,se===0&&z&&(G.bold===!0&&delete G.bold,U?.headColor!==void 0&&G.color?.toUpperCase()===U.headColor.toUpperCase()&&delete G.color),{...he,styles:G}}))),...z?{}:{head:"none"},...P.length>0?{merges:P}:{},...E.some(R=>R!==null)?{heights:E}:{},...(()=>{const R=Math.max(0,...O.map(re=>re.length)),se=In(O.map(re=>Array.from({length:R},(he,G)=>re[G]??"top")));return se.length>0?{valign:se}:{}})(),...Object.keys(N).length>0?{cells:N}:{},...Q===void 0?{}:{style:Q}};if(w.length===0||ee<=0)return te;const ge=w.map(R=>Math.round(R/15)),ie=Ln(te,ee/15,ne,ht);return ge.some((R,se)=>Math.abs(R-(ie[se]??0))>2)?{...te,widths:ge}:te};let K="portrait";const V=r(s,"w:sectPr"),q=u=>ae(r(u,"w:pgSz"),"w:orient")==="landscape"?"landscape":"portrait";K=Xn(s,q)??q(V);const pe=s.children.filter(u=>u.key==="w:p").map(u=>r(r(u,"w:pPr"),"w:sectPr")).find(u=>u!==void 0)??V;let fe=fn(pe);const J=u=>hn(u).margins,L=J(pe);let S=JSON.stringify(L);const $=[],oe=u=>{for(const h of u)if(h.key==="w:p"){const w=r(r(h,"w:pPr"),"w:sectPr");w!==void 0&&$.push(w)}else h.key==="w:sdt"?oe(r(h,"w:sdtContent")?.children??[]):h.key==="w:customXml"&&oe(h.children)};oe(s.children),V!==void 0&&$.push(V);const be=bt(e,$),we=pe===void 0?void 0:be.get(pe),ue={header:JSON.stringify(we?.header),footer:JSON.stringify(we?.footer)};fe>1&&o.push({block:{type:"pagebreak",columns:fe,continuous:!0}});const ke=u=>{for(const h of u)switch(h.key){case"w:p":{const w=_(h,e.doc);r(r(h,"w:pPr"),"w:sectPr")!==void 0&&w.every(O=>O.block.type==="paragraph"&&O.block.content.length===0)||o.push(...w);const N=w.find(O=>O.block.type==="heading")?.block;if(N!==void 0)for(const O of cn(h))l.set(O,N);const F=w.find(O=>O.block.type==="paragraph"&&O.block.look?.style==="Caption")?.block;if(F!==void 0)for(const O of cn(h))g.set(O,F);const b=r(r(h,"w:pPr"),"w:sectPr");if(b!==void 0){const O=ct(h)??V,E=q(O),C=fn(O),P=ae(r(O,"w:type"),"w:val")==="continuous",I=J(O),Q=JSON.stringify(I)!==S&&I!==void 0;Q&&P&&e.lose("a continuous section's own margins, read as the section's before it");const z=be.get(O??b),ee={};for(const ne of["header","footer"]){const U=z?.[ne];U===void 0||JSON.stringify(U)===ue[ne]||U!==!1&&U.first===void 0&&JSON.stringify(U)===it(ue[ne])||(P?e.lose(`a continuous section's own ${ne}, read as the section's before it`):(ee[ne]=U,ue[ne]=JSON.stringify(U)))}o.push({block:{type:"pagebreak",...E===K||P?{}:{orientation:E},...C!==fe?{columns:C}:{},...P?{continuous:!0}:{},...Q&&!P?{margins:I}:{},...ee}}),P||(S=JSON.stringify(I)),P&&E!==K&&e.lose("a continuous section break that turns the page, read on the same page"),K=E,fe=C}break}case"w:tbl":o.push({block:H(h,e.doc)});break;case"w:sdt":ke(r(h,"w:sdtContent")?.children??[]);break;case"w:customXml":ke(h.children);break;case"w:sectPr":case"w:bookmarkStart":case"w:bookmarkEnd":case"w:proofErr":break;case"m:oMathPara":o.push({block:{type:"code",language:_e.math,code:tn(h)}});break;default:break}};ke(s.children);const Ee=[];for(const[u,h]of e.notes){const w=e.footnotes.get(u)??[],v=[];for(const F of w){const b=[];x(F.children,{styles:{}},b,[],e.partOf(u.startsWith("e")?"endnotes":"footnotes")??e.doc),v.length>0&&b.length>0&&v.push({text:`
6
+ `,styles:{}}),v.push(...Fe(b.filter(O=>O.note===void 0)))}const N=v.map(F=>{const b={...F.styles};return(b.size===9||b.size==="小五")&&delete b.size,b.color?.toUpperCase()===pt&&delete b.color,{...F,styles:b}});Ee.push({type:"note",label:h,content:N})}const Be=new Map,$e=rt(dt(un(o,e),Be));ft($e,e,t.gather??GATHER_DEFAULT);const mn=_n($e),Ie=new Map;for(const[u,h]of l){const w=mn.get(h);w!==void 0&&Ie.set(u,w)}for(const[u,h]of g){const w=Be.get(h);if(w===void 0||!/^(b_|_Ref)/u.test(u))continue;const v=u.startsWith("b_")?u.slice(2):u.slice(1);(w.type==="table"||w.type==="image"||w.type==="chart")&&w.id===void 0&&(w.id=v,Ie.set(u,v))}Ie.size>0&&at($e,Ie);const Ne=[...$e,...Ee],He=new Map;for(const u of Z(e.xml(e.partOf("commentsExtended"),{mce:!1}),"w15:commentEx")){const h=f(u,"w15:paraId");if(h===void 0)continue;const w=f(u,"w15:paraIdParent");He.set(h,{...w===void 0?{}:{parent:w},done:f(u,"w15:done")==="1"})}const Je=e.partOf("comments"),We=Z(e.xml(Je,{mce:!1}),"w:comment"),Ge=new Map;for(const u of We){const h=Z(u,"w:p").at(-1),w=h===void 0?void 0:f(h,"w14:paraId");w!==void 0&&Ge.set(w,e.commentId(f(u,"w:id")))}for(const u of We){const h=e.commentId(f(u,"w:id")),w=Z(u,"w:p").at(-1),v=He.get(w===void 0?"":f(w,"w14:paraId")??""),N=v?.parent===void 0?void 0:Ge.get(v.parent),F=Z(u,"w:p").flatMap(O=>{const E=[];x(O.children,{styles:{}},E,[],Je??e.doc);const C=Fe(E.filter(P=>P.text!==""));return C.length===0?[]:[{type:"paragraph",content:C}]}),b=e.revisionOf(u);Ne.push({type:"comment",id:h,author:b.author,...b.date===void 0?{}:{date:b.date},...N===void 0?{}:{replyTo:N},...v?.done===!0?{done:!0}:{},blocks:F})}const Ye=new Set(Ne.flatMap(u=>u.type==="comment"&&u.replyTo!==void 0?[u.id]:[]));Ye.size>0&&ot(Ne,Ye);const wn=hn(V),Ve=ln(e),Te=[...e.notes.keys()].filter(u=>u.startsWith("e")).length;Te>0&&Te<e.notes.size&&e.lose("an endnote beside footnotes, read as a footnote",Te);const qe=e.partOf("settings"),gn=Pe(r(qe===void 0?void 0:e.xml(qe),"w:trackRevisions"))===!0,Qe=Kn(e),Xe={...wn,...L===void 0?{}:{margins:L},...we===void 0?{}:{header:we.header,footer:we.footer},...Te>0&&Te===e.notes.size?{notes:"end"}:{},...Qe===void 0?{}:{lists:Qe},...e.watermark===void 0?{}:{watermark:e.watermark},...gn?{track:!0}:{},...Object.keys(Ve).length>0?{styles:Ve}:{}},Ze=Hn(Xe);return{mdx:`${Ze===""?"":`---
7
+ ${Ze}
8
+ ---
9
+
10
+ `}${Jn(Ne)}
11
+ `,blocks:Ne,page:Xe,files:e.files,lost:[...e.lost].map(([u,h])=>h===1?u:`${u} (${String(h)})`)}}function Y(d,t){for(const n of d.children){if(n.key===t)return n;const e=Y(n,t);if(e)return e}}function Qn(d,t){const n=new Set;let e=t;for(;e!==void 0&&!n.has(e);){n.add(e);const i=d.styles.get(e),s=r(i?.pPr,"w:numPr");if(s!==void 0)return s;e=i?.basedOn}}function dn(d,t){if(t===void 0)return{};const n=d.runProps(t),e=d.styleName(A(r(t,"w:rStyle"))),i=A(r(t,"w:vertAlign")),s=r(t,"w:rPrChange"),o=s===void 0?void 0:dn(d,r(s,"w:rPr")),a=e!==void 0&&!/^(Default Paragraph Font|Hyperlink|footnote reference|endnote reference)$/iu.test(e);return a&&d.used.add(e),{...n.bold===!0?{bold:!0}:{},...n.italic===!0?{italic:!0}:{},...n.underline===!0?{underline:!0}:{},...n.strike===!0?{strike:!0}:{},...n.color===void 0?{}:{color:n.color},...n.background===void 0?{}:{background:n.background},...n.font===void 0?{}:{font:n.font},...n.size===void 0?{}:{size:n.size},...n.caps===!0?{caps:!0}:{},...n.smallCaps===!0?{smallCaps:!0}:{},...n.letterSpacing===void 0?{}:{letterSpacing:n.letterSpacing},...i==="superscript"?{superscript:!0}:{},...i==="subscript"?{subscript:!0}:{},...a?{style:e}:{},...s===void 0||o===void 0?{}:{formatted:{...d.revisionOf(s),was:Object.fromEntries(xn.flatMap(l=>o[l]===void 0?[]:[[l,o[l]]]))}}}}function Fe(d){const t=d.map(i=>({...i})),n=t[0];n!==void 0&&n.note===void 0&&n.field===void 0&&(n.text=n.text.replace(/^[ \t\n]+/u,""));const e=t.at(-1);return e!==void 0&&e.note===void 0&&e.field===void 0&&(e.text=e.text.replace(/[ \t\n]+$/u,"")),t.filter(i=>i.text!==""||i.note!==void 0||i.field!==void 0)}function an(d,t){return!("content"in d)||!Array.isArray(d.content)?d:{...d,content:d.content.map(n=>{const e={...n.styles};return t==="inserted"?delete e.inserted:delete e.deleted,{...n,styles:e}})}}function Xn(d,t){for(const n of d.children){if(n.key!=="w:p")continue;const e=r(r(n,"w:pPr"),"w:sectPr");if(e!==void 0)return t(e)}}const Zn=new Set(["PAGE","NUMPAGES","SECTIONPAGES","SECTION","PAGEREF","REF","NOTEREF","STYLEREF","DATE","TIME","CREATEDATE","SAVEDATE","PRINTDATE","EDITTIME","AUTHOR","LASTSAVEDBY","TITLE","SUBJECT","KEYWORDS","COMMENTS","FILENAME","FILESIZE","DOCPROPERTY","DOCVARIABLE","NUMWORDS","NUMCHARS","USERNAME","USERINITIALS","MERGEFIELD","FILLIN"]);function Ue(d){const t=d.trim().replace(/\s+/gu," "),n=t.split(" ")[0]?.toUpperCase()??"";return Zn.has(n)?t:void 0}function Kn(d){const[t]=[...d.numberedLists].sort((i,s)=>s[1]-i[1])[0]??[],n=t===void 0?void 0:d.numbering.get(t);if(n===void 0)return;const e=[];for(let i=0;i<6;i++){const s=n.get(i);if(s===void 0||s.bullet)break;const o=s.text.replace(/%([1-9])/gu,(a,c)=>{const l=Number(c),g=s.legal&&l!==i+1?"decimal":n.get(l-1)?.format??"decimal",m=sn.get(g)??"decimal";return m==="decimal"?`{${c}}`:`{${c}:${m}}`});if(!o.includes(`{${String(i+1)}`))break;e.push(o.replace(/%%/gu,"%"))}for(;e.length>0&&e.at(-1)===Un[e.length-1];)e.pop();return e.length===0?void 0:{numbered:e}}function et(d,t){const n="a chart, left out (its numbers are in the file's workbook)",e=(S,$)=>S===void 0?void 0:Y(S,$),i=S=>S===void 0?void 0:f(S,"val"),o=d.xml(t)?.children.find(S=>S.key==="c:chart"),a=r(o,"c:plotArea"),c=a?.children.find(S=>S.key.endsWith("Chart"));if(c===void 0)return n;(a?.children.filter(S=>S.key.endsWith("Chart")).length??0)>1&&d.lose("a chart of two kinds, read as its first");const l=i(r(c,"c:grouping")),g=l==="stacked"?"-stacked":l==="percentStacked"?"-stacked-100":"";let m;const x=c.key.replace(/3DChart$/u,"Chart");switch(x!==c.key&&d.lose("a 3D chart, read flat"),x){case"c:barChart":{const S=i(r(c,"c:barDir"))==="bar"?"bar":"column";m=g===""?`${S}-clustered`:`${S}${g}`;break}case"c:lineChart":{m=Z(c,"c:ser").some($=>i(r(r($,"c:marker"),"c:symbol"))!=="none")?"line-markers":"line";break}case"c:areaChart":m=`area${g}`;break;case"c:pieChart":m="pie";break;case"c:doughnutChart":m="doughnut";break;case"c:scatterChart":{const S=i(r(c,"c:scatterStyle"));m=S==="smoothMarker"||S==="smooth"?"scatter-smooth":S==="lineMarker"||S==="line"?"scatter-lines":"scatter";break}default:return`a chart of Word's ${c.key.slice(2,-5)} kind, left out`}const p=S=>{const $=e(S,"c:strCache")??e(S,"c:numCache"),oe=[];for(const be of Z($,"c:pt")){const we=T(f(be,"idx")),ue=r(be,"c:v")?.text??"",ke=Number(ue);we!==void 0&&(oe[we]=$?.key==="c:numCache"&&ue.trim()!==""&&Number.isFinite(ke)?String(ke):ue)}return Array.from(oe,be=>be??"")},k=Z(c,"c:ser"),y=k[0];if(y===void 0)return n;const D=c.key==="c:scatterChart",_=p(r(y,D?"c:xVal":"c:cat")),H=k.map((S,$)=>({name:p(r(S,"c:tx"))[0]??`Series ${String($+1)}`,values:p(r(S,D?"c:yVal":"c:val"))}));if(H.every(S=>S.values.length===0))return n;const K=Math.max(_.length,...H.map(S=>S.values.length)),V=[["",...H.map(S=>S.name)],...Array.from({length:K},(S,$)=>[_[$]??String($+1),...H.map(oe=>oe.values[$]??"")])],q=e(r(o,"c:title"),"c:rich"),pe=q===void 0?"":nt(q).join("").trim(),fe=r(o,"c:legend"),J=i(r(fe,"c:legendPos")),L=fe===void 0?"none":J==="r"?"right":J==="l"?"left":J==="t"?"top":J==="b"?"bottom":void 0;return{type:"chart",kind:m,table:V,...pe===""?{}:{title:pe},...L===void 0||L===(m==="pie"||m==="doughnut"?"right":H.length>1?"top":"none")?{}:{legend:L}}}function nt(d){const t=[],n=e=>{for(const i of e.children)i.key==="a:t"||i.key==="w:t"?t.push(i.text):n(i)};return n(d),t}const tt=/^\s*(?:figure|fig\.?|table|chart|图|表|圖)\s*[\d.\-–]+\s*[.::、—–-]?\s*/iu;function st(d,t,n,e){const i=d.files.get(t);if(i===void 0)return!1;let s;try{s=An(i).width}catch(o){if(o instanceof TypeError)return!1;throw o}return Math.abs(n-Math.min(s,e))<=1}function ot(d,t){const n=e=>{if(Array.isArray(e))for(const i of e)n(i);else if(e!==null&&typeof e=="object"){const i=e;if(typeof i.text=="string"&&i.styles!==void 0){const s=i.styles.comments;if(s!==void 0){const o=s.filter(a=>!t.has(a));o.length===0?delete i.styles.comments:i.styles.comments=o}return}for(const s of Object.values(e))n(s)}};n(d)}function it(d){if(d===void 0)return;const t=JSON.parse(d);if(t===null||typeof t!="object")return d;const n={...t};return delete n.first,JSON.stringify(n)}function rt(d){const t=[];for(const n of d){const e=t.at(-1);if(n.type==="toc"&&e?.type==="paragraph"&&e.look?.style==="TOC Heading"){t.pop();const i=e.content.map(s=>s.text).join("").trim();t.push(i===""||i==="Contents"||i==="目录"?n:{...n,title:i});continue}t.push(n)}return t}function dt(d,t=new Map){const n=s=>s?.type==="paragraph"&&s.look?.style==="Caption"&&s.content.length>0&&s.content.every(o=>o.note===void 0),e=s=>"content"in s&&Array.isArray(s.content)?s.content.map(o=>o.text).join("").replace(tt,"").trim():"",i=[];for(let s=0;s<d.length;s++){const o=d[s];if(o===void 0)continue;const a=d[s+1];if(n(o)&&a?.type==="table"&&a.caption===void 0){const c=e(o);if(c!==""){const l={...a,caption:c};t.set(o,l),i.push(l),s++;continue}}if(n(a)&&a!==void 0&&(o.type==="image"&&o.caption===void 0||o.type==="chart"&&o.title===void 0)){const c=e(a);if(c!==""){if(o.type==="image"){const l={...o,caption:c};t.set(a,l),i.push(l)}else{const l=[c,o.table?.[0]?.slice(1).join(", ")].filter(m=>m!==void 0&&m!=="").join(": "),g={...o,title:c};g.alt===l&&delete g.alt,t.set(a,g),i.push(g)}s++;continue}}i.push(o)}return i}function cn(d){const t=[],n=e=>{for(const i of e.children)if(i.key==="w:bookmarkStart"){const s=f(i,"w:name");s!==void 0&&s!==""&&t.push(s)}else n(i)};return n(d),t}function at(d,t){const n=e=>{if(Array.isArray(e))for(const i of e)n(i);else if(e!==null&&typeof e=="object"){const i=e;if(typeof i.text=="string"&&typeof i.styles=="object"){const s=i.href?.startsWith("#")===!0?t.get(i.href.slice(1)):void 0;if(s!==void 0&&(i.href=`#${s}`),i.field!==void 0){const[o="",a,...c]=i.field.split(" "),l=a===void 0?void 0:t.get(a);l!==void 0&&["REF","PAGEREF","NOTEREF"].includes(o.toUpperCase())&&(i.field=[o,l,...c].join(" "))}return}for(const s of Object.values(e))n(s)}};n(d)}function ct(d){const t=d.parent;if(t===void 0)return;const n=t.children.indexOf(d);for(const e of t.children.slice(n+1)){if(e.key!=="w:p")continue;const i=r(r(e,"w:pPr"),"w:sectPr");if(i!==void 0)return i}}const fn=d=>Math.min(9,Math.max(1,T(ae(r(d,"w:cols"),"w:num"))??1));function un(d,t){const n=[];let e=[];const i=new Set;for(const s of d){if(s.list===void 0){n.push(s.block),e=[];continue}const{numId:o,level:a}=s.list;let c=s.block;const l=`${o}:${String(a)}`;if(c.type==="numbered"&&!i.has(l)){i.add(l);const m=t.numbering.get(o)?.get(a)?.start??1;m!==1&&(c={...c,start:m})}for(;e.length>0&&(e.at(-1)?.level??0)>=a;)e.pop();const g=e.at(-1);if(g===void 0)n.push(c);else{const m=g.block;m.children=[...m.children??[],c]}e.push({level:a,block:c})}return n}function ft(d,t,n){const e=new Map,i=c=>{if(c.type!=="paragraph"||c.revision!==void 0)return;const l=c.look??{},g=$n(l,"paragraph"),m=ut(c.content);if(!(Object.keys(g).length===0&&Object.keys(m).length===0))return JSON.stringify([l.style??"",g,m])},s=c=>{for(const l of c){const g=i(l);g!==void 0&&e.set(g,[...e.get(g)??[],l]);const m="children"in l?l.children??[]:[];m.length>0&&s(m)}};s(d);let o=0;const a=new Map;for(const[c,l]of e){if(l.length<n)continue;const[g,m,x]=JSON.parse(c);let p;do p=`Style${String(++o)}`;while(t.styles.has(p)||[...t.styles.values()].some(k=>k.name===p));a.set(p,{...g===""?{}:{basedOn:g},...m,...x});for(const k of l){if(k.type!=="paragraph")continue;const y={...k.look?.color===void 0?{}:{color:k.look.color},style:p};k.look=y,k.content=k.content.map(D=>({...D,styles:lt(D.styles,x)}))}}t.made=a}function ut(d){const t=d.filter(o=>o.note===void 0&&o.text.trim()!==""),n=t[0];if(n===void 0)return{};const e=o=>({...o.font===void 0?{}:{font:o.font},...o.size===void 0?{}:{size:o.size},...o.bold===!0?{bold:!0}:{},...o.italic===!0?{italic:!0}:{},...o.color===void 0?{}:{color:o.color}}),i=e(n.styles),s=JSON.stringify(i);return t.every(o=>JSON.stringify(e(o.styles))===s)?i:{}}function lt(d,t){const n={...d};return t.font!==void 0&&delete n.font,t.size!==void 0&&delete n.size,t.bold===!0&&delete n.bold,t.italic===!0&&delete n.italic,t.color!==void 0&&delete n.color,n}function ln(d){const t={},n=new Map([...d.styles.values()].map(s=>[s.name,s])),e=s=>{if(Object.hasOwn(t,s))return;const o=n.get(s);if(o===void 0)return;const c=d.styles.get(o.basedOn??"")?.type===o.type?d.styleName(o.basedOn):void 0,l=d.styleName(o.next),g={...o.type==="character"?{type:"character"}:{},...c===void 0||c==="Default Paragraph Font"||c===s?{}:{basedOn:c},...l===void 0||l===s||o.type==="character"?{}:{next:l},...d.runProps(o.rPr),...o.type==="character"?{}:d.paragraphProps(o.pPr)};if(s===Ce){const p=d.defaults;Object.assign(g,{...d.runProps(r(r(p,"w:rPrDefault"),"w:rPr")),...d.runProps(o.rPr)},{...d.paragraphProps(r(r(p,"w:pPrDefault"),"w:pPr")),...d.paragraphProps(o.pPr)})}const m=/^Heading ([1-6])$/u.exec(s)?.[1],x=A(r(r(o.pPr,"w:numPr"),"w:numId"));if(m!==void 0&&x!==void 0){const p=d.numbering.get(x),k=p?.get(Number(m)-1);if(p!==void 0&&k!==void 0&&!k.bullet){const y=k.text.replace(/%([1-9])/gu,(D,_)=>{const H=Number(_),K=k.legal&&H!==Number(m)?"decimal":p.get(H-1)?.format??"decimal",V=sn.get(K);V===void 0&&d.lose(`a heading's number in Word's ${K}, read as a decimal`);const q=V??"decimal";return q==="decimal"?`{${_}}`:`{${_}:${q}}`});/\{[1-6]/u.test(y)&&Number(/\{([1-6])/u.exec(y)?.[1]??7)<=Number(m)&&(g.numbering=y.replace(/%%/gu,"%"))}}t[s]=g,c!==void 0&&c!==s&&e(c),l!==void 0&&l!==s&&e(l)};e(Ce);for(const s of[1,2,3,4,5,6])e(nn(s));e(Le);for(const s of d.used)e(s);for(const[s,o]of d.made)t[s]=o;for(const[s,o]of d.tableStyles)t[s]=o;const i=Object.fromEntries(Object.entries(t).filter(([s,o])=>Object.keys(o).length>0||!Tn.includes(s)));for(const s of Object.values(i))if(s.font!==void 0&&!Cn.includes(s.font)){const o=on.get(s.font.toLowerCase());o!==void 0&&(s.font=o)}return i}const pt=jn.lead.toUpperCase(),ht=7,mt={silver:"#C0C0C0",gray:"#808080",black:"#000000",white:"#FFFFFF",red:"#FF0000",maroon:"#800000",blue:"#0000FF",navy:"#000080",green:"#008000",yellow:"#FFFF00"};function wt(d){const t=d?.trim().split(/\s/u)[0]?.toLowerCase();if(!(t===void 0||t===""))return/^#[0-9a-f]{6}$/u.test(t)?t.toUpperCase():/^#[0-9a-f]{3}$/u.test(t)?t.replace(/[0-9a-f]/gu,n=>n+n).toUpperCase():mt[t]}function pn(d,t){return d==="center"?"center":d==="right"||d==="outside"?"right":d==="left"||d==="inside"?"left":t!==void 0&&t>36e5?"right":t!==void 0&&t>18e5?"center":"left"}function gt(d){const t=i=>new RegExp(`${i}\\s*:\\s*([^;]+)`,"u").exec(d??"")?.[1]?.trim(),n=t("margin-left"),e=n===void 0?void 0:n.endsWith("in")?Number.parseFloat(n)*72:Number.parseFloat(n);return pn(t("mso-position-horizontal"),e===void 0||Number.isNaN(e)?void 0:e*12700)}function yt(d,t,n){const e=d.xml(t);if(e===void 0)return;const i={left:[],center:[],right:[]},s={left:[],center:[],right:[]},o=p=>{const k=p.trim().split(/\s+/u)[0]?.toUpperCase()??"";return k==="PAGE"?"{page}":k==="NUMPAGES"||k==="SECTIONPAGES"?"{pages}":k==="TITLE"?"{title}":k==="STYLEREF"?"{section}":""},a=(p,k)=>{const y=p===void 0?void 0:d.picture(p,t);if(y===void 0)return;const D=k===void 0?void 0:Math.round(k/18e3)/2;return{picture:`./${y}`,...D===void 0||D<=0?{}:{height:D}}},c=(p,k)=>{if(p.key==="w:drawing"){const J=r(p,"wp:anchor");if(J!==void 0&&f(J,"behindDoc")==="1"){const ue=Y(p,"a:blip"),ke=ue===void 0?void 0:De(ue)??f(ue,"r:embed"),Ee=ke===void 0?void 0:d.picture(ke,t);if(Ee===void 0||d.watermark!==void 0){d.lose(`a picture behind the ${n}'s words, left out`);return}d.watermark={picture:`./${Ee}`,...ue!==void 0&&r(ue,"a:lum")!==void 0?{washout:!0}:{}};return}const L=r(J,"wp:positionH"),S=J===void 0?k:pn(r(L,"wp:align")?.text.trim(),T(r(L,"wp:posOffset")?.text.trim())),$=Y(p,"w:txbxContent");if($!==void 0){m($.children,S);return}const oe=Y(p,"a:blip"),be=Y(p,"wp:extent"),we=a(oe===void 0?void 0:De(oe)??f(oe,"r:embed"),T(be===void 0?void 0:f(be,"cy")));we!==void 0?s[S].push(we):oe===void 0&&d.lose(`a shape in the ${n}, left out`);return}const y=p.children.find(J=>J.key==="v:shape"),D=y===void 0?void 0:r(y,"v:textpath");if(D!==void 0||Y(p,"v:textpath")!==void 0){const J=(D===void 0?void 0:f(D,"string"))?.trim()??"";if(J==="")return;const L=y===void 0?"":f(y,"style")??"",S=wt(y===void 0?void 0:f(y,"fillcolor")),$=/rotation\s*:\s*(\d+)/u.exec(L)?.[1];d.watermark??={text:J,...S===void 0||S===Nn?{}:{color:S},...$===void 0||$==="0"?{layout:"horizontal"}:{}};return}const _=p.children.find(J=>J.key.startsWith("v:")),H=_===void 0?void 0:f(_,"style"),K=/position\s*:\s*absolute/u.test(H??"")?gt(H):k,V=Y(p,"w:txbxContent");if(V!==void 0){m(V.children,K);return}const q=Y(p,"v:imagedata");if(q===void 0)return;if(/z-index\s*:\s*-/u.test(H??"")){const J=f(q,"r:id"),L=J===void 0?void 0:d.picture(J,t);if(L===void 0||d.watermark!==void 0){d.lose(`a picture behind the ${n}'s words, left out`);return}d.watermark={picture:`./${L}`,...f(q,"gain")!==void 0||f(q,"blacklevel")!==void 0?{washout:!0}:{}};return}const pe=/(?:^|;)\s*height\s*:\s*([\d.]+)pt/u.exec(H??"")?.[1],fe=a(f(q,"r:id"),pe===void 0?void 0:Number(pe)*12700);fe!==void 0&&s[K].push(fe)},l=(p,k)=>{const y=[""],D=[];let _,H=!0;const K=L=>{y[y.length-1]=`${y.at(-1)??""}${L}`},V=L=>{for(const S of L){if(S.key==="w:fldSimple"){K(o(f(S,"w:instr")??""));continue}if(S.key==="w:r"){for(const $ of S.children)if($.key==="w:fldChar"){const oe=f($,"w:fldCharType");oe==="begin"?_="":oe==="separate"?(K(o(_??"")),H=!1):oe==="end"&&(H&&K(o(_??"")),_=void 0,H=!0)}else $.key==="w:instrText"&&_!==void 0?_+=$.text:$.key==="w:t"&&H&&_===void 0?K($.text):$.key==="w:tab"?y.push(""):($.key==="w:drawing"||$.key==="w:pict")&&D.push({el:$,piece:y.length-1});continue}S.key!=="w:pPr"&&V(S.children)}};V(p.children);const q=A(r(r(p,"w:pPr"),"w:jc")),pe=k??(q==="center"?"center":q==="right"||q==="end"?"right":"left"),fe=L=>k!==void 0||y.length===1?pe:y.length===2?L===0?"left":"right":L===0?"left":L===1?"center":"right",J={left:[],center:[],right:[]};y.forEach((L,S)=>{const $=L.trim();$!==""&&J[fe(S)].push($)});for(const L of["left","center","right"])J[L].length>0&&i[L].push(J[L].join(" "));for(const{el:L,piece:S}of D)c(L,fe(S))},g=p=>{for(const k of Z(p,"w:tr")){const y=Z(k,"w:tc");y.length>3&&d.lose(`a ${n}'s table of more than three columns, read as three`),y.forEach((D,_)=>{const H=y.length===1?"center":y.length===2?_===0?"left":"right":_===0?"left":_===y.length-1?"right":"center";m(D.children,y.length===1?void 0:H)})}},m=(p,k)=>{for(const y of p)y.key==="w:p"?l(y,k):y.key==="w:tbl"?g(y):y.key==="w:sdt"&&m(r(y,"w:sdtContent")?.children??[],k)};m(e.children,void 0);const x={};for(const p of["left","center","right"]){const[k,...y]=s[p];k!==void 0?(x[p]=k,y.length>0&&d.lose(`a ${n}'s pictures after its first at one place, left out`),i[p].length>0&&d.lose(`a ${n}'s words beside its picture at one place, left out`)):i[p].length>0&&(x[p]=i[p].join(`
12
+ `))}return Object.keys(x).length===0?void 0:x}function bt(d,t){const n=d.partOf("settings"),e=Pe(r(n===void 0?void 0:d.xml(n),"w:evenAndOddHeaders"))===!0,i=new Map,s=(c,l)=>(i.has(c)||i.set(c,yt(d,c,l)),i.get(c)),o=new Map,a={header:new Map,footer:new Map};for(const c of t){const l=Pe(r(c,"w:titlePg"))===!0,g={};for(const[m,x]of[["w:headerReference","header"],["w:footerReference","footer"]]){for(const V of Z(c,m)){const q=d.pkg.rel(d.doc,f(V,"r:id"))?.target;q!==void 0&&a[x].set(f(V,"w:type")??"default",q)}const p=V=>{const q=a[x].get(V);return q===void 0?void 0:s(q,x)},k=p("default"),y=V=>V!==void 0&&JSON.stringify(V)===JSON.stringify(k),D=l?p("first"):void 0,_=!l||y(D)?void 0:D??!1,H=e?p("even"):void 0,K=!e||y(H)?void 0:H??!1;g[x]=k===void 0&&(_===void 0||_===!1)&&(K===void 0||K===!1)?!1:{...k??{},..._===void 0?{}:{first:_},...K===void 0?{}:{even:K}}}o.set(c,g)}return o}function hn(d){if(d===void 0)return{};const t={},n=r(d,"w:pgSz"),e=T(n===void 0?void 0:f(n,"w:w")),i=T(n===void 0?void 0:f(n,"w:h"));if(e!==void 0&&i!==void 0){const o=[e/ze,i/ze].sort((c,l)=>c-l),a=Object.entries(En).find(([,c])=>Math.abs(c[0]-o[0])<1.5&&Math.abs(c[1]-o[1])<1.5)?.[0];a===void 0?t.paper=[Math.round(o[0]*10)/10,Math.round(o[1]*10)/10]:a!=="letter"&&(t.paper=a),n!==void 0&&f(n,"w:orient")==="landscape"&&(t.orientation="landscape")}const s=r(d,"w:pgMar");if(s!==void 0){const o=c=>Math.round(Math.abs(T(f(s,c))??1440)/ze*10)/10,a=[o("w:top"),o("w:right"),o("w:bottom"),o("w:left")];t.margins=a.every(c=>c===a[0])?a[0]:a[0]===a[2]&&a[1]===a[3]?[a[0],a[1]]:[...a]}return t}
@@ -1,5 +1,6 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{chartBook as Qe,embeddedChartXml as Je}from"@allyhub/chart";import{chartFrame as et,chartWords as tt,docChart as nt}from"./chart.js";import{BACKGROUNDS as Ie,TEXT_COLORS as Se,hex as ee}from"./color.js";import{columnWidths as it}from"./columns.js";import{COMPONENT_WIDTH as rt,componentName as ot}from"./component.js";import{blockId as $e,captionNumbers as st,contentsTitle as at,numberedCaption as Oe,writtenInChinese as dt,withoutTitle as ct}from"./captions.js";import{sourceList as lt,withSources as ht}from"./cite.js";import{HEADING_RULE_SPACE as ut,cardKept as pt,columnsKept as ft,docParts as gt,headingAnchors as mt,pageAccent as wt,trendSvg as yt}from"./html.js";import{effectiveLook as Fe,LIST_STEP as At,lineHeightPt as Tt,resolvePage as Et,sizePt as He}from"./page.js";import{splitTitle as Rt}from"./title.js";import{markdownOf as St}from"./markdown.js";import{charsAcross as Xe,columnShares as zt,emptyHead as Lt,numberColumns as Mt,withTableData as Ct}from"./table.js";import{DRAWN_CODE as ve}from"./math.js";import{PAPER as te,TONE_COLORS as Ue,tagColors as Nt}from"./paper.js";import{COVER_ASPECT as bt,everyBlock as ze,firstNoteMarks as xt,noteNumbers as Dt,statTone as It}from"./model.js";const ue=15,Ot=1440/25.4,Y=n=>Math.round(n*Ot),Ge="ListParagraph",Be="bullets",vt=1.8,pe=At*20,We={sans:{latin:"Calibri"},serif:{latin:"Cambria"},mono:{latin:"Courier New"},times:{latin:"Times New Roman"},song:{latin:"Times New Roman",eastAsia:"宋体"},hei:{latin:"Arial",eastAsia:"黑体"},fangsong:{latin:"Times New Roman",eastAsia:"仿宋"},kai:{latin:"Times New Roman",eastAsia:"楷体"},xiaobiaosong:{latin:"Times New Roman",eastAsia:"方正小标宋简体"}},Pe="Courier New",W=n=>n.slice(1).toUpperCase(),le=W(te.ink),fe=W(te.lead),Pt=Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=","base64"),Le=W(te.rule),ge=W(te.ruleStrong),Me=W(te.ruleMid),Ce=W(te.stone),_t=W(te.stone3),de=W(te.leadSoft),je="ALLYHUB-CHART-";function $t(n){return/[\u3040-\u30ff]/u.test(n)?"Yu Gothic":/[\uac00-\ud7af]/u.test(n)?"Malgun Gothic":"Microsoft YaHei"}const Ft=/^(https?:|mailto:)/i,Ne=n=>({indent:0,level:0,room:n,frame:rt}),Ke=n=>({...n,indent:n.indent+pe,level:Math.min(n.level+1,8)}),Ht=400,Xt=n=>n.type==="bullet"||n.type==="numbered"||n.type==="check";function Ut(n,u,w){const c=w/ue,S=Math.floor(Math.min(u??n.width,c));return{width:S,height:Math.round(S*n.height/n.width)}}const qe="TOCHeading";function Gt(n,u,w,c,S,z,r){const{AlignmentType:m,BorderStyle:y,ExternalHyperlink:l,ImageRun:x,Paragraph:h,ShadingType:Z,Table:F,TableCell:_,TableLayoutType:H,TableRow:G,TextRun:M,WidthType:p}=n,N=e=>{const t=e.filter(i=>!(i instanceof n.TableOfContents));return t.at(-1)instanceof h?t:[...t,Q(0)]},X={ascii:Pe,hAnsi:Pe,cs:Pe,eastAsia:w},$=new Set([1]);let ne=0;const k=[],B=e=>({type:Z.CLEAR,color:"auto",fill:e}),he=(e,t,i=4)=>({style:e,color:t,size:i,space:4}),o=r.page.spacing,E=e=>Math.round(e*20),Q=e=>new h({spacing:{before:0,after:E(e),line:14,lineRule:n.LineRuleType.EXACT}}),J=()=>o.after>0?[Q(o.after)]:[],j=e=>e==="center"?m.CENTER:e==="right"?m.RIGHT:e==="justify"?m.JUSTIFIED:void 0,ie=(e,t,i,f={})=>{if(t.tag!==void 0){const s=Nt(t.tag),R={...f,color:W(s.fg),size:Math.round((i.size??r.page.size*2)*.85),shading:B(W(s.bg)),...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{}};return[new M({...R,text:` ${e.replace(/\n/gu," ")} `})]}const g=ee(t.color,Se)??i.color,a=ee(t.background,Ie),d={...f,...t.bold||i.bold?{bold:!0}:{},...t.italic?{italics:!0}:{},...t.underline?{underline:{}}:{},...t.strike?{strike:!0}:{},...g===void 0?{}:{color:g},...i.size===void 0?{}:{size:i.size},...t.code?{font:X,shading:B(a??Ce)}:a===void 0?{}:{shading:B(a)}};return e.split(`
3
- `).map((s,R)=>new M({...d,text:s,...R>0?{break:1}:{}}))},U=(e,t={})=>e.flatMap(i=>i.note!==void 0?S.has(i.note.toLowerCase())?z.has(i)?[new n.FootnoteReferenceRun(S.get(i.note.toLowerCase())??1)]:[new M({text:String(S.get(i.note.toLowerCase())??1),style:"FootnoteReference"})]:[]:i.text===""&&i.href?.startsWith("#")===!0?xe(i.href.slice(1),i.styles,t):i.href!==void 0&&Ft.test(i.href)?[new l({link:i.href,children:ie(i.text,i.styles,t,{style:"Hyperlink"})})]:ie(i.text,i.styles,t)),xe=(e,t,i)=>{const f=decodeURIComponent(e),g=r.refs.get(f)??"",a=r.bookmarks.get(f);return g===""?[]:a===void 0?ie(g,t,i):[new n.InternalHyperlink({anchor:a,children:ie(g,t,i,{style:"Hyperlink"})})]},T=(e,t)=>{const i=e===void 0?void 0:r.bookmarks.get(e);return i===void 0?t:[new n.Bookmark({id:i,children:t})]},D=e=>{const t=j(e?.align),i=ee(e?.background,Ie);return{...t===void 0?{}:{alignment:t},...i===void 0?{}:{shading:B(i)}}},L=e=>e.indent===0?{}:{indent:{left:e.indent}},re=e=>{const t={style:y.SINGLE,color:e,size:4};return{top:t,bottom:t,left:t,right:t}},me=(e,t)=>{const i=ee(e.look?.background,Ie)??Ce,f=ee(e.look?.color,Se),g=t.room-t.indent,a=e.icon===void 0?0:E(r.page.size*vt)+E(o.box.side),d=g-a,s=(R,C)=>({top:E(o.box.top),bottom:E(Math.max(o.box.top-o.after,0)),left:R,right:C,marginUnitType:p.DXA});return new F({layout:H.FIXED,width:{size:g,type:p.DXA},columnWidths:a===0?[d]:[a,d],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:[...e.icon===void 0?[]:[new _({width:{size:a,type:p.DXA},shading:B(i),borders:re(i),margins:s(E(o.box.side),0),children:[new h({children:[new M({text:e.icon})]})]})],new _({width:{size:d,type:p.DXA},shading:B(i),borders:re(i),margins:s(a===0?E(o.box.side):0,E(o.box.side)),children:[new h({children:U(e.content,{color:f})}),...N(V(e.children??[],Ne(d-E(o.box.side))))]})]})]})},we=(e,t)=>{const i=t.room-t.indent,f=E(o.card.side),g=[...e.title===void 0?[]:[new h({spacing:{after:e.subtitle===void 0?E(o.after):0},children:U([{text:e.title,styles:{bold:!0}}])})],...e.subtitle===void 0?[]:[new h({spacing:{after:E(o.after)},children:[new M({text:e.subtitle,color:fe,size:o.small*2})]})]];return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:[i],...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:pt(e,r.page),children:[new _({width:{size:i,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(Math.max(o.card.top-o.after,0)),left:f,right:f,marginUnitType:p.DXA},children:N([...g,...V(e.children??[],Ne(i-2*f))])})]})]})},oe=(e,t)=>{const i=t.room-t.indent,f=E(o.gap),g=e.stats.length,a=Math.floor((i-f*(g-1))/g),d=e.stats.flatMap((b,P)=>P===0?[a]:[f,a]),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s},C=E(o.card.side),A=o.small*2,v=e.stats.flatMap((b,P)=>{const q=It(b),ce=[...b.delta===void 0?[]:[new M({text:b.delta,color:W(Ue[q]),size:A})],...b.note===void 0?[]:[new M({text:`${b.delta===void 0?"":" "}${b.note}`,color:fe,size:A})]],Ae=a-2*C,Te=b.trend===void 0?[]:[new h({spacing:{before:60,after:0,line:240},children:[new x({type:"svg",data:Buffer.from(yt(b.trend,Ue[q]).replace("<svg ",`<svg xmlns="http://www.w3.org/2000/svg" width="${String(Math.round(Ae/15))}" height="24" `)),fallback:{type:"png",data:Pt},transformation:{width:Math.round(Ae/15),height:24}})]})],I=new _({width:{size:a,type:p.DXA},borders:re(Le),margins:{top:E(o.card.top),bottom:E(o.card.top),left:C,right:C,marginUnitType:p.DXA},children:[new h({spacing:{after:0},children:[new M({text:b.label,color:fe,size:A})]}),new h({spacing:{after:0,line:240,lineRule:n.LineRuleType.AUTO},children:U([{text:b.value,styles:{bold:!0}}],{size:o.figure*2})}),...ce.length===0?[]:[new h({spacing:{after:0},children:ce})],...Te]}),O=new _({width:{size:f,type:p.DXA},borders:R,children:[new h({children:[]})]});return P===0?[I]:[O,I]});return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:d,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:!0,children:v})]})},se=(e,t)=>{const i=t.room-t.indent,f=Math.max(1,...e.rows.map(I=>I.length)),g=Array.from({length:f},(I,O)=>e.widths?.[O]?(e.widths[O]??0)*ue:void 0),a=g.reduce((I,O)=>I+(O??0),0),d=zt(e,{across:Xe(Math.max(i-a,0)/ue,o.small),margins:Xe(2*o.cell.side*96/72,o.small)}),s=g.reduce((I,O,_e)=>I+(O===void 0?d[_e]??1:0),0)||1,R=Math.max(i-a,0),C=g.map((I,O)=>I??R*(d[O]??1)/s),A=C.reduce((I,O)=>I+O,0)||1,v=Math.min(1,i/A),b=C.map(I=>Math.round(I*v)),P=Lt(e),q=(e.head===void 0||e.head==="both")&&!P,ce=e.head==="column"||e.head==="both",Ae=Mt(e),Te=P?e.rows.slice(1):e.rows;return new F({layout:H.FIXED,width:{size:b.reduce((I,O)=>I+O,0),type:p.DXA},columnWidths:b,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:Te.map((I,O)=>new G({tableHeader:q&&O===0,cantSplit:!0,children:Array.from({length:f},(_e,Ee)=>{const Re=q&&O===0,ke=ce&&Ee===0&&!Re;return new _({width:{size:b[Ee]??0,type:p.DXA},...Re?{shading:B(_t)}:{},borders:{top:O===0?{style:y.SINGLE,size:8,color:ge}:{style:y.NONE,size:0,color:"auto"},left:{style:y.NONE,size:0,color:"auto"},right:{style:y.NONE,size:0,color:"auto"},bottom:O===Te.length-1?{style:y.SINGLE,size:8,color:ge}:Re?{style:y.SINGLE,size:6,color:ge}:{style:y.SINGLE,size:4,color:Me}},margins:{top:E(o.cell.top),bottom:E(o.cell.top),left:E(o.cell.side),right:E(o.cell.side),marginUnitType:p.DXA},children:[new h({spacing:{after:0},...Ae.has(Ee)?{alignment:m.RIGHT}:{},children:U(I[Ee]??[],{bold:ke||Re,size:o.small*2})})]})})}))})},ae=(e,t,i,f,g,a)=>{const d=j(e.align),s={...L(t),...d===void 0?{}:{alignment:d}},R=i===void 0?void 0:e.caption,C=R!==void 0,A=[new h({...s,keepNext:C,...i?{spacing:{line:240,lineRule:n.LineRuleType.AUTO,...C?{after:E(o.caption)}:{}}}:{},children:i?[new x({type:i.type,data:i.data,transformation:Ut(i,e.width,t.room-t.indent),altText:{name:e.alt??"",title:e.caption??e.alt??"",description:e.alt??""}})]:[new M({text:f,color:de})]})];return R!==void 0&&A.push(new h({...s,style:"Caption",children:T(a,[new M({text:Oe(R,g)})])})),A},ye=(e,t)=>{const i=t.room-t.indent,f=e.columns.map(A=>A.width??1),g=f.reduce((A,v)=>A+v,0)||1,a=f.map(A=>Math.round(i*A/g)),d=it(e,t.frame),s={style:y.NONE,size:0,color:"auto"},R={top:s,bottom:s,left:s,right:s,insideHorizontal:s,insideVertical:s},C=Ht/2;return new F({layout:H.FIXED,width:{size:i,type:p.DXA},columnWidths:a,borders:R,...t.indent===0?{}:{indent:{size:t.indent,type:p.DXA}},rows:[new G({cantSplit:ft(e,r.page),children:e.columns.map((A,v)=>{const b=a[v]??0,P=v===0?0:C,q=v===e.columns.length-1?0:C,ce=N(V(A.blocks,{indent:0,level:0,room:b-P-q,frame:d[v]??t.frame}));return new _({width:{size:b,type:p.DXA},borders:R,margins:{top:0,bottom:0,left:P,right:q,marginUnitType:p.DXA},children:ce})})})]})},K=(e,t,i)=>{const f=ee(e.look?.color,Se),g=V(e.children??[],Ke(t)),a=D(e.look),d=Ge;return e.type==="check"?[new h({...a,...L(t),style:d,children:[new M({text:e.checked?"☑ ":"☐ "}),...U(e.content,{color:f})]}),...g]:[new h({...a,style:d,numbering:e.type==="bullet"?{reference:Be,level:t.level}:{reference:`start-${String(i.start)}`,level:t.level,instance:i.id},children:U(e.content,{color:f})}),...g]},De=(e,t)=>{const i="look"in e?e.look:void 0,f=ee(i?.color,Se),g=D(i),a=()=>"children"in e?V(e.children??[],Ke(t)):[];switch(e.type){case"paragraph":case"toggle":return[new h({...r.sets.align&&e.look?.align===void 0?{alignment:m.JUSTIFIED}:{},...g,...r.sets.indent&&e.type==="paragraph"?{indent:{left:t.indent,firstLine:Math.round(r.page.textIndent*r.page.size*20)}}:L(t),children:U(e.content,{color:f})}),...a()];case"heading":return[new h({...g,...L(t),...e===r.title?{heading:n.HeadingLevel.TITLE}:{heading:n.HeadingLevel[`HEADING_${String(e.level)}`]},children:T(r.anchors.get(e),U(e.content,{color:f}))}),...a()];case"quote":return[new h({...g,indent:{left:t.indent+E(o.quote)},border:{left:{style:y.SINGLE,color:c??ge,size:c?12:6,space:Math.floor(o.quote-(c?1.5:.75))}},children:U(e.content,{color:f??fe})}),...a()];case"callout":return[me(e,t),...J()];case"card":return[we(e,t),...J()];case"stats":return[oe(e,t),...J()];case"code":{if(e.language===ve.math||e.language===ve.mermaid){const R=u.drawn?.(e);if(R)return ae({...e.language===ve.math?{}:{align:"center"}},t,R,"")}const d=R=>({style:y.SINGLE,color:Ce,size:4,space:R}),s=E(o.box.side+.5);return[new h({indent:{left:t.indent+s,right:s},shading:B(Ce),border:{top:d(o.box.top),bottom:d(o.box.top),left:d(o.box.side),right:d(o.box.side)},keepLines:!0,children:e.code.split(`
4
- `).map((R,C)=>new M({text:R,font:X,size:o.small*2,...C>0?{break:1}:{}}))})]}case"columns":return[ye(e,t)];case"chart":{const d=r.numbers.get(e),s=d===void 0?void 0:e.title,{chart:R,problems:C}=nt(s===void 0?e:ct(e),u),A=he(y.DASHED,Me);if(!R)return[new h({...L(t),alignment:m.CENTER,border:{top:A,bottom:A,left:A,right:A},children:[new M({text:[e.title??"Chart",...C].join(": "),color:de})]})];const v=et(e,t.frame),b=(t.room-t.indent)/ue,P=Math.min(1,b/v.width);return k.push({chart:R,width:Math.round(v.width*P),height:Math.round(v.height*P),words:tt(e,R)}),[new h({...L(t),alignment:m.CENTER,keepNext:s!==void 0,spacing:{line:240,lineRule:n.LineRuleType.AUTO},children:[new M({text:`${je}${String(k.length)}`})]}),...s===void 0?[]:[new h({...L(t),alignment:m.CENTER,style:"Caption",children:T(e.id,[new M({text:Oe(s,d)})])})]]}case"image":return ae(e,t,u.picture?.(e.src),e.alt??e.caption??e.src,r.numbers.get(e),e.id);case"component":{const d=u.component?.(e);if(d)return ae(e,t,d,"",r.numbers.get(e),e.id);const s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:ot(e),color:de})]})]}case"table":return[...e.caption===void 0?[]:[new h({...L(t),style:"Caption",keepNext:!0,spacing:{after:E(o.caption)},children:T(e.id,[new M({text:Oe(e.caption,r.numbers.get(e))})])})],se(e,t),...J()];case"pagebreak":return[new h({spacing:{before:0,after:0,line:20,lineRule:n.LineRuleType.EXACT},children:[new n.PageBreak]})];case"bibliography":{const{page:d}=r,s=d.textIndent>0?Math.round(d.textIndent*d.size*20):480;return r.sources.map(R=>new h({...L(t),alignment:m.LEFT,indent:{left:t.indent+s,hanging:s},spacing:{after:E(o.after)},children:R.pieces.map(C=>{const A=C.italic?{italics:!0}:{};return new M({text:C.text,...A})})}))}case"toc":{const d=e.levels??3,s=r.headings.filter(A=>A.level<=d).map(A=>{const v=r.anchors.get(A)??"",b=u.headingPage?.(v),P=r.bookmarks.get(v);return{title:A.content.map(q=>q.text).join(""),level:A.level,...b===void 0?{}:{page:b},...P===void 0?{}:{href:P}}}),R=Math.min(...s.map(A=>A.level)),C=at(e,r.chinese);return[...C===""?[]:[new h({style:qe,text:C})],new n.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(d)}`,beginDirty:!1,cachedEntries:s.map(A=>({...A,level:A.level-R+1}))})]}case"note":return[];case"divider":return[new h({...L(t),spacing:{before:E(o.divider),after:E(o.divider),line:20,lineRule:n.LineRuleType.EXACT},border:{bottom:{style:y.SINGLE,color:Le,size:4,space:0}}})];case"embed":{const d=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],s=he(y.DASHED,Me);return[new h({...L(t),alignment:m.CENTER,border:{top:s,bottom:s,left:s,right:s},children:[new M({text:d??"",color:de})]})]}case"source":return[];case"bullet":case"numbered":case"check":return[]}};function V(e,t){const i=[];let f,g;for(const a of e){if(!Xt(a)){f=void 0,g=void 0,i.push(...De(a,t));continue}if(f===void 0||g===void 0||g.type==="numbered"!=(a.type==="numbered")){const d=a.type==="numbered"?a.start??1:1;$.add(d),f={id:++ne,start:d}}g=a,i.push(...K(a,t,f))}return i.flatMap((a,d)=>a instanceof F&&i[d+1]instanceof F?[a,Q(0)]:[a])}return{charts:k,body:(e,t)=>V(e,Ne(t)),footnotes:e=>Object.fromEntries([...ze(e)].flatMap(t=>{if(t.type!=="note")return[];const i=S.get(t.label.toLowerCase());if(i===void 0)return[];const f=V(t.children??[],Ne(Y(r.page.width)-Y(r.page.margins.left+r.page.margins.right))).filter(g=>g instanceof h);return[[String(i),{children:[new h({spacing:{after:40},children:U(t.content,{size:18,color:fe})}),...f]}]]})),numbering:()=>[{reference:Be,levels:Array.from({length:9},(e,t)=>({level:t,format:n.LevelFormat.BULLET,text:["•","◦","▪"][t%3]??"•",alignment:m.LEFT,style:{paragraph:{indent:{left:(t+1)*pe,hanging:pe}}}}))},...[...$].sort((e,t)=>e-t).map(e=>({reference:`start-${String(e)}`,levels:Array.from({length:9},(t,i)=>({level:i,format:[n.LevelFormat.DECIMAL,n.LevelFormat.LOWER_LETTER,n.LevelFormat.LOWER_ROMAN][i%3]??n.LevelFormat.DECIMAL,text:`%${String(i+1)}.`,alignment:m.LEFT,...i===0?{start:e}:{},style:{paragraph:{indent:{left:(i+1)*pe,hanging:pe}}}}))}))]}}const Bt="1980-01-01T00:00:00Z",Ye=9525,Ve="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Wt=n=>n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function jt(n,u,w,c,S){return n.forEach((z,r)=>{const m=String(r+1),y=`rIdChart${m}`,l=`Microsoft_Excel_Worksheet${m}.xlsx`;S(`word/charts/chart${m}.xml`,Je(z.chart,{width:z.width*.75,height:z.height*.75},"rId1",{frameless:!0})),S(`word/charts/_rels/chart${m}.xml.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${Ve}/package" Target="../embeddings/${l}"/></Relationships>`),S(`word/embeddings/${l}`,Qe(z.chart)),w=w.replace("</Relationships>",`<Relationship Id="${y}" Type="${Ve}/chart" Target="charts/chart${m}.xml"/></Relationships>`),c=c.replace("</Types>",`<Override ContentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml" PartName="/word/charts/chart${m}.xml"/></Types>`);const x=String(z.width*Ye),h=String(z.height*Ye),Z=`<w:r><w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${x}" cy="${h}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="0" name="Chart ${m}" descr="${Wt(z.words)}"/><wp:cNvGraphicFramePr/><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" r:id="${y}"/></a:graphicData></a:graphic></wp:inline></w:drawing></w:r>`;u=u.replace(new RegExp(`<w:r>(?:(?!<w:r>).)*?<w:t[^>]*>${je}${m}</w:t></w:r>`,"su"),Z)}),n.length>0&&!c.includes('Extension="xlsx"')&&(c=c.replace("</Types>",'<Default ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Extension="xlsx"/></Types>')),{document:u,rels:w,types:c}}function Kt(n,u,w){const c=u.unzipSync(n),S=p=>{const N=c[p];return N&&new TextDecoder().decode(N)},z=(p,N)=>{c[p]=typeof N=="string"?new TextEncoder().encode(N):N},r="word/document.xml",m="word/_rels/document.xml.rels",y="[Content_Types].xml",l=jt(w,S(r)??"",S(m)??"",S(y)??"",z);z(y,l.types);let x=l.document,h=l.rels;[...new Set([...x.matchAll(/w:hyperlink [^>]*r:id="([^"]+)"/g)].map(p=>p[1]??""))].forEach((p,N)=>{const X=`rIdLink${String(N+1)}`;x=x.split(`"${p}"`).join(`"${X}"`),h=h.split(`"${p}"`).join(`"${X}"`)});let F=0;x=x.replace(/<wp:docPr id="\d+"/g,()=>`<wp:docPr id="${String(++F)}"`);const _=new Map;x=x.replace(/<w:bookmarkStart w:name="([^"]*)" w:id="(\d+)"/g,(p,N,X)=>{const $=String(_.size+1);return _.set(X,$),`<w:bookmarkStart w:name="${N}" w:id="${$}"`}),x=x.replace(/<w:bookmarkEnd w:id="(\d+)"/g,(p,N)=>{const X=_.get(N);return X===void 0?p:`<w:bookmarkEnd w:id="${X}"`}),z(r,x),z(m,h);const H="docProps/core.xml",G=S(H);G!==void 0&&z(H,G.replace(/(<dcterms:(?:created|modified)[^>]*>)[^<]*/g,`$1${Bt}`));const M=Object.fromEntries(Object.entries(c).sort(([p],[N])=>p<N?-1:1));return u.zipSync(M,{mtime:new Date(1980,0,1)})}const be=(n,u)=>{const w=We[n];return{ascii:w.latin,hAnsi:w.latin,cs:w.latin,eastAsia:w.eastAsia??u}};function qt(n,u,w){const c={left:[],center:[],right:[]};u.left!==void 0&&c.left.push(u.left),u.center!==void 0&&c.center.push(u.center),u.right!==void 0&&c.right.push(u.right),u.outside!==void 0&&c[w.odd?"right":"left"].push(u.outside),u.inside!==void 0&&c[w.odd?"left":"right"].push(u.inside);const S={size:Math.round(w.size*2),color:w.color,font:be(w.face,w.eastAsia)},z=r=>r.split(/(\{title\}|\{section\}|\{page\}|\{pages\})/u).filter(m=>m!=="").map(m=>m==="{page}"?new n.TextRun({...S,children:[n.PageNumber.CURRENT]}):m==="{pages}"?new n.TextRun({...S,children:[n.PageNumber.TOTAL_PAGES]}):m==="{section}"?new n.SimpleField(`STYLEREF "heading ${String(w.section)}"`,""):new n.TextRun({...S,text:m==="{title}"?w.title:m}));return new n.Paragraph({style:w.style,tabStops:[{type:n.TabStopType.CENTER,position:Math.round(w.width/2)},{type:n.TabStopType.RIGHT,position:w.width}],children:[...z(c.left.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(c.center.join(" ")),new n.TextRun({...S,children:[new n.Tab]}),...z(c.right.join(" "))]})}const Ze=(n,u,w,c)=>({run:{...u?.font===void 0?{}:{font:be(n.font,w)},...u?.size===void 0?{}:{size:Math.round(n.size*2)},...u?.weight===void 0?{}:{bold:n.weight==="bold"},...u?.italic===void 0?{}:{italics:n.italic}},paragraph:u?.align===void 0?{}:{alignment:n.align==="center"?c.AlignmentType.CENTER:n.align==="right"?c.AlignmentType.RIGHT:c.AlignmentType.LEFT}});function Yt(n){const u=new Map,w=new Set;return n.forEach((c,S)=>{const z=c.replace(/[^A-Za-z0-9_]/gu,"_").replace(/^[^A-Za-z]+/u,"");let r=`b_${z}`.slice(0,32);(w.has(r)||z==="")&&(r=`b_${String(S)}_${z}`.slice(0,40)),w.add(r),u.set(c,r)}),u}export async function docxOf(n,u,w,c={}){const S=c.page??{},z=Fe(S).citationStyle??"apa",r=ht(Ct(w,c),c.sources??[],z,"block"),m=lt(w,c.sources??[],z),y=Fe(S),l=Et(S),x=We[l.font].eastAsia??$t(St(r)),h=be(l.font,x),Z=ee(wt(c.page),{}),F=mt(r),_=st(r,S),H=new Map;for(const T of ze(r)){const D=$e(T),L=_.get(T);D!==void 0&&L!==void 0&&H.set(D,L.label)}for(const[T,D]of F)T.type==="heading"&&H.set(D,T.content.map(L=>L.text).join(""));const{title:G}=Rt(r),M=[...ze(r)].filter(T=>T.type==="heading"&&T!==G),p=Yt([...F.values(),...[...ze(r)].flatMap(T=>{const D=$e(T);return D===void 0?[]:[D]})]),N=Gt(n,c,x,Z,Dt(r),xt(r),{page:l,sets:{indent:y.textIndent!==void 0&&y.textIndent>0,align:y.textAlign==="justify"},numbers:_,refs:H,bookmarks:p,anchors:F,title:G,headings:M,chinese:dt(r),sources:m}),X=gt(r),$={width:Y(l.width),height:Y(l.height)},ne={top:Y(l.margins.top),bottom:Y(l.margins.bottom),left:Y(l.margins.left),right:Y(l.margins.right)},k=c.cover,B=[l.header,l.footer].some(T=>T!==void 0&&(T.outside!==void 0||T.inside!==void 0)),he=X.map((T,D)=>{const L=T.landscape?$.height:$.width,re=L-ne.left-ne.right,me=N.body(T.blocks,re);if(D===0&&k){const K=Math.round(L/ue);me.unshift(new n.Paragraph({spacing:{before:0,after:0},children:[new n.ImageRun({type:k.type,data:k.data,transformation:{width:K,height:Math.round(K*bt)},floating:{horizontalPosition:{relative:n.HorizontalPositionRelativeFrom.PAGE,offset:0},verticalPosition:{relative:n.VerticalPositionRelativeFrom.PAGE,offset:0},allowOverlap:!1,margins:{bottom:324e3},wrap:{type:n.TextWrappingType.TOP_AND_BOTTOM}},altText:{name:"Cover",title:"Cover",description:""}})]}))}const we=(K,De,V)=>{if(K===void 0)return;const e=t=>qt(n,K,{style:V,odd:t,width:re,title:c.title??"",section:Math.min(...M.map(i=>i.level),6),face:K.font??l.font,eastAsia:x,size:K.size===void 0?Math.max(7.5,l.size*.75):He(K.size),color:De?de:le});return{default:e(!0),...B?{even:e(!1)}:{}}},oe=we(l.header,y.header===void 0,"Header"),se=we(l.footer,y.footer===void 0,"Footer"),ae=D===0&&k!==void 0&&oe!==void 0,ye=y.grid===void 0?void 0:{type:n.DocumentGridType.LINES_AND_CHARS,linePitch:Math.round(Tt(l)*20),charSpace:Math.round(l.textWidth/25.4*72/y.grid.chars-l.size)*4096};return{properties:{page:{size:{width:Math.min($.width,$.height),height:Math.max($.width,$.height),...T.landscape||$.width>$.height?{orientation:n.PageOrientation.LANDSCAPE}:{}},margin:{...ne,header:Math.max(0,ne.top-Y(7)-Math.round(l.size*20*1.2)),footer:Math.max(0,ne.bottom-Y(7)-Math.round(l.size*20*1.2))}},...ye===void 0?{}:{grid:ye},...ae?{titlePage:!0}:{}},...oe===void 0?{}:{headers:{default:new n.Header({children:[oe.default]}),...oe.even?{even:new n.Header({children:[oe.even]})}:{},...ae?{first:new n.Header({children:[]})}:{}}},...se===void 0?{}:{footers:{default:new n.Footer({children:[se.default]}),...se.even?{even:new n.Footer({children:[se.even]})}:{},...ae?{first:new n.Footer({children:[se.default]})}:{}}},children:me}}),o=l.lineHeight,E={spacing:{after:Math.round(l.paragraphSpacing*l.size*20),..."pt"in o?{line:Math.round(o.pt*20),lineRule:n.LineRuleType.EXACT}:{line:Math.round(o.multiple*240),lineRule:n.LineRuleType.AUTO}}},Q=l.spacing,J=T=>Math.round(T*20),j=T=>{const D=y.headings?.[T],L=Ze(l.headings[T],D,x,n);return{run:{size:Math.round(l.headings[T].size*2),bold:!0,font:h,color:le,...L.run},paragraph:{spacing:{before:J(Q.heading.before),after:J(Q.heading.after)},keepNext:!0,keepLines:!0,...l.headings[T].rule?{border:{bottom:{style:n.BorderStyle.SINGLE,size:4,color:Le,space:ut}}}:{},...L.paragraph}}},ie=Ze(l.title,y.title,x,n),U=new n.Document({creator:"AllyHub",lastModifiedBy:"AllyHub",...c.title===void 0?{}:{title:c.title},...B?{evenAndOddHeaderAndFooters:!0}:{},numbering:{config:N.numbering()},styles:{default:{document:{run:{font:h,size:Math.round(l.size*2),color:le},paragraph:E},hyperlink:{run:{color:Z??le,underline:{color:Z??ge}}},title:{run:{size:Math.round(l.title.size*2),bold:!0,font:h,color:le,...ie.run},paragraph:{spacing:{before:0,after:J(Q.title)},keepNext:!0,...ie.paragraph}},heading1:j(1),heading2:j(2),heading3:j(3),heading4:j(4),heading5:j(5),heading6:j(6)},paragraphStyles:[{id:qe,name:"TOC Heading",basedOn:"Normal",next:"Normal",quickFormat:!0,...j(1)},{id:"Caption",name:"caption",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:Q.small*2,color:de},paragraph:{spacing:{before:0}}},{id:Ge,name:"List Paragraph",basedOn:"Normal",quickFormat:!0,paragraph:{contextualSpacing:!0}},...[["Header",l.header,y.header===void 0],["Footer",l.footer,y.footer===void 0]].flatMap(([T,D,L])=>D===void 0?[]:[{id:T,name:T.toLowerCase(),basedOn:"Normal",run:{size:Math.round((D.size===void 0?Math.max(7.5,l.size*.75):He(D.size))*2),color:L?de:le,font:be(D.font??l.font,x)},paragraph:{spacing:{before:0,after:0,line:240}}}])]},sections:he,footnotes:N.footnotes(r)}),xe=await n.Packer.toBuffer(U);return Kt(new Uint8Array(xe),u,N.charts)}
2
+ import{CHARTEX_COLORS_REL as Vt,CHARTEX_COLORS_TYPE as Qt,CHARTEX_REL as Zt,chartExRequires as ht,CHARTEX_STYLE_REL as Jt,CHARTEX_STYLE_TYPE as en,CHARTEX_TYPE as tn,CHARTEX_URI as nn,chartBook as rn,chartExColorsXml as an,chartExReference as on,chartExStyleXml as sn,embeddedChartExXml as dn,embeddedChartXml as ln,isExtended as Rt}from"@allyhub/chart";import{chartFrame as cn,chartWords as un,chartTheme as fn,docChart as pn}from"./chart.js";import{BACKGROUNDS as be,TEXT_COLORS as Ae,hex as W}from"./color.js";import{columnWidths as hn}from"./columns.js";import{COMPONENT_WIDTH as mn,componentName as gn}from"./component.js";import{blockId as vt,captionNumbers as wn,contentsTitle as yn,numberedCaption as mt,writtenInChinese as Tn,withoutTitle as St}from"./captions.js";import{sourceList as An,withSources as En}from"./cite.js";import{HEADING_RULE_SPACE as Rn,cardKept as vn,columnsKept as Sn,docParts as Mn,partLook as Mt,headingAnchors as $n,pageAccent as $t,trendSvg as bn}from"./html.js";import{effectiveLook as gt,marginBox as Pn,PAGE_DEFAULTS as Cn,LIST_STEP as xn,lineHeightPt as Nn,resolvePage as rt,WATERMARK_COLOR as zn,WATERMARK_OPACITY as Ln,sizePt as at,RUNNING_PICTURE_HEIGHT as Fn,runningGap as On,runningTall as In}from"./page.js";import{splitTitle as _n}from"./title.js";import{alignAt as Dn,cellSpans as Hn,columnLetters as Bn}from"./merges.js";import{LIST_BULLETS as Un,NUMBER_FORMATS as bt,listNumbering as Pt,headingNumberings as Gn,ownFormat as wt,wordLevelText as Ct}from"./numbering.js";import{BUILT_IN_STYLES as xt,NORMAL as Nt,TITLE_STYLE as Xn,headingStyle as Oe,pickProps as Wn,resolveStyle as jn,styleId as Ie,resolveTableStyle as zt,TABLE_GRID as qn}from"./styles.js";import{markdownOf as kn}from"./markdown.js";import{laidWidths as Yn,emptyHead as Kn,numberColumns as Vn,withTableData as Qn}from"./table.js";import{DRAWN_CODE as ot}from"./math.js";import{PAPER as Me,TONE_COLORS as Lt,tagColors as Ft}from"./paper.js";import{COVER_ASPECT as Zn,FORMAT_KEYS as Jn,everyBlock as Ge,firstNoteMarks as ei,noteNumbers as ti,statTone as ni}from"./model.js";import{calloutTone as ii,docStatsDef as ri,libraryBlockSvg as ai,libraryBlockTable as oi}from"./blocks.js";const Ot=251658240,It="WordPictureWatermark1",si='<a:lum bright="70000" contrast="-70000"/>',di='<v:shapetype id="_x0000_t136" coordsize="21600,21600" o:spt="136" adj="10800" path="m@7,l@8,m@5,21600l@6,21600e"><v:formulas><v:f eqn="sum #0 0 10800"/><v:f eqn="prod #0 2 1"/><v:f eqn="sum 21600 0 @1"/><v:f eqn="sum 0 0 @2"/><v:f eqn="sum 21600 0 @3"/><v:f eqn="if @0 @3 0"/><v:f eqn="if @0 21600 @1"/><v:f eqn="if @0 0 @2"/><v:f eqn="if @0 @4 21600"/><v:f eqn="mid @5 @6"/><v:f eqn="mid @8 @5"/><v:f eqn="mid @7 @8"/><v:f eqn="mid @6 @7"/><v:f eqn="sum @6 0 @5"/></v:formulas><v:path textpathok="t" o:connecttype="custom" o:connectlocs="@9,0;@10,10800;@11,21600;@12,10800" o:connectangles="270,180,90,0"/><v:textpath on="t" fitshape="t"/><v:handles><v:h position="#0,bottomRight" xrange="6629,14971"/></v:handles><o:lock v:ext="edit" text="t" shapetype="t"/></v:shapetype>';function li(t,i){const h=t.layout!=="horizontal",d=h?Math.hypot(i.textWidth,i.textHeight)*.8:i.textWidth*.9;let A=0;for(const f of t.text)A+=/[\u2E80-\u9FFF\uAC00-\uD7AF\uF900-\uFAFF\uFF00-\uFFEF]/u.test(f)?1:f===" "?.3:.62;const s=Math.min(d/Math.max(1,A),i.textHeight/2)/25.4*72,E=Math.round(Math.max(1,A)*s*10)/10,r=Math.round(s*10)/10,l=t.color??zn,g=lt[t.font??i.font],S=/[\u2E80-\u9FFF]/u.test(t.text)?g.eastAsia??g.latin:g.latin,R=f=>f.replace(/[&<>"]/gu,O=>O==="&"?"&amp;":O==="<"?"&lt;":O===">"?"&gt;":"&quot;");return`<w:p><w:pPr><w:spacing w:before="0" w:after="0" w:line="20" w:lineRule="exact"/></w:pPr><w:r><w:rPr><w:noProof/></w:rPr><w:pict>${di}<v:shape id="PowerPlusWaterMarkObject1" o:spid="_x0000_s1025" type="#_x0000_t136" style="position:absolute;margin-left:0;margin-top:0;width:${String(E)}pt;height:${String(r)}pt;${h?"rotation:315;":""}z-index:-251657216;mso-position-horizontal:center;mso-position-horizontal-relative:margin;mso-position-vertical:center;mso-position-vertical-relative:margin" o:allowincell="f" fillcolor="${R(l)}" stroked="f"><v:fill opacity="${String(Ln)}"/><v:textpath style="font-family:&quot;${R(S)}&quot;;font-size:1pt" string="${R(t.text)}"/><w10:wrap anchorx="margin" anchory="margin"/></v:shape></w:pict></w:r></w:p>`}function st(t){return t.type==="svg"?{type:"svg",data:t.data,fallback:{type:"png",data:t.fallback??ct}}:{type:t.type,data:t.data}}const dt=t=>xt.includes(t)?t.replace(/\s/gu,""):Ie(t);function ci(t,i){if(!(i===void 0||t.trim()===""))try{return i.latexToMath(t)}catch(h){if(h instanceof Error)return;throw h}}function ui(t,i){const h=W(i.borderColor,Ae)??"auto",d=(R,f)=>`<w:${R} w:val="${f?"single":"nil"}" w:sz="4" w:space="0" w:color="${f?h:"auto"}"/>`,A=i.borders,z=["top","left","bottom","right","insideH","insideV"].map(R=>d(R,A==="all"||A==="rows"&&(R==="top"||R==="bottom"||R==="insideH")||A==="outside"&&!R.startsWith("inside"))),s=R=>R.replace(/&/gu,"&amp;").replace(/</gu,"&lt;").replace(/"/gu,"&quot;"),E=R=>{const f=W(R,be);return f===void 0?"":`<w:tcPr><w:shd w:val="clear" w:color="auto" w:fill="${f}"/></w:tcPr>`},r=[i.headBold===!0?"<w:b/><w:bCs/>":"",i.headColor===void 0?"":`<w:color w:val="${W(i.headColor,Ae)??"auto"}"/>`].join(""),l=r===""&&i.headBg===void 0?"":`<w:tblStylePr w:type="firstRow">${r===""?"":`<w:rPr>${r}</w:rPr>`}${E(i.headBg)}</w:tblStylePr>`,g=i.banded===void 0?"":`<w:tblStylePr w:type="band1Horz">${E(i.banded)}</w:tblStylePr>`,S=t!==qn;return`<w:style w:type="table"${S?' w:customStyle="1"':""} w:styleId="${Ie(t)}"><w:name w:val="${s(t)}"/><w:uiPriority w:val="${S?"99":"39"}"/><w:pPr><w:spacing w:after="0" w:line="240" w:lineRule="auto"/></w:pPr><w:tblPr>${g===""?"":'<w:tblStyleRowBandSize w:val="1"/>'}${A===void 0?"":`<w:tblBorders>${z.join("")}</w:tblBorders>`}<w:tblCellMar><w:left w:w="108" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr>${l}${g}</w:style>`}const fi=240,_t={top:3.6,bottom:3.6,left:7.2,right:7.2},Dt="headings",pi=new Set(["paragraph","toggle","heading","quote","bullet","numbered","check"]),Xe=15,hi=1440/25.4,ue=t=>Math.round(t*hi),Ht="ListParagraph",Bt="bullets",mi=1.8,We=xn*20,lt={sans:{latin:"Calibri"},serif:{latin:"Cambria"},mono:{latin:"Courier New"},times:{latin:"Times New Roman"},song:{latin:"Times New Roman",eastAsia:"宋体"},hei:{latin:"Arial",eastAsia:"黑体"},fangsong:{latin:"Times New Roman",eastAsia:"仿宋"},kai:{latin:"Times New Roman",eastAsia:"楷体"},xiaobiaosong:{latin:"Times New Roman",eastAsia:"方正小标宋简体"}},yt="Courier New",fe=t=>t.slice(1).toUpperCase(),Pe=fe(Me.ink),_e=fe(Me.lead),ct=Buffer.from("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=","base64"),je=fe(Me.rule),qe=fe(Me.ruleStrong),ke=fe(Me.ruleMid),Ye=fe(Me.stone),gi=fe(Me.stone3),Ce=fe(Me.leadSoft),Ut="ALLYHUB-CHART-";function wi(t){return/[\u3040-\u30ff]/u.test(t)?"Yu Gothic":/[\uac00-\ud7af]/u.test(t)?"Malgun Gothic":"Microsoft YaHei"}const yi=/^(https?:|mailto:)/i,Ke=t=>({indent:0,level:0,room:t,frame:mn}),Gt=t=>({...t,indent:t.indent+We,level:Math.min(t.level+1,8)}),Ti=400,Ai=t=>t.type==="bullet"||t.type==="numbered"||t.type==="check";function Xt(t,i,h){const d=h/Xe,A=Math.floor(Math.min(i??t.width,d));return{width:A,height:Math.round(A*t.height/t.width)}}function Ei(t,i=1){const h=[];let d=[],A=i,z=!1;for(const s of t){if(s.type==="pagebreak"&&(s.columns!==void 0||s.continuous===!0)){h.push({blocks:d,columns:A,continuous:z}),d=[],A=s.columns??1,z=s.continuous===!0;continue}d.push(s)}return h.push({blocks:d,columns:A,continuous:z}),h.filter((s,E)=>E>0||s.blocks.length>0||h.length===1)}const Ri=t=>/\p{Script=Han}/u.test(t)?Array.from(t.trim())[0]??"":t.split(/\s+/u).map(i=>Array.from(i)[0]??"").join("").toUpperCase().slice(0,3);function vi(t){const i=new Map;for(const r of t)r.type==="comment"&&!i.has(r.id)&&i.set(r.id,i.size);const h=new Map,d=new Map,A=r=>{for(const l of r)for(const g of l.styles.comments??[])i.has(g)&&(h.has(g)||h.set(g,l),d.set(g,l))};for(const r of Ge(t))if(!(r.type==="note"||r.type==="comment")&&("content"in r&&Array.isArray(r.content)&&A(r.content),r.type==="table"))for(const l of r.rows)for(const g of l)A(g);const z=new Map;for(const r of t)r.type==="comment"&&r.replyTo!==void 0&&z.set(r.id,r.replyTo);const s=r=>{let l=r;const g=new Set;for(let S=z.get(l);S!==void 0&&!g.has(S);S=z.get(l))g.add(S),l=S;return l};for(const r of z.keys()){const l=s(r),g=h.get(l),S=d.get(l);h.has(r)||g===void 0||S===void 0||(h.set(r,g),d.set(r,S))}const E=r=>{const l=new Map;for(const[g,S]of r){const R=i.get(g);R!==void 0&&l.set(S,[...l.get(S)??[],R])}return l};return{ids:i,starts:E(h),ends:E(d)}}const Wt="TOCHeading";function Si(t,i,h,d,A,z,s){const{AlignmentType:E,BorderStyle:r,ExternalHyperlink:l,ShadingType:g,Table:S,TableCell:R,TableLayoutType:f,TableRow:O,TextRun:N,WidthType:C}=t;let K=0;const pe=i.revisionDate??new Date().toISOString();let D,G=0,ge=0;const V=new Map,I=(e,n)=>(e.move!==void 0&&V.set(n,e.move),{id:n,author:e.author,date:e.date??pe}),H=()=>D===void 0?{}:D.kind==="inserted"?{insertion:I(D,G)}:{deletion:I(D,G)};let U;const de=e=>{if(U===void 0)return e;const n=U.style,{paragraph:a}=wordProps(t,Wn(U,"paragraph"),s.page.size,h),p=Object.fromEntries(Object.entries(e).filter(([m])=>m!=="heading"));return{...n===void 0?e:{...p,style:dt(n)},...a,...a.indent===void 0?{}:{indent:{...e.indent,...a.indent,...a.indent.left===void 0?{}:{left:(typeof e.indent?.left=="number"?e.indent.left:0)+(typeof a.indent.left=="number"?a.indent.left:0)}}},...a.spacing===void 0?{}:{spacing:{...e.spacing,...a.spacing}}}};let te,re;const he=(e,n)=>{const a=U;U=e;try{const p=de(n.style===void 0?{}:{style:n.style});return{...we(e),...Object.fromEntries(Object.entries(p).filter(([m])=>["style","alignment","indent","spacing","keepNext","keepLines","pageBreakBefore"].includes(m)))}}finally{U=a}};class M extends t.Paragraph{constructor(n){const a=de(n),p=re;re=void 0;const m=p===void 0?a:{...a,revision:{...he(p.was,n),...I(p,++K)}},y=D===void 0?te:void 0;te=void 0,super(D!==void 0?{...m,run:{...m.run,...H()}}:y!==void 0?{...m,run:{...m.run,...y.kind==="inserted"?{insertion:I(y,++K)}:{deletion:I(y,++K)}}}:m)}}class xe extends t.ImageRun{constructor(n){super({...n,...H()})}}const le=e=>{const n=e.filter(a=>!(a instanceof t.TableOfContents));return n.at(-1)instanceof t.Paragraph?n:[...n,ae(0)]},Qe={ascii:yt,hAnsi:yt,cs:yt,eastAsia:h},Ne=new Set([1]);let ut=0;const Ee=[],ze=new Set,Q=e=>({type:g.CLEAR,color:"auto",fill:e}),Le=(e,n,a=4)=>({style:e,color:n,size:a,space:4}),v=s.page.spacing,L=e=>Math.round(e*20),ae=e=>new M({spacing:{before:0,after:L(e),line:14,lineRule:t.LineRuleType.EXACT}}),me=()=>v.after>0?[ae(v.after)]:[],He=e=>e==="center"?E.CENTER:e==="right"?E.RIGHT:e==="justify"?E.JUSTIFIED:void 0,Fe=(e,n)=>{const a=n.deleted??(D?.kind==="deleted"?D:void 0),p=n.inserted??(D?.kind==="inserted"?D:void 0),m=n.deleted??n.inserted?ge:G;return a!==void 0?new t.DeletedTextRun({...e,...I(a,m)}):p!==void 0?new t.InsertedTextRun({...e,...I(p,m)}):new N(e)},Z=(e,n,a,p={},m)=>{if(n.tag!==void 0){const c=Ft(n.tag),b={...p,color:fe(c.fg),size:Math.round((a.size??s.page.size*2)*.85),shading:Q(fe(c.bg)),...n.bold||a.bold?{bold:!0}:{},...n.italic?{italics:!0}:{}};return[Fe({...b,text:` ${e.replace(/\n/gu," ")} `},n)]}const y=c=>{const b=W(c.color,Ae)??a.color,x=W(c.background,be),B=wordProps(t,{...c.font===void 0?{}:{font:c.font},...c.size===void 0?{}:{size:c.size},...c.caps?{caps:!0}:{},...c.smallCaps?{smallCaps:!0}:{},...c.letterSpacing===void 0?{}:{letterSpacing:c.letterSpacing}},s.page.size,h).run;return{...c.style===void 0?{}:{style:dt(c.style)},...p,...c.superscript?{superScript:!0}:{},...c.subscript?{subScript:!0}:{},...c.bold||a.bold?{bold:!0}:{},...c.italic?{italics:!0}:{},...c.underline?{underline:{}}:{},...c.strike?{strike:!0}:{},...b===void 0?{}:{color:b},...a.size===void 0?{}:{size:a.size},...c.code?{font:Qe,shading:Q(x??Ye)}:x===void 0?{}:{shading:Q(x)},...B}},T=y(n),u=n.formatted===void 0?T:{...T,revision:{...y({...Object.fromEntries(Object.entries(n).filter(([c])=>!Jn.includes(c))),...n.formatted.was}),...I(n.formatted,++K)}},_=e.split(`
3
+ `).map((c,b)=>Fe({...u,...c.includes(" ")?{children:c.split(" ").flatMap((x,B)=>[...B>0?[new t.Tab]:[],...x===""?[]:[x]])}:{text:c},...b>0?{break:1}:{}},n));if(m===void 0)return _;const $=c=>Fe({...u,children:[new t.BuilderElement({name:"w:fldChar",attributes:{type:{key:"w:fldCharType",value:c}}})]},n);return[$("begin"),Fe({...u,children:[new t.StringContainer("w:instrText",` ${m} `)]},n),$("separate"),...e===""?[]:_,$("end")]},Ze=e=>e.deleted!==void 0?`d\0${e.deleted.author}\0${e.deleted.date??""}\0${e.deleted.move??""}`:e.inserted!==void 0?`i\0${e.inserted.author}\0${e.inserted.date??""}\0${e.inserted.move??""}`:void 0,oe=(e,n={})=>{let a;return e.flatMap(p=>{const m=Ze(p.styles);m!==void 0&&m!==a&&(ge=++K),a=m;const y=s.comments.starts.get(p)??[],T=s.comments.ends.get(p)??[];return[...y.map(u=>new t.CommentRangeStart(u)),...w(p,n),...T.flatMap(u=>[new t.CommentRangeEnd(u),new N({children:[new t.CommentReference(u)]})])]})},ft=e=>{const n=e.blocks.flatMap(a=>"content"in a&&Array.isArray(a.content)?[new t.Paragraph({children:o(a.content)})]:[]);return n.length>0?n:[new t.Paragraph({children:[]})]},o=e=>e.flatMap(n=>Z(n.text,n.styles,{})),w=(e,n)=>e.field!==void 0?Z(P(e),e.styles,n,{},Ni(e.field,s.bookmarks)):e.note!==void 0?A.has(e.note.toLowerCase())?z.has(e)?[s.endnotes?new t.EndnoteReferenceRun(A.get(e.note.toLowerCase())??1):new t.FootnoteReferenceRun(A.get(e.note.toLowerCase())??1)]:[new N({text:String(A.get(e.note.toLowerCase())??1),style:s.endnotes?"EndnoteReference":"FootnoteReference"})]:[]:e.text===""&&e.href?.startsWith("#")===!0?J(e.href.slice(1),e.styles,n):e.href?.startsWith("#")===!0&&s.bookmarks.has(decodeURIComponent(e.href.slice(1)))?[new t.InternalHyperlink({anchor:s.bookmarks.get(decodeURIComponent(e.href.slice(1)))??"",children:Z(e.text,e.styles,n,{style:"Hyperlink"})})]:e.href!==void 0&&yi.test(e.href)?[new l({link:e.href,children:Z(e.text,e.styles,n,{style:"Hyperlink"})})]:Z(e.text,e.styles,n),P=e=>{const[n="",a=""]=(e.field??"").split(" ");switch(n.toUpperCase()){case"PAGEREF":{const p=i.headingPage?.(a);return p===void 0?e.text:String(p)}case"REF":return s.refs.get(a)??e.text;default:return e.text}},J=(e,n,a)=>{const p=decodeURIComponent(e),m=s.refs.get(p)??"",y=s.bookmarks.get(p);return m===""?[]:y===void 0?Z(m,n,a):[new t.InternalHyperlink({anchor:y,children:Z(m,n,a,{style:"Hyperlink"})})]},ne=(e,n)=>{const a=e===void 0?void 0:s.bookmarks.get(e);return a===void 0?n:[new t.Bookmark({id:a,children:n})]},we=e=>{const n=He(e?.align),a=W(e?.background,be);return{...n===void 0?{}:{alignment:n},...a===void 0?{}:{shading:Q(a)}}},k=e=>e.indent===0?{}:{indent:{left:e.indent}},ye=e=>{const n={style:r.SINGLE,color:e,size:4};return{top:n,bottom:n,left:n,right:n}},Je=(e,n)=>{const a=ii(e.tone,i.page),p=W(e.look?.background,be)??W(a?.bg,{})??Ye,m=W(e.look?.color,Ae)??W(a?.fg,{}),y=n.room-n.indent,T=e.icon===void 0?0:L(s.page.size*mi)+L(v.box.side),u=y-T,_=($,c)=>({top:L(v.box.top),bottom:L(Math.max(v.box.top-v.after,0)),left:$,right:c,marginUnitType:C.DXA});return new S({layout:f.FIXED,width:{size:y,type:C.DXA},columnWidths:T===0?[u]:[T,u],...n.indent===0?{}:{indent:{size:n.indent,type:C.DXA}},rows:[new O({cantSplit:!0,children:[...e.icon===void 0?[]:[new R({width:{size:T,type:C.DXA},shading:Q(p),borders:ye(p),margins:_(L(v.box.side),0),children:[new M({children:[new N({text:e.icon})]})]})],new R({width:{size:u,type:C.DXA},shading:Q(p),borders:ye(p),margins:_(T===0?L(v.box.side):0,L(v.box.side)),children:[new M({children:oe(e.content,{color:m})}),...le(F(e.children??[],Ke(u-L(v.box.side))))]})]})]})},Be=(e,n)=>{const a=n.room-n.indent,p=L(v.card.side),m=W($t(i.page),{})??W(fn(i.page).accent1,{}),y=e.featured===!0&&m!==void 0,T=e.tag===void 0?void 0:Ft("blue"),u=[...e.title===void 0?[]:[new M({spacing:{after:e.subtitle===void 0?L(v.after):0},children:[...oe([{text:e.title,styles:y?{bold:!0,color:"#FFFFFF"}:{bold:!0}}]),...T===void 0||e.tag===void 0?[]:[new N({text:"  "}),new N({text:` ${e.tag} `,size:v.small*2,color:W(T.fg,{})??_e,shading:{type:g.CLEAR,fill:W(T.bg,{})??Ye,color:"auto"}})]]})],...e.subtitle===void 0?[]:[new M({spacing:{after:L(v.after)},children:[new N({text:e.subtitle,color:y?"FFFFFF":_e,size:v.small*2})]})]];return new S({layout:f.FIXED,width:{size:a,type:C.DXA},columnWidths:[a],...n.indent===0?{}:{indent:{size:n.indent,type:C.DXA}},rows:[new O({cantSplit:vn(e,s.page),children:[new R({width:{size:a,type:C.DXA},borders:ye(y?m:je),...y?{shading:{type:g.CLEAR,fill:m,color:"auto"}}:{},margins:{top:L(v.card.top),bottom:L(Math.max(v.card.top-v.after,0)),left:p,right:p,marginUnitType:C.DXA},children:le([...u,...F(e.children??[],Ke(a-2*p))])})]})]})},et=(e,n)=>{const a=n.room-n.indent,p=Math.min(e.width??(e.float===void 0&&e.wrap===void 0?a/15:fi),a/15),m=F(e.children??[],Ke(Math.round(p*15-2*_t.left*20))),y=i.shapes;if(y===void 0)return[Be({type:"card",children:e.children??[]},n),...me()];const T=m.filter(u=>u instanceof M);return[new M({...n.indent===0?{}:{indent:{left:n.indent}},...e.float===void 0&&e.wrap===void 0?{}:{spacing:{before:0,after:0,line:20,lineRule:"exact"}},children:[new y.ShapeRun({type:"rectangle",transformation:{width:Math.round(p),height:"fitText"},line:{color:je,width:.75},fill:{type:"solid",color:"FFFFFF"},textOptions:{verticalAlignment:"top",margins:_t,resizeShapeToFitText:!0},children:T.length>0?T:[new M({})],...e.wrap===void 0?{}:{floating:{horizontalPosition:{relative:t.HorizontalPositionRelativeFrom.COLUMN,offset:Math.round((e.x??0)*De)},verticalPosition:{relative:t.VerticalPositionRelativeFrom.PARAGRAPH,offset:Math.round((e.y??0)*De)},allowOverlap:!0,behindDocument:e.wrap==="behind",...e.wrap==="front"?{zIndex:Ot}:{},wrap:{type:t.TextWrappingType.NONE}}},...e.float===void 0||e.wrap!==void 0?{}:{floating:{horizontalPosition:{relative:t.HorizontalPositionRelativeFrom.MARGIN,align:e.float==="left"?t.HorizontalPositionAlign.LEFT:t.HorizontalPositionAlign.RIGHT},verticalPosition:{relative:t.VerticalPositionRelativeFrom.PARAGRAPH,offset:0},wrap:{type:t.TextWrappingType.SQUARE,side:t.TextWrappingSide.BOTH_SIDES},margins:{left:e.float==="right"?114300:0,right:e.float==="left"?114300:0,top:0,bottom:57150}}}})]}),...m.filter(u=>!(u instanceof M))]},tt=(e,n)=>{const a=ri(e,i),p=a?.kind==="stats"?a.items:[];e={...e,stats:e.stats.map((X,ce)=>{const j=p[ce];return j===void 0?X:{...X,value:j.value.text,...j.delta===void 0?{}:{delta:j.delta.text},...j.status===void 0?{}:{status:j.status}}})};const m=n.room-n.indent,y=L(v.gap),T=e.stats.length,u=Math.floor((m-y*(T-1))/T),_=e.stats.flatMap((X,ce)=>ce===0?[u]:[y,u]),$={style:r.NONE,size:0,color:"auto"},c={top:$,bottom:$,left:$,right:$},b=L(v.card.side),x=v.small*2,B=e.stats.flatMap((X,ce)=>{const j=ni(X),q=[...X.delta===void 0?[]:[new N({text:X.delta,color:fe(Lt[j]),size:x})],...X.note===void 0?[]:[new N({text:`${X.delta===void 0?"":" "}${X.note}`,color:_e,size:x})]],Y=u-2*b,ee=X.trend===void 0?[]:[new M({spacing:{before:60,after:0,line:240},children:[new xe({type:"svg",data:Buffer.from(bn(X.trend,Lt[j]).replace("<svg ",`<svg xmlns="http://www.w3.org/2000/svg" width="${String(Math.round(Y/15))}" height="24" `)),fallback:{type:"png",data:ct},transformation:{width:Math.round(Y/15),height:24}})]})],ie=new R({width:{size:u,type:C.DXA},borders:ye(je),margins:{top:L(v.card.top),bottom:L(v.card.top),left:b,right:b,marginUnitType:C.DXA},children:[new M({spacing:{after:0},children:[new N({text:X.label,color:_e,size:x})]}),new M({spacing:{after:0,line:240,lineRule:t.LineRuleType.AUTO},children:oe([{text:X.value,styles:{bold:!0}}],{size:v.figure*2})}),...q.length===0?[]:[new M({spacing:{after:0},children:q})],...ee]}),Se=new R({width:{size:y,type:C.DXA},borders:c,children:[new M({children:[]})]});return ce===0?[ie]:[Se,ie]});return new S({layout:f.FIXED,width:{size:m,type:C.DXA},columnWidths:_,...n.indent===0?{}:{indent:{size:n.indent,type:C.DXA}},rows:[new O({cantSplit:!0,children:B})]})},pt=(e,n)=>{const a=n.room-n.indent,p=Math.max(1,...e.rows.map(j=>j.length)),m=Yn(e,a/Xe,v.small,v.cell.side).map(j=>Math.round(j*Xe)),y=Kn(e),T=(e.head===void 0||e.head==="both")&&!y,u=e.head==="column"||e.head==="both",_=Vn(e),$=y?e.rows.slice(1):e.rows,c=Hn(e.merges),b=e.style===void 0?void 0:zt(i.page?.styles,e.style);e.style!==void 0&&ze.add(e.style);const x={style:r.NONE,size:0,color:"auto"},B={style:r.SINGLE,size:4,color:W(b?.borderColor,Ae)??ke},X=(j,q,Y)=>{const ee=b?.borders,ie=j===0,Se=j===$.length-1,se={left:q===0,right:q+Y>=p};return ee==="all"?{top:B,bottom:B,left:B,right:B}:ee==="rows"?{top:ie?B:x,bottom:B,left:x,right:x}:ee==="outside"?{top:ie?B:x,bottom:Se?B:x,left:se.left?B:x,right:se.right?B:x}:{top:x,bottom:x,left:x,right:x}},ce=(j,q,Y)=>{const ee=e.cells?.[`${Bn(q)}${String(j+1)}`];if(ee===void 0)return;const ie=m.slice(q,q+Y).reduce((Se,se)=>Se+se,0);return le(F(ee,{indent:0,level:0,room:Math.max(ie-2*L(v.cell.side),1),frame:n.frame}))};return new S({...e.style===void 0?{}:{style:Ie(e.style)},layout:f.FIXED,width:{size:m.reduce((j,q)=>j+q,0),type:C.DXA},columnWidths:m,...n.indent===0?{}:{indent:{size:n.indent,type:C.DXA}},rows:$.map((j,q)=>new O({tableHeader:T&&q===0,cantSplit:!0,...(()=>{const Y=e.heights?.[q+(y?1:0)];return Y?{height:{value:Y*15,rule:"atLeast"}}:{}})(),children:Array.from({length:p},(Y,ee)=>ee).flatMap(Y=>{const ee=c(q+(y?1:0),Y);if(ee==="covered")return[];const ie=ee?.cols??1,Se=ee?.rows??1,se=T&&q===0,qt=u&&Y===0&&!se,kt=b?.banded!==void 0&&!se&&(q-(T?1:0))%2===0,At=b===void 0?se?gi:void 0:se?W(b.headBg,be):kt?W(b.banded,be):void 0,Et=Dn(e.valign,q+(y?1:0),Y);return[new R({...Et==="top"?{}:{verticalAlign:Et},...ie>1?{columnSpan:ie}:{},...Se>1?{rowSpan:Se}:{},width:{size:m.slice(Y,Y+ie).reduce((Yt,Kt)=>Yt+Kt,0),type:C.DXA},...At===void 0?{}:{shading:Q(At)},borders:b?.borders!==void 0?X(q,Y,ie):b!==void 0?{top:x,bottom:x,left:x,right:x}:{top:q===0?{style:r.SINGLE,size:8,color:qe}:{style:r.NONE,size:0,color:"auto"},left:{style:r.NONE,size:0,color:"auto"},right:{style:r.NONE,size:0,color:"auto"},bottom:q===$.length-1?{style:r.SINGLE,size:8,color:qe}:se?{style:r.SINGLE,size:6,color:qe}:{style:r.SINGLE,size:4,color:ke}},margins:{top:L(v.cell.top),bottom:L(v.cell.top),left:L(v.cell.side),right:L(v.cell.side),marginUnitType:C.DXA},children:ce(q+(y?1:0),Y,ie)??[new M({spacing:{after:0},..._.has(Y)?{alignment:E.RIGHT}:{},children:oe(j[Y]??[],{bold:qt||se&&(b===void 0||b.headBold===!0),...se&&b?.headColor!==void 0?{color:W(b.headColor,Ae)??Pe}:{},size:v.small*2})})]})]})}))})},$e=(e,n,a,p,m,y)=>{const T=He(e.align),u={...k(n),...T===void 0?{}:{alignment:T}},_=a===void 0?void 0:e.caption,$=_!==void 0,c=[new M({...u,keepNext:$,...a&&e.wrap!==void 0?{spacing:{before:0,after:0,line:20,lineRule:"exact"}}:a?{spacing:{line:240,lineRule:t.LineRuleType.AUTO,...$?{after:L(v.caption)}:{}}}:{},children:a?[new xe({...st(a),transformation:Xt(a,e.width,e.wrap===void 0?n.room-n.indent:Number.POSITIVE_INFINITY),...e.wrap===void 0?{}:{floating:{horizontalPosition:{relative:t.HorizontalPositionRelativeFrom.COLUMN,offset:Math.round((e.x??0)*De)},verticalPosition:{relative:t.VerticalPositionRelativeFrom.PARAGRAPH,offset:Math.round((e.y??0)*De)},allowOverlap:!0,behindDocument:e.wrap==="behind",...e.wrap==="front"?{zIndex:Ot}:{},wrap:{type:t.TextWrappingType.NONE}}},...e.float===void 0||e.wrap!==void 0?{}:{floating:{horizontalPosition:{relative:t.HorizontalPositionRelativeFrom.MARGIN,align:e.float==="left"?t.HorizontalPositionAlign.LEFT:t.HorizontalPositionAlign.RIGHT},verticalPosition:{relative:t.VerticalPositionRelativeFrom.PARAGRAPH,offset:0},wrap:{type:t.TextWrappingType.SQUARE,side:t.TextWrappingSide.BOTH_SIDES},margins:{left:e.float==="right"?114300:0,right:e.float==="left"?114300:0,top:0,bottom:57150}}},altText:{name:e.alt??"",title:e.caption??"",description:e.alt??""}})]:[new N({text:p,color:Ce})]})];return _!==void 0&&c.push(new M({...u,style:"Caption",children:ne(y,[new N({text:mt(_,m)})])})),c},Te=(e,n)=>{const a=n.room-n.indent,p=e.columns.map(c=>c.width??1),m=p.reduce((c,b)=>c+b,0)||1,y=p.map(c=>Math.round(a*c/m)),T=hn(e,n.frame),u={style:r.NONE,size:0,color:"auto"},_={top:u,bottom:u,left:u,right:u,insideHorizontal:u,insideVertical:u},$=Ti/2;return new S({layout:f.FIXED,width:{size:a,type:C.DXA},columnWidths:y,borders:_,...n.indent===0?{}:{indent:{size:n.indent,type:C.DXA}},rows:[new O({cantSplit:Sn(e,s.page),children:e.columns.map((c,b)=>{const x=y[b]??0,B=b===0?0:$,X=b===e.columns.length-1?0:$,ce=le(F(c.blocks,{indent:0,level:0,room:x-B-X,frame:T[b]??n.frame}));return new R({width:{size:x,type:C.DXA},borders:_,margins:{top:0,bottom:0,left:B,right:X,marginUnitType:C.DXA},children:ce})})})]})},Re=(e,n,a)=>{const p=F(e.children??[],Gt(n)),m={looking:U,marking:D,markingId:G};U=e.look,e.revision!==void 0&&D===void 0&&(D=e.revision,G=++K);try{return te=e.mark,re=e.formatted,[...nt(e,n,a),...p]}finally{te=void 0,{looking:U,marking:D,markingId:G}=m}},nt=(e,n,a)=>{const p=W(e.look?.color,Ae),m=we(e.look),y=Ht;return e.type==="check"?[new M({...m,...k(n),style:y,children:[new N({text:e.checked?"☑ ":"☐ "}),...oe(e.content,{color:p})]})]:[new M({...m,style:y,numbering:e.type==="bullet"?{reference:Bt,level:n.level}:{reference:`start-${String(a.start)}`,level:n.level,instance:a.id},children:oe(e.content,{color:p})})]},ve=(e,n)=>{const a=U;U=pi.has(e.type)&&"look"in e?e.look:void 0;try{return it(e,n)}finally{U=a,te=void 0,re=void 0}},it=(e,n)=>{if(e.revision===void 0||D!==void 0)return Ue(e,n);D=e.revision,G=++K;try{return Ue(e,n)}finally{D=void 0}},Ue=(e,n)=>{te=e.type==="paragraph"||e.type==="heading"?e.mark:void 0,re="content"in e?e.formatted:void 0;const a="look"in e?e.look:void 0,p=W(a?.color,Ae),m=we(a),y=()=>"children"in e?F(e.children??[],Gt(n)):[];switch(e.type){case"paragraph":case"toggle":return[new M({...s.sets.align&&e.look?.align===void 0?{alignment:E.JUSTIFIED}:{},...m,...s.sets.indent&&e.type==="paragraph"?{indent:{left:n.indent,firstLine:Math.round(s.page.textIndent*s.page.size*20)}}:k(n),children:oe(e.content,{color:p})}),...y()];case"heading":return[new M({...m,...k(n),...e===s.title?{heading:t.HeadingLevel.TITLE}:{heading:t.HeadingLevel[`HEADING_${String(e.level)}`]},children:ne(s.anchors.get(e),oe(e.content,{color:p}))}),...y()];case"quote":return[new M({...m,indent:{left:n.indent+L(v.quote)},border:{left:{style:r.SINGLE,color:d??qe,size:d?12:6,space:Math.floor(v.quote-(d?1.5:.75))}},children:oe(e.content,{color:p??_e})}),...y()];case"callout":return[Je(e,n),...me()];case"card":return[Be(e,n),...me()];case"textbox":return et(e,n);case"stats":return[tt(e,n),...me()];case"code":{const T=e.language===ot.math?ci(e.code,i.math):void 0;if(T!==void 0)return[new M({alignment:E.CENTER,...n.indent===0?{}:{indent:{left:n.indent}},children:[new t.Math({children:T})]})];if(e.language===ot.math||e.language===ot.mermaid){const $=i.drawn?.(e);if($)return $e({...e.language===ot.math?{}:{align:"center"}},n,$,"")}const u=$=>({style:r.SINGLE,color:Ye,size:4,space:$}),_=L(v.box.side+.5);return[new M({indent:{left:n.indent+_,right:_},shading:Q(Ye),border:{top:u(v.box.top),bottom:u(v.box.top),left:u(v.box.side),right:u(v.box.side)},keepLines:!0,children:e.code.split(`
4
+ `).map(($,c)=>new N({text:$,font:Qe,size:v.small*2,...c>0?{break:1}:{}}))})]}case"columns":return[Te(e,n)];case"chart":{const T=s.numbers.get(e),u=T===void 0?void 0:e.title,{chart:_,problems:$}=pn(u===void 0?e:St(e),i),c=Le(r.DASHED,ke);if(!_)return[new M({...k(n),alignment:E.CENTER,border:{top:c,bottom:c,left:c,right:c},children:[new N({text:[e.title??"Chart",...$].join(": "),color:Ce})]})];const b=cn(e,n.frame),x=(n.room-n.indent)/Xe,B=Math.min(1,x/b.width);return Ee.push({chart:_,width:Math.round(b.width*B),height:Math.round(b.height*B),words:un(e,_),...Rt(_.type)?{fallback:i.chart?.(u===void 0?e:St(e))}:{}}),[new M({...k(n),alignment:E.CENTER,keepNext:u!==void 0,spacing:{line:240,lineRule:t.LineRuleType.AUTO},children:[new N({text:`${Ut}${String(Ee.length)}`})]}),...u===void 0?[]:[new M({...k(n),alignment:E.CENTER,style:"Caption",children:ne(e.id,[new N({text:mt(u,T)})])})]]}case"image":return $e(e,n,i.picture?.(e.src),e.alt??e.caption??e.src,s.numbers.get(e),e.id);case"block":{const{svg:T,alt:u,problems:_}=ai(e,n.frame,i),$=u??_.join("; "),c=i.block?.(e),b=oi(e,i),x=b?ve(b,n):[];if(T===void 0)return[...c?$e({alt:$},n,c,$):[new M({...k(n),children:[new N({text:$})]})],...x];const B=Number(/ width="([\d.]+)"/u.exec(T)?.[1]??"0"),X=Number(/ height="([\d.]+)"/u.exec(T)?.[1]??"0"),ce=Xt({data:ct,type:"png",width:B,height:X},void 0,n.room);return[new M({...k(n),children:[new xe({type:"svg",data:Buffer.from(T),fallback:c&&c.type!=="svg"?{type:c.type,data:c.data}:{type:"png",data:c?.fallback??ct},transformation:ce,altText:{name:e.tag,title:e.tag,description:$}})]}),...x]}case"component":{const T=i.component?.(e);if(T)return $e(e,n,T,"",s.numbers.get(e),e.id);const u=Le(r.DASHED,ke);return[new M({...k(n),alignment:E.CENTER,border:{top:u,bottom:u,left:u,right:u},children:[new N({text:gn(e),color:Ce})]})]}case"table":return[...e.caption===void 0?[]:[new M({...k(n),style:"Caption",keepNext:!0,spacing:{after:L(v.caption)},children:ne(e.id,[new N({text:mt(e.caption,s.numbers.get(e))})])})],pt(e,n),...me()];case"pagebreak":return[new M({spacing:{before:0,after:0,line:20,lineRule:t.LineRuleType.EXACT},children:[new t.PageBreak]})];case"bibliography":{const{page:T}=s,u=T.textIndent>0?Math.round(T.textIndent*T.size*20):480;return s.sources.map(_=>new M({...k(n),alignment:E.LEFT,indent:{left:n.indent+u,hanging:u},spacing:{after:L(v.after)},children:_.pieces.map($=>{const c=$.italic?{italics:!0}:{};return new N({text:$.text,...c})})}))}case"toc":{const T=e.levels??3,u=s.headings.filter(c=>c.level<=T).map(c=>{const b=s.anchors.get(c)??"",x=i.headingPage?.(b),B=s.bookmarks.get(b);return{title:c.content.map(X=>X.text).join(""),level:c.level,...x===void 0?{}:{page:x},...B===void 0?{}:{href:B}}}),_=Math.min(...u.map(c=>c.level)),$=yn(e,s.chinese);return[...$===""?[]:[new M({style:Wt,text:$})],new t.TableOfContents(void 0,{hyperlink:!0,headingStyleRange:`1-${String(T)}`,beginDirty:!1,cachedEntries:u.map(c=>({...c,level:c.level-_+1}))})]}case"note":return[];case"divider":return[new M({...k(n),spacing:{before:L(v.divider),after:L(v.divider),line:20,lineRule:t.LineRuleType.EXACT},border:{bottom:{style:r.SINGLE,color:je,size:4,space:0}}})];case"embed":{const T=/^<\s*([A-Za-z][\w.]*)/.exec(e.source.trim())?.[1],u=Le(r.DASHED,ke);return[new M({...k(n),alignment:E.CENTER,border:{top:u,bottom:u,left:u,right:u},children:[new N({text:T??"",color:Ce})]})]}case"source":return[];case"comment":return[];case"bullet":case"numbered":case"check":return[]}};function F(e,n){const a=[];let p,m;for(const y of e){if(!Ai(y)){p=void 0,m=void 0,a.push(...ve(y,n));continue}if(p===void 0||m===void 0||m.type==="numbered"!=(y.type==="numbered")){const T=y.type==="numbered"?y.start??1:1;Ne.add(T),p={id:++ut,start:T}}m=y,a.push(...Re(y,n,p))}return a.flatMap((y,T)=>y instanceof S&&a[T+1]instanceof S?[y,ae(0)]:[y])}return{charts:Ee,commentParagraphs:ft,tableStyles:ze,moves:V,body:(e,n)=>F(e,Ke(n)),footnotes:e=>Object.fromEntries([...Ge(e)].flatMap(n=>{if(n.type!=="note")return[];const a=A.get(n.label.toLowerCase());if(a===void 0)return[];const p=F(n.children??[],Ke(ue(s.page.width)-ue(s.page.margins.left+s.page.margins.right))).filter(m=>m instanceof M);return[[String(a),{children:[new M({spacing:{after:40},children:oe(n.content,{size:18,color:_e})}),...p]}]]})),numbering:()=>[{reference:Bt,levels:Array.from({length:9},(e,n)=>({level:n,format:t.LevelFormat.BULLET,text:s.lists?.bullets?.[Math.min(n,5)]??Un[n%3]??"•",alignment:E.LEFT,style:{paragraph:{indent:{left:(n+1)*We,hanging:We}}}}))},...[...Ne].sort((e,n)=>e-n).map(e=>({reference:`start-${String(e)}`,levels:Array.from({length:9},(n,a)=>{const p=Math.min(a+1,6),m=Pt(s.lists?.numbered,p),y=new Map([1,2,3,4,5,6].map(u=>[u,wt(Pt(s.lists?.numbered,u),u)])),T=Ct(m,p,y);return{level:a,format:bt[wt(m,p)],text:a<6?T.text:`%${String(a+1)}.`,alignment:E.LEFT,...T.legal?{isLegalNumberingStyle:!0}:{},...a===0?{start:e}:{},style:{paragraph:{indent:{left:(a+1)*We,hanging:We}}}}})}))]}}const Mi="1980-01-01T00:00:00Z",De=9525,Tt="http://schemas.openxmlformats.org/officeDocument/2006/relationships",$i=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");function bi(t,i,h,d,A){let z=0,s=0;const E=new Set;t.forEach((r,l)=>{const g=String(l+1),S=`rIdChart${g}`,R=`Microsoft_Excel_Worksheet${g}.xlsx`,f=Rt(r.chart.type),O=f?`chartEx${String(++z)}.xml`:`chart${String(++s)}.xml`;A(`word/charts/${O}`,f?dn(r.chart,"rId1",{frameless:!0}):ln(r.chart,{width:r.width*.75,height:r.height*.75},"rId1",{frameless:!0}));let N="";f&&(A(`word/charts/style${g}.xml`,sn(r.chart.type)),A(`word/charts/colors${g}.xml`,an()),N=`<Relationship Id="rId2" Type="${Jt}" Target="style${g}.xml"/><Relationship Id="rId3" Type="${Vt}" Target="colors${g}.xml"/>`,d=d.replace("</Types>",`<Override ContentType="${en}" PartName="/word/charts/style${g}.xml"/><Override ContentType="${Qt}" PartName="/word/charts/colors${g}.xml"/></Types>`)),A(`word/charts/_rels/${O}.rels`,`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
5
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="${Tt}/package" Target="../embeddings/${R}"/>${N}</Relationships>`),A(`word/embeddings/${R}`,rn(r.chart)),h=h.replace("</Relationships>",`<Relationship Id="${S}" Type="${f?Zt:`${Tt}/chart`}" Target="charts/${O}"/></Relationships>`),d=d.replace("</Types>",`<Override ContentType="${f?tn:"application/vnd.openxmlformats-officedocument.drawingml.chart+xml"}" PartName="/word/charts/${O}"/></Types>`);const C=String(r.width*De),K=String(r.height*De),pe=(V,I="")=>`<w:drawing><wp:inline distT="0" distB="0" distL="0" distR="0"><wp:extent cx="${C}" cy="${K}"/><wp:effectExtent l="0" t="0" r="0" b="0"/><wp:docPr id="0" name="Chart ${g}" descr="${$i(r.words)}"/><wp:cNvGraphicFramePr>${I}</wp:cNvGraphicFramePr><a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">${V}</a:graphic></wp:inline></w:drawing>`;let D;const G=r.fallback;if(G){const V=`rIdChartPicture${g}`;A(`word/media/chart${g}.${G.type}`,G.data),E.add(G.type),h=h.replace("</Relationships>",`<Relationship Id="${V}" Type="${Tt}/image" Target="media/chart${g}.${G.type}"/></Relationships>`),D=pe(`<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:nvPicPr><pic:cNvPr id="0" name="Chart ${g}"/><pic:cNvPicPr/></pic:nvPicPr><pic:blipFill><a:blip r:embed="${V}"/><a:stretch><a:fillRect/></a:stretch></pic:blipFill><pic:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${C}" cy="${K}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></pic:spPr></pic:pic></a:graphicData>`,'<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1"/>')}else D="<w:t>This chart isn't available in your version of Word.</w:t>";const ge=f?`<w:r><mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"><mc:Choice xmlns:${ht(r.chart.type).prefix}="${ht(r.chart.type).namespace}" Requires="${ht(r.chart.type).prefix}">${pe(`<a:graphicData uri="${nn}">${on(S)}</a:graphicData>`)}</mc:Choice><mc:Fallback>${D}</mc:Fallback></mc:AlternateContent></w:r>`:`<w:r>${pe(`<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart"><c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" r:id="${S}"/></a:graphicData>`)}</w:r>`;i=i.replace(new RegExp(`<w:r>(?:(?!<w:r>).)*?<w:t[^>]*>${Ut}${g}</w:t></w:r>`,"su"),ge)});for(const r of E)d.includes(`Extension="${r}"`)||(d=d.replace("</Types>",`<Default ContentType="${r==="jpg"?"image/jpeg":`image/${r}`}" Extension="${r}"/></Types>`));return t.length>0&&!d.includes('Extension="xlsx"')&&(d=d.replace("</Types>",'<Default ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" Extension="xlsx"/></Types>')),{document:i,rels:h,types:d}}export function movesXml(t,i){if(i.size===0)return t;const h=[];let d=t.replace(/<(\/?)w:(ins|del)\b([^>]*?)(\/?)>/gu,(E,r,l,g,S)=>{if(r!=="")return`</w:${h.pop()??l}>`;const f=i.get(Number(/w:id="(\d+)"/u.exec(g)?.[1]))===void 0?l:l==="ins"?"moveTo":"moveFrom";return S===""&&h.push(f),`<w:${f}${g}${S}>`});d=d.replace(/<w:moveFrom\b[^>]*[^/]>[\s\S]*?<\/w:moveFrom>/gu,E=>E.replace(/<(\/?)w:delText\b/gu,"<$1w:t").replace(/<(\/?)w:delInstrText\b/gu,"<$1w:instrText"));const A=new Map;for(const E of d.matchAll(/<w:(moveFrom|moveTo)\b([^>]*?)(\/?)>/gu)){const[,r="",l="",g=""]=E,S=E.index,R=i.get(Number(/w:id="(\d+)"/u.exec(l)?.[1]));if(R===void 0)continue;let f=S,O;g===""?O=d.indexOf(`</w:${r}>`,S)+`</w:${r}>`.length:(f=d.indexOf("</w:pPr>",S)+8,O=d.indexOf("</w:p>",f));const N=`${r}\0${R}`,C=A.get(N);A.set(N,{start:Math.min(C?.start??f,f),end:Math.max(C?.end??O,O),attrs:C?.attrs??l.replace(/\s*w:id="\d+"/u,"")})}const z=[];let s=0;for(const[E,r]of A){const[l="",g=""]=E.split("\0"),S=String(1e6+ ++s),R=g.replace(/[&<>"]/gu,f=>`&#${String(f.charCodeAt(0))};`);z.push({at:r.start,xml:`<w:${l}RangeStart w:id="${S}"${r.attrs} w:name="${R}"/>`},{at:r.end,xml:`<w:${l}RangeEnd w:id="${S}"/>`})}z.sort((E,r)=>r.at-E.at);for(const E of z)d=d.slice(0,E.at)+E.xml+d.slice(E.at);return d}function Pi(t,i,h,d=[],A=new Map,z={}){const s=i.unzipSync(t),E=I=>{const H=s[I];return H&&new TextDecoder().decode(H)},r=(I,H)=>{s[I]=typeof H=="string"?new TextEncoder().encode(H):H},l="word/document.xml",g="word/_rels/document.xml.rels",S="[Content_Types].xml",R=bi(h,E(l)??"",E(g)??"",E(S)??"",r);r(S,R.types);let f=R.document,O=R.rels;[...new Set([...f.matchAll(/w:hyperlink [^>]*r:id="([^"]+)"/g)].map(I=>I[1]??""))].forEach((I,H)=>{const U=`rIdLink${String(H+1)}`;f=f.split(`"${I}"`).join(`"${U}"`),O=O.split(`"${I}"`).join(`"${U}"`)});let C=0;f=f.replace(/<wp:docPr id="\d+"/g,()=>`<wp:docPr id="${String(++C)}"`);const K=new Map;f=f.replace(/<w:bookmarkStart w:name="([^"]*)" w:id="(\d+)"/g,(I,H,U)=>{const de=String(K.size+1);return K.set(U,de),`<w:bookmarkStart w:name="${H}" w:id="${de}"`}),f=f.replace(/<w:bookmarkEnd w:id="(\d+)"/g,(I,H)=>{const U=K.get(H);return U===void 0?I:`<w:bookmarkEnd w:id="${U}"`}),r(l,movesXml(f,A)),r(g,O);for(const I of Object.keys(s)){if(!/^word\/header\d+\.xml$/u.test(I))continue;let H=E(I)??"";const U=z.vml;U!==void 0&&(H=H.includes("</w:hdr>")?H.replace("</w:hdr>",`${U}</w:hdr>`):H.replace(/<w:hdr\b([^>]*?)\/>/u,(de,te)=>`<w:hdr${te}>${U}</w:hdr>`)),z.washout===!0&&(H=H.replace(new RegExp(`(<wp:docPr [^>]*name="${It}"(?:(?!</w:drawing>)[\\s\\S])*?<a:blip [^>]*?)(/>|>)`,"gu"),(de,te,re)=>`${te}>${si}${re==="/>"?"</a:blip>":""}`)),r(I,H)}const pe="word/styles.xml",D=E(pe);D!==void 0&&d.length>0&&r(pe,D.replace("</w:styles>",`${d.join("")}</w:styles>`));const G="docProps/core.xml",ge=E(G);ge!==void 0&&r(G,ge.replace(/(<dcterms:(?:created|modified)[^>]*>)[^<]*/g,`$1${Mi}`));const V=Object.fromEntries(Object.entries(s).sort(([I],[H])=>I<H?-1:1));return i.zipSync(V,{mtime:new Date(1980,0,1)})}const Ve=(t,i)=>{const h=lt[t];return{ascii:h.latin,hAnsi:h.latin,cs:h.latin,eastAsia:h.eastAsia??i}},Ci=(t,i)=>Object.hasOwn(lt,t)?Ve(t,i):{ascii:t,hAnsi:t,cs:t,eastAsia:t};export function wordProps(t,i,h,d){const A=R=>Math.round(R*h*20),z=W(i.color,Ae),s=W(i.background,be),E={...i.font===void 0?{}:{font:Ci(i.font,d)},...i.size===void 0?{}:{size:Math.round(at(i.size)*2)},...i.bold===void 0?{}:{bold:i.bold},...i.italic===void 0?{}:{italics:i.italic},...i.underline===!0?{underline:{}}:{},...i.strike===void 0?{}:{strike:i.strike},...z===void 0?{}:{color:z},...s===void 0?{}:{shading:{type:t.ShadingType.CLEAR,color:"auto",fill:s}},...i.caps===void 0?{}:{allCaps:i.caps},...i.smallCaps===void 0?{}:{smallCaps:i.smallCaps},...i.letterSpacing===void 0?{}:{characterSpacing:Math.round(i.letterSpacing*20)}},r=i.align===void 0?void 0:{left:t.AlignmentType.LEFT,center:t.AlignmentType.CENTER,right:t.AlignmentType.RIGHT,justify:t.AlignmentType.JUSTIFIED}[i.align],l={...i.indent===void 0?{}:{left:A(i.indent)},...i.indentRight===void 0?{}:{right:A(i.indentRight)},...i.firstLine===void 0?{}:i.firstLine<0?{hanging:A(-i.firstLine)}:{firstLine:A(i.firstLine)}},g={...i.spaceBefore===void 0?{}:{before:Math.round(i.spaceBefore*20)},...i.spaceAfter===void 0?{}:{after:Math.round(i.spaceAfter*20)},...i.lineHeight===void 0?{}:typeof i.lineHeight=="number"?{line:Math.round(i.lineHeight*240),lineRule:t.LineRuleType.AUTO}:{line:Math.round(parseFloat(i.lineHeight)*20),lineRule:t.LineRuleType.EXACT}},S={...r===void 0?{}:{alignment:r},...Object.keys(l).length===0?{}:{indent:l},...Object.keys(g).length===0?{}:{spacing:g},...i.keepNext===void 0?{}:{keepNext:i.keepNext},...i.keepLines===void 0?{}:{keepLines:i.keepLines},...i.pageBreakBefore===void 0?{}:{pageBreakBefore:i.pageBreakBefore}};return{run:E,paragraph:S}}function xi(t,i,h){const d={left:[],center:[],right:[]};i.left!==void 0&&d.left.push(i.left),i.center!==void 0&&d.center.push(i.center),i.right!==void 0&&d.right.push(i.right),i.outside!==void 0&&d[h.odd?"right":"left"].push(i.outside),i.inside!==void 0&&d[h.odd?"left":"right"].push(i.inside);const A={size:Math.round(h.size*2),color:h.color,font:Ve(h.face,h.eastAsia)},z=R=>R.split(/(\{title\}|\{section\}|\{page\}|\{pages\})/u).filter(f=>f!=="").map(f=>f==="{page}"?new t.TextRun({...A,children:[t.PageNumber.CURRENT]}):f==="{pages}"?new t.TextRun({...A,children:[t.PageNumber.TOTAL_PAGES]}):f==="{section}"?new t.SimpleField(`STYLEREF "heading ${String(h.section)}"`,""):new t.TextRun({...A,text:f==="{title}"?h.title:f})),s=R=>{const f=h.picture?.(R.picture);if(f===void 0)return[];const O=Math.round((R.height??Fn)/25.4*96);return[new t.ImageRun({...st(f),transformation:{width:Math.round(O*f.width/f.height),height:O},altText:{name:R.picture,title:R.picture,description:""}})]},E=R=>{const f=d[R].filter(C=>typeof C=="string"),O=d[R].filter(C=>typeof C!="string"),N=f.join(" ").split(`
6
+ `).map(z);return O.length>0?[O.flatMap(s),...f.length>0?N:[]]:N},r=E("left"),l=E("center"),g=E("right"),S=Math.max(r.length,l.length,g.length);return Array.from({length:S},(R,f)=>new t.Paragraph({style:h.style,tabStops:[{type:t.TabStopType.CENTER,position:Math.round(h.width/2)},{type:t.TabStopType.RIGHT,position:h.width}],children:[...r[f]??[],new t.TextRun({...A,children:[new t.Tab]}),...l[f]??[],new t.TextRun({...A,children:[new t.Tab]}),...g[f]??[]]}))}function Ni(t,i){const[h="",d,...A]=t.split(" ");return d===void 0||!["REF","PAGEREF","NOTEREF"].includes(h.toUpperCase())?t:[h,i.get(d)??d,...A].join(" ")}const jt=(t,i,h,d)=>({run:{...i?.font===void 0?{}:{font:Ve(t.font,h)},...i?.size===void 0?{}:{size:Math.round(t.size*2)},...i?.weight===void 0?{}:{bold:t.weight==="bold"},...i?.italic===void 0?{}:{italics:t.italic}},paragraph:i?.align===void 0?{}:{alignment:t.align==="center"?d.AlignmentType.CENTER:t.align==="right"?d.AlignmentType.RIGHT:d.AlignmentType.LEFT}});function zi(t){const i=new Map,h=new Set;return t.forEach((d,A)=>{const z=d.replace(/[^A-Za-z0-9_]/gu,"_").replace(/^[^A-Za-z]+/u,"");let s=`b_${z}`.slice(0,32);(h.has(s)||z==="")&&(s=`b_${String(A)}_${z}`.slice(0,40)),h.add(s),i.set(d,s)}),i}export async function docxOf(t,i,h,d={}){const A=d.page??{},z=gt(A).citationStyle??"apa",s=En(Qn(h,d),d.sources??[],z,"block"),E=An(h,d.sources??[],z),r=gt(A),l=rt(A),g=lt[l.font].eastAsia??wi(kn(s)),S=Ve(l.font,g),R=W($t(d.page),{}),f=$n(s),O=wn(s,A),N=new Map;for(const o of Ge(s)){const w=vt(o),P=O.get(o);w!==void 0&&P!==void 0&&N.set(w,P.label)}for(const[o,w]of f)o.type==="heading"&&N.set(w,o.content.map(P=>P.text).join(""));const{title:C}=_n(s),K=[...Ge(s)].filter(o=>o.type==="heading"&&o!==C),pe=zi([...f.values(),...[...Ge(s)].flatMap(o=>{const w=vt(o);return w===void 0?[]:[w]})]),D=vi(s),G=Si(t,d,g,R,ti(s),ei(s),{page:l,sets:{indent:r.textIndent!==void 0&&r.textIndent>0,align:r.textAlign==="justify"},numbers:O,refs:N,bookmarks:pe,anchors:f,title:C,headings:K,chinese:Tn(s),sources:E,comments:D,endnotes:r.notes==="end",lists:r.lists}),ge=Mn(s),V={width:ue(l.width),height:ue(l.height)},I=o=>{const w=rt(Mt(r,o)),P=w.margins,J=(k,ye)=>ue(Math.max(0,k-On(k)-In(ye,l.size))),ne=o.margins??r.margins,we=ne===void 0?Cn.margins:Pn(ne);return{top:ue(we.top),bottom:ue(we.bottom),left:ue(P.left),right:ue(P.right),...w.header===void 0?{}:{header:J(P.top,w.header)},...w.footer===void 0?{}:{footer:J(P.bottom,w.footer)}}},H=d.cover,U=s.flatMap(o=>o.type==="pagebreak"?[o.header,o.footer].filter(w=>w!==void 0&&w!==!1):[]),de=o=>s.flatMap(w=>{const P=w.type==="pagebreak"?w[o]:void 0;return P===void 0||P===!1?[]:[P]})[0],te=o=>l[o]!==void 0||de(o)!==void 0,re=[l.header,l.footer,...U].some(o=>o!==void 0&&(o.outside!==void 0||o.inside!==void 0||o.even!==void 0)),he=r.watermark,M=he!==void 0&&"picture"in he?d.picture?.(he.picture):void 0,xe=[];if(M!==void 0&&he!==void 0&&"picture"in he){const o=l.textWidth/25.4*96,w=he.scale===void 0?Math.min(M.width,o):M.width*he.scale/100;xe.push(new t.Paragraph({spacing:{before:0,after:0,line:20,lineRule:"exact"},children:[new t.ImageRun({...st(M),transformation:{width:Math.round(w),height:Math.round(w*M.height/M.width)},floating:{horizontalPosition:{relative:t.HorizontalPositionRelativeFrom.MARGIN,align:t.HorizontalPositionAlign.CENTER},verticalPosition:{relative:t.VerticalPositionRelativeFrom.MARGIN,align:t.VerticalPositionAlign.CENTER},allowOverlap:!0,behindDocument:!0,wrap:{type:t.TextWrappingType.NONE}},altText:{name:It,title:"",description:""}})]}))}const le=o=>new t.Header({children:[...o,...xe]}),Qe=ge.flatMap((o,w)=>Ei(o.blocks,o.columns).map((P,J)=>{const ne=I(o),we=o.landscape?V.height:V.width,k=we-ne.left-ne.right,ye=G.body(P.blocks,k);if(w===0&&J===0&&H){const F=Math.round(we/Xe);ye.unshift(new t.Paragraph({spacing:{before:0,after:0},children:[new t.ImageRun({...st(H),transformation:{width:F,height:Math.round(F*Zn)},floating:{horizontalPosition:{relative:t.HorizontalPositionRelativeFrom.PAGE,offset:0},verticalPosition:{relative:t.VerticalPositionRelativeFrom.PAGE,offset:0},allowOverlap:!1,margins:{bottom:324e3},wrap:{type:t.TextWrappingType.TOP_AND_BOTTOM}},altText:{name:"Cover",title:"Cover",description:""}})]}))}const Je=(F,e,n)=>{if(F===void 0)return;const a=(p,m=F)=>{const y=m.size??F.size;return xi(t,m,{picture:d.picture,style:n,odd:p,width:k,title:d.title??"",section:Math.min(...K.map(T=>T.level),6),face:m.font??F.font??l.font,eastAsia:g,size:y===void 0?Math.max(7.5,l.size*.75):at(y),color:e?Ce:Pe})};return{default:a(!0),...F.even!==void 0?{even:F.even===!1?null:a(!1,F.even)}:re?{even:a(!1)}:{},...F.first===void 0?{}:{first:F.first===!1?null:a(!0,F.first)}}},Be=Mt(r,o),et=w===0?l:rt(Be),tt=gt(Be),pt=F=>J===0&&(w===0||(o.opens??[]).includes(F)),$e=(F,e)=>{if(F===void 0||pt(e))return F;const n={...F};return delete n.first,n},Te=Je($e(et.header,"header"),tt.header===void 0,"Header"),Re=Je($e(et.footer,"footer"),tt.footer===void 0,"Footer"),nt=w===0&&J===0&&H!==void 0&&Te!==void 0,ve=J===0&&(nt||Te?.first!==void 0||Re?.first!==void 0),it=(F,e)=>F===void 0?[]:e||F.first===null?[]:F.first??F.default,Ue=r.grid===void 0?void 0:{type:t.DocumentGridType.LINES_AND_CHARS,linePitch:Math.round(Nn(l)*20),charSpace:Math.round(l.textWidth/25.4*72/r.grid.chars-l.size)*4096};return{properties:{page:{size:{width:Math.min(V.width,V.height),height:Math.max(V.width,V.height),...o.landscape||V.width>V.height?{orientation:t.PageOrientation.LANDSCAPE}:{}},margin:{...ne,header:Math.max(0,ne.top-ue(7)-Math.round(l.size*20*1.2)),footer:Math.max(0,ne.bottom-ue(7)-Math.round(l.size*20*1.2))}},...Ue===void 0?{}:{grid:Ue},...P.columns>1?{column:{count:P.columns,space:720,equalWidth:!0}}:{},...J>0&&P.continuous?{type:t.SectionType.CONTINUOUS}:{},...ve?{titlePage:!0}:{},...r.notes==="end"?{endnoteProperties:{position:t.EndnotePosition.DOCUMENT_END,numberFormat:{type:t.NumberFormat.DECIMAL}}}:{}},...Te===void 0?w>0&&te("header")||w===0&&he!==void 0?{headers:{default:le([]),...ve?{first:le([])}:{},...re?{even:le([])}:{}}}:{}:{headers:{default:le(Te.default),...Te.even===void 0?{}:{even:le(Te.even??[])},...ve?{first:le(it(Te,nt))}:{}}},...Re===void 0?w>0&&te("footer")?{footers:{default:new t.Footer({children:[]}),...ve?{first:new t.Footer({children:[]})}:{},...re?{even:new t.Footer({children:[]})}:{}}}:{}:{footers:{default:new t.Footer({children:Re.default}),...Re.even===void 0?{}:{even:new t.Footer({children:Re.even??[]})},...ve?{first:new t.Footer({children:it(Re,!1)})}:{}}},children:ye}})),Ne=l.lineHeight,ut={spacing:{after:Math.round(l.paragraphSpacing*l.size*20),..."pt"in Ne?{line:Math.round(Ne.pt*20),lineRule:t.LineRuleType.EXACT}:{line:Math.round(Ne.multiple*240),lineRule:t.LineRuleType.AUTO}}},Ee=l.spacing,ze=o=>Math.round(o*20),Q=o=>{const w=r.headings?.[o],P=jt(l.headings[o],w,g,t);return{run:{size:Math.round(l.headings[o].size*2),bold:!0,font:S,color:Pe,...P.run},paragraph:{spacing:{before:ze(Ee.heading.before),after:ze(Ee.heading.after)},keepNext:!0,keepLines:!0,...l.headings[o].rule?{border:{bottom:{style:t.BorderStyle.SINGLE,size:4,color:je,space:Rn}}}:{},...P.paragraph}}},Le=jt(l.title,r.title,g,t),v=A.styles??{},L=o=>wordProps(t,jn(v,o),at(l.size),g),ae=(o,w)=>{if(v[w]===void 0)return o;const P=L(w);return{...o,run:{...o.run,...P.run},paragraph:{...o.paragraph,...P.paragraph,...o.paragraph?.spacing!==void 0&&P.paragraph.spacing!==void 0?{spacing:{...o.paragraph.spacing,...P.paragraph.spacing}}:{}}}},me=Gn(v),He=new Map([...me].map(([o,w])=>[o,wt(w,o)])),Fe=me.size===0?[]:[{reference:Dt,levels:[1,2,3,4,5,6].map(o=>{const w=me.get(o),P=w&&Ct(w,o,He);return{level:o-1,format:bt[He.get(o)??"decimal"],text:P?.text??"",alignment:t.AlignmentType.LEFT,suffix:t.LevelSuffix.SPACE,...P?.legal===!0?{isLegalNumberingStyle:!0}:{}}})}],Z=(o,w)=>me.has(w)?{...o,paragraph:{...o.paragraph,numbering:{reference:Dt,level:w-1}}}:o,Ze={paragraph:Object.entries(v).flatMap(([o,w])=>{if(w.type==="character"||w.type==="table"||xt.includes(o))return[];const P=L(o);return[{id:Ie(o),name:o,basedOn:dt(w.basedOn??Nt),...w.next===void 0?{}:{next:dt(w.next)},quickFormat:!0,run:P.run,paragraph:P.paragraph}]}),character:Object.entries(v).flatMap(([o,w])=>w.type!=="character"?[]:[{id:Ie(o),name:o,...w.basedOn===void 0?{}:{basedOn:Ie(w.basedOn)},quickFormat:!0,run:L(o).run}])},oe=new t.Document({creator:"AllyHub",lastModifiedBy:"AllyHub",...d.title===void 0?{}:{title:d.title},...re?{evenAndOddHeaderAndFooters:!0}:{},compatibility:{underlineTrailingSpaces:!0},numbering:{config:[...G.numbering(),...Fe]},styles:{default:{document:ae({run:{font:S,size:Math.round(l.size*2),color:Pe},paragraph:ut},Nt),hyperlink:{run:{color:R??Pe,underline:{color:R??qe}}},title:ae({run:{size:Math.round(l.title.size*2),bold:!0,font:S,color:Pe,...Le.run},paragraph:{spacing:{before:0,after:ze(Ee.title)},keepNext:!0,...Le.paragraph}},Xn),heading1:Z(ae(Q(1),Oe(1)),1),heading2:Z(ae(Q(2),Oe(2)),2),heading3:Z(ae(Q(3),Oe(3)),3),heading4:Z(ae(Q(4),Oe(4)),4),heading5:Z(ae(Q(5),Oe(5)),5),heading6:Z(ae(Q(6),Oe(6)),6)},characterStyles:Ze.character,paragraphStyles:[...Ze.paragraph,{id:Wt,name:"TOC Heading",basedOn:"Normal",next:"Normal",quickFormat:!0,...Q(1)},{id:"Caption",name:"caption",basedOn:"Normal",next:"Normal",quickFormat:!0,run:{size:Ee.small*2,color:Ce},paragraph:{spacing:{before:0}}},{id:Ht,name:"List Paragraph",basedOn:"Normal",quickFormat:!0,paragraph:{contextualSpacing:!0}},...[["Header",l.header??de("header"),r.header===void 0],["Footer",l.footer??de("footer"),r.footer===void 0]].flatMap(([o,w,P])=>w===void 0?[]:[{id:o,name:o.toLowerCase(),basedOn:"Normal",run:{size:Math.round((w.size===void 0?Math.max(7.5,l.size*.75):at(w.size))*2),color:P?Ce:Pe,font:Ve(w.font??l.font,g)},paragraph:{spacing:{before:0,after:0,line:240}}}])]},sections:Qe,...r.track===!0?{features:{trackRevisions:!0}}:{},...r.notes==="end"?{endnotes:G.footnotes(s)}:{footnotes:G.footnotes(s)},...D.ids.size===0?{}:{comments:{children:s.flatMap(o=>{if(o.type!=="comment")return[];const w=D.ids.get(o.id);if(w===void 0)return[];const P=o.replyTo===void 0?void 0:D.ids.get(o.replyTo),J=o.date===void 0?void 0:new Date(o.date);return[{id:w,author:o.author,initials:Ri(o.author),...J===void 0||Number.isNaN(J.getTime())?{}:{date:J},...P===void 0?{}:{parentId:P},...o.done===!0?{resolved:!0}:{},children:G.commentParagraphs(o)}]})}}}),ft=await t.Packer.toBuffer(oe);return Pi(new Uint8Array(ft),i,G.charts,[...G.tableStyles].map(o=>ui(o,zt(r.styles,o))),G.moves,r.watermark===void 0?{}:"picture"in r.watermark?{washout:r.watermark.washout===!0}:{vml:li(r.watermark,rt(r))})}