@allyhub/sdk 0.12.0 → 0.14.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 (154) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/node_modules/@allyhub/audio/dist/plan.d.ts +3 -0
  3. package/dist/node_modules/@allyhub/audio/dist/render.js +1 -1
  4. package/dist/node_modules/@allyhub/audio/package.json +1 -1
  5. package/dist/node_modules/@allyhub/chart/dist/chart-file.d.ts +2 -0
  6. package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
  7. package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +3 -2
  8. package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +5 -12
  9. package/dist/node_modules/@allyhub/chart/dist/chart.js +2 -1
  10. package/dist/node_modules/@allyhub/chart/dist/color.d.ts +37 -0
  11. package/dist/node_modules/@allyhub/chart/dist/color.js +2 -0
  12. package/dist/node_modules/@allyhub/chart/dist/index.d.ts +1 -0
  13. package/dist/node_modules/@allyhub/chart/dist/index.js +1 -1
  14. package/dist/node_modules/@allyhub/chart/dist/svg.js +1 -1
  15. package/dist/node_modules/@allyhub/chart/package.json +1 -1
  16. package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
  17. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +130 -0
  18. package/dist/node_modules/@allyhub/formats/dist/data/deck-code.js +1 -1
  19. package/dist/node_modules/@allyhub/formats/dist/data/gen.d.ts +3 -1
  20. package/dist/node_modules/@allyhub/formats/dist/data/gen.js +1 -1
  21. package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +512 -166
  22. package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
  23. package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +2523 -136
  24. package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
  25. package/dist/node_modules/@allyhub/formats/dist/files.d.ts +9 -2
  26. package/dist/node_modules/@allyhub/formats/dist/files.js +1 -1
  27. package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +9 -0
  28. package/dist/node_modules/@allyhub/formats/dist/note-shape.js +1 -1
  29. package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +931 -87
  30. package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
  31. package/dist/node_modules/@allyhub/formats/package.json +1 -1
  32. package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
  33. package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
  34. package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
  35. package/dist/node_modules/@allyhub/measure/package.json +1 -1
  36. package/dist/node_modules/@allyhub/ooxml/dist/color.d.ts +11 -0
  37. package/dist/node_modules/@allyhub/ooxml/dist/color.js +1 -1
  38. package/dist/node_modules/@allyhub/ooxml/dist/ext.d.ts +43 -0
  39. package/dist/node_modules/@allyhub/ooxml/dist/ext.js +1 -1
  40. package/dist/node_modules/@allyhub/ooxml/dist/index.d.ts +2 -1
  41. package/dist/node_modules/@allyhub/ooxml/dist/index.js +1 -1
  42. package/dist/node_modules/@allyhub/ooxml/dist/transform.d.ts +13 -0
  43. package/dist/node_modules/@allyhub/ooxml/dist/transform.js +2 -0
  44. package/dist/node_modules/@allyhub/ooxml/package.json +5 -1
  45. package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +4 -4
  46. package/dist/node_modules/@allyhub/piece/dist/media.d.ts +2 -2
  47. package/dist/node_modules/@allyhub/piece/package.json +1 -1
  48. package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +35 -0
  49. package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
  50. package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +19 -0
  51. package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
  52. package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +35 -20
  53. package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
  54. package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +3 -3
  55. package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +28 -2
  56. package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
  57. package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
  58. package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +73 -10
  59. package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
  60. package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +45 -9
  61. package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
  62. package/dist/node_modules/@allyhub/protocol/package.json +1 -1
  63. package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
  64. package/dist/node_modules/@allyhub/scenery/package.json +1 -1
  65. package/dist/node_modules/@allyhub/sheet/dist/annotations.d.ts +14 -0
  66. package/dist/node_modules/@allyhub/sheet/dist/annotations.js +2 -0
  67. package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
  68. package/dist/node_modules/@allyhub/sheet/dist/api/index.d.ts +1 -1
  69. package/dist/node_modules/@allyhub/sheet/dist/api/index.js +1 -1
  70. package/dist/node_modules/@allyhub/sheet/dist/api/rules.d.ts +24 -0
  71. package/dist/node_modules/@allyhub/sheet/dist/api/rules.js +1 -1
  72. package/dist/node_modules/@allyhub/sheet/dist/api/styles.d.ts +12 -0
  73. package/dist/node_modules/@allyhub/sheet/dist/api/styles.js +1 -1
  74. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +3 -1
  75. package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
  76. package/dist/node_modules/@allyhub/sheet/dist/arrange.d.ts +28 -1
  77. package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
  78. package/dist/node_modules/@allyhub/sheet/dist/data-tools.d.ts +42 -0
  79. package/dist/node_modules/@allyhub/sheet/dist/data-tools.js +2 -0
  80. package/dist/node_modules/@allyhub/sheet/dist/edit.d.ts +43 -2
  81. package/dist/node_modules/@allyhub/sheet/dist/edit.js +1 -1
  82. package/dist/node_modules/@allyhub/sheet/dist/fill.d.ts +10 -0
  83. package/dist/node_modules/@allyhub/sheet/dist/fill.js +1 -1
  84. package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
  85. package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.d.ts +14 -0
  86. package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.js +1 -1
  87. package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
  88. package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +6 -1
  89. package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
  90. package/dist/node_modules/@allyhub/sheet/dist/outline.d.ts +30 -0
  91. package/dist/node_modules/@allyhub/sheet/dist/outline.js +2 -0
  92. package/dist/node_modules/@allyhub/sheet/dist/rich.d.ts +29 -0
  93. package/dist/node_modules/@allyhub/sheet/dist/rich.js +2 -0
  94. package/dist/node_modules/@allyhub/sheet/dist/rules.js +1 -1
  95. package/dist/node_modules/@allyhub/sheet/dist/table-style.d.ts +6 -0
  96. package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
  97. package/dist/node_modules/@allyhub/sheet/dist/table-styles.js +1 -1
  98. package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +5 -1
  99. package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
  100. package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
  101. package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
  102. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +17 -1
  103. package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
  104. package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.d.ts +56 -0
  105. package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.js +2 -0
  106. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.d.ts +6 -0
  107. package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
  108. package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
  109. package/dist/node_modules/@allyhub/sheet/package.json +1 -1
  110. package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +117 -21
  111. package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
  112. package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +181 -30
  113. package/dist/node_modules/@allyhub/slides-core/dist/api.js +3 -3
  114. package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
  115. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.d.ts +28 -2
  116. package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
  117. package/dist/node_modules/@allyhub/slides-core/dist/check.js +1 -1
  118. package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +222 -4
  119. package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
  120. package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +6 -0
  121. package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
  122. package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.d.ts +3 -0
  123. package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.js +2 -0
  124. package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +3 -0
  125. package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
  126. package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
  127. package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +98 -10
  128. package/dist/node_modules/@allyhub/slides-core/dist/numbering.d.ts +6 -0
  129. package/dist/node_modules/@allyhub/slides-core/dist/numbering.js +2 -0
  130. package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +53 -0
  131. package/dist/node_modules/@allyhub/slides-core/dist/office.js +1 -1
  132. package/dist/node_modules/@allyhub/slides-core/dist/patterns.d.ts +8 -0
  133. package/dist/node_modules/@allyhub/slides-core/dist/patterns.js +2 -0
  134. package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +36 -6
  135. package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
  136. package/dist/node_modules/@allyhub/slides-core/dist/script.d.ts +11 -0
  137. package/dist/node_modules/@allyhub/slides-core/dist/script.js +2 -2
  138. package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +1 -1
  139. package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
  140. package/dist/node_modules/@allyhub/slides-core/dist/table-style.d.ts +48 -0
  141. package/dist/node_modules/@allyhub/slides-core/dist/table-style.js +2 -0
  142. package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
  143. package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +1 -1
  144. package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +4 -0
  145. package/dist/node_modules/@allyhub/video-core/package.json +1 -1
  146. package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
  147. package/docs/defaults.md +78 -4
  148. package/docs/image.md +1 -1
  149. package/docs/pictures.md +1 -1
  150. package/docs/project.md +1 -1
  151. package/docs/sheets.md +19 -9
  152. package/docs/slides.md +30 -16
  153. package/docs/speech.md +1 -1
  154. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as S,MAX_ROWS as A,cellName as E,columnIndex as _,columnLetter as O,overlaps as k,rangeName as w,readArea as y,readAreas as v}from"./address.js";import{Draft as g,applyLook as x,blankEdit as M,refused as d,tidied as D,writeOne as B,inputOf as j}from"./edit.js";import{regionAround as R}from"./filter.js";export const BORDER_PRESETS=["bottom","top","left","right","none","all","outside","thickOutside","bottomDouble","thickBottom","topBottom","topThickBottom","topDoubleBottom"];const a=(o,s)=>Object.fromEntries(Object.entries(o).filter(([t])=>t!==s)),p={top:o=>({...o,bottom:o.top}),bottom:o=>({...o,top:o.bottom}),left:o=>({...o,right:o.left}),right:o=>({...o,left:o.right})};function L(o,s,t){const n=e=>({...t,style:e});switch(o){case"bottom":return[{area:p.bottom(s),sides:{bottom:t}}];case"top":return[{area:p.top(s),sides:{top:t}}];case"left":return[{area:p.left(s),sides:{left:t}}];case"right":return[{area:p.right(s),sides:{right:t}}];case"all":return[{area:s,sides:{left:t,right:t,top:t,bottom:t}}];case"outside":case"thickOutside":{const e=o==="outside"?t:n("thick");return[{area:p.top(s),sides:{top:e}},{area:p.bottom(s),sides:{bottom:e}},{area:p.left(s),sides:{left:e}},{area:p.right(s),sides:{right:e}}]}case"bottomDouble":return[{area:p.bottom(s),sides:{bottom:n("double")}}];case"thickBottom":return[{area:p.bottom(s),sides:{bottom:n("thick")}}];case"topBottom":return[{area:p.top(s),sides:{top:t}},{area:p.bottom(s),sides:{bottom:t}}];case"topThickBottom":return[{area:p.top(s),sides:{top:t}},{area:p.bottom(s),sides:{bottom:n("thick")}}];case"topDoubleBottom":return[{area:p.top(s),sides:{top:t}},{area:p.bottom(s),sides:{bottom:n("double")}}];case"none":return[]}}export function drawSides(o,s,t,n){const e=o.spec(s),r=w(t),i=e.format?.find(c=>c.range===r)?.border;x(o,s,t,{border:{...i,...n}})}export function setBorders(o,s,t,n,e={}){const r=o.workbook.sheet(s);if(!r)return d("no-sheet");const i=new g(o);if(n==="none")return x(i,r,t,{border:void 0}),i.finish();const c={style:e.style??"thin",...e.color===void 0?{}:{color:e.color}};for(const f of L(n,t,c))drawSides(i,r,f.area,f.sides);return i.finish()}export function setBorderSides(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");const r=new g(o),i=b=>b??{style:"none"},{top:c,bottom:f,left:u,right:l,horizontal:h,vertical:m}=n;return c!==void 0&&drawSides(r,e,p.top(t),{top:i(c)}),f!==void 0&&drawSides(r,e,p.bottom(t),{bottom:i(f)}),u!==void 0&&drawSides(r,e,p.left(t),{left:i(u)}),l!==void 0&&drawSides(r,e,p.right(t),{right:i(l)}),h!==void 0&&t.bottom>t.top&&drawSides(r,e,{...t,bottom:t.bottom-1},{bottom:i(h)}),m!==void 0&&t.right>t.left&&drawSides(r,e,{...t,right:t.right-1},{right:i(m)}),r.finish()}export function mergeLoses(o,s,t){const n=Math.min(s.right,o.columnsUsed-1),e=Math.min(s.bottom,o.lastRow);for(let r=s.top;r<=e;r++){let i=!0;for(let c=s.left;c<=n;c++)if(o.at(r,c)!==void 0)if(i&&(t==="across"||r===s.top))i=!1;else return!0;if(t!=="across"&&!i&&r>=s.top){for(let c=r+1;c<=e;c++)for(let f=s.left;f<=n;f++)if(o.at(c,f)!==void 0)return!0;return!1}}return!1}export function mergeCells(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");if(e.tables.some(l=>k(l.area,t)))return d("merge-table");const r=new g(o),i=r.spec(e),c=(i.merges??[]).filter(l=>{const h=y(l);return!h||!k(h,t)}),f=n==="across"?Array.from({length:t.bottom-t.top+1},(l,h)=>({...t,top:t.top+h,bottom:t.top+h})):[t],u=[];for(const l of f)l.top===l.bottom&&l.left===l.right||(u.push(w(l)),T(r,o,e,l));return u.length===0?M():(i.merges=[...c,...u],n==="center"&&x(r,e,t,{align:"center"}),r.edit.whole=!0,r.finish())}function T(o,s,t,n){let e="";const r=Math.min(n.right,t.columnsUsed-1),i=Math.min(n.bottom,t.lastRow);for(let c=n.top;c<=i;c++)for(let f=n.left;f<=r;f++)t.at(c,f)!==void 0&&(e===""&&(e=j(s,t,c,f)),(c!==n.top||f!==n.left)&&B(o,s,t,c,f,""));e!==j(s,t,n.top,n.left)&&B(o,s,t,n.top,n.left,e)}export function unmergeCells(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r=e.spec(n),i=(r.merges??[]).filter(c=>{const f=y(c);return!f||!k(f,t)});return i.length===0?delete r.merges:r.merges=i,e.edit.whole=!0,e.finish()}export function setFreeze(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r=e.spec(n);return t&&(t.row>0||t.col>0)?r.freeze=E(t):delete r.freeze,e.edit.whole=!0,e.finish()}export function setHidden(o,s,t,n,e,r){const i=o.workbook.sheet(s);if(!i)return d("no-sheet");const c=new g(o),f=c.spec(i),u=(l,h)=>{const m=a(l[h]??{},"hidden");return r?{...l,[h]:{...m,hidden:!0}}:Object.keys(m).length===0?a(l,h):{...l,[h]:m}};if(t==="columns"){let l={...f.columns};const h=r?Array.from({length:e-n+1},(m,b)=>O(n+b)):Object.keys(l).filter(m=>{const b=_(m);return b!==void 0&&b>=n&&b<=e});for(const m of h)l=u(l,m);f.columns=l}else{let l={...f.rows};const h=r?Array.from({length:e-n+1},(m,b)=>String(n+b+1)):Object.keys(l).filter(m=>{const b=Number(m)-1;return b>=n&&b<=e});for(const m of h)l=u(l,m);f.rows=l}return D(f),c.edit.whole=!0,c.finish()}export function setSheetHidden(o,s,t){const n=o.file.sheets,e=n.filter(u=>u.hidden!==!0),r=n.findIndex(u=>u.name===s),i=n[r];if(!i)return d("no-sheet");if(t&&e.length<=1)return d("last-sheet");const c=a(i,"hidden"),f=t?{...c,hidden:!0}:c;return{...M(),file:{...o.file,sheets:n.map((u,l)=>l===r?f:u)},whole:!0}}export function setTabColor(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r=e.spec(n);return t===void 0?delete r.tab:r.tab=t,e.finish()}export function toggleFilter(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r={row:t.top,col:t.left},i=n.tableAt(r.row,r.col);if(i){const h=e.table(n,i);return h.filter===!1?delete h.filter:h.filter=!1,e.edit.whole=!0,e.finish()}const c=e.spec(n);if(c.filter)return delete c.filter,e.edit.whole=!0,e.finish();const u=t.top===t.bottom&&t.left===t.right?R(n,r):t;if(!u)return d("no-data");const l=n.used;return c.filter={range:w({...u,bottom:Math.min(u.bottom,l?.bottom??u.bottom),right:Math.min(u.right,l?.right??u.right)})},e.edit.whole=!0,e.finish()}export function setFilterColumn(o,s,t,n,e){const r=o.workbook.sheet(s);if(!r)return d("no-sheet");const i=new g(o),{table:c}=t;if(c){const f=i.table(r,c),u=c.columns[n-c.at.col]?.name??"",l=a(f.filter===!1||!f.filter?{}:f.filter.columns,u),h=e?{...l,[u]:e}:l;Object.keys(h).length===0?delete f.filter:f.filter={columns:h}}else{const f=i.spec(r);if(!f.filter)return d("no-sheet");const u=O(n),l=a(f.filter.columns??{},u),h=e?{...l,[u]:e}:l;f.filter={range:f.filter.range,...Object.keys(h).length===0?{}:{columns:h}}}return i.edit.whole=!0,i.finish()}export function clearFilters(o,s){const t=o.workbook.sheet(s);if(!t)return d("no-sheet");const n=new g(o),e=n.spec(t);e.filter&&(e.filter={range:e.filter.range});for(const r of t.tables)r.spec.filter&&delete n.table(t,r).filter;return n.edit.whole=!0,n.finish()}export function addConditional(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r=e.spec(n);return r.conditional=[t,...r.conditional??[]],e.edit.whole=!0,e.finish()}function z(o,s){if(!k(o,s))return[o];const t=[];s.top>o.top&&t.push({...o,bottom:s.top-1}),s.bottom<o.bottom&&t.push({...o,top:s.bottom+1});const n=Math.max(o.top,s.top),e=Math.min(o.bottom,s.bottom);return s.left>o.left&&t.push({...o,top:n,bottom:e,right:s.left-1}),s.right<o.right&&t.push({...o,top:n,bottom:e,left:s.right+1}),t}function C(o,s){const t=v(o);if(!t)return o;const n=t.flatMap(e=>z(e,s));return n.length===0?void 0:n.map(w).join(" ")}export function clearConditional(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r=e.spec(n),i=t?(r.conditional??[]).flatMap(c=>{const f=C(c.range,t);return f===void 0?[]:[{...c,range:f}]}):[];return i.length===0?delete r.conditional:r.conditional=i,e.edit.whole=!0,e.finish()}export function setValidation(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");const r=new g(o),i=r.spec(e),c=(i.validations??[]).flatMap(u=>{const l=C(u.range,t);return l===void 0?[]:[{...u,range:l}]}),f=n?[...c,{...n,range:w(t)}]:c;return f.length===0?delete i.validations:i.validations=f,r.edit.whole=!0,r.finish()}export const WHOLE_SHEET={top:0,left:0,bottom:A-1,right:S-1};export function addChart(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r=e.spec(n);return r.charts=[...r.charts??[],t],e.finish()}export function setChart(o,s,t,n){const e=o.workbook.sheet(s),r=e?.spec.charts?.[t];if(!e||!r)return d("no-sheet");const i=new g(o),c=i.spec(e),f=Object.fromEntries(Object.entries({...r,...n}).filter(([,u])=>u!==void 0));return c.charts=(c.charts??[]).map((u,l)=>l===t?f:u),i.finish()}export function removeChart(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new g(o),r=e.spec(n),i=(r.charts??[]).filter((c,f)=>f!==t);return i.length>0?r.charts=i:delete r.charts,e.finish()}
2
+ import{MAX_COLUMNS as S,MAX_ROWS as _,cellName as y,columnIndex as L,columnLetter as j,overlaps as a,rangeName as w,readArea as O,readAreas as R}from"./address.js";import{Draft as p,applyLook as x,blankEdit as M,refused as d,tidied as E,writeOne as C,inputOf as A}from"./edit.js";import{regionAround as v}from"./filter.js";export const BORDER_PRESETS=["bottom","top","left","right","none","all","outside","thickOutside","bottomDouble","thickBottom","topBottom","topThickBottom","topDoubleBottom"];const k=(o,s)=>Object.fromEntries(Object.entries(o).filter(([t])=>t!==s)),m={top:o=>({...o,bottom:o.top}),bottom:o=>({...o,top:o.bottom}),left:o=>({...o,right:o.left}),right:o=>({...o,left:o.right})};function D(o,s,t){const n=e=>({...t,style:e});switch(o){case"bottom":return[{area:m.bottom(s),sides:{bottom:t}}];case"top":return[{area:m.top(s),sides:{top:t}}];case"left":return[{area:m.left(s),sides:{left:t}}];case"right":return[{area:m.right(s),sides:{right:t}}];case"all":return[{area:s,sides:{left:t,right:t,top:t,bottom:t}}];case"outside":case"thickOutside":{const e=o==="outside"?t:n("thick");return[{area:m.top(s),sides:{top:e}},{area:m.bottom(s),sides:{bottom:e}},{area:m.left(s),sides:{left:e}},{area:m.right(s),sides:{right:e}}]}case"bottomDouble":return[{area:m.bottom(s),sides:{bottom:n("double")}}];case"thickBottom":return[{area:m.bottom(s),sides:{bottom:n("thick")}}];case"topBottom":return[{area:m.top(s),sides:{top:t}},{area:m.bottom(s),sides:{bottom:t}}];case"topThickBottom":return[{area:m.top(s),sides:{top:t}},{area:m.bottom(s),sides:{bottom:n("thick")}}];case"topDoubleBottom":return[{area:m.top(s),sides:{top:t}},{area:m.bottom(s),sides:{bottom:n("double")}}];case"none":return[]}}export function drawSides(o,s,t,n){const e=o.spec(s),r=w(t),i=e.format?.find(c=>c.range===r)?.border;x(o,s,t,{border:{...i,...n}})}export function setBorders(o,s,t,n,e={}){const r=o.workbook.sheet(s);if(!r)return d("no-sheet");const i=new p(o);if(n==="none")return x(i,r,t,{border:void 0}),i.finish();const c={style:e.style??"thin",...e.color===void 0?{}:{color:e.color}};for(const f of D(n,t,c))drawSides(i,r,f.area,f.sides);return i.finish()}export function setBorderSides(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");const r=new p(o),i=b=>b??{style:"none"},{top:c,bottom:f,left:u,right:l,horizontal:h,vertical:g}=n;return c!==void 0&&drawSides(r,e,m.top(t),{top:i(c)}),f!==void 0&&drawSides(r,e,m.bottom(t),{bottom:i(f)}),u!==void 0&&drawSides(r,e,m.left(t),{left:i(u)}),l!==void 0&&drawSides(r,e,m.right(t),{right:i(l)}),h!==void 0&&t.bottom>t.top&&drawSides(r,e,{...t,bottom:t.bottom-1},{bottom:i(h)}),g!==void 0&&t.right>t.left&&drawSides(r,e,{...t,right:t.right-1},{right:i(g)}),r.finish()}export function mergeLoses(o,s,t){const n=Math.min(s.right,o.columnsUsed-1),e=Math.min(s.bottom,o.lastRow);for(let r=s.top;r<=e;r++){let i=!0;for(let c=s.left;c<=n;c++)if(o.at(r,c)!==void 0)if(i&&(t==="across"||r===s.top))i=!1;else return!0;if(t!=="across"&&!i&&r>=s.top){for(let c=r+1;c<=e;c++)for(let f=s.left;f<=n;f++)if(o.at(c,f)!==void 0)return!0;return!1}}return!1}export function mergeCells(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");if(e.tables.some(l=>a(l.area,t)))return d("merge-table");const r=new p(o),i=r.spec(e),c=(i.merges??[]).filter(l=>{const h=O(l);return!h||!a(h,t)}),f=n==="across"?Array.from({length:t.bottom-t.top+1},(l,h)=>({...t,top:t.top+h,bottom:t.top+h})):[t],u=[];for(const l of f)l.top===l.bottom&&l.left===l.right||(u.push(w(l)),N(r,o,e,l));return u.length===0?M():(i.merges=[...c,...u],n==="center"&&x(r,e,t,{align:"center"}),r.edit.whole=!0,r.finish())}function N(o,s,t,n){let e="";const r=Math.min(n.right,t.columnsUsed-1),i=Math.min(n.bottom,t.lastRow);for(let c=n.top;c<=i;c++)for(let f=n.left;f<=r;f++)t.at(c,f)!==void 0&&(e===""&&(e=A(s,t,c,f)),(c!==n.top||f!==n.left)&&C(o,s,t,c,f,""));e!==A(s,t,n.top,n.left)&&C(o,s,t,n.top,n.left,e)}export function unmergeCells(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n),i=(r.merges??[]).filter(c=>{const f=O(c);return!f||!a(f,t)});return i.length===0?delete r.merges:r.merges=i,e.edit.whole=!0,e.finish()}export function setFreeze(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n);return t&&(t.row>0||t.col>0)?r.freeze=y(t):delete r.freeze,e.edit.whole=!0,e.finish()}export function setHidden(o,s,t,n,e,r){const i=o.workbook.sheet(s);if(!i)return d("no-sheet");const c=new p(o),f=c.spec(i),u=(l,h)=>{const g=k(l[h]??{},"hidden");return r?{...l,[h]:{...g,hidden:!0}}:Object.keys(g).length===0?k(l,h):{...l,[h]:g}};if(t==="columns"){let l={...f.columns};const h=r?Array.from({length:e-n+1},(g,b)=>j(n+b)):Object.keys(l).filter(g=>{const b=L(g);return b!==void 0&&b>=n&&b<=e});for(const g of h)l=u(l,g);f.columns=l}else{let l={...f.rows};const h=r?Array.from({length:e-n+1},(g,b)=>String(n+b+1)):Object.keys(l).filter(g=>{const b=Number(g)-1;return b>=n&&b<=e});for(const g of h)l=u(l,g);f.rows=l}return E(f),c.edit.whole=!0,c.finish()}export function setSheetHidden(o,s,t){const n=o.file.sheets,e=n.filter(u=>u.hidden!==!0),r=n.findIndex(u=>u.name===s),i=n[r];if(!i)return d("no-sheet");if(t&&e.length<=1)return d("last-sheet");const c=k(i,"hidden"),f=t?{...c,hidden:!0}:c;return{...M(),file:{...o.file,sheets:n.map((u,l)=>l===r?f:u)},whole:!0}}export function setTabColor(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n);return t===void 0?delete r.tab:r.tab=t,e.finish()}export function setGridlines(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n);return t?delete r.gridlines:r.gridlines=!1,e.finish()}export function toggleFilter(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r={row:t.top,col:t.left},i=n.tableAt(r.row,r.col);if(i){const h=e.table(n,i);return h.filter===!1?delete h.filter:h.filter=!1,e.edit.whole=!0,e.finish()}const c=e.spec(n);if(c.filter)return delete c.filter,e.edit.whole=!0,e.finish();const u=t.top===t.bottom&&t.left===t.right?v(n,r):t;if(!u)return d("no-data");const l=n.used;return c.filter={range:w({...u,bottom:Math.min(u.bottom,l?.bottom??u.bottom),right:Math.min(u.right,l?.right??u.right)})},e.edit.whole=!0,e.finish()}export function setFilterColumn(o,s,t,n,e){const r=o.workbook.sheet(s);if(!r)return d("no-sheet");const i=new p(o),{table:c}=t;if(c){const f=i.table(r,c),u=c.columns[n-c.at.col]?.name??"",l=k(f.filter===!1||!f.filter?{}:f.filter.columns,u),h=e?{...l,[u]:e}:l;Object.keys(h).length===0?delete f.filter:f.filter={columns:h}}else{const f=i.spec(r);if(!f.filter)return d("no-sheet");const u=j(n),l=k(f.filter.columns??{},u),h=e?{...l,[u]:e}:l;f.filter={range:f.filter.range,...Object.keys(h).length===0?{}:{columns:h}}}return i.edit.whole=!0,i.finish()}export function clearFilters(o,s){const t=o.workbook.sheet(s);if(!t)return d("no-sheet");const n=new p(o),e=n.spec(t);e.filter&&(e.filter={range:e.filter.range});for(const r of t.tables)r.spec.filter&&delete n.table(t,r).filter;return n.edit.whole=!0,n.finish()}export function addConditional(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n);return r.conditional=[t,...r.conditional??[]],e.edit.whole=!0,e.finish()}function H(o,s){if(!a(o,s))return[o];const t=[];s.top>o.top&&t.push({...o,bottom:s.top-1}),s.bottom<o.bottom&&t.push({...o,top:s.bottom+1});const n=Math.max(o.top,s.top),e=Math.min(o.bottom,s.bottom);return s.left>o.left&&t.push({...o,top:n,bottom:e,right:s.left-1}),s.right<o.right&&t.push({...o,top:n,bottom:e,left:s.right+1}),t}function B(o,s){const t=R(o);if(!t)return o;const n=t.flatMap(e=>H(e,s));return n.length===0?void 0:n.map(w).join(" ")}export function clearConditional(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n),i=t?(r.conditional??[]).flatMap(c=>{const f=B(c.range,t);return f===void 0?[]:[{...c,range:f}]}):[];return i.length===0?delete r.conditional:r.conditional=i,e.edit.whole=!0,e.finish()}export function setValidation(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");const r=new p(o),i=r.spec(e),c=(i.validations??[]).flatMap(u=>{const l=B(u.range,t);return l===void 0?[]:[{...u,range:l}]}),f=n?[...c,{...n,range:w(t)}]:c;return f.length===0?delete i.validations:i.validations=f,r.edit.whole=!0,r.finish()}export const WHOLE_SHEET={top:0,left:0,bottom:_-1,right:S-1};export function addChart(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n);return r.charts=[...r.charts??[],t],e.finish()}export function setChart(o,s,t,n){const e=o.workbook.sheet(s),r=e?.spec.charts?.[t];if(!e||!r)return d("no-sheet");const i=new p(o),c=i.spec(e),f=Object.fromEntries(Object.entries({...r,...n}).filter(([,u])=>u!==void 0));return c.charts=(c.charts??[]).map((u,l)=>l===t?f:u),i.finish()}export function removeChart(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n),i=(r.charts??[]).filter((c,f)=>f!==t);return i.length>0?r.charts=i:delete r.charts,e.finish()}export function setNote(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");const r=new p(o),i=r.spec(e),c=y(t),f=Object.fromEntries(Object.entries(i.notes??{}).filter(([u])=>u!==c));return n!==void 0&&n.text.trim()!==""&&(f[c]=n.author===void 0||n.author===""?n.text:{text:n.text,author:n.author}),Object.keys(f).length===0?delete i.notes:i.notes=f,r.finish()}export function setLink(o,s,t,n){const e=o.workbook.sheet(s);if(!e)return d("no-sheet");const r=new p(o),i=r.spec(e),c=Object.fromEntries(Object.entries(i.links??{}).filter(([f])=>{const u=O(f);return u===void 0||!a(u,t)}));if(n!==void 0&&n.trim()!==""){c[w(t)]=n.trim();const f=e.lookAt(t.top,t.left);f.color===void 0&&f.underline===void 0&&x(r,e,t,HYPERLINK_LOOK)}return Object.keys(c).length===0?delete i.links:i.links=c,E(i),r.finish()}export const HYPERLINK_LOOK={color:"#0563C1",underline:!0};export function setProtect(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n);return t?r.protect=!0:delete r.protect,e.finish()}export function protectedIn(o,s){if(o.spec.protect!==!0)return!1;const t=Math.min(s.bottom,Math.max(s.top,o.lastRow+1)),n=Math.min(s.right,Math.max(s.left,o.columnsUsed+1));for(let e=s.top;e<=t;e++)for(let r=s.left;r<=n;r++)if(o.lookAt(e,r).locked!==!1)return!0;return!1}export function setConditionals(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n);return t.length===0?delete r.conditional:r.conditional=[...t],e.edit.whole=!0,e.finish()}export function setPrint(o,s,t){const n=o.workbook.sheet(s);if(!n)return d("no-sheet");const e=new p(o),r=e.spec(n),i=Object.fromEntries(Object.entries({...r.print,...t}).filter(([,c])=>c!==void 0));return Object.keys(i).length===0?delete r.print:r.print=i,e.finish()}
@@ -0,0 +1,42 @@
1
+ import type { Area } from "./address.js";
2
+ import { type BookEdit, type EditBook } from "./edit.js";
3
+ import type { Calc } from "./calc/engine.js";
4
+ import { type Scalar } from "./values.js";
5
+ /** Which rows of values to keep: the first of each, by the columns given (all when none). */
6
+ export declare function uniqueRows(rows: readonly (readonly Scalar[])[], columns: readonly number[]): boolean[];
7
+ /**
8
+ * Remove Duplicates over an area: its header row left out when it has one,
9
+ * the rows kept closing up from the top, what is left at the foot cleared.
10
+ * Says how many rows went (`duplicates`) and stayed (`unique`).
11
+ */
12
+ export declare function removeDuplicates(book: EditBook, calc: Calc, sheetName: string, area: Area, o: {
13
+ header: boolean;
14
+ columns: readonly number[];
15
+ }): BookEdit & {
16
+ duplicates: number;
17
+ unique: number;
18
+ };
19
+ export interface SplitOptions {
20
+ /** Delimited: what splits, Excel's Tab, Semicolon, Comma, Space and Other. */
21
+ delimiters?: readonly string[];
22
+ /** Treat consecutive delimiters as one. */
23
+ consecutive?: boolean;
24
+ /** Text Qualifier: a delimiter inside it does not split. */
25
+ qualifier?: string;
26
+ /** Fixed width: where each break is, in characters from the start. */
27
+ widths?: readonly number[];
28
+ }
29
+ /** A text split as Text to Columns splits it. */
30
+ export declare function splitText(text: string, o: SplitOptions): string[];
31
+ /**
32
+ * Text to Columns over a column's cells: each one's text split into the
33
+ * columns from the destination on (the column itself unless it says),
34
+ * each part read as typed.
35
+ */
36
+ export declare function textToColumns(book: EditBook, calc: Calc, sheetName: string, area: Area, o: SplitOptions & {
37
+ destination?: {
38
+ row: number;
39
+ col: number;
40
+ };
41
+ }): BookEdit;
42
+ //# sourceMappingURL=data-tools.d.ts.map
@@ -0,0 +1,2 @@
1
+ /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
+ import{inputOf as y,refused as g,writeCells as q}from"./edit.js";import{moveFormula as x}from"./formula/move.js";import{parseFormula as A}from"./formula/parse.js";import{printFormula as C}from"./formula/print.js";import{CellError as E}from"./values.js";const $=t=>t===null?"":typeof t=="string"?`s${t.toLowerCase()}`:t instanceof E?`e${t.code}`:`${typeof t}${String(t)}`;export function uniqueRows(t,o){const i=new Set;return t.map(e=>{const s=(o.length===0?e.map((l,n)=>n):o).map(l=>$(e[l]??null)).join("\0");return i.has(s)?!1:(i.add(s),!0)})}function F(t,o){if(o===0||!t.startsWith("="))return t;const i=A(t);return i.ok?C(x(i.node,o,0)):t}export function removeDuplicates(t,o,i,e,u){const s=t.workbook.sheet(i);if(!s)return{...g("no-sheet"),duplicates:0,unique:0};const l=u.header?e.top+1:e.top,n=e.right-e.left+1,r=[],p=[];for(let f=l;f<=e.bottom;f++)r.push(Array.from({length:n},(m,w)=>o.value(s,f,e.left+w))),p.push(Array.from({length:n},(m,w)=>y(t,s,f,e.left+w)));const c=uniqueRows(r,u.columns.map(f=>f-e.left)),d=[];let h=l;c.forEach((f,m)=>{const w=l+m;f&&(w!==h&&p[m]?.forEach((k,b)=>{d.push({row:h,col:e.left+b,text:F(k,h-w)})}),h+=1)});for(let f=h;f<=e.bottom;f++)for(let m=0;m<n;m++)d.push({row:f,col:e.left+m,text:""});const a=h-l;return{...q(t,i,d),duplicates:c.length-a,unique:a}}export function splitText(t,o){if(o.widths&&o.widths.length>0){const n=[...new Set(o.widths)].filter(c=>c>0).sort((c,d)=>c-d),r=[];let p=0;for(const c of n)r.push(t.slice(p,c).trim()),p=c;return r.push(t.slice(p).trim()),r}const i=o.delimiters??[];if(i.length===0)return[t];const e=[];let u="",s=!1,l=!1;for(let n=0;n<t.length;n++){const r=t.charAt(n);if(o.qualifier&&r===o.qualifier){s&&t.charAt(n+1)===o.qualifier?(u+=r,n+=1):s=!s,l=!1;continue}if(!s&&i.includes(r)){o.consecutive===!0&&l||e.push(u),u="",l=!0;continue}u+=r,l=!1}return e.push(u),e}export function textToColumns(t,o,i,e,u){const s=t.workbook.sheet(i);if(!s)return g("no-sheet");const l=u.destination??{row:e.top,col:e.left},n=[];for(let r=e.top;r<=e.bottom;r++){const p=o.value(s,r,e.left);if(p===null)continue;const c=typeof p=="string"?p:y(t,s,r,e.left);splitText(c,u).forEach((d,h)=>{n.push({row:l.row+r-e.top,col:l.col+h,text:d})})}return n.length===0?g("no-data"):q(t,i,n)}
@@ -1,4 +1,4 @@
1
- import type { SheetFile, SheetTable, SheetWorksheet } from "@allyhub/formats";
1
+ import type { SheetFile, SheetRun, SheetTable, SheetWorksheet } from "@allyhub/formats";
2
2
  import { type Area } from "./address.js";
