ooxml-ui 1.35.0 → 1.36.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 (135) hide show
  1. package/custom-elements.json +14 -1
  2. package/dist/chart/format-pane-analysis.d.ts +0 -1
  3. package/dist/chart/format-pane-effects.d.ts +0 -1
  4. package/dist/chart/format-pane-fill-kinds.d.ts +0 -1
  5. package/dist/chart/format-pane-fill-line.d.ts +0 -1
  6. package/dist/chart/format-pane-targets.d.ts +0 -1
  7. package/dist/chart/format-pane-text.d.ts +0 -1
  8. package/dist/chrome/tab-drag.d.ts +27 -0
  9. package/dist/chrome/tab-drag.d.ts.map +1 -0
  10. package/dist/chrome/tab-strip.d.ts +25 -1
  11. package/dist/chrome/tab-strip.d.ts.map +1 -1
  12. package/dist/{chunk-CDC5MAZS.js → chunk-6VF4FEMY.js} +1 -1
  13. package/dist/{chunk-D5IRYZLP.js → chunk-7RRN2GPO.js} +1 -1
  14. package/dist/{chunk-FFM3WVLU.js → chunk-7ST5QRD5.js} +1 -1
  15. package/dist/{chunk-KYXSQFDB.js → chunk-QAX4FAB7.js} +139 -4
  16. package/dist/{chunk-TGG36HHF.js → chunk-Z4DML5NW.js} +2 -2
  17. package/dist/controls.d.ts +1 -1
  18. package/dist/controls.d.ts.map +1 -1
  19. package/dist/controls.js +1 -1
  20. package/dist/docx/building-blocks-actions.d.ts +2 -2
  21. package/dist/docx/editable-region-view.d.ts +4 -0
  22. package/dist/docx/editor-chrome.d.ts +1 -1
  23. package/dist/docx/editor-core.d.ts +4 -0
  24. package/dist/docx/editor-plugins.d.ts +3 -0
  25. package/dist/docx/file-commands.d.ts +5 -0
  26. package/dist/docx/format-dialogs.d.ts +6 -1
  27. package/dist/docx/insert-controller.d.ts +5 -0
  28. package/dist/docx/list-commands.d.ts +3 -1
  29. package/dist/docx/list-marker-display.d.ts +1 -1
  30. package/dist/docx/locales/en-app.d.ts +0 -1
  31. package/dist/docx/locales/en-ribbon.d.ts +51 -0
  32. package/dist/docx/locales/en.d.ts +51 -1
  33. package/dist/docx/localization-strings.d.ts +51 -1
  34. package/dist/docx/paragraph-styles.d.ts +1 -1
  35. package/dist/docx/protection-controls.d.ts +4 -0
  36. package/dist/docx/restrict-editing-pane.d.ts +14 -0
  37. package/dist/docx/ribbon-action.d.ts +4 -0
  38. package/dist/docx/ribbon-icons.d.ts +1 -0
  39. package/dist/docx/search-controller.d.ts +12 -5
  40. package/dist/docx/search-document.d.ts +32 -0
  41. package/dist/docx.js +1182 -384
  42. package/dist/export/pdf-embedded-font.d.ts +65 -0
  43. package/dist/export/pdf-fonts.d.ts +14 -0
  44. package/dist/export/pdf-vector.d.ts +84 -0
  45. package/dist/fonts/catalog.d.ts +1 -0
  46. package/dist/index.js +4 -4
  47. package/dist/pptx/ai/bridge-factory.d.ts +4 -1
  48. package/dist/pptx/ai/bridge-factory.d.ts.map +1 -1
  49. package/dist/pptx/ai/config.d.ts +1 -1
  50. package/dist/pptx/ai/config.d.ts.map +1 -1
  51. package/dist/pptx/ai/host.cjs +36 -36
  52. package/dist/pptx/ai/host.mjs +1 -1
  53. package/dist/pptx/ai/index.cjs +50 -43
  54. package/dist/pptx/ai/index.mjs +10 -3
  55. package/dist/pptx/ai/system-prompt.d.ts +1 -1
  56. package/dist/pptx/ai/system-prompt.d.ts.map +1 -1
  57. package/dist/pptx/ai/tool-summary.d.ts.map +1 -1
  58. package/dist/pptx/ai/tools/mcp-registry.d.ts.map +1 -1
  59. package/dist/pptx/{chunk-KGDMMWIY.mjs → chunk-2AK5MS6H.mjs} +11 -0
  60. package/dist/pptx/{chunk-M55PNMFQ.cjs → chunk-4OKSYRYA.cjs} +11 -0
  61. package/dist/pptx/{chunk-GPQP2R5Y.mjs → chunk-4RSRCNRM.mjs} +177 -13
  62. package/dist/pptx/{chunk-NPYNJOK2.cjs → chunk-6JJD3LFT.cjs} +182 -17
  63. package/dist/pptx/{chunk-46HIE4IE.cjs → chunk-CRV7G4GC.cjs} +8 -0
  64. package/dist/pptx/{chunk-5EERUTDC.mjs → chunk-KNCCSPAV.mjs} +1 -1
  65. package/dist/pptx/{chunk-GKQULDFF.cjs → chunk-SI7GQYSL.cjs} +42 -42
  66. package/dist/pptx/{chunk-6MEBLCNK.mjs → chunk-WQI3NLMY.mjs} +8 -0
  67. package/dist/pptx/dom/index.cjs +384 -384
  68. package/dist/pptx/dom/index.mjs +6 -6
  69. package/dist/pptx/i18n/index.cjs +6 -6
  70. package/dist/pptx/i18n/index.mjs +1 -1
  71. package/dist/pptx/i18n/translations-en.d.ts.map +1 -1
  72. package/dist/pptx/index.cjs +3037 -3033
  73. package/dist/pptx/index.mjs +2 -2
  74. package/dist/pptx/render/controller/custom-shows-controller.d.ts +93 -0
  75. package/dist/pptx/render/controller/custom-shows-controller.d.ts.map +1 -0
  76. package/dist/pptx/render/controller/index.d.ts +2 -0
  77. package/dist/pptx/render/controller/index.d.ts.map +1 -1
  78. package/dist/pptx/render/custom-shows.d.ts +10 -2
  79. package/dist/pptx/render/custom-shows.d.ts.map +1 -1
  80. package/dist/pptx/{smartart-insert-preview-6BITTUI4.mjs → smartart-insert-preview-JH5TXECK.mjs} +3 -3
  81. package/dist/pptx/{smartart-insert-preview-BUOS5XQR.cjs → smartart-insert-preview-QWROEVZL.cjs} +4 -4
  82. package/dist/smartart/smartart-text-pane-tools.d.ts +0 -1
  83. package/dist/teams.js +2 -2
  84. package/dist/theme.d.ts +0 -1
  85. package/dist/touch-targets.d.ts +0 -1
  86. package/dist/visio/binding.d.ts +2 -1
  87. package/dist/visio/canvas-editing.d.ts +2 -0
  88. package/dist/visio/controller.d.ts +3 -0
  89. package/dist/visio/pdf-path.d.ts +37 -0
  90. package/dist/visio/pdf-svg-gradient.d.ts +23 -0
  91. package/dist/visio/pdf-svg-style.d.ts +20 -0
  92. package/dist/visio/pdf-svg-text.d.ts +8 -0
  93. package/dist/visio/pdf-svg.d.ts +22 -0
  94. package/dist/visio/ribbon-action.d.ts +47 -5
  95. package/dist/visio/ribbon-arrange.d.ts +9 -0
  96. package/dist/visio/ribbon-contextual-formats.d.ts +18 -0
  97. package/dist/visio/ribbon-org-chart.d.ts +7 -0
  98. package/dist/visio/ribbon-router.d.ts +18 -0
  99. package/dist/visio/ribbon-shape-format.d.ts +7 -0
  100. package/dist/visio/ribbon-size-fields.d.ts +5 -0
  101. package/dist/visio/ribbon-swimlane.d.ts +9 -0
  102. package/dist/visio/ribbon-themes.d.ts +13 -3
  103. package/dist/visio/ribbon.d.ts +5 -1
  104. package/dist/visio/shapes-files-ui.d.ts +1 -1
  105. package/dist/visio/template-thumbnails.d.ts +10 -0
  106. package/dist/visio/viewer-backstage.d.ts +9 -3
  107. package/dist/visio/viewer-contextual-tabs.d.ts +21 -0
  108. package/dist/visio/viewer-diagram-parts.d.ts +9 -1
  109. package/dist/visio/viewer-element.d.ts +10 -0
  110. package/dist/visio/viewer-export.d.ts +1 -6
  111. package/dist/visio/viewer-file-commands.d.ts +6 -1
  112. package/dist/visio/viewer-guides.d.ts +8 -1
  113. package/dist/visio/viewer-inline-size.d.ts +15 -0
  114. package/dist/visio/viewer-insert-dialog.d.ts +1 -0
  115. package/dist/visio/viewer-new-drawing.d.ts +3 -2
  116. package/dist/visio/viewer-org-chart.d.ts +19 -0
  117. package/dist/visio/viewer-pdf-options.d.ts +26 -0
  118. package/dist/visio/viewer-pdf.d.ts +47 -0
  119. package/dist/visio/viewer-picture-format.d.ts +20 -0
  120. package/dist/visio/viewer-resize-handles.d.ts +13 -1
  121. package/dist/visio/viewer-swimlanes.d.ts +34 -0
  122. package/dist/visio.js +4038 -733
  123. package/dist/xlsx/dialogs/audit-dialogs.d.ts +9 -0
  124. package/dist/xlsx/dialogs/custom-lists.d.ts +6 -0
  125. package/dist/xlsx/dialogs/help-dialogs.d.ts +2 -2
  126. package/dist/xlsx/dialogs/sort-dialog.d.ts +3 -3
  127. package/dist/xlsx/dialogs/watch-window.d.ts +4 -0
  128. package/dist/xlsx/grid/audit-layer.d.ts +3 -0
  129. package/dist/xlsx/grid/grid-view.d.ts +23 -1
  130. package/dist/xlsx/grid/pane-chrome.d.ts +2 -0
  131. package/dist/xlsx/grid/split-bars.d.ts +2 -0
  132. package/dist/xlsx/grid/styles.d.ts +1 -1
  133. package/dist/xlsx/sheet-tabs/drag.d.ts +1 -2
  134. package/dist/xlsx.js +1074 -239
  135. package/package.json +2 -2
package/dist/xlsx.js CHANGED
@@ -1,28 +1,28 @@
1
1
  import { statusLayout, watchStatusWidth, defineChartExOptions } from './chunk-C4KI635Q.js';
2
2
  import { trackPointerGesture } from './chunk-GSXOZCAN.js';
3
- import { chartExSpaceFormatSource } from './chunk-D5IRYZLP.js';
4
- import './chunk-TGG36HHF.js';
3
+ import { chartExSpaceFormatSource } from './chunk-7RRN2GPO.js';
4
+ import './chunk-Z4DML5NW.js';
5
5
  import './chunk-DA57FPSN.js';
6
- import { createHostBackstagePages, syncRibbonAddIns, withHostMenuItems } from './chunk-CDC5MAZS.js';
7
- export { RIBBON_ADD_IN_EVENT } from './chunk-CDC5MAZS.js';
6
+ import { createHostBackstagePages, syncRibbonAddIns, withHostMenuItems } from './chunk-6VF4FEMY.js';
7
+ export { RIBBON_ADD_IN_EVENT } from './chunk-6VF4FEMY.js';
8
8
  import { needsPicturePixels, pictureSvg, pictureEffectFilter, SmartArtTextPaneController, defineSmartArt, defineSmartArtPicker, smartArtStylesGalleryState, smartArtColorsGalleryState, safeColor, svgTile } from './chunk-GZNBWWJ5.js';
9
- import { withExtension, saveExtension, downloadBytes, emit, emitEvent, blobFor, announceFileCommand, pickFile } from './chunk-FFM3WVLU.js';
10
- export { XLSX_EDITOR_EVENTS } from './chunk-FFM3WVLU.js';
9
+ import { withExtension, saveExtension, downloadBytes, emit, emitEvent, blobFor, announceFileCommand, pickFile } from './chunk-7ST5QRD5.js';
10
+ export { XLSX_EDITOR_EVENTS } from './chunk-7ST5QRD5.js';
11
11
  import './chunk-BOTLS2PR.js';
12
12
  import './chunk-CDAXY5KC.js';
13
13
  import './chunk-NDUD5JJB.js';
14
14
  import './chunk-KJMAVPQB.js';
15
15
  import { legacyThemeAliases, legacyThemeBridge, installOfficeUiThemeFor } from './chunk-T5ARELU2.js';
16
- import { range_control_default, createRibbonOverflow, defineBackstage, defineRibbon, defineRibbonActions, defineTitleBar, defineStatusBar, defineZoomSlider, defineChartFormatPane, defineChartDataSheet, defineOptionsDialog, defineDialog, createDialogSession, optionsLabels, runKeyTips, assignKeyTips, chartFormatTranslator, chartSpaceFormatSource, CHART_DATA_SHEET_ENGLISH, userInterfaceSection, personalizeSection, optionText, unavailableControl, unavailableCategory, defineGallery, defineContextMenu, rangeControl, defineColorGrid, defineCommentsPane, defineChartPicker, createLiveColorInput, handleLiveColorEvent } from './chunk-KYXSQFDB.js';
16
+ import { range_control_default, createRibbonOverflow, defineBackstage, defineRibbon, defineRibbonActions, defineTitleBar, defineStatusBar, defineZoomSlider, defineChartFormatPane, defineChartDataSheet, defineOptionsDialog, defineDialog, createDialogSession, optionsLabels, runKeyTips, assignKeyTips, chartFormatTranslator, chartSpaceFormatSource, CHART_DATA_SHEET_ENGLISH, userInterfaceSection, personalizeSection, optionText, unavailableControl, unavailableCategory, defineGallery, defineContextMenu, rangeControl, defineColorGrid, wireTabDrag, defineCommentsPane, defineChartPicker, createLiveColorInput, handleLiveColorEvent } from './chunk-QAX4FAB7.js';
17
17
  import { getIcon, registerIcon } from './chunk-M6GF5ED2.js';
18
18
  import './chunk-4OBMFPGF.js';
19
19
  import { definePresence } from './chunk-YZH2QS7J.js';
20
20
  import './chunk-FN7IF6M6.js';
21
21
  import { withTokens } from './chunk-QLHCGV4C.js';
22
22
  import './chunk-XL77FR4B.js';
