@a3s-lab/office 0.31.0 → 0.33.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 (63) hide show
  1. package/README.md +63 -8
  2. package/dist/0~3539.js +2 -2
  3. package/dist/0~3557.js +1 -1
  4. package/dist/0~3635.js +1 -1
  5. package/dist/0~4808.js +1 -1
  6. package/dist/0~4980.js +1 -1
  7. package/dist/0~7048.js +1 -2
  8. package/dist/0~7240.js +1 -1
  9. package/dist/0~7614.js +1 -1
  10. package/dist/{0~6090.js → 0~8136.js} +71 -2
  11. package/dist/{0~4595.js → 0~9073.js} +3 -72
  12. package/dist/0~9445.js +1 -1
  13. package/dist/0~document-editor.js +1087 -6
  14. package/dist/0~markdown-editor.js +2 -2
  15. package/dist/0~pdf-page-organization-engine.js +187 -0
  16. package/dist/0~pdf-viewer.js +1014 -30
  17. package/dist/0~presentation-editor.js +2 -2
  18. package/dist/0~spreadsheet-editor.js +4 -3
  19. package/dist/0~work-docx-export.js +1 -1
  20. package/dist/0~work-docx-import.js +10 -27
  21. package/dist/0~work-docx-large-document-import.js +1 -1
  22. package/dist/0~work-office-diagnostics.js +3 -3
  23. package/dist/0~work-pptx-import.js +1 -1
  24. package/dist/{1544.js → 3266.js} +17 -1862
  25. package/dist/4121.js +13 -0
  26. package/dist/4166.js +3848 -0
  27. package/dist/{6282.js → 4174.js} +383 -10
  28. package/dist/9333.js +1849 -0
  29. package/dist/core.d.ts +1 -0
  30. package/dist/core.js +5259 -4
  31. package/dist/index.js +3 -3
  32. package/dist/internal/features/work/editors/document-compare-dialog.d.ts +14 -0
  33. package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
  34. package/dist/internal/features/work/editors/pdf-editor-extensions.d.ts +11 -0
  35. package/dist/internal/features/work/editors/pdf-page-organization-engine.d.ts +2 -0
  36. package/dist/internal/features/work/editors/pdf-page-organization-plan.d.ts +10 -0
  37. package/dist/internal/features/work/editors/pdf-page-organization-types.d.ts +68 -0
  38. package/dist/internal/features/work/editors/pdf-page-organization-worker-client.d.ts +2 -0
  39. package/dist/internal/features/work/editors/pdf-page-organization-worker-protocol.d.ts +13 -0
  40. package/dist/internal/features/work/editors/pdf-page-organization.d.ts +3 -0
  41. package/dist/internal/features/work/editors/pdf-page-organization.worker.d.ts +1 -0
  42. package/dist/internal/features/work/editors/pdf-page-organizer-dialog.d.ts +17 -0
  43. package/dist/internal/features/work/editors/pdf-thumbnail-rail.d.ts +4 -0
  44. package/dist/internal/features/work/editors/pdf-toolbar.d.ts +2 -1
  45. package/dist/internal/features/work/editors/pdf-viewer.d.ts +3 -1
  46. package/dist/internal/features/work/editors/use-document-comparison.d.ts +9 -0
  47. package/dist/internal/features/work/editors/use-pdf-page-organization.d.ts +38 -0
  48. package/dist/internal/features/work/work-document-changes.d.ts +5 -0
  49. package/dist/internal/features/work/work-document-compare-diff.d.ts +38 -0
  50. package/dist/internal/features/work/work-document-compare-stability.d.ts +5 -0
  51. package/dist/internal/features/work/work-document-compare.d.ts +27 -0
  52. package/dist/office-kernel.wasm +0 -0
  53. package/dist/pdf-page-organization.worker.js +19667 -0
  54. package/dist/pdf-page-organization.worker.js.LICENSE.txt +14 -0
  55. package/dist/react.d.ts +1 -0
  56. package/dist/styles.css +509 -0
  57. package/dist/vue.d.ts +3 -1
  58. package/dist/vue.js +2 -0
  59. package/dist/web-component.d.ts +3 -1
  60. package/dist/web-component.js +9 -0
  61. package/docs/latest/en/browser-editor-architecture.md +52 -6
  62. package/package.json +10 -3
  63. package/dist/4104.js +0 -9336
@@ -1,8 +1,9 @@
1
1
  import { workOfficeCollaborationJsonEqual, canonicalWorkOfficeCollaborationJson, isWorkOfficeCollaborationRecord, cloneWorkOfficeCollaborationJson } from "./4650.js";
2
2
  import { initializeWorkOfficeCollaborationMetadata, assertWorkOfficeCollaborationEditable, OfficeCollaborationError as WorkOfficeCollaborationError, readOfficeCollaborationMetadata as readWorkOfficeCollaborationMetadata, registerWorkOfficeCollaborationInitializer, markWorkOfficeCollaborationInitialized, assertWorkOfficeCollaborationOrigin } from "./9787.js";
3
- import { directChild, directChildren, descendants, OFFICE_KERNEL_SPREADSHEET_MAX_ROWS, attribute, firstDescendant } from "./4121.js";
4
- import { sparseMatrixColumnCount, cloneSparseMatrix, sparseArrayEntries as spreadsheet_sparse_sparseArrayEntries, formatSpreadsheetCellRanges, isValidSpreadsheetDefinedName, parseSpreadsheetCellRanges as work_spreadsheet_ranges_parseSpreadsheetCellRanges, sparseArrayIndexes } from "./8715.js";
3
+ import { directChild, directChildren, descendants, OFFICE_KERNEL_SPREADSHEET_MAX_ROWS, attribute } from "./4121.js";
4
+ import { isValidSpreadsheetDefinedName, sparseArrayEntries } from "./8715.js";
5
5
  import { patchWorkOfficeCollaborationFlatJsonMap, readWorkOfficeCollaborationFlatJsonMap } from "./7060.js";
6
+ import { resolveXlsxColor, createXlsxColorResolver, normalizeXlsxSemanticColorOrigin, xlsxPatternFillKey, XLSX_PATTERN_FILL_CELL_KEY, xlsxCellAddress, xlsxSemanticColorMatchesValue, xlsxGradientFillSemanticColors, xlsxColorElementMatchesOrigin, decodeXlsxCellAddress, xlsxSemanticColorOriginSupported, deleteXlsxPatternFill, xlsxCellStyleOrigin, xlsxRgbColor, xlsxPatternFillSemanticColors, activeXlsxGradientFill, xlsxGradientFillKey, applyXlsxSemanticColorOrigin, deleteXlsxGradientFill, XLSX_GRADIENT_FILL_CELL_KEY, readXlsxSemanticColorOrigin, activeXlsxPatternFill } from "./9333.js";
6
7
  import * as __rspack_external_yjs from "yjs";