3
3
  import { restructure, type RefusedEdit } from "./structure.js";
4
4
  import { type CellLook, type CsvRows, type SharedFormula, type Table, type Workbook, type Worksheet } from "./workbook.js";
@@ -48,7 +48,7 @@ export interface BookEdit {
48
48
  /** CSV files no sheet names any more. */
49
49
  removed?: string[];
50
50
  }
51
- export type EditRefused = RefusedEdit | "column-name" | "sheet-name" | "sheet-taken" | "name-invalid" | "merge-table" | "no-data" | "table-move";
51
+ export type EditRefused = RefusedEdit | "column-name" | "sheet-name" | "sheet-taken" | "name-invalid" | "merge-table" | "no-data" | "table-move" | "table-shift" | "merge-shift" | "table-overlap" | "table-room" | "rich-loose";
52
52
  /** The most typed cells written as keys of `cells`: more go in a CSV file of their own, as a script's do. */
53
53
  export declare const BLOCK_CELLS = 100;
54
54
  export declare const blankEdit: () => BookEdit;
@@ -82,6 +82,12 @@ export declare class Draft {
82
82
  }
83
83
  export declare const movedTo: (text: string, rows: number, columns: number) => string;
84
84
  export declare function writeOne(d: Draft, book: EditBook, sheet: Worksheet, row: number, col: number, text: string): BookEdit | undefined;
85
+ /**
86
+ * A cell's text as rich text: its runs, alike ones joined. Runs that say
87
+ * nothing of their font are its plain text, written as typed; a table's or
88
+ * a block's cells are CSV's plain text and hold none.
89
+ */
90
+ export declare function setRuns(book: EditBook, sheetName: string, row: number, col: number, runs: readonly SheetRun[]): BookEdit;
85
91
  /** One cell written as typed, or several: `text` is what a person types there. */