23
- import { SPECIAL_CODES, FRACTION_CODES, translate, INSERT_CHART_TYPES, AUTOSUM_FUNCTIONS, ICON_ACCENTS, ICON_PATHS, normalizeEditorLocale, EXCEL_CAPABILITY_BACKSTAGE_PAGES, EXCEL_CAPABILITY_COMMANDS, normalizeThemeMode, applyThemeColors, parseSelectionRef, selectionRef, fontCommands, alignmentCommands, numberCommands, editBridge, FONT_SIZES, FONT_NAMES, style, activeRef, numberFormatOptions, selectionFormatting, DirtyState, createCommandRegistry, createDialogRegistry, createSelectionModel, SheetSelections, translator, initialSelection, sheetBaseName, historyOf, onRibbonTabsChange, activeChart, CellViewCache, QUADRANTS, columnHeaderHeight, rowHeaderWidth, GridGeometry, cellRange, scrollToReveal, buildItems, fitNumber, cssFont, clampAddress, selectCell, movingEnd, extendSelection, moveWithinSelection, rowsRange, colsRange, ALL_RANGE, ribbonTabs, isTabHidden, selectTab, setTabHidden, tabButton, searchCommands, formatNumber, target, activeSmartArt, isSingleCell, spanRange, selectionCellCount, addRange, TEMPLATES, createTemplateWorkbook, fillPaint, iconSvg, colSelected, rowSelected, rowHeaderMenu, columnHeaderMenu, cellMenu, isMenuSeparator, textDecoration, justify, alignItems, textAlign, hasBorders, edgeCss, diagonalSvg, registerRibbonTabs, installFormatPainter, SHEET_ICONS, clipboardCommands, cellCommands, editingCommands, pageLayoutCommands, pageBreakCommands, formulaCommands, dataCommands, whatIfCommands, contextualCommands, reviewTab, viewTab, helpTab, tabMenu, editing, icon, DATA_BAR_COLORS, dataBarRule, COLOR_SCALES, colorScaleRule, iconSetRule, tableAt, timelineSourceAt, slicerSourceAt, viewing, activeTable, BORDER_PRESETS, ORIENTATIONS, ACCOUNTING_FORMATS, themePaletteItems, MARGIN_PRESETS, PAPER_SIZES, FUNCTION_MENUS, MORE_FUNCTION_CATEGORIES, functionsIn, activeSlicer, activeTimeline, activeStyle, selectSpecial, insertFunctionCall, guessHeader, regionOf, evaluateRef, editChart, suggestForecastEnd, FORECAST_AGGREGATIONS, createForecastSheet, ForecastError, forecastMessage, HIGHLIGHT_STYLES, ICON_SETS, TABLE_STYLES, tableStylePreview, resolveNameBox, absoluteReference, nameForRange, recentFunctions, buildChart, createScenarioSummary, detectCategory, CATEGORIES, TIME_CODES, DATE_CODES, DEFAULT_OPTIONS, cellStyleItems, SYMBOLS, buildCode, UNSET, dxfCss, negativeCodes, iconCount, iconThresholds, rowsOf, colsOf } from 'ooxml-core/xlsx/ui';
23
+ import { SPECIAL_CODES, FRACTION_CODES, translate, INSERT_CHART_TYPES, AUTOSUM_FUNCTIONS, ICON_ACCENTS, ICON_PATHS, normalizeEditorLocale, EXCEL_CAPABILITY_BACKSTAGE_PAGES, EXCEL_CAPABILITY_COMMANDS, normalizeThemeMode, applyThemeColors, parseSelectionRef, selectionRef, fontCommands, alignmentCommands, numberCommands, editBridge, FONT_SIZES, FONT_NAMES, style, activeRef, numberFormatOptions, selectionFormatting, DirtyState, createCommandRegistry, createDialogRegistry, createSelectionModel, SheetSelections, translator, initialSelection, sheetBaseName, historyOf, onRibbonTabsChange, activeChart, CellViewCache, QUADRANTS, columnHeaderHeight, rowHeaderWidth, GridGeometry, cellRange, scrollToReveal, buildItems, fitNumber, cssFont, clampAddress, selectCell, movingEnd, extendSelection, moveWithinSelection, rowsRange, colsRange, ALL_RANGE, onAuditChange, setErrorRules, ribbonTabs, isTabHidden, selectTab, setTabHidden, tabButton, searchCommands, formatNumber, target, activeSmartArt, isSingleCell, spanRange, selectionCellCount, auditState, addRange, TEMPLATES, createTemplateWorkbook, fillPaint, iconSvg, colSelected, rowSelected, rowHeaderMenu, columnHeaderMenu, cellMenu, isMenuSeparator, textDecoration, justify, alignItems, textAlign, hasBorders, edgeCss, diagonalSvg, registerRibbonTabs, installFormatPainter, SHEET_ICONS, clipboardCommands, cellCommands, editingCommands, pageLayoutCommands, pageBreakCommands, formulaCommands, dataCommands, whatIfCommands, contextualCommands, reviewTab, viewTab, helpTab, tabMenu, editing, icon, DATA_BAR_COLORS, dataBarRule, COLOR_SCALES, colorScaleRule, iconSetRule, tableAt, timelineSourceAt, slicerSourceAt, viewing, activeTable, removeWatch, setWatchWindowOpen, BORDER_PRESETS, ORIENTATIONS, ACCOUNTING_FORMATS, themePaletteItems, MARGIN_PRESETS, PAPER_SIZES, FUNCTION_MENUS, MORE_FUNCTION_CATEGORIES, functionsIn, activeSlicer, activeTimeline, activeStyle, selectSpecial, insertFunctionCall, guessHeader, regionOf, evaluateRef, editChart, suggestForecastEnd, FORECAST_AGGREGATIONS, createForecastSheet, ForecastError, forecastMessage, HIGHLIGHT_STYLES, addWatch, ICON_SETS, TABLE_STYLES, tableStylePreview, resolveNameBox, absoluteReference, nameForRange, recentFunctions, buildChart, createScenarioSummary, detectCategory, CATEGORIES, TIME_CODES, DATE_CODES, DEFAULT_OPTIONS, cellStyleItems, SYMBOLS, buildCode, UNSET, dxfCss, negativeCodes, iconCount, iconThresholds, rowsOf, colsOf } from 'ooxml-core/xlsx/ui';
24
24
  export { EDITOR_LOCALES, EXCEL_CAPABILITY_IDS, THEME_KEYS, normalizeEditorLocale, registerRibbonTabs, themeToCssVars, darkTheme as xlsxDarkTheme, lightTheme as xlsxLightTheme } from 'ooxml-core/xlsx/ui';
25
- import { createWorksheet, cellInputText, createEditSession, approximateMeasure, createWorkbook, MAX_ROW, MAX_COL, createGridMetrics, mergeAt, visibleCells, getCell, FUNCTION_CATALOG, closeParens, isFormulaText, parseCellInput, formatAddress, referenceTarget, navigate, anchorToPixelBox, createRefEvaluator, chartView, renderChartSvg, CHART_FILL_PARTS, selectionOfPeriods, pixelBoxToAnchor, listValidationOptions, validationAt, getValue, hasFilterCriteria, resolvePasteOptions, selectionStats, formatSelectionStat, chartSpaceOf, xlsxChartExDataSheet, pictureAnchorAt, nameAtCaret, functionMatches, callAtCaret, acceptsReference, formatRange, splice, translateFormula, slicerStyleColors, slicerGeometry, timelineGeometry, TIMELINE_PERIOD_WIDTH, TIMELINE_METRICS, controlStateIn, controlListItems, formControlSvg, shapeSvg, controlLinkCell, controlValueAtFraction, timelineView, slicerItems, selectionAfterClick, isCellError, filterMenuModel, displayText, layoutRemoteSelections, parseHtmlTable, CUT_MULTIPLE, toggleAbsolute, rangeContains, printRange, chartSeriesTransparencyPatch, chartSeriesTransparency, chartSeriesGradientPatch, chartSeriesSolidFillPatch, chartSeriesFillPatch, chartWithElementFills, chartElementTransparencyPatch, chartElementTransparency, chartElementGradientPatch, chartElementSolidFillPatch, chartElementFillPatch, chartElementFill, chartColorScheme, chartBarSpacing, columnLabel, coloredReferences, syntaxParams, activeParam, drawingSchemeColors, applyControlAction, checklistCriteria, pageBreakPreview, pasteAreas, normalizeRange, currentRegion, autoFitColumnWidth, chartGradientStopTransparency, paginateWorksheet, colorFilterCriteria, resolveColor, DEFAULT_THEME, pageHeaderFooter, createPrintMergeIndex, cellView, pixelsToColumnWidth, renderHeaderFooterRuns, planBreakDrag, resizePrintArea, headerFooterPicture, nextSheetName, sheetByName, pivotGroupableFields, pivotGroupableDateFields, pivotSubtotalFields, DEFAULT_COL_WIDTH, pageViewLayout, formatValue, isDateFormat, selectedSparklineGroups, pivotTableAt, validateDefinedName, usedRange, pivotAxisChoices, parseAddress, PIVOT_DATE_UNITS, PIVOT_SUBTOTAL_ORDER, parseRange, decodeCondition, customFilter, topFilterCriteria, parseInputCell, serialToDate, styleAt, rangesIntersect, chartStylePresetOf, chartTakesQuickLayout, SLICER_STYLE_NAMES, slicerStyleLabel, slicerStylePreview, pageViewCellRect, pageOfCell, validateSheetName, dateToSerial, IMAGE_EXTENSIONS, verifySheetPassword, verifyWorkbookPassword, quoteSheetName, pivotRowFields, pivotValuesIndex, pivotSourceData, defaultFieldGroup, defaultDateGroup, dateGroupDays, pivotIsoToSerial, fieldSubtotalFunctions, printTitles, formatPrintTitleSpan, parsePrintTitleSpan, parseBreakPositions, splitFixedWidth, splitDelimited, scenariosOf, PAGE_VIEW_GAP, pivotPageItems, pivotPageItemLabel, pivotSerialToIso, previewScenario, customViewsOf, BUILTIN_NUMBER_FORMATS, validateTableName, pixelsToEmu, pageViewHit, resizedFrameAnchor, headerFooterKey, splitHeaderFooter, composeHeaderFooter } from 'ooxml-core/xlsx';
25
+ import { createWorksheet, cellInputText, createEditSession, approximateMeasure, createWorkbook, MAX_ROW, MAX_COL, createGridMetrics, splitToPx, splitAtCell, mergeAt, splitVisible, visibleCells, getCell, FUNCTION_CATALOG, closeParens, isFormulaText, parseCellInput, formatAddress, referenceTarget, navigate, anchorToPixelBox, createRefEvaluator, chartView, renderChartSvg, CHART_FILL_PARTS, selectionOfPeriods, pixelBoxToAnchor, listValidationOptions, validationAt, getValue, hasFilterCriteria, resolvePasteOptions, ERROR_RULES, selectionStats, formatSelectionStat, chartSpaceOf, xlsxChartExDataSheet, pictureAnchorAt, nameAtCaret, functionMatches, callAtCaret, acceptsReference, formatRange, splice, translateFormula, slicerStyleColors, slicerGeometry, timelineGeometry, TIMELINE_PERIOD_WIDTH, TIMELINE_METRICS, controlStateIn, controlListItems, formControlSvg, shapeSvg, controlLinkCell, controlValueAtFraction, timelineView, slicerItems, selectionAfterClick, isCellError, filterMenuModel, displayText, layoutRemoteSelections, parseHtmlTable, CUT_MULTIPLE, toggleAbsolute, rangeContains, printRange, chartSeriesTransparencyPatch, chartSeriesTransparency, chartSeriesGradientPatch, chartSeriesSolidFillPatch, chartSeriesFillPatch, chartWithElementFills, chartElementTransparencyPatch, chartElementTransparency, chartElementGradientPatch, chartElementSolidFillPatch, chartElementFillPatch, chartElementFill, chartColorScheme, chartBarSpacing, columnLabel, coloredReferences, syntaxParams, activeParam, drawingSchemeColors, applyControlAction, checklistCriteria, pageBreakPreview, pxToSplit, pasteAreas, normalizeRange, currentRegion, autoFitColumnWidth, chartGradientStopTransparency, paginateWorksheet, colorFilterCriteria, clampSplitBar, resolveColor, DEFAULT_THEME, pageHeaderFooter, createPrintMergeIndex, cellView, pixelsToColumnWidth, renderHeaderFooterRuns, planBreakDrag, resizePrintArea, headerFooterPicture, nextSheetName, sheetByName, pivotGroupableFields, pivotGroupableDateFields, pivotSubtotalFields, DEFAULT_COL_WIDTH, pageViewLayout, formatValue, isDateFormat, selectedSparklineGroups, pivotTableAt, FormulaStepper, findErrors, adjacentIssue, withIgnoredError, parseNumberText, validateDefinedName, usedRange, pivotAxisChoices, parseAddress, PIVOT_DATE_UNITS, PIVOT_SUBTOTAL_ORDER, parseRange, decodeCondition, customFilter, topFilterCriteria, parseInputCell, serialToDate, styleAt, rangesIntersect, watchExists, describeWatch, watchValueText, chartStylePresetOf, chartTakesQuickLayout, SLICER_STYLE_NAMES, slicerStyleLabel, slicerStylePreview, pageViewCellRect, pageOfCell, validateSheetName, dateToSerial, IMAGE_EXTENSIONS, verifySheetPassword, verifyWorkbookPassword, quoteSheetName, pivotRowFields, pivotValuesIndex, pivotSourceData, defaultFieldGroup, defaultDateGroup, dateGroupDays, pivotIsoToSerial, fieldSubtotalFunctions, printTitles, formatPrintTitleSpan, parsePrintTitleSpan, parseBreakPositions, splitFixedWidth, splitDelimited, scenariosOf, parseSortList, PAGE_VIEW_GAP, pivotPageItems, pivotPageItemLabel, pivotSerialToIso, previewScenario, customViewsOf, BUILTIN_NUMBER_FORMATS, BUILT_IN_SORT_LISTS, sortChoices, validateTableName, pixelsToEmu, pageViewHit, resizedFrameAnchor, headerFooterKey, splitHeaderFooter, composeHeaderFooter } from 'ooxml-core/xlsx';
26
26
  import { isCapabilityEnabled, capabilityHiddenActions, saveToStorage, documentSaveMeta, withoutHiddenEntries } from 'ooxml-core/embedding';
27
27
  import { hyperlinkPolicy } from 'ooxml-core/opc';
28
28
  import { previewDiagramLayout, resolveDiagramDrawingStyles, DIAGRAM_INSERT_CATEGORIES, DIAGRAM_INSERT_PRESETS, RECT_GRADIENT_DIRECTIONS, OFFICE_GRADIENT_PRESETS, officeGradientPresetId, officeGradientPresetFill, resolveDrawingColor, drawingColorBrightness, drawingColorCss, rectGradientDirection, DIAGRAM_DESIGN_COMMANDS, DIAGRAM_COLOR_ENTRIES, DIAGRAM_STYLE_ENTRIES, DIAGRAM_ADD_SHAPE_LABEL, DIAGRAM_DESIGN_GROUPS, DIAGRAM_ADD_SHAPE_COMMANDS } from 'ooxml-core/diagram';
