ooxml-core 1.30.1 → 1.32.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 (418) hide show
  1. package/dist/{PptxHandler-KKLAYUGQ.mjs → PptxHandler-QY5VL3CY.mjs} +2 -2
  2. package/dist/PptxHandler-SJ5ZUIUX.mjs +4 -0
  3. package/dist/{PptxHandler-DHQPVTUI.cjs → PptxHandler-TESZUH66.cjs} +3 -3
  4. package/dist/{PresentationBuilder-YYZYCKTZ.mjs → PresentationBuilder-3CH5TR4W.mjs} +2 -2
  5. package/dist/{PresentationBuilder-JORMF5CP.cjs → PresentationBuilder-5NFBUP7Y.cjs} +5 -5
  6. package/dist/{PresentationBuilder-Q2Z33LLM.mjs → PresentationBuilder-S6HXHKEJ.mjs} +2 -2
  7. package/dist/automation/index.cjs +6446 -3410
  8. package/dist/automation/index.mjs +6446 -3410
  9. package/dist/automation/node.cjs +2 -1
  10. package/dist/automation/node.d.ts.map +1 -1
  11. package/dist/automation/node.mjs +2 -1
  12. package/dist/automation/tools/define.d.ts +2 -0
  13. package/dist/automation/tools/define.d.ts.map +1 -1
  14. package/dist/automation/tools/types.d.ts +6 -0
  15. package/dist/automation/tools/types.d.ts.map +1 -1
  16. package/dist/{chunk-GJDFCP2T.mjs → chunk-3H5UAJB3.mjs} +258 -155
  17. package/dist/{chunk-MKDONWNO.mjs → chunk-4R65YYAD.mjs} +32 -14
  18. package/dist/{chunk-KWJYMAEF.mjs → chunk-IOTGRLJH.mjs} +255 -152
  19. package/dist/{chunk-6FXOAMNL.mjs → chunk-N6424WKA.mjs} +1 -1
  20. package/dist/{chunk-WZJ25K7P.mjs → chunk-NAWLWKOJ.mjs} +1 -1
  21. package/dist/{chunk-DJ3CDTMX.mjs → chunk-O7SVHLD7.mjs} +23 -5
  22. package/dist/{chunk-CZXM4ZJH.cjs → chunk-Q6NM64J2.cjs} +23 -4
  23. package/dist/{chunk-FFJBOR2Y.mjs → chunk-UYMSFJQZ.mjs} +76 -4
  24. package/dist/{chunk-B4LXDHBX.cjs → chunk-X6VNUBES.cjs} +1419 -1316
  25. package/dist/collab/index.cjs +35 -4
  26. package/dist/collab/index.mjs +35 -4
  27. package/dist/collab/websocket-transport.d.ts +9 -1
  28. package/dist/collab/websocket-transport.d.ts.map +1 -1
  29. package/dist/diagram/index.cjs +8 -4
  30. package/dist/diagram/index.mjs +8 -4
  31. package/dist/docx/data-binding.d.ts +9 -0
  32. package/dist/docx/data-binding.d.ts.map +1 -0
  33. package/dist/docx/document-parts.d.ts +1 -0
  34. package/dist/docx/document-parts.d.ts.map +1 -1
  35. package/dist/docx/drawing.d.ts.map +1 -1
  36. package/dist/docx/embedded.cjs +1391 -613
  37. package/dist/docx/embedded.mjs +1391 -613
  38. package/dist/docx/index.cjs +1402 -622
  39. package/dist/docx/index.mjs +1402 -622
  40. package/dist/docx/inline-model.d.ts +2 -0
  41. package/dist/docx/inline-model.d.ts.map +1 -1
  42. package/dist/docx/layout/adapt-floats.d.ts.map +1 -1
  43. package/dist/docx/layout/adapt-table.d.ts.map +1 -1
  44. package/dist/docx/layout/adapter.d.ts.map +1 -1
  45. package/dist/docx/layout/equation-object.d.ts +1 -1
  46. package/dist/docx/layout/equation-object.d.ts.map +1 -1
  47. package/dist/docx/layout/floats.d.ts +1 -1
  48. package/dist/docx/layout/floats.d.ts.map +1 -1
  49. package/dist/docx/layout/flow-paragraph.d.ts +4 -0
  50. package/dist/docx/layout/flow-paragraph.d.ts.map +1 -1
  51. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  52. package/dist/docx/layout/index.cjs +460 -207
  53. package/dist/docx/layout/index.mjs +460 -207
  54. package/dist/docx/layout/input.d.ts +12 -0
  55. package/dist/docx/layout/input.d.ts.map +1 -1
  56. package/dist/docx/layout/nested-frame-profile.d.ts +3 -1
  57. package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -1
  58. package/dist/docx/layout/page-cursor.d.ts +11 -2
  59. package/dist/docx/layout/page-cursor.d.ts.map +1 -1
  60. package/dist/docx/layout/paragraph-fragments.d.ts.map +1 -1
  61. package/dist/docx/layout/paragraph-layout.d.ts +5 -0
  62. package/dist/docx/layout/paragraph-layout.d.ts.map +1 -1
  63. package/dist/docx/layout/result.d.ts +4 -0
  64. package/dist/docx/layout/result.d.ts.map +1 -1
  65. package/dist/docx/layout/section-flow.d.ts +2 -0
  66. package/dist/docx/layout/section-flow.d.ts.map +1 -1
  67. package/dist/docx/layout/table-layout.d.ts +4 -14
  68. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  69. package/dist/docx/layout/table-merged-rows.d.ts +21 -0
  70. package/dist/docx/layout/table-merged-rows.d.ts.map +1 -0
  71. package/dist/docx/layout/table-row-split.d.ts +16 -0
  72. package/dist/docx/layout/table-row-split.d.ts.map +1 -0
  73. package/dist/docx/layout/wrap.d.ts +2 -0
  74. package/dist/docx/layout/wrap.d.ts.map +1 -1
  75. package/dist/docx/load/index.cjs +1405 -627
  76. package/dist/docx/load/index.mjs +1405 -627
  77. package/dist/docx/model-paragraph.d.ts +4 -1
  78. package/dist/docx/model-paragraph.d.ts.map +1 -1
  79. package/dist/docx/model.d.ts +24 -1
  80. package/dist/docx/model.d.ts.map +1 -1
  81. package/dist/docx/paragraph-properties.d.ts.map +1 -1
  82. package/dist/docx/paragraph-styles.d.ts.map +1 -1
  83. package/dist/docx/parse-table.d.ts.map +1 -1
  84. package/dist/docx/parse.d.ts.map +1 -1
  85. package/dist/docx/run-segmentation.d.ts.map +1 -1
  86. package/dist/docx/save-modified.d.ts +4 -0
  87. package/dist/docx/save-modified.d.ts.map +1 -0
  88. package/dist/docx/save.d.ts +2 -2
  89. package/dist/docx/save.d.ts.map +1 -1
  90. package/dist/docx/style-formatting-package.d.ts +9 -0
  91. package/dist/docx/style-formatting-package.d.ts.map +1 -0
  92. package/dist/docx/style-numbering-package.d.ts +4 -1
  93. package/dist/docx/style-numbering-package.d.ts.map +1 -1
  94. package/dist/docx/table-grid.d.ts +35 -0
  95. package/dist/docx/table-grid.d.ts.map +1 -0
  96. package/dist/docx/table-structure-cells.d.ts +19 -0
  97. package/dist/docx/table-structure-cells.d.ts.map +1 -0
  98. package/dist/docx/table-structure-check.d.ts +12 -0
  99. package/dist/docx/table-structure-check.d.ts.map +1 -0
  100. package/dist/docx/table-structure-merge.d.ts +28 -0
  101. package/dist/docx/table-structure-merge.d.ts.map +1 -0
  102. package/dist/docx/table-structure.d.ts +30 -0
  103. package/dist/docx/table-structure.d.ts.map +1 -0
  104. package/dist/docx/ui/index.cjs +725 -260
  105. package/dist/docx/ui/index.d.ts +4 -0
  106. package/dist/docx/ui/index.d.ts.map +1 -1
  107. package/dist/docx/ui/index.mjs +711 -261
  108. package/dist/docx/ui/ribbon-action-ids.d.ts +1 -1
  109. package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -1
  110. package/dist/docx/ui/table-structure-guard.d.ts +2 -0
  111. package/dist/docx/ui/table-structure-guard.d.ts.map +1 -1
  112. package/dist/docx/word-content-control-docs.d.ts +5 -0
  113. package/dist/docx/word-content-control-docs.d.ts.map +1 -0
  114. package/dist/docx/word-corpus-gaps.d.ts +10 -0
  115. package/dist/docx/word-corpus-gaps.d.ts.map +1 -0
  116. package/dist/docx/word-measurer.d.ts +6 -0
  117. package/dist/docx/word-measurer.d.ts.map +1 -0
  118. package/dist/docx/word-spacing-docs.d.ts +12 -0
  119. package/dist/docx/word-spacing-docs.d.ts.map +1 -0
  120. package/dist/docx/word-table-docs.d.ts +9 -0
  121. package/dist/docx/word-table-docs.d.ts.map +1 -0
  122. package/dist/docx/write-drawing.d.ts.map +1 -1
  123. package/dist/docx/write-fallback.d.ts +5 -0
  124. package/dist/docx/write-fallback.d.ts.map +1 -0
  125. package/dist/docx/write-table-properties.d.ts +1 -0
  126. package/dist/docx/write-table-properties.d.ts.map +1 -1
  127. package/dist/docx/write-table-structure.d.ts +14 -0
  128. package/dist/docx/write-table-structure.d.ts.map +1 -0
  129. package/dist/docx/write-table.d.ts +3 -4
  130. package/dist/docx/write-table.d.ts.map +1 -1
  131. package/dist/geometry/index.cjs +16 -12
  132. package/dist/geometry/index.mjs +16 -12
  133. package/dist/geometry/preset-shape-definitions-table.d.ts.map +1 -1
  134. package/dist/index.cjs +38 -34
  135. package/dist/index.mjs +38 -34
  136. package/dist/math/index.cjs +22 -22
  137. package/dist/math/index.mjs +22 -22
  138. package/dist/math/omml-box-grouped.d.ts.map +1 -1
  139. package/dist/math/omml-box-layout.d.ts +3 -1
  140. package/dist/math/omml-box-layout.d.ts.map +1 -1
  141. package/dist/math/omml-box-structures.d.ts.map +1 -1
  142. package/dist/math/omml-box.d.ts +2 -0
  143. package/dist/math/omml-box.d.ts.map +1 -1
  144. package/dist/math/omml-svg.d.ts +6 -2
  145. package/dist/math/omml-svg.d.ts.map +1 -1
  146. package/dist/pptx/automation/index.cjs +295 -157
  147. package/dist/pptx/automation/index.d.ts +9 -3
  148. package/dist/pptx/automation/index.d.ts.map +1 -1
  149. package/dist/pptx/automation/index.mjs +6 -5
  150. package/dist/pptx/chunks/{index-PdM5zpmu.d.ts → index-D-FdgqrP.d.ts} +102 -3
  151. package/dist/pptx/chunks/index-D-FdgqrP.d.ts.map +1 -0
  152. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts → index-DKybuHPT.d.ts} +51 -3
  153. package/dist/pptx/chunks/{index-BQDcu_0a.d.ts.map → index-DKybuHPT.d.ts.map} +1 -1
  154. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts → index-DnWlmYCy.d.ts} +2 -2
  155. package/dist/pptx/chunks/{index-CBV1oHN7.d.ts.map → index-DnWlmYCy.d.ts.map} +1 -1
  156. package/dist/pptx/cli/index.cjs +294 -157
  157. package/dist/pptx/cli/index.mjs +4 -4
  158. package/dist/pptx/converter/index.cjs +8 -4
  159. package/dist/pptx/converter/index.d.ts +1 -1
  160. package/dist/pptx/converter/index.mjs +2 -2
  161. package/dist/pptx/editor/render/find-replace.cjs +14 -14
  162. package/dist/pptx/editor/render/find-replace.d.ts +1 -1
  163. package/dist/pptx/editor/render/find-replace.mjs +1 -1
  164. package/dist/pptx/editor/render/slide-operations.cjs +8 -8
  165. package/dist/pptx/editor/render/slide-operations.mjs +2 -2
  166. package/dist/pptx/index.cjs +380 -171
  167. package/dist/pptx/index.d.ts +4 -4
  168. package/dist/pptx/index.mjs +5 -5
  169. package/dist/pptx/node/index.d.ts +1 -1
  170. package/dist/teams/chat-rooms.d.ts.map +1 -1
  171. package/dist/teams/chat-view.d.ts +10 -1
  172. package/dist/teams/chat-view.d.ts.map +1 -1
  173. package/dist/teams/chat.d.ts +7 -0
  174. package/dist/teams/chat.d.ts.map +1 -1
  175. package/dist/teams/files.d.ts +1 -1
  176. package/dist/teams/files.d.ts.map +1 -1
  177. package/dist/teams/index.cjs +3471 -1223
  178. package/dist/teams/index.d.ts +4 -0
  179. package/dist/teams/index.d.ts.map +1 -1
  180. package/dist/teams/index.mjs +3435 -1223
  181. package/dist/teams/message-transfer.d.ts +1 -1
  182. package/dist/teams/message-transfer.d.ts.map +1 -1
  183. package/dist/teams/presence-controller.d.ts +18 -3
  184. package/dist/teams/presence-controller.d.ts.map +1 -1
  185. package/dist/teams/presence-meetings.d.ts +21 -0
  186. package/dist/teams/presence-meetings.d.ts.map +1 -0
  187. package/dist/teams/presence.d.ts +40 -2
  188. package/dist/teams/presence.d.ts.map +1 -1
  189. package/dist/teams/protocol.d.ts +30 -0
  190. package/dist/teams/protocol.d.ts.map +1 -0
  191. package/dist/teams/schema.d.ts +59 -0
  192. package/dist/teams/schema.d.ts.map +1 -0
  193. package/dist/teams/server-config.d.ts +19 -2
  194. package/dist/teams/server-config.d.ts.map +1 -1
  195. package/dist/teams/server-file-storage.d.ts +11 -1
  196. package/dist/teams/server-file-storage.d.ts.map +1 -1
  197. package/dist/teams/server-session.d.ts +2 -0
  198. package/dist/teams/server-session.d.ts.map +1 -1
  199. package/dist/teams/signaling.d.ts +2 -0
  200. package/dist/teams/signaling.d.ts.map +1 -1
  201. package/dist/teams/store.d.ts +14 -0
  202. package/dist/teams/store.d.ts.map +1 -1
  203. package/dist/teams/stored-file.d.ts +1 -1
  204. package/dist/teams/stored-file.d.ts.map +1 -1
  205. package/dist/teams/sync-transport.d.ts.map +1 -1
  206. package/dist/teams/validate-members.d.ts +28 -0
  207. package/dist/teams/validate-members.d.ts.map +1 -0
  208. package/dist/teams/validate-owned.d.ts +20 -0
  209. package/dist/teams/validate-owned.d.ts.map +1 -0
  210. package/dist/teams/validate-update.d.ts +70 -0
  211. package/dist/teams/validate-update.d.ts.map +1 -0
  212. package/dist/teams/view.d.ts +5 -0
  213. package/dist/teams/view.d.ts.map +1 -1
  214. package/dist/teams/workspace.d.ts +17 -2
  215. package/dist/teams/workspace.d.ts.map +1 -1
  216. package/dist/visio/connector-route-walk.d.ts +2 -0
  217. package/dist/visio/connector-route-walk.d.ts.map +1 -1
  218. package/dist/visio/edit-connector-reroute.d.ts.map +1 -1
  219. package/dist/visio/edit-connector.d.ts +2 -0
  220. package/dist/visio/edit-connector.d.ts.map +1 -1
  221. package/dist/visio/edit-delete.d.ts.map +1 -1
  222. package/dist/visio/edit-duplicate-line.d.ts +40 -0
  223. package/dist/visio/edit-duplicate-line.d.ts.map +1 -0
  224. package/dist/visio/edit-duplicate.d.ts.map +1 -1
  225. package/dist/visio/edit-formatting-scope.d.ts +5 -1
  226. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  227. package/dist/visio/edit-geometry.d.ts.map +1 -1
  228. package/dist/visio/edit-instance-duplicate.d.ts +2 -1
  229. package/dist/visio/edit-instance-duplicate.d.ts.map +1 -1
  230. package/dist/visio/edit-master-move.d.ts.map +1 -1
  231. package/dist/visio/edit-recalculate-index.d.ts +23 -0
  232. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  233. package/dist/visio/edit-recalculate-text.d.ts +12 -0
  234. package/dist/visio/edit-recalculate-text.d.ts.map +1 -0
  235. package/dist/visio/edit-recalculate-values.d.ts.map +1 -1
  236. package/dist/visio/edit-recalculate.d.ts +15 -3
  237. package/dist/visio/edit-recalculate.d.ts.map +1 -1
  238. package/dist/visio/edit-resize-anchor.d.ts.map +1 -1
  239. package/dist/visio/edit-stencil-connector-layout.d.ts +1 -1
  240. package/dist/visio/edit-stencil-connector-layout.d.ts.map +1 -1
  241. package/dist/visio/edit-text-scope.d.ts +4 -1
  242. package/dist/visio/edit-text-scope.d.ts.map +1 -1
  243. package/dist/visio/formula-analyze.d.ts +18 -0
  244. package/dist/visio/formula-analyze.d.ts.map +1 -0
  245. package/dist/visio/formula-bound.d.ts +4 -0
  246. package/dist/visio/formula-bound.d.ts.map +1 -0
  247. package/dist/visio/formula-evaluate.d.ts +2 -9
  248. package/dist/visio/formula-evaluate.d.ts.map +1 -1
  249. package/dist/visio/formula-extra-functions.d.ts +23 -0
  250. package/dist/visio/formula-extra-functions.d.ts.map +1 -0
  251. package/dist/visio/formula-indirect.d.ts +6 -0
  252. package/dist/visio/formula-indirect.d.ts.map +1 -0
  253. package/dist/visio/formula-master.d.ts +1 -0
  254. package/dist/visio/formula-master.d.ts.map +1 -1
  255. package/dist/visio/formula-operators.d.ts +6 -0
  256. package/dist/visio/formula-operators.d.ts.map +1 -0
  257. package/dist/visio/formula-text-functions.d.ts +5 -1
  258. package/dist/visio/formula-text-functions.d.ts.map +1 -1
  259. package/dist/visio/formula.d.ts +12 -0
  260. package/dist/visio/formula.d.ts.map +1 -1
  261. package/dist/visio/index.cjs +1359 -396
  262. package/dist/visio/index.mjs +1359 -396
  263. package/dist/visio/ui/index.cjs +1346 -383
  264. package/dist/visio/ui/index.mjs +1346 -383
  265. package/dist/xlsx/collab/apply.d.ts.map +1 -1
  266. package/dist/xlsx/collab/codec.d.ts +2 -0
  267. package/dist/xlsx/collab/codec.d.ts.map +1 -1
  268. package/dist/xlsx/collab/dirty.d.ts +4 -1
  269. package/dist/xlsx/collab/dirty.d.ts.map +1 -1
  270. package/dist/xlsx/collab/index.cjs +551 -106
  271. package/dist/xlsx/collab/index.mjs +551 -106
  272. package/dist/xlsx/collab/keyed.d.ts +36 -0
  273. package/dist/xlsx/collab/keyed.d.ts.map +1 -0
  274. package/dist/xlsx/collab/names.d.ts +2 -0
  275. package/dist/xlsx/collab/names.d.ts.map +1 -1
  276. package/dist/xlsx/collab/part-specs.d.ts +13 -0
  277. package/dist/xlsx/collab/part-specs.d.ts.map +1 -0
  278. package/dist/xlsx/collab/schema.d.ts +8 -0
  279. package/dist/xlsx/collab/schema.d.ts.map +1 -1
  280. package/dist/xlsx/collab/sheet-parts.d.ts +19 -0
  281. package/dist/xlsx/collab/sheet-parts.d.ts.map +1 -0
  282. package/dist/xlsx/collab/sheets.d.ts +6 -0
  283. package/dist/xlsx/collab/sheets.d.ts.map +1 -1
  284. package/dist/xlsx/collab/write.d.ts +3 -0
  285. package/dist/xlsx/collab/write.d.ts.map +1 -1
  286. package/dist/xlsx/edit/clipboard-areas.d.ts +17 -0
  287. package/dist/xlsx/edit/clipboard-areas.d.ts.map +1 -0
  288. package/dist/xlsx/edit/custom-views.d.ts +21 -0
  289. package/dist/xlsx/edit/custom-views.d.ts.map +1 -0
  290. package/dist/xlsx/edit/data-table.d.ts.map +1 -1
  291. package/dist/xlsx/edit/history.d.ts +1 -1
  292. package/dist/xlsx/edit/history.d.ts.map +1 -1
  293. package/dist/xlsx/edit/index.d.ts +2 -0
  294. package/dist/xlsx/edit/index.d.ts.map +1 -1
  295. package/dist/xlsx/edit/paste-selection.d.ts.map +1 -1
  296. package/dist/xlsx/edit/scenario-merge.d.ts +7 -0
  297. package/dist/xlsx/edit/scenario-merge.d.ts.map +1 -0
  298. package/dist/xlsx/edit/session.d.ts.map +1 -1
  299. package/dist/xlsx/edit/shift-data-tables.d.ts +7 -0
  300. package/dist/xlsx/edit/shift-data-tables.d.ts.map +1 -0
  301. package/dist/xlsx/edit/shift-scenarios.d.ts +7 -0
  302. package/dist/xlsx/edit/shift-scenarios.d.ts.map +1 -0
  303. package/dist/xlsx/edit/shift-sheet.d.ts.map +1 -1
  304. package/dist/xlsx/edit/sparkline-grouping.d.ts +10 -0
  305. package/dist/xlsx/edit/sparkline-grouping.d.ts.map +1 -0
  306. package/dist/xlsx/edit/types.d.ts +21 -0
  307. package/dist/xlsx/edit/types.d.ts.map +1 -1
  308. package/dist/xlsx/formula/ets-drift-compare.d.ts +19 -0
  309. package/dist/xlsx/formula/ets-drift-compare.d.ts.map +1 -0
  310. package/dist/xlsx/formula/ets-excel-compare.d.ts +36 -0
  311. package/dist/xlsx/formula/ets-excel-compare.d.ts.map +1 -0
  312. package/dist/xlsx/formula/ets-init-compare.d.ts +24 -0
  313. package/dist/xlsx/formula/ets-init-compare.d.ts.map +1 -0
  314. package/dist/xlsx/formula/ets-init-maps.d.ts +21 -0
  315. package/dist/xlsx/formula/ets-init-maps.d.ts.map +1 -0
  316. package/dist/xlsx/formula/functions/ets-core.d.ts +36 -0
  317. package/dist/xlsx/formula/functions/ets-core.d.ts.map +1 -0
  318. package/dist/xlsx/formula/functions/ets-grid.d.ts +15 -0
  319. package/dist/xlsx/formula/functions/ets-grid.d.ts.map +1 -0
  320. package/dist/xlsx/formula/functions/ets-init-chain.d.ts +11 -0
  321. package/dist/xlsx/formula/functions/ets-init-chain.d.ts.map +1 -0
  322. package/dist/xlsx/formula/functions/ets-init-four.d.ts +3 -0
  323. package/dist/xlsx/formula/functions/ets-init-four.d.ts.map +1 -0
  324. package/dist/xlsx/formula/functions/ets-init-short.d.ts +17 -0
  325. package/dist/xlsx/formula/functions/ets-init-short.d.ts.map +1 -0
  326. package/dist/xlsx/formula/functions/ets-init-states.d.ts +5 -0
  327. package/dist/xlsx/formula/functions/ets-init-states.d.ts.map +1 -0
  328. package/dist/xlsx/formula/functions/ets-init-three.d.ts +23 -0
  329. package/dist/xlsx/formula/functions/ets-init-three.d.ts.map +1 -0
  330. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts +13 -0
  331. package/dist/xlsx/formula/functions/ets-init-threeplus.d.ts.map +1 -0
  332. package/dist/xlsx/formula/functions/ets-init.d.ts +33 -0
  333. package/dist/xlsx/formula/functions/ets-init.d.ts.map +1 -0
  334. package/dist/xlsx/formula/functions/ets-input.d.ts +13 -0
  335. package/dist/xlsx/formula/functions/ets-input.d.ts.map +1 -0
  336. package/dist/xlsx/formula/functions/ets-search-map.d.ts +24 -0
  337. package/dist/xlsx/formula/functions/ets-search-map.d.ts.map +1 -0
  338. package/dist/xlsx/formula/functions/ets-search.d.ts +17 -0
  339. package/dist/xlsx/formula/functions/ets-search.d.ts.map +1 -0
  340. package/dist/xlsx/formula/functions/ets-season.d.ts +6 -0
  341. package/dist/xlsx/formula/functions/ets-season.d.ts.map +1 -0
  342. package/dist/xlsx/formula/functions/ets-validate.d.ts +16 -0
  343. package/dist/xlsx/formula/functions/ets-validate.d.ts.map +1 -0
  344. package/dist/xlsx/formula/functions/forecast-ets.d.ts +3 -0
  345. package/dist/xlsx/formula/functions/forecast-ets.d.ts.map +1 -0
  346. package/dist/xlsx/formula/functions/statistical.d.ts.map +1 -1
  347. package/dist/xlsx/index.cjs +5118 -2648
  348. package/dist/xlsx/index.mjs +5097 -2649
  349. package/dist/xlsx/layout/form-control-link.d.ts +20 -0
  350. package/dist/xlsx/layout/form-control-link.d.ts.map +1 -0
  351. package/dist/xlsx/layout/form-control-state.d.ts +49 -0
  352. package/dist/xlsx/layout/form-control-state.d.ts.map +1 -0
  353. package/dist/xlsx/layout/form-control-view.d.ts +11 -0
  354. package/dist/xlsx/layout/form-control-view.d.ts.map +1 -0
  355. package/dist/xlsx/layout/header-footer-edit.d.ts +4 -2
  356. package/dist/xlsx/layout/header-footer-edit.d.ts.map +1 -1
  357. package/dist/xlsx/layout/header-footer.d.ts +16 -0
  358. package/dist/xlsx/layout/header-footer.d.ts.map +1 -1
  359. package/dist/xlsx/layout/index.d.ts +5 -0
  360. package/dist/xlsx/layout/index.d.ts.map +1 -1
  361. package/dist/xlsx/layout/ref-evaluator.d.ts +6 -0
  362. package/dist/xlsx/layout/ref-evaluator.d.ts.map +1 -1
  363. package/dist/xlsx/layout/shape-paint.d.ts +25 -0
  364. package/dist/xlsx/layout/shape-paint.d.ts.map +1 -0
  365. package/dist/xlsx/layout/shape-view.d.ts +15 -0
  366. package/dist/xlsx/layout/shape-view.d.ts.map +1 -0
  367. package/dist/xlsx/load/index.cjs +2667 -1163
  368. package/dist/xlsx/load/index.mjs +2667 -1163
  369. package/dist/xlsx/model-custom-views.d.ts +33 -0
  370. package/dist/xlsx/model-custom-views.d.ts.map +1 -0
  371. package/dist/xlsx/model-shapes.d.ts +78 -0
  372. package/dist/xlsx/model-shapes.d.ts.map +1 -0
  373. package/dist/xlsx/model.d.ts +38 -1
  374. package/dist/xlsx/model.d.ts.map +1 -1
  375. package/dist/xlsx/read/custom-views.d.ts +5 -0
  376. package/dist/xlsx/read/custom-views.d.ts.map +1 -0
  377. package/dist/xlsx/read/drawing.d.ts.map +1 -1
  378. package/dist/xlsx/read/form-control.d.ts +14 -0
  379. package/dist/xlsx/read/form-control.d.ts.map +1 -0
  380. package/dist/xlsx/read/header-footer-images.d.ts +5 -0
  381. package/dist/xlsx/read/header-footer-images.d.ts.map +1 -0
  382. package/dist/xlsx/read/load.d.ts.map +1 -1
  383. package/dist/xlsx/read/shape.d.ts +5 -0
  384. package/dist/xlsx/read/shape.d.ts.map +1 -0
  385. package/dist/xlsx/read/sheet-data.d.ts.map +1 -1
  386. package/dist/xlsx/read/workbook-part.d.ts +5 -1
  387. package/dist/xlsx/read/workbook-part.d.ts.map +1 -1
  388. package/dist/xlsx/read/worksheet-children.d.ts +3 -0
  389. package/dist/xlsx/read/worksheet-children.d.ts.map +1 -0
  390. package/dist/xlsx/read/worksheet.d.ts.map +1 -1
  391. package/dist/xlsx/ui/commands/i18n/sparklines.d.ts.map +1 -1
  392. package/dist/xlsx/ui/commands/i18n/what-if.d.ts.map +1 -1
  393. package/dist/xlsx/ui/commands/what-if.d.ts +0 -1
  394. package/dist/xlsx/ui/commands/what-if.d.ts.map +1 -1
  395. package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts +51 -0
  396. package/dist/xlsx/ui/dialogs/forecast-sheet.d.ts.map +1 -0
  397. package/dist/xlsx/ui/dialogs/scenario-summary.d.ts +15 -0
  398. package/dist/xlsx/ui/dialogs/scenario-summary.d.ts.map +1 -0
  399. package/dist/xlsx/ui/index.cjs +5088 -2399
  400. package/dist/xlsx/ui/index.d.ts +2 -0
  401. package/dist/xlsx/ui/index.d.ts.map +1 -1
  402. package/dist/xlsx/ui/index.mjs +5081 -2398
  403. package/dist/xlsx/ui/locales/de/grid.d.ts.map +1 -1
  404. package/dist/xlsx/ui/locales/en/grid.d.ts.map +1 -1
  405. package/dist/xlsx/ui/locales/es/grid.d.ts.map +1 -1
  406. package/dist/xlsx/ui/locales/fr/grid.d.ts.map +1 -1
  407. package/dist/xlsx/ui/locales/zh-CN/grid.d.ts.map +1 -1
  408. package/dist/xlsx/write/custom-views.d.ts +4 -0
  409. package/dist/xlsx/write/custom-views.d.ts.map +1 -0
  410. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  411. package/dist/xlsx/write/form-control.d.ts +4 -0
  412. package/dist/xlsx/write/form-control.d.ts.map +1 -0
  413. package/dist/xlsx/write/sheet-data.d.ts.map +1 -1
  414. package/dist/xlsx/write/workbook-part.d.ts.map +1 -1
  415. package/dist/xlsx/write/worksheet.d.ts.map +1 -1
  416. package/package.json +1 -1
  417. package/dist/PptxHandler-E4DDV3FQ.mjs +0 -4
  418. package/dist/pptx/chunks/index-PdM5zpmu.d.ts.map +0 -1