86
92
  export interface CellWrite {
87
93
  row: number;
@@ -151,4 +157,39 @@ export declare function exceptionsOf(table: Table): {
151
157
  column: string;
152
158
  text: string;
153
159
  }[];
160
+ /**
161
+ * Insert's Table and Home's Format as Table over cells: Excel's Create
162
+ * Table. The area's top row is its header (with no header, Excel's
163
+ * Column1, Column2), what the cells hold, as typed, goes to a CSV file of
164
+ * its own, and their looks stay where they are. Refused over a table.
165
+ */
166
+ export declare function makeTable(book: EditBook, sheetName: string, area: Area, o: {
167
+ header: boolean;
168
+ style?: string | undefined;
169
+ }): BookEdit;
170
+ /** Format as Table over a table: its style; TableStyleMedium2 is a new table's, `none` none. */
171
+ export declare function setTableStyle(book: EditBook, sheetName: string, tableName: string, style: string): BookEdit;
172
+ /** Table Design's Table Style Options: each said only where it is not a new table's. */
173
+ export declare function setTableOptions(book: EditBook, sheetName: string, tableName: string, options: {
174
+ banded_rows?: boolean;
175
+ banded_columns?: boolean;
176
+ first_column?: boolean;
177
+ last_column?: boolean;
178
+ }): BookEdit;
179
+ /**
180
+ * Name Manager's New and Edit: a name, what it refers to as typed (a
181
+ * formula after =, or a value) and its scope, the workbook or a sheet. A
182
+ * name renamed is renamed in every formula that read it, as Excel does.
183
+ */
184
+ export declare function setName(book: EditBook, o: {
185
+ name: string;
186
+ value: string;
187
+ scope?: string | undefined;
188
+ was?: {
189
+ name: string;
190
+ scope?: string | undefined;
191
+ } | undefined;
192
+ }): BookEdit;
193
+ /** Name Manager's Delete: a formula that read it then reads #NAME?, as Excel's does. */
194
+ export declare function deleteName(book: EditBook, name: string, scope?: string): BookEdit;
154
195
  //# sourceMappingURL=edit.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as K,MAX_ROWS as R,cellName as N,columnLetter as C,contains as q,overlaps as O,rangeName as M,readAddress as X,readArea as j}from"./address.js";import{moveFormula as z}from"./formula/move.js";import{parseFormula as D}from"./formula/parse.js";import{printFormula as G}from"./formula/print.js";import{freeColumn as B,duplicated as H,restructure as F,uniqueColumn as I,withColumnsUpTo as A}from"./structure.js";import{readTyped as T}from"./values.js";import{FormulaCell as P,placeKey as V,validName as J}from"./workbook.js";export const BLOCK_CELLS=100;const _=(n,o)=>n.top<=o.top&&n.left<=o.left&&n.bottom>=o.bottom&&n.right>=o.right,S=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o)),Q=n=>S(n,"formula"),b=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o));export const blankEdit=()=>({rows:new Map,cells:[],whole:!1}),refused=n=>({...blankEdit(),refused:n});const v=n=>T(n).formula!==void 0;function Y(n){const o=T(n);return o.formula!==void 0?n:o.value===null?null:o.format!==void 0?n:typeof o.value=="number"||typeof o.value=="boolean"?o.value:n}const Z=n=>n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).filter(([o])=>o!=="value"&&o!=="formula")):{};export class Draft{book;specs=new Map;file;fileChanged=!1;grown=new Map;added=new Map;edit=blankEdit();constructor(o){this.book=o,this.file=o.file}spec(o){let e=this.specs.get(o.index);if(!e){const t=this.file.sheets.findIndex(s=>s.name===o.name);e={...this.file.sheets[t]??{name:o.name}},this.specs.set(o.index,e),this.fileChanged||(this.file={...this.file,sheets:[...this.file.sheets]},this.fileChanged=!0),this.file.sheets[t]=e}return e}table(o,e){const t=this.spec(o),s=[...t.tables??[]],r=s.findIndex(l=>l.name===e.name),i={...s[r]??e.spec};return s[r]=i,t.tables=s,i}rows(o){const e=this.edit.rows.get(o);if(e)return e;const t=[...this.book.rows.get(o)??[]];return this.edit.rows.set(o,t),t}setField(o,e,t,s){const r=this.rows(o),i=[...r[e]??[]];for(;i.length<=t;)i.push("");return i[t]=s,r[e]=i,i}rowsOf(o){return this.grown.get(o)??o.rows}grow(o,e,t){this.grown.set(o,this.rowsOf(o)+1);const s=this.added.get(o)??new Map;s.set(e,t),this.added.set(o,s)}addedAt(o,e,t){for(const[s,r]of this.added){const i=r.get(e);if(i!==void 0&&s.sheet===o&&t>=s.at.col&&t<s.at.col+s.columns.length)return{table:s,record:i}}}finish(){return this.fileChanged&&(this.edit.file=this.file),this.edit}}function ee(n,o,e,t){return o.tables.find(s=>{const r=s.at.row+n.rowsOf(s)+1;if(e!==r)return!1;const i=s.at.col+s.columns.length-1;if(t<s.at.col||t>i)return!1;for(let l=s.at.col;l<=i;l++)if(o.at(e,l)!==void 0)return!1;return!0})}function te(n,o,e){return n.tables.find(t=>{const{top:s,bottom:r,right:i}=t.area;if(e!==i+1||o<s||o>r)return!1;for(let l=s;l<=r;l++)if(n.at(l,e)!==void 0)return!1;return!0})}export const movedTo=(n,o,e)=>{const t=D(n);return t.ok?G(z(t.node,o,e)):n};function E(n,o,e,t,s,r){const i=e.at.row+1,l=n.table(o,e),f=movedTo(r,i-s,0);if(l.columns={...l.columns,[t.name]:{...l.columns?.[t.name],formula:f}},t.csv!==void 0){const c=e.places[s-i];c!==void 0&&n.setField(e.file,c,t.csv,"")}n.edit.whole=!0}function ne(n,o,e,t){const{csv:s}=e;if(s===void 0)return!1;const r=n.rows(o.file);return o.places.some((i,l)=>l!==t&&(r[i]?.[s]??"")!=="")}function oe(n,o,e,t,s){const r=s.trim();if(r==="")return refused("column-name");if(r===t.name)return n.finish();const i=e.columns.filter(c=>c!==t).map(c=>c.name),l=I(i,r),f=F(o,{op:"rename-column",table:e.name,from:t.name,to:l});return{...blankEdit(),file:f.file,rows:new Map(f.rows),whole:!0}}function se(n,o,e,t,s,r){const i=e.columns[s-e.at.col];if(!i)return;const l=t-e.at.row-1;if(v(r)){if(i.formula){E(n,o,e,i,t,r);return}if(!ne(n,e,i,l)){E(n,o,e,i,t,r);return}n.edit.offer={sheet:o.name,row:t,col:s,text:r}}const c=e.places[l];if(c===void 0)return;let d=i.csv;if(d===void 0){if(r==="")return;const w=e.columns.map(p=>p.name);n.edit.rows.set(e.file,A(n.rows(e.file),w,i.index)),n.edit.whole=!0,d=i.index}const a=n.setField(e.file,c,d,r);n.edit.cells.push({sheet:o,row:t,col:s,...r===""&&i.formula?{column:i.formula}:{input:r},record:{table:e,index:l,fields:a}})}function re(n,o,e,t,s){const r=n.rows(o.file),i=Math.max(r[0]?.length??1,1),l=new Array(i).fill(""),f=o.columns[t-o.at.col];f?.csv!==void 0&&(l[f.csv]=s),r.push(l),n.grow(o,e,r.length-1),n.edit.whole=!0}function ie(n,o,e,t,s){const r=n.table(o,e),i=e.columns.map(w=>w.name),l=t===e.at.row,f=l?I(i,s.trim()===""?B(i):s.trim()):B(i);if(n.edit.whole=!0,!l&&v(s)){r.columns={...r.columns,[f]:{formula:movedTo(s,e.at.row+1-t,0)}};return}const c=i.length,d=A(n.rows(e.file),i,c-1),a=d[0];if(a&&a.push(f),d.forEach((w,p)=>{p>0&&w.length>0&&w.push("")}),!l){const w=e.places[t-e.at.row-1],p=w===void 0?void 0:d[w];p&&(p[c]=s)}n.edit.rows.set(e.file,d)}function le(n,o,e,t,s,r,i){n.setField(e,s-t.top,r-t.left,i),n.edit.cells.push({sheet:o,row:s,col:r,input:i})}function fe(n,o,e){return Object.keys(n.spec.cells??{}).some(t=>{if(!t.includes(":"))return!1;const s=j(t);return s!==void 0&&q(s,o,e)})}function ce(n,o,e,t,s){const r=n.spec(o),i=N({row:e,col:t});let l={...r.cells};const f=l[i],c=f===void 0?{}:Z(f),d=Y(s),a=Object.keys(c).length===0;let w;if(d===null){const p=fe(o,e,t);w=!a||p,a&&!p?l=b(l,i):l[i]=a?null:c}else w=!0,l[i]=a?d:{...c,...v(s)?{formula:s}:{value:d}};r.cells=l,Object.keys(l).length===0&&delete r.cells,n.edit.cells.push({sheet:o,row:e,col:t,input:s,key:w?i:null})}export function writeOne(n,o,e,t,s,r){const i=n.addedAt(e,t,s);if(i){const{csv:c}=i.table.columns[s-i.table.at.col]??{};c!==void 0&&n.setField(i.table.file,i.record,c,r);return}const l=e.tableAt(t,s);if(l){const c=l.columns[s-l.at.col];if(t===l.at.row)return c?oe(n,o,l,c,r):void 0;se(n,e,l,t,s,r);return}if(r!==""){const c=ee(n,e,t,s);if(c){re(n,c,t,s,r);return}const d=te(e,t,s);if(d){ie(n,e,d,t,r);return}}const f=e.blockAt(t,s);f?le(n,e,f.file,f.area,t,s,r):ce(n,e,t,s,r)}export function writeCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const{row:r,col:i,text:l}of[...e].sort((f,c)=>f.row-c.row||f.col-c.col)){const f=writeOne(s,n,t,r,i,l);if(f)return f}return s.finish()}export function overwriteColumn(n,o,e,t,s){const r=n.workbook.sheet(o),i=r?.tableAt(e,t);if(!r||!i)return refused("no-sheet");const l=i.columns[t-i.at.col];if(!l)return refused("no-sheet");const f=new Draft(n);E(f,r,i,l,e,s);const{csv:c}=l;if(c!==void 0)for(const d of i.places)f.setField(i.file,d,c,"");return f.finish()}function*ue(n,o){const e=Math.min(o.right,n.columnsUsed-1);for(let t=o.left;t<=e;t++){const[s,r]=n.span(t,o.top,o.bottom);for(let i=s;i<=r;i++)n.at(i,t)!==void 0&&(yield[i,t])}}export function clearCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const r of t.tables){const{top:i,bottom:l}=r.data;if(!(l<i||e.top>i||e.bottom<l))for(const f of r.columns){const c=r.at.col+f.index;if(c<e.left||c>e.right||!f.formula)continue;const d=s.table(t,r),a=r.columns.map(L=>L.name);f.csv===void 0&&s.edit.rows.set(r.file,A(s.rows(r.file),a,f.index));const w=Q(d.columns?.[f.name]??{}),p=b(d.columns??{},f.name);d.columns=Object.keys(w).length>0?{...p,[f.name]:w}:p,Object.keys(d.columns).length===0&&delete d.columns,s.edit.whole=!0}}for(const[r,i]of ue(t,e)){if(t.tableAt(r,i)?.at.row===r)continue;const l=writeOne(s,n,t,r,i,"");if(l)return l}return s.finish()}export function dropKeys(n,o){n.cells&&(n.cells=Object.fromEntries(Object.entries(n.cells).filter(([e])=>{const t=j(e);return!t||!_(o,t)})))}export function fillCells(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");if(!r.tables.some(f=>O(f.area,t))&&!r.blocks.some(f=>O(f.area,t))&&v(s)){const f=new Draft(n),c=f.spec(r);dropKeys(c,t);const d=movedTo(s,t.top-e.row,t.left-e.col),a=M(t);return c.cells={...c.cells,[a]:d},f.edit.whole=!0,f.finish()}const l=[];for(let f=t.top;f<=t.bottom;f++)for(let c=t.left;c<=t.right;c++)f===e.row&&c===e.col||l.push({row:f,col:c,text:v(s)?movedTo(s,f-e.row,c-e.col):s});return writeCells(n,o,l)}export function writeBlockOf(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");const i=new Draft(n),l=i.spec(r);return l.blocks=[...l.blocks??[],{at:N(e),rows:s}],i.edit.rows.set(s,t),i.edit.whole=!0,i.finish()}const $=(n,o)=>Object.keys(o).some(e=>e in n),x=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>!(e in o)));function de(n){if(n===null||typeof n!="object")return n;const o=Object.keys(n);return o.length===1&&o[0]==="value"?n.value??null:o.length===1&&o[0]==="formula"?n.formula??null:n}const me={bold:!1,italic:!1,underline:!1,strike:!1,wrap:!1,align:"general",format:"General",color:"#000000",fill:"#FFFFFF",font:"Calibri",size:11,border:{left:{style:"none"},right:{style:"none"},top:{style:"none"},bottom:{style:"none"}}};function ae(n,o,e,t){for(const[s,r]of Object.entries(n.columns??{})){const i=X(`${s}1`)?.col;if(i!==void 0&&i>=e.left&&i<=e.right&&t in r)return!0}for(const[s,r]of Object.entries(n.rows??{})){const i=Number(s)-1;if(i>=e.top&&i<=e.bottom&&t in r)return!0}return o.tables.some(s=>O(s.area,e)&&s.columns.some(r=>r.spec!==void 0&&t in r.spec&&s.at.col+r.index>=e.left&&s.at.col+r.index<=e.right))}export function setLook(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n);return applyLook(r,s,e,t),r.finish()}export function applyLook(n,o,e,t){const s=n.spec(o);he(n,o,s,e,t),tidied(s)}function he(n,o,e,t,s){if(e.cells){const u={...e.cells},m=[];for(const[g,h]of Object.entries(u)){if(h===null||typeof h!="object"||!$(h,s))continue;const y=j(g);!y||!O(y,t)||(g.includes(":")&&!_(t,y)&&m.push({range:g,...Object.fromEntries(Object.entries(h).filter(([W])=>W in s))}),u[g]=de(x(h,s)))}e.cells=u,m.length>0&&(e.format=[...e.format??[],...m])}const r=e.format??[],i=u=>{const m=j(u.range);return m!==void 0&&O(m,t)},l=r.some(u=>i(u)&&$(u,s)),f=Object.fromEntries(Object.entries(s).filter(([,u])=>u!==void 0)),c=t.top===0&&t.bottom===R-1,d=t.left===0&&t.right===K-1;if(c&&!d&&!l){let u={...e.columns};for(let m=t.left;m<=t.right;m++){const g=C(m),h={...x(u[g]??{},s),...f};u=Object.keys(h).length===0?b(u,g):{...u,[g]:h}}e.columns=u;return}if(d&&!c&&!l){let u={...e.rows};for(let m=t.top;m<=t.bottom;m++){const g=String(m+1),h={...x(u[g]??{},s),...f};u=Object.keys(h).length===0?b(u,g):{...u,[g]:h}}e.rows=u;return}const a=o.tables.find(u=>u.rows>0&&t.top===u.data.top&&t.bottom===u.data.bottom&&t.left>=u.area.left&&t.right<=u.area.right);if(a&&!l){const u=n.table(o,a);let m={...u.columns};for(let g=t.left;g<=t.right;g++){const h=a.columns[g-a.at.col]?.name;if(h===void 0)continue;const y={...x(m[h]??{},s),...f};m=Object.keys(y).length===0?b(m,h):{...m,[h]:y}}u.columns=m,Object.keys(m).length===0&&delete u.columns,n.edit.whole=!0;return}const w=M(t),p=r.find(u=>{const m=j(u.range);return m!==void 0&&M(m)===w}),U=(p?r.slice(r.indexOf(p)+1):[]).some(u=>i(u)&&$(u,s)),k={};for(const[u,m]of Object.entries(s)){const g=r.some(h=>h!==p&&i(h)&&u in h)||ae(e,o,t,u);m!==void 0?k[u]=m:g&&(k[u]=me[u])}if(p&&!U){const u={...x(p,s),...k};e.format=r.flatMap(m=>m!==p?[m]:Object.keys(u).length>1?[u]:[])}else Object.keys(k).length>0&&(e.format=[...r,{range:w,...k}])}export function tidied(n){n.format?.length===0&&delete n.format,n.columns&&Object.keys(n.columns).length===0&&delete n.columns,n.rows&&Object.keys(n.rows).length===0&&delete n.rows,n.cells&&Object.keys(n.cells).length===0&&delete n.cells}export function setColumnWidth(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=C(e),f=S(i.columns?.[l]??{},"width"),c=t===void 0?f:{...f,width:t},d=b(i.columns??{},l);return i.columns=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function setRowHeight(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=String(e+1),f=S(i.rows?.[l]??{},"height"),c=t===void 0?f:{...f,height:t},d=b(i.rows??{},l);return i.rows=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function sheetNameProblem(n,o,e){if(o.trim()===""||o.length>31||/[\\/?*[\]:]/u.test(o)||o.startsWith("'")||o.endsWith("'"))return"sheet-name";const t=n.workbook.sheet(o);if(t&&t.name!==e)return"sheet-taken"}export function renameSheet(n,o,e){const t=sheetNameProblem(n,e,o);if(t)return refused(t);const s=F(n,{op:"rename-sheet",from:o,to:e});return{...blankEdit(),file:s.file,rows:new Map(s.rows),whole:!0}}export function addSheet(n,o,e){const t=sheetNameProblem(n,o);if(t)return refused(t);const s=[...n.file.sheets],r=s.findIndex(i=>i.name===e);return s.splice(r<0?s.length:r+1,0,{name:o}),{...blankEdit(),file:{...n.file,sheets:s},whole:!0}}export function copyName(n,o){for(let e=2;;e++){const t=` (${String(e)})`,s=o.slice(0,31-t.length).trimEnd()+t;if(!n.workbook.sheet(s))return s}}export function duplicateSheet(n,o){const e=H(n,o,copyName(n,o));return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function deleteSheet(n,o){const e=F(n,{op:"delete-sheet",name:o});if(e.refused)return refused(e.refused);const t=we(n.file,e.file);for(const s of t)e.rows.delete(s);return{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0,...t.length===0?{}:{removed:t}}}function we(n,o){const e=s=>s.sheets.flatMap(r=>[...(r.tables??[]).map(i=>i.rows),...(r.blocks??[]).map(i=>i.rows)]),t=new Set(e(o));return[...new Set(e(n))].filter(s=>!t.has(s))}export function moveSheet(n,o,e){const t=[...n.file.sheets],s=t.findIndex(i=>i.name===o),[r]=t.splice(s,1);return r?(t.splice(e,0,r),{...blankEdit(),file:{...n.file,sheets:t},whole:!0}):refused("no-sheet")}export function bandEdit(n,o){const e=F(n,o);return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function defineName(n,o,e,t){if(!J(o)||n.workbook.name(o)||n.workbook.table(o))return refused("name-invalid");const s=(l,f)=>`$${C(f)}$${String(l+1)}`,r=t.top===t.bottom&&t.left===t.right?s(t.top,t.left):`${s(t.top,t.left)}:${s(t.bottom,t.right)}`,i=/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)?e:`'${e.replaceAll("'","''")}'`;return{...blankEdit(),file:{...n.file,names:{...n.file.names,[o]:`=${i}!${r}`}},whole:!0}}export function inputOf(n,o,e,t){const s=o.at(e,t);if(s===void 0)return"";if(s instanceof P)return s.text;const r=o.tableAt(e,t);if(r){const d=r.columns[t-r.at.col];if(e===r.at.row)return d?.name??"";const a=d?.csv===void 0?void 0:r.records[e-r.at.row-1]?.[d.csv];if(a!==void 0)return a}const i=o.blockAt(e,t);if(i){const d=n.rows.get(i.file)?.[e-i.area.top]?.[t-i.area.left];if(d!==void 0)return d}const l=o.keys.get(V(e,t)),f=l===void 0?void 0:o.spec.cells?.[l],c=f!==null&&typeof f=="object"?f.value:f;return c!=null?String(c):typeof s=="object"?s.code:String(s)}export function exceptionsOf(n){const o=[];for(const e of n.columns){const{csv:t}=e;!e.formula||t===void 0||n.records.forEach((s,r)=>{const i=s[t]??"";i!==""&&o.push({row:n.at.row+1+r,col:n.at.col+e.index,column:e.name,text:i})})}return o}
2
+ import{MAX_COLUMNS as P,MAX_ROWS as V,cellName as S,columnLetter as $,contains as J,overlaps as k,rangeName as E,readAddress as Q,readArea as v}from"./address.js";import{moveFormula as Y}from"./formula/move.js";import{parseFormula as Z}from"./formula/parse.js";import{printFormula as ee}from"./formula/print.js";import{freeColumn as K,duplicated as te,restructure as _,uniqueColumn as q,withColumnsUpTo as T}from"./structure.js";import{RUN_FIELDS as ne,joinedRuns as oe,plainRuns as D,runsWithout as se}from"./rich.js";import{CellError as re,readTyped as C}from"./values.js";import{FormulaCell as ie,placeKey as le,runsText as N,validName as X}from"./workbook.js";export const BLOCK_CELLS=100;const z=(n,o)=>n.top<=o.top&&n.left<=o.left&&n.bottom>=o.bottom&&n.right>=o.right,R=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o)),fe=n=>R(n,"formula"),O=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>e!==o));export const blankEdit=()=>({rows:new Map,cells:[],whole:!1}),refused=n=>({...blankEdit(),refused:n});const x=n=>C(n).formula!==void 0;function ce(n){const o=C(n);return o.formula!==void 0?n:o.value===null?null:o.format!==void 0?n:typeof o.value=="number"||typeof o.value=="boolean"?o.value:n}const I=n=>n!==null&&typeof n=="object"?Object.fromEntries(Object.entries(n).filter(([o])=>o!=="value"&&o!=="formula"&&o!=="runs")):{};export class Draft{book;specs=new Map;file;fileChanged=!1;grown=new Map;added=new Map;edit=blankEdit();constructor(o){this.book=o,this.file=o.file}spec(o){let e=this.specs.get(o.index);if(!e){const t=this.file.sheets.findIndex(s=>s.name===o.name);e={...this.file.sheets[t]??{name:o.name}},this.specs.set(o.index,e),this.fileChanged||(this.file={...this.file,sheets:[...this.file.sheets]},this.fileChanged=!0),this.file.sheets[t]=e}return e}table(o,e){const t=this.spec(o),s=[...t.tables??[]],r=s.findIndex(l=>l.name===e.name),i={...s[r]??e.spec};return s[r]=i,t.tables=s,i}rows(o){const e=this.edit.rows.get(o);if(e)return e;const t=[...this.book.rows.get(o)??[]];return this.edit.rows.set(o,t),t}setField(o,e,t,s){const r=this.rows(o),i=[...r[e]??[]];for(;i.length<=t;)i.push("");return i[t]=s,r[e]=i,i}rowsOf(o){return this.grown.get(o)??o.rows}grow(o,e,t){this.grown.set(o,this.rowsOf(o)+1);const s=this.added.get(o)??new Map;s.set(e,t),this.added.set(o,s)}addedAt(o,e,t){for(const[s,r]of this.added){const i=r.get(e);if(i!==void 0&&s.sheet===o&&t>=s.at.col&&t<s.at.col+s.columns.length)return{table:s,record:i}}}finish(){return this.fileChanged&&(this.edit.file=this.file),this.edit}}function ue(n,o,e,t){return o.tables.find(s=>{const r=s.at.row+n.rowsOf(s)+1;if(e!==r)return!1;const i=s.at.col+s.columns.length-1;if(t<s.at.col||t>i)return!1;for(let l=s.at.col;l<=i;l++)if(o.at(e,l)!==void 0)return!1;return!0})}function de(n,o,e){return n.tables.find(t=>{const{top:s,bottom:r,right:i}=t.area;if(e!==i+1||o<s||o>r)return!1;for(let l=s;l<=r;l++)if(n.at(l,e)!==void 0)return!1;return!0})}export const movedTo=(n,o,e)=>{const t=Z(n);return t.ok?ee(Y(t.node,o,e)):n};function U(n,o,e,t,s,r){const i=e.at.row+1,l=n.table(o,e),f=movedTo(r,i-s,0);if(l.columns={...l.columns,[t.name]:{...l.columns?.[t.name],formula:f}},t.csv!==void 0){const c=e.places[s-i];c!==void 0&&n.setField(e.file,c,t.csv,"")}n.edit.whole=!0}function ae(n,o,e,t){const{csv:s}=e;if(s===void 0)return!1;const r=n.rows(o.file);return o.places.some((i,l)=>l!==t&&(r[i]?.[s]??"")!=="")}function me(n,o,e,t,s){const r=s.trim();if(r==="")return refused("column-name");if(r===t.name)return n.finish();const i=e.columns.filter(c=>c!==t).map(c=>c.name),l=q(i,r),f=_(o,{op:"rename-column",table:e.name,from:t.name,to:l});return{...blankEdit(),file:f.file,rows:new Map(f.rows),whole:!0}}function he(n,o,e,t,s,r){const i=e.columns[s-e.at.col];if(!i)return;const l=t-e.at.row-1;if(x(r)){if(i.formula){U(n,o,e,i,t,r);return}if(!ae(n,e,i,l)){U(n,o,e,i,t,r);return}n.edit.offer={sheet:o.name,row:t,col:s,text:r}}const c=e.places[l];if(c===void 0)return;let d=i.csv;if(d===void 0){if(r==="")return;const h=e.columns.map(g=>g.name);n.edit.rows.set(e.file,T(n.rows(e.file),h,i.index)),n.edit.whole=!0,d=i.index}const m=n.setField(e.file,c,d,r);n.edit.cells.push({sheet:o,row:t,col:s,...r===""&&i.formula?{column:i.formula}:{input:r},record:{table:e,index:l,fields:m}})}function we(n,o,e,t,s){const r=n.rows(o.file),i=Math.max(r[0]?.length??1,1),l=new Array(i).fill(""),f=o.columns[t-o.at.col];f?.csv!==void 0&&(l[f.csv]=s),r.push(l),n.grow(o,e,r.length-1),n.edit.whole=!0}function pe(n,o,e,t,s){const r=n.table(o,e),i=e.columns.map(h=>h.name),l=t===e.at.row,f=l?q(i,s.trim()===""?K(i):s.trim()):K(i);if(n.edit.whole=!0,!l&&x(s)){r.columns={...r.columns,[f]:{formula:movedTo(s,e.at.row+1-t,0)}};return}const c=i.length,d=T(n.rows(e.file),i,c-1),m=d[0];if(m&&m.push(f),d.forEach((h,g)=>{g>0&&h.length>0&&h.push("")}),!l){const h=e.places[t-e.at.row-1],g=h===void 0?void 0:d[h];g&&(g[c]=s)}n.edit.rows.set(e.file,d)}function be(n,o,e,t,s,r,i){n.setField(e,s-t.top,r-t.left,i),n.edit.cells.push({sheet:o,row:s,col:r,input:i})}function ge(n,o,e){return Object.keys(n.spec.cells??{}).some(t=>{if(!t.includes(":"))return!1;const s=v(t);return s!==void 0&&J(s,o,e)})}function ye(n,o,e,t,s){const r=n.spec(o),i=S({row:e,col:t});let l={...r.cells};const f=l[i];if(f!==null&&typeof f=="object"&&f.runs!==void 0&&N(f.runs)===s){n.edit.cells.push({sheet:o,row:e,col:t,input:s,key:i});return}const c=f===void 0?{}:I(f),d=ce(s),m=Object.keys(c).length===0;let h;if(d===null){const g=ge(o,e,t);h=!m||g,m&&!g?l=O(l,i):l[i]=m?null:c}else h=!0,l[i]=m?d:{...c,...x(s)?{formula:s}:{value:d}};r.cells=l,Object.keys(l).length===0&&delete r.cells,n.edit.cells.push({sheet:o,row:e,col:t,input:s,key:h?i:null})}export function writeOne(n,o,e,t,s,r){const i=n.addedAt(e,t,s);if(i){const{csv:c}=i.table.columns[s-i.table.at.col]??{};c!==void 0&&n.setField(i.table.file,i.record,c,r);return}const l=e.tableAt(t,s);if(l){const c=l.columns[s-l.at.col];if(t===l.at.row)return c?me(n,o,l,c,r):void 0;he(n,e,l,t,s,r);return}if(r!==""){const c=ue(n,e,t,s);if(c){we(n,c,t,s,r);return}const d=de(e,t,s);if(d){pe(n,e,d,t,r);return}}const f=e.blockAt(t,s);f?be(n,e,f.file,f.area,t,s,r):ye(n,e,t,s,r)}export function setRuns(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");const i=oe(s),l=N(i);if(i.length===0||D(i))return writeCells(n,o,[{row:e,col:t,text:l}]);if(r.tableAt(e,t)||r.blockAt(e,t))return refused("rich-loose");const f=new Draft(n),c=f.spec(r),d=S({row:e,col:t}),m=c.cells?.[d],h=m===void 0?{}:I(m);return c.cells={...c.cells,[d]:{...h,runs:i}},f.edit.cells.push({sheet:r,row:e,col:t,input:l,key:d}),f.finish()}function ke(n,o){if(n===null||typeof n!="object"||!n.runs)return n;const e=se(n.runs,o);if(!D(e))return{...n,runs:e};const t=N(e),s=I(n);return C(t).value===t&&C(t).format===void 0?Object.keys(s).length===0?t:{...s,value:t}:{...s,runs:[{text:t}]}}export function writeCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const{row:r,col:i,text:l}of[...e].sort((f,c)=>f.row-c.row||f.col-c.col)){const f=writeOne(s,n,t,r,i,l);if(f)return f}return s.finish()}export function overwriteColumn(n,o,e,t,s){const r=n.workbook.sheet(o),i=r?.tableAt(e,t);if(!r||!i)return refused("no-sheet");const l=i.columns[t-i.at.col];if(!l)return refused("no-sheet");const f=new Draft(n);U(f,r,i,l,e,s);const{csv:c}=l;if(c!==void 0)for(const d of i.places)f.setField(i.file,d,c,"");return f.finish()}function*G(n,o){const e=Math.min(o.right,n.columnsUsed-1);for(let t=o.left;t<=e;t++){const[s,r]=n.span(t,o.top,o.bottom);for(let i=s;i<=r;i++)n.at(i,t)!==void 0&&(yield[i,t])}}export function clearCells(n,o,e){const t=n.workbook.sheet(o);if(!t)return refused("no-sheet");const s=new Draft(n);for(const r of t.tables){const{top:i,bottom:l}=r.data;if(!(l<i||e.top>i||e.bottom<l))for(const f of r.columns){const c=r.at.col+f.index;if(c<e.left||c>e.right||!f.formula)continue;const d=s.table(t,r),m=r.columns.map(y=>y.name);f.csv===void 0&&s.edit.rows.set(r.file,T(s.rows(r.file),m,f.index));const h=fe(d.columns?.[f.name]??{}),g=O(d.columns??{},f.name);d.columns=Object.keys(h).length>0?{...g,[f.name]:h}:g,Object.keys(d.columns).length===0&&delete d.columns,s.edit.whole=!0}}for(const[r,i]of G(t,e)){if(t.tableAt(r,i)?.at.row===r)continue;const l=writeOne(s,n,t,r,i,"");if(l)return l}return s.finish()}export function dropKeys(n,o){n.cells&&(n.cells=Object.fromEntries(Object.entries(n.cells).filter(([e])=>{const t=v(e);return!t||!z(o,t)})))}export function fillCells(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");if(!r.tables.some(f=>k(f.area,t))&&!r.blocks.some(f=>k(f.area,t))&&x(s)){const f=new Draft(n),c=f.spec(r);dropKeys(c,t);const d=movedTo(s,t.top-e.row,t.left-e.col),m=E(t);return c.cells={...c.cells,[m]:d},f.edit.whole=!0,f.finish()}const l=[];for(let f=t.top;f<=t.bottom;f++)for(let c=t.left;c<=t.right;c++)f===e.row&&c===e.col||l.push({row:f,col:c,text:x(s)?movedTo(s,f-e.row,c-e.col):s});return writeCells(n,o,l)}export function writeBlockOf(n,o,e,t,s){const r=n.workbook.sheet(o);if(!r)return refused("no-sheet");const i=new Draft(n),l=i.spec(r);return l.blocks=[...l.blocks??[],{at:S(e),rows:s}],i.edit.rows.set(s,t),i.edit.whole=!0,i.finish()}const W=(n,o)=>Object.keys(o).some(e=>e in n),L=(n,o)=>Object.fromEntries(Object.entries(n).filter(([e])=>!(e in o)));function Oe(n){if(n===null||typeof n!="object")return n;const o=Object.keys(n);return o.length===1&&o[0]==="value"?n.value??null:o.length===1&&o[0]==="formula"?n.formula??null:n}const je={bold:!1,italic:!1,underline:!1,strike:!1,wrap:!1,locked:!0,hide_formula:!1,align:"general",format:"General",color:"#000000",fill:"#FFFFFF",font:"Calibri",size:11,border:{left:{style:"none"},right:{style:"none"},top:{style:"none"},bottom:{style:"none"}}};function ve(n,o,e,t){for(const[s,r]of Object.entries(n.columns??{})){const i=Q(`${s}1`)?.col;if(i!==void 0&&i>=e.left&&i<=e.right&&t in r)return!0}for(const[s,r]of Object.entries(n.rows??{})){const i=Number(s)-1;if(i>=e.top&&i<=e.bottom&&t in r)return!0}return o.tables.some(s=>k(s.area,e)&&s.columns.some(r=>r.spec!==void 0&&t in r.spec&&s.at.col+r.index>=e.left&&s.at.col+r.index<=e.right))}export function setLook(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n);return applyLook(r,s,e,t),r.finish()}export function applyLook(n,o,e,t){const s=n.spec(o);Ce(n,o,s,e,t),tidied(s)}function Ce(n,o,e,t,s){const r=ne.filter(u=>u in s);if(e.cells&&r.length>0)for(const[u,a]of Object.entries(e.cells)){if(a===null||typeof a!="object"||!a.runs)continue;const w=v(u);w&&k(w,t)&&(e.cells={...e.cells,[u]:ke(a,r)})}if(e.cells){const u={...e.cells},a=[];for(const[w,b]of Object.entries(u)){if(b===null||typeof b!="object"||!W(b,s))continue;const j=v(w);!j||!k(j,t)||(w.includes(":")&&!z(t,j)&&a.push({range:w,...Object.fromEntries(Object.entries(b).filter(([H])=>H in s))}),u[w]=Oe(L(b,s)))}e.cells=u,a.length>0&&(e.format=[...e.format??[],...a])}const i=e.format??[],l=u=>{const a=v(u.range);return a!==void 0&&k(a,t)},f=i.some(u=>l(u)&&W(u,s)),c=Object.fromEntries(Object.entries(s).filter(([,u])=>u!==void 0)),d=t.top===0&&t.bottom===V-1,m=t.left===0&&t.right===P-1;if(d&&!m&&!f){let u={...e.columns};for(let a=t.left;a<=t.right;a++){const w=$(a),b={...L(u[w]??{},s),...c};u=Object.keys(b).length===0?O(u,w):{...u,[w]:b}}e.columns=u;return}if(m&&!d&&!f){let u={...e.rows};for(let a=t.top;a<=t.bottom;a++){const w=String(a+1),b={...L(u[w]??{},s),...c};u=Object.keys(b).length===0?O(u,w):{...u,[w]:b}}e.rows=u;return}const h=o.tables.find(u=>u.rows>0&&t.top===u.data.top&&t.bottom===u.data.bottom&&t.left>=u.area.left&&t.right<=u.area.right);if(h&&!f){const u=n.table(o,h);let a={...u.columns};for(let w=t.left;w<=t.right;w++){const b=h.columns[w-h.at.col]?.name;if(b===void 0)continue;const j={...L(a[b]??{},s),...c};a=Object.keys(j).length===0?O(a,b):{...a,[b]:j}}u.columns=a,Object.keys(a).length===0&&delete u.columns,n.edit.whole=!0;return}const g=E(t),y=i.find(u=>{const a=v(u.range);return a!==void 0&&E(a)===g}),A=(y?i.slice(i.indexOf(y)+1):[]).some(u=>l(u)&&W(u,s)),p={};for(const[u,a]of Object.entries(s)){const w=i.some(b=>b!==y&&l(b)&&u in b)||ve(e,o,t,u);a!==void 0?p[u]=a:w&&(p[u]=je[u])}if(y&&!A){const u={...L(y,s),...p};e.format=i.flatMap(a=>a!==y?[a]:Object.keys(u).length>1?[u]:[])}else Object.keys(p).length>0&&(e.format=[...i,{range:g,...p}])}export function tidied(n){n.format?.length===0&&delete n.format,n.columns&&Object.keys(n.columns).length===0&&delete n.columns,n.rows&&Object.keys(n.rows).length===0&&delete n.rows,n.cells&&Object.keys(n.cells).length===0&&delete n.cells}export function setColumnWidth(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=$(e),f=R(i.columns?.[l]??{},"width"),c=t===void 0?f:{...f,width:t},d=O(i.columns??{},l);return i.columns=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function setRowHeight(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");const r=new Draft(n),i=r.spec(s),l=String(e+1),f=R(i.rows?.[l]??{},"height"),c=t===void 0?f:{...f,height:t},d=O(i.rows??{},l);return i.rows=Object.keys(c).length===0?d:{...d,[l]:c},tidied(i),r.finish()}export function sheetNameProblem(n,o,e){if(o.trim()===""||o.length>31||/[\\/?*[\]:]/u.test(o)||o.startsWith("'")||o.endsWith("'"))return"sheet-name";const t=n.workbook.sheet(o);if(t&&t.name!==e)return"sheet-taken"}export function renameSheet(n,o,e){const t=sheetNameProblem(n,e,o);if(t)return refused(t);const s=_(n,{op:"rename-sheet",from:o,to:e});return{...blankEdit(),file:s.file,rows:new Map(s.rows),whole:!0}}export function addSheet(n,o,e){const t=sheetNameProblem(n,o);if(t)return refused(t);const s=[...n.file.sheets],r=s.findIndex(i=>i.name===e);return s.splice(r<0?s.length:r+1,0,{name:o}),{...blankEdit(),file:{...n.file,sheets:s},whole:!0}}export function copyName(n,o){for(let e=2;;e++){const t=` (${String(e)})`,s=o.slice(0,31-t.length).trimEnd()+t;if(!n.workbook.sheet(s))return s}}export function duplicateSheet(n,o){const e=te(n,o,copyName(n,o));return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function deleteSheet(n,o){const e=_(n,{op:"delete-sheet",name:o});if(e.refused)return refused(e.refused);const t=xe(n.file,e.file);for(const s of t)e.rows.delete(s);return{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0,...t.length===0?{}:{removed:t}}}function xe(n,o){const e=s=>s.sheets.flatMap(r=>[...(r.tables??[]).map(i=>i.rows),...(r.blocks??[]).map(i=>i.rows)]),t=new Set(e(o));return[...new Set(e(n))].filter(s=>!t.has(s))}export function moveSheet(n,o,e){const t=[...n.file.sheets],s=t.findIndex(i=>i.name===o),[r]=t.splice(s,1);return r?(t.splice(e,0,r),{...blankEdit(),file:{...n.file,sheets:t},whole:!0}):refused("no-sheet")}export function bandEdit(n,o){const e=_(n,o);return e.refused?refused(e.refused):{...blankEdit(),file:e.file,rows:new Map(e.rows),whole:!0}}export function defineName(n,o,e,t){if(!X(o)||n.workbook.name(o)||n.workbook.table(o))return refused("name-invalid");const s=(l,f)=>`$${$(f)}$${String(l+1)}`,r=t.top===t.bottom&&t.left===t.right?s(t.top,t.left):`${s(t.top,t.left)}:${s(t.bottom,t.right)}`,i=/^[\p{L}_][\p{L}\p{N}_.]*$/u.test(e)?e:`'${e.replaceAll("'","''")}'`;return{...blankEdit(),file:{...n.file,names:{...n.file.names,[o]:`=${i}!${r}`}},whole:!0}}export function inputOf(n,o,e,t){const s=o.at(e,t);if(s===void 0)return"";if(s instanceof ie)return s.text;const r=o.tableAt(e,t);if(r){const d=r.columns[t-r.at.col];if(e===r.at.row)return d?.name??"";const m=d?.csv===void 0?void 0:r.records[e-r.at.row-1]?.[d.csv];if(m!==void 0)return m}const i=o.blockAt(e,t);if(i){const d=n.rows.get(i.file)?.[e-i.area.top]?.[t-i.area.left];if(d!==void 0)return d}const l=o.keys.get(le(e,t)),f=l===void 0?void 0:o.spec.cells?.[l],c=f!==null&&typeof f=="object"?f.value:f;return c!=null?String(c):typeof s=="object"?s.code:String(s)}export function exceptionsOf(n){const o=[];for(const e of n.columns){const{csv:t}=e;!e.formula||t===void 0||n.records.forEach((s,r)=>{const i=s[t]??"";i!==""&&o.push({row:n.at.row+1+r,col:n.at.col+e.index,column:e.name,text:i})})}return o}function Le(n){const o=new Set([...n.file.sheets.flatMap(e=>(e.tables??[]).map(t=>t.name)),...Object.keys(n.file.names??{})].map(e=>e.toLowerCase()));for(let e=1;;e++){const t=`Table${String(e)}`;if(!o.has(t.toLowerCase()))return t}}export function makeTable(n,o,e,t){const s=n.workbook.sheet(o);if(!s)return refused("no-sheet");if(s.tables.some(p=>k(p.area,e)))return refused("table-overlap");const r=e.right-e.left+1,i=(p,u)=>inputOf(n,s,p,u);if(!t.header){if(e.top===0)return refused("table-room");for(let p=0;p<r;p++)if(i(e.top-1,e.left+p)!=="")return refused("table-room")}const l=new Draft(n),f=new Set,c=Array.from({length:r},(p,u)=>{const a=t.header?i(e.top,e.left+u).trim():"";let w=a===""?`Column${String(u+1)}`:a;for(let b=2;f.has(w.toLowerCase());b++)w=`${a===""?`Column${String(u+1)}`:a}${String(b)}`;return f.add(w.toLowerCase()),w}),d=t.header?e.top+1:e.top,m=[];for(let p=d;p<=e.bottom;p++)m.push(Array.from({length:r},(u,a)=>i(p,e.left+a)));for(const[p,u]of G(s,e)){const a=writeOne(l,n,s,p,u,"");if(a)return a}const h=Le(n),g=new Set([...n.rows.keys(),...l.edit.rows.keys()].map(p=>p.toLowerCase()));let y=`data/${h.toLowerCase()}.csv`;for(let p=2;g.has(y);p++)y=`data/${h.toLowerCase()}-${String(p)}.csv`;l.edit.rows.set(y,[c,...m]);const M=l.spec(s),A=t.header?e.top:e.top-1;return M.tables=[...M.tables??[],{name:h,at:S({row:A,col:e.left}),rows:y,...t.style!==void 0&&t.style!=="TableStyleMedium2"?{style:t.style}:{}}],l.edit.whole=!0,l.finish()}export function setTableStyle(n,o,e,t){const s=n.workbook.sheet(o),r=s?.tables.find(f=>f.name===e);if(!s||!r)return refused("no-sheet");const i=new Draft(n),l=i.table(s,r);return t==="TableStyleMedium2"?delete l.style:l.style=t,i.edit.whole=!0,i.finish()}export function setTableOptions(n,o,e,t){const s=n.workbook.sheet(o),r=s?.tables.find(f=>f.name===e);if(!s||!r)return refused("no-sheet");const i=new Draft(n),l=i.table(s,r);return t.banded_rows!==void 0&&(t.banded_rows?delete l.banded_rows:l.banded_rows=!1),t.banded_columns!==void 0&&(t.banded_columns?l.banded_columns=!0:delete l.banded_columns),t.first_column!==void 0&&(t.first_column?l.first_column=!0:delete l.first_column),t.last_column!==void 0&&(t.last_column?l.last_column=!0:delete l.last_column),i.edit.whole=!0,i.finish()}function F(n,o){return o===void 0?n.names:n.sheets.find(e=>e.name===o)?.names}function B(n,o,e){const t=Object.keys(e).length===0?void 0:e;if(o===void 0){const s={...n};return t?s.names=t:delete s.names,s}return{...n,sheets:n.sheets.map(s=>{if(s.name!==o)return s;const r={...s};return t?r.names=t:delete r.names,r})}}export function setName(n,o){const e=o.name.trim(),t=o.was!==void 0&&o.was.name.toLowerCase()!==e.toLowerCase(),s=Object.keys(F(n.file,o.scope)??{}).some(d=>d.toLowerCase()===e.toLowerCase()&&!(d.toLowerCase()===o.was?.name.toLowerCase()&&o.was.scope===o.scope));if(!X(e)||s||n.workbook.table(e))return refused("name-invalid");const r=o.value.trim(),i=C(r).value,l=r.startsWith("=")||i instanceof re?r:i,f=t&&o.was?bandEdit(n,{op:"rename-name",from:o.was.name,to:e}):void 0;if(f?.refused)return f;let c=f?.file??n.file;if(o.was){const d={...F(c,o.was.scope)};for(const m of Object.keys(d))m.toLowerCase()===o.was.name.toLowerCase()&&(d[m]=null);c=B(c,o.was.scope,Object.fromEntries(Object.entries(d).filter(([,m])=>m!==null)))}return c=B(c,o.scope,{...F(c,o.scope),[e]:l}),{...blankEdit(),file:c,rows:f?.rows??new Map,whole:!0}}export function deleteName(n,o,e){const t=F(n.file,e)??{},s=Object.fromEntries(Object.entries(t).filter(([r])=>r.toLowerCase()!==o.toLowerCase()));return{...blankEdit(),file:B(n.file,e,s),whole:!0}}
@@ -27,4 +27,14 @@ export declare function fillDownTo(sheet: Worksheet, area: Area): number | undef
27
27
  * of one moves as its cells' values.
28
28
  */
29
29
  export declare function moveCells(book: EditBook, sheetName: string, from: Area, toSheet: string, to: Place): BookEdit;
30
+ export type CellShift = "right" | "down" | "left" | "up";
31
+ /**
32
+ * Excel's Insert Cells (shift right or down) and Delete Cells (shift left or
33
+ * up) over an area: the cells from it to the sheet's edge, across it alone,
34
+ * move by its size, looks with them, and every formula that named them
35
+ * follows, as Excel's references do (one to a deleted cell is #REF!).
36
+ * Refused when a table or a merged range is among what would move, as
37
+ * Excel refuses.
38
+ */
39
+ export declare function shiftCells(book: EditBook, sheetName: string, area: Area, shift: CellShift): BookEdit;
30
40
  //# sourceMappingURL=fill.d.ts.map
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{cellName as X,contains as v,overlaps as A,rangeName as Y}from"./address.js";import{rectangles as N}from"./api/rectangles.js";import{Draft as E,applyLook as R,blankEdit as I,clearCells as Z,dropKeys as tt,inputOf as U,movedTo as W,refused as x,writeCells as ot,writeOne as et}from"./edit.js";import{relativeKey as nt}from"./formula/move.js";import{parseFormula as q}from"./formula/parse.js";import{printFormula as st}from"./formula/print.js";import{mapNode as rt}from"./formula/walk.js";import{restructure as it}from"./structure.js";import{seriesAfter as lt}from"./series.js";import{readTyped as ct}from"./values.js";import{workbookOf as ft}from"./workbook.js";const K=n=>ct(n).formula!==void 0;function ut(n,e,t){const o=q(n);return o.ok?nt(o.node,e,t):void 0}const at=(n,e)=>!n.tables.some(t=>A(t.area,e))&&!n.blocks.some(t=>A(t.area,e));function pt(n,e,t,o){if(n.some(r=>K(r.text))){const r=n.length;return e.map((f,l)=>{const a=t?n[((r-1-l)%r+r)%r]:n[l%r],b=a?.text??"";return{...f,text:a?W(b,f.row-a.row,f.col-a.col):b}})}const s=lt(n.map(r=>r.text),e.length,{mode:o,back:t});return e.map((r,f)=>({...r,text:s[f]??""}))}const G=["bold","italic","underline","strike","font","size","color","fill","align","valign","wrap","shrink","indent","rotation","border","format"];export const NO_LOOK=Object.fromEntries(G.map(n=>[n,void 0]));export function copyLooks(n,e,t,o){const i=new Map;for(const s of o){const r=e.lookAt(s.from.row,s.from.col),f=t.lookAt(s.to.row,s.to.col);if(JSON.stringify(r)===JSON.stringify(f))continue;const l=JSON.stringify(r),a=i.get(l);a?a.places.push(s.to):i.set(l,{look:r,places:[s.to]})}for(const{look:s,places:r}of i.values()){const f={};for(const l of G)f[l]=s[l];for(const l of N(r))R(n,t,l,f)}}export function autoFill(n,e,t,o,i="auto"){const s=n.workbook.sheet(e);if(!s)return x("no-sheet");const r=o.bottom>t.bottom||o.top<t.top,f=o.top<t.top||o.left<t.left,l=new E(n),a=r?{first:t.left,last:t.right}:{first:t.top,last:t.bottom},b=new Map,g=(u,w)=>{const k=`${String(u)}:${String(w)}`;let m=b.get(k);return m===void 0&&(m=U(n,s,u,w),b.set(k,m)),m},L=(t.bottom-t.top+1)*(t.right-t.left+1),y=new Set;for(let u=t.top;u<=t.bottom;u++)for(let w=t.left;w<=t.right;w++){const k=g(u,w);K(k)&&y.add(ut(k,u,w)??"")}if(y.size===1&&L>0&&at(s,o)&&wt(g,t)){const u=l.spec(s);return tt(u,o),u.cells={...u.cells,[Y(o)]:W(g(t.top,t.left),o.top-t.top,o.left-t.left)},l.edit.whole=!0,H(l,s,t,o,r),l.finish()}for(let u=a.first;u<=a.last;u++){const w=[];if(r)for(let p=t.top;p<=t.bottom;p++)w.push({row:p,col:u,text:g(p,u)});else for(let p=t.left;p<=t.right;p++)w.push({row:u,col:p,text:g(u,p)});const k=[],m=f?r?t.top-1:t.left-1:r?t.bottom+1:t.right+1,O=r?f?o.top:o.bottom:f?o.left:o.right,T=f?-1:1;for(let p=m;f?p>=O:p<=O;p+=T)k.push(r?{row:p,col:u}:{row:u,col:p});for(const p of pt(w,k,f,i))et(l,n,s,p.row,p.col,p.text)}return H(l,s,t,o,r),l.finish()}function wt(n,e){for(let t=e.top;t<=e.bottom;t++)for(let o=e.left;o<=e.right;o++)if(!K(n(t,o)))return!1;return!0}function H(n,e,t,o,i){const s=[],r=t.bottom-t.top+1,f=t.right-t.left+1;for(let l=o.top;l<=o.bottom;l++)for(let a=o.left;a<=o.right;a++){if(v(t,l,a))continue;const b=i?t.top+((l-t.top)%r+r)%r:l,g=i?a:t.left+((a-t.left)%f+f)%f;s.push({from:{row:b,col:g},to:{row:l,col:a}})}copyLooks(n,e,e,s)}export function pasteLooks(n,e,t,o){const i=n.workbook.sheet(e),s=n.workbook.sheet(t);if(!i||!s)return x("no-sheet");const r=new E(n);return copyLooks(r,i,s,o),r.finish()}export function fillDownTo(n,e){const t=(o,i)=>i>=0&&n.at(o,i)!==void 0;for(const o of[e.left-1,e.right+1]){if(!t(e.bottom,o)&&!t(e.bottom+1,o))continue;let i=e.bottom;for(;t(i+1,o);)i+=1;if(i>e.bottom)return i}}function dt(n,e,t){if(!K(n))return n;const o=q(n);if(!o.ok)return n;const i=rt(o.node,s=>s.kind!=="ref"?s:s.sheet===void 0?{...s,sheet:e}:s.sheet.toLowerCase()!==t.toLowerCase()||s.lastSheet!==void 0?s:Object.fromEntries(Object.entries(s).filter(([r])=>r!=="sheet")));return st(i)}function ht(n){const e=I();e.whole=!0;for(const t of n){t.file&&(e.file=t.file);for(const[o,i]of t.rows)e.rows.set(o,i)}return e}function S(n,e){const t=e.file??n.file,o=new Map(n.rows);for(const[i,s]of e.rows)o.set(i,s);return{file:t,rows:o,workbook:ft({file:t,rows:i=>o.get(i)})}}export function moveCells(n,e,t,o,i){const s=n.workbook.sheet(e),r=n.workbook.sheet(o);if(!s||!r)return x("no-sheet");const f=i.row-t.top,l=i.col-t.left;if(f===0&&l===0&&s===r)return I();const a={top:i.row,left:i.col,bottom:t.bottom+f,right:t.right+l},b=s.tables.filter(c=>v(t,c.area.top,c.area.left)&&v(t,c.area.bottom,c.area.right));for(const c of s.tables)if(!b.includes(c)&&A(c.area,t)&&t.top<=c.at.row)return x("table-move");if(b.length>0&&s!==r)return x("table-move");for(const c of r.tables)if(!b.includes(c)&&A(c.area,a)&&a.top<=c.at.row)return x("table-move");const g={op:"move-cells",sheet:e,area:t,rows:f,columns:l,...s===r?{}:{to:o}},L=it(n,g),y={...I(),file:L.file,rows:new Map(L.rows)},u=S(n,y),w=u.workbook.sheet(e),k=u.workbook.sheet(o);if(!w||!k)return x("no-sheet");const m=[],O=[],T=Math.min(t.right,w.columnsUsed-1),p=Math.min(t.bottom,w.lastRow),P=(c,d)=>b.some(h=>v(h.area,c,d));for(let c=t.top;c<=p;c++)for(let d=t.left;d<=T;d++)if(!P(c,d)){if(w.at(c,d)!==void 0){const h=U(u,w,c,d);m.push({row:c+f,col:d+l,text:s===r?h:dt(h,e,o)})}O.push({from:{row:c,col:d},to:{row:c+f,col:d+l}})}const F=Z(u,e,t);if(F.refused!==void 0)return F;const M=S(u,F),j=[y,F];let z=M;if(b.length>0){const c=new E(M),d=M.workbook.sheet(e);if(!d)return x("no-sheet");for(const J of b){const B=d.tables.find(V=>V.name===J.name);if(!B)continue;const Q=c.table(d,B);Q.at=X({row:J.at.row+f,col:J.at.col+l})}const h=c.finish();j.push(h),z=S(M,h)}const C=ot(z,o,m);if(C.refused!==void 0)return C;j.push(C);const D=S(z,C),_=D.workbook.sheet(e),$=D.workbook.sheet(o);if(_&&$){const c=new E(D);copyLooks(c,w,$,O);const d=O.map(h=>h.from).filter(h=>!(s===r&&v(a,h.row,h.col))&&Object.keys(w.lookAt(h.row,h.col)).length>0);for(const h of N(d))R(c,_,h,NO_LOOK);j.push(c.finish())}return ht(j)}
2
+ import{MAX_COLUMNS as et,MAX_ROWS as nt,cellName as W,contains as U,overlaps as T,rangeName as st}from"./address.js";import{rectangles as X}from"./api/rectangles.js";import{Draft as z,applyLook as $,blankEdit as D,clearCells as G,dropKeys as rt,inputOf as B,movedTo as H,refused as M,writeCells as P,writeOne as it}from"./edit.js";import{relativeKey as ct}from"./formula/move.js";import{parseFormula as Q}from"./formula/parse.js";import{printFormula as lt}from"./formula/print.js";import{mapNode as ft}from"./formula/walk.js";import{restructure as V}from"./structure.js";import{seriesAfter as ut}from"./series.js";import{readTyped as pt}from"./values.js";import{workbookOf as dt}from"./workbook.js";const J=s=>pt(s).formula!==void 0;function wt(s,e,t){const o=Q(s);return o.ok?ct(o.node,e,t):void 0}const ht=(s,e)=>!s.tables.some(t=>T(t.area,e))&&!s.blocks.some(t=>T(t.area,e));function at(s,e,t,o){if(s.some(r=>J(r.text))){const r=s.length;return e.map((f,i)=>{const p=t?s[((r-1-i)%r+r)%r]:s[i%r],h=p?.text??"";return{...f,text:p?H(h,f.row-p.row,f.col-p.col):h}})}const n=ut(s.map(r=>r.text),e.length,{mode:o,back:t});return e.map((r,f)=>({...r,text:n[f]??""}))}const Y=["bold","italic","underline","strike","font","size","color","fill","align","valign","wrap","shrink","indent","rotation","border","locked","hide_formula","format"];export const NO_LOOK=Object.fromEntries(Y.map(s=>[s,void 0]));export function copyLooks(s,e,t,o){const c=new Map;for(const n of o){const r=e.lookAt(n.from.row,n.from.col),f=t.lookAt(n.to.row,n.to.col);if(JSON.stringify(r)===JSON.stringify(f))continue;const i=JSON.stringify(r),p=c.get(i);p?p.places.push(n.to):c.set(i,{look:r,places:[n.to]})}for(const{look:n,places:r}of c.values()){const f={};for(const i of Y)f[i]=n[i];for(const i of X(r))$(s,t,i,f)}}export function autoFill(s,e,t,o,c="auto"){const n=s.workbook.sheet(e);if(!n)return M("no-sheet");const r=o.bottom>t.bottom||o.top<t.top,f=o.top<t.top||o.left<t.left,i=new z(s),p=r?{first:t.left,last:t.right}:{first:t.top,last:t.bottom},h=new Map,y=(u,d)=>{const x=`${String(u)}:${String(d)}`;let v=h.get(x);return v===void 0&&(v=B(s,n,u,d),h.set(x,v)),v},L=(t.bottom-t.top+1)*(t.right-t.left+1),m=new Set;for(let u=t.top;u<=t.bottom;u++)for(let d=t.left;d<=t.right;d++){const x=y(u,d);J(x)&&m.add(wt(x,u,d)??"")}if(m.size===1&&L>0&&ht(n,o)&&bt(y,t)){const u=i.spec(n);return rt(u,o),u.cells={...u.cells,[st(o)]:H(y(t.top,t.left),o.top-t.top,o.left-t.left)},i.edit.whole=!0,Z(i,n,t,o,r),i.finish()}for(let u=p.first;u<=p.last;u++){const d=[];if(r)for(let w=t.top;w<=t.bottom;w++)d.push({row:w,col:u,text:y(w,u)});else for(let w=t.left;w<=t.right;w++)d.push({row:u,col:w,text:y(u,w)});const x=[],v=f?r?t.top-1:t.left-1:r?t.bottom+1:t.right+1,A=r?f?o.top:o.bottom:f?o.left:o.right,E=f?-1:1;for(let w=v;f?w>=A:w<=A;w+=E)x.push(r?{row:w,col:u}:{row:u,col:w});for(const w of at(d,x,f,c))it(i,s,n,w.row,w.col,w.text)}return Z(i,n,t,o,r),i.finish()}function bt(s,e){for(let t=e.top;t<=e.bottom;t++)for(let o=e.left;o<=e.right;o++)if(!J(s(t,o)))return!1;return!0}function Z(s,e,t,o,c){const n=[],r=t.bottom-t.top+1,f=t.right-t.left+1;for(let i=o.top;i<=o.bottom;i++)for(let p=o.left;p<=o.right;p++){if(U(t,i,p))continue;const h=c?t.top+((i-t.top)%r+r)%r:i,y=c?p:t.left+((p-t.left)%f+f)%f;n.push({from:{row:h,col:y},to:{row:i,col:p}})}copyLooks(s,e,e,n)}export function pasteLooks(s,e,t,o){const c=s.workbook.sheet(e),n=s.workbook.sheet(t);if(!c||!n)return M("no-sheet");const r=new z(s);return copyLooks(r,c,n,o),r.finish()}export function fillDownTo(s,e){const t=(o,c)=>c>=0&&s.at(o,c)!==void 0;for(const o of[e.left-1,e.right+1]){if(!t(e.bottom,o)&&!t(e.bottom+1,o))continue;let c=e.bottom;for(;t(c+1,o);)c+=1;if(c>e.bottom)return c}}function gt(s,e,t){if(!J(s))return s;const o=Q(s);if(!o.ok)return s;const c=ft(o.node,n=>n.kind!=="ref"?n:n.sheet===void 0?{...n,sheet:e}:n.sheet.toLowerCase()!==t.toLowerCase()||n.lastSheet!==void 0?n:Object.fromEntries(Object.entries(n).filter(([r])=>r!=="sheet")));return lt(c)}function N(s){const e=D();e.whole=!0;for(const t of s){t.file&&(e.file=t.file);for(const[o,c]of t.rows)e.rows.set(o,c)}return e}function _(s,e){const t=e.file??s.file,o=new Map(s.rows);for(const[c,n]of e.rows)o.set(c,n);return{file:t,rows:o,workbook:dt({file:t,rows:c=>o.get(c)})}}export function moveCells(s,e,t,o,c){const n=s.workbook.sheet(e),r=s.workbook.sheet(o);if(!n||!r)return M("no-sheet");const f=c.row-t.top,i=c.col-t.left;if(f===0&&i===0&&n===r)return D();const p={top:c.row,left:c.col,bottom:t.bottom+f,right:t.right+i},h=n.tables.filter(l=>U(t,l.area.top,l.area.left)&&U(t,l.area.bottom,l.area.right));for(const l of n.tables)if(!h.includes(l)&&T(l.area,t)&&t.top<=l.at.row)return M("table-move");if(h.length>0&&n!==r)return M("table-move");for(const l of r.tables)if(!h.includes(l)&&T(l.area,p)&&p.top<=l.at.row)return M("table-move");const y={op:"move-cells",sheet:e,area:t,rows:f,columns:i,...n===r?{}:{to:o}},L=V(s,y),m={...D(),file:L.file,rows:new Map(L.rows)},u=_(s,m),d=u.workbook.sheet(e),x=u.workbook.sheet(o);if(!d||!x)return M("no-sheet");const v=[],A=[],E=Math.min(t.right,d.columnsUsed-1),w=Math.min(t.bottom,d.lastRow),K=(l,b)=>h.some(g=>U(g.area,l,b));for(let l=t.top;l<=w;l++)for(let b=t.left;b<=E;b++)if(!K(l,b)){if(d.at(l,b)!==void 0){const g=B(u,d,l,b);v.push({row:l+f,col:b+i,text:n===r?g:gt(g,e,o)})}A.push({from:{row:l,col:b},to:{row:l+f,col:b+i}})}const S=G(u,e,t);if(S.refused!==void 0)return S;const C=_(u,S),j=[m,S];let R=C;if(h.length>0){const l=new z(C),b=C.workbook.sheet(e);if(!b)return M("no-sheet");for(const I of h){const q=b.tables.find(ot=>ot.name===I.name);if(!q)continue;const tt=l.table(b,q);tt.at=W({row:I.at.row+f,col:I.at.col+i})}const g=l.finish();j.push(g),R=_(C,g)}const F=P(R,o,v);if(F.refused!==void 0)return F;j.push(F);const a=_(R,F),O=a.workbook.sheet(e),k=a.workbook.sheet(o);if(O&&k){const l=new z(a);copyLooks(l,d,k,A);const b=A.map(g=>g.from).filter(g=>!(n===r&&U(p,g.row,g.col))&&Object.keys(d.lookAt(g.row,g.col)).length>0);for(const g of X(b))$(l,O,g,NO_LOOK);j.push(l.finish())}return N(j)}export function shiftCells(s,e,t,o){const c=s.workbook.sheet(e);if(!c)return M("no-sheet");const n=o==="down"||o==="up",r=o==="down"||o==="right",f=n?t.bottom-t.top+1:t.right-t.left+1,i=n?{...t,bottom:Math.max(t.bottom,c.lastRow)}:{...t,right:Math.max(t.right,c.columnsUsed-1)},p=n?{...t,bottom:nt-1}:{...t,right:et-1};if(c.tables.some(a=>T(a.area,p)))return M("table-shift");if(c.merges.some(a=>T(a,p)))return M("merge-shift");const h=V(s,{op:"shift-cells",sheet:e,rows:n,insert:r,at:n?t.top:t.left,count:f,first:n?t.left:t.top,last:n?t.right:t.bottom});if(h.refused!==void 0)return M(h.refused);const y={...D(),file:h.file,rows:new Map(h.rows)},L=_(s,y),m=L.workbook.sheet(e);if(!m)return M("no-sheet");const u=r?f:-f,d=r?i:n?{...i,top:t.bottom+1}:{...i,left:t.right+1},x=Math.min(i.bottom,m.lastRow),v=Math.min(i.right,m.columnsUsed-1),A=[],E=[],w=new Set;for(let a=d.top;a<=Math.min(d.bottom,x);a++)for(let O=d.left;O<=Math.min(d.right,v);O++){const k=n?{row:a+u,col:O}:{row:a,col:O+u};m.at(a,O)!==void 0&&A.push({...k,text:B(L,m,a,O)}),E.push({from:{row:a,col:O},to:k}),w.add(W(k))}const K=G(L,e,i);if(K.refused!==void 0)return K;const S=_(L,K),C=P(S,e,A);if(C.refused!==void 0)return C;const j=_(S,C),R=[y,K,C],F=j.workbook.sheet(e);if(F){const a=new z(j);copyLooks(a,m,F,E);const O=[];for(let k=i.top;k<=x;k++)for(let l=i.left;l<=v;l++)!w.has(W({row:k,col:l}))&&Object.keys(m.lookAt(k,l)).length>0&&O.push({row:k,col:l});for(const k of X(O))$(a,F,k,NO_LOOK);R.push(a.finish())}return N(R)}
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import"./address.js";import{compareForSort as C}from"./sort.js";import{shownValue as h}from"./format.js";import{choicesIn as x}from"./validate.js";const g=(o,e,r,t)=>h(e.value(o,r,t),o.lookAt(r,t).format),b=(o,e)=>{if(e==="")return o.blanks===!0;const r=e.toLowerCase();return o.values?.some(t=>t.toLowerCase()===r)===!0};function v(o,e,r,t){const s=o.validations.length===0?void 0:o.validationAt(e,r);return s?.spec.multiple===!0?x(t,s.spec):[t]}function k(o,e,r,t,s){for(const[n,u]of r.columns){if(n===s)continue;const f=g(o,e,t,n);if(f===""){if(u.blanks!==!0)return!1;continue}if(!v(o,t,n,f).some(a=>b(u,a)))return!1}return!0}export function filteredRows(o,e){const r=new Set;for(const t of o.filters){if(t.columns.size===0)continue;const{top:s,bottom:n}=t.area,u=Math.min(n,o.lastRow);for(let f=s+1;f<=u;f++)k(o,e,t,f)||r.add(f)}return r}export function filterChoices(o,e,r,t){const s=r.columns.get(t),n=new Map;let u=0;const{top:f,bottom:a}=r.area,i=Math.min(a,o.lastRow);for(let l=f+1;l<=i;l++){if(!k(o,e,r,l,t))continue;const c=g(o,e,l,t);if(c===""){u+=1;continue}const d=v(o,l,t,c);for(const m of d){const p=m.toLowerCase(),w=n.get(p);w?w.count+=1:n.set(p,{text:m,count:1,on:s===void 0||b(s,m),value:d.length>1?m:e.value(o,l,t)})}}return{values:[...n.values()].sort((l,c)=>C(l.value,c.value)),blanks:u===0?void 0:{count:u,on:s===void 0||s.blanks===!0}}}export function regionAround(o,e){const r=(n,u)=>n>=0&&u>=0&&(o.at(n,u)!==void 0||o.spillAt(n,u)!==void 0),t={top:e.row,left:e.col,bottom:e.row,right:e.col};for(let n=!0;n;){n=!1;const u=a=>{for(let i=t.left-1;i<=t.right+1;i++)if(r(a,i))return!0;return!1},f=a=>{for(let i=t.top-1;i<=t.bottom+1;i++)if(r(i,a))return!0;return!1};u(t.top-1)&&(t.top-=1,n=!0),u(t.bottom+1)&&(t.bottom+=1,n=!0),f(t.left-1)&&(t.left-=1,n=!0),f(t.right+1)&&(t.right+=1,n=!0)}return t.top===t.bottom&&t.left===t.right&&!r(t.top,t.left)?void 0:t}
2
+ import"./address.js";import{hasWildcard as q,wildcard as M}from"./calc/functions/criteria.js";import{compareForSort as T}from"./sort.js";import{shownValue as L}from"./format.js";import{choicesIn as E}from"./validate.js";const g=(e,n,o,t)=>L(n.value(e,o,t),e.lookAt(o,t).format),v=(e,n)=>{if(n==="")return e.blanks===!0;const o=n.toLowerCase();return e.values?.some(t=>t.toLowerCase()===o)===!0},h=e=>e.values!==void 0||e.blanks!==void 0,O=(e,n)=>!h(e)||v(e,n);function C(e,n,o,t){const r=e.validations.length===0?void 0:e.validationAt(n,o);return r?.spec.multiple===!0?E(t,r.spec):[t]}function A(e,n,o){const{operator:t}=e,r=e.value;if(typeof r=="number"&&typeof n=="number")switch(t){case"equal":return n===r;case"notEqual":return n!==r;case"greaterThan":return n>r;case"greaterThanOrEqual":return n>=r;case"lessThan":return n<r;case"lessThanOrEqual":return n<=r}const a=String(r);if(t==="equal"||t==="notEqual"){const m=q(a)?M(a)(o):o.toLowerCase()===a.toLowerCase();return t==="equal"?m:!m}if(o==="")return!1;const i=o.toLowerCase().localeCompare(a.toLowerCase());switch(t){case"greaterThan":return i>0;case"greaterThanOrEqual":return i>=0;case"lessThan":return i<0;case"lessThanOrEqual":return i<=0}}function R(e,n,o,t,r){const{top:a}=o.area,i=Math.min(o.area.bottom,e.lastRow),m=()=>{const s=[];for(let u=a+1;u<=i;u++){const d=n.value(e,u,t);typeof d=="number"&&s.push(d)}return s};if(r.values!==void 0||r.blanks!==void 0)return s=>{const u=g(e,n,s,t);return u===""?r.blanks===!0:C(e,s,t,u).some(d=>v(r,d))};const p=r.conditions;if(p)return s=>{const u=n.value(e,s,t),d=g(e,n,s,t),c=p.map(f=>A(f,u,d));return r.or===!0?c.some(Boolean):c.every(Boolean)};const l=r.top;if(l){const s=m().sort((c,f)=>l.bottom===!0?c-f:f-c),u=l.percent===!0?Math.max(1,Math.floor(s.length*l.count/100)):Math.round(l.count),d=s[Math.min(u,s.length)-1];return c=>{const f=n.value(e,c,t);return typeof f!="number"||d===void 0?!1:l.bottom===!0?f<=d:f>=d}}if(r.average){const s=m(),u=s.reduce((c,f)=>c+f,0)/Math.max(1,s.length),d=r.average==="above";return c=>{const f=n.value(e,c,t);return typeof f=="number"&&(d?f>u:f<u)}}const b=r.color;return b?s=>{const u=e.lookAt(s,t);return b.fill!==void 0?typeof u.fill=="string"&&u.fill.toUpperCase()===b.fill.toUpperCase():b.font!==void 0?(u.color??"#000000").toUpperCase()===b.font.toUpperCase():!0}:()=>!0}function k(e,n,o,t){return[...o.columns].filter(([r])=>r!==t).map(([r,a])=>R(e,n,o,r,a))}const y=(e,n)=>e.every(o=>o(n));export function filteredRows(e,n){const o=new Set;for(const t of e.filters){if(t.columns.size===0)continue;const{top:r,bottom:a}=t.area,i=Math.min(a,e.lastRow),m=k(e,n,t);for(let p=r+1;p<=i;p++)y(m,p)||o.add(p)}return o}export function filterChoices(e,n,o,t){const r=o.columns.get(t),a=new Map;let i=0;const{top:m,bottom:p}=o.area,l=Math.min(p,e.lastRow),b=k(e,n,o,t);for(let s=m+1;s<=l;s++){if(!y(b,s))continue;const u=g(e,n,s,t);if(u===""){i+=1;continue}const d=C(e,s,t,u);for(const c of d){const f=c.toLowerCase(),w=a.get(f);w?w.count+=1:a.set(f,{text:c,count:1,on:r===void 0||O(r,c),value:d.length>1?c:n.value(e,s,t)})}}return{values:[...a.values()].sort((s,u)=>T(s.value,u.value)),blanks:i===0?void 0:{count:i,on:r===void 0||r.blanks===!0||!h(r)}}}export function regionAround(e,n){const o=(a,i)=>a>=0&&i>=0&&(e.at(a,i)!==void 0||e.spillAt(a,i)!==void 0),t={top:n.row,left:n.col,bottom:n.row,right:n.col};for(let a=!0;a;){a=!1;const i=p=>{for(let l=t.left-1;l<=t.right+1;l++)if(o(p,l))return!0;return!1},m=p=>{for(let l=t.top-1;l<=t.bottom+1;l++)if(o(l,p))return!0;return!1};i(t.top-1)&&(t.top-=1,a=!0),i(t.bottom+1)&&(t.bottom+=1,a=!0),m(t.left-1)&&(t.left-=1,a=!0),m(t.right+1)&&(t.right+=1,a=!0)}return t.top===t.bottom&&t.left===t.right&&!o(t.top,t.left)?void 0:t}
@@ -47,6 +47,20 @@ export type StructureEdit = {
47
47
  op: "delete-column";
48
48
  table: string;
49
49
  name: string;
50
+ } | {
51
+ /**
52
+ * Excel's Insert Cells and Delete Cells: rows (or columns) put in or
53
+ * taken out at `at` across `first`…`last` alone, the cells past them
54
+ * shifted down or up (right or left).
55
+ */
56
+ op: "shift-cells";
57
+ sheet: string;
58
+ rows: boolean;
59
+ insert: boolean;
60
+ at: number;
61
+ count: number;
62
+ first: number;
63
+ last: number;
50
64
  } | {
51
65
  op: "move-cells";
52
66
  sheet: string;
@@ -1,2 +1,2 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{MAX_COLUMNS as b,MAX_ROWS as M}from"../address.js";import{mapNode as S}from"./walk.js";const u=(r,n)=>r?.toLowerCase()===n?.toLowerCase(),k=(r,n,s)=>r.index>=n?{...r,index:r.index+s}:r;function O(r,n,s){if(r.index<n)return r;if(r.index>=n+s)return{...r,index:r.index-s}}function R(r,n,s,i){const o=r.index<=n.index?r:n,e=o===r?n:r,t=k(o,s,i),c=e.index>=s?{...e,index:e.index+i}:e;return o===r?[t,c]:[c,t]}function C(r,n,s,i){const o=r.index<=n.index?r:n,e=o===r?n:r,t=s+i-1;if(o.index>=s&&e.index<=t)return;const c=o.index<s?o:o.index>t?{...o,index:o.index-i}:{...o,index:s},a=e.index<s?e:e.index>t?{...e,index:e.index-i}:{...e,index:s-1};return o===r?[c,a]:[a,c]}function x(r){return{kind:"error",code:"#REF!",...r.sheet===void 0?{}:{sheet:r.sheet}}}const h={kind:"error",code:"#REF!"};function E(r,n,s){if(!u(r.sheet??s,n.sheet)||r.lastSheet!==void 0)return r;const{col:i,row:o}=r;if(i===void 0||o===void 0)return r;const e=r.col2??i,t=r.row2??o,{area:c,rows:a,columns:d,to:m}=n;if(!(Math.min(i.index,e.index)>=c.left&&Math.max(i.index,e.index)<=c.right&&Math.min(o.index,t.index)>=c.top&&Math.max(o.index,t.index)<=c.bottom))return r;const f=(l,p)=>({...l,index:l.index+p}),w={...r,col:f(i,d),row:f(o,a),...r.col2?{col2:f(r.col2,d)}:{},...r.row2?{row2:f(r.row2,a)}:{}};return m===void 0?w:u(m,s)?Object.fromEntries(Object.entries(w).filter(([l])=>l!=="sheet")):{...w,sheet:m}}function g(r,n,s){if(!u(r.sheet??s,n.sheet)||r.lastSheet!==void 0)return r;const i=n.op==="insert-rows"||n.op==="delete-rows",o=i?r.row:r.col,e=i?r.row2:r.col2;if(o===void 0)return r;const t=i?["row","row2"]:["col","col2"],c=n.op==="insert-rows"||n.op==="insert-columns",a=i?M:b;if(e===void 0){const m=c?k(o,n.at,n.count):O(o,n.at,n.count);return!m||m.index>=a?x(r):m===o?r:{...r,[t[0]]:m}}const d=c?R(o,e,n.at,n.count):C(o,e,n.at,n.count);return!d||d[0].index>=a||d[1].index>=a?x(r):d[0]===o&&d[1]===e?r:{...r,[t[0]]:d[0],[t[1]]:d[1]}}export function rewriteFormula(r,n,s,i){const o=(e,t)=>e===void 0?i===void 0||u(i,t):u(e,t);return S(r,e=>{switch(n.op){case"rename-sheet":return(e.kind==="ref"||e.kind==="name"||e.kind==="error")&&u(e.sheet,n.from)?{...e,sheet:n.to}:e.kind==="ref"&&u(e.lastSheet,n.from)?{...e,lastSheet:n.to}:e;case"rename-table":return e.kind==="structured"&&u(e.table,n.from)?{...e,table:n.to}:e;case"delete-sheet":return e.kind==="ref"&&u(e.sheet,n.name)||e.kind==="ref"&&u(e.lastSheet,n.name)?x(e):e.kind==="name"&&u(e.sheet,n.name)?h:e;case"delete-table":return e.kind==="structured"&&u(e.table,n.name)||e.kind==="name"&&u(e.name,n.name)?h:e;case"delete-column":return e.kind==="structured"&&o(e.table,n.table)&&e.columns.some(t=>u(t,n.name))?h:e;case"rename-column":return e.kind==="structured"&&o(e.table,n.table)&&e.columns.some(t=>u(t,n.from))?{...e,columns:e.columns.map(t=>u(t,n.from)?n.to:t)}:e;case"rename-name":return e.kind==="name"&&u(e.name,n.from)?{...e,name:n.to}:e.kind==="call"&&u(e.name,n.from)?{...e,name:n.to.toUpperCase(),written:n.to}:e;case"move-cells":return e.kind==="ref"?E(e,n,s):e;default:return e.kind==="ref"?g(e,n,s):e}})}
2
+ import{MAX_COLUMNS as M,MAX_ROWS as S}from"../address.js";import{mapNode as O}from"./walk.js";const c=(n,r)=>n?.toLowerCase()===r?.toLowerCase(),k=(n,r,t)=>n.index>=r?{...n,index:n.index+t}:n;function R(n,r,t){if(n.index<r)return n;if(n.index>=r+t)return{...n,index:n.index-t}}function C(n,r,t,s){const o=n.index<=r.index?n:r,e=o===n?r:n,u=k(o,t,s),i=e.index>=t?{...e,index:e.index+s}:e;return o===n?[u,i]:[i,u]}function E(n,r,t,s){const o=n.index<=r.index?n:r,e=o===n?r:n,u=t+s-1;if(o.index>=t&&e.index<=u)return;const i=o.index<t?o:o.index>u?{...o,index:o.index-s}:{...o,index:t},a=e.index<t?e:e.index>u?{...e,index:e.index-s}:{...e,index:t-1};return o===n?[i,a]:[a,i]}function x(n){return{kind:"error",code:"#REF!",...n.sheet===void 0?{}:{sheet:n.sheet}}}const h={kind:"error",code:"#REF!"};function g(n,r,t){if(!c(n.sheet??t,r.sheet)||n.lastSheet!==void 0)return n;const{col:s,row:o}=n;if(s===void 0||o===void 0)return n;const e=n.col2??s,u=n.row2??o,{area:i,rows:a,columns:d,to:f}=r;if(!(Math.min(s.index,e.index)>=i.left&&Math.max(s.index,e.index)<=i.right&&Math.min(o.index,u.index)>=i.top&&Math.max(o.index,u.index)<=i.bottom))return n;const l=(m,b)=>({...m,index:m.index+b}),w={...n,col:l(s,d),row:l(o,a),...n.col2?{col2:l(n.col2,d)}:{},...n.row2?{row2:l(n.row2,a)}:{}};return f===void 0?w:c(f,t)?Object.fromEntries(Object.entries(w).filter(([m])=>m!=="sheet")):{...w,sheet:f}}function p(n,r,t){if(!c(n.sheet??t,r.sheet)||n.lastSheet!==void 0)return n;const s=r.op==="insert-rows"||r.op==="delete-rows",o=s?n.row:n.col,e=s?n.row2:n.col2;if(o===void 0)return n;const u=s?["row","row2"]:["col","col2"],i=r.op==="insert-rows"||r.op==="insert-columns",a=s?S:M;if(e===void 0){const f=i?k(o,r.at,r.count):R(o,r.at,r.count);return!f||f.index>=a?x(n):f===o?n:{...n,[u[0]]:f}}const d=i?C(o,e,r.at,r.count):E(o,e,r.at,r.count);return!d||d[0].index>=a||d[1].index>=a?x(n):d[0]===o&&d[1]===e?n:{...n,[u[0]]:d[0],[u[1]]:d[1]}}function F(n,r,t){const s=r.rows?n.col:n.row,o=(r.rows?n.col2:n.row2)??s;if(s===void 0||o===void 0||Math.min(s.index,o.index)<r.first||Math.max(s.index,o.index)>r.last)return n;const e=r.rows?r.insert?"insert-rows":"delete-rows":r.insert?"insert-columns":"delete-columns";return p(n,{op:e,sheet:r.sheet,at:r.at,count:r.count},t)}export function rewriteFormula(n,r,t,s){const o=(e,u)=>e===void 0?s===void 0||c(s,u):c(e,u);return O(n,e=>{switch(r.op){case"rename-sheet":return(e.kind==="ref"||e.kind==="name"||e.kind==="error")&&c(e.sheet,r.from)?{...e,sheet:r.to}:e.kind==="ref"&&c(e.lastSheet,r.from)?{...e,lastSheet:r.to}:e;case"rename-table":return e.kind==="structured"&&c(e.table,r.from)?{...e,table:r.to}:e;case"delete-sheet":return e.kind==="ref"&&c(e.sheet,r.name)||e.kind==="ref"&&c(e.lastSheet,r.name)?x(e):e.kind==="name"&&c(e.sheet,r.name)?h:e;case"delete-table":return e.kind==="structured"&&c(e.table,r.name)||e.kind==="name"&&c(e.name,r.name)?h:e;case"delete-column":return e.kind==="structured"&&o(e.table,r.table)&&e.columns.some(u=>c(u,r.name))?h:e;case"rename-column":return e.kind==="structured"&&o(e.table,r.table)&&e.columns.some(u=>c(u,r.from))?{...e,columns:e.columns.map(u=>c(u,r.from)?r.to:u)}:e;case"rename-name":return e.kind==="name"&&c(e.name,r.from)?{...e,name:r.to}:e.kind==="call"&&c(e.name,r.from)?{...e,name:r.to.toUpperCase(),written:r.to}:e;case"move-cells":return e.kind==="ref"?g(e,r,t):e;case"shift-cells":return e.kind==="ref"?F(e,r,t):e;default:return e.kind==="ref"?p(e,r,t):e}})}
@@ -1,6 +1,6 @@
1
1
  /*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
2
- import{formatColor as O,isValidFormat as P}from"numfmt";import{cellName as T,columnLetter as _}from"./address.js";import{chartDef as U,chartPlace as k,chartSize as q,chartSvg as V}from"./chart.js";import{fileCells as K,isPicture as Y,pictureHeight as X,pictureSize as Z}from"./files.js";import{generalForms as J,shownValue as Q}from"./format.js";import{DEFAULT_COLUMN_WIDTH as tt,DEFAULT_ROW_HEIGHT as D,columnHidden as N,columnWidth as M,pageTitleCols as et,pageTitleRows as nt,rowHeight as st,rowHidden as H,paginate as it,usedWithCharts as ot}from"./paginate.js";import{Rules as rt,iconShape as lt}from"./rules.js";import{tableStyleLook as at,tableStyleOf as dt}from"./table-style.js";import{CellError as ct}from"./values.js";import{placeKey as I}from"./workbook.js";export{tt as DEFAULT_COLUMN_WIDTH,D as DEFAULT_ROW_HEIGHT};const ht={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},ft=o=>{let t="";for(let e=0;e<o.length;e+=32768)t+=String.fromCharCode(...o.subarray(e,e+32768));return btoa(t)},v=o=>o.replace(/[&<>"]/gu,t=>ht[t]??t),gt={thin:"1px solid",medium:"2px solid",thick:"3px solid",double:"3px double",hair:"1px dotted",dotted:"1px dotted",dashed:"1px dashed",dashDot:"1px dashed",dashDotDot:"1px dashed",mediumDashed:"2px dashed",mediumDashDot:"2px dashed",mediumDashDotDot:"2px dashed",slantDashDot:"2px dashed"},pt={left:"left",center:"center",right:"right",justify:"justify",distributed:"justify",centerContinuous:"center",fill:"left"},ut={top:"top",center:"middle",justify:"middle",distributed:"middle"};function mt(o){if(typeof o=="number")return"right";if(typeof o=="boolean"||o instanceof ct)return"center"}const $t={up:"▲","up-right":"◥",right:"▶","down-right":"◢",down:"▼",circle:"●",flag:"⚑",check:"✔",bang:"!",cross:"✖",triangle:"▲",diamond:"◆",bars:"▮",quarter:"◔"};function wt(o){const{shape:t,color:e,level:i}=lt(o.set,o.index),l=($t[t]??"●").repeat(t==="bars"?i??1:1);return`<span style="float:left;color:${e}">${l}</span>`}function bt(o,t,e){const i=[];o.bold===!0&&i.push("font-weight:bold"),o.italic===!0&&i.push("font-style:italic");const l=[o.underline?"underline":"",o.strike===!0?"line-through":""].filter(Boolean);l.length>0&&i.push(`text-decoration:${l.join(" ")}`),o.font!==void 0&&i.push(`font-family:"${o.font.replace(/["\\]/gu,"")}",var(--font)`),o.size!==void 0&&i.push(`font-size:${String(o.size)}pt`);const r=(typeof t=="number"&&e!==void 0&&P(e)?O(e,t)??void 0:void 0)??o.color;typeof r=="string"&&i.push(`color:${r}`);const{fill:d}=o;if(typeof d=="string")i.push(`background:${d}`);else if(d){const s=d.color??d.background;s!==void 0&&i.push(`background:${s}`)}const f=(o.align===void 0||o.align==="general"?void 0:pt[o.align])??mt(t);f!==void 0&&i.push(`text-align:${f}`);const c=o.valign===void 0?void 0:ut[o.valign];c!==void 0&&i.push(`vertical-align:${c}`),o.wrap===!0&&i.push("white-space:pre-wrap","overflow-wrap:anywhere"),o.indent!==void 0&&i.push(`padding-left:${String(3+o.indent*9)}px`);for(const s of["left","right","top","bottom"]){const n=o.border?.[s];n&&n.style!=="none"&&i.push(`border-${s}:${gt[n.style]??"1px solid"} ${n.color??"#000"}`)}return i.join(";")}class L{names=new Map;of(t){if(t==="")return"";let e=this.names.get(t);return e||(e=`s${String(this.names.size)}`,this.names.set(t,e)),e}css(){return[...this.names].map(([t,e])=>`.${e}{${t}}`).join(`
3
- `)}}class W{calc;sheet;rules;read;drawnFiles;bands=new Map;svgs=new Map;constructor(t,e,i){this.calc=t,this.sheet=e,this.read=i,this.rules=e.conditions.length>0?new rt(e,t):void 0}files(){if(this.drawnFiles)return this.drawnFiles;const t=new Map,e=new Map,i=this.read;for(const{row:l,col:r,paths:d,column:f}of i?K(this.sheet,this.calc):[]){const c=X(f),s=d.map(n=>{const a=Y(n)?i?.(n):void 0,h=a&&Z(a);return!a||!h?v(n):(e.set(l,Math.max(e.get(l)??0,c)),`<img src="data:image/${h.type};base64,${ft(a)}" alt="${v(n)}" style="height:${String(c)}px">`)});t.set(I(l,r),s.join(" "))}return this.drawnFiles={cells:t,rows:e},this.drawnFiles}height(t){return this.sheet.spec.rows?.[String(t+1)]?.height??this.files().rows.get(t)??D}band(t,e){if(e===t.at.row)return;let i=this.bands.get(t);if(!i){i=new Map;let l=0;for(let r=t.at.row+1;r<=t.area.bottom;r++)H(this.calc,this.sheet,r)||i.set(r,l++);this.bands.set(t,i)}return i.get(e)??0}cell(t,e,i,l,r){const{sheet:d}=this,f=this.calc.value(d,t,e),c=this.rules?.at(t,e),s=d.lookAt(t,e),n=d.tableAt(t,e),a=n&&dt(n),h=n&&a?at(a,n,t,e,this.band(n,t)):void 0,g={...h,...s,...c?.look,...c?.scale===void 0?{}:{fill:c.scale}};(h?.border||s.border)&&(g.border={...h?.border,...s.border,...c?.look?.border});const w=g.format;let m=bt(g,f,w);if(c?.bar){const C=`${String(Math.round(c.bar.share*100))}%`;m=[m,`background:linear-gradient(90deg,${c.bar.color} ${C},transparent ${C})`].filter(Boolean).join(";")}const p=this.files().cells.get(I(t,e)),y=c?.icon?wt(c.icon):"",x=p??(c?.bare===!0?"":v(Q(f,w))),b=typeof f=="string"&&g.wrap!==!0&&l&&!i,S=typeof f=="number"&&!p&&y===""&&x!=="",F=S&&(w===void 0||w==="General"),j=[r.of(m),b?"over":"",S?"n":""].filter(Boolean).join(" ");return`<td${[j===""?"":` class="${j}"`,F?` data-g="${v(J(f).slice(1).join(" "))}"`:"",i&&i.rows>1?` rowspan="${String(i.rows)}"`:"",i&&i.cols>1?` colspan="${String(i.cols)}"`:""].join("")}>${y}${x}</td>`}spans(t,e){const i=new Map,l=new Set;for(const r of this.sheet.merges){const d=t.filter(n=>n>=r.top&&n<=r.bottom),f=e.filter(n=>n>=r.left&&n<=r.right),[c]=d,[s]=f;if(!(c===void 0||s===void 0)){for(const n of d)for(const a of f)l.add(`${String(n)}:${String(a)}`);l.delete(`${String(c)}:${String(s)}`),i.set(`${String(c)}:${String(s)}`,{rows:d.length,cols:f.length})}}return{spans:i,covered:l}}table(t,e,i,l){const{sheet:r}=this,{spans:d,covered:f}=this.spans(t,e),c=e.map(h=>M(r,h)),s=l.headings?B:0,n=c.reduce((h,g)=>h+g,0)+s,a=[`<table class="${l.className??""}" style="width:${String(n)}px"><colgroup>`,l.headings?`<col style="width:${String(s)}px">`:"",...c.map(h=>`<col style="width:${String(h)}px">`),"</colgroup>"];l.headings&&a.push(`<thead><tr><th></th>${e.map(h=>`<th>${_(h)}</th>`).join("")}</tr></thead>`),a.push("<tbody>");for(const h of t)a.push(`<tr style="height:${String(this.height(h))}px">`),l.headings&&a.push(`<th>${String(h+1)}</th>`),e.forEach((g,w)=>{const m=`${String(h)}:${String(g)}`;if(f.has(m))return;const p=e[w+1],y=p!==void 0&&r.at(h,p)===void 0&&!f.has(`${String(h)}:${String(p)}`);a.push(this.cell(h,g,d.get(m),y,i))}),a.push("</tr>");return a.push("</tbody></table>"),{html:a.join(""),width:n}}svg(t){let e=this.svgs.get(t);if(e===void 0){const{width:i,height:l}=q(t.spec);e=V(U(this.calc,this.sheet,t),i,l,{font:"var(--font)"}),this.svgs.set(t,e)}return e}charts(t,e,i){const{sheet:l}=this;if(l.charts.length===0||t.length===0||e.length===0)return"";const r=(s,n)=>{const a=new Map;let h=0;for(const g of s)a.set(g,h),h+=n(g);return{at:a,sum:h}},d=r(t,s=>this.height(s)),f=r(e,s=>M(l,s)),c=(s,n,a,h)=>{const g=s[0]??0;if(a<g){let m=0;for(let p=a;p<g;p++)m-=h(p);return m}const w=s.find(m=>m>=a);return w===void 0?1/0:n.get(w)??0};return l.charts.map(s=>{const n=k(s.spec,h=>c(t,d.at,h,g=>H(this.calc,l,g)?0:st(l,g)),h=>c(e,f.at,h,g=>N(l,g)?0:M(l,g)));return n.left<f.sum&&n.left+n.width>0&&n.top<d.sum&&n.top+n.height>0?`<div class="chart" style="left:${String(i.left+n.left)}px;top:${String(i.top+n.top)}px">${this.svg(s)}</div>`:""}).join("")}}const B=44,yt=`
2
+ import{formatColor as O,isValidFormat as P}from"numfmt";import{cellName as T,columnLetter as k}from"./address.js";import{linkAt as _}from"./annotations.js";import{chartDef as U,chartPlace as q,chartSize as V,chartSvg as K}from"./chart.js";import{fileCells as Y,isPicture as X,pictureHeight as Z,pictureSize as J}from"./files.js";import{generalForms as Q,shownValue as tt}from"./format.js";import{DEFAULT_COLUMN_WIDTH as et,DEFAULT_ROW_HEIGHT as F,columnHidden as N,columnWidth as R,pageTitleCols as nt,pageTitleRows as st,rowHeight as it,rowHidden as E,paginate as ot,usedWithCharts as rt}from"./paginate.js";import{Rules as lt,iconShape as at}from"./rules.js";import{tableStyleLook as dt,tableStyleOf as ct}from"./table-style.js";import{CellError as ht}from"./values.js";import{placeKey as I}from"./workbook.js";export{et as DEFAULT_COLUMN_WIDTH,F as DEFAULT_ROW_HEIGHT};const ft={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"},pt=n=>{let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t)},x=n=>n.replace(/[&<>"]/gu,t=>ft[t]??t),gt={thin:"1px solid",medium:"2px solid",thick:"3px solid",double:"3px double",hair:"1px dotted",dotted:"1px dotted",dashed:"1px dashed",dashDot:"1px dashed",dashDotDot:"1px dashed",mediumDashed:"2px dashed",mediumDashDot:"2px dashed",mediumDashDotDot:"2px dashed",slantDashDot:"2px dashed"},ut={left:"left",center:"center",right:"right",justify:"justify",distributed:"justify",centerContinuous:"center",fill:"left"},mt={top:"top",center:"middle",justify:"middle",distributed:"middle"};function $t(n){if(typeof n=="number")return"right";if(typeof n=="boolean"||n instanceof ht)return"center"}const bt={up:"▲","up-right":"◥",right:"▶","down-right":"◢",down:"▼",circle:"●",flag:"⚑",check:"✔",bang:"!",cross:"✖",triangle:"▲",diamond:"◆",bars:"▮",quarter:"◔"};function wt(n){const{shape:t,color:e,level:o}=at(n.set,n.index),l=(bt[t]??"●").repeat(t==="bars"?o??1:1);return`<span style="float:left;color:${e}">${l}</span>`}function yt(n){const t=[];if(n.bold!==void 0&&t.push(`font-weight:${n.bold?"bold":"normal"}`),n.italic!==void 0&&t.push(`font-style:${n.italic?"italic":"normal"}`),n.underline!==void 0||n.strike!==void 0){const l=[n.underline!==void 0&&n.underline!==!1?"underline":"",n.strike===!0?"line-through":""].filter(Boolean);t.push(`text-decoration:${l.length>0?l.join(" "):"none"}`)}n.font!==void 0&&t.push(`font-family:"${n.font.replace(/["\\]/gu,"")}",var(--font)`),n.size!==void 0&&t.push(`font-size:${String(n.size)}pt`),n.color!==void 0&&t.push(`color:${n.color}`);const e=x(n.text),o=n.script==="superscript"?`<sup>${e}</sup>`:n.script==="subscript"?`<sub>${e}</sub>`:e;return t.length===0&&n.script===void 0?e:`<span${t.length===0?"":` style="${t.join(";")}"`}>${o}</span>`}function xt(n,t,e){const o=[];n.bold===!0&&o.push("font-weight:bold"),n.italic===!0&&o.push("font-style:italic");const l=[n.underline?"underline":"",n.strike===!0?"line-through":""].filter(Boolean);l.length>0&&o.push(`text-decoration:${l.join(" ")}`),n.font!==void 0&&o.push(`font-family:"${n.font.replace(/["\\]/gu,"")}",var(--font)`),n.size!==void 0&&o.push(`font-size:${String(n.size)}pt`);const r=(typeof t=="number"&&e!==void 0&&P(e)?O(e,t)??void 0:void 0)??n.color;typeof r=="string"&&o.push(`color:${r}`);const{fill:a}=n;if(typeof a=="string")o.push(`background:${a}`);else if(a){const i=a.color??a.background;i!==void 0&&o.push(`background:${i}`)}const f=(n.align===void 0||n.align==="general"?void 0:ut[n.align])??$t(t);f!==void 0&&o.push(`text-align:${f}`);const c=n.valign===void 0?void 0:mt[n.valign];c!==void 0&&o.push(`vertical-align:${c}`),n.wrap===!0&&o.push("white-space:pre-wrap","overflow-wrap:anywhere"),n.indent!==void 0&&o.push(`padding-left:${String(3+n.indent*9)}px`);for(const i of["left","right","top","bottom"]){const s=n.border?.[i];s&&s.style!=="none"&&o.push(`border-${i}:${gt[s.style]??"1px solid"} ${s.color??"#000"}`)}return o.join(";")}class L{names=new Map;of(t){if(t==="")return"";let e=this.names.get(t);return e||(e=`s${String(this.names.size)}`,this.names.set(t,e)),e}css(){return[...this.names].map(([t,e])=>`.${e}{${t}}`).join(`
3
+ `)}}class W{calc;sheet;rules;read;drawnFiles;bands=new Map;svgs=new Map;constructor(t,e,o){this.calc=t,this.sheet=e,this.read=o,this.rules=e.conditions.length>0?new lt(e,t):void 0}files(){if(this.drawnFiles)return this.drawnFiles;const t=new Map,e=new Map,o=this.read;for(const{row:l,col:r,paths:a,column:f}of o?Y(this.sheet,this.calc):[]){const c=Z(f),i=a.map(s=>{const d=X(s)?o?.(s):void 0,h=d&&J(d);return!d||!h?x(s):(e.set(l,Math.max(e.get(l)??0,c)),`<img src="data:image/${h.type};base64,${pt(d)}" alt="${x(s)}" style="height:${String(c)}px">`)});t.set(I(l,r),i.join(" "))}return this.drawnFiles={cells:t,rows:e},this.drawnFiles}height(t){return this.sheet.spec.rows?.[String(t+1)]?.height??this.files().rows.get(t)??F}band(t,e){if(e===t.at.row)return;let o=this.bands.get(t);if(!o){o=new Map;let l=0;for(let r=t.at.row+1;r<=t.area.bottom;r++)E(this.calc,this.sheet,r)||o.set(r,l++);this.bands.set(t,o)}return o.get(e)??0}cell(t,e,o,l,r){const{sheet:a}=this,f=this.calc.value(a,t,e),c=this.rules?.at(t,e),i=a.lookAt(t,e),s=a.tableAt(t,e),d=s&&ct(s),h=s&&d?dt(d,s,t,e,this.band(s,t)):void 0,p={...h,...i,...c?.look,...c?.scale===void 0?{}:{fill:c.scale}};(h?.border||i.border)&&(p.border={...h?.border,...i.border,...c?.look?.border});const w=p.format;let $=xt(p,f,w);if(c?.bar){const v=`${String(Math.round(c.bar.share*100))}%`;$=[$,`background:linear-gradient(90deg,${c.bar.color} ${v},transparent ${v})`].filter(Boolean).join(";")}const u=this.files().cells.get(I(t,e)),y=c?.icon?wt(c.icon):"",S=typeof f=="string"?a.runsAt(t,e):void 0,b=u??(c?.bare===!0?"":S?S.map(yt).join(""):x(tt(f,w))),C=typeof f=="string"&&p.wrap!==!0&&l&&!o,A=typeof f=="number"&&!u&&y===""&&b!=="",M=A&&(w===void 0||w==="General"),z=[r.of($),C?"over":"",A?"n":""].filter(Boolean).join(" "),D=[z===""?"":` class="${z}"`,M?` data-g="${x(Q(f).slice(1).join(" "))}"`:"",o&&o.rows>1?` rowspan="${String(o.rows)}"`:"",o&&o.cols>1?` colspan="${String(o.cols)}"`:""].join(""),j=A?void 0:_(a.spec,t,e)?.to,g=j!==void 0&&/^(?:https?:|mailto:)/iu.test(j)&&b!==""?`<a href="${x(j)}" style="color:inherit;text-decoration:inherit">${b}</a>`:b;return`<td${D}>${y}${g}</td>`}spans(t,e){const o=new Map,l=new Set;for(const r of this.sheet.merges){const a=t.filter(s=>s>=r.top&&s<=r.bottom),f=e.filter(s=>s>=r.left&&s<=r.right),[c]=a,[i]=f;if(!(c===void 0||i===void 0)){for(const s of a)for(const d of f)l.add(`${String(s)}:${String(d)}`);l.delete(`${String(c)}:${String(i)}`),o.set(`${String(c)}:${String(i)}`,{rows:a.length,cols:f.length})}}return{spans:o,covered:l}}table(t,e,o,l){const{sheet:r}=this,{spans:a,covered:f}=this.spans(t,e),c=e.map(h=>R(r,h)),i=l.headings?B:0,s=c.reduce((h,p)=>h+p,0)+i,d=[`<table class="${l.className??""}" style="width:${String(s)}px"><colgroup>`,l.headings?`<col style="width:${String(i)}px">`:"",...c.map(h=>`<col style="width:${String(h)}px">`),"</colgroup>"];l.headings&&d.push(`<thead><tr><th></th>${e.map(h=>`<th>${k(h)}</th>`).join("")}</tr></thead>`),d.push("<tbody>");for(const h of t)d.push(`<tr style="height:${String(this.height(h))}px">`),l.headings&&d.push(`<th>${String(h+1)}</th>`),e.forEach((p,w)=>{const $=`${String(h)}:${String(p)}`;if(f.has($))return;const u=e[w+1],y=u!==void 0&&r.at(h,u)===void 0&&!f.has(`${String(h)}:${String(u)}`);d.push(this.cell(h,p,a.get($),y,o))}),d.push("</tr>");return d.push("</tbody></table>"),{html:d.join(""),width:s}}svg(t){let e=this.svgs.get(t);if(e===void 0){const{width:o,height:l}=V(t.spec);e=K(U(this.calc,this.sheet,t),o,l,{font:"var(--font)"}),this.svgs.set(t,e)}return e}charts(t,e,o){const{sheet:l}=this;if(l.charts.length===0||t.length===0||e.length===0)return"";const r=(i,s)=>{const d=new Map;let h=0;for(const p of i)d.set(p,h),h+=s(p);return{at:d,sum:h}},a=r(t,i=>this.height(i)),f=r(e,i=>R(l,i)),c=(i,s,d,h)=>{const p=i[0]??0;if(d<p){let $=0;for(let u=d;u<p;u++)$-=h(u);return $}const w=i.find($=>$>=d);return w===void 0?1/0:s.get(w)??0};return l.charts.map(i=>{const s=q(i.spec,h=>c(t,a.at,h,p=>E(this.calc,l,p)?0:it(l,p)),h=>c(e,f.at,h,p=>N(l,p)?0:R(l,p)));return s.left<f.sum&&s.left+s.width>0&&s.top<a.sum&&s.top+s.height>0?`<div class="chart" style="left:${String(o.left+s.left)}px;top:${String(o.top+s.top)}px">${this.svg(i)}</div>`:""}).join("")}}const B=44,vt=`
4
4
  (() => {
5
5
  const fit = () => {
6
6
  const cells = Array.from(document.querySelectorAll("td.n"));
@@ -23,24 +23,24 @@ import{formatColor as O,isValidFormat as P}from"numfmt";import{cellName as T,col
23
23
  };
24
24
  window.allyhubReady = new Promise((r) => addEventListener("load", r, { once: true })).then(() => document.fonts.ready).then(fit);
25
25
  })();
26
- `;function G(o,t,e){return`<!doctype html><html><head><meta charset="utf-8"><style>
27
- ${o.css??""}
28
- :root{--font:${o.font===void 0?"":`"${o.font}",`}Carlito,Calibri,"Noto Sans SC",Arial,sans-serif}
26
+ `;function G(n,t,e){return`<!doctype html><html><head><meta charset="utf-8"><style>
27
+ ${n.css??""}
28
+ :root{--font:${n.font===void 0?"":`"${n.font}",`}Carlito,Calibri,"Noto Sans SC",Arial,sans-serif}
29
29
  *{box-sizing:border-box}
30
30
  html,body{margin:0;background:#fff;color:#000}
31
31
  body{font:11pt/1.2 var(--font)}
32
32
  table{table-layout:fixed;border-collapse:collapse}
33
- td,th{height:${String(D)}px;padding:0 3px;overflow:hidden;white-space:pre;vertical-align:bottom}
33
+ td,th{height:${String(F)}px;padding:0 3px;overflow:hidden;white-space:pre;vertical-align:bottom}
34
34
  td.over{overflow:visible}
35
35
  .chart{position:absolute;line-height:0}
36
36
  .grid td{border:1px solid #e3e3e3}
37
37
  .edged th{border:1px solid #e3e3e3;background:#f5f5f5;color:#555;font-weight:normal;text-align:center;vertical-align:middle;font-size:9pt}
38
38
  ${t}
39
- </style><script>${yt}<\/script></head><body>${e}</body></html>`}export function sheetHtml(o,t={}){const e=t.sheets??o.wb.sheets.filter(s=>s.spec.hidden!==!0),i=new L,l=[];let r=0;const d=e.length>1&&t.area===void 0,f=e.map(s=>{const n=new W(o,s,t.file),a=t.area??ot(s)??{top:0,left:0,bottom:0,right:0},h=[];for(let b=a.top;b<=a.bottom;b++)H(o,s,b)||h.push(b);const g=[];for(let b=a.left;b<=a.right;b++)N(s,b)||g.push(b);const w=h.slice(0,t.rows??h.length),m=g.slice(0,t.columns??g.length);if(w.length<h.length||m.length<g.length){const b=w[w.length-1]??a.top,S=m[m.length-1]??a.left;l.push(`${s.name}: drew ${T({row:a.top,col:a.left})}:${T({row:b,col:S})} of ${String(h.length)} rows and ${String(g.length)} columns`)}const p=t.headings===!0,y=n.table(w,m,i,{headings:p,className:p?s.spec.gridlines===!1?"edged":"edged grid":""});r=Math.max(r,y.width);const x=n.charts(w,m,{left:p?B:0,top:p?D:0});return`<section class="sheet">${d?`<h2>${v(s.name)}</h2>`:""}<div class="book">${y.html}${x}</div></section>`});return{html:G(t,`h2{font:bold 12pt var(--font);margin:0 0 8px}
39
+ </style><script>${vt}<\/script></head><body>${e}</body></html>`}export function sheetHtml(n,t={}){const e=t.sheets??n.wb.sheets.filter(i=>i.spec.hidden!==!0),o=new L,l=[];let r=0;const a=e.length>1&&t.area===void 0,f=e.map(i=>{const s=new W(n,i,t.file),d=t.area??rt(i)??{top:0,left:0,bottom:0,right:0},h=[];for(let b=d.top;b<=d.bottom;b++)E(n,i,b)||h.push(b);const p=[];for(let b=d.left;b<=d.right;b++)N(i,b)||p.push(b);const w=h.slice(0,t.rows??h.length),$=p.slice(0,t.columns??p.length);if(w.length<h.length||$.length<p.length){const b=w[w.length-1]??d.top,C=$[$.length-1]??d.left;l.push(`${i.name}: drew ${T({row:d.top,col:d.left})}:${T({row:b,col:C})} of ${String(h.length)} rows and ${String(p.length)} columns`)}const u=t.headings===!0,y=s.table(w,$,o,{headings:u,className:u?i.spec.gridlines===!1?"edged":"edged grid":""});r=Math.max(r,y.width);const S=s.charts(w,$,{left:u?B:0,top:u?F:0});return`<section class="sheet">${a?`<h2>${x(i.name)}</h2>`:""}<div class="book">${y.html}${S}</div></section>`});return{html:G(t,`h2{font:bold 12pt var(--font);margin:0 0 8px}
40
40
  .sheet+.sheet{margin-top:24px}
41
41
  .book{position:relative;width:max-content;overflow:hidden}
42
- ${i.css()}`,f.join("")),width:r,cut:l}}const z=o=>String(o).padStart(2,"0");export function headerFooterHtml(o,t){let e="",i=0;const l=d=>{e+=`<span style="${d}">`,i++},r={B:"font-weight:bold",I:"font-style:italic",U:"text-decoration:underline",E:"text-decoration:underline double",S:"text-decoration:line-through",X:"vertical-align:super;font-size:smaller",Y:"vertical-align:sub;font-size:smaller"};for(let d=0;d<o.length;d++){const f=o[d]??"";if(f!=="&"){e+=v(f);continue}const c=o[d+1]??"",s=c.toUpperCase();if(d++,c==="&")e+="&amp;";else if(s==="P"||s==="N"){const n=/^[+-]\d+/u.exec(o.slice(d+1)),a=s==="P"?t.page:t.pages;e+=String(a+(n?Number(n[0]):0)),n&&(d+=n[0].length)}else if(s==="D")e+=`${String(t.date.getFullYear())}-${z(t.date.getMonth()+1)}-${z(t.date.getDate())}`;else if(s==="T")e+=`${z(t.date.getHours())}:${z(t.date.getMinutes())}`;else if(s==="F"||s==="Z")e+=v(t.file);else if(s==="A")e+=v(t.sheet);else{if(s==="G")continue;if(r[s]!==void 0)l(r[s]);else if(c==='"'){const n=o.indexOf('"',d+1),[a="",h=""]=o.slice(d+1,n<0?o.length:n).split(",");d=n<0?o.length:n;const g=[a==="-"||a===""?"":`font-family:"${a.replace(/["\\]/gu,"")}",var(--font)`,/bold/iu.test(h)?"font-weight:bold":"",/italic/iu.test(h)?"font-style:italic":""].filter(Boolean).join(";");g!==""&&l(g)}else if(/\d/u.test(c)){const n=/^\d+/u.exec(o.slice(d))?.[0]??c;d+=n.length-1,l(`font-size:${n}pt`)}else if(s==="K"){const n=o.slice(d+1,d+7);d+=6,/^[0-9A-Fa-f]{6}$/u.test(n)&&l(`color:#${n}`)}}}return e+"</span>".repeat(i)}const u=o=>`${String(Math.round(o*1e3)/1e3)}px`;export class SheetPrint{job;calc;drawers=new Map;file;constructor(t,e={}){this.calc=t,this.file=e.file,this.job=it(t,{...e.sheets?{sheets:e.sheets}:{},height:(i,l)=>this.drawer(i).height(l)})}drawer(t){let e=this.drawers.get(t);return e||(e=new W(this.calc,t,this.file),this.drawers.set(t,e)),e}html(t,e,i){const l=new L,r=new Map,d=[];for(const c of this.job.pages.slice(t,e)){const{of:s}=c,n=`${u(s.paper.width)} ${u(s.paper.height)}`;let a=r.get(n);a===void 0&&(a=`paper${String(r.size)}`,r.set(n,a)),d.push(this.page(c,l,a,i))}const f=[...r].map(([c,s])=>`@page ${s}{size:${c};margin:0}`).join(`
43
- `);return G(i,`${f}
42
+ ${o.css()}`,f.join("")),width:r,cut:l}}const H=n=>String(n).padStart(2,"0");export function headerFooterHtml(n,t){let e="",o=0;const l=a=>{e+=`<span style="${a}">`,o++},r={B:"font-weight:bold",I:"font-style:italic",U:"text-decoration:underline",E:"text-decoration:underline double",S:"text-decoration:line-through",X:"vertical-align:super;font-size:smaller",Y:"vertical-align:sub;font-size:smaller"};for(let a=0;a<n.length;a++){const f=n[a]??"";if(f!=="&"){e+=x(f);continue}const c=n[a+1]??"",i=c.toUpperCase();if(a++,c==="&")e+="&amp;";else if(i==="P"||i==="N"){const s=/^[+-]\d+/u.exec(n.slice(a+1)),d=i==="P"?t.page:t.pages;e+=String(d+(s?Number(s[0]):0)),s&&(a+=s[0].length)}else if(i==="D")e+=`${String(t.date.getFullYear())}-${H(t.date.getMonth()+1)}-${H(t.date.getDate())}`;else if(i==="T")e+=`${H(t.date.getHours())}:${H(t.date.getMinutes())}`;else if(i==="F"||i==="Z")e+=x(t.file);else if(i==="A")e+=x(t.sheet);else{if(i==="G")continue;if(r[i]!==void 0)l(r[i]);else if(c==='"'){const s=n.indexOf('"',a+1),[d="",h=""]=n.slice(a+1,s<0?n.length:s).split(",");a=s<0?n.length:s;const p=[d==="-"||d===""?"":`font-family:"${d.replace(/["\\]/gu,"")}",var(--font)`,/bold/iu.test(h)?"font-weight:bold":"",/italic/iu.test(h)?"font-style:italic":""].filter(Boolean).join(";");p!==""&&l(p)}else if(/\d/u.test(c)){const s=/^\d+/u.exec(n.slice(a))?.[0]??c;a+=s.length-1,l(`font-size:${s}pt`)}else if(i==="K"){const s=n.slice(a+1,a+7);a+=6,/^[0-9A-Fa-f]{6}$/u.test(s)&&l(`color:#${s}`)}}}return e+"</span>".repeat(o)}const m=n=>`${String(Math.round(n*1e3)/1e3)}px`;export class SheetPrint{job;calc;drawers=new Map;file;constructor(t,e={}){this.calc=t,this.file=e.file,this.job=ot(t,{...e.sheets?{sheets:e.sheets}:{},height:(o,l)=>this.drawer(o).height(l)})}drawer(t){let e=this.drawers.get(t);return e||(e=new W(this.calc,t,this.file),this.drawers.set(t,e)),e}html(t,e,o){const l=new L,r=new Map,a=[];for(const c of this.job.pages.slice(t,e)){const{of:i}=c,s=`${m(i.paper.width)} ${m(i.paper.height)}`;let d=r.get(s);d===void 0&&(d=`paper${String(r.size)}`,r.set(s,d)),a.push(this.page(c,l,d,o))}const f=[...r].map(([c,i])=>`@page ${i}{size:${c};margin:0}`).join(`
43
+ `);return G(o,`${f}
44
44
  .page{position:relative;overflow:hidden;break-after:page}
45
45
  .page:last-child{break-after:auto}
46
46
  .body,.charts{position:absolute;overflow:hidden}
@@ -49,4 +49,4 @@ ${i.css()}`,f.join("")),width:r,cut:l}}const z=o=>String(o).padStart(2,"0");expo
49
49
  .hf>div{flex:1 1 0;overflow:visible}
50
50
  .hf>.c{text-align:center}
51
51
  .hf>.r{text-align:right}
52
- ${l.css()}`,d.join(""))}page(t,e,i,l){const{of:r}=t,d=this.drawer(r.sheet),{margins:f,scale:c}=r,s=nt(t),n=et(t),a=r.rows.slice(t.down.from,t.down.to),h=r.cols.slice(t.across.from,t.across.to),g=d.table([...s,...a],[...n,...h],e,{headings:!1}),w=s.reduce(($,A)=>$+d.height(A),0),m=n.reduce(($,A)=>$+M(r.sheet,A),0),p=r.rowAt[t.down.from]??0,y=r.colAt[t.across.from]??0,x=(r.rowAt[t.down.to]??0)-p,b=(r.colAt[t.across.to]??0)-y,S=r.charts.filter($=>$.left<y+b&&$.left+$.width>y&&$.top<p+x&&$.top+$.height>p).map($=>`<div class="chart" style="left:${u($.left-y)};top:${u($.top-p)}">${d.svg($.chart)}</div>`).join(""),F=S===""?"":`<div class="charts" style="left:${u(m)};top:${u(w)};width:${u(b)};height:${u(x)}">${S}</div>`,j=r.paper.width-f.left-f.right,R=r.paper.height-f.top-f.bottom,C={page:t.number,pages:this.job.pages.length,sheet:r.sheet.name,file:l.name,date:l.date},E=($,A)=>$?`<div class="hf" style="left:${u(f.left)};right:${u(f.right)};${A}"><div>${headerFooterHtml($.left??"",C)}</div><div class="c">${headerFooterHtml($.center??"",C)}</div><div class="r">${headerFooterHtml($.right??"",C)}</div></div>`:"";return`<section class="page" style="page:${i};width:${u(r.paper.width)};height:${u(r.paper.height)}">`+E(r.header,`top:${u(f.header)}`)+`<div class="body" style="left:${u(f.left)};top:${u(f.top)};width:${u(j)};height:${u(R)}"><div class="scaled" style="width:${u(j/c)};height:${u(R/c)}${c===1?"":`;transform:scale(${String(c)})`}">`+g.html+F+"</div></div>"+E(r.footer,`bottom:${u(f.footer)}`)+"</section>"}}
52
+ ${l.css()}`,a.join(""))}page(t,e,o,l){const{of:r}=t,a=this.drawer(r.sheet),{margins:f,scale:c}=r,i=st(t),s=nt(t),d=r.rows.slice(t.down.from,t.down.to),h=r.cols.slice(t.across.from,t.across.to),p=a.table([...i,...d],[...s,...h],e,{headings:!1}),w=i.reduce((g,v)=>g+a.height(v),0),$=s.reduce((g,v)=>g+R(r.sheet,v),0),u=r.rowAt[t.down.from]??0,y=r.colAt[t.across.from]??0,S=(r.rowAt[t.down.to]??0)-u,b=(r.colAt[t.across.to]??0)-y,C=r.charts.filter(g=>g.left<y+b&&g.left+g.width>y&&g.top<u+S&&g.top+g.height>u).map(g=>`<div class="chart" style="left:${m(g.left-y)};top:${m(g.top-u)}">${a.svg(g.chart)}</div>`).join(""),A=C===""?"":`<div class="charts" style="left:${m($)};top:${m(w)};width:${m(b)};height:${m(S)}">${C}</div>`,M=r.paper.width-f.left-f.right,z=r.paper.height-f.top-f.bottom,D={page:t.number,pages:this.job.pages.length,sheet:r.sheet.name,file:l.name,date:l.date},j=(g,v)=>g?`<div class="hf" style="left:${m(f.left)};right:${m(f.right)};${v}"><div>${headerFooterHtml(g.left??"",D)}</div><div class="c">${headerFooterHtml(g.center??"",D)}</div><div class="r">${headerFooterHtml(g.right??"",D)}</div></div>`:"";return`<section class="page" style="page:${o};width:${m(r.paper.width)};height:${m(r.paper.height)}">`+j(r.header,`top:${m(f.header)}`)+`<div class="body" style="left:${m(f.left)};top:${m(f.top)};width:${m(M)};height:${m(z)}"><div class="scaled" style="width:${m(M/c)};height:${m(z/c)}${c===1?"":`;transform:scale(${String(c)})`}">`+p.html+A+"</div></div>"+j(r.footer,`bottom:${m(f.footer)}`)+"</section>"}}
@@ -24,12 +24,17 @@ export { generalForms, generalText, isDateCode, shownColor, shownValue, } from "
24
24
  export { DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT, headerFooterHtml, sheetHtml, SheetPrint, type PageFields, type PrintHtmlOptions, type SheetHtml, type SheetHtmlOptions, } from "./html.js";