@@ -838,6 +838,16 @@ var LANGUAGES = [
838
838
  var DEFAULT_ITERATIONS = 100;
839
839
  var DEFAULT_MAX_CHANGE = 1e-3;
840
840
  var DIRECT_KEYS = ["locale", "theme", "author", "calculation"];
841
+ var RULE_LABELS = {
842
+ "error-value": "Cells containing formulas that result in an error",
843
+ "calculated-column": "Inconsistent calculated column formula in tables",
844
+ "number-as-text": "Numbers formatted as text or preceded by an apostrophe",
845
+ "inconsistent-formula": "Formulas inconsistent with other formulas in the region",
846
+ "omits-adjacent-cells": "Formulas which omit cells in a region",
847
+ "unlocked-formula": "Unlocked cells containing formulas",
848
+ "empty-cell-reference": "Formulas referring to empty cells"
849
+ };
850
+ var ruleKey = (rule2) => "rule:" + rule2;
841
851
  var ITERATION_KEYS = ["iterate", "iterationCount", "iterationDelta"];
842
852
  function excelCategories(context) {
843
853
  const { t } = context;
@@ -917,6 +927,15 @@ function excelCategories(context) {
917
927
  }
918
928
  ]
919
929
  },
930
+ {
931
+ id: "error-checking",
932
+ title: t("Error Checking Rules"),
933
+ controls: ERROR_RULES.map((rule2) => ({
934
+ kind: "toggle",
935
+ key: ruleKey(rule2),
936
+ label: t(RULE_LABELS[rule2])
937
+ }))
938
+ },
920
939
  {
921
940
  id: "working",
922
941
  title: t("Working with formulas"),
@@ -982,7 +1001,10 @@ function dialogValues(host) {
982
1001
  calculation: current.calculation,
983
1002
  iterate: Boolean(current.iteration),
984
1003
  iterationCount: current.iteration?.count ?? DEFAULT_ITERATIONS,
985
- iterationDelta: current.iteration?.delta ?? DEFAULT_MAX_CHANGE
1004
+ iterationDelta: current.iteration?.delta ?? DEFAULT_MAX_CHANGE,
1005
+ ...Object.fromEntries(
1006
+ ERROR_RULES.map((rule2) => [ruleKey(rule2), auditState(host.ctx).rules.includes(rule2)])
1007
+ )
986
1008
  };
987
1009
  }
988
1010
  function iterationOf(values) {
@@ -1013,13 +1035,21 @@ function createExcelOptions(host) {
1013
1035
  calculation: "automatic",
1014
1036
  iterate: false,
1015
1037
  iterationCount: DEFAULT_ITERATIONS,
1016
- iterationDelta: DEFAULT_MAX_CHANGE
1038
+ iterationDelta: DEFAULT_MAX_CHANGE,
1039
+ ...Object.fromEntries(
1040
+ ERROR_RULES.map((rule2) => [ruleKey(rule2), rule2 !== "empty-cell-reference"])
1041
+ )
1017
1042
  };
1018
1043
  };