@@ -703,11 +703,11 @@ function inspectDeclaration(value3, encoding) {
703
703
  if (declarations.length) fail("INVALID_XML", "Invalid XML declaration attributes");
704
704
  }
705
705
  function decodeXmlAttribute(value3) {
706
- const entities = { amp: "&", lt: "<", gt: ">", apos: "'", quot: '"' };
706
+ const entities2 = { amp: "&", lt: "<", gt: ">", apos: "'", quot: '"' };
707
707
  return value3.replace(/[\t\r\n]/g, " ").replace(/&(amp|lt|gt|apos|quot|#x[\da-fA-F]+|#\d+);/g, (_, entity) => {
708
708
  if (entity.startsWith("#x")) return String.fromCodePoint(parseInt(entity.slice(2), 16));
709
709
  if (entity.startsWith("#")) return String.fromCodePoint(Number(entity.slice(1)));
710
- return entities[entity] ?? "";
710
+ return entities2[entity] ?? "";
711
711
  });
712
712
  }
713
713
  function inspectNamespaces(root2, check) {
@@ -2054,6 +2054,60 @@ function evaluateNumericFormulaFunction(name3, args) {
2054
2054
  return formulaFailure("unsupported", `Unsupported numeric function ${name3}`);
2055
2055
  }
2056
2056
 
2057
+ // visio/formula-extra-functions.ts
2058
+ var IGNORE_CASE = 1;
2059
+ var IGNORE_NONSPACE = 2;
2060
+ var IGNORE_SYMBOLS = 4;
2061
+ function strSameEx(a2, b, flags) {
2062
+ if (!Number.isInteger(flags) || flags < 0)
2063
+ return formulaFailure("value", "STRSAMEEX flags must be a whole number");
2064
+ if (flags & -8)
2065
+ return formulaFailure("unsupported", "STRSAMEEX with kana or width comparison flags");
2066
+ const fold = (text5) => {
2067
+ let result2 = text5;
2068
+ if (flags & IGNORE_NONSPACE) result2 = result2.normalize("NFD").replace(/\p{Mn}/gu, "");
2069
+ if (flags & IGNORE_SYMBOLS) result2 = result2.replace(/[\p{P}\p{S}\s]/gu, "");
2070
+ return flags & IGNORE_CASE ? result2.toLowerCase() : result2;
2071
+ };
2072
+ return fold(a2) === fold(b);
2073
+ }
2074
+ function formatNumberPicture(value3, picture) {
2075
+ if (value3.unit !== "scalar") return formulaFailure("unit", "FORMAT requires a plain number");
2076
+ const match = /^([#,0]*)(?:\.([0#]*))?(%?)$/.exec(picture);
2077
+ const integerPicture = match?.[1] ?? "";
2078
+ if (!match || !integerPicture.includes("0") || /0,*#/.test(integerPicture) || integerPicture.startsWith(",") || integerPicture.endsWith(",") || integerPicture.includes(",,") || /0#/.test(match[2] ?? ""))
2079
+ return formulaFailure("unsupported", `FORMAT picture "${picture}"`);
2080
+ const fractionPicture = match[2] ?? "", percent = match[3] === "%", grouped = integerPicture.includes(",");
2081
+ const minInteger = (integerPicture.match(/0/g) ?? []).length;
2082
+ const minFraction = (fractionPicture.match(/0/g) ?? []).length;
2083
+ const maxFraction = fractionPicture.length;
2084
+ const scaled = percent ? value3.value * 100 : value3.value;
2085
+ const factor = 10 ** maxFraction;
2086
+ const rounded = Math.sign(scaled) * Math.round(Math.abs(scaled) * factor + 1e-9) / factor;
2087
+ const [digits = "", decimals = ""] = Math.abs(rounded).toFixed(maxFraction).split(".");
2088
+ let whole = digits.replace(/^0+/, "").padStart(minInteger, "0");
2089
+ if (grouped) whole = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
2090
+ let fraction = decimals;
2091
+ while (fraction.length > minFraction && fraction.endsWith("0")) fraction = fraction.slice(0, -1);
2092
+ const negative = rounded < 0;
2093
+ return `${negative ? "-" : ""}${whole}${fraction ? `.${fraction}` : ""}${percent ? "%" : ""}`;
2094
+ }
2095
+ function visioDateSerial(year, month, day) {
2096
+ if (![year, month, day].every(Number.isInteger))
2097
+ return formulaFailure("value", "DATE requires whole numbers");
2098
+ if (year < 1 || year > 9999 || month < 1 || month > 12 || day < 1 || day > 31)
2099
+ return formulaFailure("value", "DATE is outside the calendar");
2100
+ const date2 = /* @__PURE__ */ new Date(0);
2101
+ date2.setUTCFullYear(year, month - 1, day);
2102
+ if (date2.getUTCMonth() !== month - 1) return formulaFailure("value", "DATE is not a real day");
2103
+ return (date2.getTime() - Date.UTC(1899, 11, 30)) / 864e5;
2104
+ }
2105
+ var angleToLocal = (frame, angle) => angle - frame.angle;
2106
+ function localToParent(frame, x, y) {
2107
+ const dx = x - frame.locPinX, dy = y - frame.locPinY, cos = Math.cos(frame.angle), sin = Math.sin(frame.angle);
2108
+ return [frame.pinX + dx * cos - dy * sin, frame.pinY + dx * sin + dy * cos];
2109
+ }
2110
+
2057
2111
  // visio/formula-text-functions.ts
2058
2112
  var textResultFunctions = /* @__PURE__ */ new Set([
2059
2113
  "MID",
@@ -2065,12 +2119,15 @@ var textResultFunctions = /* @__PURE__ */ new Set([
2065
2119
  "SUBSTITUTE",
2066
2120
  "REPLACE",
2067
2121
  "CHAR",
2068
- "INDEX"
2122
+ "INDEX",
2123
+ "FORMAT",
2124
+ "SHAPETEXT"
2069
2125
  ]);
2070
2126
  var textNumberFunctions = /* @__PURE__ */ new Set([
2071
2127
  "LEN",
2072
2128
  "FIND",
2073
2129
  "STRSAME",
2130
+ "STRSAMEEX",
2074
2131
  "LOOKUP"
2075
2132
  ]);
2076
2133
  var LIST_SEPARATOR = ";";
@@ -2086,6 +2143,7 @@ function exactInteger(context, node3, name3) {
2086
2143
  if (!Number.isInteger(value3.value)) return unsupported2(`${name3} with a fractional number`);
2087
2144
  return value3.value;
2088
2145
  }
2146
+ var isTheText = (node3) => node3.kind === "reference" && node3.reference.cell.toLowerCase() === "thetext";
2089
2147
  function evaluateFormulaText(node3, context, depth = 0) {
2090
2148
  context.tick();
2091
2149
  if (depth > 64) return formulaFailure("limit", "Formula evaluation limit");
@@ -2096,6 +2154,10 @@ function evaluateFormulaText(node3, context, depth = 0) {
2096
2154
  if (node3.kind === "string") return node3.value;
2097
2155
  if (node3.kind === "binary" && node3.operator === "&")
2098
2156
  return text5(node3.left, "&") + text5(node3.right, "&");
2157
+ if (node3.kind === "reference" && isTheText(node3)) {
2158
+ const read = context.textOf?.(node3.reference);
2159
+ return read === void 0 ? unsupported2("Text read from a cell") : read;
2160
+ }
2099
2161
  if (node3.kind !== "call") {
2100
2162
  let value3;
2101
2163
  try {
@@ -2117,6 +2179,12 @@ function evaluateFormulaText(node3, context, depth = 0) {
2117
2179
  if (value3.unit !== "scalar") return unsupported2("Text from a number with a unit");
2118
2180
  return String(value3.value);
2119
2181
  }
2182
+ if (name3 === "SHAPETEXT") {
2183
+ arity(1);
2184
+ const target2 = args[0];
2185
+ if (!isTheText(target2)) return unsupported2("SHAPETEXT of something other than TheText");
2186
+ return text5(target2, name3);
2187
+ }
2120
2188
  if (name3 === "MID") {
2121
2189
  arity(3);
2122
2190
  const source = text5(args[0], name3), start = integer(context, args[1], name3), length = integer(context, args[2], name3);
@@ -2171,6 +2239,10 @@ function evaluateFormulaText(node3, context, depth = 0) {
2171
2239
  if (code >= 128 && code <= 159) return unsupported2("CHAR in the Windows-1252 range");
2172
2240
  return String.fromCharCode(code);
2173
2241
  }
2242
+ if (name3 === "FORMAT") {
2243
+ arity(2);
2244
+ return formatNumberPicture(context.number(args[0]), text5(args[1], name3));
2245
+ }
2174
2246
  arity(2);
2175
2247
  const index2 = integer(context, args[0], name3);
2176
2248
  const items = text5(args[1], name3).split(LIST_SEPARATOR);
@@ -2203,6 +2275,11 @@ function evaluateTextNumberFunction(name3, args, context) {
2203
2275
  const ignoreCase = args[2] ? context.number(args[2]).value !== 0 : false;
2204
2276
  return scalar4(ignoreCase ? Number(a2.toLowerCase() === b.toLowerCase()) : Number(a2 === b));
2205
2277
  }
2278
+ if (name3 === "STRSAMEEX") {
2279
+ if (args.length === 4) return formulaFailure("unsupported", "STRSAMEEX with a locale");
2280
+ arity(3);
2281
+ return scalar4(Number(strSameEx(text5(0), text5(1), context.number(args[2]).value)));
2282
+ }
2206
2283
  arity(2);
2207
2284
  const wanted = text5(0).toLowerCase();
2208
2285
  return scalar4(
@@ -2210,6 +2287,23 @@ function evaluateTextNumberFunction(name3, args, context) {
2210
2287
  );
2211
2288
  }
2212
2289
 
2290
+ // visio/formula-indirect.ts
2291
+ var FRAME_INPUTS = {
2292
+ ANGLETOLOC: ["Angle", "FlipX", "FlipY"],
2293
+ LOCTOPAR: ["PinX", "PinY", "LocPinX", "LocPinY", "Angle", "FlipX", "FlipY"]
2294
+ };
2295
+ function literalIndirectTarget(node3) {
2296
+ if (node3.kind !== "call" || node3.args.length !== 1) return void 0;
2297
+ const address = node3.args[0];
2298
+ if (address.kind !== "string") return void 0;
2299
+ try {
2300
+ const target2 = parseVisioFormula(address.value);
2301
+ return target2.kind === "reference" && !(target2.reference.shapeId === void 0 && /^(true|false)$/i.test(target2.reference.cell)) && target2.reference.cell.toLowerCase() !== "thetext" ? target2.reference : void 0;
2302
+ } catch {
2303
+ return void 0;
2304
+ }
2305
+ }
2306
+
2213
2307
  // visio/formula-math-functions.ts
2214
2308
  var mathFormulaFunctions = /* @__PURE__ */ new Set([
2215
2309
  "ROUND",
@@ -2314,7 +2408,7 @@ function evaluateMathFormulaFunction(name3, args) {
2314
2408
  return formulaFailure("unsupported", `Unsupported function ${name3}`);
2315
2409
  }
2316
2410
 
2317
- // visio/formula-evaluate.ts
2411
+ // visio/formula-analyze.ts
2318
2412
  var supported = /* @__PURE__ */ new Set([
2319
2413
  "GUARD",
2320
2414
  "IF",
@@ -2336,6 +2430,11 @@ var supported = /* @__PURE__ */ new Set([
2336
2430
  "PNTY",
2337
2431
  "ISERROR",
2338
2432
  "IFERROR",
2433
+ "INDIRECT",
2434
+ "DATE",
2435
+ "ANGLETOLOC",
2436
+ "LOCTOPAR",
2437
+ "SHEETREF",
2339
2438
  ...textNumberFunctions,
2340
2439
  ...textResultFunctions,
2341
2440
  ...numericFormulaFunctions,
@@ -2388,10 +2487,11 @@ var staticUnsupported = /* @__PURE__ */ new Set([
2388
2487
  "MSOTINT",
2389
2488
  "SHADE",
2390
2489
  "LUMDIFF",
2391
- "MODULUS"
2490
+ "MODULUS",
2491
+ // Reads an argument of the master the shape was dropped from; pure, evaluated in master scope.
2492
+ "ARG"
2392
2493
  ]);
2393
2494
  var dynamic = /* @__PURE__ */ new Set([
2394
- "INDIRECT",
2395
2495
  "EVALCELL",
2396
2496
  "EVALTEXT",
2397
2497
  "DEPENDSON",
@@ -2408,6 +2508,19 @@ var dynamic = /* @__PURE__ */ new Set([
2408
2508
  "PAR"
2409
2509
  ]);
2410
2510
  var isClassifiedVisioFunction = (name3) => supported.has(name3) || staticUnsupported.has(name3) || dynamic.has(name3);
2511
+ var opaqueFunctions = /* @__PURE__ */ new Set([
2512
+ "EVALCELL",
2513
+ "EVALTEXT",
2514
+ "GETREF",
2515
+ "REF",
2516
+ "_SHEETCELL",
2517
+ // Structure lookups: the result changes when shapes are created, moved or reparented.
2518
+ "CONTAINERSHEETREF",
2519
+ "MEMBERSHEETREF",
2520
+ "CALLOUTTARGET",
2521
+ "PARENT",
2522
+ "PAR"
2523
+ ]);
2411
2524
  function traverse(ast, limits, visit) {
2412
2525
  const maxNodes = formulaLimit(limits.maxNodes, 1024), maxDepth = formulaLimit(limits.maxDepth, 64);
2413
2526
  const queue = [[ast, 0]];
@@ -2425,7 +2538,7 @@ function traverse(ast, limits, visit) {
2425
2538
  function analyzeVisioFormula(source, limits = {}) {
2426
2539
  const ast = typeof source === "string" ? parseVisioFormula(source, limits) : source;
2427
2540
  const references = /* @__PURE__ */ new Map(), unsupportedFunctions = /* @__PURE__ */ new Set();
2428
- let unsafe2 = false, guarded = false;
2541
+ let unsafe2 = false, opaque = false, guarded = false;
2429
2542
  traverse(ast, limits, (node3) => {
2430
2543
  if (node3.kind === "reference")
2431
2544
  references.set(
@@ -2435,9 +2548,23 @@ function analyzeVisioFormula(source, limits = {}) {
2435
2548
  if (node3.kind === "call") {
2436
2549
  const inputs = node3.name === "ISTHEMED" ? ["ColorSchemeIndex"] : ["THEMEVAL", "THEME"].includes(node3.name) ? themeInputs : [];
2437
2550
  for (const cell of inputs) references.set(`!${cell.toLowerCase()}`, { cell });
2551
+ for (const cell of FRAME_INPUTS[node3.name] ?? [])
2552
+ references.set(`!${cell.toLowerCase()}`, { cell });
2553
+ if (node3.name === "INDIRECT") {
2554
+ const target2 = literalIndirectTarget(node3);
2555
+ if (target2 && limits.literalIndirect)
2556
+ references.set(`${target2.shapeId ?? ""}!${target2.cell.toLowerCase()}`, target2);
2557
+ else {
2558
+ unsafe2 = true;
2559
+ opaque = true;
2560
+ }
2561
+ }
2438
2562
  if (!supported.has(node3.name)) unsupportedFunctions.add(node3.name);
2439
- if (dynamic.has(node3.name) || !supported.has(node3.name) && !staticUnsupported.has(node3.name))
2563
+ const shapeText2 = node3.name === "SHAPETEXT" && limits.shapeTextReads === true && node3.args.length === 1 && isTheText(node3.args[0]);
2564
+ if (dynamic.has(node3.name) && !shapeText2 || !supported.has(node3.name) && !staticUnsupported.has(node3.name))
2440
2565
  unsafe2 = true;
2566
+ if (opaqueFunctions.has(node3.name) || node3.name === "SHAPETEXT" && !shapeText2 || !supported.has(node3.name) && !staticUnsupported.has(node3.name) && !dynamic.has(node3.name) && node3.name !== "_SHEETCALL")
2567
+ opaque = true;
2441
2568
  if (node3.name === "GUARD") guarded = true;
2442
2569
  }
2443
2570
  });
@@ -2445,10 +2572,56 @@ function analyzeVisioFormula(source, limits = {}) {
2445
2572
  references: [...references.values()],
2446
2573
  unsupportedFunctions: [...unsupportedFunctions],
2447
2574
  dynamic: unsafe2,
2575
+ opaque,
2448
2576
  guarded
2449
2577
  };
2450
2578
  }
2451
- function binary(operator, a2, b) {
2579
+
2580
+ // visio/formula-bound.ts
2581
+ function evaluateBound(args, arg) {
2582
+ if (args.length < 5 || (args.length - 2) % 3 !== 0 || args.length > 302)
2583
+ return formulaFailure("arity", "Invalid BOUND argument count");
2584
+ const value3 = arg(0), type = arg(1);
2585
+ if (type.unit !== "scalar" || ![0, 1, 2].includes(type.value))
2586
+ return formulaFailure("value", "BOUND type must be 0, 1 or 2");
2587
+ if (type.value === 2) return value3;
2588
+ if (type.value === 1) {
2589
+ let current = value3.value, unit4 = value3.unit;
2590
+ for (let pass = 0; pass <= (args.length - 2) / 3; pass++) {
2591
+ let moved = false;
2592
+ for (let index2 = 2; index2 < args.length; index2 += 3) {
2593
+ if (arg(index2).value !== 0) continue;
2594
+ const a2 = arg(index2 + 1), b = arg(index2 + 2);
2595
+ unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, a2);
2596
+ unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, b);
2597
+ const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2598
+ if (current > low && current < high) {
2599
+ current = current - low < high - current ? low : high;
2600
+ moved = true;
2601
+ }
2602
+ }
2603
+ if (!moved) break;
2604
+ }
2605
+ return finiteFormulaValue({ value: current, unit: unit4 });
2606
+ }
2607
+ let nearest;
2608
+ let unit3 = value3.unit;
2609
+ for (let index2 = 2; index2 < args.length; index2 += 3) {
2610
+ if (arg(index2).value !== 0) continue;
2611
+ const a2 = arg(index2 + 1), b = arg(index2 + 2);
2612
+ unit3 = compatibleFormulaUnits({ value: value3.value, unit: unit3 }, a2);
2613
+ unit3 = compatibleFormulaUnits({ value: value3.value, unit: unit3 }, b);
2614
+ const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2615
+ if (value3.value >= low && value3.value <= high) return finiteFormulaValue({ value: value3.value, unit: unit3 });
2616
+ const edge2 = value3.value < low ? low : high;
2617
+ if (nearest === void 0 || Math.abs(edge2 - value3.value) < Math.abs(nearest - value3.value))
2618
+ nearest = edge2;
2619
+ }
2620
+ return finiteFormulaValue({ value: nearest ?? value3.value, unit: unit3 });
2621
+ }
2622
+
2623
+ // visio/formula-operators.ts
2624
+ function binaryOperator(operator, a2, b) {
2452
2625
  let unit3;
2453
2626
  if (operator === "+" || operator === "-") {
2454
2627
  unit3 = compatibleFormulaUnits(a2, b);
@@ -2478,12 +2651,36 @@ function binary(operator, a2, b) {
2478
2651
  return formulaFailure("syntax", `Unsupported operator ${operator}`);
2479
2652
  return { value: comparisons[operator] ? 1 : 0, unit: "scalar" };
2480
2653
  }
2654
+ function evaluatedShapeFrame(sheet, resolve) {
2655
+ if (sheet.kind !== "call" || sheet.name !== "SHEETREF" || sheet.args.length)
2656
+ return formulaFailure("unsupported", "A sheet other than SHEETREF()");
2657
+ const read = (cell, fallback) => {
2658
+ try {
2659
+ return finiteFormulaValue(resolve({ cell })).value;
2660
+ } catch (error) {
2661
+ if (fallback === void 0) throw error;
2662
+ return fallback;
2663
+ }
2664
+ };
2665
+ if (read("FlipX", 0) !== 0 || read("FlipY", 0) !== 0)
2666
+ return formulaFailure("unsupported", "A coordinate conversion on a flipped shape");
2667
+ return {
2668
+ pinX: read("PinX"),
2669
+ pinY: read("PinY"),
2670
+ locPinX: read("LocPinX", 0),
2671
+ locPinY: read("LocPinY", 0),
2672
+ angle: read("Angle", 0)
2673
+ };
2674
+ }
2675
+
2676
+ // visio/formula-evaluate.ts
2481
2677
  function evaluateVisioFormula(source, resolve, limits = {}) {
2482
2678
  const ast = typeof source === "string" ? parseVisioFormula(source, limits) : source;
2483
2679
  const maxSteps = formulaLimit(limits.maxSteps, 8192), maxDepth = formulaLimit(limits.maxDepth, 64);
2484
2680
  traverse(ast, limits, () => {
2485
2681
  });
2486
2682
  let steps = 0;
2683
+ const shapeFrame = (sheet) => evaluatedShapeFrame(sheet, resolve);
2487
2684
  const evaluate = (node3, depth = 0) => {
2488
2685
  if (++steps > maxSteps || depth > maxDepth)
2489
2686
  return formulaFailure("limit", "Formula evaluation limit");
@@ -2507,7 +2704,7 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
2507
2704
  else if (right2.unit === "length" && left.unit === "scalar" && node3.left.kind === "number")
2508
2705
  left = { ...left, unit: "length" };
2509
2706
  }
2510
- return binary(node3.operator, left, right2);
2707
+ return binaryOperator(node3.operator, left, right2);
2511
2708
  }
2512
2709
  const name3 = node3.name;
2513
2710
  if ((name3 === "TEXTWIDTH" || name3 === "TEXTHEIGHT") && limits.text) {
@@ -2536,18 +2733,57 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
2536
2733
  return formulaFailure("context", `${name3} requires a valid document context`);
2537
2734
  return { value: value4, unit: "scalar" };
2538
2735
  }
2736
+ const textContext = {
2737
+ number: (child4) => evaluate(child4, depth + 1),
2738
+ ...limits.textOf ? { textOf: limits.textOf } : {},
2739
+ tick: () => {
2740
+ if (++steps > maxSteps) formulaFailure("limit", "Formula evaluation limit");
2741
+ }
2742
+ };
2539
2743
  if (textNumberFunctions.has(name3))
2540
- return evaluateTextNumberFunction(name3, node3.args, {
2541
- number: (child4) => evaluate(child4, depth + 1),
2542
- tick: () => {
2543
- if (++steps > maxSteps) formulaFailure("limit", "Formula evaluation limit");
2544
- }
2744
+ return evaluateTextNumberFunction(name3, node3.args, textContext);
2745
+ if (name3 === "INDIRECT") {
2746
+ arity(1);
2747
+ const target2 = parseVisioFormula(evaluateFormulaText(node3.args[0], textContext, 1));
2748
+ if (target2.kind !== "reference")
2749
+ return formulaFailure("value", "INDIRECT needs a cell address");
2750
+ return finiteFormulaValue(resolve(target2.reference));
2751
+ }
2752
+ if (name3 === "DATE") {
2753
+ arity(3);
2754
+ const [year, month, day] = node3.args.map((_, index2) => {
2755
+ const part = arg(index2);
2756
+ if (part.unit !== "scalar") return formulaFailure("unit", "DATE requires plain numbers");
2757
+ return part.value;
2545
2758
  });
2759
+ return { value: visioDateSerial(year, month, day), unit: "time" };
2760
+ }
2761
+ if (name3 === "SHEETREF" || name3 === "LOCTOPAR")
2762
+ return formulaFailure("unsupported", `${name3} does not return a number`);
2763
+ if (name3 === "ANGLETOLOC") {
2764
+ arity(2);
2765
+ const angle = arg(1);
2766
+ if (angle.unit !== "angle" && angle.unit !== "scalar")
2767
+ return formulaFailure("unit", "ANGLETOLOC requires an angle");
2768
+ return { value: angleToLocal(shapeFrame(node3.args[0]), angle.value), unit: "angle" };
2769
+ }
2546
2770
  if (textResultFunctions.has(name3) || name3 === "PNT")
2547
2771
  return formulaFailure("unsupported", `${name3} does not return a number`);
2548
2772
  if (name3 === "PNTX" || name3 === "PNTY") {
2549
2773
  arity(1);
2550
2774
  const point2 = node3.args[0];
2775
+ if (point2.kind === "call" && point2.name === "LOCTOPAR") {
2776
+ if (point2.args.length !== 3)
2777
+ return formulaFailure("arity", "Invalid LOCTOPAR argument count");
2778
+ const [x2, y2] = [1, 2].map((index2) => {
2779
+ const part = evaluate(point2.args[index2], depth + 2);
2780
+ if (part.unit !== "scalar" && part.unit !== "length")
2781
+ return formulaFailure("unit", "LOCTOPAR requires lengths");
2782
+ return part.value;
2783
+ });
2784
+ const parent = localToParent(shapeFrame(point2.args[0]), x2, y2);
2785
+ return finiteFormulaValue({ value: parent[name3 === "PNTX" ? 0 : 1], unit: "length" });
2786
+ }
2551
2787
  if (point2.kind !== "call" || point2.name !== "PNT")
2552
2788
  return formulaFailure("unsupported", `${name3} of something other than PNT(x,y)`);
2553
2789
  if (point2.args.length !== 2) return formulaFailure("arity", "Invalid PNT argument count");
@@ -2605,47 +2841,7 @@ function evaluateVisioFormula(source, resolve, limits = {}) {
2605
2841
  }
2606
2842
  return finiteFormulaValue(result2);
2607
2843
  }
2608
- if (name3 === "BOUND") {
2609
- if (node3.args.length < 5 || (node3.args.length - 2) % 3 !== 0 || node3.args.length > 302)
2610
- return formulaFailure("arity", "Invalid BOUND argument count");
2611
- const value4 = arg(0), type = arg(1);
2612
- if (type.unit !== "scalar" || ![0, 1, 2].includes(type.value))
2613
- return formulaFailure("value", "BOUND type must be 0, 1 or 2");
2614
- if (type.value === 2) return value4;
2615
- if (type.value === 1) {
2616
- let current = value4.value, unit4 = value4.unit;
2617
- for (let pass = 0; pass <= (node3.args.length - 2) / 3; pass++) {
2618
- let moved = false;
2619
- for (let index2 = 2; index2 < node3.args.length; index2 += 3) {
2620
- if (arg(index2).value !== 0) continue;
2621
- const a2 = arg(index2 + 1), b = arg(index2 + 2);
2622
- unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, a2);
2623
- unit4 = compatibleFormulaUnits({ value: current, unit: unit4 }, b);
2624
- const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2625
- if (current > low && current < high) {
2626
- current = current - low < high - current ? low : high;
2627
- moved = true;
2628
- }
2629
- }
2630
- if (!moved) break;
2631
- }
2632
- return finiteFormulaValue({ value: current, unit: unit4 });
2633
- }
2634
- let nearest;
2635
- let unit3 = value4.unit;
2636
- for (let index2 = 2; index2 < node3.args.length; index2 += 3) {
2637
- if (arg(index2).value !== 0) continue;
2638
- const a2 = arg(index2 + 1), b = arg(index2 + 2);
2639
- unit3 = compatibleFormulaUnits({ value: value4.value, unit: unit3 }, a2);
2640
- unit3 = compatibleFormulaUnits({ value: value4.value, unit: unit3 }, b);
2641
- const low = Math.min(a2.value, b.value), high = Math.max(a2.value, b.value);
2642
- if (value4.value >= low && value4.value <= high) return finiteFormulaValue({ value: value4.value, unit: unit3 });
2643
- const edge2 = value4.value < low ? low : high;
2644
- if (nearest === void 0 || Math.abs(edge2 - value4.value) < Math.abs(nearest - value4.value))
2645
- nearest = edge2;
2646
- }
2647
- return finiteFormulaValue({ value: nearest ?? value4.value, unit: unit3 });
2648
- }
2844
+ if (name3 === "BOUND") return evaluateBound(node3.args, arg);
2649
2845
  if (name3 === "ATAN2") {
2650
2846
  arity(2);
2651
2847
  const y = arg(0), x = arg(1);
@@ -2795,14 +2991,18 @@ function parseVisioFormula(source, limits = {}) {
2795
2991
  offset += identifier[0].length;
2796
2992
  whitespace();
2797
2993
  if (source[offset] === "(") {
2798
- if (!/^[A-Za-z_][A-Za-z_0-9]*$/.test(identifier[0]))
2994
+ const qualified = /^Sheet\.(\d+)!([A-Za-z_][A-Za-z_0-9]*)$/i.exec(identifier[0]);
2995
+ if (!qualified && !/^[A-Za-z_][A-Za-z_0-9]*$/.test(identifier[0]))
2799
2996
  return formulaFailure("syntax", "Qualified function names are unsupported");
2800
2997
  offset++;
2801
2998
  const args = [];
2802
2999
  whitespace();
2803
3000
  if (source[offset] !== ")") {
2804
3001
  for (; ; ) {
2805
- args.push(expression(0, depth + 1));
3002
+ whitespace();
3003
+ args.push(
3004
+ /^[,)]/.test(source.slice(offset)) ? node3({ kind: "string", value: "" }) : expression(0, depth + 1)
3005
+ );
2806
3006
  whitespace();
2807
3007
  if (source[offset] !== ",") break;
2808
3008
  offset++;
@@ -2810,7 +3010,27 @@ function parseVisioFormula(source, limits = {}) {
2810
3010
  }
2811
3011
  if (source[offset++] !== ")")
2812
3012
  return formulaFailure("syntax", "Expected function closing parenthesis");
2813
- left = node3({ kind: "call", name: identifier[0].toUpperCase(), args });
3013
+ left = node3({
3014
+ kind: "call",
3015
+ name: (qualified ? qualified[2] : identifier[0]).toUpperCase(),
3016
+ args
3017
+ });
3018
+ if (qualified)
3019
+ left = node3({
3020
+ kind: "call",
3021
+ name: "_SHEETCALL",
3022
+ args: [node3({ kind: "string", value: qualified[1] }), left]
3023
+ });
3024
+ whitespace();
3025
+ const member = source[offset] === "!" && /^!([A-Za-z_][A-Za-z_0-9.]*)/.exec(source.slice(offset));
3026
+ if (member) {
3027
+ offset += member[0].length;
3028
+ left = node3({
3029
+ kind: "call",
3030
+ name: "_SHEETCELL",
3031
+ args: [left, node3({ kind: "string", value: member[1] })]
3032
+ });
3033
+ }
2814
3034
  } else {
2815
3035
  const ref = /^Sheet\.(\d+)!(.+)$/i.exec(identifier[0]);
2816
3036
  left = node3({
@@ -4397,20 +4617,36 @@ function indexCells(roots, options2) {
4397
4617
  if (executableCellFormula(source) && !independentTextFieldFormula(node3, source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
4398
4618
  // (Visio's freshly dropped connector names its own sheet).
4399
4619
  !(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
4620
+ const lenient = options2.scope === "affected";
4621
+ const unprovable = (message, opaque) => {
4622
+ if (!lenient) fail("EDIT_UNKNOWN_DEPENDENCY", message);
4623
+ item2.unsafe = true;
4624
+ item2.refusal = message;
4625
+ if (opaque) item2.opaque = true;
4626
+ };
4400
4627
  try {
4401
4628
  item2.formula = parseVisioFormula(source);
4402
- const plain4 = analyzeVisioFormula(item2.formula);
4629
+ const plain4 = analyzeVisioFormula(item2.formula, {
4630
+ shapeTextReads: true,
4631
+ literalIndirect: true
4632
+ });
4403
4633
  const analysis = plain4.dynamic && textSizeFormula(item2.formula) || plain4;
4404
- if (analysis.dynamic)
4405
- fail(
4406
- "EDIT_DYNAMIC_DEPENDENCY",
4407
- "Dynamic ShapeSheet dependencies cannot be safely edited."
4634
+ if (analysis.dynamic) {
4635
+ if (!lenient)
4636
+ fail(
4637
+ "EDIT_DYNAMIC_DEPENDENCY",
4638
+ "Dynamic ShapeSheet dependencies cannot be safely edited."
4639
+ );
4640
+ unprovable(
4641
+ `${cell} on shape ${sheet.shapeId || "page"} has dynamic ShapeSheet dependencies that cannot be followed.`,
4642
+ "opaque" in analysis && analysis.opaque
4408
4643
  );
4644
+ }
4409
4645
  item2.dependencies = analysis.references.filter((ref) => !isBooleanLiteral(ref)).map((ref) => key({ pageId: pageId2, shapeId: ref.shapeId ?? sheet.shapeId, cell: ref.cell }));
4410
4646
  } catch (error) {
4411
- fail(
4412
- "EDIT_UNKNOWN_DEPENDENCY",
4413
- `Cannot prove ShapeSheet dependency closure: ${error instanceof Error ? error.message : "invalid formula"}`
4647
+ unprovable(
4648
+ `Cannot prove ShapeSheet dependency closure: ${error instanceof Error ? error.message : "invalid formula"}`,
4649
+ true
4414
4650
  );
4415
4651
  }
4416
4652
  }
@@ -4493,13 +4729,20 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
4493
4729
  if (!item2 || item2.unsafe && (!item2.node || !options2.masterMovePins?.has(item2.node) && !options2.groupRotationCells?.has(item2.node)))
4494
4730
  fail(
4495
4731
  "EDIT_UNSUPPORTED_DEPENDENCY",
4496
- "Affected formula references missing, inherited or grouped cells."
4732
+ item2?.refusal ? `Affected formula cannot be evaluated: ${item2.refusal}` : "Affected formula references missing, inherited or grouped cells."
4497
4733
  );
4498
4734
  if (item2.node?.hasAttribute("E"))
4499
4735
  fail("EDIT_FORMULA_ERROR", "Affected ShapeSheet cell has an error cache.");
4500
4736
  active.add(id3);
4737
+ try {
4738
+ return evaluateCell(id3, item2);
4739
+ } finally {
4740
+ active.delete(id3);
4741
+ }
4742
+ };
4743
+ const evaluateCell = (id3, item2) => {
4501
4744
  let result2;
4502
- const analysis = item2.formula ? analyzeVisioFormula(item2.formula) : void 0;
4745
+ const analysis = item2.formula ? analyzeVisioFormula(item2.formula, { literalIndirect: true }) : void 0;
4503
4746
  if (item2.formula && item2.node && analysis.unsupportedFunctions.length) {
4504
4747
  if (!textSizeFormula(item2.formula))
4505
4748
  fail("EDIT_UNSUPPORTED_FORMULA", "Affected formula uses unsupported functions.");
@@ -4515,6 +4758,9 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
4515
4758
  ),
4516
4759
  {
4517
4760
  ...options2.pageContext?.get(item2.pageId),
4761
+ ...options2.textOf ? {
4762
+ textOf: (ref) => options2.textOf(item2.pageId, ref.shapeId ?? item2.shapeId)
4763
+ } : {},
4518
4764
  onStep: () => {
4519
4765
  if (--steps < 0)
4520
4766
  fail("LIMIT_FORMULA_STEPS", "ShapeSheet dependency evaluation limit exceeded.");
@@ -4538,16 +4784,63 @@ function createVisioCellEvaluator(cells4, options2 = {}, verifyCaches = false) {
4538
4784
  if (Math.abs(cachedValue2.value - result2.value) > 1e-10 * Math.max(1, Math.abs(result2.value)))
4539
4785
  fail("EDIT_FORMULA_CACHE", "Source formula and numeric cache disagree.");
4540
4786
  }
4541
- active.delete(id3);
4542
4787
  values.set(id3, result2);
4543
4788
  return result2;
4544
4789
  };
4545
4790
  return evaluate;
4546
4791
  }
4547
4792
 
4793
+ // visio/edit-recalculate-text.ts
4794
+ function plainShapeText(root2, shapeId2) {
4795
+ if (!root2) return void 0;
4796
+ const pending2 = children2(children2(root2, "Shapes")[0], "Shape");
4797
+ while (pending2.length) {
4798
+ const shape = pending2.pop();
4799
+ if (attribute2(shape, "ID") === shapeId2) {
4800
+ if (shape.hasAttribute("Master") || shape.hasAttribute("MasterShape")) return void 0;
4801
+ if (children2(shape, "Section").some((section3) => attribute2(section3, "N") === "Field"))
4802
+ return void 0;
4803
+ const texts = children2(shape, "Text");
4804
+ if (texts.length > 1) return void 0;
4805
+ const node3 = texts[0];
4806
+ if (!node3) return "";
4807
+ const plain4 = Array.from(node3.childNodes).every(
4808
+ (item2) => item2.nodeType === 3 || item2.nodeType === 4
4809
+ );
4810
+ return plain4 ? decodeVisioPlainText(node3.textContent ?? "") : void 0;
4811
+ }
4812
+ pending2.push(...children2(children2(shape, "Shapes")[0], "Shape"));
4813
+ }
4814
+ return void 0;
4815
+ }
4816
+ var TEXT_READERS = /* @__PURE__ */ new Set([...textNumberFunctions, ...textResultFunctions]);
4817
+ function textReadFormula(source) {
4818
+ try {
4819
+ const ast = parseVisioFormula(source);
4820
+ const analysis = analyzeVisioFormula(ast, { shapeTextReads: true });
4821
+ if (analysis.dynamic || analysis.unsupportedFunctions.length) return false;
4822
+ const textResult = ast.kind === "string" || isTheText(ast) || ast.kind === "binary" && ast.operator === "&" || ast.kind === "call" && textResultFunctions.has(ast.name);
4823
+ if (textResult) return false;
4824
+ let reads = 0;
4825
+ const walk = (node3, parent) => {
4826
+ if (isTheText(node3)) {
4827
+ reads++;
4828
+ return parent?.kind === "call" && TEXT_READERS.has(parent.name);
4829
+ }
4830
+ if (node3.kind === "unary") return walk(node3.operand, node3);
4831
+ if (node3.kind === "binary") return walk(node3.left, node3) && walk(node3.right, node3);
4832
+ if (node3.kind === "call") return node3.args.every((arg) => walk(arg, node3));
4833
+ return true;
4834
+ };
4835
+ return walk(ast) && reads > 0;
4836
+ } catch {
4837
+ return false;
4838
+ }
4839
+ }
4840
+
4548
4841
  // visio/edit-recalculate.ts
4549
4842
  function recalculateVisioCells(roots, changed, options2 = {}) {
4550
- const cells4 = indexCells(roots, options2);
4843
+ const cells4 = indexCells(roots, { scope: "affected", ...options2 });
4551
4844
  const reverse = /* @__PURE__ */ new Map();
4552
4845
  for (const [id3, item2] of cells4)
4553
4846
  for (const dependency of item2.dependencies) {
@@ -4556,6 +4849,8 @@ function recalculateVisioCells(roots, changed, options2 = {}) {
4556
4849
  reverse.set(dependency, next);
4557
4850
  }
4558
4851
  const affected = new Set(changed.map(key));
4852
+ const editedPages = new Set(changed.map((cell) => cell.pageId));
4853
+ for (const [id3, item2] of cells4) if (item2.opaque && editedPages.has(item2.pageId)) affected.add(id3);
4559
4854
  const pending2 = [...affected];
4560
4855
  const maxAffected = bound(options2.maxAffectedCells, 1e4);
4561
4856
  for (let i = 0; i < pending2.length; i++) {
@@ -4568,13 +4863,29 @@ function recalculateVisioCells(roots, changed, options2 = {}) {
4568
4863
  if (affected.size > maxAffected)
4569
4864
  fail("LIMIT_FORMULA_AFFECTED", "Affected ShapeSheet cell limit exceeded.");
4570
4865
  }
4571
- const evaluate = createVisioCellEvaluator(cells4, options2);
4866
+ const evaluate = createVisioCellEvaluator(cells4, {
4867
+ textOf: (pageId2, shapeId2) => plainShapeText(roots.get(pageId2), shapeId2),
4868
+ ...options2
4869
+ });
4572
4870
  const values = /* @__PURE__ */ new Map();
4573
- for (const id3 of affected) values.set(id3, evaluate(id3));
4871
+ for (const id3 of affected) {
4872
+ if (!cells4.has(id3) && /,"thetext"]$/.test(id3)) continue;
4873
+ try {
4874
+ values.set(id3, evaluate(id3));
4875
+ } catch (error) {
4876
+ if (options2.cycles !== "keep" || !(error instanceof VisioPackageError) || error.code !== "EDIT_FORMULA_CYCLE")
4877
+ throw error;
4878
+ const cyclic = cells4.get(id3);
4879
+ options2.diagnostics?.push({
4880
+ code: "FORMULA_CYCLE",
4881
+ message: `Kept the cached value of ${cyclic.cell} on shape ${cyclic.shapeId || "page"} (page ${cyclic.pageId}): it is part of, or depends on, a dependency cycle.`
4882
+ });
4883
+ }
4884
+ }
4574
4885
  const pages = /* @__PURE__ */ new Set();
4575
4886
  for (const id3 of affected) {
4576
4887
  const item2 = cells4.get(id3);
4577
- if (item2.node && item2.formula) {
4888
+ if (item2?.node && item2.formula && values.has(id3)) {
4578
4889
  const value3 = String(values.get(id3).value);
4579
4890
  if (item2.node.getAttribute("V") !== value3) {
4580
4891
  item2.node.setAttribute("V", value3);
@@ -4585,15 +4896,29 @@ function recalculateVisioCells(roots, changed, options2 = {}) {
4585
4896
  return [...pages];
4586
4897
  }
4587
4898
  function assertVisioShapesUnreferenced(roots, removed, options2 = {}) {
4588
- const cells4 = indexCells(roots, options2);
4899
+ const cells4 = indexCells(roots, { scope: "affected", ...options2 });
4900
+ const frozen = [];
4589
4901
  for (const cell of cells4.values()) {
4590
4902
  options2.check?.();
4903
+ if (cell.opaque && removed.has(cell.pageId) && !removed.get(cell.pageId).has(cell.shapeId))
4904
+ fail(
4905
+ "EDIT_REFERENCED_DELETE",
4906
+ `${cell.cell} on shape ${cell.shapeId || "page"} may read the removed shape through a dynamic dependency.`
4907
+ );
4591
4908
  if (removed.get(cell.pageId)?.has(cell.shapeId)) continue;
4592
4909
  if (cell.dependencies.some((id3) => {
4593
4910
  const parts = JSON.parse(id3);
4594
4911
  return removed.get(parts[0])?.has(parts[1]) ?? false;
4595
- }))
4596
- fail("EDIT_REFERENCED_DELETE", "Shape is referenced by a ShapeSheet formula.");
4912
+ })) {
4913
+ if (!options2.freeze || !cell.node || !cell.formula || cell.unsafe || cell.node.hasAttribute("E") || analyzeVisioFormula(cell.formula, { literalIndirect: true }).guarded || !Number.isFinite(
4914
+ visioFormulaCachedValue(
4915
+ cell.node.getAttribute("V") ?? "",
4916
+ cell.node.getAttribute("U") ?? void 0
4917
+ ).value
4918
+ ))
4919
+ fail("EDIT_REFERENCED_DELETE", "Shape is referenced by a ShapeSheet formula.");
4920
+ frozen.push(cell.node);
4921
+ }
4597
4922
  }
4598
4923
  for (const [pageId2, ids] of removed)
4599
4924
  for (const connections2 of children2(roots.get(pageId2), "Connects"))
@@ -4602,12 +4927,16 @@ function assertVisioShapesUnreferenced(roots, removed, options2 = {}) {
4602
4927
  if (["FromSheet", "ToSheet"].some((name3) => ids.has(attribute2(connection, name3) ?? "")))
4603
4928
  fail("EDIT_REFERENCED_DELETE", "Shape participates in a Connect record.");
4604
4929
  }
4930
+ return frozen;
4605
4931
  }
4932
+ var freezeVisioCells = (nodes) => {
4933
+ for (const node3 of nodes) node3.removeAttribute("F");
4934
+ };
4606
4935
  function assertVisioShapeUnreferenced(roots, pageId2, shapeId2, options2 = {}) {
4607
- assertVisioShapesUnreferenced(roots, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
4936
+ return assertVisioShapesUnreferenced(roots, /* @__PURE__ */ new Map([[pageId2, /* @__PURE__ */ new Set([shapeId2])]]), options2);
4608
4937
  }
4609
4938
  function createVisioDependencyQuery(roots, options2 = {}) {
4610
- const cells4 = indexCells(roots, options2);
4939
+ const cells4 = indexCells(roots, { scope: "affected", ...options2 });
4611
4940
  return (source, targets) => {
4612
4941
  const wanted = new Set(targets.map(key));
4613
4942
  const seen = /* @__PURE__ */ new Set();
@@ -4622,7 +4951,7 @@ function createVisioDependencyQuery(roots, options2 = {}) {
4622
4951
  if (seen.size > maxSteps) fail("LIMIT_FORMULA_STEPS", "Dependency analysis limit exceeded.");
4623
4952
  const item2 = cells4.get(id3);
4624
4953
  if (!item2 || item2.unsafe || item2.node?.hasAttribute("E")) return false;
4625
- if (item2.formula && analyzeVisioFormula(item2.formula).unsupportedFunctions.length)
4954
+ if (item2.formula && analyzeVisioFormula(item2.formula, { literalIndirect: true }).unsupportedFunctions.length)
4626
4955
  return false;
4627
4956
  if (wanted.has(id3)) found = true;
4628
4957
  else pending2.push(...item2.dependencies);
@@ -11950,10 +12279,10 @@ async function* streamEntryGuarded(entry3, alreadyRead, limits) {
11950
12279
  }
11951
12280
  }
11952
12281
  function toBase64(bytes) {
11953
- let binary2 = "";
12282
+ let binary = "";
11954
12283
  for (let i = 0; i < bytes.length; i += 32768)
11955
- binary2 += String.fromCharCode(...bytes.subarray(i, i + 32768));
11956
- return btoa(binary2);
12284
+ binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
12285
+ return btoa(binary);
11957
12286
  }
11958
12287
  function guardZip(zip, limits = {}) {
11959
12288
  const r = resolveLimits(limits);
@@ -14397,6 +14726,332 @@ function parseStyles(xml, warnings) {
14397
14726
  return result2;
14398
14727
  }
14399
14728
 
14729
+ // xlsx/read/print-options.ts
14730
+ var KEYS = ["gridLines", "headings", "horizontalCentered", "verticalCentered"];
14731
+ function readPrintOptions(node3) {
14732
+ if (!node3) return void 0;
14733
+ const out = {};
14734
+ for (const key2 of KEYS) if (boolAttr(node3, key2)) out[key2] = true;
14735
+ return Object.keys(out).length ? out : void 0;
14736
+ }
14737
+
14738
+ // xlsx/read/password-hash.ts
14739
+ function modernHashAttributeNames(prefix2 = "") {
14740
+ const name3 = (base2) => prefix2 ? `${prefix2}${base2[0].toUpperCase()}${base2.slice(1)}` : base2;
14741
+ return {
14742
+ algorithmName: name3("algorithmName"),
14743
+ hashValue: name3("hashValue"),
14744
+ saltValue: name3("saltValue"),
14745
+ spinCount: name3("spinCount")
14746
+ };
14747
+ }
14748
+ function readModernHash(node3, prefix2 = "") {
14749
+ const names = modernHashAttributeNames(prefix2);
14750
+ const algorithmName = att(node3, names.algorithmName);
14751
+ const hashValue = att(node3, names.hashValue);
14752
+ const saltValue = att(node3, names.saltValue);
14753
+ if (!algorithmName || !hashValue || !saltValue) return void 0;
14754
+ const hash2 = { algorithmName, hashValue, saltValue };
14755
+ const spin = att(node3, names.spinCount);
14756
+ const spinCount = spin === void 0 || spin.trim() === "" ? Number.NaN : Number(spin);
14757
+ if (Number.isFinite(spinCount)) hash2.spinCount = spinCount;
14758
+ return hash2;
14759
+ }
14760
+
14761
+ // xlsx/read/sheet-props.ts
14762
+ var defaultSheetView = () => ({
14763
+ showGridLines: true,
14764
+ showHeaders: true,
14765
+ showZeros: true,
14766
+ rightToLeft: false,
14767
+ zoom: 100
14768
+ });
14769
+ function parseSqref(sqref) {
14770
+ if (!sqref) return [];
14771
+ return sqref.split(/\s+/).filter(Boolean).map((part) => parseRange(part)).filter((range2) => range2 !== void 0);
14772
+ }
14773
+ var readTabColor = (sheetPr, palette) => parseColor(xFirst(sheetPr, "tabColor"), palette);
14774
+ var readFitToPage = (sheetPr) => boolAttr(xFirst(sheetPr, "pageSetUpPr"), "fitToPage") ?? false;
14775
+ function readSheetView(sheetViews) {
14776
+ const view2 = defaultSheetView();
14777
+ const node3 = xFirst(sheetViews, "sheetView");
14778
+ if (!node3) return view2;
14779
+ view2.showGridLines = boolAttr(node3, "showGridLines", true);
14780
+ view2.showHeaders = boolAttr(node3, "showRowColHeaders", true);
14781
+ view2.showZeros = boolAttr(node3, "showZeros", true);
14782
+ view2.rightToLeft = boolAttr(node3, "rightToLeft", false);
14783
+ view2.zoom = numAttr(node3, "zoomScale") || 100;
14784
+ if (boolAttr(node3, "showFormulas")) view2.showFormulas = true;
14785
+ const mode = att(node3, "view");
14786
+ if (mode === "pageLayout" || mode === "pageBreakPreview") view2.mode = mode;
14787
+ const pane = xFirst(node3, "pane");
14788
+ const state = att(pane, "state");
14789
+ const frozen = pane && (state === "frozen" || state === "frozenSplit");
14790
+ if (frozen) {
14791
+ const rows = Math.max(0, Math.round(numAttr(pane, "ySplit") ?? 0));
14792
+ const cols = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
14793
+ if (rows || cols) view2.freeze = { rows, cols };
14794
+ }
14795
+ const topLeft = parseAddress(
14796
+ (frozen ? att(pane, "topLeftCell") : att(node3, "topLeftCell")) ?? ""
14797
+ );
14798
+ if (topLeft) view2.topLeft = topLeft;
14799
+ const selections = xChildren(node3, "selection");
14800
+ const activePane = att(pane, "activePane") ?? "topLeft";
14801
+ const selection = selections.find((sel) => (att(sel, "pane") ?? "topLeft") === activePane) ?? selections[0];
14802
+ if (selection) {
14803
+ const ranges = parseSqref(att(selection, "sqref") ?? att(selection, "activeCell") ?? "A1");
14804
+ const active = parseAddress(att(selection, "activeCell") ?? "") ?? ranges[0]?.start ?? { row: 0, col: 0 };
14805
+ view2.selection = {
14806
+ active,
14807
+ ranges: ranges.length ? ranges : [{ start: active, end: { ...active } }]
14808
+ };
14809
+ }
14810
+ return view2;
14811
+ }
14812
+ var FORMAT_FLAGS = ["zeroHeight", "customHeight", "thickTop", "thickBottom"];
14813
+ function readSheetFormat(format5) {
14814
+ const result2 = {
14815
+ defaultRowHeight: numAttr(format5, "defaultRowHeight") ?? 15
14816
+ };
14817
+ const width = numAttr(format5, "defaultColWidth");
14818
+ if (width !== void 0) result2.defaultColWidth = width;
14819
+ const flags = {};
14820
+ for (const key2 of FORMAT_FLAGS) {
14821
+ const value3 = boolAttr(format5, key2);
14822
+ if (value3 !== void 0) flags[key2] = value3;
14823
+ }
14824
+ const base2 = numAttr(format5, "baseColWidth");
14825
+ if (base2 !== void 0) flags.baseColWidth = base2;
14826
+ if (Object.keys(flags).length) result2.format = flags;
14827
+ return result2;
14828
+ }
14829
+ function readColumns(cols, xfMap) {
14830
+ const out = [];
14831
+ for (const col of cols ? xChildren(cols, "col") : []) {
14832
+ const min = (numAttr(col, "min") ?? 1) - 1;
14833
+ const max = (numAttr(col, "max") ?? min + 1) - 1;
14834
+ const info = { min, max };
14835
+ const width = numAttr(col, "width");
14836
+ if (width !== void 0) info.width = width;
14837
+ if (boolAttr(col, "customWidth")) info.customWidth = true;
14838
+ if (boolAttr(col, "hidden")) info.hidden = true;
14839
+ const style2 = numAttr(col, "style");
14840
+ const styleId = style2 === void 0 ? 0 : xfMap[style2] ?? 0;
14841
+ if (styleId) info.styleId = styleId;
14842
+ const outline = numAttr(col, "outlineLevel");
14843
+ if (outline) info.outlineLevel = outline;
14844
+ if (boolAttr(col, "collapsed")) info.collapsed = true;
14845
+ if (boolAttr(col, "bestFit")) info.bestFit = true;
14846
+ out.push(info);
14847
+ }
14848
+ return out;
14849
+ }
14850
+ var MAIN_NS_DECL = /(?<=^<[^>]*) xmlns="http:\/\/schemas\.openxmlformats\.org\/spreadsheetml\/2006\/main"/;
14851
+ function readAutoFilter(node3) {
14852
+ const range2 = parseRange(att(node3, "ref") ?? "");
14853
+ if (!node3 || !range2) return void 0;
14854
+ const filter = { range: range2 };
14855
+ const columns = [];
14856
+ for (const column of xChildren(node3, "filterColumn")) {
14857
+ const entry3 = {
14858
+ offset: numAttr(column, "colId") ?? 0
14859
+ };
14860
+ const filters = xFirst(column, "filters");
14861
+ if (filters) {
14862
+ entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
14863
+ if (boolAttr(filters, "blank")) entry3.blank = true;
14864
+ }
14865
+ entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
14866
+ columns.push(entry3);
14867
+ }
14868
+ if (columns.length) filter.columns = columns;
14869
+ return filter;
14870
+ }
14871
+ var HEADER_FOOTER_TEXT = {
14872
+ header: "oddHeader",
14873
+ footer: "oddFooter",
14874
+ evenHeader: "evenHeader",
14875
+ evenFooter: "evenFooter",
14876
+ firstHeader: "firstHeader",
14877
+ firstFooter: "firstFooter"
14878
+ };
14879
+ var HEADER_FOOTER_FLAGS = [
14880
+ "differentOddEven",
14881
+ "differentFirst",
14882
+ "scaleWithDoc",
14883
+ "alignWithMargins"
14884
+ ];
14885
+ function readHeaderFooter(node3) {
14886
+ const out = {};
14887
+ for (const key2 of HEADER_FOOTER_FLAGS) {
14888
+ const value3 = boolAttr(node3, key2);
14889
+ if (value3 !== void 0) out[key2] = value3;
14890
+ }
14891
+ for (const [key2, local] of Object.entries(HEADER_FOOTER_TEXT)) {
14892
+ const child4 = xFirst(node3, local);
14893
+ if (child4) out[key2] = xText(child4);
14894
+ }
14895
+ return out;
14896
+ }
14897
+ var ORIENTATIONS = /* @__PURE__ */ new Set(["portrait", "landscape"]);
14898
+ function readPageSetup(margins, setup, headerFooter, fitToPage) {
14899
+ const page = {};
14900
+ if (setup) {
14901
+ if (/^(1|true)$/.test(att(setup, "useFirstPageNumber") ?? "")) {
14902
+ page.firstPageNumber = numAttr(setup, "firstPageNumber") ?? 1;
14903
+ }
14904
+ const order = att(setup, "pageOrder");
14905
+ if (order === "downThenOver" || order === "overThenDown") page.pageOrder = order;
14906
+ const orientation = att(setup, "orientation");
14907
+ if (orientation && ORIENTATIONS.has(orientation))
14908
+ page.orientation = orientation;
14909
+ const paper = numAttr(setup, "paperSize");
14910
+ if (paper !== void 0) page.paperSize = paper;
14911
+ const scale = numAttr(setup, "scale");
14912
+ if (scale !== void 0) page.scale = scale;
14913
+ }
14914
+ if (fitToPage) {
14915
+ page.fitToWidth = numAttr(setup, "fitToWidth") ?? 1;
14916
+ page.fitToHeight = numAttr(setup, "fitToHeight") ?? 1;
14917
+ }
14918
+ if (margins) {
14919
+ const m = (name3, fallback) => numAttr(margins, name3) ?? fallback;
14920
+ page.margins = {
14921
+ left: m("left", 0.7),
14922
+ right: m("right", 0.7),
14923
+ top: m("top", 0.75),
14924
+ bottom: m("bottom", 0.75),
14925
+ header: m("header", 0.3),
14926
+ footer: m("footer", 0.3)
14927
+ };
14928
+ }
14929
+ if (headerFooter) Object.assign(page, readHeaderFooter(headerFooter));
14930
+ return Object.keys(page).length ? page : void 0;
14931
+ }
14932
+ var PROTECTION_META = /* @__PURE__ */ new Set([
14933
+ "sheet",
14934
+ "password",
14935
+ "algorithmName",
14936
+ "hashValue",
14937
+ "saltValue",
14938
+ "spinCount"
14939
+ ]);
14940
+ function readProtection(node3) {
14941
+ if (!node3) return void 0;
14942
+ const protection2 = { sheet: boolAttr(node3, "sheet", false) };
14943
+ const password = att(node3, "password");
14944
+ if (password) protection2.passwordHash = password;
14945
+ const modernHash = readModernHash(node3);
14946
+ if (modernHash) protection2.modernHash = modernHash;
14947
+ const allow = [];
14948
+ for (const attribute4 of Array.from(node3.attributes)) {
14949
+ if (PROTECTION_META.has(attribute4.name)) continue;
14950
+ if (attribute4.value === "0" || attribute4.value === "false") allow.push(attribute4.name);
14951
+ }
14952
+ if (allow.length) protection2.allow = allow.sort();
14953
+ return protection2;
14954
+ }
14955
+
14956
+ // xlsx/read/custom-views.ts
14957
+ var SHEET_VIEW_ATTRS = [
14958
+ "guid",
14959
+ "scale",
14960
+ "showGridLines",
14961
+ "showRowCol",
14962
+ "zeroValues",
14963
+ "topLeftCell",
14964
+ "view",
14965
+ "showFormulas",
14966
+ "hiddenRows",
14967
+ "hiddenColumns",
14968
+ "filter",
14969
+ "showAutoFilter",
14970
+ "fitToPage"
14971
+ ];
14972
+ var WORKBOOK_VIEW_KNOWN = ["name", "guid", "includePrintSettings", "includeHiddenRowCol"];
14973
+ function readCustomWorkbookViews(node3) {
14974
+ return xChildren(node3, "customWorkbookView").flatMap((view2) => {
14975
+ const guid3 = att(view2, "guid");
14976
+ if (!guid3) return [];
14977
+ const attrs = {};
14978
+ for (const attribute4 of Array.from(view2.attributes))
14979
+ if (!WORKBOOK_VIEW_KNOWN.includes(attribute4.name) && !attribute4.name.startsWith("xmlns"))
14980
+ attrs[attribute4.name] = attribute4.value;
14981
+ return [
14982
+ {
14983
+ guid: guid3,
14984
+ name: att(view2, "name") ?? "",
14985
+ includePrintSettings: boolAttr(view2, "includePrintSettings", true),
14986
+ includeHiddenRowCol: boolAttr(view2, "includeHiddenRowCol", true),
14987
+ attrs
14988
+ }
14989
+ ];
14990
+ });
14991
+ }
14992
+ var escape2 = (value3) => value3.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
14993
+ function asSheetViews(view2) {
14994
+ const map = [
14995
+ ["scale", "zoomScale"],
14996
+ ["showGridLines", "showGridLines"],
14997
+ ["showRowCol", "showRowColHeaders"],
14998
+ ["zeroValues", "showZeros"],
14999
+ ["topLeftCell", "topLeftCell"],
15000
+ ["view", "view"],
15001
+ ["showFormulas", "showFormulas"]
15002
+ ];
15003
+ const attributes = map.flatMap(([from, to]) => {
15004
+ const value3 = att(view2, from);
15005
+ return value3 === void 0 ? [] : [` ${to}="${escape2(value3)}"`];
15006
+ }).join("");
15007
+ const children5 = elements(view2).filter((child4) => child4.localName === "pane" || child4.localName === "selection").map((child4) => outerXml(child4)).join("");
15008
+ return parseXml(
15009
+ `<sheetViews xmlns="${NS.x}"><sheetView${attributes}>${children5}</sheetView></sheetViews>`
15010
+ ).documentElement;
15011
+ }
15012
+ function readCustomSheetViews(node3) {
15013
+ return xChildren(node3, "customSheetView").flatMap((view2) => {
15014
+ const guid3 = att(view2, "guid");
15015
+ if (!guid3) return [];
15016
+ const child4 = (name3) => xChildren(view2, name3)[0];
15017
+ const pageSetup = readPageSetup(
15018
+ child4("pageMargins"),
15019
+ child4("pageSetup"),
15020
+ child4("headerFooter"),
15021
+ boolAttr(view2, "fitToPage", false)
15022
+ );
15023
+ const printOptions = readPrintOptions(child4("printOptions"));
15024
+ const filter = readAutoFilter(child4("autoFilter"));
15025
+ const attrs = {};
15026
+ for (const attribute4 of Array.from(view2.attributes))
15027
+ if (!SHEET_VIEW_ATTRS.includes(attribute4.name) && !attribute4.name.startsWith("xmlns"))
15028
+ attrs[attribute4.name] = attribute4.value;
15029
+ const modelled = [
15030
+ "pane",
15031
+ "selection",
15032
+ "pageMargins",
15033
+ "printOptions",
15034
+ "pageSetup",
15035
+ "headerFooter",
15036
+ "autoFilter"
15037
+ ];
15038
+ return [
15039
+ {
15040
+ guid: guid3,
15041
+ view: readSheetView(asSheetViews(view2)),
15042
+ ...boolAttr(view2, "hiddenRows", false) ? { hiddenRows: true } : {},
15043
+ ...boolAttr(view2, "hiddenColumns", false) ? { hiddenColumns: true } : {},
15044
+ ...filter ? { filter } : {},
15045
+ ...boolAttr(view2, "showAutoFilter", false) ? { showAutoFilter: true } : {},
15046
+ ...pageSetup ? { pageSetup } : {},
15047
+ ...printOptions ? { printOptions } : {},
15048
+ attrs,
15049
+ extra: elements(view2).filter((c2) => !modelled.includes(c2.localName ?? "")).map((c2) => outerXml(c2))
15050
+ }
15051
+ ];
15052
+ });
15053
+ }
15054
+
14400
15055
  // xlsx/read/formula-storage.ts
14401
15056
  function tokens(formula2) {
14402
15057
  try {
@@ -14494,30 +15149,20 @@ function stripFuturePrefixes(formula2) {
14494
15149
  return fromStoredSyntax(plain4);
14495
15150
  }
14496
15151
 
14497
- // xlsx/read/password-hash.ts
14498
- function modernHashAttributeNames(prefix2 = "") {
14499
- const name3 = (base2) => prefix2 ? `${prefix2}${base2[0].toUpperCase()}${base2.slice(1)}` : base2;
14500
- return {
14501
- algorithmName: name3("algorithmName"),
14502
- hashValue: name3("hashValue"),
14503
- saltValue: name3("saltValue"),
14504
- spinCount: name3("spinCount")
14505
- };
14506
- }
14507
- function readModernHash(node3, prefix2 = "") {
14508
- const names = modernHashAttributeNames(prefix2);
14509
- const algorithmName = att(node3, names.algorithmName);
14510
- const hashValue = att(node3, names.hashValue);
14511
- const saltValue = att(node3, names.saltValue);
14512
- if (!algorithmName || !hashValue || !saltValue) return void 0;
14513
- const hash2 = { algorithmName, hashValue, saltValue };
14514
- const spin = att(node3, names.spinCount);
14515
- const spinCount = spin === void 0 || spin.trim() === "" ? Number.NaN : Number(spin);
14516
- if (Number.isFinite(spinCount)) hash2.spinCount = spinCount;
14517
- return hash2;
14518
- }
14519
-
14520
15152
  // xlsx/read/workbook-part.ts
15153
+ var NAME_EXTRA_ATTRIBUTES = [
15154
+ "function",
15155
+ "vbProcedure",
15156
+ "xlm",
15157
+ "customMenu",
15158
+ "description",
15159
+ "help",
15160
+ "statusBar",
15161
+ "shortcutKey",
15162
+ "functionGroupId",
15163
+ "publishToServer",
15164
+ "workbookParameter"
15165
+ ];
14521
15166
  function parseWorkbookPart(xml) {
14522
15167
  const root2 = parseXml(xml, { label: "XLSX workbook" }).documentElement;
14523
15168
  const sheets = [];
@@ -14541,6 +15186,12 @@ function parseWorkbookPart(xml) {
14541
15186
  if (boolAttr(node3, "hidden")) name3.hidden = true;
14542
15187
  const comment = att(node3, "comment");
14543
15188
  if (comment) name3.comment = comment;
15189
+ const extra = {};
15190
+ for (const key2 of NAME_EXTRA_ATTRIBUTES) {
15191
+ const value3 = att(node3, key2);
15192
+ if (value3 !== void 0) extra[key2] = value3;
15193
+ }
15194
+ if (Object.keys(extra).length) name3.extra = extra;
14544
15195
  if (name3.name) definedNames.push(name3);
14545
15196
  }
14546
15197
  const view2 = xFirst(xFirst(root2, "bookViews"), "workbookView");
@@ -14554,7 +15205,9 @@ function parseWorkbookPart(xml) {
14554
15205
  delta: numAttr(calcPr, "iterateDelta") ?? 1e-3
14555
15206
  } : void 0;
14556
15207
  const oleSize = att(xFirst(root2, "oleSize"), "ref");
15208
+ const customViews = xFirst(root2, "customWorkbookViews");
14557
15209
  return {
15210
+ ...customViews ? { customViews: readCustomWorkbookViews(customViews) } : {},
14558
15211
  ...oleSize ? { oleSize } : {},
14559
15212
  ...iterate ? { iterate } : {},
14560
15213
  ...password ? { workbookPasswordHash: password } : {},
@@ -14588,9 +15241,9 @@ function parseFormula(fmla) {
14588
15241
  return { op, args };
14589
15242
  }
14590
15243
  function resolveOperand(token, variables) {
14591
- const num = Number(token);
14592
- if (Number.isFinite(num)) {
14593
- return num;
15244
+ const num2 = Number(token);
15245
+ if (Number.isFinite(num2)) {
15246
+ return num2;
14594
15247
  }
14595
15248
  const value3 = variables.get(token);
14596
15249
  if (value3 !== void 0) {
@@ -16263,18 +16916,18 @@ function groupTransform(group2, parent) {
16263
16916
  const ext = first(xfrm, "ext", NS.a);
16264
16917
  const chOff = first(xfrm, "chOff", NS.a);
16265
16918
  const chExt = first(xfrm, "chExt", NS.a);
16266
- const num = (element2, name3) => Number.parseInt(element2?.getAttribute(name3) ?? "", 10);
16267
- const cx = num(ext, "cx");
16268
- const cy = num(ext, "cy");
16269
- const chCx = num(chExt, "cx");
16270
- const chCy = num(chExt, "cy");
16919
+ const num2 = (element2, name3) => Number.parseInt(element2?.getAttribute(name3) ?? "", 10);
16920
+ const cx = num2(ext, "cx");
16921
+ const cy = num2(ext, "cy");
16922
+ const chCx = num2(chExt, "cx");
16923
+ const chCy = num2(chExt, "cy");
16271
16924
  if (!off || ![cx, cy, chCx, chCy].every(Number.isFinite) || chCx === 0 || chCy === 0)
16272
16925
  return parent;
16273
16926
  const scaleX = cx / chCx;
16274
16927
  const scaleY = cy / chCy;
16275
16928
  const local = {
16276
- offsetX: num(off, "x") - (num(chOff, "x") || 0) * scaleX,
16277
- offsetY: num(off, "y") - (num(chOff, "y") || 0) * scaleY,
16929
+ offsetX: num2(off, "x") - (num2(chOff, "x") || 0) * scaleX,
16930
+ offsetY: num2(off, "y") - (num2(chOff, "y") || 0) * scaleY,
16278
16931
  scaleX,
16279
16932
  scaleY
16280
16933
  };
@@ -16582,200 +17235,48 @@ async function resolveSmartArt(sheets, source, warn) {
16582
17235
  }
16583
17236
  }
16584
17237
 
16585
- // xlsx/read/sheet-props.ts
16586
- var defaultSheetView = () => ({
16587
- showGridLines: true,
16588
- showHeaders: true,
16589
- showZeros: true,
16590
- rightToLeft: false,
16591
- zoom: 100
16592
- });
16593
- function parseSqref(sqref) {
16594
- if (!sqref) return [];
16595
- return sqref.split(/\s+/).filter(Boolean).map((part) => parseRange(part)).filter((range2) => range2 !== void 0);
16596
- }
16597
- var readTabColor = (sheetPr, palette) => parseColor(xFirst(sheetPr, "tabColor"), palette);
16598
- var readFitToPage = (sheetPr) => boolAttr(xFirst(sheetPr, "pageSetUpPr"), "fitToPage") ?? false;
16599
- function readSheetView(sheetViews) {
16600
- const view2 = defaultSheetView();
16601
- const node3 = xFirst(sheetViews, "sheetView");
16602
- if (!node3) return view2;
16603
- view2.showGridLines = boolAttr(node3, "showGridLines", true);
16604
- view2.showHeaders = boolAttr(node3, "showRowColHeaders", true);
16605
- view2.showZeros = boolAttr(node3, "showZeros", true);
16606
- view2.rightToLeft = boolAttr(node3, "rightToLeft", false);
16607
- view2.zoom = numAttr(node3, "zoomScale") || 100;
16608
- if (boolAttr(node3, "showFormulas")) view2.showFormulas = true;
16609
- const mode = att(node3, "view");
16610
- if (mode === "pageLayout" || mode === "pageBreakPreview") view2.mode = mode;
16611
- const pane = xFirst(node3, "pane");
16612
- const state = att(pane, "state");
16613
- const frozen = pane && (state === "frozen" || state === "frozenSplit");
16614
- if (frozen) {
16615
- const rows = Math.max(0, Math.round(numAttr(pane, "ySplit") ?? 0));
16616
- const cols = Math.max(0, Math.round(numAttr(pane, "xSplit") ?? 0));
16617
- if (rows || cols) view2.freeze = { rows, cols };
16618
- }
16619
- const topLeft = parseAddress(
16620
- (frozen ? att(pane, "topLeftCell") : att(node3, "topLeftCell")) ?? ""
16621
- );
16622
- if (topLeft) view2.topLeft = topLeft;
16623
- const selections = xChildren(node3, "selection");
16624
- const activePane = att(pane, "activePane") ?? "topLeft";
16625
- const selection = selections.find((sel) => (att(sel, "pane") ?? "topLeft") === activePane) ?? selections[0];
16626
- if (selection) {
16627
- const ranges = parseSqref(att(selection, "sqref") ?? att(selection, "activeCell") ?? "A1");
16628
- const active = parseAddress(att(selection, "activeCell") ?? "") ?? ranges[0]?.start ?? { row: 0, col: 0 };
16629
- view2.selection = {
16630
- active,
16631
- ranges: ranges.length ? ranges : [{ start: active, end: { ...active } }]
16632
- };
16633
- }
16634
- return view2;
16635
- }
16636
- var FORMAT_FLAGS = ["zeroHeight", "customHeight", "thickTop", "thickBottom"];
16637
- function readSheetFormat(format5) {
16638
- const result2 = {
16639
- defaultRowHeight: numAttr(format5, "defaultRowHeight") ?? 15
16640
- };
16641
- const width = numAttr(format5, "defaultColWidth");
16642
- if (width !== void 0) result2.defaultColWidth = width;
16643
- const flags = {};
16644
- for (const key2 of FORMAT_FLAGS) {
16645
- const value3 = boolAttr(format5, key2);
16646
- if (value3 !== void 0) flags[key2] = value3;
16647
- }
16648
- const base2 = numAttr(format5, "baseColWidth");
16649
- if (base2 !== void 0) flags.baseColWidth = base2;
16650
- if (Object.keys(flags).length) result2.format = flags;
16651
- return result2;
16652
- }
16653
- function readColumns(cols, xfMap) {
16654
- const out = [];
16655
- for (const col of cols ? xChildren(cols, "col") : []) {
16656
- const min = (numAttr(col, "min") ?? 1) - 1;
16657
- const max = (numAttr(col, "max") ?? min + 1) - 1;
16658
- const info = { min, max };
16659
- const width = numAttr(col, "width");
16660
- if (width !== void 0) info.width = width;
16661
- if (boolAttr(col, "customWidth")) info.customWidth = true;
16662
- if (boolAttr(col, "hidden")) info.hidden = true;
16663
- const style2 = numAttr(col, "style");
16664
- const styleId = style2 === void 0 ? 0 : xfMap[style2] ?? 0;
16665
- if (styleId) info.styleId = styleId;
16666
- const outline = numAttr(col, "outlineLevel");
16667
- if (outline) info.outlineLevel = outline;
16668
- if (boolAttr(col, "collapsed")) info.collapsed = true;
16669
- if (boolAttr(col, "bestFit")) info.bestFit = true;
16670
- out.push(info);
16671
- }
16672
- return out;
16673
- }
16674
- var MAIN_NS_DECL = /(?<=^<[^>]*) xmlns="http:\/\/schemas\.openxmlformats\.org\/spreadsheetml\/2006\/main"/;
16675
- function readAutoFilter(node3) {
16676
- const range2 = parseRange(att(node3, "ref") ?? "");
16677
- if (!node3 || !range2) return void 0;
16678
- const filter = { range: range2 };
16679
- const columns = [];
16680
- for (const column of xChildren(node3, "filterColumn")) {
16681
- const entry3 = {
16682
- offset: numAttr(column, "colId") ?? 0
16683
- };
16684
- const filters = xFirst(column, "filters");
16685
- if (filters) {
16686
- entry3.values = xChildren(filters, "filter").map((f) => att(f, "val") ?? "");
16687
- if (boolAttr(filters, "blank")) entry3.blank = true;
16688
- }
16689
- entry3.sourceXml = outerXml(column).replace(MAIN_NS_DECL, "");
16690
- columns.push(entry3);
16691
- }
16692
- if (columns.length) filter.columns = columns;
16693
- return filter;
16694
- }
16695
- var HEADER_FOOTER_TEXT = {
16696
- header: "oddHeader",
16697
- footer: "oddFooter",
16698
- evenHeader: "evenHeader",
16699
- evenFooter: "evenFooter",
16700
- firstHeader: "firstHeader",
16701
- firstFooter: "firstFooter"
16702
- };
16703
- var HEADER_FOOTER_FLAGS = [
16704
- "differentOddEven",
16705
- "differentFirst",
16706
- "scaleWithDoc",
16707
- "alignWithMargins"
17238
+ // xlsx/read/worksheet-children.ts
17239
+ var WORKSHEET_CHILD_ORDER = [
17240
+ "sheetPr",
17241
+ "dimension",
17242
+ "sheetViews",
17243
+ "sheetFormatPr",
17244
+ "cols",
17245
+ "sheetData",
17246
+ "sheetCalcPr",
17247
+ "sheetProtection",
17248
+ "protectedRanges",
17249
+ "scenarios",
17250
+ "autoFilter",
17251
+ "sortState",
17252
+ "dataConsolidate",
17253
+ "customSheetViews",
17254
+ "mergeCells",
17255
+ "phoneticPr",
17256
+ "conditionalFormatting",
17257
+ "dataValidations",
17258
+ "hyperlinks",
17259
+ "printOptions",
17260
+ "pageMargins",
17261
+ "pageSetup",
17262
+ "headerFooter",
17263
+ "rowBreaks",
17264
+ "colBreaks",
17265
+ "customProperties",
17266
+ "cellWatches",
17267
+ "ignoredErrors",
17268
+ "smartTags",
17269
+ "drawing",
17270
+ "legacyDrawing",
17271
+ "legacyDrawingHF",
17272
+ "drawingHF",
17273
+ "picture",
17274
+ "oleObjects",
17275
+ "controls",
17276
+ "webPublishItems",
17277
+ "tableParts",
17278
+ "extLst"
16708
17279
  ];
16709
- function readHeaderFooter(node3) {
16710
- const out = {};
16711
- for (const key2 of HEADER_FOOTER_FLAGS) {
16712
- const value3 = boolAttr(node3, key2);
16713
- if (value3 !== void 0) out[key2] = value3;
16714
- }
16715
- for (const [key2, local] of Object.entries(HEADER_FOOTER_TEXT)) {
16716
- const child4 = xFirst(node3, local);
16717
- if (child4) out[key2] = xText(child4);
16718
- }
16719
- return out;
16720
- }
16721
- var ORIENTATIONS = /* @__PURE__ */ new Set(["portrait", "landscape"]);
16722
- function readPageSetup(margins, setup, headerFooter, fitToPage) {
16723
- const page = {};
16724
- if (setup) {
16725
- if (/^(1|true)$/.test(att(setup, "useFirstPageNumber") ?? "")) {
16726
- page.firstPageNumber = numAttr(setup, "firstPageNumber") ?? 1;
16727
- }
16728
- const order = att(setup, "pageOrder");
16729
- if (order === "downThenOver" || order === "overThenDown") page.pageOrder = order;
16730
- const orientation = att(setup, "orientation");
16731
- if (orientation && ORIENTATIONS.has(orientation))
16732
- page.orientation = orientation;
16733
- const paper = numAttr(setup, "paperSize");
16734
- if (paper !== void 0) page.paperSize = paper;
16735
- const scale = numAttr(setup, "scale");
16736
- if (scale !== void 0) page.scale = scale;
16737
- }
16738
- if (fitToPage) {
16739
- page.fitToWidth = numAttr(setup, "fitToWidth") ?? 1;
16740
- page.fitToHeight = numAttr(setup, "fitToHeight") ?? 1;
16741
- }
16742
- if (margins) {
16743
- const m = (name3, fallback) => numAttr(margins, name3) ?? fallback;
16744
- page.margins = {
16745
- left: m("left", 0.7),
16746
- right: m("right", 0.7),
16747
- top: m("top", 0.75),
16748
- bottom: m("bottom", 0.75),
16749
- header: m("header", 0.3),
16750
- footer: m("footer", 0.3)
16751
- };
16752
- }
16753
- if (headerFooter) Object.assign(page, readHeaderFooter(headerFooter));
16754
- return Object.keys(page).length ? page : void 0;
16755
- }
16756
- var PROTECTION_META = /* @__PURE__ */ new Set([
16757
- "sheet",
16758
- "password",
16759
- "algorithmName",
16760
- "hashValue",
16761
- "saltValue",
16762
- "spinCount"
16763
- ]);
16764
- function readProtection(node3) {
16765
- if (!node3) return void 0;
16766
- const protection2 = { sheet: boolAttr(node3, "sheet", false) };
16767
- const password = att(node3, "password");
16768
- if (password) protection2.passwordHash = password;
16769
- const modernHash = readModernHash(node3);
16770
- if (modernHash) protection2.modernHash = modernHash;
16771
- const allow = [];
16772
- for (const attribute4 of Array.from(node3.attributes)) {
16773
- if (PROTECTION_META.has(attribute4.name)) continue;
16774
- if (attribute4.value === "0" || attribute4.value === "false") allow.push(attribute4.name);
16775
- }
16776
- if (allow.length) protection2.allow = allow.sort();
16777
- return protection2;
16778
- }
16779
17280
 
16780
17281
  // xlsx/read/conditional.ts
16781
17282
  var CFVO_TYPES = /* @__PURE__ */ new Set(["min", "max", "num", "percent", "percentile", "formula"]);
@@ -20151,9 +20652,210 @@ function readSlicerFrame(content2, anchor, sourceXml) {
20151
20652
  return void 0;
20152
20653
  }
20153
20654
 
20154
- // xlsx/read/drawing.ts
20655
+ // xlsx/read/form-control.ts
20656
+ var TYPES = {
20657
+ checkbox: "checkbox",
20658
+ radio: "radio",
20659
+ drop: "dropdown",
20660
+ list: "list",
20661
+ button: "button",
20662
+ spin: "spin",
20663
+ scroll: "scroll",
20664
+ gbox: "groupBox",
20665
+ label: "label",
20666
+ edit: "edit"
20667
+ };
20668
+ function readFormControlFrame(alternate, anchorOf) {
20669
+ const choice2 = elements(alternate).find((node3) => node3.localName === "Choice");
20670
+ const anchorEl = choice2 ? elements(choice2).find((node3) => node3.localName?.endsWith("Anchor")) : void 0;
20671
+ if (!anchorEl) return void 0;
20672
+ const shape = elements(anchorEl).find((node3) => node3.localName === "sp");
20673
+ const nv = first(shape, "nvSpPr", NS.xdr);
20674
+ const cNvPr = first(nv, "cNvPr", NS.xdr);
20675
+ const spid = [...cNvPr?.getElementsByTagName("*") ?? []].find(
20676
+ (node3) => node3.localName === "compatExt"
20677
+ );
20678
+ if (!spid) return void 0;
20679
+ const shapeId2 = Number(att(cNvPr, "id"));
20680
+ if (!Number.isFinite(shapeId2)) return void 0;
20681
+ const name3 = att(cNvPr, "name");
20682
+ return {
20683
+ kind: "formControl",
20684
+ anchor: anchorOf(anchorEl),
20685
+ shapeId: shapeId2,
20686
+ controlType: "other",
20687
+ ...name3 ? { name: name3 } : {},
20688
+ sourceXml: selfContainedXml(alternate)
20689
+ };
20690
+ }
20691
+ var num = (value3) => {
20692
+ if (value3 === void 0 || value3 === "") return void 0;
20693
+ const parsed = Number(value3);
20694
+ return Number.isFinite(parsed) ? parsed : void 0;
20695
+ };
20696
+ function readProps(control, xml) {
20697
+ const props = parseXml(xml, { label: "XLSX form control" }).documentElement;
20698
+ control.controlType = TYPES[(att(props, "objectType") ?? "").toLowerCase()] ?? "other";
20699
+ const link = att(props, "fmlaLink");
20700
+ if (link) control.linkedCell = link;
20701
+ const range2 = att(props, "fmlaRange");
20702
+ if (range2) control.listRange = range2;
20703
+ if (control.controlType === "checkbox" || control.controlType === "radio") {
20704
+ const checked = att(props, "checked");
20705
+ control.checked = checked === "Checked" ? "checked" : checked === "Mixed" ? "mixed" : "unchecked";
20706
+ }
20707
+ if (att(props, "firstButton") === "1") control.firstButton = true;
20708
+ for (const [key2, attribute4] of [
20709
+ ["selected", "sel"],
20710
+ ["value", "val"],
20711
+ ["min", "min"],
20712
+ ["max", "max"],
20713
+ ["step", "inc"],
20714
+ ["page", "page"]
20715
+ ]) {
20716
+ const value3 = num(att(props, attribute4));
20717
+ if (value3 !== void 0) control[key2] = value3;
20718
+ }
20719
+ if (att(props, "horiz") === "1") control.horizontal = true;
20720
+ const style2 = att(props, "dropStyle");
20721
+ if (style2) control.dropStyle = style2;
20722
+ }
20723
+ var entities = {
20724
+ amp: "&",
20725
+ lt: "<",
20726
+ gt: ">",
20727
+ quot: '"',
20728
+ apos: "'",
20729
+ nbsp: " "
20730
+ };
20731
+ function vmlCaption(vml, shapeId2) {
20732
+ const start = vml.indexOf(`id="_x0000_s${shapeId2}"`);
20733
+ if (start < 0) return void 0;
20734
+ const end = vml.indexOf("</v:shape>", start);
20735
+ const shape = vml.slice(start, end < 0 ? void 0 : end);
20736
+ const box4 = /<v:textbox[^>]*>([\s\S]*?)<\/v:textbox>/.exec(shape)?.[1];
20737
+ if (!box4) return void 0;
20738
+ let stripped = box4.replace(/<br\s*\/?>/gi, "\n");
20739
+ for (let prev = ""; prev !== stripped; ) {
20740
+ prev = stripped;
20741
+ stripped = stripped.replace(/<[^>]*>/g, "");
20742
+ }
20743
+ const text5 = stripped.replace(/&(#x?[0-9a-f]+|\w+);/gi, (match, code) => {
20744
+ if (code.startsWith("#")) {
20745
+ const value3 = code[1]?.toLowerCase() === "x" ? parseInt(code.slice(2), 16) : Number(code.slice(1));
20746
+ return Number.isFinite(value3) ? String.fromCodePoint(value3) : match;
20747
+ }
20748
+ return entities[code.toLowerCase()] ?? match;
20749
+ }).replace(/\s+/g, " ").trim();
20750
+ return text5 || void 0;
20751
+ }
20752
+ function attachFormControls(source, sheetPart, root2, sheet, legacyDrawing) {
20753
+ const controls3 = sheet.drawings.filter(
20754
+ (object) => object.kind === "formControl"
20755
+ );
20756
+ if (!controls3.length) return;
20757
+ const rels = source.rels(sheetPart);
20758
+ const parts = /* @__PURE__ */ new Map();
20759
+ for (const control of Array.from(root2.getElementsByTagNameNS(NS.x, "control"))) {
20760
+ const shapeId2 = Number(att(control, "shapeId"));
20761
+ const rel = rels.get(relAttr(control, "id") ?? "");
20762
+ const target2 = rel ? source.target(sheetPart, rel) : void 0;
20763
+ if (target2) parts.set(shapeId2, target2);
20764
+ }
20765
+ const vmlRel = legacyDrawing ? rels.get(relAttr(legacyDrawing, "id") ?? "") : void 0;
20766
+ const vmlPart = vmlRel ? source.target(sheetPart, vmlRel) : void 0;
20767
+ const vml = vmlPart ? source.text(vmlPart) : void 0;
20768
+ for (const control of controls3) {
20769
+ const part = parts.get(control.shapeId);
20770
+ const xml = part ? source.text(part) : void 0;
20771
+ if (part && xml) {
20772
+ control.partName = part;
20773
+ try {
20774
+ readProps(control, xml);
20775
+ } catch {
20776
+ control.controlType = "other";
20777
+ }
20778
+ }
20779
+ const caption = vml ? vmlCaption(vml, control.shapeId) : void 0;
20780
+ if (caption) control.caption = caption;
20781
+ }
20782
+ }
20783
+
20784
+ // xlsx/read/shape.ts
20155
20785
  var xdr = (parent, local) => first(parent, local, NS.xdr);
20156
- var int2 = (parent, local) => Math.round(Number(xdr(parent, local)?.textContent ?? 0)) || 0;
20786
+ function styleRef2(style2, name3) {
20787
+ const ref = first(style2, name3, NS.a);
20788
+ if (!ref) return void 0;
20789
+ const idx = Number(att(ref, "idx") ?? 0);
20790
+ const color2 = parseDrawingColorIn(ref);
20791
+ return { idx: Number.isFinite(idx) ? idx : 0, ...color2 ? { color: color2 } : {} };
20792
+ }
20793
+ function readStyle(style2) {
20794
+ if (!style2) return void 0;
20795
+ const fill = styleRef2(style2, "fillRef");
20796
+ const line = styleRef2(style2, "lnRef");
20797
+ const fontColor = parseDrawingColorIn(first(style2, "fontRef", NS.a));
20798
+ return {
20799
+ ...fill ? { fill } : {},
20800
+ ...line ? { line } : {},
20801
+ ...fontColor ? { font: { color: fontColor } } : {}
20802
+ };
20803
+ }
20804
+ function readShapeNode(element2) {
20805
+ const local = element2.localName;
20806
+ if (local !== "sp" && local !== "cxnSp" && local !== "grpSp") return void 0;
20807
+ const isGroup = local === "grpSp";
20808
+ const nv = elements(element2).find((node4) => node4.localName?.startsWith("nv"));
20809
+ const cNvPr = xdr(nv, "cNvPr");
20810
+ const spPr = xdr(element2, isGroup ? "grpSpPr" : "spPr");
20811
+ const xfrm = first(spPr, "xfrm", NS.a);
20812
+ const transform2 = parseTransform(xfrm);
20813
+ const geometry = isGroup ? { geometry: "group" } : parseDrawingGeometry(spPr);
20814
+ const node3 = {
20815
+ kind: isGroup ? "group" : local === "cxnSp" ? "connector" : "shape",
20816
+ frame: transform2?.frame ?? { x: 0, y: 0, width: 0, height: 0 },
20817
+ geometry: geometry.geometry
20818
+ };
20819
+ const name3 = att(cNvPr, "name");
20820
+ if (name3) node3.name = name3;
20821
+ if (att(xdr(nv, "cNvSpPr"), "txBox") === "1") node3.textBox = true;
20822
+ if (transform2?.rotation) node3.rotation = transform2.rotation;
20823
+ if (transform2?.flipHorizontal) node3.flipH = true;
20824
+ if (transform2?.flipVertical) node3.flipV = true;
20825
+ if ("adjustments" in geometry && geometry.adjustments) node3.adjustments = geometry.adjustments;
20826
+ if ("paths" in geometry && geometry.paths) node3.paths = geometry.paths;
20827
+ if (!isGroup) {
20828
+ const fill = parseDrawingFill(spPr);
20829
+ if (fill) node3.fill = fill;
20830
+ const line = parseDrawingLine(first(spPr, "ln", NS.a));
20831
+ if (line) node3.line = line;
20832
+ const style2 = readStyle(xdr(element2, "style"));
20833
+ if (style2) node3.style = style2;
20834
+ const text5 = parseDrawingTextBody(xdr(element2, "txBody"));
20835
+ if (text5?.text) node3.text = text5;
20836
+ return node3;
20837
+ }
20838
+ const childFrame = parseFrameOf(first(xfrm, "chOff", NS.a), first(xfrm, "chExt", NS.a));
20839
+ if (childFrame) node3.childFrame = childFrame;
20840
+ node3.children = elements(element2).flatMap((child4) => {
20841
+ const read = readShapeNode(child4);
20842
+ return read ? [read] : [];
20843
+ });
20844
+ return node3;
20845
+ }
20846
+ function parseFrameOf(off, ext) {
20847
+ if (!off || !ext) return void 0;
20848
+ return {
20849
+ x: Number(att(off, "x") ?? 0),
20850
+ y: Number(att(off, "y") ?? 0),
20851
+ width: Number(att(ext, "cx") ?? 0),
20852
+ height: Number(att(ext, "cy") ?? 0)
20853
+ };
20854
+ }
20855
+
20856
+ // xlsx/read/drawing.ts
20857
+ var xdr2 = (parent, local) => first(parent, local, NS.xdr);
20858
+ var int2 = (parent, local) => Math.round(Number(xdr2(parent, local)?.textContent ?? 0)) || 0;
20157
20859
  function marker(node3) {
20158
20860
  return {
20159
20861
  col: int2(node3, "col"),
@@ -20164,7 +20866,7 @@ function marker(node3) {
20164
20866
  }
20165
20867
  function readAnchor(anchor) {
20166
20868
  if (anchor.localName === "absoluteAnchor") {
20167
- const pos = xdr(anchor, "pos");
20869
+ const pos = xdr2(anchor, "pos");
20168
20870
  const result3 = {
20169
20871
  from: {
20170
20872
  row: 0,
@@ -20173,26 +20875,26 @@ function readAnchor(anchor) {
20173
20875
  rowOffset: Number(att(pos, "y") ?? 0)
20174
20876
  }
20175
20877
  };
20176
- const ext2 = xdr(anchor, "ext");
20878
+ const ext2 = xdr2(anchor, "ext");
20177
20879
  if (ext2) result3.ext = { cx: Number(att(ext2, "cx") ?? 0), cy: Number(att(ext2, "cy") ?? 0) };
20178
20880
  return result3;
20179
20881
  }
20180
- const result2 = { from: marker(xdr(anchor, "from")) };
20181
- const to = xdr(anchor, "to");
20882
+ const result2 = { from: marker(xdr2(anchor, "from")) };
20883
+ const to = xdr2(anchor, "to");
20182
20884
  if (to) result2.to = marker(to);
20183
- const ext = xdr(anchor, "ext");
20885
+ const ext = xdr2(anchor, "ext");
20184
20886
  if (ext) result2.ext = { cx: Number(att(ext, "cx") ?? 0), cy: Number(att(ext, "cy") ?? 0) };
20185
20887
  return result2;
20186
20888
  }
20187
20889
  var ANCHOR_PARTS = /* @__PURE__ */ new Set(["from", "to", "ext", "pos", "clientData"]);
20188
20890
  function nonVisual(content2) {
20189
20891
  const nv = elements(content2).find((node3) => node3.localName?.startsWith("nv"));
20190
- return xdr(nv, "cNvPr");
20892
+ return xdr2(nv, "cNvPr");
20191
20893
  }
20192
20894
  function describe(content2) {
20193
20895
  switch (content2.localName) {
20194
20896
  case "sp":
20195
- return xdr(content2, "nvSpPr") && att(xdr(xdr(content2, "nvSpPr"), "cNvSpPr"), "txBox") === "1" ? "text box" : "shape";
20897
+ return xdr2(content2, "nvSpPr") && att(xdr2(xdr2(content2, "nvSpPr"), "cNvSpPr"), "txBox") === "1" ? "text box" : "shape";
20196
20898
  case "grpSp":
20197
20899
  return "group";
20198
20900
  case "cxnSp":
@@ -20212,6 +20914,11 @@ function parseDrawing(source, partName, warn) {
20212
20914
  const rels = source.rels(partName);
20213
20915
  const out = [];
20214
20916
  for (const anchorEl of elements(root2)) {
20917
+ if (anchorEl.localName === "AlternateContent") {
20918
+ const control = readFormControlFrame(anchorEl, readAnchor);
20919
+ if (control) out.push(control);
20920
+ continue;
20921
+ }
20215
20922
  if (!["twoCellAnchor", "oneCellAnchor", "absoluteAnchor"].includes(anchorEl.localName ?? ""))
20216
20923
  continue;
20217
20924
  const anchor = readAnchor(anchorEl);
@@ -20226,7 +20933,7 @@ function parseDrawing(source, partName, warn) {
20226
20933
  const cNvPr = nonVisual(content2);
20227
20934
  const name3 = att(cNvPr, "name");
20228
20935
  if (content2.localName === "pic") {
20229
- const blipFill = xdr(content2, "blipFill");
20936
+ const blipFill = xdr2(content2, "blipFill");
20230
20937
  const blip = first(blipFill, "blip", NS.a);
20231
20938
  const rel = rels.get(relAttr(blip, "embed") ?? "");
20232
20939
  const target2 = rel ? source.target(partName, rel) : void 0;
@@ -20301,11 +21008,50 @@ function parseDrawing(source, partName, warn) {
20301
21008
  continue;
20302
21009
  }
20303
21010
  }
20304
- out.push(unsupported4(describe(content2)));
21011
+ const shape = readShapeNode(content2);
21012
+ out.push({ ...unsupported4(describe(content2)), ...shape ? { shape } : {} });
20305
21013
  }
20306
21014
  return out;
20307
21015
  }
20308
21016
 
21017
+ // xlsx/read/header-footer-images.ts
21018
+ var UNIT_PT = { pt: 1, in: 72, cm: 72 / 2.54, mm: 72 / 25.4, px: 0.75 };
21019
+ function styleLength(style2, property2) {
21020
+ const match = new RegExp(
21021
+ `(?:^|[;\\s])${property2}\\s*:\\s*([\\d.]+)\\s*(pt|in|cm|mm|px)?`,
21022
+ "i"
21023
+ ).exec(style2);
21024
+ return match ? Number(match[1]) * (UNIT_PT[(match[2] ?? "pt").toLowerCase()] ?? 1) : 0;
21025
+ }
21026
+ function readHeaderFooterImages(source, sheetPart, legacyHF) {
21027
+ if (!legacyHF) return void 0;
21028
+ const rel = source.rels(sheetPart).get(relAttr(legacyHF, "id") ?? "");
21029
+ const vmlPart = rel ? source.target(sheetPart, rel) : void 0;
21030
+ const vml = vmlPart ? source.text(vmlPart) : void 0;
21031
+ if (!vmlPart || !vml) return void 0;
21032
+ const rels = source.rels(vmlPart);
21033
+ const images = {};
21034
+ for (const match of vml.matchAll(/<v:shape\b([^>]*)>([\s\S]*?)<\/v:shape>/g)) {
21035
+ const id3 = /\bid="([^"]+)"/.exec(match[1] ?? "")?.[1];
21036
+ const style2 = /style=(?:'([^']*)'|"([^"]*)")/.exec(match[1] ?? "");
21037
+ const data = /<v:imagedata\b([^>]*)>/.exec(match[2] ?? "")?.[1];
21038
+ const relId = /\bo:relid="([^"]+)"/.exec(data ?? "")?.[1];
21039
+ const imageRel = relId ? rels.get(relId) : void 0;
21040
+ const partName = imageRel ? source.target(vmlPart, imageRel) : void 0;
21041
+ if (!id3 || !partName || !source.has(partName)) continue;
21042
+ const css = style2?.[1] ?? style2?.[2] ?? "";
21043
+ const title = /\bo:title="([^"]*)"/.exec(data ?? "")?.[1];
21044
+ images[id3] = {
21045
+ partName,
21046
+ contentType: source.contentType(partName) ?? "application/octet-stream",
21047
+ widthPt: styleLength(css, "width"),
21048
+ heightPt: styleLength(css, "height"),
21049
+ ...title ? { title } : {}
21050
+ };
21051
+ }
21052
+ return Object.keys(images).length ? images : void 0;
21053
+ }
21054
+
20309
21055
  // xlsx/read/dates.ts
20310
21056
  var DAY_MS2 = 864e5;
20311
21057
  var EPOCH_19003 = Date.UTC(1899, 11, 30);
@@ -20447,6 +21193,8 @@ function readRowInfo(ctx, rowEl) {
20447
21193
  const outline = numAttr(rowEl, "outlineLevel");
20448
21194
  if (outline) info.outlineLevel = outline;
20449
21195
  if (boolAttr(rowEl, "collapsed")) info.collapsed = true;
21196
+ if (boolAttr(rowEl, "thickTop")) info.thickTop = true;
21197
+ if (boolAttr(rowEl, "thickBot")) info.thickBot = true;
20450
21198
  return Object.keys(info).length ? info : void 0;
20451
21199
  }
20452
21200
  function readSheetData(ctx, rows, sheet) {
@@ -20559,15 +21307,6 @@ function readScenarios(node3) {
20559
21307
  return set;
20560
21308
  }
20561
21309
 
20562
- // xlsx/read/print-options.ts
20563
- var KEYS = ["gridLines", "headings", "horizontalCentered", "verticalCentered"];
20564
- function readPrintOptions(node3) {
20565
- if (!node3) return void 0;
20566
- const out = {};
20567
- for (const key2 of KEYS) if (boolAttr(node3, key2)) out[key2] = true;
20568
- return Object.keys(out).length ? out : void 0;
20569
- }
20570
-
20571
21310
  // xlsx/read/tables.ts
20572
21311
  function parseTable(xml, partName) {
20573
21312
  const root2 = parseXml(xml, { label: "XLSX table" }).documentElement;
@@ -20658,8 +21397,14 @@ var MODELLED = /* @__PURE__ */ new Set([
20658
21397
  "drawing",
20659
21398
  "legacyDrawing",
20660
21399
  "tableParts",
20661
- "scenarios"
21400
+ "scenarios",
21401
+ "customSheetViews"
20662
21402
  ]);
21403
+ function reportUnplaceable(ctx, sheet, element2) {
21404
+ ctx.warn(
21405
+ `Sheet "${sheet}": the element "${element2}" is not part of the worksheet schema and is dropped on save.`
21406
+ );
21407
+ }
20663
21408
  function keep(sheet, key2, xml) {
20664
21409
  const list2 = sheet.preserved.get(key2);
20665
21410
  if (list2) list2.push(xml);
@@ -20741,9 +21486,15 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
20741
21486
  else if (!byName.has(local)) byName.set(local, node3);
20742
21487
  if (SNAPSHOT_ELEMENTS.includes(local))
20743
21488
  keep(sheet, snapshotKey(local), outerXml(node3));
20744
- else if (local === "AlternateContent")
20745
- keep(sheet, alternateContentName(node3) ?? local, selfContainedXml(node3));
20746
- else if (!MODELLED.has(local)) keep(sheet, local, selfContainedXml(node3));
21489
+ else if (local === "AlternateContent") {
21490
+ const inner = alternateContentName(node3);
21491
+ if (!WORKSHEET_CHILD_ORDER.includes(inner ?? local))
21492
+ reportUnplaceable(ctx, name3, inner ?? local);
21493
+ keep(sheet, inner ?? local, selfContainedXml(node3));
21494
+ } else if (!MODELLED.has(local)) {
21495
+ if (!WORKSHEET_CHILD_ORDER.includes(local)) reportUnplaceable(ctx, name3, local);
21496
+ keep(sheet, local, selfContainedXml(node3));
21497
+ }
20747
21498
  }
20748
21499
  const sheetPr = byName.get("sheetPr");
20749
21500
  const tabColor = readTabColor(sheetPr, ctx.palette);
@@ -20779,6 +21530,10 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
20779
21530
  readFitToPage(sheetPr)
20780
21531
  );
20781
21532
  if (page) sheet.pageSetup = page;
21533
+ const customViews = byName.get("customSheetViews");
21534
+ if (customViews) sheet.customViews = readCustomSheetViews(customViews);
21535
+ const hfImages = readHeaderFooterImages(ctx.source, partName, byName.get("legacyDrawingHF"));
21536
+ if (hfImages) sheet.headerFooterImages = hfImages;
20782
21537
  const printOptions = readPrintOptions(byName.get("printOptions"));
20783
21538
  if (printOptions) sheet.printOptions = printOptions;
20784
21539
  const drawing = byName.get("drawing");
@@ -20786,6 +21541,7 @@ function readWorksheet(ctx, partName, name3, sheetId5, xml, rows) {
20786
21541
  const rel = ctx.source.rels(partName).get(relAttr(drawing, "id") ?? "");
20787
21542
  const target2 = rel ? ctx.source.target(partName, rel) : void 0;
20788
21543
  if (target2) sheet.drawings = parseDrawing(ctx.source, target2, (m) => ctx.warn(m));
21544
+ attachFormControls(ctx.source, partName, root2, sheet, byName.get("legacyDrawing"));
20789
21545
  }
20790
21546
  readTables(ctx, partName, byName.get("tableParts"), sheet);
20791
21547
  readComments(ctx, partName, sheet);
@@ -20894,6 +21650,7 @@ async function loadXlsx(input, options2 = {}) {
20894
21650
  if (book.workbookPasswordHash) workbook.workbookPasswordHash = book.workbookPasswordHash;
20895
21651
  if (book.workbookModernHash) workbook.workbookModernHash = book.workbookModernHash;
20896
21652
  if (book.oleSize) workbook.oleSize = book.oleSize;
21653
+ if (book.customViews) workbook.customViews = book.customViews;
20897
21654
  if (book.calcMode) workbook.calcMode = book.calcMode;
20898
21655
  if (book.iterate) workbook.iterate = book.iterate;
20899
21656
  if (signatures.hasSignatures)
@@ -22677,9 +23434,9 @@ function sampleArc(start, rxIn, ryIn, xAxisRotationDeg, largeArcFlag, sweepFlag,
22677
23434
  ry *= scale;
22678
23435
  }
22679
23436
  const sign = largeArcFlag !== sweepFlag ? 1 : -1;
22680
- const num = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
23437
+ const num2 = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
22681
23438
  const den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
22682
- const coef = sign * Math.sqrt(Math.max(0, num / den));
23439
+ const coef = sign * Math.sqrt(Math.max(0, num2 / den));
22683
23440
  const cxp = coef * (rx * y1p) / ry;
22684
23441
  const cyp = coef * -(ry * x1p) / rx;
22685
23442
  const cx = cosPhi * cxp - sinPhi * cyp + (start.x + end.x) / 2;
@@ -28469,10 +29226,10 @@ function processCompoundFileStream(input, path3, replacement) {
28469
29226
  if (input[0] !== 208 || input[1] !== 207 || input[2] !== 17 || input[3] !== 224 || input[4] !== 161 || input[5] !== 177 || input[6] !== 26 || input[7] !== 225 || // Readers tolerate a non-canonical byte-order mark; edits do not.
28470
29227
  replacement && view2.getUint16(28, true) !== 65534)
28471
29228
  return reject2();
28472
- const major = view2.getUint16(26, true), shift2 = view2.getUint16(30, true), miniShift = view2.getUint16(32, true);
28473
- if (major !== 3 && major !== 4 || shift2 !== (major === 3 ? 9 : 12) || miniShift !== 6)
29229
+ const major = view2.getUint16(26, true), shift3 = view2.getUint16(30, true), miniShift = view2.getUint16(32, true);
29230
+ if (major !== 3 && major !== 4 || shift3 !== (major === 3 ? 9 : 12) || miniShift !== 6)
28474
29231
  return reject2();
28475
- const sectorSize = 1 << shift2, miniSize = 1 << miniShift;
29232
+ const sectorSize = 1 << shift3, miniSize = 1 << miniShift;
28476
29233
  if (input.length < sectorSize || replacement && input.length % sectorSize !== 0)
28477
29234
  return reject2();
28478
29235
  const sectorCount = Math.ceil(input.length / sectorSize) - 1;
@@ -36216,7 +36973,7 @@ function readVsdDrawing(input) {
36216
36973
  }
36217
36974
  seen.add(offset);
36218
36975
  active.add(offset);
36219
- const compressed = (format5 & 2) !== 0, shift2 = compressed ? 4 : 0;
36976
+ const compressed = (format5 & 2) !== 0, shift3 = compressed ? 4 : 0;
36220
36977
  const bytes = compressed ? decodeVsdBlock(stream.subarray(offset, offset + length), decodedBudget) : stream.slice(offset, offset + length);
36221
36978
  decodedBudget -= bytes.length;
36222
36979
  if (decodedBudget < 0)
@@ -36231,17 +36988,17 @@ function readVsdDrawing(input) {
36231
36988
  if (page && [71, 72, 78].includes(type)) {
36232
36989
  shape = { id: id3, kind: type === 71 ? "group" : type === 78 ? "foreign" : "shape", coordinateSpace: "shape-local", unsupportedGeometry: false, unsafeTransform: false, geometry: [], unsafeText: false };
36233
36990
  page.shapes.push(shape);
36234
- if (bytes.length - shift2 >= 54) {
36991
+ if (bytes.length - shift3 >= 54) {
36235
36992
  const sv = view(bytes);
36236
- shape.parentId = sv.getUint32(shift2 + 10, true);
36237
- shape.masterPageId = sv.getUint32(shift2 + 18, true);
36238
- shape.masterShapeId = sv.getUint32(shift2 + 26, true);
36993
+ shape.parentId = sv.getUint32(shift3 + 10, true);
36994
+ shape.masterPageId = sv.getUint32(shift3 + 18, true);
36995
+ shape.masterShapeId = sv.getUint32(shift3 + 26, true);
36239
36996
  }
36240
36997
  }
36241
36998
  const mode = format5 >>> 4;
36242
36999
  if (mode === 5 || type === 20) {
36243
- bounded3(bytes, shift2, 4);
36244
- const table2 = view(bytes).getUint32(shift2, true) + shift2 - 4;
37000
+ bounded3(bytes, shift3, 4);
37001
+ const table2 = view(bytes).getUint32(shift3, true) + shift3 - 4;
36245
37002
  bounded3(bytes, table2, 12);
36246
37003
  const count = view(bytes).getInt32(table2 + 4, true), order = view(bytes).getUint32(table2, true);
36247
37004
  if (count < 0 || count > 1e5 || count > Math.floor((bytes.length - table2 - 12) / 18))
@@ -37378,8 +38135,13 @@ function resolveVisioPageVisibility(page, options2 = {}) {
37378
38135
  }
37379
38136
 
37380
38137
  // visio/edit-formatting-scope.ts
37381
- async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shape, changed, check, instanceView2) {
37382
- indexCells(roots, { check });
38138
+ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shape, changed, check, instanceView2, options2 = {}) {
38139
+ for (const item2 of indexCells(roots, { check, scope: "affected" }).values())
38140
+ if (item2.refusal && item2.pageId === pageId2)
38141
+ fail(
38142
+ "EDIT_UNKNOWN_DEPENDENCY",
38143
+ `Cannot prove ShapeSheet dependency closure: ${item2.refusal}`
38144
+ );
37383
38145
  const shapeId2 = attribute2(shape, "ID");
37384
38146
  const changedNames = new Set([...changed.keys()].map((name3) => name3.toLowerCase()));
37385
38147
  const jumpOnly = [...changedNames].every(
@@ -37434,11 +38196,17 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
37434
38196
  if (textEdit && localShapeId === shapeId2 && sourcePageId === pageId2) continue;
37435
38197
  analysis = sized;
37436
38198
  }
38199
+ if (options2.textReads && textEdit && !named2 && sourcePageId !== void 0 && textReadFormula(source))
38200
+ continue;
37437
38201
  if (named2 && analysis.dynamic) {
37438
38202
  if (mentions()) failure2();
37439
38203
  continue;
37440
38204
  }
37441
- if (analysis.dynamic || analysis.references.some(
38205
+ if (analysis.dynamic && analysis.opaque) {
38206
+ if (sourcePageId === pageId2 || mentions()) failure2();
38207
+ continue;
38208
+ }
38209
+ if (analysis.references.some(
37442
38210
  (ref) => changedNames.has(canonical2(ref.cell)) && (sourcePageId === void 0 || sourcePageId === pageId2) && (ref.shapeId === shapeId2 || ref.shapeId === void 0 && (localShapeId === shapeId2 || sourcePageId === void 0))
37443
38211
  ))
37444
38212
  failure2();
@@ -37451,6 +38219,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
37451
38219
  const part = await pkg.readXml(path3);
37452
38220
  const master2 = part.localName === "MasterContents";
37453
38221
  if (instanceView2 && master2) continue;
38222
+ if (master2 && !shape.hasAttribute("Master") && !shape.hasAttribute("MasterShape")) continue;
37454
38223
  inspect7(part, void 0, master2);
37455
38224
  }
37456
38225
  }
@@ -37653,7 +38422,7 @@ function masterTemplate(pkg) {
37653
38422
  return matches2.length === 1 ? matches2[0] : missing();
37654
38423
  };
37655
38424
  }
37656
- function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check) {
38425
+ function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check, diagnostics = []) {
37657
38426
  return replacePlainText(
37658
38427
  roots.get(edit.pageId),
37659
38428
  document,
@@ -37667,10 +38436,20 @@ function replaceScopedPlainText(pkg, pagePaths, roots, document, edit, check) {
37667
38436
  edit.pageId,
37668
38437
  shape,
37669
38438
  /* @__PURE__ */ new Map([["TheText", text5]]),
37670
- check
38439
+ check,
38440
+ void 0,
38441
+ { textReads: true }
37671
38442
  ),
37672
38443
  masterTemplate(pkg)
37673
- );
38444
+ ).then((changed) => {
38445
+ if (changed)
38446
+ recalculateVisioCells(
38447
+ roots,
38448
+ [{ pageId: edit.pageId, shapeId: edit.shapeId, cell: "TheText" }],
38449
+ { check, cycles: "keep", diagnostics }
38450
+ );
38451
+ return changed;
38452
+ });
37674
38453
  }
37675
38454
 
37676
38455
  // visio/edit-stencil-connector.ts
@@ -38934,9 +39713,16 @@ function visioWalkPath(begin, end) {
38934
39713
  return horizontal2 ? [p, { x: p.x + turn, y: p.y }, { x: p.x + turn, y: q.y }, q] : [p, { x: p.x, y: p.y + turn }, { x: q.x, y: p.y + turn }, q];
38935
39714
  };
38936
39715
  let path3;
38937
- if (gapX >= -EPSILON3 && inside2(from.y, b.minY, b.maxY))
38938
- path3 = jog(side(begin, sx, 0), side(end, -sx, 0), true);
38939
- else if (gapY >= -EPSILON3 && inside2(from.x, b.minX, b.maxX))
39716
+ if (gapX >= -EPSILON3 && inside2(from.y, b.minY, b.maxY)) {
39717
+ const p = side(begin, sx, 0), q = side(end, -sx, 0);
39718
+ if (begin.shape?.floating && end.shape?.floating) {
39719
+ const y = (Math.max(a2.minY, b.minY) + Math.min(a2.maxY, b.maxY)) / 2;
39720
+ path3 = [
39721
+ { x: p.x, y },
39722
+ { x: q.x, y }
39723
+ ];
39724
+ } else path3 = jog(p, q, true);
39725
+ } else if (gapY >= -EPSILON3 && inside2(from.x, b.minX, b.maxX))
38940
39726
  path3 = jog(side(begin, 0, sy), side(end, 0, -sy), false);
38941
39727
  else if (gapY < -EPSILON3 || gapY < CHANNEL && gapX >= CHANNEL) {
38942
39728
  const p = side(begin, sx, 0);
@@ -39572,7 +40358,7 @@ function writeStencilConnector(shape, route, vertices) {
39572
40358
 
39573
40359
  // visio/edit-stencil-connector-layout.ts
39574
40360
  var same6 = (a2, b) => Math.abs(a2 - b) <= 1e-9 * Math.max(1, Math.abs(a2), Math.abs(b));
39575
- function walkShape(box4) {
40361
+ function walkShape(box4, floating = false) {
39576
40362
  const [a2, b, c2, d, e, f] = box4.transform;
39577
40363
  const at2 = (x, y) => ({
39578
40364
  x: a2 * x + c2 * y + e,
@@ -39584,7 +40370,8 @@ function walkShape(box4) {
39584
40370
  sites: sites.map((site) => ({ point: site.point, normal: site.normal })),
39585
40371
  bounds: sites[0].box,
39586
40372
  center: at2(box4.width / 2, box4.height / 2),
39587
- corners: [at2(0, 0), at2(box4.width, 0), at2(box4.width, box4.height), at2(0, box4.height)]
40373
+ corners: [at2(0, 0), at2(box4.width, 0), at2(box4.width, box4.height), at2(0, box4.height)],
40374
+ ...floating ? { floating } : {}
39588
40375
  }
39589
40376
  };
39590
40377
  }
@@ -39805,6 +40592,11 @@ function connectionRows(shape) {
39805
40592
  }
39806
40593
  return rows;
39807
40594
  }
40595
+ function hasConnectionPoints(root2, shapeId2) {
40596
+ const target2 = topShape(root2, shapeId2);
40597
+ if (!target2) return false;
40598
+ return (stencilTemplate(target2) ? effectiveRows(target2, "Connection") : connectionRows(target2)).size > 0;
40599
+ }
39808
40600
  function glueSites(root2, end) {
39809
40601
  const box4 = glueBox(root2, end.target);
39810
40602
  if (end.point === void 0) return dynamicSites(box4);
@@ -39915,8 +40707,9 @@ function proveConnector(root2, connectorId) {
39915
40707
  const named2 = visioPointGlueTarget(source);
39916
40708
  return index2 === void 0 ? !named2 : !!named2 && named2.shapeId === target2 && named2.index === index2;
39917
40709
  };
39918
- if (!end || !target2 || ends[end] !== void 0 || (index2 === void 0 ? toCell !== "PinX" || attribute2(row2, "ToPart") !== "3" : attribute2(row2, "ToPart") !== String(100 + index2)) || // A line master has no glue trigger of its own unless Visio wrote one with the glue.
39919
- visioGlueTriggerTarget(formula2(triggerName(end))) !== target2 && !(isStencilLine(shape) && formula2(triggerName(end)) === void 0) || !glued("X") || !glued("Y"))
40710
+ if (!end || !target2 || ends[end] !== void 0 || (index2 === void 0 ? toCell !== "PinX" || attribute2(row2, "ToPart") !== "3" : attribute2(row2, "ToPart") !== String(100 + index2)) || // A line master has no glue trigger of its own unless Visio wrote one with the glue, and
40711
+ // point glue on a drawn line has none either (native-edit-families-flat-2026-10-29.json).
40712
+ visioGlueTriggerTarget(formula2(triggerName(end))) !== target2 && !(formula2(triggerName(end)) === void 0 && !local.has(triggerName(end)) && (isStencilLine(shape) || index2 !== void 0)) || !glued("X") || !glued("Y"))
39920
40713
  fail("UNSUPPORTED_GEOMETRY_EDIT", UNSUPPORTED2);
39921
40714
  ends[end] = { target: target2, ...index2 === void 0 ? {} : { point: index2 } };
39922
40715
  }
@@ -40182,7 +40975,7 @@ function rerouteConnector(roots, pageId2, glue, check, options2 = {}) {
40182
40975
  }
40183
40976
  const walk = (end) => {
40184
40977
  const target2 = glue.ends[end];
40185
- return target2 && target2.point === void 0 ? walkShape(glueBox(root2, target2.target)) : { point: sites(end)[0].point };
40978
+ return target2 && target2.point === void 0 ? walkShape(glueBox(root2, target2.target), !hasConnectionPoints(root2, target2.target)) : { point: sites(end)[0].point };
40186
40979
  };
40187
40980
  const route = options2.route ?? current;
40188
40981
  if (route === "straight" && current === "straight" && ENDS.every(
@@ -41453,7 +42246,7 @@ var unquotedVisioFormula = (source) => source.split(/("(?:[^"]|"")*")/g).map((pa
41453
42246
 
41454
42247
  // visio/formula-functions.ts
41455
42248
  var DOCUMENTED = new Set(
41456
- `ABS ACOS AND ANG360 ANGLEALONGPATH ANGLETOLOC ANGLETOPAR ASIN ATAN ATAN2 BITAND BITNOT BITOR
42249
+ `ABS ACOS AND ARG ANG360 ANGLEALONGPATH ANGLETOLOC ANGLETOPAR ASIN ATAN ATAN2 BITAND BITNOT BITOR
41457
42250
  BITXOR BKGPAGENAME BLEND BLOB BLUE BOUND CALLOUTCOUNT CALLOUTTARGETREF CALLTHIS CATEGORY CEILING
41458
42251
  CELLISTHEMED CHAR COMPANY CONTAINERCOUNT CONTAINERMEMBERCOUNT CONTAINERSHEETREF COS COSH CREATOR
41459
42252
  CY DATA1 DATA2 DATA3 DATE DATETIME DATEVALUE DAY DAYOFYEAR DECIMALSEP DEFAULTEVENT DEG DEPENDSON
@@ -42982,17 +43775,17 @@ function pageSettingConstant(node3, length) {
42982
43775
  }
42983
43776
  return value3.value;
42984
43777
  }
42985
- var escape2 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
43778
+ var escape3 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
42986
43779
  function assertDependencies(roots, pagesPart, pages, pagePaths, pageId2, changed, check) {
42987
43780
  const page = children2(pages, "Page").find((node3) => attribute2(node3, "ID") === pageId2);
42988
43781
  const targetNames = new Set(
42989
43782
  ["Name", "NameU"].map((name3) => attribute2(page, name3)?.toLowerCase())
42990
43783
  );
42991
43784
  const otherNames = children2(pages, "Page").filter((node3) => node3 !== page).flatMap((node3) => ["Name", "NameU"].map((name3) => attribute2(node3, name3))).filter((name3) => !!name3 && !targetNames.has(name3.toLowerCase()));
42992
- const cells4 = changed.map(escape2).join("|");
43785
+ const cells4 = changed.map(escape3).join("|");
42993
43786
  const reference2 = new RegExp(`(?:^|[^a-z0-9_.])(?:${cells4})(?:$|[^a-z0-9_.])`, "i");
42994
43787
  const other = otherNames.length ? new RegExp(
42995
- `Pages\\[(?:${otherNames.map(escape2).join("|")})\\]!(?:ThePage!)?(?:${cells4})(?![a-z0-9_.])`,
43788
+ `Pages\\[(?:${otherNames.map(escape3).join("|")})\\]!(?:ThePage!)?(?:${cells4})(?![a-z0-9_.])`,
42996
43789
  "gi"
42997
43790
  ) : void 0;
42998
43791
  const paths = new Map([...pagePaths].map(([id3, path3]) => [path3, id3]));
@@ -43411,7 +44204,7 @@ var VISIO_DEFAULT_TITLE = "Title";
43411
44204
  var ACCENT = { background: "Background Accent", border: "Border Accent" };
43412
44205
  function visioShade(color2, amount) {
43413
44206
  const value3 = Number.parseInt(color2.slice(1), 16);
43414
- const channel = (shift2) => Math.round((value3 >> shift2 & 255) * (1 - amount)).toString(16).padStart(2, "0");
44207
+ const channel = (shift3) => Math.round((value3 >> shift3 & 255) * (1 - amount)).toString(16).padStart(2, "0");
43415
44208
  return `#${channel(16)}${channel(8)}${channel(0)}`.toUpperCase();
43416
44209
  }
43417
44210
  function visioDecorationName(name3) {
@@ -43608,14 +44401,14 @@ function snapshotPageSetupEdit(edit) {
43608
44401
  }
43609
44402
 
43610
44403
  // visio/edit-data-commands.ts
43611
- var TYPES = [
44404
+ var TYPES2 = [
43612
44405
  "import-data-recordset",
43613
44406
  "refresh-data-recordset",
43614
44407
  "delete-data-recordset",
43615
44408
  "link-data-rows",
43616
44409
  "unlink-data-rows"
43617
44410
  ];
43618
- var isVisioDataEdit = (edit) => TYPES.includes(edit.type);
44411
+ var isVisioDataEdit = (edit) => TYPES2.includes(edit.type);
43619
44412
  var id = (value3, label) => {
43620
44413
  if (typeof value3 !== "string" || !/^(0|[1-9]\d{0,9})$/.test(value3) || Number(value3) > 4294967295)
43621
44414
  fail("INVALID_EDIT", `Invalid ${label}.`);
@@ -46088,6 +46881,7 @@ function resizeVisioShapeAtAnchor(roots, document, edit, check, glueShapes = /*
46088
46881
  fail("UNSUPPORTED_GEOMETRY_EDIT", "Glued shapes require routing outside this subset.");
46089
46882
  const graph = indexCells(roots, {
46090
46883
  check,
46884
+ scope: "affected",
46091
46885
  glueShapes,
46092
46886
  ...group2 ? { groupResizeShapes: group2.shapes } : {}
46093
46887
  });
@@ -46401,13 +47195,23 @@ function prepareMasterMovePins(roots, commands, bindings, check) {
46401
47195
  }
46402
47196
  }
46403
47197
  if (result2.size) {
46404
- const indexed = indexCells(roots, { check });
47198
+ const indexed = indexCells(roots, { check, scope: "affected" });
46405
47199
  const pins = new Set(
46406
47200
  [...indexed.values()].filter((cell) => cell.node && result2.has(cell.node)).map(key)
46407
47201
  );
46408
- for (const cell of indexed.values())
46409
- if (charge(), cell.dependencies.some((dependency) => pins.has(dependency)))
47202
+ const pinPages = new Set(
47203
+ [...indexed.values()].filter((cell) => cell.node && result2.has(cell.node)).map((c2) => c2.pageId)
47204
+ );
47205
+ for (const cell of indexed.values()) {
47206
+ charge();
47207
+ if (cell.opaque && pinPages.has(cell.pageId))
47208
+ fail(
47209
+ "EDIT_UNSUPPORTED_DEPENDENCY",
47210
+ "A formula that may read a master rotation pin exists."
47211
+ );
47212
+ if (cell.dependencies.some((dependency) => pins.has(dependency)))
46410
47213
  fail("EDIT_UNSUPPORTED_DEPENDENCY", "A page cache depends on a master rotation pin.");
47214
+ }
46411
47215
  }
46412
47216
  return { pins: result2, dimensions: provenDimensions };
46413
47217
  }
@@ -46504,8 +47308,12 @@ function applyGeometryEdit(roots, document, edit, check, masterMoveProof = empty
46504
47308
  if (edit.type === "delete-shape") {
46505
47309
  unlocked("LockDelete");
46506
47310
  releaseDeletedGlue(roots, /* @__PURE__ */ new Map([[edit.pageId, /* @__PURE__ */ new Set([edit.shapeId])]]));
46507
- assertVisioShapeUnreferenced(roots, edit.pageId, edit.shapeId, { check });
47311
+ const frozen = assertVisioShapeUnreferenced(roots, edit.pageId, edit.shapeId, {
47312
+ check,
47313
+ freeze: true
47314
+ });
46508
47315
  shape.parentNode.removeChild(shape);
47316
+ freezeVisioCells(frozen);
46509
47317
  return [edit.pageId];
46510
47318
  }
46511
47319
  if (edit.type === "rotate-shape" || edit.type === "flip-shape") {
@@ -47443,7 +48251,7 @@ async function recalculatePageFormulas(pkg, pagesPart, pages, paths, dirty, chec
47443
48251
  }
47444
48252
 
47445
48253
  // visio/edit-page-rename.ts
47446
- var escape3 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48254
+ var escape4 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47447
48255
  function localCell(node3) {
47448
48256
  const row2 = node3.parentNode;
47449
48257
  const section3 = row2?.parentNode;
@@ -47472,7 +48280,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47472
48280
  }
47473
48281
  const roots = await editableVisioPageRoots(pkg, pagesPart, pages, pagePaths, dirty, check);
47474
48282
  const changedCells = [];
47475
- const prefix2 = new RegExp(`Pages\\[${escape3(oldUniversal)}\\]!`, "gi");
48283
+ const prefix2 = new RegExp(`Pages\\[${escape4(oldUniversal)}\\]!`, "gi");
47476
48284
  const targetByPath = new Map([...pagePaths].map(([id3, path3]) => [path3, id3]));
47477
48285
  for (const [path3, root2] of roots) {
47478
48286
  let changed = false;
@@ -47506,7 +48314,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47506
48314
  if (cell) changedCells.push({ node: node3, cell });
47507
48315
  }
47508
48316
  } else if (/\bPAGENAME\s*\(/i.test(code)) {
47509
- if (target2 === pageId2 || !target2 || new RegExp(`Pages\\[${escape3(oldUniversal)}\\]!`, "i").test(code))
48317
+ if (target2 === pageId2 || !target2 || new RegExp(`Pages\\[${escape4(oldUniversal)}\\]!`, "i").test(code))
47510
48318
  fail(
47511
48319
  "EDIT_UNSUPPORTED_PAGE_NAME_FORMULA",
47512
48320
  "Complex page-name formula caches cannot be safely refreshed."
@@ -47556,7 +48364,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47556
48364
  for (const changed of changedCells) {
47557
48365
  if (changed.node === node3) continue;
47558
48366
  const reference2 = new RegExp(
47559
- `(?:^|[^a-z0-9_.])${escape3(changed.cell)}(?:$|[^a-z0-9_.])`,
48367
+ `(?:^|[^a-z0-9_.])${escape4(changed.cell)}(?:$|[^a-z0-9_.])`,
47560
48368
  "i"
47561
48369
  );
47562
48370
  if (reference2.test(unquotedVisioFormula(formula2)))
@@ -47578,7 +48386,7 @@ async function renameVisioPage(pkg, pagesPart, pages, pagePaths, dirty, pageId2,
47578
48386
  // visio/edit-page-delete.ts
47579
48387
  var officeRel = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
47580
48388
  var pageType = "http://schemas.microsoft.com/visio/2010/relationships/page";
47581
- var escape4 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48389
+ var escape5 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47582
48390
  async function deleteVisioPage(pkg, pagesPart, pages, rels, types, pagePaths, parts, dirty, removed, pageId2, check) {
47583
48391
  const existing = children2(pages, "Page");
47584
48392
  const page = existing.find((node3) => attribute2(node3, "ID") === pageId2);
@@ -47587,7 +48395,7 @@ async function deleteVisioPage(pkg, pagesPart, pages, rels, types, pagePaths, pa
47587
48395
  const names = new Set(
47588
48396
  ["Name", "NameU"].map((key2) => attribute2(page, key2)).filter((value3) => !!value3)
47589
48397
  );
47590
- const reference2 = new RegExp(`Pages\\[(?:${[...names].map(escape4).join("|")})\\]!`, "i");
48398
+ const reference2 = new RegExp(`Pages\\[(?:${[...names].map(escape5).join("|")})\\]!`, "i");
47591
48399
  const documentPart2 = await related(pkg, "", "document");
47592
48400
  const roots = await editableVisioPageRoots(
47593
48401
  pkg,
@@ -47912,7 +48720,7 @@ function createVisioPagePart(parts, pages, pageId2, check) {
47912
48720
  }
47913
48721
 
47914
48722
  // visio/edit-page-decoration.ts
47915
- var escape5 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
48723
+ var escape6 = (value3) => value3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47916
48724
  var name2 = (page) => attribute2(page, "NameU") ?? attribute2(page, "Name") ?? "";
47917
48725
  function largestShapeId(root2) {
47918
48726
  let largest = 0;
@@ -47928,9 +48736,9 @@ function removeDecoration(root2, pageName, kind, pageRoots, check) {
47928
48736
  ) : [];
47929
48737
  if (!targets.length) return false;
47930
48738
  const ids = targets.map((shape) => attribute2(shape, "ID") ?? "");
47931
- const local = new RegExp(`\\bSheet\\.(?:${ids.map(escape5).join("|")})!`, "i");
48739
+ const local = new RegExp(`\\bSheet\\.(?:${ids.map(escape6).join("|")})!`, "i");
47932
48740
  const remote = new RegExp(
47933
- `Pages\\[${escape5(pageName)}\\]!Sheet\\.(?:${ids.map(escape5).join("|")})!`,
48741
+ `Pages\\[${escape6(pageName)}\\]!Sheet\\.(?:${ids.map(escape6).join("|")})!`,
47934
48742
  "i"
47935
48743
  );
47936
48744
  for (const connect of children2(root2, "Connects").flatMap((node3) => children2(node3, "Connect")))
@@ -48764,17 +49572,117 @@ async function formatTarget(pkg, pagePaths, roots, document, edit, check, instan
48764
49572
  return true;
48765
49573
  }
48766
49574
 
49575
+ // visio/edit-duplicate-line.ts
49576
+ var ENDS2 = ["BeginX", "BeginY", "EndX", "EndY"];
49577
+ var connects = (root2) => children2(root2, "Connects").flatMap((container) => children2(container, "Connect"));
49578
+ var gluedTargets = (root2, id3) => connects(root2).filter((row2) => attribute2(row2, "FromSheet") === id3).map((row2) => attribute2(row2, "ToSheet") ?? "");
49579
+ function assertGlueDroppable(root2, id3, copied, code = "UNSUPPORTED_DUPLICATE") {
49580
+ if (gluedTargets(root2, id3).some((target2) => copied.has(target2)))
49581
+ fail(code, "A glued connector cannot be copied together with a shape it is glued to yet.");
49582
+ }
49583
+ function assertEndFormulas(read, code) {
49584
+ for (const name3 of ENDS2) {
49585
+ const formula2 = executableCellFormula(attribute2(read(name3), "F"));
49586
+ if (formula2 && !isNativeGlueCell(name3, formula2))
49587
+ fail(code, `${name3} of the line holds a formula that is not native glue.`);
49588
+ }
49589
+ }
49590
+ var isLineSheet2 = (shape) => ENDS2.some((name3) => cells(shape).has(name3));
49591
+ function planLineCopy(shape, code = "UNSUPPORTED_DUPLICATE") {
49592
+ proveLocalLine(shape);
49593
+ assertEndFormulas((name3) => cells(shape).get(name3), code);
49594
+ const local = cells(shape);
49595
+ return { x: numeric(local.get("PinX")), y: numeric(local.get("PinY")) };
49596
+ }
49597
+ var shift2 = (node3, delta, name3) => {
49598
+ if (!node3) fail("UNSUPPORTED_DUPLICATE", `The line has no local ${name3}.`);
49599
+ const value3 = numeric(node3);
49600
+ node3.setAttribute("V", String(Object.is(value3 + delta, -0) ? 0 : value3 + delta));
49601
+ node3.removeAttribute("E");
49602
+ };
49603
+ function finishLineCopy(shape, dx, dy) {
49604
+ const local = cells(shape);
49605
+ for (const name3 of ENDS2) {
49606
+ const node3 = local.get(name3);
49607
+ const formula2 = executableCellFormula(attribute2(node3, "F"));
49608
+ if (formula2 && isNativeGlueCell(name3, formula2)) node3.removeAttribute("F");
49609
+ shift2(node3, name3.endsWith("X") ? dx : dy, name3);
49610
+ }
49611
+ shift2(local.get("PinX"), dx, "PinX");
49612
+ shift2(local.get("PinY"), dy, "PinY");
49613
+ }
49614
+ var isStencilConnector2 = (target2) => ENDS2.some((name3) => instanceCell(target2, name3));
49615
+ function planConnectorCopy(target2, code = "UNSUPPORTED_DUPLICATE") {
49616
+ const local = cells(target2.instance);
49617
+ for (const name3 of [...ENDS2, "PinX", "PinY"]) {
49618
+ const node3 = local.get(name3);
49619
+ if (!node3?.hasAttribute("V") || node3.hasAttribute("E"))
49620
+ fail(code, `The stencil connector has no usable local ${name3}.`);
49621
+ numeric(node3);
49622
+ }
49623
+ assertEndFormulas((name3) => local.get(name3), code);
49624
+ return { x: numeric(local.get("PinX")), y: numeric(local.get("PinY")) };
49625
+ }
49626
+ function finishConnectorCopy(shape, id3, dx, dy) {
49627
+ const local = cells(shape);
49628
+ for (const name3 of ENDS2) shift2(local.get(name3), name3.endsWith("X") ? dx : dy, name3);
49629
+ shift2(local.get("PinX"), dx, "PinX");
49630
+ shift2(local.get("PinY"), dy, "PinY");
49631
+ for (const name3 of ["BegTrigger", "EndTrigger"]) {
49632
+ const node3 = local.get(name3);
49633
+ if (!node3) continue;
49634
+ node3.setAttribute("F", visioGlueTrigger(id3));
49635
+ node3.setAttribute("V", "1");
49636
+ }
49637
+ }
49638
+ var CLEARANCE = 0.25;
49639
+ var endsBox = (shape, dx, dy) => {
49640
+ const local = cells(shape);
49641
+ const x = [numeric(local.get("BeginX")) + dx, numeric(local.get("EndX")) + dx];
49642
+ const y = [numeric(local.get("BeginY")) + dy, numeric(local.get("EndY")) + dy];
49643
+ return {
49644
+ minX: Math.min(...x) - CLEARANCE,
49645
+ maxX: Math.max(...x) + CLEARANCE,
49646
+ minY: Math.min(...y) - CLEARANCE,
49647
+ maxY: Math.max(...y) + CLEARANCE
49648
+ };
49649
+ };
49650
+ function assertConnectorCopyApart(root2, copies, dx, dy, code = "UNSUPPORTED_DUPLICATE") {
49651
+ const boxes = copies.map((shape) => endsBox(shape, dx, dy));
49652
+ for (const container of children2(root2, "Shapes"))
49653
+ for (const other of children2(container, "Shape")) {
49654
+ const local = cells(other);
49655
+ const formula2 = executableCellFormula(attribute2(local.get("BeginX"), "F")) ?? "";
49656
+ if (!/^_WALKGLUE\(/i.test(formula2)) continue;
49657
+ const box4 = endsBox(other, 0, 0);
49658
+ for (const copy8 of boxes)
49659
+ if (copy8.minX <= box4.maxX && box4.minX <= copy8.maxX && copy8.minY <= box4.maxY && box4.minY <= copy8.maxY)
49660
+ fail(
49661
+ code,
49662
+ "The copy of a connector would meet another connector, which Visio lays out again."
49663
+ );
49664
+ }
49665
+ }
49666
+
48767
49667
  // visio/edit-instance-duplicate.ts
48768
- async function planInstanceCopy(pkg, pageId2, sourceRoot, target2, offsetX, offsetY, code = "UNSUPPORTED_DUPLICATE") {
49668
+ async function planInstanceCopy(pkg, pageId2, sourceRoot, target2, offsetX, offsetY, code = "UNSUPPORTED_DUPLICATE", allowConnector = code === "UNSUPPORTED_DUPLICATE") {
48769
49669
  const id3 = attribute2(target2.instance, "ID");
48770
- if (["BeginX", "EndX"].some((name3) => instanceCell(target2, name3)) || connectRows(sourceRoot).some((row2) => attribute2(row2, "FromSheet") === id3))
49670
+ const connector2 = allowConnector && isStencilConnector2(target2);
49671
+ if (!connector2 && (isStencilConnector2(target2) || connectRows(sourceRoot).some((row2) => attribute2(row2, "FromSheet") === id3)))
48771
49672
  fail(code, "Lines and connectors that come from a stencil cannot be copied yet.");
48772
49673
  await assertInstanceUnlocked(pkg, pageId2, target2, ["LockSelect"], "selection");
49674
+ if (connector2) {
49675
+ const pin2 = planConnectorCopy(target2, code);
49676
+ const x2 = pin2.x + offsetX, y2 = pin2.y + offsetY;
49677
+ if (Math.abs(x2) > 1e6 || Math.abs(y2) > 1e6)
49678
+ fail(code, "Duplicated pins exceed coordinate limits.");
49679
+ return { x: x2, y: y2, connector: connector2 };
49680
+ }
48773
49681
  const pin = instancePin(target2);
48774
49682
  const x = pin.x + offsetX, y = pin.y + offsetY;
48775
49683
  if (Math.abs(x) > 1e6 || Math.abs(y) > 1e6)
48776
49684
  fail(code, "Duplicated pins exceed coordinate limits.");
48777
- return { x, y };
49685
+ return { x, y, connector: connector2 };
48778
49686
  }
48779
49687
  function finishInstanceCopy(clone, template, x, y, taken, check) {
48780
49688
  const mapping = /* @__PURE__ */ new Map();
@@ -48858,7 +49766,18 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48858
49766
  structural ||= !source || await shapeIsStructural(source, template);
48859
49767
  }
48860
49768
  await assertDuplicateScope(pkg, pagePaths, root2, newIds, check, structural);
48861
- const indexed = indexCells(detached ? /* @__PURE__ */ new Map([[sourcePageId, sourceRoot]]) : roots, { check });
49769
+ const glueTargets = new Set(
49770
+ children2(sourceRoot, "Connects").flatMap(
49771
+ (container2) => children2(container2, "Connect").map((row2) => attribute2(row2, "ToSheet"))
49772
+ )
49773
+ );
49774
+ const indexed = indexCells(detached ? /* @__PURE__ */ new Map([[sourcePageId, sourceRoot]]) : roots, {
49775
+ check,
49776
+ scope: "affected",
49777
+ glueShapes: new Set(
49778
+ pageShapes(sourceRoot).filter((shape) => glueTargets.has(attribute2(shape, "ID")))
49779
+ )
49780
+ });
48862
49781
  const evaluate = createVisioCellEvaluator(indexed, { check }, true);
48863
49782
  const containers = children2(root2, "Shapes");
48864
49783
  if (containers.length > 1) fail("INVALID_SHAPE_ID", "Duplicate Shapes containers.");
@@ -48872,6 +49791,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48872
49791
  if (value3 !== void 0) occupied.add(value3.toLowerCase());
48873
49792
  }
48874
49793
  const plans = [];
49794
+ const copied = new Set(edit.copies.map((copy8) => copy8.shapeId));
48875
49795
  let cloneNodes = 0, cloneCharacters = buildXml(root2).length;
48876
49796
  const size3 = (source) => {
48877
49797
  cloneNodes += source.getElementsByTagName("*").length + 1;
@@ -48888,6 +49808,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48888
49808
  "UNSUPPORTED_DUPLICATE"
48889
49809
  );
48890
49810
  if (stencil) {
49811
+ assertGlueDroppable(sourceRoot, copy8.shapeId, copied);
48891
49812
  const pin = await planInstanceCopy(
48892
49813
  pkg,
48893
49814
  edit.pageId,
@@ -48900,18 +49821,33 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48900
49821
  plans.push({
48901
49822
  source: stencil.instance,
48902
49823
  id: copy8.newShapeId,
48903
- ...pin,
49824
+ x: pin.x,
49825
+ y: pin.y,
49826
+ ...pin.connector ? { connector: true } : {},
48904
49827
  template: stencil.template
48905
49828
  });
48906
49829
  continue;
48907
49830
  }
49831
+ const line = pageShapes(sourceRoot).find((shape) => attribute2(shape, "ID") === copy8.shapeId);
49832
+ if (line && !line.hasAttribute("Master") && isLineSheet2(line)) {
49833
+ assertCloneLeaf(line);
49834
+ assertUnlayeredShape(line, document);
49835
+ assertShapeLocks(line, document, ["LockSelect"]);
49836
+ assertGlueDroppable(sourceRoot, copy8.shapeId, copied);
49837
+ const pin = planLineCopy(line);
49838
+ if (Math.abs(pin.x + edit.offsetX) > 1e6 || Math.abs(pin.y + edit.offsetY) > 1e6)
49839
+ fail("UNSUPPORTED_DUPLICATE", "Duplicated pins exceed coordinate limits.");
49840
+ size3(line);
49841
+ plans.push({ source: line, id: copy8.newShapeId, x: pin.x, y: pin.y, line: true });
49842
+ continue;
49843
+ }
48908
49844
  const source = admitted(sourceRoot, copy8.shapeId);
48909
49845
  assertCloneLeaf(source);
48910
49846
  assertUnlayeredShape(source, document);
48911
49847
  assertShapeLocks(source, document, ["LockSelect"]);
48912
- for (const connects of children2(sourceRoot, "Connects"))
48913
- for (const connection of children2(connects, "Connect"))
48914
- if (["FromSheet", "ToSheet"].some((name3) => attribute2(connection, name3) === copy8.shapeId))
49848
+ for (const connects2 of children2(sourceRoot, "Connects"))
49849
+ for (const connection of children2(connects2, "Connect"))
49850
+ if (attribute2(connection, "FromSheet") === copy8.shapeId)
48915
49851
  fail("UNSUPPORTED_DUPLICATE", "Glued shapes cannot be duplicated safely.");
48916
49852
  const x = numeric(formattingCell(source, "PinX")), y = numeric(formattingCell(source, "PinY"));
48917
49853
  for (const [name3, offset] of [
@@ -48926,6 +49862,9 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48926
49862
  size3(source);
48927
49863
  plans.push({ source, id: copy8.newShapeId, x: x + edit.offsetX, y: y + edit.offsetY });
48928
49864
  }
49865
+ const connectorSources = plans.filter((plan) => plan.connector).map((plan) => plan.source);
49866
+ if (connectorSources.length)
49867
+ assertConnectorCopyApart(root2, connectorSources, edit.offsetX, edit.offsetY);
48929
49868
  const order = new Map(
48930
49869
  children2(children2(sourceRoot, "Shapes")[0], "Shape").map((source, index2) => [source, index2])
48931
49870
  );
@@ -48936,6 +49875,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48936
49875
  check();
48937
49876
  const shape = root2.ownerDocument.importNode(plan.source, true);
48938
49877
  copyIdentity(shape, plan.id, names);
49878
+ if (plan.line) finishLineCopy(shape, edit.offsetX, edit.offsetY);
48939
49879
  for (const node3 of [shape, ...Array.from(shape.getElementsByTagName("*"))]) {
48940
49880
  const source = executableCellFormula(attribute2(node3, "F"));
48941
49881
  if (!source) continue;
@@ -48954,6 +49894,15 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48954
49894
  )
48955
49895
  );
48956
49896
  }
49897
+ if (plan.line) {
49898
+ container.appendChild(shape);
49899
+ continue;
49900
+ }
49901
+ if (plan.connector) {
49902
+ finishConnectorCopy(shape, plan.id, edit.offsetX, edit.offsetY);
49903
+ container.appendChild(shape);
49904
+ continue;
49905
+ }
48957
49906
  if (plan.template) {
48958
49907
  for (const id3 of newIds) ids.add(id3);
48959
49908
  finishInstanceCopy(shape, plan.template, plan.x, plan.y, ids, check);
@@ -48970,7 +49919,7 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
48970
49919
  }
48971
49920
  container.appendChild(shape);
48972
49921
  }
48973
- const local = plans.filter((plan) => !plan.template);
49922
+ const local = plans.filter((plan) => !plan.template && !plan.line);
48974
49923
  if (changed.length) {
48975
49924
  await assertGeometryPackageScope(
48976
49925
  pkg,
@@ -49004,6 +49953,9 @@ async function duplicateVisioShapes(pkg, pagePaths, roots, document, edit, check
49004
49953
  }
49005
49954
  const dirty = /* @__PURE__ */ new Set([edit.pageId]);
49006
49955
  for (const id3 of recalculateVisioCells(roots, changed, { check })) dirty.add(id3);
49956
+ for (const plan of plans)
49957
+ if (!plan.line && !plan.connector)
49958
+ for (const id3 of rerouteBlockedConnectors(roots, edit.pageId, plan.id, check)) dirty.add(id3);
49007
49959
  return [...dirty];
49008
49960
  }
49009
49961
  function assertCloneLeaf(source) {
@@ -49334,9 +50286,10 @@ function deleteVisioShapes(roots, document, edits, check, instances = /* @__PURE
49334
50286
  }
49335
50287
  releaseStencilGlue(roots, removed);
49336
50288
  releaseDeletedGlue(roots, removed);
49337
- assertVisioShapesUnreferenced(roots, removed, { check });
50289
+ const frozen = assertVisioShapesUnreferenced(roots, removed, { check, freeze: true });
49338
50290
  check();
49339
50291
  for (const shape of shapes) shape.parentNode.removeChild(shape);
50292
+ freezeVisioCells(frozen);
49340
50293
  for (const pageId2 of removed.keys())
49341
50294
  for (const container of children2(roots.get(pageId2), "Connects"))
49342
50295
  if (!children2(container, "Connect").length) container.parentNode.removeChild(container);
@@ -49365,8 +50318,8 @@ function admittedShape(root2, document, shapeId2) {
49365
50318
  if (["1", "true"].includes(attribute2(shape, "Del") ?? "")) refuse3("The shape is deleted.");
49366
50319
  const local = cells(shape);
49367
50320
  if (isLineSheet(local)) refuse3("Lines and connectors (1D shapes) cannot change shape.");
49368
- for (const connects of children2(root2, "Connects"))
49369
- for (const connect of children2(connects, "Connect"))
50321
+ for (const connects2 of children2(root2, "Connects"))
50322
+ for (const connect of children2(connects2, "Connect"))
49370
50323
  if (["FromSheet", "ToSheet"].some((name3) => attribute2(connect, name3) === shapeId2))
49371
50324
  refuse3("Glued connectors would need rerouting, which is not supported yet.");
49372
50325
  if (children2(shape, "Section").some((section3) => attribute2(section3, "N") === "Controls"))
@@ -50809,8 +51762,8 @@ async function captureVisioClipboard(input, pageId2, shapeIds2, options2 = {}) {
50809
51762
  numeric(formattingCell(source, name3));
50810
51763
  evaluate(key({ pageId: pageId2, shapeId: id3, cell: name3 }));
50811
51764
  }
50812
- for (const connects of children2(root2, "Connects"))
50813
- for (const connection of children2(connects, "Connect"))
51765
+ for (const connects2 of children2(root2, "Connects"))
51766
+ for (const connection of children2(connects2, "Connect"))
50814
51767
  if (["FromSheet", "ToSheet"].some((name3) => attribute2(connection, name3) === id3))
50815
51768
  fail("UNSUPPORTED_CLIPBOARD", "Glued shapes cannot be captured safely.");
50816
51769
  }
@@ -51351,8 +52304,8 @@ function assertUnreferenced3(roots, shapeId2, check) {
51351
52304
  if (reference2.test(executableCellFormula(attribute2(cell, "F")) ?? ""))
51352
52305
  fail("UNSUPPORTED_GUIDE_EDIT", "A shape formula refers to this guide.");
51353
52306
  }
51354
- for (const connects of children2(root2, "Connects"))
51355
- for (const row2 of children2(connects, "Connect"))
52307
+ for (const connects2 of children2(root2, "Connects"))
52308
+ for (const row2 of children2(connects2, "Connect"))
51356
52309
  if (attribute2(row2, "ToSheet") === shapeId2 || attribute2(row2, "FromSheet") === shapeId2)
51357
52310
  fail("UNSUPPORTED_GUIDE_EDIT", "Shapes are glued to this guide.");
51358
52311
  }
@@ -51729,6 +52682,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
51729
52682
  if (deleteOnly)
51730
52683
  for (const pageId2 of deleteVisioShapes(roots, document, deletions, check, instanceDeletes))
51731
52684
  dirty.set(pages.get(pageId2), roots.get(pageId2));
52685
+ const formulaDiagnostics = [];
51732
52686
  const noteTextSize = async (target2, root2) => {
51733
52687
  if (await measuresOwnText(root2, target2.shapeId, masterTemplate(pkg), check))
51734
52688
  clock.textSizes.push({ pageId: target2.pageId, shapeId: target2.shapeId });
@@ -51744,7 +52698,15 @@ async function editVsdxTransaction(input, edits, options2, clock = {
51744
52698
  roots.set(command2.pageId, root2);
51745
52699
  }
51746
52700
  if (command2.type === "replace-plain-text" || command2.type === "replace-text-ranges") {
51747
- if (await (command2.type === "replace-plain-text" ? replaceScopedPlainText(pkg, new Set(pages.values()), roots, document, command2, check) : replaceScopedTextRanges(pkg, new Set(pages.values()), roots, document, command2, check))) {
52701
+ if (await (command2.type === "replace-plain-text" ? replaceScopedPlainText(
52702
+ pkg,
52703
+ new Set(pages.values()),
52704
+ roots,
52705
+ document,
52706
+ command2,
52707
+ check,
52708
+ formulaDiagnostics
52709
+ ) : replaceScopedTextRanges(pkg, new Set(pages.values()), roots, document, command2, check))) {
51748
52710
  dirty.set(path3, root2);
51749
52711
  textChanged = true;
51750
52712
  await noteTextSize(command2, root2);
@@ -51890,6 +52852,7 @@ async function editVsdxTransaction(input, edits, options2, clock = {
51890
52852
  bytes,
51891
52853
  changedParts: [...dirty.keys()],
51892
52854
  diagnostics: [
52855
+ ...formulaDiagnostics,
51893
52856
  ...pasteChanged ? [
51894
52857
  {
51895
52858
  code: "edit-paste-experimental",