@rowsncolumns/spreadsheet-state 28.0.75 → 29.0.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 (259) hide show
  1. package/dist/cjs/api/anchored-objects.d.ts +66 -0
  2. package/dist/cjs/api/anchored-objects.d.ts.map +1 -0
  3. package/dist/cjs/api/anchored-objects.js +259 -0
  4. package/dist/cjs/api/copy-paste.d.ts +8 -1
  5. package/dist/cjs/api/copy-paste.d.ts.map +1 -1
  6. package/dist/cjs/api/copy-paste.js +4 -2
  7. package/dist/cjs/api/dependency.d.ts +13 -2
  8. package/dist/cjs/api/dependency.d.ts.map +1 -1
  9. package/dist/cjs/api/dependency.js +11 -5
  10. package/dist/cjs/api/formula.d.ts +61 -4
  11. package/dist/cjs/api/formula.d.ts.map +1 -1
  12. package/dist/cjs/api/formula.js +250 -61
  13. package/dist/cjs/api/immer-utils.d.ts +11 -1
  14. package/dist/cjs/api/immer-utils.d.ts.map +1 -1
  15. package/dist/cjs/api/immer-utils.js +17 -1
  16. package/dist/cjs/api/insert-cut-cells.d.ts +35 -0
  17. package/dist/cjs/api/insert-cut-cells.d.ts.map +1 -0
  18. package/dist/cjs/api/insert-cut-cells.js +60 -0
  19. package/dist/cjs/api/merges.d.ts +16 -0
  20. package/dist/cjs/api/merges.d.ts.map +1 -1
  21. package/dist/cjs/api/merges.js +75 -1
  22. package/dist/cjs/api/named-range-structural.d.ts +62 -0
  23. package/dist/cjs/api/named-range-structural.d.ts.map +1 -0
  24. package/dist/cjs/api/named-range-structural.js +197 -0
  25. package/dist/cjs/api/range-rule-helpers.d.ts +45 -1
  26. package/dist/cjs/api/range-rule-helpers.d.ts.map +1 -1
  27. package/dist/cjs/api/range-rule-helpers.js +159 -6
  28. package/dist/cjs/api/structural-formula-update.d.ts.map +1 -1
  29. package/dist/cjs/api/structural-formula-update.js +24 -6
  30. package/dist/cjs/api/structural-guards.d.ts +78 -0
  31. package/dist/cjs/api/structural-guards.d.ts.map +1 -0
  32. package/dist/cjs/api/structural-guards.js +202 -0
  33. package/dist/cjs/api/structural-table-refs.d.ts +94 -0
  34. package/dist/cjs/api/structural-table-refs.d.ts.map +1 -0
  35. package/dist/cjs/api/structural-table-refs.js +313 -0
  36. package/dist/cjs/api/subtotal.d.ts +20 -13
  37. package/dist/cjs/api/subtotal.d.ts.map +1 -1
  38. package/dist/cjs/api/subtotal.js +26 -19
  39. package/dist/cjs/commands.d.ts +9 -0
  40. package/dist/cjs/commands.d.ts.map +1 -1
  41. package/dist/cjs/constants.d.ts +25 -0
  42. package/dist/cjs/constants.d.ts.map +1 -0
  43. package/dist/cjs/constants.js +26 -0
  44. package/dist/cjs/hooks/use-calculation-worker.d.ts.map +1 -1
  45. package/dist/cjs/hooks/use-calculation-worker.js +64 -6
  46. package/dist/cjs/hooks/use-calculation.d.ts +7 -0
  47. package/dist/cjs/hooks/use-calculation.d.ts.map +1 -1
  48. package/dist/cjs/hooks/use-calculation.js +15 -0
  49. package/dist/cjs/hooks/use-on-calculation-success.d.ts +7 -0
  50. package/dist/cjs/hooks/use-on-calculation-success.d.ts.map +1 -1
  51. package/dist/cjs/hooks/use-on-calculation-success.js +7 -1
  52. package/dist/cjs/hooks/use-on-copy.d.ts +1 -1
  53. package/dist/cjs/hooks/use-on-copy.d.ts.map +1 -1
  54. package/dist/cjs/hooks/use-on-copy.js +2 -3
  55. package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts +13 -3
  56. package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -1
  57. package/dist/cjs/hooks/use-on-delete-cells-shift-left.js +27 -2
  58. package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts +13 -3
  59. package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -1
  60. package/dist/cjs/hooks/use-on-delete-cells-shift-up.js +27 -2
  61. package/dist/cjs/hooks/use-on-delete-column.d.ts +13 -4
  62. package/dist/cjs/hooks/use-on-delete-column.d.ts.map +1 -1
  63. package/dist/cjs/hooks/use-on-delete-column.js +14 -2
  64. package/dist/cjs/hooks/use-on-delete-row.d.ts +13 -4
  65. package/dist/cjs/hooks/use-on-delete-row.d.ts.map +1 -1
  66. package/dist/cjs/hooks/use-on-delete-row.js +14 -2
  67. package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts +13 -3
  68. package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -1
  69. package/dist/cjs/hooks/use-on-insert-cells-shift-down.js +27 -2
  70. package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts +13 -3
  71. package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -1
  72. package/dist/cjs/hooks/use-on-insert-cells-shift-right.js +27 -2
  73. package/dist/cjs/hooks/use-on-insert-column.d.ts +10 -3
  74. package/dist/cjs/hooks/use-on-insert-column.d.ts.map +1 -1
  75. package/dist/cjs/hooks/use-on-insert-column.js +33 -7
  76. package/dist/cjs/hooks/use-on-insert-row.d.ts +10 -3
  77. package/dist/cjs/hooks/use-on-insert-row.d.ts.map +1 -1
  78. package/dist/cjs/hooks/use-on-insert-row.js +32 -7
  79. package/dist/cjs/hooks/use-on-move-columns.d.ts +2 -1
  80. package/dist/cjs/hooks/use-on-move-columns.d.ts.map +1 -1
  81. package/dist/cjs/hooks/use-on-move-columns.js +14 -5
  82. package/dist/cjs/hooks/use-on-move-rows.d.ts +16 -1
  83. package/dist/cjs/hooks/use-on-move-rows.d.ts.map +1 -1
  84. package/dist/cjs/hooks/use-on-move-rows.js +30 -5
  85. package/dist/cjs/hooks/use-on-move-selection.d.ts +7 -2
  86. package/dist/cjs/hooks/use-on-move-selection.d.ts.map +1 -1
  87. package/dist/cjs/hooks/use-on-move-selection.js +14 -1
  88. package/dist/cjs/hooks/use-on-paste.d.ts +12 -2
  89. package/dist/cjs/hooks/use-on-paste.d.ts.map +1 -1
  90. package/dist/cjs/hooks/use-on-paste.js +56 -8
  91. package/dist/cjs/hooks/use-spreadsheet-state.d.ts +16 -5
  92. package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
  93. package/dist/cjs/hooks/use-spreadsheet-state.js +141 -18
  94. package/dist/cjs/hooks/use-structured-reference.d.ts.map +1 -1
  95. package/dist/cjs/hooks/use-structured-reference.js +10 -6
  96. package/dist/cjs/index.d.ts +4 -0
  97. package/dist/cjs/index.d.ts.map +1 -1
  98. package/dist/cjs/index.js +4 -0
  99. package/dist/cjs/interface/calculation-interface.d.ts +9 -0
  100. package/dist/cjs/interface/calculation-interface.d.ts.map +1 -1
  101. package/dist/cjs/interface/calculation-interface.js +31 -2
  102. package/dist/cjs/interface/delete-cells-shift-left.d.ts +8 -1
  103. package/dist/cjs/interface/delete-cells-shift-left.d.ts.map +1 -1
  104. package/dist/cjs/interface/delete-cells-shift-left.js +158 -80
  105. package/dist/cjs/interface/delete-cells-shift-up.d.ts +9 -1
  106. package/dist/cjs/interface/delete-cells-shift-up.d.ts.map +1 -1
  107. package/dist/cjs/interface/delete-cells-shift-up.js +155 -73
  108. package/dist/cjs/interface/delete-column.d.ts +1 -1
  109. package/dist/cjs/interface/delete-column.d.ts.map +1 -1
  110. package/dist/cjs/interface/delete-column.js +109 -50
  111. package/dist/cjs/interface/delete-row.d.ts +1 -1
  112. package/dist/cjs/interface/delete-row.d.ts.map +1 -1
  113. package/dist/cjs/interface/delete-row.js +105 -46
  114. package/dist/cjs/interface/insert-cells-shift-down.d.ts +10 -1
  115. package/dist/cjs/interface/insert-cells-shift-down.d.ts.map +1 -1
  116. package/dist/cjs/interface/insert-cells-shift-down.js +147 -52
  117. package/dist/cjs/interface/insert-cells-shift-right.d.ts +10 -1
  118. package/dist/cjs/interface/insert-cells-shift-right.d.ts.map +1 -1
  119. package/dist/cjs/interface/insert-cells-shift-right.js +154 -58
  120. package/dist/cjs/interface/insert-column.d.ts +1 -1
  121. package/dist/cjs/interface/insert-column.d.ts.map +1 -1
  122. package/dist/cjs/interface/insert-column.js +80 -26
  123. package/dist/cjs/interface/insert-row.d.ts +1 -1
  124. package/dist/cjs/interface/insert-row.d.ts.map +1 -1
  125. package/dist/cjs/interface/insert-row.js +63 -15
  126. package/dist/cjs/interface/spreadsheet-interface.d.ts.map +1 -1
  127. package/dist/cjs/interface/spreadsheet-interface.js +33 -0
  128. package/dist/cjs/sheet-cell.d.ts.map +1 -1
  129. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  130. package/dist/esm/api/anchored-objects.d.ts +66 -0
  131. package/dist/esm/api/anchored-objects.d.ts.map +1 -0
  132. package/dist/esm/api/anchored-objects.js +212 -0
  133. package/dist/esm/api/copy-paste.d.ts +8 -1
  134. package/dist/esm/api/copy-paste.d.ts.map +1 -1
  135. package/dist/esm/api/copy-paste.js +4 -2
  136. package/dist/esm/api/dependency.d.ts +13 -2
  137. package/dist/esm/api/dependency.d.ts.map +1 -1
  138. package/dist/esm/api/dependency.js +10 -4
  139. package/dist/esm/api/formula.d.ts +61 -4
  140. package/dist/esm/api/formula.d.ts.map +1 -1
  141. package/dist/esm/api/formula.js +238 -60
  142. package/dist/esm/api/immer-utils.d.ts +11 -1
  143. package/dist/esm/api/immer-utils.d.ts.map +1 -1
  144. package/dist/esm/api/immer-utils.js +16 -0
  145. package/dist/esm/api/insert-cut-cells.d.ts +35 -0
  146. package/dist/esm/api/insert-cut-cells.d.ts.map +1 -0
  147. package/dist/esm/api/insert-cut-cells.js +67 -0
  148. package/dist/esm/api/merges.d.ts +16 -0
  149. package/dist/esm/api/merges.d.ts.map +1 -1
  150. package/dist/esm/api/merges.js +60 -0
  151. package/dist/esm/api/named-range-structural.d.ts +62 -0
  152. package/dist/esm/api/named-range-structural.d.ts.map +1 -0
  153. package/dist/esm/api/named-range-structural.js +176 -0
  154. package/dist/esm/api/range-rule-helpers.d.ts +45 -1
  155. package/dist/esm/api/range-rule-helpers.d.ts.map +1 -1
  156. package/dist/esm/api/range-rule-helpers.js +153 -1
  157. package/dist/esm/api/structural-formula-update.d.ts.map +1 -1
  158. package/dist/esm/api/structural-formula-update.js +24 -6
  159. package/dist/esm/api/structural-guards.d.ts +78 -0
  160. package/dist/esm/api/structural-guards.d.ts.map +1 -0
  161. package/dist/esm/api/structural-guards.js +186 -0
  162. package/dist/esm/api/structural-table-refs.d.ts +94 -0
  163. package/dist/esm/api/structural-table-refs.d.ts.map +1 -0
  164. package/dist/esm/api/structural-table-refs.js +219 -0
  165. package/dist/esm/api/subtotal.d.ts +20 -13
  166. package/dist/esm/api/subtotal.d.ts.map +1 -1
  167. package/dist/esm/api/subtotal.js +15 -8
  168. package/dist/esm/commands.d.ts +9 -0
  169. package/dist/esm/commands.d.ts.map +1 -1
  170. package/dist/esm/constants.d.ts +25 -0
  171. package/dist/esm/constants.d.ts.map +1 -0
  172. package/dist/esm/constants.js +26 -0
  173. package/dist/esm/hooks/use-calculation-worker.d.ts.map +1 -1
  174. package/dist/esm/hooks/use-calculation-worker.js +45 -0
  175. package/dist/esm/hooks/use-calculation.d.ts +7 -0
  176. package/dist/esm/hooks/use-calculation.d.ts.map +1 -1
  177. package/dist/esm/hooks/use-calculation.js +15 -0
  178. package/dist/esm/hooks/use-on-calculation-success.d.ts +7 -0
  179. package/dist/esm/hooks/use-on-calculation-success.d.ts.map +1 -1
  180. package/dist/esm/hooks/use-on-calculation-success.js +7 -1
  181. package/dist/esm/hooks/use-on-copy.d.ts +1 -1
  182. package/dist/esm/hooks/use-on-copy.d.ts.map +1 -1
  183. package/dist/esm/hooks/use-on-copy.js +2 -3
  184. package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts +13 -3
  185. package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -1
  186. package/dist/esm/hooks/use-on-delete-cells-shift-left.js +26 -2
  187. package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts +13 -3
  188. package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -1
  189. package/dist/esm/hooks/use-on-delete-cells-shift-up.js +26 -2
  190. package/dist/esm/hooks/use-on-delete-column.d.ts +13 -4
  191. package/dist/esm/hooks/use-on-delete-column.d.ts.map +1 -1
  192. package/dist/esm/hooks/use-on-delete-column.js +14 -2
  193. package/dist/esm/hooks/use-on-delete-row.d.ts +13 -4
  194. package/dist/esm/hooks/use-on-delete-row.d.ts.map +1 -1
  195. package/dist/esm/hooks/use-on-delete-row.js +14 -2
  196. package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts +13 -3
  197. package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -1
  198. package/dist/esm/hooks/use-on-insert-cells-shift-down.js +26 -2
  199. package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts +13 -3
  200. package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -1
  201. package/dist/esm/hooks/use-on-insert-cells-shift-right.js +26 -2
  202. package/dist/esm/hooks/use-on-insert-column.d.ts +10 -3
  203. package/dist/esm/hooks/use-on-insert-column.d.ts.map +1 -1
  204. package/dist/esm/hooks/use-on-insert-column.js +33 -7
  205. package/dist/esm/hooks/use-on-insert-row.d.ts +10 -3
  206. package/dist/esm/hooks/use-on-insert-row.d.ts.map +1 -1
  207. package/dist/esm/hooks/use-on-insert-row.js +32 -7
  208. package/dist/esm/hooks/use-on-move-columns.d.ts +2 -1
  209. package/dist/esm/hooks/use-on-move-columns.d.ts.map +1 -1
  210. package/dist/esm/hooks/use-on-move-columns.js +14 -5
  211. package/dist/esm/hooks/use-on-move-rows.d.ts +16 -1
  212. package/dist/esm/hooks/use-on-move-rows.d.ts.map +1 -1
  213. package/dist/esm/hooks/use-on-move-rows.js +30 -5
  214. package/dist/esm/hooks/use-on-move-selection.d.ts +7 -2
  215. package/dist/esm/hooks/use-on-move-selection.d.ts.map +1 -1
  216. package/dist/esm/hooks/use-on-move-selection.js +14 -1
  217. package/dist/esm/hooks/use-on-paste.d.ts +12 -2
  218. package/dist/esm/hooks/use-on-paste.d.ts.map +1 -1
  219. package/dist/esm/hooks/use-on-paste.js +41 -2
  220. package/dist/esm/hooks/use-spreadsheet-state.d.ts +16 -5
  221. package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
  222. package/dist/esm/hooks/use-spreadsheet-state.js +141 -17
  223. package/dist/esm/hooks/use-structured-reference.d.ts.map +1 -1
  224. package/dist/esm/hooks/use-structured-reference.js +10 -6
  225. package/dist/esm/index.d.ts +4 -0
  226. package/dist/esm/index.d.ts.map +1 -1
  227. package/dist/esm/index.js +4 -0
  228. package/dist/esm/interface/calculation-interface.d.ts +9 -0
  229. package/dist/esm/interface/calculation-interface.d.ts.map +1 -1
  230. package/dist/esm/interface/calculation-interface.js +33 -2
  231. package/dist/esm/interface/delete-cells-shift-left.d.ts +8 -1
  232. package/dist/esm/interface/delete-cells-shift-left.d.ts.map +1 -1
  233. package/dist/esm/interface/delete-cells-shift-left.js +135 -59
  234. package/dist/esm/interface/delete-cells-shift-up.d.ts +9 -1
  235. package/dist/esm/interface/delete-cells-shift-up.d.ts.map +1 -1
  236. package/dist/esm/interface/delete-cells-shift-up.js +133 -53
  237. package/dist/esm/interface/delete-column.d.ts +1 -1
  238. package/dist/esm/interface/delete-column.d.ts.map +1 -1
  239. package/dist/esm/interface/delete-column.js +96 -38
  240. package/dist/esm/interface/delete-row.d.ts +1 -1
  241. package/dist/esm/interface/delete-row.d.ts.map +1 -1
  242. package/dist/esm/interface/delete-row.js +98 -39
  243. package/dist/esm/interface/insert-cells-shift-down.d.ts +10 -1
  244. package/dist/esm/interface/insert-cells-shift-down.d.ts.map +1 -1
  245. package/dist/esm/interface/insert-cells-shift-down.js +116 -47
  246. package/dist/esm/interface/insert-cells-shift-right.d.ts +10 -1
  247. package/dist/esm/interface/insert-cells-shift-right.d.ts.map +1 -1
  248. package/dist/esm/interface/insert-cells-shift-right.js +120 -51
  249. package/dist/esm/interface/insert-column.d.ts +1 -1
  250. package/dist/esm/interface/insert-column.d.ts.map +1 -1
  251. package/dist/esm/interface/insert-column.js +68 -18
  252. package/dist/esm/interface/insert-row.d.ts +1 -1
  253. package/dist/esm/interface/insert-row.d.ts.map +1 -1
  254. package/dist/esm/interface/insert-row.js +60 -14
  255. package/dist/esm/interface/spreadsheet-interface.d.ts.map +1 -1
  256. package/dist/esm/interface/spreadsheet-interface.js +29 -0
  257. package/dist/esm/sheet-cell.d.ts.map +1 -1
  258. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  259. package/package.json +18 -18