1019
1044
  element.addEventListener("office-options-change", (event) => {
1020
1045
  const { values, changed } = event.detail;
1021
1046
  for (const key of DIRECT_KEYS)
1022
1047
  if (changed.includes(key)) host.setOption(key, String(values[key]));
1048
+ if (changed.some((key) => key.startsWith("rule:")))
1049
+ setErrorRules(
1050
+ ctx,
1051
+ ERROR_RULES.filter((rule2) => values[ruleKey(rule2)] === true)
1052
+ );
1023
1053
  if (changed.some((key) => ITERATION_KEYS.includes(key)))
1024
1054
  host.setOption("iteration", iterationOf(values));
1025
1055
  build();
@@ -1147,8 +1177,8 @@ function resolveExcelCustomization(customization) {
1147
1177
  }
1148
1178
  var EMPTY_EXCEL_CUSTOMIZATION = resolveExcelCustomization();
1149
1179
  var registry = /* @__PURE__ */ new WeakMap();
1150
- function provideCustomization(ctx, read) {
1151
- registry.set(ctx, read);
1180
+ function provideCustomization(ctx, read2) {
1181
+ registry.set(ctx, read2);
1152
1182
  }
1153
1183
  function customizationOf(ctx) {
1154
1184
  return registry.get(ctx)?.() ?? EMPTY_EXCEL_CUSTOMIZATION;
@@ -3374,7 +3404,188 @@ function openGoToSpecial(ctx) {
3374
3404
  });
3375
3405
  }
3376
3406
 
3377
- // src/xlsx/dialogs/comments-list.ts
3407
+ // src/xlsx/dialogs/audit-dialogs.ts
3408
+ var evalBox = (ctx) => {
3409
+ const box = el(ctx, "div", "xve-eval-box");
3410
+ box.style.cssText = "font-family:Consolas,monospace;border:1px solid var(--xve-input,var(--office-border,#c8c6c4));padding:6px 8px;min-height:3em;white-space:pre-wrap;word-break:break-all";
3411
+ return box;
3412
+ };
3413
+ function openEvaluateFormula(ctx, at) {
3414
+ const session = ctx.session();
3415
+ const active2 = ctx.selection.get().active;
3416
+ const start = at ?? { sheet: ctx.activeSheet(), row: active2.row, col: active2.col };
3417
+ if (!session || !FormulaStepper.canEvaluate(session.workbook, start)) {
3418
+ ctx.toast(ctx.t("Evaluate Formula needs a cell that contains a formula."), "warning");
3419
+ return Promise.resolve(void 0);
3420
+ }
3421
+ const stepper = new FormulaStepper(session.workbook, session.calc, start);
3422
+ const reference = evalBox(ctx);
3423
+ const evaluation = evalBox(ctx);
3424
+ const stepIn = button(ctx, "Step In");
3425
+ const stepOut = button(ctx, "Step Out");
3426
+ const evaluate = button(ctx, "Evaluate", true);
3427
+ let finished = false;
3428
+ const paint = () => {
3429
+ const view = stepper.view();
3430
+ finished = view.finished;
3431
+ reference.textContent = view.reference;
3432
+ evaluation.replaceChildren();
3433
+ const { underline } = view;
3434
+ const doc = ctx.host.ownerDocument;
3435
+ if (underline) {
3436
+ const u = doc.createElement("u");
3437
+ u.textContent = view.text.slice(underline.start, underline.end);
3438
+ evaluation.append(
3439
+ doc.createTextNode(view.text.slice(0, underline.start)),
3440
+ u,
3441
+ doc.createTextNode(view.text.slice(underline.end))
3442
+ );
3443
+ } else evaluation.textContent = view.text;
3444
+ stepIn.disabled = !view.canStepIn;
3445
+ stepOut.disabled = !view.canStepOut;
3446
+ evaluate.textContent = ctx.t(finished ? "Restart" : "Evaluate");
3447
+ };
3448
+ stepIn.addEventListener("click", () => (stepper.stepIn(), paint()));
3449
+ stepOut.addEventListener("click", () => (stepper.stepOut(), paint()));
3450
+ evaluate.addEventListener("click", () => {
3451
+ if (finished) stepper.restart();
3452
+ else stepper.evaluate();
3453
+ paint();
3454
+ });
3455
+ paint();
3456
+ const labelled2 = (key, box) => {
3457
+ const wrap = el(ctx, "div");
3458
+ wrap.append(text(ctx, key, "xve-field-label"), box);
3459
+ return wrap;
3460
+ };
3461
+ return showDialog(ctx, {
3462
+ name: "evaluate-formula",
3463
+ heading: "Evaluate Formula",
3464
+ okLabel: null,
3465
+ buttons: [stepIn, stepOut, evaluate],
3466
+ body: [labelled2("Reference:", reference), labelled2("Evaluation:", evaluation)],
3467
+ opened: () => evaluate.focus()
3468
+ });
3469
+ }
3470
+ var RULE_TEXT = {
3471
+ "error-value": ["Error in cell {cell}", "The formula in this cell results in the error {code}."],
3472
+ "number-as-text": [
3473
+ "Number stored as text",
3474
+ "The number in this cell is formatted as text or preceded by an apostrophe."
3475
+ ],
3476
+ "inconsistent-formula": [
3477
+ "Inconsistent formula",
3478
+ "The formula in this cell differs from the formulas in this area of the spreadsheet."
3479
+ ],
3480
+ "omits-adjacent-cells": [
3481
+ "Formula omits adjacent cells",
3482
+ "The formula in this cell refers to a range that has additional numbers adjacent to it."
3483
+ ],
3484
+ "empty-cell-reference": [
3485
+ "Formula refers to empty cells",
3486
+ "The formula in this cell refers to cells that are empty."
3487
+ ],
3488
+ "calculated-column": [
3489
+ "Inconsistent calculated column formula",
3490
+ "The formula in this cell differs from the formula of the rest of its table column."
3491
+ ],
3492
+ "unlocked-formula": [
3493
+ "Unlocked cell containing formula",
3494
+ "This cell contains a formula and is not locked, so it can still be changed when the sheet is protected."
3495
+ ]
3496
+ };
3497
+ function openErrorChecking(ctx) {
3498
+ const session = ctx.session();
3499
+ if (!session) return Promise.resolve(void 0);
3500
+ const workbook = session.workbook;
3501
+ const sheet = ctx.activeSheet();
3502
+ const active2 = ctx.selection.get().active;
3503
+ let issues = findErrors(workbook, sheet, auditState(ctx).rules);
3504
+ let current = adjacentIssue(issues, { sheet, row: active2.row, col: active2.col }, 1, true);
3505
+ const complete = () => ctx.toast(ctx.t("The error check is complete for the entire sheet."), "info");
3506
+ if (!current) {
3507
+ complete();
3508
+ return Promise.resolve(void 0);
3509
+ }
3510
+ const title = el(ctx, "strong");
3511
+ const body = el(ctx, "p", "xve-note");
3512
+ const ignore = button(ctx, "Ignore Error");
3513
+ const edit = button(ctx, "Edit in Formula Bar");
3514
+ const steps = button(ctx, "Show Calculation Steps...");
3515
+ const convert = button(ctx, "Convert to Number");
3516
+ const prev = button(ctx, "Previous");
3517
+ const next = button(ctx, "Next");
3518
+ let close = () => void 0;
3519
+ const show = (issue) => {
3520
+ current = issue;
3521
+ selectOn(ctx, issue.sheet, { start: issue, end: issue });
3522
+ const [head, detail] = RULE_TEXT[issue.rule];
3523
+ const vars = {
3524
+ cell: formatAddress({ row: issue.row, col: issue.col }),
3525
+ code: issue.code ?? ""
3526
+ };
3527
+ title.textContent = ctx.t(head, vars);
3528
+ body.textContent = ctx.t(detail, vars);
3529
+ steps.hidden = issue.rule !== "error-value";
3530
+ convert.hidden = issue.rule !== "number-as-text";
3531
+ convert.disabled = ctx.readOnly();
3532
+ prev.disabled = next.disabled = issues.length < 2;
3533
+ };
3534
+ const go = (direction) => {
3535
+ if (current) {
3536
+ const target42 = adjacentIssue(issues, current, direction);
3537
+ if (target42) show(target42);
3538
+ }
3539
+ };
3540
+ prev.addEventListener("click", () => go(-1));
3541
+ next.addEventListener("click", () => go(1));
3542
+ ignore.addEventListener("click", () => {
3543
+ if (!current) return;
3544
+ const done = current;
3545
+ session.setIgnoredErrors(done.sheet, withIgnoredError(workbook, done));
3546
+ issues = findErrors(workbook, sheet, auditState(ctx).rules);
3547
+ const target42 = adjacentIssue(issues, done, 1);
3548
+ if (!target42) {
3549
+ close();
3550
+ complete();
3551
+ } else show(target42);
3552
+ });
3553
+ edit.addEventListener("click", () => {
3554
+ close();
3555
+ ctx.grid()?.beginEdit();
3556
+ });
3557
+ steps.addEventListener("click", () => {
3558
+ if (!current) return;
3559
+ const at = { sheet: current.sheet, row: current.row, col: current.col };
3560
+ close();
3561
+ void openEvaluateFormula(ctx, at);
3562
+ });
3563
+ convert.addEventListener("click", () => {
3564
+ if (!current) return;
3565
+ const cell = workbook.sheets[current.sheet]?.rows.get(current.row)?.get(current.col);
3566
+ const value = typeof cell?.value === "string" ? parseNumberText(cell.value) : void 0;
3567
+ if (value === void 0) return;
3568
+ session.setCellInput(current.sheet, current.row, current.col, String(value));
3569
+ issues = findErrors(workbook, sheet, auditState(ctx).rules);
3570
+ const target42 = adjacentIssue(issues, current, 1);
3571
+ if (!target42) {
3572
+ close();
3573
+ complete();
3574
+ } else show(target42);
3575
+ });
3576
+ return showDialog(
3577
+ ctx,
3578
+ {
3579
+ name: "error-checking",
3580
+ heading: "Error Checking",
3581
+ okLabel: null,
3582
+ buttons: [prev, next, ignore, edit, steps, convert],
3583
+ body: [title, body],
3584
+ opened: () => show(current)
3585
+ },
3586
+ (open) => close = () => open.close()
3587
+ );
3588
+ }
3378
3589
  function excelCommentThreads(comments) {
3379
3590
  return [...comments].sort((a, b) => a.address.row - b.address.row || a.address.col - b.address.col).map((comment) => {
3380
3591
  const id = formatAddress(comment.address);
@@ -4218,9 +4429,9 @@ function commandButton(scope, command, options = {}) {
4218
4429
  });
4219
4430
  return button2;
4220
4431
  }
4221
- var safe = (read) => {
4432
+ var safe = (read2) => {
4222
4433
  try {
4223
- return read();
4434
+ return read2();
4224
4435
  } catch {
4225
4436
  return void 0;
4226
4437
  }
@@ -4530,16 +4741,14 @@ var SUPPORTED_FEATURES = [
4530
4741
  "Data validation",
4531
4742
  "Sort and filter",
4532
4743
  "AutoFilter drop-down: value checklist with search, Text, Number and Date filters, Top 10, Above and Below Average, colour and custom criteria",
4533
- "Freeze panes"
4744
+ "Freeze panes",
4745
+ "Formula auditing: Trace Precedents and Dependents, Remove Arrows, Evaluate Formula, Error Checking and Watch Window"
4534
4746
  ];
4535
4747
  var UNSUPPORTED_FEATURES = [
4536
4748
  "Unmodeled PivotTable layouts, grouping, slicers and external data sources (preserved)",
4537
4749
  "Multiple/dynamic report filters and repeated column captions (preserved)",
4538
4750
  "AutoFilter on table headers, the date-hierarchy checklist and icon filters from the menu",
4539
- "Sorting by cell colour, font colour or icon",
4540
4751
  "Flash Fill, Subtotal and Consolidate",
4541
- "Split panes (Freeze Panes works)",
4542
- "Formula auditing: Trace Precedents, Trace Dependents, Evaluate Formula, Watch Window",
4543
4752
  "Opening .xlsb binary workbooks",
4544
4753
  "Editing threaded comment replies",
4545
4754
  "Macros (VBA is kept in the file but never run)",
@@ -4875,6 +5084,8 @@ var obj = (props2) => props2 && typeof props2 === "object" ? props2 : {};
4875
5084
  function registerNavigationDialogs(ctx) {
4876
5085
  const d = ctx.dialogs;
4877
5086
  d.register("find-replace", (c, p) => openFindReplace(c, obj(p)));
5087
+ d.register("evaluate-formula", (c) => openEvaluateFormula(c));
5088
+ d.register("error-checking", (c) => openErrorChecking(c));
4878
5089
  d.register("go-to", (c) => openGoTo(c));
4879
5090
  d.register("go-to-special", (c) => openGoToSpecial(c));
4880
5091
  d.register("insert-function", (c, p) => openInsertFunction(c, obj(p)));
@@ -5535,9 +5746,9 @@ function editRuleDialog(ctx, initial) {
5535
5746
  ],
5536
5747
  opened: () => types.element.focus(),
5537
5748
  submit: () => {
5538
- const read = panels[kind].read(structuredClone(style2));
5539
- if ("error" in read) return invalid(ctx, read.control, read.error, read.vars);
5540
- const rule2 = keepExtras(read, initial?.rule);
5749
+ const read2 = panels[kind].read(structuredClone(style2));
5750
+ if ("error" in read2) return invalid(ctx, read2.control, read2.error, read2.vars);
5751
+ const rule2 = keepExtras(read2, initial?.rule);
5541
5752
  return { rule: rule2, ranges };
5542
5753
  }
5543
5754
  });
@@ -6083,7 +6294,7 @@ function dataValidationDialog(ctx) {
6083
6294
  for (const input of [promptTitle, prompt, errorTitle, error]) input.value = "";
6084
6295
  sync();
6085
6296
  });
6086
- const read = () => {
6297
+ const read2 = () => {
6087
6298
  const type = allow.value;
6088
6299
  const hasMessages = promptTitle.value || prompt.value || errorTitle.value || error.value;
6089
6300
  if (type === "none" && !hasMessages) return null;
@@ -6127,7 +6338,7 @@ function dataValidationDialog(ctx) {
6127
6338
  buttons: [clear],
6128
6339
  opened: () => allow.focus(),
6129
6340
  submit: () => {
6130
- const dv = read();
6341
+ const dv = read2();
6131
6342
  if (dv === void 0) return void 0;
6132
6343
  t.session.batch("Data validation", () => {
6133
6344
  for (const range2 of t.ranges) t.session.setDataValidation(t.sheet, dv ?? void 0, range2);
@@ -6213,7 +6424,7 @@ function hyperlinkDialog(ctx) {
6213
6424
  let removed = false;
6214
6425
  const remove = button(ctx, "Remove Link");
6215
6426
  const buttons = existing ? [remove] : [];
6216
- const read = () => {
6427
+ const read2 = () => {
6217
6428
  const link = {};
6218
6429
  const v = linkTo.get();
6219
6430
  if (v === "web") {
@@ -6253,7 +6464,7 @@ function hyperlinkDialog(ctx) {
6253
6464
  buttons,
6254
6465
  opened: () => (kind === "web" ? address : kind === "email" ? email : ref).focus(),
6255
6466
  submit: () => {
6256
- const link = read();
6467
+ const link = read2();
6257
6468
  if (!link) return void 0;
6258
6469
  t.session.batch("Insert link", () => {
6259
6470
  if (shownChanged(cellText2, display.value) && link.display)
@@ -6274,23 +6485,150 @@ function hyperlinkDialog(ctx) {
6274
6485
  );
6275
6486
  }
6276
6487
  var shownChanged = (cellText2, display) => cellText2 !== "" && display.trim() !== "" && display.trim() !== cellText2;
6488
+
6489
+ // src/xlsx/dialogs/custom-lists.ts
6490
+ var KEY = "ooxml.xlsx.customLists";
6491
+ var memory = [];
6492
+ function read() {
6493
+ try {
6494
+ const raw = globalThis.localStorage?.getItem(KEY);
6495
+ if (raw === null || raw === void 0) return memory;
6496
+ const parsed = JSON.parse(raw);
6497
+ if (!Array.isArray(parsed)) return memory;
6498
+ return parsed.filter(
6499
+ (list) => Array.isArray(list) && list.every((s) => typeof s === "string")
6500
+ ).filter((list) => list.length > 0);
6501
+ } catch {
6502
+ return memory;
6503
+ }
6504
+ }
6505
+ var userSortLists = () => read().map((list) => [...list]);
6506
+ function saveUserSortList(items2) {
6507
+ const lists = read();
6508
+ const same = lists.findIndex(
6509
+ (list) => list.length === items2.length && list.every((item, i) => item === items2[i])
6510
+ );
6511
+ if (same >= 0) return same;
6512
+ memory = [...lists, [...items2]];
6513
+ try {
6514
+ globalThis.localStorage?.setItem(KEY, JSON.stringify(memory));
6515
+ } catch {
6516
+ }
6517
+ return memory.length - 1;
6518
+ }
6519
+
6520
+ // src/xlsx/dialogs/sort-dialog.ts
6521
+ var NEW_LIST = "new";
6522
+ var allLists = () => [
6523
+ ...BUILT_IN_SORT_LISTS.map((items2) => [...items2]),
6524
+ ...userSortLists()
6525
+ ];
6277
6526
  function sortDialog(ctx) {
6278
6527
  const t = target(ctx);
6279
6528
  if (!t) return Promise.resolve(void 0);
6280
6529
  const region = regionOf(t);
6281
6530
  const header = checkbox(ctx, "My data has headers", guessHeader(t.ws, region));
6531
+ const caseBox = checkbox(ctx, "Case sensitive");
6532
+ const orientation = select(
6533
+ ctx,
6534
+ [
6535
+ ["tb", "Sort top to bottom"],
6536
+ ["lr", "Sort left to right"]
6537
+ ],
6538
+ "tb"
6539
+ );
6540
+ orientation.setAttribute("aria-label", ctx.t("Orientation"));
6541
+ const optionsPanel = row(ctx, caseBox.wrapper, orientation);
6542
+ optionsPanel.hidden = true;
6282
6543
  const levels = [];
6283
6544
  const list = el(ctx, "div", "xve-sort-levels");
6284
6545
  let selected2 = 0;
6285
- const columnOptions = () => {
6546
+ const across = () => orientation.value === "lr";
6547
+ const choicesCache = /* @__PURE__ */ new Map();
6548
+ const choicesFor = (key) => {
6549
+ const id = `${across()}:${header.input.checked}:${key}`;
6550
+ let found = choicesCache.get(id);
6551
+ if (!found) {
6552
+ const workbook = ctx.workbook();
6553
+ found = workbook ? sortChoices(
6554
+ workbook,
6555
+ t.sheet,
6556
+ (formula, at) => t.session.calc.evaluate(formula, at),
6557
+ region,
6558
+ key,
6559
+ header.input.checked,
6560
+ across()
6561
+ ) : { fills: [], noFill: false, fonts: [], icons: [], noIcon: false };
6562
+ choicesCache.set(id, found);
6563
+ }
6564
+ return found;
6565
+ };
6566
+ const lineOptions = () => {
6286
6567
  const out = [];
6287
- for (let col = region.start.col; col <= region.end.col; col++) {
6288
- const head = getCell(t.ws, region.start.row, col)?.value;
6289
- const label = header.input.checked && head !== null && head !== void 0 && String(head) !== "" ? String(head) : ctx.t("Column {name}", { name: columnLabel(col) });
6290
- out.push([String(col), label]);
6568
+ const [from, to] = across() ? [region.start.row, region.end.row] : [region.start.col, region.end.col];
6569
+ for (let at = from; at <= to; at++) {
6570
+ const head = across() ? getCell(t.ws, at, region.start.col)?.value : getCell(t.ws, region.start.row, at)?.value;
6571
+ const named = header.input.checked && head !== null && head !== void 0 && head !== "";
6572
+ out.push([
6573
+ String(at),
6574
+ named ? String(head) : across() ? ctx.t("Row {name}", { name: String(at + 1) }) : ctx.t("Column {name}", { name: columnLabel(at) })
6575
+ ]);
6291
6576
  }
6292
6577
  return out;
6293
6578
  };
6579
+ const fill = (sel, options2, raw = false) => {
6580
+ const value = sel.value;
6581
+ sel.replaceChildren(...options2.map(([v, label]) => new Option(raw ? label : ctx.t(label), v)));
6582
+ if (options2.some(([v]) => v === value)) sel.value = value;
6583
+ };
6584
+ const refresh = (level) => {
6585
+ const on = level.on.value;
6586
+ const plain = on === "value";
6587
+ const [before, after] = across() ? ["On Left", "On Right"] : ["On Top", "On Bottom"];
6588
+ fill(
6589
+ level.order,
6590
+ plain ? [
6591
+ ["asc", "A to Z"],
6592
+ ["desc", "Z to A"],
6593
+ ["custom", "Custom List..."]
6594
+ ] : [
6595
+ ["top", before],
6596
+ ["bottom", after]
6597
+ ]
6598
+ );
6599
+ level.choice.hidden = plain;
6600
+ const found = choicesFor(Number(level.column.value));
6601
+ if (on === "cellColor")
6602
+ fill(
6603
+ level.choice,
6604
+ [
6605
+ ...found.noFill ? [["", ctx.t("No Cell Color")]] : [],
6606
+ ...found.fills.map((c) => [c, c])
6607
+ ],
6608
+ true
6609
+ );
6610
+ else if (on === "fontColor")
6611
+ fill(
6612
+ level.choice,
6613
+ found.fonts.map((c) => [c, c === "#000000" ? ctx.t("Automatic") : c]),
6614
+ true
6615
+ );
6616
+ else if (on === "icon")
6617
+ fill(
6618
+ level.choice,
6619
+ [
6620
+ ...found.noIcon ? [["none", ctx.t("No Cell Icon")]] : [],
6621
+ ...found.icons.map((i) => [
6622
+ `${i.set}:${i.index}`,
6623
+ `${i.set} ${i.index + 1}`
6624
+ ])
6625
+ ],
6626
+ true
6627
+ );
6628
+ const custom = plain && level.order.value === "custom";
6629
+ level.listPick.hidden = !custom;
6630
+ level.listText.hidden = !custom || level.listPick.value !== NEW_LIST;
6631
+ };
6294
6632
  const render2 = () => {
6295
6633
  list.replaceChildren(
6296
6634
  ...levels.map((level, i) => {
@@ -6301,53 +6639,90 @@ function sortDialog(ctx) {
6301
6639
  })
6302
6640
  );
6303
6641
  };
6304
- const addLevel = (col, descending, at = levels.length) => {
6305
- const column = select(ctx, columnOptions(), String(col), true);
6306
- column.setAttribute("aria-label", ctx.t("Column"));
6307
- const on = select(ctx, [["values", "Cell Values"]], "values");
6308
- on.setAttribute("aria-label", ctx.t("Sort On"));
6309
- const order = select(
6642
+ const addLevel = (col, descending, at = levels.length, from) => {
6643
+ const column = select(ctx, lineOptions(), String(col), true);
6644
+ column.setAttribute("aria-label", ctx.t(across() ? "Row" : "Column"));
6645
+ const on = select(
6310
6646
  ctx,
6311
6647
  [
6312
- ["asc", "A to Z"],
6313
- ["desc", "Z to A"]
6648
+ ["value", "Cell Values"],
6649
+ ["cellColor", "Cell Color"],
6650
+ ["fontColor", "Font Color"],
6651
+ ["icon", "Conditional Formatting Icon"]
6314
6652
  ],
6315
- descending ? "desc" : "asc"
6653
+ from?.on.value ?? "value"
6316
6654
  );
6655
+ on.setAttribute("aria-label", ctx.t("Sort On"));
6656
+ const order = select(ctx, [["asc", "A to Z"]], descending ? "desc" : "asc");
6317
6657
  order.setAttribute("aria-label", ctx.t("Order"));
6658
+ const choice = select(ctx, [], void 0, true);
6659
+ choice.setAttribute("aria-label", ctx.t("Color"));
6660
+ const listPick = select(
6661
+ ctx,
6662
+ [
6663
+ ...allLists().map((items2, i) => [String(i), items2.join(", ")]),
6664
+ [NEW_LIST, ctx.t("New list...")]
6665
+ ],
6666
+ void 0,
6667
+ true
6668
+ );
6669
+ listPick.setAttribute("aria-label", ctx.t("Custom List..."));
6670
+ const listText = textInput(ctx, "");
6671
+ listText.setAttribute("aria-label", ctx.t("List entries"));
6318
6672
  const caption = el(ctx, "span", "xve-field-label xve-sort-caption");
6319
- const element = row(ctx, caption, column, on, order);
6320
- const level = { element, column, order };
6673
+ const element = row(ctx, caption, column, on, choice, order, listPick, listText);
6674
+ const level = { element, column, on, order, choice, listPick, listText };
6321
6675
  element.addEventListener("focusin", () => {
6322
6676
  selected2 = levels.indexOf(level);
6323
6677
  render2();
6324
6678
  });
6679
+ for (const sel of [on, column, order, listPick])
6680
+ sel.addEventListener("change", () => refresh(level));
6325
6681
  levels.splice(at, 0, level);
6326
6682
  selected2 = at;
6683
+ refresh(level);
6684
+ if (from) {
6685
+ order.value = from.order.value;
6686
+ choice.value = from.choice.value;
6687
+ listPick.value = from.listPick.value;
6688
+ listText.value = from.listText.value;
6689
+ refresh(level);
6690
+ }
6327
6691
  render2();
6328
6692
  };
6693
+ const rebuildColumns = () => {
6694
+ choicesCache.clear();
6695
+ const options2 = lineOptions();
6696
+ for (const level of levels) {
6697
+ const value = options2.some(([v]) => v === level.column.value) ? level.column.value : options2[0][0];
6698
+ fill(level.column, options2, true);
6699
+ level.column.value = value;
6700
+ level.column.setAttribute("aria-label", ctx.t(across() ? "Row" : "Column"));
6701
+ refresh(level);
6702
+ }
6703
+ };
6329
6704
  addLevel(
6330
6705
  t.active.col >= region.start.col && t.active.col <= region.end.col ? t.active.col : region.start.col,
6331
6706
  false
6332
6707
  );
6333
- header.input.addEventListener("change", () => {
6334
- const options = columnOptions();
6335
- for (const level of levels) {
6336
- const value = level.column.value;
6337
- level.column.replaceChildren(...options.map(([v, label]) => new Option(label, v)));
6338
- level.column.value = value;
6339
- }
6708
+ header.input.addEventListener("change", rebuildColumns);
6709
+ orientation.addEventListener("change", () => {
6710
+ for (const level of levels) level.column.replaceChildren();
6711
+ rebuildColumns();
6340
6712
  });
6341
6713
  const add = button(ctx, "Add Level");
6342
6714
  const remove = button(ctx, "Delete Level");
6343
6715
  const copy = button(ctx, "Copy Level");
6344
6716
  const up = button(ctx, "Move Up");
6345
6717
  const down = button(ctx, "Move Down");
6718
+ const options = button(ctx, "Options...");
6719
+ options.addEventListener("click", () => optionsPanel.hidden = !optionsPanel.hidden);
6346
6720
  add.addEventListener("click", () => {
6347
6721
  const used = new Set(levels.map((l) => Number(l.column.value)));
6348
- let col = region.start.col;
6349
- while (used.has(col) && col < region.end.col) col++;
6350
- addLevel(col, false);
6722
+ const [from, to] = across() ? [region.start.row, region.end.row] : [region.start.col, region.end.col];
6723
+ let at = from;
6724
+ while (used.has(at) && at < to) at++;
6725
+ addLevel(at, false);
6351
6726
  });
6352
6727
  remove.addEventListener("click", () => {
6353
6728
  if (levels.length <= 1) return;
@@ -6357,7 +6732,8 @@ function sortDialog(ctx) {
6357
6732
  });
6358
6733
  copy.addEventListener("click", () => {
6359
6734
  const level = levels[selected2];
6360
- if (level) addLevel(Number(level.column.value), level.order.value === "desc", selected2 + 1);
6735
+ if (level)
6736
+ addLevel(Number(level.column.value), level.order.value === "desc", selected2 + 1, level);
6361
6737
  });
6362
6738
  const move = (delta) => {
6363
6739
  const to = selected2 + delta;
@@ -6369,18 +6745,44 @@ function sortDialog(ctx) {
6369
6745
  };
6370
6746
  up.addEventListener("click", () => move(-1));
6371
6747
  down.addEventListener("click", () => move(1));
6748
+ const keyOf = (level) => {
6749
+ const col = Number(level.column.value);
6750
+ const on = level.on.value;
6751
+ if (on === "value") {
6752
+ const spec2 = { col, descending: level.order.value === "desc" };
6753
+ if (level.order.value === "custom") {
6754
+ const typed = level.listPick.value === NEW_LIST;
6755
+ const items2 = typed ? parseSortList(level.listText.value) : allLists()[Number(level.listPick.value)] ?? [];
6756
+ if (items2.length) spec2.customList = items2;
6757
+ }
6758
+ return spec2;
6759
+ }
6760
+ const spec = { col, descending: level.order.value === "bottom" };
6761
+ if (on === "icon") {
6762
+ const [set, index] = level.choice.value.split(":");
6763
+ spec.sortOn = "icon";
6764
+ spec.icon = set && index !== void 0 ? { set, index: Number(index) } : { set: "" };
6765
+ } else {
6766
+ spec.sortOn = on === "fontColor" ? "fontColor" : "cellColor";
6767
+ if (level.choice.value) spec.color = level.choice.value;
6768
+ }
6769
+ return spec;
6770
+ };
6372
6771
  return showDialog(ctx, {
6373
6772
  name: "sort",
6374
6773
  heading: "Sort",
6375
6774
  wide: true,
6376
- body: [row(ctx, add, remove, copy, up, down, header.wrapper), list],
6775
+ body: [row(ctx, add, remove, copy, up, down, options, header.wrapper), optionsPanel, list],
6377
6776
  opened: () => levels[0]?.column.focus(),
6378
6777
  submit: () => {
6379
- const keys2 = levels.map((l) => ({
6380
- col: Number(l.column.value),
6381
- descending: l.order.value === "desc"
6382
- }));
6383
- t.session.sort(t.sheet, region, keys2, header.input.checked);
6778
+ const keys2 = levels.map(keyOf);
6779
+ for (const [i, level] of levels.entries())
6780
+ if (level.listPick.value === NEW_LIST && keys2[i]?.customList)
6781
+ saveUserSortList(keys2[i].customList);
6782
+ t.session.sort(t.sheet, region, keys2, header.input.checked, {
6783
+ ...across() ? { leftToRight: true } : {},
6784
+ ...caseBox.input.checked ? { caseSensitive: true } : {}
6785
+ });
6384
6786
  return keys2;
6385
6787
  }
6386
6788
  });
@@ -7300,9 +7702,9 @@ function headerTab(ctx, setup) {
7300
7702
  const original = setup[key] ?? "";
7301
7703
  const shown3 = original.startsWith("&C") && !/&[LR]/.test(original.slice(2)) ? original.slice(2) : original;
7302
7704
  const input = textArea(ctx, shown3, 2);
7303
- const read = () => input.value ? /&[LCR]/.test(input.value) ? input.value : `&C${input.value}` : void 0;
7304
- input.addEventListener("input", () => changes.set(key, read));
7305
- input.addEventListener("change", () => changes.set(key, read));
7705
+ const read2 = () => input.value ? /&[LCR]/.test(input.value) ? input.value : `&C${input.value}` : void 0;
7706
+ input.addEventListener("input", () => changes.set(key, read2));
7707
+ input.addEventListener("change", () => changes.set(key, read2));
7306
7708
  input.addEventListener("focus", () => {
7307
7709
  active2 = input;
7308
7710
  });
@@ -7387,7 +7789,7 @@ function headerTab(ctx, setup) {
7387
7789
  ),
7388
7790
  ...inputs.map((input) => input.field)
7389
7791
  ),
7390
- read: () => Object.fromEntries([...changes].map(([key, read]) => [key, read()]))
7792
+ read: () => Object.fromEntries([...changes].map(([key, read2]) => [key, read2()]))
7391
7793
  };
7392
7794
  }
7393
7795
 
@@ -8188,13 +8590,13 @@ function openTextToColumns(ctx) {
8188
8590
  return (line) => splitDelimited(line, opts);
8189
8591
  };
8190
8592
  const refresh = () => {
8191
- const split = splitter();
8192
- breaks.setAttribute("aria-invalid", split ? "false" : "true");
8593
+ const split2 = splitter();
8594
+ breaks.setAttribute("aria-invalid", split2 ? "false" : "true");
8193
8595
  const table = el(ctx, "table");
8194
- if (split)
8596
+ if (split2)
8195
8597
  for (const line of lines.slice(0, 5)) {
8196
8598
  const tr = el(ctx, "tr");
8197
- for (const part of split(line)) {
8599
+ for (const part of split2(line)) {
8198
8600
  const td = el(ctx, "td");
8199
8601
  td.textContent = part;
8200
8602
  tr.append(td);
@@ -8264,8 +8666,8 @@ function openTextToColumns(ctx) {
8264
8666
  destination.focus();
8265
8667
  return void 0;
8266
8668
  }
8267
- const split = splitter();
8268
- if (!split)
8669
+ const split2 = splitter();
8670
+ if (!split2)
8269
8671
  return invalid(
8270
8672
  ctx,
8271
8673
  breaks,
@@ -8275,7 +8677,7 @@ function openTextToColumns(ctx) {
8275
8677
  t.session.batch("Text to Columns", () => {
8276
8678
  lines.forEach((line, i) => {
8277
8679
  if (!line) return;
8278
- split(line).forEach((part, j) => {
8680
+ split2(line).forEach((part, j) => {
8279
8681
  t.session.setCellInput(t.sheet, dest.row + i, dest.col + j, part);
8280
8682
  written++;
8281
8683
  });
@@ -8315,6 +8717,14 @@ function freeze(ctx, rows, cols) {
8315
8717
  if (!t) return;
8316
8718
  t.session.setFreeze(t.sheet, rows || cols ? { rows, cols } : void 0);
8317
8719
  }
8720
+ var split = (ctx) => !!target(ctx)?.ws.view.split;
8721
+ function toggleSplit(ctx) {
8722
+ const t = target(ctx);
8723
+ if (!t) return;
8724
+ if (split(ctx)) return t.session.setSplit(t.sheet, void 0);
8725
+ const next = ctx.grid()?.splitAt?.(t.active);
8726
+ if (next) t.session.setSplit(t.sheet, next.split, next.topLeft);
8727
+ }
8318
8728
  var formulaBarHost = (ctx) => "showFormulaBar" in ctx.host ? ctx.host : void 0;
8319
8729
  var viewMode = (ctx) => target(ctx)?.ws.view?.mode;
8320
8730
  function setViewMode(ctx, mode) {
@@ -8383,6 +8793,13 @@ function viewCommands() {
8383
8793
  ctx.grid()?.scrollTo(t.range.start);
8384
8794
  }
8385
8795
  }),
8796
+ viewing({
8797
+ id: "view.split",
8798
+ label: "Split",
8799
+ icon: icon("split"),
8800
+ checked: split,
8801
+ run: toggleSplit
8802
+ }),
8386
8803
  viewing({
8387
8804
  id: "view.freeze-panes",
8388
8805
  label: "Freeze Panes",
@@ -9044,10 +9461,10 @@ function openSparklineSettings(ctx) {
9044
9461
  datesChanged = true;
9045
9462
  });
9046
9463
  const changes = /* @__PURE__ */ new Map();
9047
- const track = (input, key, read) => {
9464
+ const track = (input, key, read2) => {
9048
9465
  const changed = () => {
9049
9466
  if (input.dataset.mixed && input.value === "") changes.delete(key);
9050
- else changes.set(key, read);
9467
+ else changes.set(key, read2);
9051
9468
  };
9052
9469
  input.addEventListener("input", changed);
9053
9470
  input.addEventListener("change", changed);
@@ -9187,7 +9604,7 @@ function openSparklineSettings(ctx) {
9187
9604
  ],
9188
9605
  submit: () => {
9189
9606
  const patch = {};
9190
- for (const read of changes.values()) Object.assign(patch, read());
9607
+ for (const read2 of changes.values()) Object.assign(patch, read2());
9191
9608
  if (minType.value !== "custom") delete patch.manualMin;
9192
9609
  if (maxType.value !== "custom") delete patch.manualMax;
9193
9610
  if (patch.minAxisType === "custom" && !min.value.trim() || patch.maxAxisType === "custom" && !max.value.trim())
@@ -10198,6 +10615,176 @@ function registerToolDialogs(ctx) {
10198
10615
  d.register("create-table", (c, p) => openCreateTable(c, props(p)));
10199
10616
  }
10200
10617
 
10618
+ // src/xlsx/grid/dom.ts
10619
+ function h(doc, tag, className, attrs) {
10620
+ const node = doc.createElement(tag);
10621
+ if (className) node.className = className;
10622
+ if (attrs) for (const [name, value] of Object.entries(attrs)) node.setAttribute(name, value);
10623
+ return node;
10624
+ }
10625
+ function place(node, left, top, width, height) {
10626
+ node.style.left = `${left}px`;
10627
+ node.style.top = `${top}px`;
10628
+ node.style.width = `${Math.max(0, width)}px`;
10629
+ node.style.height = `${Math.max(0, height)}px`;
10630
+ }
10631
+ function toggleClass(node, name, on) {
10632
+ if (node.classList.contains(name) !== on) node.classList.toggle(name, on);
10633
+ }
10634
+ function svgNode(doc, markup) {
10635
+ const holder = doc.createElement("div");
10636
+ holder.innerHTML = markup;
10637
+ return holder.firstElementChild ?? doc.createElement("span");
10638
+ }
10639
+ var viewOf = (node) => node.ownerDocument?.defaultView ?? (typeof window === "undefined" ? null : window);
10640
+ function nextFrame(node, fn) {
10641
+ const win = viewOf(node);
10642
+ if (win?.requestAnimationFrame) {
10643
+ const id2 = win.requestAnimationFrame(() => fn());
10644
+ return () => win.cancelAnimationFrame(id2);
10645
+ }
10646
+ const id = setTimeout(fn, 16);
10647
+ return () => clearTimeout(id);
10648
+ }
10649
+ function ensureStyle(root, id, css2) {
10650
+ if (root.querySelector(`style[data-xg-style="${id}"]`)) return;
10651
+ const doc = root.ownerDocument ?? document;
10652
+ const style2 = doc.createElement("style");
10653
+ style2.dataset.xgStyle = id;
10654
+ style2.textContent = css2;
10655
+ root.append(style2);
10656
+ }
10657
+
10658
+ // src/xlsx/dialogs/watch-window.ts
10659
+ var MAX_WATCHES_AT_ONCE = 1e3;
10660
+ var WATCH_CSS = `
10661
+ .xve-watch{position:fixed;right:16px;bottom:40px;width:min(640px,92vw);height:240px;min-width:280px;min-height:140px;z-index:40;
10662
+ display:flex;flex-direction:column;resize:both;overflow:hidden;box-sizing:border-box;
10663
+ background:var(--xve-background,var(--office-background,#fff));color:var(--xve-foreground,var(--office-foreground,#201f1e));
10664
+ border:1px solid var(--xve-border,var(--office-border,#c8c6c4));border-radius:var(--xve-radius,var(--office-radius,4px));
10665
+ box-shadow:0 6px 24px rgba(0,0,0,.25);font:12px/1.4 var(--xve-font,var(--office-font,system-ui,sans-serif))}
10666
+ .xve-watch[hidden]{display:none}
10667
+ .xve-watch-head{display:flex;align-items:center;justify-content:space-between;padding:4px 8px;font-weight:600;
10668
+ border-bottom:1px solid var(--xve-border,var(--office-border,#c8c6c4))}
10669
+ .xve-watch-bar{display:flex;gap:6px;padding:4px 8px}
10670
+ .xve-watch-scroll{flex:1;overflow:auto}
10671
+ .xve-watch table{border-collapse:collapse;width:100%}
10672
+ .xve-watch th,.xve-watch td{text-align:left;padding:2px 8px;border-bottom:1px solid var(--xve-border,var(--office-border,#e1dfdd));white-space:nowrap;
10673
+ max-width:220px;overflow:hidden;text-overflow:ellipsis}
10674
+ .xve-watch th{position:sticky;top:0;background:var(--xve-muted,var(--office-muted,#f3f2f1))}
10675
+ .xve-watch tr[aria-selected=true]{background:var(--xve-accent,var(--office-selected,#e1ecf7))}
10676
+ `;
10677
+ var COLUMNS = ["Book", "Sheet", "Name", "Cell", "Value", "Formula"];
10678
+ function openAddWatch(ctx) {
10679
+ const selection = ctx.selection.get();
10680
+ const range2 = selection.ranges[0] ?? { start: selection.active, end: selection.active };
10681
+ const input = textInput(
10682
+ ctx,
10683
+ `${ctx.workbook()?.sheets[ctx.activeSheet()]?.name ?? ""}!${formatRange(range2)}`
10684
+ );
10685
+ void showDialog(ctx, {
10686
+ name: "add-watch",
10687
+ heading: "Add Watch",
10688
+ okLabel: "Add",
10689
+ body: [field(ctx, "Choose the cells that you would like to watch the value of:", input)],
10690
+ opened: () => input.select(),
10691
+ submit: () => {
10692
+ const target42 = resolveReference(ctx, input.value);
10693
+ if (!target42) {
10694
+ input.focus();
10695
+ return void 0;
10696
+ }
10697
+ let added = 0;
10698
+ for (let row2 = target42.range.start.row; row2 <= target42.range.end.row; row2++)
10699
+ for (let col = target42.range.start.col; col <= target42.range.end.col; col++) {
10700
+ if (added++ >= MAX_WATCHES_AT_ONCE) return true;
10701
+ addWatch(ctx, { sheet: target42.sheet, row: row2, col });
10702
+ }
10703
+ return true;
10704
+ }
10705
+ });
10706
+ }
10707
+ function mountWatchWindow(ctx) {
10708
+ ensureStyle(ctx.root, "xve-watch", WATCH_CSS);
10709
+ const panel3 = el(ctx, "div", "xve-watch");
10710
+ panel3.setAttribute("role", "dialog");
10711
+ panel3.dataset.part = "watch-window";
10712
+ panel3.hidden = true;
10713
+ const head = el(ctx, "div", "xve-watch-head");
10714
+ const title = el(ctx, "span");
10715
+ title.textContent = ctx.t("Watch Window");
10716
+ const closeBtn = button(ctx, "Close");
10717
+ head.append(title, closeBtn);
10718
+ const bar = el(ctx, "div", "xve-watch-bar");
10719
+ const add = button(ctx, "Add Watch...");
10720
+ const del = button(ctx, "Delete Watch");
10721
+ bar.append(add, del);
10722
+ const scroll = el(ctx, "div", "xve-watch-scroll");
10723
+ panel3.append(head, bar, scroll);
10724
+ ctx.root.append(panel3);
10725
+ let selected2 = -1;
10726
+ const render2 = () => {
10727
+ const state = auditState(ctx);
10728
+ panel3.hidden = !state.watchOpen;
10729
+ if (!state.watchOpen) return;
10730
+ title.textContent = ctx.t("Watch Window");
10731
+ const workbook = ctx.workbook();
10732
+ const doc = ctx.host.ownerDocument;
10733
+ const table = doc.createElement("table");
10734
+ const headRow = table.createTHead().insertRow();
10735
+ for (const name of COLUMNS) {
10736
+ const th = doc.createElement("th");
10737
+ th.textContent = ctx.t(name);
10738
+ headRow.append(th);
10739
+ }
10740
+ const body = table.createTBody();
10741
+ const book = ctx.host.fileName || "Book1";
10742
+ state.watches.forEach((watch, index) => {
10743
+ if (!workbook || !watchExists(workbook, watch)) return;
10744
+ const info = describeWatch(workbook, watch);
10745
+ const row2 = body.insertRow();
10746
+ row2.setAttribute("aria-selected", String(index === selected2));
10747
+ for (const value of [
10748
+ book,
10749
+ info.sheet,
10750
+ info.name,
10751
+ info.cell,
10752
+ watchValueText(info.value),
10753
+ info.formula
10754
+ ]) {
10755
+ const td = row2.insertCell();
10756
+ td.textContent = value;
10757
+ td.title = value;
10758
+ }
10759
+ row2.addEventListener("click", () => {
10760
+ selected2 = index;
10761
+ render2();
10762
+ });
10763
+ row2.addEventListener(
10764
+ "dblclick",
10765
+ () => selectOn(ctx, watch.sheet, { start: watch, end: watch })
10766
+ );
10767
+ });
10768
+ scroll.replaceChildren(table);
10769
+ del.disabled = !state.watches[selected2];
10770
+ };
10771
+ add.addEventListener("click", () => openAddWatch(ctx));
10772
+ del.addEventListener("click", () => {
10773
+ const watch = auditState(ctx).watches[selected2];
10774
+ if (watch) removeWatch(ctx, watch);
10775
+ selected2 = -1;
10776
+ });
10777
+ closeBtn.addEventListener("click", () => setWatchWindowOpen(ctx, false));
10778
+ const offAudit = onAuditChange(ctx, render2);
10779
+ const offModel = ctx.onModelChange(render2);
10780
+ render2();
10781
+ return () => {
10782
+ offAudit();
10783
+ offModel();
10784
+ panel3.remove();
10785
+ };
10786
+ }
10787
+
10201
10788
  // src/xlsx/dialogs/index.ts
10202
10789
  function registerDialogs(ctx) {
10203
10790
  registerSimpleDialogs(ctx);
@@ -10205,6 +10792,7 @@ function registerDialogs(ctx) {
10205
10792
  registerToolDialogs(ctx);
10206
10793
  registerFormatCellsDialogs(ctx);
10207
10794
  registerRuleDialogs(ctx);
10795
+ mountWatchWindow(ctx);
10208
10796
  }
10209
10797
  function chooseSmartArt(ctx) {
10210
10798
  const doc = ctx.host.ownerDocument;
@@ -10408,48 +10996,6 @@ function smartArtCommands() {
10408
10996
  })
10409
10997
  ];
10410
10998
  }
10411
-
10412
- // src/xlsx/grid/dom.ts
10413
- function h(doc, tag, className, attrs) {
10414
- const node = doc.createElement(tag);
10415
- if (className) node.className = className;
10416
- if (attrs) for (const [name, value] of Object.entries(attrs)) node.setAttribute(name, value);
10417
- return node;
10418
- }
10419
- function place(node, left, top, width, height) {
10420
- node.style.left = `${left}px`;
10421
- node.style.top = `${top}px`;
10422
- node.style.width = `${Math.max(0, width)}px`;
10423
- node.style.height = `${Math.max(0, height)}px`;
10424
- }
10425
- function toggleClass(node, name, on) {
10426
- if (node.classList.contains(name) !== on) node.classList.toggle(name, on);
10427
- }
10428
- function svgNode(doc, markup) {
10429
- const holder = doc.createElement("div");
10430
- holder.innerHTML = markup;
10431
- return holder.firstElementChild ?? doc.createElement("span");
10432
- }
10433
- var viewOf = (node) => node.ownerDocument?.defaultView ?? (typeof window === "undefined" ? null : window);
10434
- function nextFrame(node, fn) {
10435
- const win = viewOf(node);
10436
- if (win?.requestAnimationFrame) {
10437
- const id2 = win.requestAnimationFrame(() => fn());
10438
- return () => win.cancelAnimationFrame(id2);
10439
- }
10440
- const id = setTimeout(fn, 16);
10441
- return () => clearTimeout(id);
10442
- }
10443
- function ensureStyle(root, id, css2) {
10444
- if (root.querySelector(`style[data-xg-style="${id}"]`)) return;
10445
- const doc = root.ownerDocument ?? document;
10446
- const style2 = doc.createElement("style");
10447
- style2.dataset.xgStyle = id;
10448
- style2.textContent = css2;
10449
- root.append(style2);
10450
- }
10451
-
10452
- // src/xlsx/grid/smartart.ts
10453
10999
  var smartArtSchemeColors = drawingSchemeColors;
10454
11000
  var objectCacheStatus = (object) => object.cacheGenerated ? "generated-drawing" : "cached-drawing";
10455
11001
  function paintSmartArt(ctx, node, obj2, theme, size = {
@@ -11728,7 +12274,34 @@ function formulasTab() {
11728
12274
  {
11729
12275
  id: "formula-auditing",
11730
12276
  label: "Formula Auditing",
11731
- controls: [{ kind: "toggle", command: "formulas.show-formulas", showLabel: true }]
12277
+ controls: [
12278
+ {
12279
+ kind: "stack",
12280
+ controls: [
12281
+ { kind: "button", command: "formulas.trace-precedents", showLabel: true },
12282
+ { kind: "button", command: "formulas.trace-dependents", showLabel: true },
12283
+ {
12284
+ kind: "split",
12285
+ command: "formulas.remove-arrows",
12286
+ showLabel: true,
12287
+ menu: [
12288
+ { command: "formulas.remove-arrows" },
12289
+ { command: "formulas.remove-precedent-arrows" },
12290
+ { command: "formulas.remove-dependent-arrows" }
12291
+ ]
12292
+ }
12293
+ ]
12294
+ },
12295
+ {
12296
+ kind: "stack",
12297
+ controls: [
12298
+ { kind: "toggle", command: "formulas.show-formulas", showLabel: true },
12299
+ { kind: "button", command: "formulas.error-checking", showLabel: true },
12300
+ { kind: "button", command: "formulas.evaluate-formula", showLabel: true }
12301
+ ]
12302
+ },
12303
+ { kind: "toggle", command: "formulas.watch-window", size: "large" }
12304
+ ]
11732
12305
  },
11733
12306
  {
11734
12307
  id: "calculation",
@@ -16380,6 +16953,7 @@ var GridlineLayer = class {
16380
16953
  }
16381
16954
  }
16382
16955
  };
16956
+ var SPLIT_BAR = 5;
16383
16957
  function paintChrome(nodes, g, metrics, vis, selection) {
16384
16958
  const show = g.headerW > 0;
16385
16959
  const font = Math.max(6, Math.round(11 * (metrics.zoom / 100)));
@@ -16389,28 +16963,10 @@ function paintChrome(nodes, g, metrics, vis, selection) {
16389
16963
  const fh = Math.min(g.frozenH, g.cellsH);
16390
16964
  const { colHeaders, rowHeaders } = nodes;
16391
16965
  const panes = [
16392
- [colHeaders.frozen, g.headerW, 0, fw, g.headerH, vis.frozenCols, 0, "col"],
16393
- [
16394
- colHeaders.scroll,
16395
- g.headerW + fw,
16396
- 0,
16397
- g.cellsW - fw,
16398
- g.headerH,
16399
- vis.cols,
16400
- g.frozenW + g.scrollLeft,
16401
- "col"
16402
- ],
16403
- [rowHeaders.frozen, 0, g.headerH, g.headerW, fh, vis.frozenRows, 0, "row"],
16404
- [
16405
- rowHeaders.scroll,
16406
- 0,
16407
- g.headerH + fh,
16408
- g.headerW,
16409
- g.cellsH - fh,
16410
- vis.rows,
16411
- g.frozenH + g.scrollTop,
16412
- "row"
16413
- ]
16966
+ [colHeaders.frozen, g.headerW, 0, fw, g.headerH, vis.frozenCols, g.fixedOx, "col"],
16967
+ [colHeaders.scroll, g.headerW + fw, 0, g.cellsW - fw, g.headerH, vis.cols, g.mainOx, "col"],
16968
+ [rowHeaders.frozen, 0, g.headerH, g.headerW, fh, vis.frozenRows, g.fixedOy, "row"],
16969
+ [rowHeaders.scroll, 0, g.headerH + fh, g.headerW, g.cellsH - fh, vis.rows, g.mainOy, "row"]
16414
16970
  ];
16415
16971
  for (const [pane, x, y, w, hgt, indices, offset, axis] of panes) {
16416
16972
  pane.box.hidden = !show || w <= 0 || hgt <= 0;
@@ -16423,10 +16979,15 @@ function paintChrome(nodes, g, metrics, vis, selection) {
16423
16979
  }
16424
16980
  nodes.corner.hidden = !show;
16425
16981
  if (show) place(nodes.corner, 0, 0, g.headerW, g.headerH);
16426
- nodes.freezeH.hidden = g.fRows === 0;
16427
- nodes.freezeV.hidden = g.fCols === 0;
16428
- if (g.fRows) place(nodes.freezeH, 0, g.headerH + g.frozenH - 1, g.width, 1);
16429
- if (g.fCols) place(nodes.freezeV, g.headerW + g.frozenW - 1, 0, 1, g.height);
16982
+ const rowsFixed = g.split ? g.split.y > 0 : g.fRows > 0;
16983
+ const colsFixed = g.split ? g.split.x > 0 : g.fCols > 0;
16984
+ for (const bar of [nodes.freezeH, nodes.freezeV]) bar.classList.toggle("xg-split-bar", !!g.split);
16985
+ nodes.freezeH.hidden = !rowsFixed;
16986
+ nodes.freezeV.hidden = !colsFixed;
16987
+ const t = g.split ? SPLIT_BAR : 1;
16988
+ const o = g.split ? Math.floor(SPLIT_BAR / 2) : 1;
16989
+ if (rowsFixed) place(nodes.freezeH, 0, g.headerH + g.frozenH - o, g.width, t);
16990
+ if (colsFixed) place(nodes.freezeV, g.headerW + g.frozenW - o, 0, t, g.height);
16430
16991
  }
16431
16992
  var HeaderLayer = class {
16432
16993
  element;
@@ -16668,8 +17229,13 @@ var GridView = class {
16668
17229
  });
16669
17230
  #cancelFrame;
16670
17231
  #zoomOverride = /* @__PURE__ */ new Map();
16671
- #freezeH;
16672
- #freezeV;
17232
+ /** The horizontal and vertical lines: freeze lines, or the draggable split bars. */
17233
+ barH;
17234
+ barV;
17235
+ /** Bar positions (pixels) while a split bar is being dragged. */
17236
+ splitDrag;
17237
+ #paintedMode;
17238
+ #splitScroll = /* @__PURE__ */ new WeakMap();
16673
17239
  #sheetRef;
16674
17240
  constructor(ctx, container) {
16675
17241
  this.ctx = ctx;
@@ -16705,11 +17271,19 @@ var GridView = class {
16705
17271
  this.colHeaders = { frozen: pane("col"), scroll: pane("col") };
16706
17272
  this.rowHeaders = { frozen: pane("row"), scroll: pane("row") };
16707
17273
  this.corner = h(doc, "div", "xg-corner", { role: "button", title: ctx.t("Select All") });
16708
- this.#freezeH = h(doc, "div", "xg-freeze-h");
16709
- this.#freezeV = h(doc, "div", "xg-freeze-v");
16710
- this.view.append(this.corner, this.#freezeH, this.#freezeV);
17274
+ this.barH = h(doc, "div", "xg-freeze-h");
17275
+ this.barV = h(doc, "div", "xg-freeze-v");
17276
+ this.view.append(this.corner, this.barH, this.barV);
17277
+ this.view.addEventListener("wheel", (event) => this.#onWheel(event), { passive: false });
16711
17278
  container.append(this.root);
16712
- this.scroller.addEventListener("scroll", () => this.schedule(), { passive: true });
17279
+ this.scroller.addEventListener(
17280
+ "scroll",
17281
+ () => {
17282
+ this.#syncSplitView();
17283
+ this.schedule();
17284
+ },
17285
+ { passive: true }
17286
+ );
16713
17287
  this.rebuild();
16714
17288
  }
16715
17289
  workbook() {
@@ -16785,9 +17359,97 @@ var GridView = class {
16785
17359
  width,
16786
17360
  height,
16787
17361
  scrollLeft: this.scroller.scrollLeft,
16788
- scrollTop: this.scroller.scrollTop
17362
+ scrollTop: this.scroller.scrollTop,
17363
+ split: this.splitState()
16789
17364
  });
16790
17365
  }
17366
+ /** The split window in pixels with the scroll of its left and top panes, or undefined. */
17367
+ splitState() {
17368
+ const sheet = this.sheet();
17369
+ const split2 = sheet?.view.split;
17370
+ if (!sheet || !split2 || split2.x <= 0 && split2.y <= 0) {
17371
+ if (sheet) this.#splitScroll.delete(sheet);
17372
+ return void 0;
17373
+ }
17374
+ const zoom = this.metrics.zoom;
17375
+ const x = this.splitDrag?.x ?? splitToPx(split2.x, zoom);
17376
+ const y = this.splitDrag?.y ?? splitToPx(split2.y, zoom);
17377
+ let scroll = this.#splitScroll.get(sheet);
17378
+ if (!scroll) {
17379
+ scroll = {
17380
+ left: split2.topLeft ? this.metrics.colLeft(split2.topLeft.col) : 0,
17381
+ top: split2.topLeft ? this.metrics.rowTop(split2.topLeft.row) : 0
17382
+ };
17383
+ this.#splitScroll.set(sheet, scroll);
17384
+ }
17385
+ return { x, y, left: scroll.left, top: scroll.top };
17386
+ }
17387
+ /** The split View > Split makes with `active` selected, from the painted window. */
17388
+ splitAt(active2) {
17389
+ const g = this.#geometry();
17390
+ const split2 = splitAtCell(
17391
+ this.metrics,
17392
+ active2,
17393
+ { left: g.mainOx, top: g.mainOy },
17394
+ { width: g.cellsW, height: g.cellsH }
17395
+ );
17396
+ if (!split2) return void 0;
17397
+ const topLeft = { row: this.metrics.rowAt(g.mainOy), col: this.metrics.colAt(g.mainOx) };
17398
+ return { split: split2, topLeft };
17399
+ }
17400
+ /**
17401
+ * Writes the panes' scroll positions into the sheet view, as Excel saves them: the scrolling
17402
+ * pane's first cell is `pane/@topLeftCell` (`view.topLeft`), the top-left pane's `split.topLeft`.
17403
+ */
17404
+ #syncSplitView() {
17405
+ const view = this.sheet()?.view;
17406
+ const state = this.splitState();
17407
+ if (!view?.split || !state || this.splitDrag) return;
17408
+ const m = this.metrics;
17409
+ const g = this.#geometry();
17410
+ const main = { row: m.rowAt(g.scrollTop), col: m.colAt(g.scrollLeft) };
17411
+ const first = {
17412
+ row: m.rowAt(state.y > 0 ? state.top : g.scrollTop),
17413
+ col: m.colAt(state.x > 0 ? state.left : g.scrollLeft)
17414
+ };
17415
+ const differs = (a, b) => !a || a.row !== b.row || a.col !== b.col;
17416
+ if (differs(view.topLeft, main)) view.topLeft = main;
17417
+ if (differs(view.split.topLeft, first)) view.split.topLeft = first;
17418
+ }
17419
+ /** Shows `cell` at the top-left of the scrolling pane (a loaded sheet's saved scroll position). */
17420
+ showTopLeft(cell) {
17421
+ if (!this.sheet()?.view.split) return this.reveal(cell.row, cell.col);
17422
+ this.ensureExtent(cell.row, cell.col);
17423
+ this.scroller.scrollLeft = this.metrics.colLeft(cell.col);
17424
+ this.scroller.scrollTop = this.metrics.rowTop(cell.row);
17425
+ this.schedule();
17426
+ }
17427
+ /** Wheel over the top or left panes of a split scrolls that pane, not the native scroller. */
17428
+ #onWheel(event) {
17429
+ const sheet = this.sheet();
17430
+ const split2 = this.splitState();
17431
+ const scroll = sheet && this.#splitScroll.get(sheet);
17432
+ if (!split2 || !scroll || event.ctrlKey) return;
17433
+ const { x, y } = this.clientToView(event.clientX, event.clientY);
17434
+ const g = this.geometry;
17435
+ const inLeft = split2.x > 0 && x >= g.headerW && x < g.headerW + split2.x;
17436
+ const inTop = split2.y > 0 && y >= g.headerH && y < g.headerH + split2.y;
17437
+ if (!inLeft && !inTop) return;
17438
+ const swap = event.shiftKey && !event.deltaX;
17439
+ let dx = swap ? event.deltaY : event.deltaX;
17440
+ let dy = swap ? 0 : event.deltaY;
17441
+ if (event.deltaMode === 1) {
17442
+ dx *= 40;
17443
+ dy *= 40;
17444
+ }
17445
+ if (inLeft) scroll.left = Math.max(0, scroll.left + dx);
17446
+ else this.scroller.scrollLeft += dx;
17447
+ if (inTop) scroll.top = Math.max(0, scroll.top + dy);
17448
+ else this.scroller.scrollTop += dy;
17449
+ event.preventDefault();
17450
+ this.#syncSplitView();
17451
+ this.schedule();
17452
+ }
16791
17453
  schedule() {
16792
17454
  if (this.#cancelFrame) return;
16793
17455
  this.#cancelFrame = nextFrame(this.root, () => {
@@ -16825,8 +17487,21 @@ var GridView = class {
16825
17487
  paint() {
16826
17488
  this.#cancelFrame?.();
16827
17489
  this.#cancelFrame = void 0;
16828
- const g = this.geometry = this.#geometry();
17490
+ let g = this.#geometry();
16829
17491
  const sheet = this.sheet();
17492
+ const before = this.#paintedMode;
17493
+ if (before && before.sheet === sheet && before.kind !== g.mode && g.mode !== "none") {
17494
+ if (before.kind === "freeze" && g.mode === "split") {
17495
+ this.scroller.scrollLeft = before.ox;
17496
+ this.scroller.scrollTop = before.oy;
17497
+ } else if (before.kind === "split" && g.mode === "freeze") {
17498
+ this.scroller.scrollLeft = Math.max(0, before.ox - g.frozenW);
17499
+ this.scroller.scrollTop = Math.max(0, before.oy - g.frozenH);
17500
+ }
17501
+ g = this.#geometry();
17502
+ }
17503
+ this.geometry = g;
17504
+ this.#paintedMode = { sheet, kind: g.mode, ox: g.mainOx, oy: g.mainOy };
16830
17505
  this.view.style.width = `${g.width}px`;
16831
17506
  this.view.style.height = `${g.height}px`;
16832
17507
  if (g.scrollTop + g.height > this.metrics.totalHeight(this.extentRow) - 400)
@@ -16834,16 +17509,19 @@ var GridView = class {
16834
17509
  if (g.scrollLeft + g.width > this.metrics.totalWidth(this.extentCol) - 300)
16835
17510
  this.ensureExtent(0, this.extentCol + 10);
16836
17511
  const freeze2 = sheet?.view.freeze;
16837
- const vis = visibleCells(
16838
- this.metrics,
16839
- {
16840
- scrollLeft: g.scrollLeft,
16841
- scrollTop: g.scrollTop,
16842
- width: g.cellsW + 40,
16843
- height: g.cellsH + 30
16844
- },
16845
- freeze2
16846
- );
17512
+ const viewport = {
17513
+ scrollLeft: g.scrollLeft,
17514
+ scrollTop: g.scrollTop,
17515
+ width: g.cellsW + 40,
17516
+ height: g.cellsH + 30
17517
+ };
17518
+ const vis = g.split ? splitVisible(this.metrics, {
17519
+ ...g.split,
17520
+ mainLeft: g.scrollLeft,
17521
+ mainTop: g.scrollTop,
17522
+ width: viewport.width,
17523
+ height: viewport.height
17524
+ }) : visibleCells(this.metrics, viewport, freeze2);
16847
17525
  const zoom = this.metrics.zoom;
16848
17526
  const selection = this.ctx.selection.get();
16849
17527
  const editable = !this.ctx.readOnly();
@@ -16905,8 +17583,8 @@ var GridView = class {
16905
17583
  colHeaders: this.colHeaders,
16906
17584
  rowHeaders: this.rowHeaders,
16907
17585
  corner: this.corner,
16908
- freezeH: this.#freezeH,
16909
- freezeV: this.#freezeV
17586
+ freezeH: this.barH,
17587
+ freezeV: this.barV
16910
17588
  },
16911
17589
  g,
16912
17590
  this.metrics,
@@ -17100,6 +17778,8 @@ var GRID_CSS = `
17100
17778
  border-right:1px solid var(--xve-header-line, var(--office-border, #d4d4d4));border-bottom:1px solid var(--xve-header-line, var(--office-border, #d4d4d4));cursor:default}
17101
17779
  .xg-corner::after{content:"";position:absolute;right:3px;bottom:3px;border-left:9px solid transparent;border-bottom:9px solid #b4b4b4}
17102
17780
  .xg-freeze-h,.xg-freeze-v{position:absolute;background:var(--xve-freeze-line, var(--office-border, #9b9b9b));z-index:6;pointer-events:none}
17781
+ .xg-freeze-h.xg-split-bar,.xg-freeze-v.xg-split-bar{pointer-events:auto;background:var(--xve-split-bar, var(--office-border, #b4b4b4));touch-action:none}
17782
+ .xg-freeze-h.xg-split-bar{cursor:row-resize}.xg-freeze-v.xg-split-bar{cursor:col-resize}
17103
17783
  .xg-col-resize{cursor:col-resize!important}.xg-row-resize{cursor:row-resize!important}
17104
17784
  .xg-resize-guide{position:absolute;z-index:8;border:0 dashed #666;pointer-events:none}
17105
17785
  .xg-editor-host{position:absolute;z-index:7;box-sizing:border-box;opacity:0;overflow:hidden;pointer-events:none;background:#fff;color:#000;line-height:1.25}
@@ -17219,6 +17899,76 @@ var GRID_CSS = `
17219
17899
  .xg-timeline button:focus-visible,.xg-timeline select:focus-visible{outline:2px solid var(--xve-selection-border, var(--office-accent, #217346));outline-offset:-2px}
17220
17900
  .xg-live{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
17221
17901
  `;
17902
+ function installSplitBars(view) {
17903
+ const commit = (next) => {
17904
+ const session = view.ctx.session();
17905
+ if (session && !view.ctx.readOnly()) session.setSplit(view.sheetIndex(), next);
17906
+ };
17907
+ const current = () => view.sheet()?.view.split;
17908
+ const remove = (axes) => {
17909
+ const split2 = current();
17910
+ if (!split2) return;
17911
+ const next = { ...split2 };
17912
+ for (const axis of axes) next[axis] = 0;
17913
+ commit(next.x > 0 || next.y > 0 ? next : void 0);
17914
+ };
17915
+ const install = (bar, axis) => {
17916
+ const other = axis === "x" ? view.barH : view.barV;
17917
+ let pointer = -1;
17918
+ let moved = false;
17919
+ const position = (event) => {
17920
+ const { x, y } = view.clientToView(event.clientX, event.clientY);
17921
+ const g = view.geometry;
17922
+ return axis === "x" ? clampSplitBar(x - g.headerW, g.cellsW, view.metrics.zoom) : clampSplitBar(y - g.headerH, g.cellsH, view.metrics.zoom);
17923
+ };
17924
+ const down = (event) => {
17925
+ if (event.button !== 0 || view.ctx.readOnly()) return;
17926
+ event.preventDefault();
17927
+ event.stopPropagation();
17928
+ pointer = event.pointerId;
17929
+ moved = false;
17930
+ bar.setPointerCapture?.(event.pointerId);
17931
+ };
17932
+ const move = (event) => {
17933
+ if (event.pointerId !== pointer) return;
17934
+ moved = true;
17935
+ view.splitDrag = { ...view.splitDrag, [axis]: position(event) };
17936
+ view.paint();
17937
+ };
17938
+ const up = (event) => {
17939
+ if (event.pointerId !== pointer) return;
17940
+ pointer = -1;
17941
+ bar.releasePointerCapture?.(event.pointerId);
17942
+ const drag = view.splitDrag;
17943
+ view.splitDrag = void 0;
17944
+ const split2 = current();
17945
+ if (!moved || !split2 || drag?.[axis] === void 0) return;
17946
+ commit({ ...split2, [axis]: pxToSplit(drag[axis], view.metrics.zoom) });
17947
+ };
17948
+ const dbl = (event) => {
17949
+ event.preventDefault();
17950
+ event.stopPropagation();
17951
+ if (view.ctx.readOnly()) return;
17952
+ const rect = other.getBoundingClientRect();
17953
+ const onCrossing = !other.hidden && (axis === "x" ? Math.abs(event.clientY - (rect.top + rect.height / 2)) : Math.abs(event.clientX - (rect.left + rect.width / 2))) <= SPLIT_BAR;
17954
+ remove(onCrossing ? ["x", "y"] : [axis]);
17955
+ };
17956
+ bar.addEventListener("pointerdown", down);
17957
+ bar.addEventListener("pointermove", move);
17958
+ bar.addEventListener("pointerup", up);
17959
+ bar.addEventListener("pointercancel", up);
17960
+ bar.addEventListener("dblclick", dbl);
17961
+ return () => {
17962
+ bar.removeEventListener("pointerdown", down);
17963
+ bar.removeEventListener("pointermove", move);
17964
+ bar.removeEventListener("pointerup", up);
17965
+ bar.removeEventListener("pointercancel", up);
17966
+ bar.removeEventListener("dblclick", dbl);
17967
+ };
17968
+ };
17969
+ const offs = [install(view.barV, "x"), install(view.barH, "y")];
17970
+ return () => offs.forEach((off) => off());
17971
+ }
17222
17972
 
17223
17973
  // src/xlsx/grid/filter-presets.ts
17224
17974
  var op = (label, operator) => ({
@@ -17878,6 +18628,144 @@ function installRemoteSelections(view) {
17878
18628
  for (const layer of layers) layer.element.remove();
17879
18629
  };
17880
18630
  }
18631
+ var AUDIT_CSS = `
18632
+ .xga-layer{position:absolute;inset:0;pointer-events:none;z-index:3;overflow:hidden}
18633
+ .xga-layer svg{position:absolute;inset:0;width:100%;height:100%;overflow:hidden}
18634
+ `;
18635
+ var SVG2 = "http://www.w3.org/2000/svg";
18636
+ var BLUE = "#1f4e9e";
18637
+ var RED = "#c00000";
18638
+ var BLACK = "#201f1e";
18639
+ var ICON = 22;
18640
+ function installAuditArrows(view) {
18641
+ const doc = view.doc;
18642
+ const layer = h(doc, "div", "xga-layer", { "data-part": "audit-arrows" });
18643
+ const svg = doc.createElementNS(SVG2, "svg");
18644
+ layer.append(svg);
18645
+ view.view.append(layer);
18646
+ const node = (name, attrs) => {
18647
+ const n = doc.createElementNS(SVG2, name);
18648
+ for (const [k, v] of Object.entries(attrs)) n.setAttribute(k, String(v));
18649
+ return n;
18650
+ };
18651
+ const arrow = (x1, y1, x2, y2, color, dashed) => {
18652
+ const out = [];
18653
+ const line = node("line", { x1, y1, x2, y2, stroke: color, "stroke-width": 1.5 });
18654
+ if (dashed) line.setAttribute("stroke-dasharray", "4 3");
18655
+ out.push(line);
18656
+ const angle = Math.atan2(y2 - y1, x2 - x1);
18657
+ const spread = 0.45;
18658
+ const size = 8;
18659
+ out.push(
18660
+ node("polygon", {
18661
+ points: `${x2},${y2} ${x2 - size * Math.cos(angle - spread)},${y2 - size * Math.sin(angle - spread)} ${x2 - size * Math.cos(angle + spread)},${y2 - size * Math.sin(angle + spread)}`,
18662
+ fill: color
18663
+ })
18664
+ );
18665
+ return out;
18666
+ };
18667
+ const sheetIcon = (x, y) => {
18668
+ const g = node("g", {});
18669
+ g.append(
18670
+ node("rect", {
18671
+ x,
18672
+ y,
18673
+ width: ICON,
18674
+ height: ICON * 0.8,
18675
+ fill: "#fff",
18676
+ stroke: BLACK,
18677
+ "stroke-width": 1
18678
+ }),
18679
+ node("path", {
18680
+ d: `M${x} ${y + 5}h${ICON}M${x} ${y + 10}h${ICON}M${x + 7} ${y}v${ICON * 0.8}M${x + 14} ${y}v${ICON * 0.8}`,
18681
+ stroke: BLACK,
18682
+ "stroke-width": 0.8,
18683
+ fill: "none"
18684
+ })
18685
+ );
18686
+ return g;
18687
+ };
18688
+ const visible = (b) => {
18689
+ const g = view.geometry;
18690
+ return b.x + b.w > g.headerW && b.y + b.h > g.headerH && b.x < g.width && b.y < g.height;
18691
+ };
18692
+ const draw = (a, out) => {
18693
+ const g = view.geometry;
18694
+ const sheet = view.sheetIndex();
18695
+ const color = a.error ? RED : BLUE;
18696
+ const toBox = g.rangeBox({ start: a.to, end: a.to });
18697
+ if (a.offSheet) {
18698
+ if (a.kind === "precedents" && a.to.sheet === sheet) {
18699
+ if (!visible(toBox)) return;
18700
+ const cy = toBox.y + toBox.h / 2;
18701
+ const ix = Math.max(g.headerW + 2, toBox.x - 70);
18702
+ out.push(
18703
+ sheetIcon(ix, cy - ICON * 0.4),
18704
+ ...arrow(ix + ICON, cy, toBox.x + 2, cy, BLACK, true)
18705
+ );
18706
+ } else if (a.kind === "dependents" && a.from.sheet === sheet) {
18707
+ const fromBox2 = g.rangeBox(a.from.range);
18708
+ if (!visible(fromBox2)) return;
18709
+ const cy = fromBox2.y + fromBox2.h / 2;
18710
+ const ix = fromBox2.x + fromBox2.w + 50;
18711
+ out.push(
18712
+ node("circle", { cx: fromBox2.x + fromBox2.w - 4, cy, r: 3, fill: BLACK }),
18713
+ ...arrow(fromBox2.x + fromBox2.w - 4, cy, ix, cy, BLACK, true),
18714
+ sheetIcon(ix, cy - ICON * 0.4)
18715
+ );
18716
+ }
18717
+ return;
18718
+ }
18719
+ if (a.from.sheet !== sheet || a.to.sheet !== sheet) return;
18720
+ const fromBox = g.rangeBox(a.from.range);
18721
+ if (!visible(fromBox) && !visible(toBox)) return;
18722
+ const first = g.rangeBox({ start: a.from.range.start, end: a.from.range.start });
18723
+ const multi = a.from.range.start.row !== a.from.range.end.row || a.from.range.start.col !== a.from.range.end.col;
18724
+ if (multi)
18725
+ out.push(
18726
+ node("rect", {
18727
+ x: fromBox.x,
18728
+ y: fromBox.y,
18729
+ width: fromBox.w,
18730
+ height: fromBox.h,
18731
+ fill: "none",
18732
+ stroke: color,
18733
+ "stroke-width": 1.5
18734
+ })
18735
+ );
18736
+ const sx = first.x + Math.min(first.w, 12) / 2 + 2;
18737
+ const sy = first.y + first.h / 2;
18738
+ const tx = toBox.x + toBox.w / 2;
18739
+ const ty = toBox.y + toBox.h / 2;
18740
+ const dx = tx - sx;
18741
+ const dy = ty - sy;
18742
+ const len = Math.hypot(dx, dy) || 1;
18743
+ const trim = Math.min(toBox.w, toBox.h) / 2;
18744
+ const ex = len > trim ? tx - dx / len * trim : tx;
18745
+ const ey = len > trim ? ty - dy / len * trim : ty;
18746
+ out.push(
18747
+ node("circle", { cx: sx, cy: sy, r: 3, fill: color }),
18748
+ ...arrow(sx, sy, ex, ey, color, false)
18749
+ );
18750
+ };
18751
+ const hook = () => {
18752
+ const arrows = auditState(view.ctx).arrows;
18753
+ if (!arrows.length) {
18754
+ if (svg.firstChild) svg.replaceChildren();
18755
+ return;
18756
+ }
18757
+ const out = [];
18758
+ for (const a of arrows) draw(a, out);
18759
+ svg.replaceChildren(...out);
18760
+ };
18761
+ view.hooks.add(hook);
18762
+ const off = onAuditChange(view.ctx, () => view.schedule());
18763
+ return () => {
18764
+ view.hooks.delete(hook);
18765
+ off();
18766
+ layer.remove();
18767
+ };
18768
+ }
17881
18769
  var PAGE_BREAK_CSS = `
17882
18770
  .xgpb-layer{position:absolute;inset:0;pointer-events:none;z-index:3;overflow:hidden}
17883
18771
  .xgpb-layer[hidden]{display:none}
@@ -18078,6 +18966,7 @@ var structuralKinds = /* @__PURE__ */ new Set(["structure", "sheets", "view", "u
18078
18966
  function mountGrid(ctx, container) {
18079
18967
  ensureStyle(ctx.root, "xg", GRID_CSS);
18080
18968
  ensureStyle(ctx.root, "xgpb", PAGE_BREAK_CSS);
18969
+ ensureStyle(ctx.root, "xga", AUDIT_CSS);
18081
18970
  const view = new GridView(ctx, container);
18082
18971
  const selection = new GridSelection(view);
18083
18972
  const editor = new CellEditor(view, (move) => {
@@ -18090,6 +18979,8 @@ function mountGrid(ctx, container) {
18090
18979
  const a11y = new GridA11y(view, sink);
18091
18980
  const removeRemote = installRemoteSelections(view);
18092
18981
  const removePageBreaks = installPageBreakPreview(view);
18982
+ const removeSplitBars = installSplitBars(view);
18983
+ const removeAuditArrows = installAuditArrows(view);
18093
18984
  let marqueeSheet = -1;
18094
18985
  const clipboard = createGridClipboard({
18095
18986
  ctx,
@@ -18200,7 +19091,7 @@ function mountGrid(ctx, container) {
18200
19091
  view.rebuild();
18201
19092
  if (ctx.selection.get().sheet !== view.sheetIndex() || !workbook) restoreSelection();
18202
19093
  const top = sheet?.view.topLeft;
18203
- if (top) view.reveal(top.row, top.col);
19094
+ if (top) view.showTopLeft(top);
18204
19095
  return;
18205
19096
  }
18206
19097
  const kind = typeof change === "object" && change && "kind" in change ? String(change.kind) : "";
@@ -18225,6 +19116,7 @@ function mountGrid(ctx, container) {
18225
19116
  measureText: (text3, font) => view.measurer.measure(text3, font),
18226
19117
  zoom: () => view.zoom(),
18227
19118
  setZoom: (percent) => view.setZoom(percent),
19119
+ splitAt: (active2) => view.splitAt(active2),
18228
19120
  mode: () => editor.bridge.state().mode
18229
19121
  };
18230
19122
  ctx.attachGrid(controller);
@@ -18244,6 +19136,8 @@ function mountGrid(ctx, container) {
18244
19136
  a11y.destroy();
18245
19137
  removeRemote();
18246
19138
  removePageBreaks();
19139
+ removeSplitBars();
19140
+ removeAuditArrows();
18247
19141
  view.destroy();
18248
19142
  };
18249
19143
  }
@@ -18621,88 +19515,29 @@ function mountFormulaBar(ctx, container) {
18621
19515
  }
18622
19516
 
18623
19517
  // src/xlsx/sheet-tabs/drag.ts
18624
- var THRESHOLD = 5;
18625
19518
  function dropTarget(visible, from, slot) {
18626
19519
  if (!visible.length) return from;
18627
19520
  const last = visible[visible.length - 1] ?? from;
18628
19521
  const before = slot < visible.length ? visible[slot] ?? last + 1 : last + 1;
18629
19522
  return before > from ? before - 1 : before;
18630
19523
  }
18631
- function slotAt(tabs2, clientX) {
18632
- for (let i = 0; i < tabs2.length; i++) {
18633
- const box = tabs2[i].getBoundingClientRect();
18634
- if (clientX < box.left + box.width / 2) return i;
18635
- }
18636
- return tabs2.length;
18637
- }
18638
- function wireTabDrag(host) {
19524
+ function wireTabDrag2(host) {
18639
19525
  const { strip } = host;
18640
- let state;
18641
- let marker;
18642
- const tabs2 = () => [...strip.querySelectorAll(".xst-tab")];
18643
- const clear = () => {
18644
- marker?.remove();
18645
- marker = void 0;
18646
- state?.tab.classList.remove("xst-dragging");
18647
- state = void 0;
18648
- };
18649
- const onDown = (event) => {
18650
- if (event.button !== 0 || !host.enabled()) return;
18651
- const tab = event.target.closest?.(".xst-tab");
18652
- if (!tab || tab.dataset.sheet === void 0) return;
18653
- state = {
18654
- from: Number(tab.dataset.sheet),
18655
- tab,
18656
- x: event.clientX,
18657
- pointer: event.pointerId,
18658
- dragging: false,
18659
- slot: -1
18660
- };
18661
- };
18662
- const onMove = (event) => {
18663
- if (!state || event.pointerId !== state.pointer) return;
18664
- if (!state.dragging) {
18665
- if (Math.abs(event.clientX - state.x) < THRESHOLD) return;
18666
- state.dragging = true;
18667
- state.tab.classList.add("xst-dragging");
18668
- try {
18669
- strip.setPointerCapture?.(event.pointerId);
18670
- } catch {
18671
- }
19526
+ return wireTabDrag({
19527
+ area: strip,
19528
+ tabs: () => [...strip.querySelectorAll(".xst-tab")],
19529
+ tabSelector: ".xst-tab",
19530
+ canDrag: (tab) => host.enabled() && tab.dataset.sheet !== void 0,
19531
+ draggingClass: "xst-dragging",
19532
+ markerClass: "xst-marker",
19533
+ markerParent: strip,
19534
+ markerBox: strip,
19535
+ drop(tab, slot) {
19536
+ const from = Number(tab.dataset.sheet);
19537
+ const to = dropTarget(host.visible(), from, slot);
19538
+ if (to !== from) host.move(from, to);
18672
19539
  }
18673
- const list = tabs2();
18674
- state.slot = slotAt(list, event.clientX);
18675
- marker ??= h(strip.ownerDocument, "div", "xst-marker", { "aria-hidden": "true" });
18676
- const stripBox = strip.getBoundingClientRect();
18677
- const ref = list[state.slot] ?? list[list.length - 1];
18678
- const box = ref?.getBoundingClientRect();
18679
- const x = !box ? 0 : state.slot < list.length ? box.left : box.right;
18680
- marker.style.left = `${x - stripBox.left + strip.scrollLeft}px`;
18681
- strip.append(marker);
18682
- };
18683
- const onUp = (event) => {
18684
- if (!state || event.pointerId !== state.pointer) return;
18685
- const { dragging, from, slot } = state;
18686
- clear();
18687
- if (!dragging || slot < 0) return;
18688
- strip.addEventListener("click", stop, { capture: true, once: true });
18689
- setTimeout(() => strip.removeEventListener("click", stop, true), 0);
18690
- const to = dropTarget(host.visible(), from, slot);
18691
- if (to !== from) host.move(from, to);
18692
- };
18693
- const stop = (e) => e.stopPropagation();
18694
- const onCancel = () => clear();
18695
- strip.addEventListener("pointerdown", onDown);
18696
- strip.addEventListener("pointermove", onMove);
18697
- strip.addEventListener("pointerup", onUp);
18698
- strip.addEventListener("pointercancel", onCancel);
18699
- return () => {
18700
- clear();
18701
- strip.removeEventListener("pointerdown", onDown);
18702
- strip.removeEventListener("pointermove", onMove);
18703
- strip.removeEventListener("pointerup", onUp);
18704
- strip.removeEventListener("pointercancel", onCancel);
18705
- };
19540
+ });
18706
19541
  }
18707
19542
  function startRename(ctx, tab, index, done) {
18708
19543
  const session = ctx.session();
@@ -19094,7 +19929,7 @@ function mountSheetTabs(ctx, container) {
19094
19929
  ctx.toast(ctx.t(error instanceof Error ? error.message : String(error)), "warning");
19095
19930
  }
19096
19931
  });
19097
- const disposeDrag = wireTabDrag({
19932
+ const disposeDrag = wireTabDrag2({
19098
19933
  strip,
19099
19934
  enabled: () => editable() && !renaming,
19100
19935
  visible: () => {