7
8
  function requiredCoordinate(value, maximum, label, sheetId) {
8
9
  if (!Number.isSafeInteger(value) || value < 0 || value >= maximum) invalidWorkOfficeSpreadsheetInput(`a valid ${label} coordinate in sheet '${sheetId}'`);
@@ -743,7 +744,7 @@ function assertCompatibleValue(previous, next, shared, label) {
743
744
  function spreadsheetCells(sheet) {
744
745
  const result = new Map();
745
746
  if (void 0 !== sheet.data) {
746
- for (const [row, values] of spreadsheet_sparse_sparseArrayEntries(sheet.data))for (const [column, cell] of spreadsheet_sparse_sparseArrayEntries(values))if (null !== cell) result.set(`${row}:${column}`, cell);
747
+ for (const [row, values] of sparseArrayEntries(sheet.data))for (const [column, cell] of sparseArrayEntries(values))if (null !== cell) result.set(`${row}:${column}`, cell);
747
748
  return result;
748
749
  }
749
750
  for (const entry of sheet.celldata ?? [])if (null !== entry.v) result.set(`${entry.r}:${entry.c}`, entry.v);
@@ -853,7 +854,7 @@ function spreadsheetCellEntries(sheet) {
853
854
  if (!sheet) return [];
854
855
  const entries = [];
855
856
  if (void 0 !== sheet.data) {
856
- for (const [row, values] of spreadsheet_sparse_sparseArrayEntries(sheet.data))for (const [column, cell] of spreadsheet_sparse_sparseArrayEntries(values))if (null !== cell) entries.push({
857
+ for (const [row, values] of sparseArrayEntries(sheet.data))for (const [column, cell] of sparseArrayEntries(values))if (null !== cell) entries.push({
857
858
  cell,
858
859
  column,
859
860
  coordinate: encodedCoordinate(row, column),
@@ -1620,1359 +1621,6 @@ function assertInitializedSpreadsheetSession(session) {
1620
1621
  if (metadata?.initialized) return;
1621
1622
  throw new WorkOfficeCollaborationError('office.collaboration.not_initialized', 'The Spreadsheet collaboration session has not been initialized.');
1622
1623
  }
1623
- function* xlsxWorksheetCellEntries(worksheet) {
1624
- if (Array.isArray(worksheet)) {
1625
- for(let row = 0; row < worksheet.length; row += 1){
1626
- const cells = worksheet[row];
1627
- if (Array.isArray(cells)) for(let column = 0; column < cells.length; column += 1){
1628
- const cell = cells[column];
1629
- if (!(!cell || 'object' != typeof cell || Array.isArray(cell))) yield {
1630
- address: xlsxCellAddress(row, column),
1631
- cell: cell,
1632
- column,
1633
- row
1634
- };
1635
- }
1636
- }
1637
- return;
1638
- }
1639
- for (const [address, cell] of Object.entries(worksheet)){
1640
- if (address.startsWith('!') || !cell || 'object' != typeof cell) continue;
1641
- const position = decodeXlsxCellAddress(address);
1642
- if (position) yield {
1643
- address,
1644
- cell: cell,
1645
- ...position
1646
- };
1647
- }
1648
- }
1649
- function xlsxCellAddress(row, column) {
1650
- let value = column + 1;
1651
- let label = '';
1652
- while(value > 0){
1653
- value -= 1;
1654
- label = String.fromCharCode(65 + value % 26) + label;
1655
- value = Math.floor(value / 26);
1656
- }
1657
- return `${label}${row + 1}`;
1658
- }
1659
- function decodeXlsxCellAddress(address) {
1660
- const match = /^([A-Za-z]+)([1-9][0-9]*)$/.exec(address);
1661
- if (!match) return null;
1662
- let column = 0;
1663
- for (const character of match[1].toUpperCase())column = 26 * column + character.charCodeAt(0) - 64;
1664
- const row = Number(match[2]);
1665
- if (!Number.isSafeInteger(row) || row <= 0) return null;
1666
- return {
1667
- column: column - 1,
1668
- row: row - 1
1669
- };
1670
- }
1671
- const spreadsheetFormulaHistoryIgnoredKeys = new Set([
1672
- 'ct',
1673
- 'm',
1674
- 'v'
1675
- ]);
1676
- function sameSpreadsheetHistoryValue(left, right) {
1677
- if (left === right) return true;
1678
- if (null === left || null === right || typeof left !== typeof right) return false;
1679
- const leftFormulaCell = spreadsheetFormulaCell(left);
1680
- const rightFormulaCell = spreadsheetFormulaCell(right);
1681
- if (leftFormulaCell || rightFormulaCell) return Boolean(leftFormulaCell && rightFormulaCell && sameSpreadsheetFormulaHistoryCell(leftFormulaCell, rightFormulaCell));
1682
- if (Array.isArray(left) || Array.isArray(right)) {
1683
- if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false;
1684
- const leftKeys = Object.keys(left).filter((key)=>void 0 !== left[Number(key)]);
1685
- const rightKeys = Object.keys(right).filter((key)=>void 0 !== right[Number(key)]);
1686
- return leftKeys.length === rightKeys.length && leftKeys.every((key)=>Object.hasOwn(right, key) && sameSpreadsheetHistoryValue(left[Number(key)], right[Number(key)]));
1687
- }
1688
- if ('object' != typeof left || 'object' != typeof right) return false;
1689
- const leftRecord = left;
1690
- const rightRecord = right;
1691
- const leftKeys = Object.keys(leftRecord).filter((key)=>void 0 !== leftRecord[key]);
1692
- const rightKeys = Object.keys(rightRecord).filter((key)=>void 0 !== rightRecord[key]);
1693
- return leftKeys.length === rightKeys.length && leftKeys.every((key)=>sameSpreadsheetHistoryValue(leftRecord[key], rightRecord[key]));
1694
- }
1695
- function spreadsheetFormulaCell(value) {
1696
- return value && 'object' == typeof value && 'string' == typeof value.f ? value : null;
1697
- }
1698
- function sameSpreadsheetFormulaHistoryCell(left, right) {
1699
- const leftRecord = left;
1700
- const rightRecord = right;
1701
- const leftKeys = Object.keys(leftRecord).filter((key)=>!spreadsheetFormulaHistoryIgnoredKeys.has(key) && void 0 !== leftRecord[key]);
1702
- const rightKeys = Object.keys(rightRecord).filter((key)=>!spreadsheetFormulaHistoryIgnoredKeys.has(key) && void 0 !== rightRecord[key]);
1703
- return leftKeys.length === rightKeys.length && leftKeys.every((key)=>sameSpreadsheetHistoryValue(leftRecord[key], rightRecord[key])) && sameSpreadsheetHistoryValue(spreadsheetFormulaHistoryCellType(left.ct), spreadsheetFormulaHistoryCellType(right.ct));
1704
- }
1705
- function spreadsheetFormulaHistoryCellType(cellType) {
1706
- if (!cellType) return;
1707
- const { fa, t: _type, ...retainedCellType } = cellType;
1708
- const normalized = {
1709
- ...retainedCellType,
1710
- ...fa && 'General' !== fa ? {
1711
- fa
1712
- } : {}
1713
- };
1714
- return Object.keys(normalized).length ? normalized : void 0;
1715
- }
1716
- const borderChildOrder = [
1717
- 'start',
1718
- 'end',
1719
- 'left',
1720
- 'right',
1721
- 'top',
1722
- 'bottom',
1723
- 'diagonal',
1724
- 'vertical',
1725
- 'horizontal',
1726
- 'extLst'
1727
- ];
1728
- function ensureXlsxStyleCollection(document, name, anchors) {
1729
- const root = document.documentElement;
1730
- const existing = directChild(root, name);
1731
- if (existing) return existing;
1732
- const collection = document.createElementNS(root.namespaceURI, name);
1733
- root.insertBefore(collection, directChildren(root).find((child)=>anchors.includes(child.localName)) ?? null);
1734
- return collection;
1735
- }
1736
- function defaultXlsxFill(document, patternType) {
1737
- const fill = document.createElementNS(document.documentElement.namespaceURI, 'fill');
1738
- const pattern = document.createElementNS(document.documentElement.namespaceURI, 'patternFill');
1739
- pattern.setAttribute('patternType', patternType);
1740
- fill.append(pattern);
1741
- return fill;
1742
- }
1743
- function defaultXlsxBorder(document) {
1744
- const border = document.createElementNS(document.documentElement.namespaceURI, 'border');
1745
- for (const name of [
1746
- 'left',
1747
- 'right',
1748
- 'top',
1749
- 'bottom',
1750
- 'diagonal'
1751
- ])border.append(document.createElementNS(document.documentElement.namespaceURI, name));
1752
- return border;
1753
- }
1754
- function setXlsxBorderLine(document, border, name, line) {
1755
- removeXlsxChildren(border, name);
1756
- const element = document.createElementNS(document.documentElement.namespaceURI, name);
1757
- if (line) {
1758
- element.setAttribute('style', line.style);
1759
- const color = xlsxRgbColor(line.color);
1760
- if (color) {
1761
- const child = document.createElementNS(document.documentElement.namespaceURI, 'color');
1762
- child.setAttribute('rgb', color);
1763
- element.append(child);
1764
- }
1765
- }
1766
- insertXlsxOrderedChild(border, element, borderChildOrder);
1767
- }
1768
- function writeXlsxAlignment(document, xf, style) {
1769
- let alignment = directChild(xf, 'alignment');
1770
- if (!alignment) {
1771
- alignment = document.createElementNS(document.documentElement.namespaceURI, 'alignment');
1772
- xf.insertBefore(alignment, directChildren(xf).find((child)=>[
1773
- 'protection',
1774
- 'extLst'
1775
- ].includes(child.localName)) ?? null);
1776
- }
1777
- if (void 0 !== style.horizontal) alignment.setAttribute('horizontal', style.horizontal);
1778
- if (void 0 !== style.vertical) alignment.setAttribute('vertical', style.vertical);
1779
- if (void 0 !== style.wrapText) alignment.setAttribute('wrapText', style.wrapText ? '1' : '0');
1780
- if (void 0 !== style.textRotation && Number.isInteger(style.textRotation) && (style.textRotation >= 0 && style.textRotation <= 180 || 255 === style.textRotation)) alignment.setAttribute('textRotation', String(style.textRotation));
1781
- }
1782
- function setXlsxValueChild(document, parent, name, value, order) {
1783
- removeXlsxChildren(parent, name);
1784
- const child = document.createElementNS(document.documentElement.namespaceURI, name);
1785
- child.setAttribute('val', value);
1786
- insertXlsxOrderedChild(parent, child, order);
1787
- }
1788
- function setXlsxColorChild(document, parent, color, order) {
1789
- removeXlsxChildren(parent, 'color');
1790
- const child = document.createElementNS(document.documentElement.namespaceURI, 'color');
1791
- child.setAttribute('rgb', color);
1792
- insertXlsxOrderedChild(parent, child, order);
1793
- }
1794
- function setXlsxToggleChild(document, parent, name, enabled, order) {
1795
- removeXlsxChildren(parent, name);
1796
- if (!enabled) return;
1797
- const child = document.createElementNS(document.documentElement.namespaceURI, name);
1798
- child.setAttribute('val', '1');
1799
- insertXlsxOrderedChild(parent, child, order);
1800
- }
1801
- function setXlsxUnderlineChild(document, parent, style, order) {
1802
- removeXlsxChildren(parent, 'u');
1803
- if ('none' === style) return;
1804
- const child = document.createElementNS(document.documentElement.namespaceURI, 'u');
1805
- child.setAttribute('val', style);
1806
- insertXlsxOrderedChild(parent, child, order);
1807
- }
1808
- function xlsxRgbColor(value) {
1809
- if ('string' != typeof value) return null;
1810
- const color = value.trim().replace('#', '').toUpperCase();
1811
- if (/^[0-9A-F]{6}$/.test(color)) return `FF${color}`;
1812
- if (/^[0-9A-F]{8}$/.test(color)) return color;
1813
- if (/^[0-9A-F]{3}$/.test(color)) return `FF${[
1814
- ...color
1815
- ].map((character)=>character.repeat(2)).join('')}`;
1816
- return null;
1817
- }
1818
- function removeXlsxChildren(parent, name) {
1819
- for (const child of directChildren(parent, name))child.remove();
1820
- }
1821
- function insertXlsxOrderedChild(parent, child, order) {
1822
- const requested = order.indexOf(child.localName);
1823
- const anchor = directChildren(parent).find((candidate)=>order.indexOf(candidate.localName) > requested);
1824
- parent.insertBefore(child, anchor ?? null);
1825
- }
1826
- const defaultThemeColors = [
1827
- 'ffffff',
1828
- '000000',
1829
- 'e7e6e6',
1830
- '44546a',
1831
- '4472c4',
1832
- 'ed7d31',
1833
- 'a5a5a5',
1834
- 'ffc000',
1835
- '5b9bd5',
1836
- '70ad47',
1837
- '0563c1',
1838
- '954f72'
1839
- ];
1840
- const themeColorNames = [
1841
- 'lt1',
1842
- 'dk1',
1843
- 'lt2',
1844
- 'dk2',
1845
- 'accent1',
1846
- 'accent2',
1847
- 'accent3',
1848
- 'accent4',
1849
- 'accent5',
1850
- 'accent6',
1851
- 'hlink',
1852
- 'folHlink'
1853
- ];
1854
- const defaultIndexedColors = [
1855
- '000000',
1856
- 'ffffff',
1857
- 'ff0000',
1858
- '00ff00',
1859
- '0000ff',
1860
- 'ffff00',
1861
- 'ff00ff',
1862
- '00ffff',
1863
- '000000',
1864
- 'ffffff',
1865
- 'ff0000',
1866
- '00ff00',
1867
- '0000ff',
1868
- 'ffff00',
1869
- 'ff00ff',
1870
- '00ffff',
1871
- '800000',
1872
- '008000',
1873
- '000080',
1874
- '808000',
1875
- '800080',
1876
- '008080',
1877
- 'c0c0c0',
1878
- '808080',
1879
- '9999ff',
1880
- '993366',
1881
- 'ffffcc',
1882
- 'ccffff',
1883
- '660066',
1884
- 'ff8080',
1885
- '0066cc',
1886
- 'ccccff',
1887
- '000080',
1888
- 'ff00ff',
1889
- 'ffff00',
1890
- '00ffff',
1891
- '800080',
1892
- '800000',
1893
- '008080',
1894
- '0000ff',
1895
- '00ccff',
1896
- 'ccffff',
1897
- 'ccffcc',
1898
- 'ffff99',
1899
- '99ccff',
1900
- 'ff99cc',
1901
- 'cc99ff',
1902
- 'ffcc99',
1903
- '3366ff',
1904
- '33cccc',
1905
- '99cc00',
1906
- 'ffcc00',
1907
- 'ff9900',
1908
- 'ff6600',
1909
- '666699',
1910
- '969696',
1911
- '003366',
1912
- '339966',
1913
- '003300',
1914
- '333300',
1915
- '993300',
1916
- '993366',
1917
- '333399',
1918
- '333333'
1919
- ];
1920
- function createXlsxColorResolver(styles, theme) {
1921
- return {
1922
- indexed: styles ? readIndexedColors(styles) : defaultIndexedColors,
1923
- theme: readThemeColors(theme)
1924
- };
1925
- }
1926
- function resolveXlsxColor(element, resolver) {
1927
- if (!element) return;
1928
- const direct = normalizedHexColor(attribute(element, 'rgb'));
1929
- const themeIndex = boundedInteger(attribute(element, 'theme'), 11);
1930
- const indexed = boundedInteger(attribute(element, 'indexed'), 65535);
1931
- const automatic = booleanAttribute(element, 'auto');
1932
- const source = direct ?? (null === themeIndex ? void 0 : resolver.theme[themeIndex]) ?? (null === indexed ? void 0 : resolver.indexed[indexed]) ?? (automatic ? '000000' : void 0);
1933
- if (!source) return;
1934
- const tint = Number(attribute(element, 'tint'));
1935
- return `#${Number.isFinite(tint) && tint >= -1 && tint <= 1 ? tintXlsxColor(source, tint) : source}`;
1936
- }
1937
- function readThemeColors(theme) {
1938
- if (!theme) return defaultThemeColors;
1939
- const scheme = firstDescendant(theme, 'clrScheme');
1940
- if (!scheme) return defaultThemeColors;
1941
- return themeColorNames.map((name, index)=>{
1942
- const entry = directChild(scheme, name);
1943
- const color = entry ? drawingColor(directChildren(entry)[0]) : void 0;
1944
- return color ?? defaultThemeColors[index];
1945
- });
1946
- }
1947
- function readIndexedColors(styles) {
1948
- const indexed = firstDescendant(styles, 'indexedColors');
1949
- if (!indexed) return defaultIndexedColors;
1950
- const colors = directChildren(indexed, 'rgbColor').map((element)=>normalizedHexColor(attribute(element, 'rgb')));
1951
- return colors.every(Boolean) ? colors : defaultIndexedColors;
1952
- }
1953
- function drawingColor(element) {
1954
- if (!element) return;
1955
- return normalizedHexColor('sysClr' === element.localName ? attribute(element, 'lastClr') : attribute(element, 'val'));
1956
- }
1957
- function tintXlsxColor(color, tint) {
1958
- const [hue, saturation, lightness] = rgbToHsl([
1959
- 0,
1960
- 2,
1961
- 4
1962
- ].map((offset)=>Number.parseInt(color.slice(offset, offset + 2), 16) / 255));
1963
- const tintedLightness = tint < 0 ? lightness * (1 + tint) : 1 - (1 - lightness) * (1 - tint);
1964
- return hslToRgb(hue, saturation, tintedLightness).map((channel)=>Math.round(255 * channel)).map((channel)=>channel.toString(16).padStart(2, '0')).join('');
1965
- }
1966
- function rgbToHsl([red, green, blue]) {
1967
- const maximum = Math.max(red, green, blue);
1968
- const minimum = Math.min(red, green, blue);
1969
- const delta = maximum - minimum;
1970
- const lightness = (maximum + minimum) / 2;
1971
- if (0 === delta) return [
1972
- 0,
1973
- 0,
1974
- lightness
1975
- ];
1976
- const saturation = delta / (1 - Math.abs(2 * lightness - 1));
1977
- const hue = maximum === red ? ((green - blue) / delta + (green < blue ? 6 : 0)) / 6 : maximum === green ? ((blue - red) / delta + 2) / 6 : ((red - green) / delta + 4) / 6;
1978
- return [
1979
- hue,
1980
- saturation,
1981
- lightness
1982
- ];
1983
- }
1984
- function hslToRgb(hue, saturation, lightness) {
1985
- if (0 === saturation) return [
1986
- lightness,
1987
- lightness,
1988
- lightness
1989
- ];
1990
- const chroma = 2 * saturation * (lightness < 0.5 ? lightness : 1 - lightness);
1991
- const minimum = lightness - chroma / 2;
1992
- const channels = [
1993
- minimum,
1994
- minimum,
1995
- minimum
1996
- ];
1997
- const sector = 6 * hue;
1998
- switch(Math.floor(sector)){
1999
- case 0:
2000
- case 6:
2001
- channels[0] += chroma;
2002
- channels[1] += chroma * sector;
2003
- break;
2004
- case 1:
2005
- channels[0] += chroma * (2 - sector);
2006
- channels[1] += chroma;
2007
- break;
2008
- case 2:
2009
- channels[1] += chroma;
2010
- channels[2] += chroma * (sector - 2);
2011
- break;
2012
- case 3:
2013
- channels[1] += chroma * (4 - sector);
2014
- channels[2] += chroma;
2015
- break;
2016
- case 4:
2017
- channels[0] += chroma * (sector - 4);
2018
- channels[2] += chroma;
2019
- break;
2020
- case 5:
2021
- channels[0] += chroma;
2022
- channels[2] += chroma * (6 - sector);
2023
- break;
2024
- }
2025
- return channels;
2026
- }
2027
- function normalizedHexColor(value) {
2028
- if (!value || !/^[0-9a-f]{6,8}$/i.test(value)) return;
2029
- return value.slice(-6).toLowerCase();
2030
- }
2031
- function boundedInteger(value, maximum) {
2032
- if (null === value || !/^\d+$/.test(value)) return null;
2033
- const parsed = Number(value);
2034
- return Number.isSafeInteger(parsed) && parsed <= maximum ? parsed : null;
2035
- }
2036
- function booleanAttribute(element, name) {
2037
- const value = attribute(element, name)?.trim().toLowerCase();
2038
- return '1' === value || 'true' === value || 'on' === value;
2039
- }
2040
- const THEME_COLOR_NAMES = [
2041
- 'lt1',
2042
- 'dk1',
2043
- 'lt2',
2044
- 'dk2',
2045
- 'accent1',
2046
- 'accent2',
2047
- 'accent3',
2048
- 'accent4',
2049
- 'accent5',
2050
- 'accent6',
2051
- 'hlink',
2052
- 'folHlink'
2053
- ];
2054
- const MAX_INDEXED_COLOR = 255;
2055
- function readXlsxSemanticColorOrigin(element, colors) {
2056
- if (!element || attribute(element, 'rgb')) return;
2057
- const renderedColor = resolveXlsxColor(element, colors);
2058
- if (!renderedColor) return;
2059
- const tint = boundedTint(attribute(element, 'tint'));
2060
- const theme = work_xlsx_cell_style_origin_boundedInteger(attribute(element, 'theme'), THEME_COLOR_NAMES.length - 1);
2061
- if (null !== theme && colors.theme[theme]) return {
2062
- kind: 'theme',
2063
- baseColor: `#${colors.theme[theme]}`,
2064
- index: theme,
2065
- renderedColor,
2066
- ...null === tint ? {} : {
2067
- tint
2068
- }
2069
- };
2070
- const indexed = work_xlsx_cell_style_origin_boundedInteger(attribute(element, 'indexed'), MAX_INDEXED_COLOR);
2071
- if (null !== indexed && colors.indexed[indexed]) return {
2072
- kind: 'indexed',
2073
- baseColor: `#${colors.indexed[indexed]}`,
2074
- index: indexed,
2075
- renderedColor,
2076
- ...null === tint ? {} : {
2077
- tint
2078
- }
2079
- };
2080
- if (xlsxBooleanAttribute(element, 'auto')) return {
2081
- kind: 'automatic',
2082
- baseColor: '#000000',
2083
- renderedColor,
2084
- ...null === tint ? {} : {
2085
- tint
2086
- }
2087
- };
2088
- }
2089
- function withXlsxCellStyleOrigin(cell, origin) {
2090
- return origin && xlsxCellStyleOriginHasValues(origin) ? {
2091
- ...cell,
2092
- a3sXlsxStyleOrigin: origin
2093
- } : cell;
2094
- }
2095
- function xlsxCellStyleOrigin(cell) {
2096
- const candidate = cell?.a3sXlsxStyleOrigin;
2097
- if (!isRecord(candidate)) return;
2098
- const fontColor = normalizeXlsxSemanticColorOrigin(candidate.fontColor);
2099
- const fillColor = normalizeXlsxSemanticColorOrigin(candidate.fillColor);
2100
- const borderColors = normalizedBorderColors(candidate.borderColors);
2101
- const origin = {
2102
- ...fontColor ? {
2103
- fontColor
2104
- } : {},
2105
- ...fillColor ? {
2106
- fillColor
2107
- } : {},
2108
- ...borderColors ? {
2109
- borderColors
2110
- } : {}
2111
- };
2112
- return xlsxCellStyleOriginHasValues(origin) ? origin : void 0;
2113
- }
2114
- function xlsxSemanticColorMatchesValue(origin, value) {
2115
- return work_xlsx_cell_style_origin_normalizedColor(value) === origin.renderedColor.toLowerCase();
2116
- }
2117
- function xlsxColorElementMatchesOrigin(element, origin) {
2118
- if (!element || attribute(element, 'rgb')) return false;
2119
- if ('theme' === origin.kind) {
2120
- if (attribute(element, 'theme') !== String(origin.index)) return false;
2121
- } else if ('indexed' === origin.kind) {
2122
- if (attribute(element, 'indexed') !== String(origin.index)) return false;
2123
- } else if (!xlsxBooleanAttribute(element, 'auto')) return false;
2124
- const tint = boundedTint(attribute(element, 'tint'));
2125
- return tint === (origin.tint ?? null);
2126
- }
2127
- function applyXlsxSemanticColorOrigin(element, origin) {
2128
- for (const name of [
2129
- 'rgb',
2130
- 'theme',
2131
- 'indexed',
2132
- 'auto',
2133
- 'tint'
2134
- ])element.removeAttribute(name);
2135
- if ('theme' === origin.kind) element.setAttribute('theme', String(origin.index));
2136
- else if ('indexed' === origin.kind) element.setAttribute('indexed', String(origin.index));
2137
- else element.setAttribute('auto', '1');
2138
- if (void 0 !== origin.tint) element.setAttribute('tint', String(origin.tint));
2139
- }
2140
- function xlsxSemanticColorOriginKey(origin) {
2141
- return origin ? `${origin.kind}:${'index' in origin ? origin.index : ''}:${origin.baseColor}:${origin.renderedColor}:${origin.tint ?? ''}` : '';
2142
- }
2143
- function xlsxSemanticColorOriginSupported(origin, palette) {
2144
- if ('automatic' === origin.kind) return true;
2145
- return palette?.[origin.kind].get(origin.index)?.toLowerCase() === origin.baseColor.toLowerCase();
2146
- }
2147
- function prepareXlsxSemanticPalette(styles, theme, colors) {
2148
- const candidates = semanticPaletteCandidates(colors);
2149
- const supportedTheme = new Map();
2150
- let themeChanged = false;
2151
- const scheme = theme ? firstDescendant(theme, 'clrScheme') : void 0;
2152
- for (const [index, color] of candidates.theme){
2153
- const name = THEME_COLOR_NAMES[index];
2154
- const entry = name && scheme ? directChild(scheme, name) : void 0;
2155
- if (entry) {
2156
- themeChanged = writeThemeColor(entry, color) || themeChanged;
2157
- supportedTheme.set(index, color);
2158
- }
2159
- }
2160
- const supportedIndexed = new Map();
2161
- let stylesChanged = false;
2162
- if (candidates.indexed.size) {
2163
- const colors = ensureXlsxStyleCollection(styles, 'colors', [
2164
- 'extLst'
2165
- ]);
2166
- let indexedColors = directChild(colors, 'indexedColors');
2167
- if (!indexedColors) {
2168
- indexedColors = styles.createElementNS(styles.documentElement.namespaceURI, 'indexedColors');
2169
- colors.prepend(indexedColors);
2170
- stylesChanged = true;
2171
- }
2172
- const resolver = createXlsxColorResolver(styles, theme);
2173
- const highestIndex = Math.max(...candidates.indexed.keys());
2174
- while(directChildren(indexedColors, 'rgbColor').length <= highestIndex){
2175
- const index = directChildren(indexedColors, 'rgbColor').length;
2176
- const element = styles.createElementNS(styles.documentElement.namespaceURI, 'rgbColor');
2177
- element.setAttribute('rgb', `FF${(resolver.indexed[index] ?? '000000').toUpperCase()}`);
2178
- indexedColors.append(element);
2179
- stylesChanged = true;
2180
- }
2181
- const entries = directChildren(indexedColors, 'rgbColor');
2182
- for (const [index, color] of candidates.indexed){
2183
- const expected = `FF${color.slice(1).toUpperCase()}`;
2184
- const entry = entries[index];
2185
- if (entry) {
2186
- if (attribute(entry, 'rgb')?.toUpperCase() !== expected) {
2187
- entry.setAttribute('rgb', expected);
2188
- stylesChanged = true;
2189
- }
2190
- supportedIndexed.set(index, color);
2191
- }
2192
- }
2193
- }
2194
- return {
2195
- palette: {
2196
- indexed: supportedIndexed,
2197
- theme: supportedTheme
2198
- },
2199
- stylesChanged,
2200
- themeChanged
2201
- };
2202
- }
2203
- function semanticPaletteCandidates(colors) {
2204
- const theme = new Map();
2205
- const indexed = new Map();
2206
- const themeConflicts = new Set();
2207
- const indexedConflicts = new Set();
2208
- for (const color of colors){
2209
- if ('automatic' === color.kind) continue;
2210
- const target = 'theme' === color.kind ? theme : indexed;
2211
- const conflicts = 'theme' === color.kind ? themeConflicts : indexedConflicts;
2212
- const current = target.get(color.index);
2213
- if (current && current.toLowerCase() !== color.baseColor.toLowerCase()) conflicts.add(color.index);
2214
- else if (!current) target.set(color.index, color.baseColor);
2215
- }
2216
- for (const index of themeConflicts)theme.delete(index);
2217
- for (const index of indexedConflicts)indexed.delete(index);
2218
- return {
2219
- indexed,
2220
- theme
2221
- };
2222
- }
2223
- function xlsxCellStyleOriginSemanticColors(origin) {
2224
- return [
2225
- origin.fontColor,
2226
- origin.fillColor,
2227
- ...Object.values(origin.borderColors ?? {})
2228
- ].filter((value)=>Boolean(value));
2229
- }
2230
- function writeThemeColor(entry, color) {
2231
- const current = directChildren(entry)[0];
2232
- if (current?.localName === 'srgbClr' && attribute(current, 'val')?.toLowerCase() === color.slice(1).toLowerCase()) return false;
2233
- for (const child of directChildren(entry))child.remove();
2234
- const qualifiedName = entry.prefix ? `${entry.prefix}:srgbClr` : 'srgbClr';
2235
- const replacement = entry.ownerDocument.createElementNS(entry.namespaceURI, qualifiedName);
2236
- replacement.setAttribute('val', color.slice(1).toUpperCase());
2237
- entry.append(replacement);
2238
- return true;
2239
- }
2240
- function normalizedBorderColors(value) {
2241
- if (!isRecord(value)) return;
2242
- const result = {};
2243
- for (const side of [
2244
- 'bottom',
2245
- 'diagonal',
2246
- 'left',
2247
- 'right',
2248
- 'top'
2249
- ]){
2250
- const color = normalizeXlsxSemanticColorOrigin(value[side]);
2251
- if (color) result[side] = color;
2252
- }
2253
- return Object.keys(result).length ? result : void 0;
2254
- }
2255
- function normalizeXlsxSemanticColorOrigin(value) {
2256
- if (!isRecord(value)) return;
2257
- const baseColor = work_xlsx_cell_style_origin_normalizedColor(value.baseColor);
2258
- const renderedColor = work_xlsx_cell_style_origin_normalizedColor(value.renderedColor);
2259
- const tint = normalizedTint(value.tint);
2260
- if (!baseColor || !renderedColor || void 0 === tint) return;
2261
- if ('automatic' === value.kind) return {
2262
- kind: 'automatic',
2263
- baseColor,
2264
- renderedColor,
2265
- ...null === tint ? {} : {
2266
- tint
2267
- }
2268
- };
2269
- const maximum = 'theme' === value.kind ? THEME_COLOR_NAMES.length - 1 : MAX_INDEXED_COLOR;
2270
- const index = boundedNumber(value.index, maximum);
2271
- if ('theme' !== value.kind && 'indexed' !== value.kind || null === index) return;
2272
- return {
2273
- kind: value.kind,
2274
- baseColor,
2275
- index,
2276
- renderedColor,
2277
- ...null === tint ? {} : {
2278
- tint
2279
- }
2280
- };
2281
- }
2282
- function xlsxCellStyleOriginHasValues(origin) {
2283
- return Boolean(origin.fontColor || origin.fillColor || Object.keys(origin.borderColors ?? {}).length);
2284
- }
2285
- function work_xlsx_cell_style_origin_normalizedColor(value) {
2286
- const rgb = xlsxRgbColor(value);
2287
- return rgb ? `#${rgb.slice(-6).toLowerCase()}` : null;
2288
- }
2289
- function normalizedTint(value) {
2290
- if (void 0 === value) return null;
2291
- return 'number' == typeof value && Number.isFinite(value) && value >= -1 && value <= 1 ? value : void 0;
2292
- }
2293
- function boundedTint(value) {
2294
- if (null === value) return null;
2295
- const tint = Number(value);
2296
- return Number.isFinite(tint) && tint >= -1 && tint <= 1 ? tint : null;
2297
- }
2298
- function work_xlsx_cell_style_origin_boundedInteger(value, maximum) {
2299
- if (null === value || !/^\d+$/.test(value)) return null;
2300
- return boundedNumber(Number(value), maximum);
2301
- }
2302
- function boundedNumber(value, maximum) {
2303
- return 'number' == typeof value && Number.isSafeInteger(value) && value >= 0 && value <= maximum ? value : null;
2304
- }
2305
- function xlsxBooleanAttribute(element, name) {
2306
- const value = attribute(element, name)?.trim().toLowerCase();
2307
- return '1' === value || 'true' === value || 'on' === value;
2308
- }
2309
- function isRecord(value) {
2310
- return 'object' == typeof value && null !== value && !Array.isArray(value);
2311
- }
2312
- const XLSX_GRADIENT_FILL_CELL_KEY = 'a3sXlsxGradientFill';
2313
- const MAX_XLSX_GRADIENT_STOPS = 256;
2314
- function readXlsxGradientFill(element, colors) {
2315
- if (!element) return;
2316
- const type = attribute(element, 'type') ?? 'linear';
2317
- if ('linear' !== type && 'path' !== type) return;
2318
- const children = directChildren(element);
2319
- if (children.length < 2 || children.length > MAX_XLSX_GRADIENT_STOPS || children.some((child)=>'stop' !== child.localName)) return;
2320
- const stops = [];
2321
- for (const stop of children){
2322
- const position = unitInterval(attribute(stop, 'position'));
2323
- const stopChildren = directChildren(stop);
2324
- const colorElement = stopChildren[0];
2325
- if (null === position || 1 !== stopChildren.length || colorElement?.localName !== 'color') return;
2326
- const renderedColor = resolveXlsxColor(colorElement, colors);
2327
- const color = work_xlsx_gradient_fill_normalizedColor(renderedColor);
2328
- if (!color || (stops.at(-1)?.position ?? 0) > position) return;
2329
- const colorOrigin = readXlsxSemanticColorOrigin(colorElement, colors);
2330
- stops.push({
2331
- color,
2332
- ...colorOrigin ? {
2333
- colorOrigin
2334
- } : {},
2335
- position
2336
- });
2337
- }
2338
- if ('linear' === type) {
2339
- const degree = optionalFiniteNumber(attribute(element, 'degree'), 0);
2340
- return null === degree ? void 0 : {
2341
- degree,
2342
- stops,
2343
- type
2344
- };
2345
- }
2346
- const left = optionalUnitInterval(attribute(element, 'left'), 0);
2347
- const right = optionalUnitInterval(attribute(element, 'right'), 0);
2348
- const top = optionalUnitInterval(attribute(element, 'top'), 0);
2349
- const bottom = optionalUnitInterval(attribute(element, 'bottom'), 0);
2350
- if (null === left || null === right || null === top || null === bottom || left > right || top > bottom) return;
2351
- return {
2352
- bottom,
2353
- left,
2354
- right,
2355
- stops,
2356
- top,
2357
- type
2358
- };
2359
- }
2360
- function withXlsxGradientFill(cell, fill) {
2361
- const normalized = normalizeXlsxGradientFill(fill);
2362
- return normalized ? {
2363
- ...cell,
2364
- [XLSX_GRADIENT_FILL_CELL_KEY]: normalized
2365
- } : cell;
2366
- }
2367
- function deleteXlsxGradientFill(cell) {
2368
- delete cell[XLSX_GRADIENT_FILL_CELL_KEY];
2369
- }
2370
- function xlsxGradientFill(cell) {
2371
- return normalizeXlsxGradientFill(cell?.[XLSX_GRADIENT_FILL_CELL_KEY]);
2372
- }
2373
- function activeXlsxGradientFill(cell) {
2374
- const fill = xlsxGradientFill(cell);
2375
- return fill && work_xlsx_gradient_fill_normalizedColor(cell?.bg) === xlsxGradientFillFallbackColor(fill) ? fill : void 0;
2376
- }
2377
- function normalizeXlsxGradientFill(value) {
2378
- if (!work_xlsx_gradient_fill_isRecord(value) || !Array.isArray(value.stops)) return;
2379
- if (value.stops.length < 2 || value.stops.length > MAX_XLSX_GRADIENT_STOPS) return;
2380
- const stops = [];
2381
- for (const valueStop of value.stops){
2382
- if (!work_xlsx_gradient_fill_isRecord(valueStop)) return;
2383
- const position = normalizedUnitInterval(valueStop.position);
2384
- const color = work_xlsx_gradient_fill_normalizedColor(valueStop.color);
2385
- if (null === position || !color || (stops.at(-1)?.position ?? 0) > position) return;
2386
- const colorOrigin = normalizeXlsxSemanticColorOrigin(valueStop.colorOrigin);
2387
- stops.push({
2388
- color,
2389
- ...colorOrigin ? {
2390
- colorOrigin
2391
- } : {},
2392
- position
2393
- });
2394
- }
2395
- if ('linear' === value.type) {
2396
- const degree = finiteNumber(value.degree);
2397
- return null === degree ? void 0 : {
2398
- degree,
2399
- stops,
2400
- type: 'linear'
2401
- };
2402
- }
2403
- if ('path' !== value.type) return;
2404
- const left = normalizedUnitInterval(value.left);
2405
- const right = normalizedUnitInterval(value.right);
2406
- const top = normalizedUnitInterval(value.top);
2407
- const bottom = normalizedUnitInterval(value.bottom);
2408
- if (null === left || null === right || null === top || null === bottom || left > right || top > bottom) return;
2409
- return {
2410
- bottom,
2411
- left,
2412
- right,
2413
- stops,
2414
- top,
2415
- type: 'path'
2416
- };
2417
- }
2418
- function xlsxGradientFillFallbackColor(fill) {
2419
- return fill.stops[0]?.color ?? '#ffffff';
2420
- }
2421
- function xlsxGradientFillSemanticColors(fill) {
2422
- return (fill?.stops ?? []).flatMap((stop)=>stop.colorOrigin ? [
2423
- stop.colorOrigin
2424
- ] : []);
2425
- }
2426
- function xlsxGradientFillKey(fill) {
2427
- if (!fill) return '';
2428
- const geometry = 'linear' === fill.type ? `linear:${fill.degree}` : `path:${fill.left}:${fill.right}:${fill.top}:${fill.bottom}`;
2429
- return `${geometry}:${fill.stops.map((stop)=>`${stop.position}:${stop.color}:${xlsxSemanticColorOriginKey(stop.colorOrigin)}`).join('|')}`;
2430
- }
2431
- function unitInterval(value) {
2432
- if (null === value || !value.trim()) return null;
2433
- return normalizedUnitInterval(Number(value));
2434
- }
2435
- function optionalUnitInterval(value, fallback) {
2436
- return null === value ? fallback : unitInterval(value);
2437
- }
2438
- function normalizedUnitInterval(value) {
2439
- return 'number' == typeof value && Number.isFinite(value) && value >= 0 && value <= 1 ? value : null;
2440
- }
2441
- function optionalFiniteNumber(value, fallback) {
2442
- if (null === value) return fallback;
2443
- if (!value.trim()) return null;
2444
- return finiteNumber(Number(value));
2445
- }
2446
- function finiteNumber(value) {
2447
- return 'number' == typeof value && Number.isFinite(value) ? value : null;
2448
- }
2449
- function work_xlsx_gradient_fill_normalizedColor(value) {
2450
- const rgb = xlsxRgbColor(value);
2451
- return rgb ? `#${rgb.slice(-6).toLowerCase()}` : null;
2452
- }
2453
- function work_xlsx_gradient_fill_isRecord(value) {
2454
- return 'object' == typeof value && null !== value && !Array.isArray(value);
2455
- }
2456
- const XLSX_PATTERN_FILL_CELL_KEY = 'a3sXlsxPatternFill';
2457
- const xlsxPatternFillTypes = [
2458
- 'darkDown',
2459
- 'darkGray',
2460
- 'darkGrid',
2461
- 'darkHorizontal',
2462
- 'darkTrellis',
2463
- 'darkUp',
2464
- 'darkVertical',
2465
- 'gray0625',
2466
- 'gray125',
2467
- 'lightDown',
2468
- 'lightGray',
2469
- 'lightGrid',
2470
- 'lightHorizontal',
2471
- 'lightTrellis',
2472
- 'lightUp',
2473
- 'lightVertical',
2474
- 'mediumGray'
2475
- ];
2476
- const xlsxPatternFillTypeSet = new Set(xlsxPatternFillTypes);
2477
- function readXlsxPatternFill(pattern, colors) {
2478
- if (!pattern) return;
2479
- const patternType = attribute(pattern, 'patternType');
2480
- if (!patternType || !isXlsxPatternFillType(patternType)) return;
2481
- const foreground = directChild(pattern, 'fgColor');
2482
- const background = directChild(pattern, 'bgColor');
2483
- const foregroundColor = foreground ? resolveXlsxColor(foreground, colors) : '#000000';
2484
- const backgroundColor = background ? resolveXlsxColor(background, colors) : '#ffffff';
2485
- const normalizedForegroundColor = work_xlsx_pattern_fill_normalizedColor(foregroundColor);
2486
- const normalizedBackgroundColor = work_xlsx_pattern_fill_normalizedColor(backgroundColor);
2487
- if (!normalizedForegroundColor || !normalizedBackgroundColor) return;
2488
- const foregroundColorOrigin = readXlsxSemanticColorOrigin(foreground, colors);
2489
- const backgroundColorOrigin = readXlsxSemanticColorOrigin(background, colors);
2490
- return {
2491
- backgroundColor: normalizedBackgroundColor,
2492
- ...backgroundColorOrigin ? {
2493
- backgroundColorOrigin
2494
- } : {},
2495
- foregroundColor: normalizedForegroundColor,
2496
- ...foregroundColorOrigin ? {
2497
- foregroundColorOrigin
2498
- } : {},
2499
- patternType
2500
- };
2501
- }
2502
- function withXlsxPatternFill(cell, fill) {
2503
- const normalized = normalizeXlsxPatternFill(fill);
2504
- return normalized ? {
2505
- ...cell,
2506
- [XLSX_PATTERN_FILL_CELL_KEY]: normalized
2507
- } : cell;
2508
- }
2509
- function deleteXlsxPatternFill(cell) {
2510
- delete cell[XLSX_PATTERN_FILL_CELL_KEY];
2511
- }
2512
- function xlsxPatternFill(cell) {
2513
- return normalizeXlsxPatternFill(cell?.[XLSX_PATTERN_FILL_CELL_KEY]);
2514
- }
2515
- function activeXlsxPatternFill(cell) {
2516
- const fill = xlsxPatternFill(cell);
2517
- return fill && work_xlsx_pattern_fill_normalizedColor(cell?.bg) === fill.backgroundColor ? fill : void 0;
2518
- }
2519
- function normalizeXlsxPatternFill(value) {
2520
- if (!work_xlsx_pattern_fill_isRecord(value) || !isXlsxPatternFillType(value.patternType)) return;
2521
- const foregroundColor = work_xlsx_pattern_fill_normalizedColor(value.foregroundColor);
2522
- const backgroundColor = work_xlsx_pattern_fill_normalizedColor(value.backgroundColor);
2523
- if (!foregroundColor || !backgroundColor) return;
2524
- const foregroundColorOrigin = normalizeXlsxSemanticColorOrigin(value.foregroundColorOrigin);
2525
- const backgroundColorOrigin = normalizeXlsxSemanticColorOrigin(value.backgroundColorOrigin);
2526
- return {
2527
- backgroundColor,
2528
- ...backgroundColorOrigin ? {
2529
- backgroundColorOrigin
2530
- } : {},
2531
- foregroundColor,
2532
- ...foregroundColorOrigin ? {
2533
- foregroundColorOrigin
2534
- } : {},
2535
- patternType: value.patternType
2536
- };
2537
- }
2538
- function xlsxPatternFillSemanticColors(fill) {
2539
- return fill ? [
2540
- fill.foregroundColorOrigin,
2541
- fill.backgroundColorOrigin
2542
- ].filter((value)=>Boolean(value)) : [];
2543
- }
2544
- function xlsxPatternFillKey(fill) {
2545
- return fill ? [
2546
- fill.patternType,
2547
- fill.foregroundColor,
2548
- xlsxSemanticColorOriginKey(fill.foregroundColorOrigin),
2549
- fill.backgroundColor,
2550
- xlsxSemanticColorOriginKey(fill.backgroundColorOrigin)
2551
- ].join(':') : '';
2552
- }
2553
- function isXlsxPatternFillType(value) {
2554
- return 'string' == typeof value && xlsxPatternFillTypeSet.has(value);
2555
- }
2556
- function work_xlsx_pattern_fill_normalizedColor(value) {
2557
- const rgb = xlsxRgbColor(value);
2558
- return rgb ? `#${rgb.slice(-6).toLowerCase()}` : null;
2559
- }
2560
- function work_xlsx_pattern_fill_isRecord(value) {
2561
- return 'object' == typeof value && null !== value && !Array.isArray(value);
2562
- }
2563
- const SPREADSHEET_SHOWN_COMMENT_CELLS_PROPERTY = '__a3sShownCommentCells';
2564
- const spreadsheetMatrixProfiles = new WeakMap();
2565
- function freezeImportedSpreadsheetCell(cell) {
2566
- const gradientFill = cell[XLSX_GRADIENT_FILL_CELL_KEY];
2567
- if (gradientFill && 'object' == typeof gradientFill) {
2568
- const stops = gradientFill.stops;
2569
- if (Array.isArray(stops)) {
2570
- for (const stop of stops)if (stop && 'object' == typeof stop) {
2571
- freezeObject(stop.colorOrigin);
2572
- freezeObject(stop);
2573
- }
2574
- Object.freeze(stops);
2575
- }
2576
- }
2577
- freezeObject(gradientFill);
2578
- const patternFill = cell[XLSX_PATTERN_FILL_CELL_KEY];
2579
- if (patternFill && 'object' == typeof patternFill) {
2580
- const record = patternFill;
2581
- freezeObject(record.foregroundColorOrigin);
2582
- freezeObject(record.backgroundColorOrigin);
2583
- }
2584
- freezeObject(patternFill);
2585
- freezeObject(cell.mc);
2586
- freezeObject(cell.ct?.s);
2587
- freezeObject(cell.ct);
2588
- freezeObject(cell.ps);
2589
- freezeObject(cell.hl);
2590
- freezeObject(cell.spl);
2591
- return Object.freeze(cell);
2592
- }
2593
- function registerImportedSpreadsheetMatrix(data, options) {
2594
- data.length = Math.max(data.length, options.rowCount);
2595
- data[0] ??= [];
2596
- for (const rowIndex of sparseArrayIndexes(data)){
2597
- const row = data[rowIndex];
2598
- if (row) {
2599
- row.length = Math.max(row.length, options.columnCount);
2600
- Object.freeze(row);
2601
- }
2602
- }
2603
- registerSpreadsheetMatrixProfile(data, options);
2604
- }
2605
- function registerDerivedSpreadsheetMatrix(data, source, changes) {
2606
- const sourceProfile = spreadsheetMatrixProfiles.get(source);
2607
- if (!sourceProfile?.fortuneReady) return false;
2608
- const formulaCells = new Map(sourceProfile.formulaCells.map(({ column, row })=>[
2609
- spreadsheetCoordinateKey(row, column),
2610
- {
2611
- column,
2612
- row
2613
- }
2614
- ]));
2615
- const shownCommentCells = new Map(sourceProfile.shownCommentCells.map(({ c, r })=>[
2616
- spreadsheetCoordinateKey(r, c),
2617
- {
2618
- c,
2619
- r
2620
- }
2621
- ]));
2622
- let populatedCellCount = sourceProfile.populatedCellCount;
2623
- let protectionCellKey = sourceProfile.protectionCellKey;
2624
- let protectionCells;
2625
- for (const { column, current, previous, row } of changes){
2626
- const coordinateKey = spreadsheetCoordinateKey(row, column);
2627
- if (null == previous && null != current) populatedCellCount += 1;
2628
- if (null != previous && null == current) populatedCellCount -= 1;
2629
- if (current?.f) formulaCells.set(coordinateKey, {
2630
- column,
2631
- row
2632
- });
2633
- else formulaCells.delete(coordinateKey);
2634
- if (current?.ps?.isShow) shownCommentCells.set(coordinateKey, {
2635
- c: column,
2636
- r: row
2637
- });
2638
- else shownCommentCells.delete(coordinateKey);
2639
- if (spreadsheetProtectionSignature(previous) !== spreadsheetProtectionSignature(current)) {
2640
- protectionCells ??= spreadsheetProtectionCells(protectionCellKey);
2641
- const signature = spreadsheetProtectionSignature(current);
2642
- if (null === signature) protectionCells.delete(coordinateKey);
2643
- else protectionCells.set(coordinateKey, signature);
2644
- }
2645
- const changedRow = data[row];
2646
- if (changedRow && !Object.isFrozen(changedRow)) Object.freeze(changedRow);
2647
- }
2648
- if (protectionCells) protectionCellKey = Array.from(protectionCells, ([coordinate, value])=>({
2649
- coordinate,
2650
- value
2651
- })).sort((left, right)=>compareSpreadsheetCoordinates(left.coordinate, right.coordinate)).map(({ coordinate, value })=>`${coordinate}:${value}`).join(',');
2652
- registerSpreadsheetMatrixProfile(data, {
2653
- columnCount: Math.max(sourceProfile.columnCount, ...changes.map(({ column, row })=>Math.max(column + 1, data[row]?.length ?? 0))),
2654
- formulaCells: Array.from(formulaCells.values()).sort(compareSpreadsheetCells),
2655
- fortuneReady: true,
2656
- populatedCellCount: Math.max(0, populatedCellCount),
2657
- protectionCellKey,
2658
- rowCount: Math.max(sourceProfile.rowCount, data.length, ...changes.map(({ row })=>row + 1)),
2659
- shownCommentCells: Array.from(shownCommentCells.values()).sort((left, right)=>left.r - right.r || left.c - right.c)
2660
- }, {
2661
- historyRoot: sourceProfile.historyRoot,
2662
- historyState: changes.some(({ current, previous })=>!sameSpreadsheetHistoryValue(current, previous)) ? Object.freeze({}) : sourceProfile.historyState
2663
- });
2664
- return true;
2665
- }
2666
- function spreadsheetMatrixProfile(data) {
2667
- return data ? spreadsheetMatrixProfiles.get(data) : void 0;
2668
- }
2669
- function attachSpreadsheetShownCommentCells(data, cells) {
2670
- Object.defineProperty(data, SPREADSHEET_SHOWN_COMMENT_CELLS_PROPERTY, {
2671
- configurable: false,
2672
- enumerable: false,
2673
- value: cells,
2674
- writable: false
2675
- });
2676
- }
2677
- function registerSpreadsheetMatrixProfile(data, options, history) {
2678
- const initialHistoryState = Object.freeze({});
2679
- const profile = Object.freeze({
2680
- columnCount: options.columnCount,
2681
- formulaCells: Object.freeze(options.formulaCells.map((cell)=>Object.freeze({
2682
- ...cell
2683
- }))),
2684
- fortuneReady: options.fortuneReady,
2685
- historyRoot: history?.historyRoot ?? initialHistoryState,
2686
- historyState: history?.historyState ?? initialHistoryState,
2687
- populatedCellCount: options.populatedCellCount,
2688
- protectionCellKey: options.protectionCellKey,
2689
- rowCount: options.rowCount,
2690
- shownCommentCells: Object.freeze(options.shownCommentCells.map((cell)=>Object.freeze({
2691
- ...cell
2692
- })))
2693
- });
2694
- attachSpreadsheetShownCommentCells(data, profile.shownCommentCells);
2695
- Object.freeze(data);
2696
- spreadsheetMatrixProfiles.set(data, profile);
2697
- }
2698
- function spreadsheetProtectionCells(value) {
2699
- const cells = new Map();
2700
- for (const entry of value.split(',')){
2701
- if (!entry) continue;
2702
- const separator = entry.indexOf(':');
2703
- if (!(separator <= 0)) cells.set(entry.slice(0, separator), entry.slice(separator + 1));
2704
- }
2705
- return cells;
2706
- }
2707
- function spreadsheetProtectionSignature(cell) {
2708
- const hidden = cell?.hi;
2709
- if (cell?.lo === void 0 && void 0 === hidden) return null;
2710
- return `${cell?.lo ?? ''}:${hidden ?? ''}`;
2711
- }
2712
- function spreadsheetCoordinateKey(row, column) {
2713
- return `${row}_${column}`;
2714
- }
2715
- function compareSpreadsheetCoordinates(left, right) {
2716
- const [leftRow = 0, leftColumn = 0] = left.split('_').map(Number);
2717
- const [rightRow = 0, rightColumn = 0] = right.split('_').map(Number);
2718
- return leftRow - rightRow || leftColumn - rightColumn;
2719
- }
2720
- function compareSpreadsheetCells(left, right) {
2721
- return left.row - right.row || left.column - right.column;
2722
- }
2723
- function freezeObject(value) {
2724
- if (value && 'object' == typeof value) Object.freeze(value);
2725
- }
2726
- const DEFAULT_PROTECTION_HINT = '此工作表已受保护。若要更改锁定的单元格,请先取消工作表保护。';
2727
- function defaultSheetProtectionAuthority(enabled = false) {
2728
- return {
2729
- sheet: enabled ? 1 : 0,
2730
- selectLockedCells: 1,
2731
- selectunLockedCells: 1,
2732
- formatCells: 0,
2733
- formatColumns: 0,
2734
- formatRows: 0,
2735
- insertColumns: 0,
2736
- insertRows: 0,
2737
- insertHyperlinks: 0,
2738
- deleteColumns: 0,
2739
- deleteRows: 0,
2740
- sort: 0,
2741
- filter: 0,
2742
- usePivotTablereports: 0,
2743
- editObjects: 0,
2744
- editScenarios: 0,
2745
- hintText: '',
2746
- defaultSheetHintText: DEFAULT_PROTECTION_HINT,
2747
- allowRangeList: [],
2748
- cellProtectionRanges: []
2749
- };
2750
- }
2751
- function sheetProtectionAuthority(sheet) {
2752
- return normalizeSheetProtectionAuthority(sheet.config?.authority);
2753
- }
2754
- function normalizeSheetProtectionAuthority(source) {
2755
- const defaults = defaultSheetProtectionAuthority();
2756
- if (!source || 'object' != typeof source) return defaults;
2757
- const authority = source;
2758
- return {
2759
- sheet: flag(authority.sheet, defaults.sheet),
2760
- selectLockedCells: flag(authority.selectLockedCells, defaults.selectLockedCells),
2761
- selectunLockedCells: flag(authority.selectunLockedCells, defaults.selectunLockedCells),
2762
- formatCells: flag(authority.formatCells, defaults.formatCells),
2763
- formatColumns: flag(authority.formatColumns, defaults.formatColumns),
2764
- formatRows: flag(authority.formatRows, defaults.formatRows),
2765
- insertColumns: flag(authority.insertColumns, defaults.insertColumns),
2766
- insertRows: flag(authority.insertRows, defaults.insertRows),
2767
- insertHyperlinks: flag(authority.insertHyperlinks, defaults.insertHyperlinks),
2768
- deleteColumns: flag(authority.deleteColumns, defaults.deleteColumns),
2769
- deleteRows: flag(authority.deleteRows, defaults.deleteRows),
2770
- sort: flag(authority.sort, defaults.sort),
2771
- filter: flag(authority.filter, defaults.filter),
2772
- usePivotTablereports: flag(authority.usePivotTablereports, defaults.usePivotTablereports),
2773
- editObjects: flag(authority.editObjects, defaults.editObjects),
2774
- editScenarios: flag(authority.editScenarios, defaults.editScenarios),
2775
- hintText: stringValue(authority.hintText),
2776
- defaultSheetHintText: stringValue(authority.defaultSheetHintText) || DEFAULT_PROTECTION_HINT,
2777
- allowRangeList: editableRangeList(authority.allowRangeList),
2778
- cellProtectionRanges: cellProtectionRangeList(authority.cellProtectionRanges),
2779
- xlsxAttributes: stringRecord(authority.xlsxAttributes)
2780
- };
2781
- }
2782
- function importedSheetProtectionAuthority(authority, cellProtectionRanges) {
2783
- if (!authority && !cellProtectionRanges.length) return;
2784
- const normalized = normalizeSheetProtectionAuthority(authority);
2785
- normalized.cellProtectionRanges = [
2786
- ...cellProtectionRanges,
2787
- ...normalized.allowRangeList.filter((range)=>!editableRangeRequiresCredentials(range)).flatMap((range)=>work_spreadsheet_ranges_parseSpreadsheetCellRanges(range.sqref) ?? []).map((range)=>({
2788
- range,
2789
- locked: false,
2790
- hidden: false
2791
- }))
2792
- ];
2793
- return normalized;
2794
- }
2795
- function withSheetProtection(sheet, enabled) {
2796
- const authority = sheetProtectionAuthority(sheet);
2797
- authority.sheet = enabled ? 1 : 0;
2798
- return withAuthority(sheet, authority);
2799
- }
2800
- function withSheetSelectionPermissions(sheet, permissions) {
2801
- const authority = sheetProtectionAuthority(sheet);
2802
- if (void 0 !== permissions.selectLockedCells) authority.selectLockedCells = permissions.selectLockedCells ? 1 : 0;
2803
- if (void 0 !== permissions.selectUnlockedCells) authority.selectunLockedCells = permissions.selectUnlockedCells ? 1 : 0;
2804
- return withAuthority(sheet, authority);
2805
- }
2806
- function withEditableRange(sheet, index, editableRange) {
2807
- const authority = sheetProtectionAuthority(sheet);
2808
- const nextRange = {
2809
- name: editableRange.name.trim(),
2810
- sqref: canonicalRangeReference(editableRange.sqref),
2811
- hintText: editableRange.hintText?.trim() || void 0,
2812
- xlsxAttributes: editableRange.xlsxAttributes
2813
- };
2814
- if (null !== index && authority.allowRangeList[index]) authority.allowRangeList[index] = nextRange;
2815
- else authority.allowRangeList.push(nextRange);
2816
- const ranges = work_spreadsheet_ranges_parseSpreadsheetCellRanges(nextRange.sqref) ?? [];
2817
- const next = withCellProtection(sheet, ranges, false);
2818
- const nextAuthority = sheetProtectionAuthority(next);
2819
- nextAuthority.allowRangeList = authority.allowRangeList;
2820
- return withAuthority(next, nextAuthority);
2821
- }
2822
- function withoutEditableRange(sheet, index) {
2823
- const authority = sheetProtectionAuthority(sheet);
2824
- const removed = authority.allowRangeList[index];
2825
- if (!removed) return sheet;
2826
- authority.allowRangeList.splice(index, 1);
2827
- const removedRanges = work_spreadsheet_ranges_parseSpreadsheetCellRanges(removed.sqref) ?? [];
2828
- let next = withCellProtection(sheet, removedRanges, true);
2829
- for (const editableRange of authority.allowRangeList)if (!editableRangeRequiresCredentials(editableRange)) next = withCellProtection(next, work_spreadsheet_ranges_parseSpreadsheetCellRanges(editableRange.sqref) ?? [], false);
2830
- const nextAuthority = sheetProtectionAuthority(next);
2831
- nextAuthority.allowRangeList = authority.allowRangeList;
2832
- return withAuthority(next, nextAuthority);
2833
- }
2834
- function withCellProtection(sheet, ranges, locked, hidden = false) {
2835
- if (!ranges.length) return sheet;
2836
- const data = cloneSparseMatrix(sheet.data);
2837
- let rowCount = Math.max(sheet.row ?? 0, data.length);
2838
- let columnCount = Math.max(sheet.column ?? 0, sparseMatrixColumnCount(data));
2839
- for (const range of ranges){
2840
- rowCount = Math.max(rowCount, range.row[1] + 1);
2841
- columnCount = Math.max(columnCount, range.column[1] + 1);
2842
- for (const [row, values] of spreadsheet_sparse_sparseArrayEntries(data))if (!(row < range.row[0]) && !(row > range.row[1])) for (const [column, source] of spreadsheet_sparse_sparseArrayEntries(values)){
2843
- if (column < range.column[0] || column > range.column[1]) continue;
2844
- const cell = {
2845
- ...source ?? {}
2846
- };
2847
- cell.lo = locked ? 1 : 0;
2848
- if (hidden) cell.hi = 1;
2849
- else if (void 0 !== cell.hi) delete cell.hi;
2850
- data[row][column] = cell;
2851
- }
2852
- }
2853
- normalizeMatrix(data, rowCount, columnCount);
2854
- const authority = sheetProtectionAuthority(sheet);
2855
- authority.cellProtectionRanges.push(...ranges.map((range)=>({
2856
- range,
2857
- locked,
2858
- hidden
2859
- })));
2860
- return withAuthority({
2861
- ...sheet,
2862
- row: rowCount,
2863
- column: columnCount,
2864
- data
2865
- }, authority);
2866
- }
2867
- function editableRangeRequiresCredentials(range) {
2868
- const attributes = range.xlsxAttributes ?? {};
2869
- return Boolean(attributes.password || attributes.hashValue || attributes.saltValue || attributes.securityDescriptor || attributes.securitydescriptor);
2870
- }
2871
- function sheetHasProtectionState(sheet) {
2872
- const authority = sheetProtectionAuthority(sheet);
2873
- if (1 === authority.sheet || authority.allowRangeList.length || Object.keys(authority.xlsxAttributes ?? {}).length) return true;
2874
- return (sheet.data ?? []).some((row)=>row.some((cell)=>cell?.lo !== void 0 || cell?.hi !== void 0));
2875
- }
2876
- function protectedSheetCount(sheets) {
2877
- return sheets.filter((sheet)=>1 === sheetProtectionAuthority(sheet).sheet).length;
2878
- }
2879
- function unlockedCellCount(sheet) {
2880
- return (sheet.data ?? []).reduce((total, row)=>total + row.reduce((rowTotal, cell)=>rowTotal + (cell?.lo === 0 ? 1 : 0), 0), 0);
2881
- }
2882
- function spreadsheetProtectionKey(sheets) {
2883
- return sheets.map((sheet)=>{
2884
- const authority = sheetProtectionAuthority(sheet);
2885
- const profile = spreadsheetMatrixProfile(sheet.data);
2886
- let protectionCellKey = profile?.protectionCellKey;
2887
- if (void 0 === protectionCellKey) {
2888
- const cells = [];
2889
- for (const [row, values] of spreadsheet_sparse_sparseArrayEntries(sheet.data))for (const [column, cell] of spreadsheet_sparse_sparseArrayEntries(values)){
2890
- const hidden = cell?.hi;
2891
- if (cell?.lo !== void 0 || void 0 !== hidden) cells.push(`${row}_${column}:${cell?.lo ?? ''}:${hidden ?? ''}`);
2892
- }
2893
- protectionCellKey = cells.join(',');
2894
- }
2895
- return `${sheet.id ?? sheet.name}:${JSON.stringify(authority)}:${protectionCellKey}`;
2896
- }).join('|');
2897
- }
2898
- function editableRangeCellCount(ranges) {
2899
- return ranges.reduce((total, range)=>total + (range.row[1] - range.row[0] + 1) * (range.column[1] - range.column[0] + 1), 0);
2900
- }
2901
- function withAuthority(sheet, authority) {
2902
- return {
2903
- ...sheet,
2904
- config: {
2905
- ...sheet.config ?? {},
2906
- authority
2907
- }
2908
- };
2909
- }
2910
- function editableRangeList(value) {
2911
- if (!Array.isArray(value)) return [];
2912
- return value.flatMap((item, index)=>{
2913
- if (!item || 'object' != typeof item) return [];
2914
- const range = item;
2915
- const sqref = stringValue(range.sqref);
2916
- if (!sqref || !work_spreadsheet_ranges_parseSpreadsheetCellRanges(sqref)) return [];
2917
- return [
2918
- {
2919
- name: stringValue(range.name) || `Range ${index + 1}`,
2920
- sqref: canonicalRangeReference(sqref),
2921
- hintText: stringValue(range.hintText) || void 0,
2922
- xlsxAttributes: stringRecord(range.xlsxAttributes)
2923
- }
2924
- ];
2925
- });
2926
- }
2927
- function canonicalRangeReference(value) {
2928
- const ranges = work_spreadsheet_ranges_parseSpreadsheetCellRanges(value);
2929
- return ranges ? formatSpreadsheetCellRanges(ranges) : value.trim();
2930
- }
2931
- function normalizeMatrix(data, rows, columns) {
2932
- data.length = Math.max(data.length, rows);
2933
- for (const [, row] of spreadsheet_sparse_sparseArrayEntries(data))row.length = Math.max(row.length, columns);
2934
- }
2935
- function cellProtectionRangeList(value) {
2936
- if (!Array.isArray(value)) return [];
2937
- return value.flatMap((item)=>{
2938
- if (!item || 'object' != typeof item) return [];
2939
- const candidate = item;
2940
- const range = candidate.range;
2941
- if (!range || !Array.isArray(range.row) || !Array.isArray(range.column) || range.row.length < 2 || range.column.length < 2 || ![
2942
- ...range.row,
2943
- ...range.column
2944
- ].every((index)=>Number.isSafeInteger(index) && index >= 0)) return [];
2945
- return [
2946
- {
2947
- range: {
2948
- row: [
2949
- Math.min(range.row[0], range.row[1]),
2950
- Math.max(range.row[0], range.row[1])
2951
- ],
2952
- column: [
2953
- Math.min(range.column[0], range.column[1]),
2954
- Math.max(range.column[0], range.column[1])
2955
- ]
2956
- },
2957
- locked: false !== candidate.locked,
2958
- hidden: true === candidate.hidden
2959
- }
2960
- ];
2961
- });
2962
- }
2963
- function flag(value, fallback) {
2964
- if (1 === value || true === value || '1' === value) return 1;
2965
- if (0 === value || false === value || '0' === value) return 0;
2966
- return fallback;
2967
- }
2968
- function stringValue(value) {
2969
- return 'string' == typeof value ? value : '';
2970
- }
2971
- function stringRecord(value) {
2972
- if (!value || 'object' != typeof value || Array.isArray(value)) return;
2973
- const entries = Object.entries(value).filter((entry)=>'string' == typeof entry[1]);
2974
- return entries.length ? Object.fromEntries(entries) : void 0;
2975
- }
2976
1624
  const MILLISECONDS_PER_DAY = 86400000;
2977
1625
  const SPREADSHEET_DATA_VALIDATION_ERROR_STYLES = [
2978
1626
  'stop',
@@ -3020,9 +1668,9 @@ function isoDateFromTimestamp(timestamp) {
3020
1668
  }
3021
1669
  const A3S_DIAGONAL_BORDER_KEY = 'a3sDiagonal';
3022
1670
  function spreadsheetDiagonalBorderFromCellValue(value) {
3023
- if (!work_spreadsheet_diagonal_borders_isRecord(value)) return;
1671
+ if (!isRecord(value)) return;
3024
1672
  const metadata = value[A3S_DIAGONAL_BORDER_KEY];
3025
- if (work_spreadsheet_diagonal_borders_isRecord(metadata)) {
1673
+ if (isRecord(metadata)) {
3026
1674
  const up = metadata.up;
3027
1675
  const down = metadata.down;
3028
1676
  const line = spreadsheetDiagonalBorderLine(metadata.line);
@@ -3062,13 +1710,13 @@ function spreadsheetCellValueWithDiagonalBorder(value, border) {
3062
1710
  return next;
3063
1711
  }
3064
1712
  function spreadsheetDiagonalBorderLine(value) {
3065
- if (!work_spreadsheet_diagonal_borders_isRecord(value)) return null;
1713
+ if (!isRecord(value)) return null;
3066
1714
  return 'string' == typeof value.color && 'string' == typeof value.style ? {
3067
1715
  color: value.color,
3068
1716
  style: value.style
3069
1717
  } : null;
3070
1718
  }
3071
- function work_spreadsheet_diagonal_borders_isRecord(value) {
1719
+ function isRecord(value) {
3072
1720
  return Boolean(value && 'object' == typeof value && !Array.isArray(value));
3073
1721
  }
3074
1722
  const spreadsheetTextOrientationIds = [
@@ -3298,7 +1946,7 @@ function xlsxBorderLineMatches(element, line, colors, semanticColor) {
3298
1946
  function activeXlsxSemanticColorOrigin(origin, value, palette) {
3299
1947
  return origin && xlsxSemanticColorMatchesValue(origin, value) && xlsxSemanticColorOriginSupported(origin, palette) ? origin : void 0;
3300
1948
  }
3301
- function work_xlsx_cell_style_values_xlsxBooleanAttribute(element, name) {
1949
+ function xlsxBooleanAttribute(element, name) {
3302
1950
  if (!element) return false;
3303
1951
  const value = attribute(element, name)?.trim().toLowerCase();
3304
1952
  return '1' === value || 'true' === value || 'on' === value;
@@ -3307,7 +1955,7 @@ function xlsxAlignmentMatches(xf, style) {
3307
1955
  const alignment = directChild(xf, 'alignment');
3308
1956
  if (void 0 !== style.horizontal && attribute(alignment ?? xf, 'horizontal') !== style.horizontal) return false;
3309
1957
  if (void 0 !== style.vertical && attribute(alignment ?? xf, 'vertical') !== style.vertical) return false;
3310
- if (void 0 !== style.wrapText && (!alignment || null === attribute(alignment, 'wrapText') || work_xlsx_cell_style_values_xlsxBooleanAttribute(alignment, 'wrapText') !== style.wrapText)) return false;
1958
+ if (void 0 !== style.wrapText && (!alignment || null === attribute(alignment, 'wrapText') || xlsxBooleanAttribute(alignment, 'wrapText') !== style.wrapText)) return false;
3311
1959
  if (void 0 !== style.textRotation) {
3312
1960
  const rotation = nonNegativeInteger(alignment ? attribute(alignment, 'textRotation') : null);
3313
1961
  if (rotation !== style.textRotation) return false;
@@ -3347,499 +1995,6 @@ function xlsxNativeFillKey(fill) {
3347
1995
  if (!fill) return '';
3348
1996
  return 'gradient' === fill.kind ? `gradient:${xlsxGradientFillKey(fill.value)}` : `pattern:${xlsxPatternFillKey(fill.value)}`;
3349
1997
  }
3350
- const SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS = [
3351
- 'greaterThan',
3352
- 'greaterThanOrEqual',
3353
- 'lessThan',
3354
- 'lessThanOrEqual',
3355
- 'equal',
3356
- 'notEqual',
3357
- 'between',
3358
- 'notBetween'
3359
- ];
3360
- function isSpreadsheetConditionalComparisonOperator(value) {
3361
- return SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS.some((operator)=>operator === value);
3362
- }
3363
- function spreadsheetConditionalComparisonNeedsUpperValue(operator) {
3364
- return 'between' === operator || 'notBetween' === operator;
3365
- }
3366
- const DEFAULT_DATA_BAR_MIN_LENGTH = 10;
3367
- const DEFAULT_DATA_BAR_MAX_LENGTH = 90;
3368
- function defaultSpreadsheetColorScaleThresholds(colorCount) {
3369
- return 3 === colorCount ? [
3370
- {
3371
- type: 'min'
3372
- },
3373
- {
3374
- type: 'percentile',
3375
- value: 50
3376
- },
3377
- {
3378
- type: 'max'
3379
- }
3380
- ] : [
3381
- {
3382
- type: 'min'
3383
- },
3384
- {
3385
- type: 'max'
3386
- }
3387
- ];
3388
- }
3389
- function defaultSpreadsheetDataBarOptions() {
3390
- return {
3391
- thresholds: [
3392
- {
3393
- type: 'min'
3394
- },
3395
- {
3396
- type: 'max'
3397
- }
3398
- ],
3399
- showValue: true,
3400
- minLength: DEFAULT_DATA_BAR_MIN_LENGTH,
3401
- maxLength: DEFAULT_DATA_BAR_MAX_LENGTH
3402
- };
3403
- }
3404
- function normalizeSpreadsheetConditionalThreshold(value) {
3405
- if (!value || 'object' != typeof value || Array.isArray(value)) return null;
3406
- const source = value;
3407
- if (![
3408
- 'min',
3409
- 'max',
3410
- 'num',
3411
- 'percent',
3412
- 'percentile'
3413
- ].includes(String(source.type))) return null;
3414
- const type = source.type;
3415
- if ('min' === type || 'max' === type) return {
3416
- type
3417
- };
3418
- if ('number' != typeof source.value || !Number.isFinite(source.value)) return null;
3419
- return {
3420
- type,
3421
- value: source.value
3422
- };
3423
- }
3424
- function normalizeSpreadsheetConditionalVisualOptions(value, expectedThresholdCount, kind) {
3425
- if (!value || 'object' != typeof value || Array.isArray(value)) return null;
3426
- const source = value;
3427
- if (!Array.isArray(source.thresholds) || source.thresholds.length !== expectedThresholdCount) return null;
3428
- const thresholds = source.thresholds.map(normalizeSpreadsheetConditionalThreshold);
3429
- if (thresholds.some((threshold)=>!threshold)) return null;
3430
- if ('colorScale' === kind) return {
3431
- thresholds: thresholds
3432
- };
3433
- const minLength = source.minLength ?? DEFAULT_DATA_BAR_MIN_LENGTH;
3434
- const maxLength = source.maxLength ?? DEFAULT_DATA_BAR_MAX_LENGTH;
3435
- if ('number' != typeof minLength || !Number.isFinite(minLength) || minLength < 0 || minLength > 100 || 'number' != typeof maxLength || !Number.isFinite(maxLength) || maxLength < 0 || maxLength > 100 || minLength > maxLength) return null;
3436
- return {
3437
- thresholds: thresholds,
3438
- showValue: false !== source.showValue,
3439
- minLength,
3440
- maxLength
3441
- };
3442
- }
3443
- function spreadsheetConditionalThresholdValue(threshold, sourceValues) {
3444
- const values = sourceValues.filter(Number.isFinite).sort((left, right)=>left - right);
3445
- if (!values.length) return null;
3446
- const minimum = values[0];
3447
- const maximum = values.at(-1);
3448
- if ('min' === threshold.type) return minimum;
3449
- if ('max' === threshold.type) return maximum;
3450
- if ('num' === threshold.type) return threshold.value ?? null;
3451
- const percentage = threshold.value;
3452
- if (void 0 === percentage || !Number.isFinite(percentage)) return null;
3453
- if ('percent' === threshold.type) return minimum + (maximum - minimum) * percentage / 100;
3454
- const position = Math.max(0, Math.min(100, percentage)) / 100 * (values.length - 1);
3455
- const lower = Math.floor(position);
3456
- const upper = Math.ceil(position);
3457
- if (lower === upper) return values[lower];
3458
- return values[lower] + (values[upper] - values[lower]) * (position - lower);
3459
- }
3460
- function spreadsheetConditionalThresholdsEqual(left, right) {
3461
- return left.length === right.length && left.every((threshold, index)=>threshold.type === right[index]?.type && threshold.value === right[index]?.value);
3462
- }
3463
- const SPREADSHEET_CONDITIONAL_ICON_SETS = [
3464
- {
3465
- name: '3Arrows',
3466
- label: '三向彩色箭头',
3467
- count: 3
3468
- },
3469
- {
3470
- name: '3ArrowsGray',
3471
- label: '三向灰色箭头',
3472
- count: 3
3473
- },
3474
- {
3475
- name: '3Flags',
3476
- label: '三色旗帜',
3477
- count: 3
3478
- },
3479
- {
3480
- name: '3TrafficLights1',
3481
- label: '三色交通灯(实心)',
3482
- count: 3
3483
- },
3484
- {
3485
- name: '3TrafficLights2',
3486
- label: '三色交通灯(边框)',
3487
- count: 3
3488
- },
3489
- {
3490
- name: '3Signs',
3491
- label: '三色标志',
3492
- count: 3
3493
- },
3494
- {
3495
- name: '3Symbols',
3496
- label: '三色符号(圆形)',
3497
- count: 3
3498
- },
3499
- {
3500
- name: '3Symbols2',
3501
- label: '三色符号',
3502
- count: 3
3503
- },
3504
- {
3505
- name: '4Arrows',
3506
- label: '四向彩色箭头',
3507
- count: 4
3508
- },
3509
- {
3510
- name: '4ArrowsGray',
3511
- label: '四向灰色箭头',
3512
- count: 4
3513
- },
3514
- {
3515
- name: '4RedToBlack',
3516
- label: '红到黑圆点',
3517
- count: 4
3518
- },
3519
- {
3520
- name: '4Rating',
3521
- label: '四级评分',
3522
- count: 4
3523
- },
3524
- {
3525
- name: '4TrafficLights',
3526
- label: '四色交通灯',
3527
- count: 4
3528
- },
3529
- {
3530
- name: '5Arrows',
3531
- label: '五向彩色箭头',
3532
- count: 5
3533
- },
3534
- {
3535
- name: '5ArrowsGray',
3536
- label: '五向灰色箭头',
3537
- count: 5
3538
- },
3539
- {
3540
- name: '5Rating',
3541
- label: '五级评分',
3542
- count: 5
3543
- },
3544
- {
3545
- name: '5Quarters',
3546
- label: '五级圆饼',
3547
- count: 5
3548
- }
3549
- ];
3550
- const COLOR_3 = [
3551
- '#c62828',
3552
- '#f9a825',
3553
- '#2e7d32'
3554
- ];
3555
- const COLOR_4 = [
3556
- '#c62828',
3557
- '#ef6c00',
3558
- '#7cb342',
3559
- '#2e7d32'
3560
- ];
3561
- const COLOR_5 = [
3562
- '#c62828',
3563
- '#ef6c00',
3564
- '#f9a825',
3565
- '#7cb342',
3566
- '#2e7d32'
3567
- ];
3568
- function isSpreadsheetConditionalIconSetName(value) {
3569
- return SPREADSHEET_CONDITIONAL_ICON_SETS.some((item)=>item.name === value);
3570
- }
3571
- function spreadsheetConditionalIconSetCount(iconSet) {
3572
- return SPREADSHEET_CONDITIONAL_ICON_SETS.find((item)=>item.name === iconSet).count;
3573
- }
3574
- function defaultSpreadsheetConditionalIconThresholds(iconSet) {
3575
- const count = spreadsheetConditionalIconSetCount(iconSet);
3576
- return Array.from({
3577
- length: count
3578
- }, (_, index)=>0 === index ? {
3579
- type: 'min',
3580
- gte: true
3581
- } : {
3582
- type: 'percent',
3583
- value: Math.round(100 * index / count),
3584
- gte: true
3585
- });
3586
- }
3587
- function normalizeSpreadsheetConditionalIconSetFormat(value) {
3588
- if (!value || 'object' != typeof value || Array.isArray(value)) return null;
3589
- const source = value;
3590
- if (!isSpreadsheetConditionalIconSetName(source.iconSet) || !Array.isArray(source.thresholds)) return null;
3591
- const count = spreadsheetConditionalIconSetCount(source.iconSet);
3592
- if (source.thresholds.length !== count) return null;
3593
- const thresholds = source.thresholds.map(normalizeThreshold);
3594
- if (thresholds.some((threshold)=>!threshold)) return null;
3595
- return {
3596
- iconSet: source.iconSet,
3597
- showValue: false !== source.showValue,
3598
- reverse: true === source.reverse,
3599
- percent: false !== source.percent,
3600
- thresholds: thresholds
3601
- };
3602
- }
3603
- function spreadsheetConditionalIconForValue(sourceFormat, value, sourceValues) {
3604
- const format = normalizeSpreadsheetConditionalIconSetFormat(sourceFormat);
3605
- const values = sourceValues.filter(Number.isFinite);
3606
- if (!format || !Number.isFinite(value) || !values.length) return null;
3607
- const count = spreadsheetConditionalIconSetCount(format.iconSet);
3608
- let level = 0;
3609
- for(let index = 1; index < count; index += 1){
3610
- const threshold = format.thresholds[index];
3611
- const cutoff = spreadsheetConditionalThresholdValue(threshold, values);
3612
- if (null === cutoff) return null;
3613
- if (threshold.gte ? value >= cutoff : value > cutoff) level = index;
3614
- }
3615
- return {
3616
- iconSet: format.iconSet,
3617
- index: format.reverse ? count - 1 - level : level,
3618
- count,
3619
- showValue: format.showValue
3620
- };
3621
- }
3622
- function spreadsheetConditionalIconAppearance(icon) {
3623
- const index = Math.max(0, Math.min(icon.count - 1, icon.index));
3624
- const definition = SPREADSHEET_CONDITIONAL_ICON_SETS.find((item)=>item.name === icon.iconSet);
3625
- const label = `${definition.label} ${index + 1}/${icon.count}`;
3626
- if (icon.iconSet.includes('Arrows')) {
3627
- const glyphs = 3 === icon.count ? [
3628
- '↓',
3629
- '→',
3630
- '↑'
3631
- ] : 4 === icon.count ? [
3632
- '↓',
3633
- '↘',
3634
- '↗',
3635
- '↑'
3636
- ] : [
3637
- '↓',
3638
- '↘',
3639
- '→',
3640
- '↗',
3641
- '↑'
3642
- ];
3643
- return {
3644
- glyph: glyphs[index],
3645
- color: icon.iconSet.includes('Gray') ? '#606a78' : work_spreadsheet_conditional_icons_palette(icon.count)[index],
3646
- label
3647
- };
3648
- }
3649
- if ('3Flags' === icon.iconSet) return {
3650
- glyph: '⚑',
3651
- color: COLOR_3[index],
3652
- label
3653
- };
3654
- if (icon.iconSet.includes('TrafficLights')) return {
3655
- glyph: '3TrafficLights2' === icon.iconSet ? '◉' : '●',
3656
- color: work_spreadsheet_conditional_icons_palette(icon.count)[index],
3657
- label
3658
- };
3659
- if ('3Signs' === icon.iconSet) return {
3660
- glyph: [
3661
- '◆',
3662
- '▲',
3663
- '●'
3664
- ][index],
3665
- color: COLOR_3[index],
3666
- label
3667
- };
3668
- if ('3Symbols' === icon.iconSet || '3Symbols2' === icon.iconSet) return {
3669
- glyph: [
3670
- '✕',
3671
- '!',
3672
- '✓'
3673
- ][index],
3674
- color: COLOR_3[index],
3675
- label
3676
- };
3677
- if ('4RedToBlack' === icon.iconSet) return {
3678
- glyph: '●',
3679
- color: [
3680
- '#c62828',
3681
- '#e45b4f',
3682
- '#697386',
3683
- '#111827'
3684
- ][index],
3685
- label
3686
- };
3687
- if ('4Rating' === icon.iconSet) return {
3688
- glyph: [
3689
- '▁',
3690
- '▃',
3691
- '▆',
3692
- '█'
3693
- ][index],
3694
- color: '#54708f',
3695
- label
3696
- };
3697
- if ('5Rating' === icon.iconSet) return {
3698
- glyph: [
3699
- '▁',
3700
- '▂',
3701
- '▄',
3702
- '▆',
3703
- '█'
3704
- ][index],
3705
- color: '#54708f',
3706
- label
3707
- };
3708
- return {
3709
- glyph: [
3710
- '○',
3711
- '◔',
3712
- '◑',
3713
- '◕',
3714
- '●'
3715
- ][index],
3716
- color: '#54708f',
3717
- label
3718
- };
3719
- }
3720
- function drawSpreadsheetConditionalIcon(context, bounds, icon, background, maskValue = !icon.showValue) {
3721
- const width = bounds.endX - bounds.startX;
3722
- const height = bounds.endY - bounds.startY;
3723
- if (width < 6 || height < 6) return;
3724
- const appearance = spreadsheetConditionalIconAppearance(icon);
3725
- context.save();
3726
- context.beginPath();
3727
- context.rect(bounds.startX + 1, bounds.startY + 1, Math.max(0, width - 3), Math.max(0, height - 3));
3728
- context.clip();
3729
- if (maskValue) {
3730
- context.fillStyle = background;
3731
- context.fillRect(bounds.startX + 1, bounds.startY + 1, Math.max(0, width - 3), Math.max(0, height - 3));
3732
- }
3733
- const size = Math.max(9, Math.min(16, height - 5));
3734
- context.fillStyle = appearance.color;
3735
- context.font = `700 ${size}px "Arial Unicode MS", "Segoe UI Symbol", sans-serif`;
3736
- context.textAlign = 'left';
3737
- context.textBaseline = 'middle';
3738
- context.fillText(appearance.glyph, bounds.startX + 4, bounds.startY + height / 2);
3739
- context.restore();
3740
- }
3741
- function normalizeThreshold(value) {
3742
- if (!value || 'object' != typeof value || Array.isArray(value)) return null;
3743
- const source = value;
3744
- const threshold = normalizeSpreadsheetConditionalThreshold(source);
3745
- return threshold ? {
3746
- ...threshold,
3747
- gte: false !== source.gte
3748
- } : null;
3749
- }
3750
- function work_spreadsheet_conditional_icons_palette(count) {
3751
- if (3 === count) return COLOR_3;
3752
- if (4 === count) return COLOR_4;
3753
- return COLOR_5;
3754
- }
3755
- function effectiveSpreadsheetHeaderFooterSections(sections) {
3756
- return {
3757
- left: sections?.left ?? '',
3758
- center: sections?.center ?? '',
3759
- right: sections?.right ?? ''
3760
- };
3761
- }
3762
- const DEFAULT_MARGINS = {
3763
- top: 19.05,
3764
- right: 17.78,
3765
- bottom: 19.05,
3766
- left: 17.78,
3767
- header: 7.62,
3768
- footer: 7.62
3769
- };
3770
- const PAPER_DIMENSIONS = {
3771
- a3: {
3772
- width: 297,
3773
- height: 420
3774
- },
3775
- a4: {
3776
- width: 210,
3777
- height: 297
3778
- },
3779
- a5: {
3780
- width: 148,
3781
- height: 210
3782
- },
3783
- letter: {
3784
- width: 215.9,
3785
- height: 279.4
3786
- },
3787
- legal: {
3788
- width: 215.9,
3789
- height: 355.6
3790
- },
3791
- tabloid: {
3792
- width: 279.4,
3793
- height: 431.8
3794
- }
3795
- };
3796
- PAPER_DIMENSIONS.a4.height, DEFAULT_MARGINS.left, DEFAULT_MARGINS.right;
3797
- PAPER_DIMENSIONS.a4.width, DEFAULT_MARGINS.top, DEFAULT_MARGINS.bottom;
3798
- function effectiveSpreadsheetPageSetup(pageSetup) {
3799
- return {
3800
- paperSize: normalizeSpreadsheetPaperSize(pageSetup?.paperSize),
3801
- orientation: pageSetup?.orientation === 'portrait' ? 'portrait' : 'landscape',
3802
- scale: work_spreadsheet_page_setup_boundedInteger(pageSetup?.scale, 10, 400, 100),
3803
- fitToPage: Boolean(pageSetup?.fitToPage),
3804
- fitToWidth: work_spreadsheet_page_setup_boundedInteger(pageSetup?.fitToWidth, 0, 32767, 1),
3805
- fitToHeight: work_spreadsheet_page_setup_boundedInteger(pageSetup?.fitToHeight, 0, 32767, 0),
3806
- horizontalCentered: Boolean(pageSetup?.horizontalCentered),
3807
- verticalCentered: Boolean(pageSetup?.verticalCentered),
3808
- header: effectiveSpreadsheetHeaderFooterSections(pageSetup?.header),
3809
- footer: effectiveSpreadsheetHeaderFooterSections(pageSetup?.footer),
3810
- pageNumberStart: work_spreadsheet_page_setup_boundedInteger(pageSetup?.pageNumberStart, 1, 32767, 1),
3811
- pageOrder: pageSetup?.pageOrder === 'downThenOver' ? 'downThenOver' : 'overThenDown',
3812
- scaleWithDocument: pageSetup?.scaleWithDocument !== false,
3813
- alignWithMargins: pageSetup?.alignWithMargins !== false,
3814
- margins: {
3815
- top: work_spreadsheet_page_setup_boundedNumber(pageSetup?.margins?.top, 0, 100, DEFAULT_MARGINS.top),
3816
- right: work_spreadsheet_page_setup_boundedNumber(pageSetup?.margins?.right, 0, 100, DEFAULT_MARGINS.right),
3817
- bottom: work_spreadsheet_page_setup_boundedNumber(pageSetup?.margins?.bottom, 0, 100, DEFAULT_MARGINS.bottom),
3818
- left: work_spreadsheet_page_setup_boundedNumber(pageSetup?.margins?.left, 0, 100, DEFAULT_MARGINS.left),
3819
- header: work_spreadsheet_page_setup_boundedNumber(pageSetup?.margins?.header, 0, 100, DEFAULT_MARGINS.header),
3820
- footer: work_spreadsheet_page_setup_boundedNumber(pageSetup?.margins?.footer, 0, 100, DEFAULT_MARGINS.footer)
3821
- }
3822
- };
3823
- }
3824
- function normalizeSpreadsheetPaperSize(value) {
3825
- switch(value){
3826
- case 'a3':
3827
- case 'a4':
3828
- case 'a5':
3829
- case 'letter':
3830
- case 'legal':
3831
- case 'tabloid':
3832
- return value;
3833
- default:
3834
- return 'a4';
3835
- }
3836
- }
3837
- function work_spreadsheet_page_setup_boundedInteger(value, minimum, maximum, fallback) {
3838
- return Math.trunc(work_spreadsheet_page_setup_boundedNumber(value, minimum, maximum, fallback));
3839
- }
3840
- function work_spreadsheet_page_setup_boundedNumber(value, minimum, maximum, fallback) {
3841
- return 'number' == typeof value && Number.isFinite(value) && value >= minimum && value <= maximum ? value : fallback;
3842
- }
3843
1998
  const MAX_XLSX_RICH_TEXT_CELL_CHARACTERS = 32767;
3844
1999
  const MAX_XLSX_RICH_TEXT_RUNS_PER_CELL = 512;
3845
2000
  const MAX_XLSX_RICH_TEXT_FONT_NAME_CHARACTERS = 128;
@@ -4061,12 +2216,12 @@ function xlsxRichTextCellText(cell) {
4061
2216
  return normalizeXlsxRichTextCell(cell)?.text ?? null;
4062
2217
  }
4063
2218
  function sheetHasXlsxRichTextCells(sheet) {
4064
- for (const [, row] of spreadsheet_sparse_sparseArrayEntries(sheet.data))for (const [, cell] of spreadsheet_sparse_sparseArrayEntries(row))if (cell && normalizeXlsxRichTextCell(cell)) return true;
2219
+ for (const [, row] of sparseArrayEntries(sheet.data))for (const [, cell] of sparseArrayEntries(row))if (cell && normalizeXlsxRichTextCell(cell)) return true;
4065
2220
  return false;
4066
2221
  }
4067
2222
  function xlsxRichTextStyleOrigins(sheet) {
4068
2223
  const origins = [];
4069
- for (const [, row] of spreadsheet_sparse_sparseArrayEntries(sheet.data))for (const [, cell] of spreadsheet_sparse_sparseArrayEntries(row))if (cell) for (const run of normalizeXlsxRichTextCell(cell)?.runs ?? []){
2224
+ for (const [, row] of sparseArrayEntries(sheet.data))for (const [, cell] of sparseArrayEntries(row))if (cell) for (const run of normalizeXlsxRichTextCell(cell)?.runs ?? []){
4070
2225
  const fontColor = normalizeXlsxSemanticColorOrigin(run.a3sXlsxColorOrigin);
4071
2226
  if (fontColor && run.fc && xlsxSemanticColorMatchesValue(fontColor, run.fc)) origins.push({
4072
2227
  fontColor
@@ -4086,7 +2241,7 @@ function writeXlsxRichTextCells(worksheet, sheet, semanticPalette) {
4086
2241
  }));
4087
2242
  let remainingCells = 10000;
4088
2243
  let remainingRuns = 100000;
4089
- for (const [row, values] of spreadsheet_sparse_sparseArrayEntries(sheet.data))for (const [column, cell] of spreadsheet_sparse_sparseArrayEntries(values)){
2244
+ for (const [row, values] of sparseArrayEntries(sheet.data))for (const [column, cell] of sparseArrayEntries(values)){
4090
2245
  if (remainingCells <= 0 || remainingRuns <= 0) return;
4091
2246
  if (!cell) continue;
4092
2247
  const richText = normalizeXlsxRichTextCell(cell);
@@ -4144,7 +2299,7 @@ function readRichTextRun(element, value, colors) {
4144
2299
  if (work_xlsx_rich_text_xlsxToggleEnabled(directChild(properties, 'b'))) run.bl = 1;
4145
2300
  if (work_xlsx_rich_text_xlsxToggleEnabled(directChild(properties, 'i'))) run.it = 1;
4146
2301
  if (work_xlsx_rich_text_xlsxToggleEnabled(directChild(properties, 'strike'))) run.cl = 1;
4147
- const size = work_xlsx_rich_text_finiteNumber(attribute(directChild(properties, 'sz') ?? properties, 'val'));
2302
+ const size = finiteNumber(attribute(directChild(properties, 'sz') ?? properties, 'val'));
4148
2303
  if (null !== size && size >= 1 && size <= 409) run.fs = size;
4149
2304
  const underline = directChild(properties, 'u');
4150
2305
  if (underline) {
@@ -4216,7 +2371,7 @@ function work_xlsx_rich_text_xlsxToggleEnabled(element) {
4216
2371
  const value = attribute(element, 'val')?.trim().toLowerCase();
4217
2372
  return '0' !== value && 'false' !== value && 'off' !== value;
4218
2373
  }
4219
- function work_xlsx_rich_text_finiteNumber(value) {
2374
+ function finiteNumber(value) {
4220
2375
  if (null === value || !value.trim()) return null;
4221
2376
  const parsed = Number(value);
4222
2377
  return Number.isFinite(parsed) ? parsed : null;
@@ -4229,4 +2384,4 @@ function work_xlsx_rich_text_nonNegativeInteger(value) {
4229
2384
  function work_xlsx_rich_text_isRecord(value) {
4230
2385
  return 'object' == typeof value && null !== value && !Array.isArray(value);
4231
2386
  }
4232
- export { DEFAULT_PROTECTION_HINT, SPREADSHEET_CONDITIONAL_COMPARISON_OPERATORS, SPREADSHEET_CONDITIONAL_ICON_SETS, activeXlsxNativeFill, activeXlsxSemanticColorOrigin, applyImportedXlsxRichText, applyXlsxSemanticColorOrigin, attachSpreadsheetShownCommentCells, boundedSpreadsheetDataValidationText, coalesceXlsxRichTextRuns, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, createXlsxColorResolver, createXlsxRichTextReadContext, defaultSpreadsheetColorScaleThresholds, defaultSpreadsheetConditionalIconThresholds, defaultSpreadsheetDataBarOptions, defaultXlsxBorder, defaultXlsxFill, deleteXlsxNativeFills, directXlsxAlignment, directXlsxFontStyle, drawSpreadsheetConditionalIcon, editableRangeCellCount, editableRangeRequiresCredentials, effectiveSpreadsheetPageSetup, ensureXlsxStyleCollection, freezeImportedSpreadsheetCell, hasXlsxDirectFontStyle, importedSheetProtectionAuthority, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isHighSurrogate, isLowSurrogate, isSpreadsheetConditionalComparisonOperator, isSpreadsheetConditionalIconSetName, isSpreadsheetTextOrientationId, isSpreadsheetUnderlineStyle, normalizeSheetProtectionAuthority, normalizeSpreadsheetConditionalIconSetFormat, normalizeSpreadsheetConditionalVisualOptions, normalizeSpreadsheetDataValidationErrorStyle, normalizeSpreadsheetDateValidationBoundary, normalizeSpreadsheetPaperSize, normalizeXlsxGradientFill, normalizeXlsxPatternFill, normalizeXlsxRichTextCell, normalizeXlsxRichTextColor, normalizeXlsxRichTextEditSource, normalizeXlsxRichTextRun, normalizeXlsxSemanticColorOrigin, patchSpreadsheetRichTextFontRuns, prepareXlsxSemanticPalette, protectedSheetCount, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, readXlsxGradientFill, readXlsxPatternFill, readXlsxRichTextCells, readXlsxSemanticColorOrigin, registerDerivedSpreadsheetMatrix, registerImportedSpreadsheetMatrix, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, resolveXlsxColor, sameSpreadsheetHistoryValue, sameXlsxRichTextRunStyle, setXlsxBorderLine, setXlsxColorChild, setXlsxToggleChild, setXlsxUnderlineChild, setXlsxValueChild, sheetHasProtectionState, sheetHasXlsxRichTextCells, sheetProtectionAuthority, spreadsheetCellValueWithDiagonalBorder, spreadsheetConditionalComparisonNeedsUpperValue, spreadsheetConditionalIconForValue, spreadsheetConditionalIconSetCount, spreadsheetConditionalThresholdValue, spreadsheetConditionalThresholdsEqual, spreadsheetDateValidationFormula, spreadsheetDiagonalBorderFromCellValue, spreadsheetExplicitTextOrientationFromCell, spreadsheetMatrixProfile, spreadsheetProtectionKey, spreadsheetTextOrientationCellStyle, spreadsheetTextOrientationChoiceFromCell, spreadsheetTextOrientationFromAngle, spreadsheetTextOrientationFromCell, spreadsheetTextOrientationFromChoice, spreadsheetTextOrientationFromXlsx, spreadsheetUnderlineCellValue, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetUnderlineCellValueFromXlsx, spreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell, unlockedCellCount, validXlsxRichText, withEditableRange, withSheetProtection, withSheetSelectionPermissions, withXlsxCellStyleOrigin, withXlsxGradientFill, withXlsxPatternFill, withoutEditableRange, work_xlsx_cell_style_values_xlsxBooleanAttribute, writeXlsxAlignment, writeXlsxRichTextCells, xlsxAlignmentMatches, xlsxBorderLineMatches, xlsxCellStyleOrigin, xlsxCellStyleOriginSemanticColors, xlsxColorElementMatchesOrigin, xlsxColorMatches, xlsxGradientFillFallbackColor, xlsxGradientFillKey, xlsxNativeFillCellKeys, xlsxNativeFillKey, xlsxNativeFillSemanticColors, xlsxPatternFillTypes, xlsxRgbColor, xlsxRichTextCellText, xlsxRichTextStyleOrigins, xlsxSemanticColorMatchesValue, xlsxSemanticColorOriginKey, xlsxStyleCollectionIndex, xlsxToggleEnabled, xlsxUnderlineStyle, xlsxWorksheetCellEntries };
2387
+ export { activeXlsxNativeFill, activeXlsxSemanticColorOrigin, applyImportedXlsxRichText, boundedSpreadsheetDataValidationText, coalesceXlsxRichTextRuns, createWorkOfficeSpreadsheetCollaborationBinding as createOfficeSpreadsheetCollaborationBinding, createXlsxRichTextReadContext, deleteXlsxNativeFills, directXlsxAlignment, directXlsxFontStyle, hasXlsxDirectFontStyle, initializeWorkOfficeSpreadsheetCollaboration as initializeOfficeSpreadsheetCollaboration, isHighSurrogate, isLowSurrogate, isSpreadsheetTextOrientationId, isSpreadsheetUnderlineStyle, normalizeSpreadsheetDataValidationErrorStyle, normalizeSpreadsheetDateValidationBoundary, normalizeXlsxRichTextCell, normalizeXlsxRichTextColor, normalizeXlsxRichTextEditSource, normalizeXlsxRichTextRun, patchSpreadsheetRichTextFontRuns, readWorkOfficeSpreadsheetCollaboration as readOfficeSpreadsheetCollaboration, readXlsxRichTextCells, replaceWorkOfficeSpreadsheetCollaboration as replaceOfficeSpreadsheetCollaboration, sameXlsxRichTextRunStyle, sheetHasXlsxRichTextCells, spreadsheetCellValueWithDiagonalBorder, spreadsheetDateValidationFormula, spreadsheetDiagonalBorderFromCellValue, spreadsheetExplicitTextOrientationFromCell, spreadsheetTextOrientationCellStyle, spreadsheetTextOrientationChoiceFromCell, spreadsheetTextOrientationFromAngle, spreadsheetTextOrientationFromCell, spreadsheetTextOrientationFromChoice, spreadsheetTextOrientationFromXlsx, spreadsheetUnderlineCellValue, spreadsheetUnderlineCellValueFromSheetJs, spreadsheetUnderlineCellValueFromXlsx, spreadsheetUnderlineStyle, spreadsheetVisibleTextRotationFromCell, validXlsxRichText, writeXlsxRichTextCells, xlsxAlignmentMatches, xlsxBooleanAttribute, xlsxBorderLineMatches, xlsxColorMatches, xlsxNativeFillCellKeys, xlsxNativeFillKey, xlsxNativeFillSemanticColors, xlsxRichTextCellText, xlsxRichTextStyleOrigins, xlsxStyleCollectionIndex, xlsxToggleEnabled, xlsxUnderlineStyle };