25
25
  export { PAPERS, PRINT_DEFAULTS, paginate, type PaginateOptions, type PrintJob, type PrintedPage, type SheetPages, } from "./paginate.js";
26
26
  export { DEFAULT_TABLE_STYLE, tableStyleLook, tableStyleOf, type TablePart, type TableStyle, } from "./table-style.js";
27
+ export { TABLE_STYLES } from "./table-styles.js";
27
28
  export { PROFILE_TOP, profileTable, type ColumnProfile } from "./profile.js";
28
29
  export { importRows, type ImportedSheet } from "./import.js";
29
30
  export { patchYaml, writeYaml } from "./write.js";
30
31
  export * from "./edit.js";
32
+ export * from "./rich.js";
33
+ export * from "./annotations.js";
31
34
  export * from "./arrange.js";
32
- export { NO_LOOK, autoFill, copyLooks, fillDownTo, moveCells, pasteLooks, type LookCopy, } from "./fill.js";
35
+ export * from "./outline.js";
36
+ export * from "./data-tools.js";
37
+ export { NO_LOOK, autoFill, copyLooks, fillDownTo, moveCells, pasteLooks, shiftCells, type CellShift, type LookCopy, } from "./fill.js";
33
38
  export { seriesAfter, type FillMode } from "./series.js";
34
39
  export { compareForSort, hasHeader, sortCells, sortedOrder, sortedRows, type SortKey, } from "./sort.js";
35
40
  export { filterChoices, filteredRows, regionAround, type FilterChoice, } from "./filter.js";