@@ -86,6 +86,11 @@ export const updateFormulasForStructuralChange = (params) => {
86
86
  startColumnIndex: isInsert ? referenceIndex : referenceIndex + count,
87
87
  endColumnIndex: columnCount,
88
88
  };
89
+ // The cells a delete removes: any reference into them (that Pass 1 did not
90
+ // already contract) is broken to `#REF!` instead of sliding onto the cell
91
+ // that moves into its place.
92
+ const deletedRange = isInsert ? undefined : pass1Range;
93
+ const editedSheetName = getSheetName(sheetId);
89
94
  // ---- PASS 1 ----
90
95
  const pass1Formulas = collectUniqueDependentsForRange({
91
96
  draft,
@@ -104,10 +109,15 @@ export const updateFormulasForStructuralChange = (params) => {
104
109
  const formulaValue = sheetCell.formula;
105
110
  if (!formulaValue)
106
111
  continue;
107
- const activeSheetName = getSheetName(pos.sheetId);
112
+ // Scope to the EDITED sheet: a qualified `Sheet1!A1:A3` on another
113
+ // sheet expands like a local range, while that other sheet's own bare
114
+ // `A1:A3` (which resolves to ITS sheet) is left alone.
115
+ const rangeOptions = {
116
+ includeUnqualifiedReferences: pos.sheetId === sheetId,
117
+ };
108
118
  const updatedFormula = isInsert
109
- ? expandRangesInFormula(formulaValue, referenceIndex, count, axis, activeSheetName)
110
- : contractRangesInFormula(formulaValue, referenceIndex, count, axis, activeSheetName);
119
+ ? expandRangesInFormula(formulaValue, referenceIndex, count, axis, editedSheetName, rangeOptions)
120
+ : contractRangesInFormula(formulaValue, referenceIndex, count, axis, editedSheetName, rangeOptions);
111
121
  if (!updatedFormula || updatedFormula === formulaValue)
112
122
  continue;
113
123
  sheetCell.setFormulaValue(updatedFormula, false);
@@ -165,7 +175,7 @@ export const updateFormulasForStructuralChange = (params) => {
165
175
  shiftExternalDependentFormulaReferences({
166
176
  draft,
167
177
  position: pos,
168
- editedSheetName: getSheetName(sheetId),
178
+ editedSheetName,
169
179
  enqueueCalculation,
170
180
  enqueueGraphOperation,
171
181
  recalcCells,
@@ -173,6 +183,7 @@ export const updateFormulasForStructuralChange = (params) => {
173
183
  rowDelta,
174
184
  columnDelta,
175
185
  sourceRange: pass2SourceRange,
186
+ deletedRange,
176
187
  locale,
177
188
  rowCount,
178
189
  columnCount,
@@ -192,6 +203,7 @@ export const updateFormulasForStructuralChange = (params) => {
192
203
  rowDelta,
193
204
  columnDelta,
194
205
  sourceRange: pass2SourceRange,
206
+ deletedRange,
195
207
  locale,
196
208
  rowCount,
197
209
  columnCount,
@@ -206,7 +218,7 @@ export const updateFormulasForStructuralChange = (params) => {
206
218
  shiftExternalDependentFormulaReferences({
207
219
  draft,
208
220
  position,
209
- editedSheetName: getSheetName(sheetId),
221
+ editedSheetName,
210
222
  enqueueCalculation,
211
223
  enqueueGraphOperation,
212
224
  recalcCells,
@@ -214,6 +226,7 @@ export const updateFormulasForStructuralChange = (params) => {
214
226
  rowDelta,
215
227
  columnDelta,
216
228
  sourceRange: pass2SourceRange,
229
+ deletedRange,
217
230
  locale,
218
231
  rowCount,
219
232
  columnCount,
@@ -249,6 +262,7 @@ export const updateFormulasForStructuralChange = (params) => {
249
262
  rowIndex: pos.rowIndex,
250
263
  columnIndex: pos.columnIndex,
251
264
  },
265
+ activeSheetName: editedSheetName,
252
266
  enqueueCalculation,
253
267
  enqueueGraphOperation,
254
268
  recalcCells,
@@ -256,6 +270,7 @@ export const updateFormulasForStructuralChange = (params) => {
256
270
  rowDelta,
257
271
  columnDelta,
258
272
  sourceRange: pass2SourceRange,
273
+ deletedRange,
259
274
  locale,
260
275
  rowCount,
261
276
  columnCount,
@@ -285,6 +300,7 @@ export const updateFormulasForStructuralChange = (params) => {
285
300
  moveFormulaAtPosition({
286
301
  draft,
287
302
  position: { sheetId, rowIndex, columnIndex },
303
+ activeSheetName: editedSheetName,
288
304
  enqueueCalculation,
289
305
  enqueueGraphOperation,
290
306
  recalcCells,
@@ -292,6 +308,7 @@ export const updateFormulasForStructuralChange = (params) => {
292
308
  rowDelta,
293
309
  columnDelta,
294
310
  sourceRange: pass2SourceRange,
311
+ deletedRange,
295
312
  locale,
296
313
  rowCount,
297
314
  columnCount,
@@ -302,7 +319,7 @@ export const updateFormulasForStructuralChange = (params) => {
302
319
  }
303
320
  }
304
321
  };
305
- const shiftExternalDependentFormulaReferences = ({ draft, position, editedSheetName, enqueueCalculation, enqueueGraphOperation, recalcCells, movedKeys, rowDelta, columnDelta, sourceRange, locale, rowCount, columnCount, cellXfsRegistry, sharedStringRegistry, }) => {
322
+ const shiftExternalDependentFormulaReferences = ({ draft, position, editedSheetName, enqueueCalculation, enqueueGraphOperation, recalcCells, movedKeys, rowDelta, columnDelta, sourceRange, deletedRange, locale, rowCount, columnCount, cellXfsRegistry, sharedStringRegistry, }) => {
306
323
  const sheetCell = new SheetCell();
307
324
  const currentSheet = createSheetDraft(draft, position.sheetId, position.rowIndex);
308
325
  const cellData = currentSheet[position.rowIndex]?.values?.[position.columnIndex];
@@ -317,6 +334,7 @@ const shiftExternalDependentFormulaReferences = ({ draft, position, editedSheetN
317
334
  columnIndex: position.columnIndex + columnDelta,
318
335
  }, editedSheetName, {
319
336
  exclusionRange: sourceRange,
337
+ deletedRange,
320
338
  rowCount,
321
339
  columnCount,
322
340
  referenceSheetName: editedSheetName,
@@ -0,0 +1,78 @@
1
+ import type { CellData, CellInterface, GridRange, SelectionArea } from "@rowsncolumns/common-types";
2
+ import type { SelectionAttributes, TableView } from "@rowsncolumns/spreadsheet";
3
+ import { type StructuralRefusal } from "../constants";
4
+ import type { SheetData } from "../hooks/use-spreadsheet-state";
5
+ /**
6
+ * Pure predicates behind Excel's structural-edit refusals. The hooks run them BEFORE the interface
7
+ * function touches any state and `showError` the Excel message on refusal, so a refused edit leaves
8
+ * sheetData / merges / tables / selection exactly as they were.
9
+ *
10
+ * A "band" is the rectangle of cells an edit relocates. Shift cells down at `B2:B3` moves
11
+ * `B2:B∞` — an open end is expressed with `Number.POSITIVE_INFINITY`.
12
+ */
13
+ export type StructuralBand = GridRange;
14
+ export type ShiftDirection = "down" | "right" | "up" | "left";
15
+ /** The selection a cell shift operates on — the LAST selection, or the active cell as a 1×1. The
16
+ * hooks' guards and the interface functions must agree on it, so both resolve it here. */
17
+ export declare const resolveShiftSelection: (activeCell: CellInterface, selections: SelectionArea<SelectionAttributes>[]) => SelectionArea<SelectionAttributes>;
18
+ /** The cells a shift relocates: the selection's rows/columns from its leading edge to the sheet edge. */
19
+ export declare const shiftBand: (direction: ShiftDirection, range: GridRange) => StructuralBand;
20
+ export declare const isNonBlankCell: (cell: CellData | null | undefined) => boolean;
21
+ /**
22
+ * INS-06 / INS-09 / SHF-10 — the first non-blank cell that a shift of `count` rows (axis `row`) or
23
+ * columns (axis `column`) would push past `limit` (the last valid row/column index). Only cells
24
+ * inside `band` move. `undefined` when the edit is safe.
25
+ */
26
+ export declare const findOffSheetPush: <T extends CellData>({ rows, axis, count, limit, band, }: {
27
+ rows: SheetData<T>[number] | undefined;
28
+ axis: "row" | "column";
29
+ count: number;
30
+ limit: number | undefined;
31
+ band: StructuralBand;
32
+ }) => CellInterface | undefined;
33
+ /**
34
+ * A range the band reaches but does not contain whole is TORN by the shift. For a delete, a range
35
+ * that touches the deleted block must lie wholly inside it (it is removed with the block) — one
36
+ * straddling the block's edge is torn too.
37
+ */
38
+ export declare const findTornRange: (ranges: readonly GridRange[] | undefined | null, band: StructuralBand, deletedBlock?: GridRange) => GridRange | undefined;
39
+ /** SHF-05 / MRG-07 — a merge the band covers only partially. */
40
+ export declare const findTornMerge: (merges: readonly GridRange[] | undefined | null, band: StructuralBand, deletedBlock?: GridRange) => GridRange | undefined;
41
+ /** TBL-05 — a table the band covers only partially (a table wholly inside the band moves intact). */
42
+ export declare const findTornTable: (tables: readonly TableView[] | undefined | null, sheetId: number, band: StructuralBand, deletedBlock?: GridRange) => TableView | undefined;
43
+ /** ANC-14 — a CSE / dynamic-array range the band covers only partially. */
44
+ export declare const findTornArray: (arrayRanges: readonly GridRange[] | undefined | null, band: StructuralBand, deletedBlock?: GridRange) => GridRange | undefined;
45
+ /** Ranges (merges / tables) that travel with the band: wholly inside it and, for a delete, not
46
+ * inside the deleted block. */
47
+ export declare const isRangeInsideBand: (range: GridRange, band: StructuralBand) => boolean;
48
+ export declare const isRangeInsideBlock: (outer: GridRange, inner: GridRange) => boolean;
49
+ /**
50
+ * The Excel refusal (if any) for an insert/delete-cells shift of `range`. Checks run in Excel's
51
+ * order: array tear, merge tear, table tear, off-sheet push. `undefined` means the edit may proceed.
52
+ */
53
+ export declare const getShiftCellsRefusal: <T extends CellData>({ direction, range, sheetId, rows, rowCount, columnCount, merges, tables, arrayRanges, }: {
54
+ direction: ShiftDirection;
55
+ range: GridRange;
56
+ sheetId: number;
57
+ rows: SheetData<T>[number] | undefined;
58
+ /** Last valid row index for a vertical shift (the grid does not grow on a cell shift). */
59
+ rowCount?: number;
60
+ /** Last valid column index for a horizontal shift. */
61
+ columnCount?: number;
62
+ merges?: readonly GridRange[] | null;
63
+ tables?: readonly TableView[] | null;
64
+ arrayRanges?: readonly GridRange[] | null;
65
+ }) => StructuralRefusal | undefined;
66
+ /**
67
+ * INS-06 / INS-09 — the refusal for a whole-row (`axis: "row"`) or whole-column insert of `count`
68
+ * lines before `referenceIndex`, given the hard grid cap (`maxRowCount` / `maxColumnCount`). Blank
69
+ * trailing lines may fall off the end; a non-blank one refuses the insert.
70
+ */
71
+ export declare const getInsertLinesRefusal: <T extends CellData>({ axis, referenceIndex, count, rows, limit, }: {
72
+ axis: "row" | "column";
73
+ referenceIndex: number;
74
+ count: number;
75
+ rows: SheetData<T>[number] | undefined;
76
+ limit: number | undefined;
77
+ }) => StructuralRefusal | undefined;
78
+ //# sourceMappingURL=structural-guards.d.ts.map
@@ -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EAAE,GAAG,IAAI,CAAC;CAC3C,KAAG,iBAAiB,GAAG,SA8BvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,QAAQ,EAAE,+CAMvD;IACD,IAAI,EAAE,KAAK,GAAG,QAAQ,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACvC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,KAAG,iBAAiB,GAAG,SAkBvB,CAAC"}
@@ -0,0 +1,186 @@
1
+ import { selectionFromActiveCell } from "@rowsncolumns/utils";
2
+ import { structuralRefusal, } from "../constants";
3
+ /** The selection a cell shift operates on — the LAST selection, or the active cell as a 1×1. The
4
+ * hooks' guards and the interface functions must agree on it, so both resolve it here. */
5
+ export const resolveShiftSelection = (activeCell, selections) => {
6
+ const finalSelections = selections.length
7
+ ? selections
8
+ : selectionFromActiveCell(activeCell);
9
+ return finalSelections[finalSelections.length - 1];
10
+ };
11
+ const rangesIntersect = (a, b) => a.startRowIndex <= b.endRowIndex &&
12
+ a.endRowIndex >= b.startRowIndex &&
13
+ a.startColumnIndex <= b.endColumnIndex &&
14
+ a.endColumnIndex >= b.startColumnIndex;
15
+ const rangeContains = (outer, inner) => inner.startRowIndex >= outer.startRowIndex &&
16
+ inner.endRowIndex <= outer.endRowIndex &&
17
+ inner.startColumnIndex >= outer.startColumnIndex &&
18
+ inner.endColumnIndex <= outer.endColumnIndex;
19
+ /** The cells a shift relocates: the selection's rows/columns from its leading edge to the sheet edge. */
20
+ export const shiftBand = (direction, range) => {
21
+ switch (direction) {
22
+ case "down":
23
+ case "up":
24
+ return {
25
+ startRowIndex: range.startRowIndex,
26
+ endRowIndex: Number.POSITIVE_INFINITY,
27
+ startColumnIndex: range.startColumnIndex,
28
+ endColumnIndex: range.endColumnIndex,
29
+ };
30
+ case "right":
31
+ case "left":
32
+ return {
33
+ startRowIndex: range.startRowIndex,
34
+ endRowIndex: range.endRowIndex,
35
+ startColumnIndex: range.startColumnIndex,
36
+ endColumnIndex: Number.POSITIVE_INFINITY,
37
+ };
38
+ }
39
+ };
40
+ /**
41
+ * A cell counts as non-blank when it carries a value, a formula, a format, a note, a link or a
42
+ * citation — Excel's "might appear empty but have blank values, some formatting, or a formula".
43
+ * Derived render results (CF / DV results) don't count.
44
+ */
45
+ const DERIVED_CELL_KEYS = new Set([
46
+ "conditionalFormattingResultById",
47
+ "dataValidationResult",
48
+ ]);
49
+ export const isNonBlankCell = (cell) => {
50
+ if (!cell)
51
+ return false;
52
+ return Object.entries(cell).some(([key, value]) => !DERIVED_CELL_KEYS.has(key) && value !== undefined && value !== null);
53
+ };
54
+ /**
55
+ * INS-06 / INS-09 / SHF-10 — the first non-blank cell that a shift of `count` rows (axis `row`) or
56
+ * columns (axis `column`) would push past `limit` (the last valid row/column index). Only cells
57
+ * inside `band` move. `undefined` when the edit is safe.
58
+ */
59
+ export const findOffSheetPush = ({ rows, axis, count, limit, band, }) => {
60
+ if (!rows || limit === undefined || count <= 0)
61
+ return undefined;
62
+ const firstPushed = limit - count + 1;
63
+ if (axis === "row") {
64
+ const startRow = Math.max(band.startRowIndex, firstPushed, 1);
65
+ for (let rowIndex = startRow; rowIndex < rows.length; rowIndex++) {
66
+ const values = rows[rowIndex]?.values;
67
+ if (!values)
68
+ continue;
69
+ const startCol = Math.max(band.startColumnIndex, 1);
70
+ const endCol = Math.min(band.endColumnIndex, values.length - 1);
71
+ for (let columnIndex = startCol; columnIndex <= endCol; columnIndex++) {
72
+ if (isNonBlankCell(values[columnIndex])) {
73
+ return { rowIndex, columnIndex };
74
+ }
75
+ }
76
+ }
77
+ return undefined;
78
+ }
79
+ const startRow = Math.max(band.startRowIndex, 1);
80
+ const endRow = Math.min(band.endRowIndex, rows.length - 1);
81
+ for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
82
+ const values = rows[rowIndex]?.values;
83
+ if (!values)
84
+ continue;
85
+ const startCol = Math.max(band.startColumnIndex, firstPushed, 1);
86
+ for (let columnIndex = startCol; columnIndex < values.length; columnIndex++) {
87
+ if (isNonBlankCell(values[columnIndex])) {
88
+ return { rowIndex, columnIndex };
89
+ }
90
+ }
91
+ }
92
+ return undefined;
93
+ };
94
+ /**
95
+ * A range the band reaches but does not contain whole is TORN by the shift. For a delete, a range
96
+ * that touches the deleted block must lie wholly inside it (it is removed with the block) — one
97
+ * straddling the block's edge is torn too.
98
+ */
99
+ export const findTornRange = (ranges, band, deletedBlock) => {
100
+ if (!ranges)
101
+ return undefined;
102
+ return ranges.find((range) => {
103
+ if (rangesIntersect(range, band) && !rangeContains(band, range)) {
104
+ return true;
105
+ }
106
+ if (deletedBlock &&
107
+ rangesIntersect(range, deletedBlock) &&
108
+ !rangeContains(deletedBlock, range)) {
109
+ return true;
110
+ }
111
+ return false;
112
+ });
113
+ };
114
+ /** SHF-05 / MRG-07 — a merge the band covers only partially. */
115
+ export const findTornMerge = (merges, band, deletedBlock) => findTornRange(merges, band, deletedBlock);
116
+ /** TBL-05 — a table the band covers only partially (a table wholly inside the band moves intact). */
117
+ export const findTornTable = (tables, sheetId, band, deletedBlock) => {
118
+ if (!tables)
119
+ return undefined;
120
+ return tables.find((table) => table.sheetId === sheetId &&
121
+ !!findTornRange([table.range], band, deletedBlock));
122
+ };
123
+ /** ANC-14 — a CSE / dynamic-array range the band covers only partially. */
124
+ export const findTornArray = (arrayRanges, band, deletedBlock) => findTornRange(arrayRanges, band, deletedBlock);
125
+ /** Ranges (merges / tables) that travel with the band: wholly inside it and, for a delete, not
126
+ * inside the deleted block. */
127
+ export const isRangeInsideBand = (range, band) => rangeContains(band, range);
128
+ export const isRangeInsideBlock = rangeContains;
129
+ /**
130
+ * The Excel refusal (if any) for an insert/delete-cells shift of `range`. Checks run in Excel's
131
+ * order: array tear, merge tear, table tear, off-sheet push. `undefined` means the edit may proceed.
132
+ */
133
+ export const getShiftCellsRefusal = ({ direction, range, sheetId, rows, rowCount, columnCount, merges, tables, arrayRanges, }) => {
134
+ const band = shiftBand(direction, range);
135
+ const isDelete = direction === "up" || direction === "left";
136
+ const deletedBlock = isDelete ? range : undefined;
137
+ if (findTornArray(arrayRanges, band, deletedBlock)) {
138
+ return structuralRefusal("torn-array");
139
+ }
140
+ if (findTornMerge(merges, band, deletedBlock)) {
141
+ return structuralRefusal("torn-merge");
142
+ }
143
+ if (findTornTable(tables, sheetId, band, deletedBlock)) {
144
+ return structuralRefusal("torn-table");
145
+ }
146
+ if (!isDelete) {
147
+ const vertical = direction === "down";
148
+ const count = vertical
149
+ ? range.endRowIndex - range.startRowIndex + 1
150
+ : range.endColumnIndex - range.startColumnIndex + 1;
151
+ const pushed = findOffSheetPush({
152
+ rows,
153
+ axis: vertical ? "row" : "column",
154
+ count,
155
+ limit: vertical ? rowCount : columnCount,
156
+ band,
157
+ });
158
+ if (pushed) {
159
+ return structuralRefusal("off-sheet-push");
160
+ }
161
+ }
162
+ return undefined;
163
+ };
164
+ /**
165
+ * INS-06 / INS-09 — the refusal for a whole-row (`axis: "row"`) or whole-column insert of `count`
166
+ * lines before `referenceIndex`, given the hard grid cap (`maxRowCount` / `maxColumnCount`). Blank
167
+ * trailing lines may fall off the end; a non-blank one refuses the insert.
168
+ */
169
+ export const getInsertLinesRefusal = ({ axis, referenceIndex, count, rows, limit, }) => {
170
+ const band = axis === "row"
171
+ ? {
172
+ startRowIndex: referenceIndex,
173
+ endRowIndex: Number.POSITIVE_INFINITY,
174
+ startColumnIndex: 1,
175
+ endColumnIndex: Number.POSITIVE_INFINITY,
176
+ }
177
+ : {
178
+ startRowIndex: 1,
179
+ endRowIndex: Number.POSITIVE_INFINITY,
180
+ startColumnIndex: referenceIndex,
181
+ endColumnIndex: Number.POSITIVE_INFINITY,
182
+ };
183
+ return findOffSheetPush({ rows, axis, count, limit, band })
184
+ ? structuralRefusal("off-sheet-push")
185
+ : undefined;
186
+ };
@@ -0,0 +1,94 @@
1
+ import type { GridRange } from "@rowsncolumns/common-types";
2
+ import type { CellData, TableView } from "@rowsncolumns/spreadsheet";
3
+ import type { Draft } from "immer";
4
+ import type { useCalculation } from "../hooks/use-calculation";
5
+ import type { CellXfsRegistry } from "../hooks/use-cellxfs-registry";
6
+ import type { SheetData } from "../hooks/use-spreadsheet-state";
7
+ import type { SharedStringRegistry } from "../hooks/use-ss-registry";
8
+ import type { RecalcCellCoordinate } from "../types";
9
+ type StructuralAxis = "row" | "column";
10
+ /**
11
+ * The table parts a row/column delete takes away, computed from the PRE-edit
12
+ * table definitions: tables the delete removes entirely, and — for a column
13
+ * delete — the named columns it drops out of the tables that survive. Excel
14
+ * breaks the structured references into them: `=SUM(Table1[Price])` →
15
+ * `=SUM(#REF!)` once Table1 is gone, `=Table1[@Qty]*2` → `=Table1[@#REF!]*2`
16
+ * once the `Qty` column is deleted, so the cell shows `#REF!` rather than a
17
+ * stale value, `#NAME?` or `#VALUE!`.
18
+ */
19
+ export type RemovedTableParts = {
20
+ tables: string[];
21
+ columns: Array<{
22
+ table: string;
23
+ sheetId: number;
24
+ /** Pre-edit range, to attribute bare `[@Col]` references to this table. */
25
+ range: GridRange;
26
+ columns: string[];
27
+ }>;
28
+ };
29
+ /**
30
+ * Which tables / table columns `deleteRow` (a table goes with its header row)
31
+ * or `deleteColumn` (a table goes when every column is deleted; otherwise the
32
+ * covered columns are spliced out) removes for the band
33
+ * `[minIndex, maxIndex]` on `sheetId`. Mirrors the table updates those
34
+ * interfaces apply to `tables`.
35
+ */
36
+ export declare const collectRemovedTableParts: (tables: TableView[] | undefined, sheetId: number, axis: StructuralAxis, minIndex: number, maxIndex: number) => RemovedTableParts;
37
+ export type BreakStructuredRefsParams<T extends CellData> = {
38
+ draft: Draft<SheetData<T>>;
39
+ /** The edited sheet. */
40
+ sheetId: number;
41
+ axis: StructuralAxis;
42
+ /** Smallest deleted index and the number of deleted rows/columns. */
43
+ referenceIndex: number;
44
+ count: number;
45
+ removed: RemovedTableParts;
46
+ getGraphNodes?: ReturnType<typeof useCalculation>["getGraphNodes"];
47
+ enqueueCalculation?: ReturnType<typeof useCalculation>["enqueueCalculation"];
48
+ enqueueGraphOperation?: ReturnType<typeof useCalculation>["enqueueGraphOperation"];
49
+ recalcCells: Map<string, RecalcCellCoordinate>;
50
+ locale?: string;
51
+ cellXfsRegistry?: CellXfsRegistry;
52
+ sharedStringRegistry?: SharedStringRegistry;
53
+ };
54
+ /**
55
+ * Rewrite, across every sheet, the structured references that point at the
56
+ * table parts a delete removes (see `RemovedTableParts`). Runs BEFORE the
57
+ * splice, so bare `[@Col]` references are attributed to the table by the
58
+ * formula's pre-edit position. Formula cells come from the dependency graph
59
+ * when it is available (cost O(formula cells)); without one the draft is swept.
60
+ */
61
+ export declare const breakStructuredRefsForRemovedTableParts: <T extends CellData>({ draft, sheetId, axis, referenceIndex, count, removed, getGraphNodes, enqueueCalculation, enqueueGraphOperation, recalcCells, locale, cellXfsRegistry, sharedStringRegistry, }: BreakStructuredRefsParams<T>) => void;
62
+ /**
63
+ * Drop the materialised spill cells of every dynamic-array anchor that sits
64
+ * inside the deleted band `[minIndex, maxIndex]` (rows or columns) of
65
+ * `sheetId`. Spilled values live in the sheet data as computed-only cells (no
66
+ * `ue`); once the anchor goes with its row/column they would otherwise slide
67
+ * into place as orphan plain values (Excel: the whole spill disappears).
68
+ * Runs BEFORE the splice. The anchor records its spill as an A1 range in `af`.
69
+ */
70
+ export type SpillRange = {
71
+ startRowIndex: number;
72
+ startColumnIndex: number;
73
+ endRowIndex: number;
74
+ endColumnIndex: number;
75
+ };
76
+ /** The calculator's live spill rectangle for an anchor cell, if it spills. */
77
+ export type GetArrayRange = (position: {
78
+ sheetId: number;
79
+ rowIndex: number;
80
+ columnIndex: number;
81
+ }) => SpillRange | undefined;
82
+ export declare const removeSpillsOfDeletedAnchors: <T extends CellData>({ draft, sheetId, axis, minIndex, maxIndex, getArrayRange, locale, cellXfsRegistry, sharedStringRegistry, }: {
83
+ draft: Draft<SheetData<T>>;
84
+ sheetId: number;
85
+ axis: StructuralAxis;
86
+ minIndex: number;
87
+ maxIndex: number;
88
+ getArrayRange?: GetArrayRange;
89
+ locale?: string;
90
+ cellXfsRegistry?: CellXfsRegistry;
91
+ sharedStringRegistry?: SharedStringRegistry;
92
+ }) => void;
93
+ export {};
94
+ //# sourceMappingURL=structural-table-refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structural-table-refs.d.ts","sourceRoot":"","sources":["../../../api/structural-table-refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAMrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAQrD,KAAK,cAAc,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,2EAA2E;QAC3E,KAAK,EAAE,SAAS,CAAC;QACjB,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC,CAAC;CACJ,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GACnC,Q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