@univerjs/sheets-ui 0.1.0-alpha.1 → 0.1.0-alpha.3
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.
- package/LICENSE.txt +178 -0
- package/README.md +1 -1
- package/lib/cjs/index.js +15 -21729
- package/lib/es/index.js +15140 -0
- package/lib/index.css +1 -587
- package/lib/types/basics/const/default-univer-sheet-config.d.ts +15 -1
- package/lib/types/basics/const/index.d.ts +15 -1
- package/lib/types/basics/const/plugin-name.d.ts +15 -1
- package/lib/types/basics/editor/get-editor-object.d.ts +15 -1
- package/lib/types/basics/index.d.ts +15 -1
- package/lib/types/basics/interfaces/cell.d.ts +15 -1
- package/lib/types/basics/interfaces/component-config/i-sheet-ui-plugin-config.d.ts +16 -2
- package/lib/types/basics/interfaces/component-config/index.d.ts +15 -1
- package/lib/types/basics/interfaces/component-config/sheet-container-config.d.ts +15 -1
- package/lib/types/basics/interfaces/component-config/toolbar-config.d.ts +15 -1
- package/lib/types/basics/interfaces/index.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/add-worksheet-merge.command.spec.d.ts +16 -0
- package/lib/types/commands/commands/__tests__/auto-fill.controller.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/create-selection-command-test-bed.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/set-format-painter.command.spec.d.ts +16 -0
- package/lib/types/commands/commands/__tests__/set-frozen.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/__tests__/set-selections.command.spec.d.ts +15 -1
- package/lib/types/commands/commands/add-worksheet-merge.command.d.ts +27 -0
- package/lib/types/commands/commands/auto-fill.command.d.ts +17 -3
- package/lib/types/commands/commands/clipboard.command.d.ts +15 -1
- package/lib/types/commands/commands/inline-format.command.d.ts +17 -1
- package/lib/types/commands/commands/refill.command.d.ts +15 -1
- package/lib/types/commands/commands/rename.command.d.ts +15 -1
- package/lib/types/commands/commands/set-format-painter.command.d.ts +23 -5
- package/lib/types/commands/commands/set-frozen.command.d.ts +15 -1
- package/lib/types/commands/commands/set-scroll.command.d.ts +15 -1
- package/lib/types/commands/commands/set-selection-frozen.command.d.ts +15 -1
- package/lib/types/commands/commands/set-selection.command.d.ts +15 -1
- package/lib/types/commands/commands/set-zoom-ratio.command.d.ts +17 -3
- package/lib/types/commands/commands/unhide.command.d.ts +15 -1
- package/lib/types/commands/commands/utils/selection-utils.d.ts +46 -0
- package/lib/types/commands/operations/activate-cell-edit.operation.d.ts +15 -1
- package/lib/types/commands/operations/cell-edit.operation.d.ts +15 -1
- package/lib/types/commands/operations/scroll.operation.d.ts +15 -1
- package/lib/types/commands/operations/set-editor-resize.operation.d.ts +15 -1
- package/lib/types/commands/operations/set-format-painter.operation.d.ts +15 -1
- package/lib/types/commands/operations/set-zoom-ratio.operation.d.ts +17 -3
- package/lib/types/common/keys.d.ts +15 -1
- package/lib/types/common/utils.d.ts +25 -0
- package/lib/types/components/border-panel/BorderPanel.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/BorderLine.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDashDot.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDashDotDot.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDashed.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDotted.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderHair.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMedium.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDot.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDotDot.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashed.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderThick.d.ts +15 -1
- package/lib/types/components/border-panel/border-line/icons/BorderThin.d.ts +15 -1
- package/lib/types/components/border-panel/interface.d.ts +15 -1
- package/lib/types/components/color-picker/index.d.ts +15 -1
- package/lib/types/components/color-picker/interface.d.ts +15 -1
- package/lib/types/components/const.d.ts +15 -1
- package/lib/types/components/font-family/FontFamily.d.ts +15 -1
- package/lib/types/components/font-family/FontFamilyItem.d.ts +15 -1
- package/lib/types/components/font-family/index.d.ts +15 -1
- package/lib/types/components/font-family/interface.d.ts +15 -1
- package/lib/types/components/font-size/FontSize.d.ts +15 -1
- package/lib/types/components/font-size/index.d.ts +15 -1
- package/lib/types/components/font-size/interface.d.ts +15 -1
- package/lib/types/components/menu-item-input/MenuItemInput.d.ts +15 -1
- package/lib/types/components/menu-item-input/index.d.ts +15 -1
- package/lib/types/components/menu-item-input/interface.d.ts +15 -1
- package/lib/types/components/range-selector/RangeSelector.d.ts +15 -1
- package/lib/types/controllers/active-worksheet/active-worksheet.controller.d.ts +33 -0
- package/lib/types/controllers/auto-fill.controller.d.ts +15 -1
- package/lib/types/controllers/auto-height.controller.d.ts +15 -1
- package/lib/types/controllers/clipboard/clipboard.controller.d.ts +15 -1
- package/lib/types/controllers/clipboard/utils.d.ts +21 -7
- package/lib/types/controllers/contextmenu/contextmenu.controller.d.ts +15 -1
- package/lib/types/controllers/editor/editing.controller.d.ts +20 -8
- package/lib/types/controllers/editor/end-edit.controller.d.ts +18 -4
- package/lib/types/controllers/editor/formula-editor.controller.d.ts +16 -1
- package/lib/types/controllers/editor/initialize-editor.controller.d.ts +16 -8
- package/lib/types/controllers/editor/start-edit.controller.d.ts +16 -1
- package/lib/types/controllers/editor-bridge.controller.d.ts +19 -3
- package/lib/types/controllers/format-painter/format-painter.controller.d.ts +18 -3
- package/lib/types/controllers/freeze.controller.d.ts +15 -1
- package/lib/types/controllers/header-menu.controller.d.ts +15 -1
- package/lib/types/controllers/header-move.controller.d.ts +15 -1
- package/lib/types/controllers/header-resize.controller.d.ts +19 -3
- package/lib/types/controllers/header-unhide.controller.d.ts +15 -1
- package/lib/types/controllers/menu/__tests__/create-menu-test-bed.d.ts +15 -1
- package/lib/types/controllers/menu/__tests__/menu.spec.d.ts +15 -1
- package/lib/types/controllers/menu/__tests__/row-col.menu.spec.d.ts +15 -1
- package/lib/types/controllers/menu/border.menu.d.ts +15 -1
- package/lib/types/controllers/menu/clear.menu.d.ts +15 -1
- package/lib/types/controllers/menu/delete.menu.d.ts +15 -1
- package/lib/types/controllers/menu/insert.menu.d.ts +15 -1
- package/lib/types/controllers/menu/menu.d.ts +18 -1
- package/lib/types/controllers/menu/merge.menu.d.ts +15 -1
- package/lib/types/controllers/menu/sheet.menu.d.ts +15 -1
- package/lib/types/controllers/move-range.controller.d.ts +15 -1
- package/lib/types/controllers/navigation/navigation.controller.d.ts +15 -1
- package/lib/types/controllers/scroll.controller.d.ts +15 -1
- package/lib/types/controllers/selection.controller.d.ts +18 -1
- package/lib/types/controllers/sheet-render.controller.d.ts +15 -1
- package/lib/types/controllers/sheet-ui.controller.d.ts +20 -1
- package/lib/types/controllers/shortcuts/editor.shortcut.d.ts +15 -1
- package/lib/types/controllers/shortcuts/operation.shortcut.d.ts +15 -1
- package/lib/types/controllers/shortcuts/selection.shortcut.d.ts +15 -1
- package/lib/types/controllers/shortcuts/style.shortcut.d.ts +15 -1
- package/lib/types/controllers/shortcuts/utils.d.ts +15 -1
- package/lib/types/controllers/shortcuts/value.shortcut.d.ts +15 -1
- package/lib/types/controllers/shortcuts/view.shortcut.d.ts +15 -1
- package/lib/types/controllers/status-bar.controller.d.ts +19 -4
- package/lib/types/controllers/utils/component-tools.d.ts +15 -1
- package/lib/types/controllers/zoom.controller.d.ts +15 -1
- package/lib/types/index.d.ts +32 -3
- package/lib/types/locale/en-US.d.ts +34 -1
- package/lib/types/locale/index.d.ts +15 -1
- package/lib/types/locale/zh-CN.d.ts +61 -1
- package/lib/types/services/auto-fill/auto-fill.service.d.ts +15 -1
- package/lib/types/services/auto-fill/rules.d.ts +15 -1
- package/lib/types/services/auto-fill/tools.d.ts +16 -2
- package/lib/types/services/auto-fill/type.d.ts +15 -1
- package/lib/types/services/clipboard/__tests__/clipboard-service.spec.d.ts +15 -1
- package/lib/types/services/clipboard/__tests__/clipboard-test-bed.d.ts +15 -1
- package/lib/types/services/clipboard/__tests__/mock-clipboard.d.ts +15 -1
- package/lib/types/services/clipboard/__tests__/utils.spec.d.ts +16 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +18 -2
- package/lib/types/services/clipboard/copy-content-cache.d.ts +17 -3
- package/lib/types/services/clipboard/html-to-usm/converter.d.ts +24 -2
- package/lib/types/services/clipboard/html-to-usm/parse-node-style.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-lark.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-word.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-usm/paste-plugins/type.d.ts +15 -1
- package/lib/types/services/clipboard/html-to-usm/utils.d.ts +15 -1
- package/lib/types/services/clipboard/type.d.ts +23 -7
- package/lib/types/services/clipboard/usm-to-html/convertor.d.ts +15 -1
- package/lib/types/services/clipboard/utils.d.ts +28 -0
- package/lib/types/services/editor/cell-editor-manager.service.d.ts +15 -1
- package/lib/types/services/editor/formula-editor-manager.service.d.ts +15 -1
- package/lib/types/services/editor-bridge.service.d.ts +21 -6
- package/lib/types/services/format-painter/format-painter.service.d.ts +30 -8
- package/lib/types/services/mark-selection/mark-selection.service.d.ts +18 -2
- package/lib/types/services/scroll-manager.service.d.ts +15 -1
- package/lib/types/services/selection/selection-render-model.d.ts +15 -1
- package/lib/types/services/selection/selection-render.service.d.ts +28 -12
- package/lib/types/services/selection/selection-shape-extension.d.ts +16 -2
- package/lib/types/services/selection/selection-shape.d.ts +15 -1
- package/lib/types/services/sheet-bar/sheet-bar.service.d.ts +15 -1
- package/lib/types/services/sheet-skeleton-manager.service.d.ts +15 -1
- package/lib/types/services/status-bar.service.d.ts +24 -5
- package/lib/types/sheets-ui-plugin.d.ts +16 -2
- package/lib/types/views/count-bar/CountBar.d.ts +15 -1
- package/lib/types/views/count-bar/index.d.ts +15 -1
- package/lib/types/views/count-bar/zoom-slider.d.ts +15 -1
- package/lib/types/views/editor-container/EditorContainer.d.ts +15 -1
- package/lib/types/views/editor-container/index.d.ts +15 -1
- package/lib/types/views/formula-bar/FormulaBar.d.ts +15 -1
- package/lib/types/views/formula-bar/index.d.ts +15 -1
- package/lib/types/views/header-menu-shape.d.ts +15 -1
- package/lib/types/views/header-resize-shape.d.ts +15 -1
- package/lib/types/views/header-unhide-shape.d.ts +15 -1
- package/lib/types/views/operate-container/AutoFillPopupMenu.d.ts +15 -1
- package/lib/types/views/operate-container/OperateContainer.d.ts +15 -1
- package/lib/types/views/operate-container/index.d.ts +15 -1
- package/lib/types/views/sheet-bar/SheetBar.d.ts +15 -1
- package/lib/types/views/sheet-bar/sheet-bar-button/SheetBarButton.d.ts +15 -1
- package/lib/types/views/sheet-bar/sheet-bar-menu/SheetBarMenu.d.ts +15 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarItem.d.ts +15 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.d.ts +15 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/animate.d.ts +17 -2
- package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.d.ts +19 -4
- package/lib/types/views/sheet-canvas-view.d.ts +20 -3
- package/lib/types/views/sheet-container/SheetContainer.d.ts +17 -3
- package/lib/types/views/status-bar/CopyableStatisticItem.d.ts +18 -3
- package/lib/types/views/status-bar/StatusBar.d.ts +15 -1
- package/lib/umd/index.js +15 -0
- package/package.json +40 -30
- package/LICENSE +0 -21
- package/lib/cjs/locale/en-US.js +0 -605
- package/lib/cjs/locale/zh-CN.js +0 -442
- package/lib/esm/index.js +0 -21640
- package/lib/esm/locale/en-US.js +0 -584
- package/lib/esm/locale/zh-CN.js +0 -421
- package/lib/types/basics/const/default-univer-sheet-config.d.ts.map +0 -1
- package/lib/types/basics/const/index.d.ts.map +0 -1
- package/lib/types/basics/const/plugin-name.d.ts.map +0 -1
- package/lib/types/basics/editor/get-editor-object.d.ts.map +0 -1
- package/lib/types/basics/index.d.ts.map +0 -1
- package/lib/types/basics/interfaces/cell.d.ts.map +0 -1
- package/lib/types/basics/interfaces/component-config/i-sheet-ui-plugin-config.d.ts.map +0 -1
- package/lib/types/basics/interfaces/component-config/index.d.ts.map +0 -1
- package/lib/types/basics/interfaces/component-config/sheet-container-config.d.ts.map +0 -1
- package/lib/types/basics/interfaces/component-config/toolbar-config.d.ts.map +0 -1
- package/lib/types/basics/interfaces/index.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/auto-fill.controller.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/create-selection-command-test-bed.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/set-frozen.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/__tests__/set-selections.command.spec.d.ts.map +0 -1
- package/lib/types/commands/commands/auto-fill.command.d.ts.map +0 -1
- package/lib/types/commands/commands/clipboard.command.d.ts.map +0 -1
- package/lib/types/commands/commands/inline-format.command.d.ts.map +0 -1
- package/lib/types/commands/commands/refill.command.d.ts.map +0 -1
- package/lib/types/commands/commands/rename.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-format-painter.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-frozen.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-scroll.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-selection-frozen.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-selection.command.d.ts.map +0 -1
- package/lib/types/commands/commands/set-zoom-ratio.command.d.ts.map +0 -1
- package/lib/types/commands/commands/unhide.command.d.ts.map +0 -1
- package/lib/types/commands/operations/activate-cell-edit.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/cell-edit.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/scroll.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/selection.operation.d.ts +0 -12
- package/lib/types/commands/operations/selection.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/set-editor-resize.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/set-format-painter.operation.d.ts.map +0 -1
- package/lib/types/commands/operations/set-zoom-ratio.operation.d.ts.map +0 -1
- package/lib/types/common/keys.d.ts.map +0 -1
- package/lib/types/components/border-panel/BorderPanel.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/BorderLine.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDashDot.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDashDotDot.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDashed.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderDotted.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderHair.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMedium.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDot.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashDotDot.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderMediumDashed.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderThick.d.ts.map +0 -1
- package/lib/types/components/border-panel/border-line/icons/BorderThin.d.ts.map +0 -1
- package/lib/types/components/border-panel/index.d.ts +0 -1
- package/lib/types/components/border-panel/index.d.ts.map +0 -1
- package/lib/types/components/border-panel/interface.d.ts.map +0 -1
- package/lib/types/components/color-picker/index.d.ts.map +0 -1
- package/lib/types/components/color-picker/interface.d.ts.map +0 -1
- package/lib/types/components/const.d.ts.map +0 -1
- package/lib/types/components/font-family/FontFamily.d.ts.map +0 -1
- package/lib/types/components/font-family/FontFamilyItem.d.ts.map +0 -1
- package/lib/types/components/font-family/index.d.ts.map +0 -1
- package/lib/types/components/font-family/interface.d.ts.map +0 -1
- package/lib/types/components/font-size/FontSize.d.ts.map +0 -1
- package/lib/types/components/font-size/index.d.ts.map +0 -1
- package/lib/types/components/font-size/interface.d.ts.map +0 -1
- package/lib/types/components/menu-item-input/MenuItemInput.d.ts.map +0 -1
- package/lib/types/components/menu-item-input/index.d.ts.map +0 -1
- package/lib/types/components/menu-item-input/interface.d.ts.map +0 -1
- package/lib/types/components/range-selector/RangeSelector.d.ts.map +0 -1
- package/lib/types/controllers/auto-fill.controller.d.ts.map +0 -1
- package/lib/types/controllers/auto-height.controller.d.ts.map +0 -1
- package/lib/types/controllers/clipboard/clipboard.controller.d.ts.map +0 -1
- package/lib/types/controllers/clipboard/utils.d.ts.map +0 -1
- package/lib/types/controllers/contextmenu/contextmenu.controller.d.ts.map +0 -1
- package/lib/types/controllers/editor/editing.controller.d.ts.map +0 -1
- package/lib/types/controllers/editor/end-edit.controller.d.ts.map +0 -1
- package/lib/types/controllers/editor/formula-editor.controller.d.ts.map +0 -1
- package/lib/types/controllers/editor/initialize-editor.controller.d.ts.map +0 -1
- package/lib/types/controllers/editor/start-edit.controller.d.ts.map +0 -1
- package/lib/types/controllers/editor-bridge.controller.d.ts.map +0 -1
- package/lib/types/controllers/format-painter/format-painter.controller.d.ts.map +0 -1
- package/lib/types/controllers/freeze.controller.d.ts.map +0 -1
- package/lib/types/controllers/header-menu.controller.d.ts.map +0 -1
- package/lib/types/controllers/header-move.controller.d.ts.map +0 -1
- package/lib/types/controllers/header-resize.controller.d.ts.map +0 -1
- package/lib/types/controllers/header-unhide.controller.d.ts.map +0 -1
- package/lib/types/controllers/menu/__tests__/create-menu-test-bed.d.ts.map +0 -1
- package/lib/types/controllers/menu/__tests__/menu.spec.d.ts.map +0 -1
- package/lib/types/controllers/menu/__tests__/row-col.menu.spec.d.ts.map +0 -1
- package/lib/types/controllers/menu/border.menu.d.ts.map +0 -1
- package/lib/types/controllers/menu/clear.menu.d.ts.map +0 -1
- package/lib/types/controllers/menu/delete.menu.d.ts.map +0 -1
- package/lib/types/controllers/menu/insert.menu.d.ts.map +0 -1
- package/lib/types/controllers/menu/menu.d.ts.map +0 -1
- package/lib/types/controllers/menu/merge.menu.d.ts.map +0 -1
- package/lib/types/controllers/menu/sheet.menu.d.ts.map +0 -1
- package/lib/types/controllers/move-range.controller.d.ts.map +0 -1
- package/lib/types/controllers/navigation/navigation.controller.d.ts.map +0 -1
- package/lib/types/controllers/scroll.controller.d.ts.map +0 -1
- package/lib/types/controllers/selection.controller.d.ts.map +0 -1
- package/lib/types/controllers/sheet-render.controller.d.ts.map +0 -1
- package/lib/types/controllers/sheet-ui.controller.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/editor.shortcut.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/operation.shortcut.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/selection.shortcut.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/style.shortcut.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/utils.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/value.shortcut.d.ts.map +0 -1
- package/lib/types/controllers/shortcuts/view.shortcut.d.ts.map +0 -1
- package/lib/types/controllers/status-bar.controller.d.ts.map +0 -1
- package/lib/types/controllers/utils/component-tools.d.ts.map +0 -1
- package/lib/types/controllers/zoom.controller.d.ts.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/locale/en-US.d.ts.map +0 -1
- package/lib/types/locale/index.d.ts.map +0 -1
- package/lib/types/locale/zh-CN.d.ts.map +0 -1
- package/lib/types/services/auto-fill/auto-fill.service.d.ts.map +0 -1
- package/lib/types/services/auto-fill/rules.d.ts.map +0 -1
- package/lib/types/services/auto-fill/tools.d.ts.map +0 -1
- package/lib/types/services/auto-fill/type.d.ts.map +0 -1
- package/lib/types/services/clipboard/__tests__/clipboard-service.spec.d.ts.map +0 -1
- package/lib/types/services/clipboard/__tests__/clipboard-test-bed.d.ts.map +0 -1
- package/lib/types/services/clipboard/__tests__/mock-clipboard.d.ts.map +0 -1
- package/lib/types/services/clipboard/clipboard.service.d.ts.map +0 -1
- package/lib/types/services/clipboard/copy-content-cache.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-usm/converter.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-usm/parse-node-style.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-lark.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-usm/paste-plugins/plugin-word.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-usm/paste-plugins/type.d.ts.map +0 -1
- package/lib/types/services/clipboard/html-to-usm/utils.d.ts.map +0 -1
- package/lib/types/services/clipboard/type.d.ts.map +0 -1
- package/lib/types/services/clipboard/usm-to-html/convertor.d.ts.map +0 -1
- package/lib/types/services/editor/cell-editor-manager.service.d.ts.map +0 -1
- package/lib/types/services/editor/formula-editor-manager.service.d.ts.map +0 -1
- package/lib/types/services/editor-bridge.service.d.ts.map +0 -1
- package/lib/types/services/format-painter/format-painter.service.d.ts.map +0 -1
- package/lib/types/services/mark-selection/mark-selection.service.d.ts.map +0 -1
- package/lib/types/services/scroll-manager.service.d.ts.map +0 -1
- package/lib/types/services/selection/selection-render-model.d.ts.map +0 -1
- package/lib/types/services/selection/selection-render.service.d.ts.map +0 -1
- package/lib/types/services/selection/selection-shape-extension.d.ts.map +0 -1
- package/lib/types/services/selection/selection-shape.d.ts.map +0 -1
- package/lib/types/services/sheet-bar/sheet-bar.service.d.ts.map +0 -1
- package/lib/types/services/sheet-skeleton-manager.service.d.ts.map +0 -1
- package/lib/types/services/status-bar.service.d.ts.map +0 -1
- package/lib/types/sheets-ui-plugin.d.ts.map +0 -1
- package/lib/types/views/count-bar/CountBar.d.ts.map +0 -1
- package/lib/types/views/count-bar/index.d.ts.map +0 -1
- package/lib/types/views/count-bar/zoom-slider.d.ts.map +0 -1
- package/lib/types/views/editor-container/EditorContainer.d.ts.map +0 -1
- package/lib/types/views/editor-container/index.d.ts.map +0 -1
- package/lib/types/views/formula-bar/FormulaBar.d.ts.map +0 -1
- package/lib/types/views/formula-bar/index.d.ts.map +0 -1
- package/lib/types/views/header-menu-shape.d.ts.map +0 -1
- package/lib/types/views/header-resize-shape.d.ts.map +0 -1
- package/lib/types/views/header-unhide-shape.d.ts.map +0 -1
- package/lib/types/views/operate-container/AutoFillPopupMenu.d.ts.map +0 -1
- package/lib/types/views/operate-container/OperateContainer.d.ts.map +0 -1
- package/lib/types/views/operate-container/index.d.ts.map +0 -1
- package/lib/types/views/sheet-bar/SheetBar.d.ts.map +0 -1
- package/lib/types/views/sheet-bar/sheet-bar-button/SheetBarButton.d.ts.map +0 -1
- package/lib/types/views/sheet-bar/sheet-bar-menu/SheetBarMenu.d.ts.map +0 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarItem.d.ts.map +0 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/SheetBarTabs.d.ts.map +0 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/animate.d.ts.map +0 -1
- package/lib/types/views/sheet-bar/sheet-bar-tabs/utils/slide-tab-bar.d.ts.map +0 -1
- package/lib/types/views/sheet-canvas-view.d.ts.map +0 -1
- package/lib/types/views/sheet-container/SheetContainer.d.ts.map +0 -1
- package/lib/types/views/status-bar/CopyableStatisticItem.d.ts.map +0 -1
- package/lib/types/views/status-bar/StatusBar.d.ts.map +0 -1
package/lib/umd/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
(function(P,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@wendellhu/redi"),require("rxjs"),require("@univerjs/engine-render"),require("react"),require("@univerjs/design"),require("@wendellhu/redi/react-bindings"),require("@univerjs/docs"),require("rxjs/operators"),require("@univerjs/engine-formula"),require("clsx")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/ui","@wendellhu/redi","rxjs","@univerjs/engine-render","react","@univerjs/design","@wendellhu/redi/react-bindings","@univerjs/docs","rxjs/operators","@univerjs/engine-formula","clsx"],l):(P=typeof globalThis<"u"?globalThis:P||self,l(P.UniverSheetsUi={},P.UniverCore,P.UniverSheets,P.UniverUi,P["@wendellhu/redi"],P.rxjs,P.UniverEngineRender,P.React,P.UniverDesign,P["@wendellhu/redi/react-bindings"],P.UniverDocs,P.rxjs.operators,P.UniverEngineFormula,P.clsx))})(this,function(P,l,f,M,L,B,w,k,ne,F,G,Ti,Z,St){"use strict";var fh=Object.defineProperty;var ph=(P,l,f)=>l in P?fh(P,l,{enumerable:!0,configurable:!0,writable:!0,value:f}):P[l]=f;var C=(P,l,f)=>(ph(P,typeof l!="symbol"?l+"":l,f),f);var wi;const Ei={InsertRow:!0,InsertColumn:!0,AddRowTop:!1,AddRowBottom:!1,AddColumnLeft:!1,AddColumnRight:!1,DeleteRow:!0,DeleteColumn:!0,HideRow:!1,ShowRow:!1,RowHeight:!1,HideColumn:!1,ShowColumn:!1,ColumnWidth:!1,DeleteCell:!0,ClearContent:!0,Matrix:!1},Oi={undo:!0,redo:!0,paintFormat:!0,currencyFormat:!0,percentageFormat:!0,numberDecrease:!0,numberIncrease:!0,moreFormats:!0,font:!0,fontSize:!0,bold:!0,italic:!0,strikethrough:!0,underline:!0,textColor:!0,fillColor:!0,border:!0,horizontalAlignMode:!0,verticalAlignMode:!0,textWrapMode:!0,textRotateMode:!0,mergeCell:!0},yi={outerLeft:!1,outerRight:!1,header:!0,footer:!0,innerLeft:!1,innerRight:!1,frozenHeaderLT:!1,frozenHeaderRT:!1,frozenHeaderLM:!1,frozenContent:!1,infoBar:!0,toolbar:!0,formulaBar:!0,rightMenu:!0,countBar:!0,sheetBar:!0},Rr={layout:{sheetContainerConfig:yi,rightMenuConfig:Ei,toolbarConfig:Oi}},xi="SheetUI";function Bt(i,e){if(i==null)return;const t=e.getRenderById(i);if(t==null)return;const{mainComponent:n,scene:o,engine:r}=t;return{document:n,scene:o,engine:r}}const Vt={type:l.CommandType.COMMAND,id:"sheet.command.auto-fill",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUniverInstanceService),o=i.get(l.IUndoRedoService),{applyRange:r,selectionRange:s,applyDatas:a,unitId:c=n.getCurrentUniverSheetInstance().getUnitId(),subUnitId:d=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),applyMergeRanges:u}=e||{};if(!r||!a||!s)return!1;const h=new l.ObjectMatrix,{startRow:m,startColumn:_,endRow:g,endColumn:S}=r;for(let D=0;D<=g-m;D++)for(let N=0;N<=S-_;N++)h.setValue(D+m,N+_,a[D][N]);const v={subUnitId:d,unitId:c,cellValue:h.getMatrix()},I=f.SetRangeValuesUndoMutationFactory(i,v),b=t.syncExecuteCommand(f.SetRangeValuesMutation.id,v),R=t.syncExecuteCommand(f.SetSelectionsOperation.id,{selections:[{primary:{...s,endColumn:s.startColumn,endRow:s.startRow},range:{...s,rangeType:l.RANGE_TYPE.NORMAL}}],unitId:c,subUnitId:d}),T=[{id:f.SetRangeValuesMutation.id,params:I}],E=[{id:f.SetRangeValuesMutation.id,params:v}];let O=!0,y=!0;if(u!=null&&u.length){const D=f.getAddMergeMutationRangeByType(u),N={unitId:c,subUnitId:d,ranges:D},U=f.RemoveMergeUndoMutationFactory(i,N);O=t.syncExecuteCommand(f.RemoveWorksheetMergeMutation.id,N);const V={unitId:c,subUnitId:d,ranges:D},$=f.AddMergeUndoMutationFactory(i,V);y=t.syncExecuteCommand(f.AddWorksheetMergeMutation.id,V),T.push({id:f.AddWorksheetMergeMutation.id,params:U}),T.push({id:f.RemoveWorksheetMergeMutation.id,params:$}),E.push({id:f.RemoveWorksheetMergeMutation.id,params:N}),E.push({id:f.AddWorksheetMergeMutation.id,params:V})}const{undo:x,redo:A}=e==null?void 0:e.extendMutations,H=A.every(D=>t.syncExecuteCommand(D.id,D.params));return x.forEach(D=>{T.push(D)}),A.forEach(D=>{E.push(D)}),b&&O&&y&&R&&H&&o.pushUndoRedo({unitID:c,undoMutations:T,redoMutations:E}),!0}},Ft={id:"sheet.command.auto-clear-content",type:l.CommandType.COMMAND,handler:async(i,e)=>{const t=i.get(l.IUniverInstanceService),n=i.get(l.ICommandService),o=i.get(l.IUndoRedoService),r=t.getCurrentUniverSheetInstance(),s=r.getUnitId(),c=r.getActiveSheet().getSheetId(),{clearRange:d,selectionRange:u}=e,h={subUnitId:c,unitId:s,cellValue:wr([d])},m=f.SetRangeValuesUndoMutationFactory(i,h);return n.executeCommand(f.SetSelectionsOperation.id,{selections:[{primary:{...u},range:{...u}}],unitId:s,subUnitId:c}),n.syncExecuteCommand(f.SetRangeValuesMutation.id,h)?(o.pushUndoRedo({unitID:s,undoMutations:[{id:f.SetRangeValuesMutation.id,params:m}],redoMutations:[{id:f.SetRangeValuesMutation.id,params:h}],undo(){return n.syncExecuteCommand(f.SetRangeValuesMutation.id,m)},redo(){return n.syncExecuteCommand(f.SetRangeValuesMutation.id,h)}}),!0):!1}};function wr(i){const e=new l.ObjectMatrix;return i.forEach(t=>{const{startRow:n,startColumn:o,endRow:r,endColumn:s}=t;for(let a=n;a<=r;a++)for(let c=o;c<=s;c++)e.setValue(a,c,{v:null,p:null,f:null,si:null})}),e.getData()}function Y(i){return i.getContextValue(l.FOCUSING_SHEET)&&!i.getContextValue(l.FOCUSING_EDITOR)}function Tr(i){return i.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!i.getContextValue(l.FOCUSING_EDITOR)}function Er(i){return i.getContextValue(l.FOCUSING_EDITOR)&&i.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)}function Ai(i){return i.getContextValue(l.FOCUSING_FORMULA_EDITOR)}function Or(i){return i.getContextValue(l.FOCUSING_EDITOR)&&i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}function Wt(i){return i.getContextValue(l.FOCUSING_EDITOR)&&!i.getContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA)}const yr=l.createInterceptorKey("BEFORE_CELL_EDIT"),xr=l.createInterceptorKey("AFTER_CELL_EDIT");class Pi extends l.Disposable{constructor(){super();C(this,"_state",null);C(this,"_isForceKeepVisible",!1);C(this,"_editorIsDirty",!1);C(this,"_visible",{visible:!1,eventType:w.DeviceInputEventType.Dblclick});C(this,"_state$",new B.BehaviorSubject(null));C(this,"state$",this._state$.asObservable());C(this,"_visible$",new B.BehaviorSubject(this._visible));C(this,"visible$",this._visible$.asObservable());C(this,"_afterVisible$",new B.BehaviorSubject(this._visible));C(this,"afterVisible$",this._afterVisible$.asObservable());C(this,"interceptor",new l.InterceptorManager({BEFORE_CELL_EDIT:yr,AFTER_CELL_EDIT:xr}));this.disposeWithMe(l.toDisposable(()=>{this._state$.complete(),this._state=null})),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().AFTER_CELL_EDIT,{priority:-1,handler:t=>t}))),this.disposeWithMe(l.toDisposable(this.interceptor.intercept(this.interceptor.getInterceptPoints().BEFORE_CELL_EDIT,{priority:-1,handler:t=>t})))}setState(t){this._state=t,this._state$.next(t)}getState(){return this._state}getCurrentEditorId(){var t;return(t=this._state)==null?void 0:t.editorUnitId}changeVisible(t){this._visible=t,t.visible&&(this._editorIsDirty=!1),this._visible$.next(this._visible),this._afterVisible$.next(this._visible)}isVisible(){return this._visible}enableForceKeepVisible(){this._isForceKeepVisible=!0}disableForceKeepVisible(){this._isForceKeepVisible=!1}isForceKeepVisible(){return this._isForceKeepVisible}changeEditorDirty(t){this._editorIsDirty=t}getEditorDirty(){return this._editorIsDirty}}const Ce=L.createIdentifier("univer.sheet-editor-bridge.service"),Ie={id:"sheet.operation.set-cell-edit-visible",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(Ce);return e==null?!1:(t.changeVisible(e),!0)}},gt={id:"sheet.operation.set-cell-edit-visible-arrow",type:l.CommandType.OPERATION,handler:()=>!0};class Ar{constructor(){C(this,"_startColumn",-1);C(this,"_startRow",-1);C(this,"_endColumn",-1);C(this,"_endRow",-1);C(this,"_startX",0);C(this,"_startY",0);C(this,"_endX",0);C(this,"_endY",0);C(this,"_currentCell");C(this,"_rangeType",l.RANGE_TYPE.NORMAL)}get startColumn(){return this._startColumn}get startRow(){return this._startRow}get endColumn(){return this._endColumn}get endRow(){return this._endRow}get startX(){return this._startX}get startY(){return this._startY}get endX(){return this._endX}get endY(){return this._endY}get currentCell(){return this._currentCell}get rangeType(){return this._rangeType}isEqual(e){const{startColumn:t,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return t===s&&n===a&&o===c&&r===d}isInclude(e){const{startColumn:t,startRow:n,endColumn:o,endRow:r}=this,{startColumn:s,startRow:a,endColumn:c,endRow:d}=e;return!(c<t||s>o||a>r||d<n)}highlightToSelection(){return l.makeCellToSelection(this._currentCell)}getRange(){return{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this.rangeType}}getCell(){return this._currentCell}getRangeType(){return this._rangeType}getValue(){return{rangeWithCoord:{startColumn:this._startColumn,startRow:this._startRow,endColumn:this._endColumn,endRow:this._endRow,startX:this._startX,startY:this._startY,endX:this._endX,endY:this._endY,rangeType:this._rangeType},primaryWithCoord:this._currentCell}}setValue(e,t){const{startColumn:n,startRow:o,endColumn:r,endRow:s,startX:a,startY:c,endX:d,endY:u,rangeType:h}=e;this._startColumn=n,this._startRow=o,this._endColumn=r,this._endRow=s,this._startX=a,this._startY=c,this._endX=d,this._endY=u,h!=null&&(this._rangeType=h),this.setCurrentCell(t)}setCurrentCell(e){e&&(this._currentCell=e)}clearCurrentCell(){this._currentCell=null}}const Di=.3;class jt{constructor(e,t,n=!0,o){C(this,"_leftControl");C(this,"_rightControl");C(this,"_topControl");C(this,"_bottomControl");C(this,"_backgroundControlTop");C(this,"_backgroundControlBottom");C(this,"_backgroundControlMiddleLeft");C(this,"_backgroundControlMiddleRight");C(this,"_fillControl");C(this,"_selectionShape");C(this,"_rowHeaderBackground");C(this,"_rowHeaderBorder");C(this,"_rowHeaderGroup");C(this,"_rowHeaderHighlight");C(this,"_columnHeaderBackground");C(this,"_columnHeaderBorder");C(this,"_columnHeaderGroup");C(this,"_columnHeaderHighlight");C(this,"_topLeftWidget");C(this,"_topCenterWidget");C(this,"_topRightWidget");C(this,"_middleLeftWidget");C(this,"_middleRightWidget");C(this,"_bottomLeftWidget");C(this,"_bottomCenterWidget");C(this,"_bottomRightWidget");C(this,"_dashRect");C(this,"_selectionModel");C(this,"_selectionStyle");C(this,"_rowHeaderWidth",0);C(this,"_columnHeaderHeight",0);C(this,"_widgetRects",[]);C(this,"_dispose$",new B.BehaviorSubject(this));C(this,"dispose$",this._dispose$.asObservable());C(this,"selectionMoving$",new B.Subject);C(this,"selectionMoved$",new B.Subject);C(this,"selectionScaling$",new B.Subject);C(this,"selectionScaled$",new B.Subject);C(this,"selectionFilling$",new B.Subject);C(this,"_selectionFilled$",new B.Subject);C(this,"selectionFilled$",this._selectionFilled$.asObservable());C(this,"_defaultStyle");C(this,"_isHelperSelection",!0);this._scene=e,this._zIndex=t,this._isHeaderHighlight=n,this._themeService=o,this._initialize()}get zIndex(){return this._zIndex}get leftControl(){return this._leftControl}get rightControl(){return this._rightControl}get topControl(){return this._topControl}get bottomControl(){return this._bottomControl}get fillControl(){return this._fillControl}get backgroundControlTop(){return this._backgroundControlTop}get backgroundControlBottom(){return this._backgroundControlBottom}get backgroundControlMiddleLeft(){return this._backgroundControlMiddleLeft}get backgroundControlMiddleRight(){return this._backgroundControlMiddleRight}get selectionShape(){return this._selectionShape}get model(){return this._selectionModel}get topLeftWidget(){return this._topLeftWidget}get topCenterWidget(){return this._topCenterWidget}get topRightWidget(){return this._topRightWidget}get middleLeftWidget(){return this._middleLeftWidget}get middleRightWidget(){return this._middleRightWidget}get bottomLeftWidget(){return this._bottomLeftWidget}get bottomCenterWidget(){return this._bottomCenterWidget}get bottomRightWidget(){return this._bottomRightWidget}get selectionStyle(){return this._selectionStyle}get dashRect(){return this._dashRect}get isHelperSelection(){return this._isHelperSelection}enableHeaderHighlight(){this._isHelperSelection=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}refreshSelectionFilled(e){this._selectionFilled$.next(e)}updateStyle(e){this._updateControl(e,this._rowHeaderWidth,this._columnHeaderHeight)}update(e,t=0,n=0,o,r){this._selectionModel.setValue(e,r),o==null&&(o=this._selectionStyle),this._updateControl(o,t,n)}clearHighlight(){this._selectionModel.clearCurrentCell(),this._updateControl(this._selectionStyle,this._rowHeaderWidth,this._columnHeaderHeight)}getScene(){return this._scene}dispose(){var e,t,n,o,r,s,a,c,d,u,h,m,_,g,S,v,I,b,R,T,E,O,y,x,A;(e=this._leftControl)==null||e.dispose(),(t=this._rightControl)==null||t.dispose(),(n=this._topControl)==null||n.dispose(),(o=this._bottomControl)==null||o.dispose(),(r=this._backgroundControlTop)==null||r.dispose(),(s=this._backgroundControlMiddleLeft)==null||s.dispose(),(a=this._backgroundControlMiddleRight)==null||a.dispose(),(c=this._backgroundControlBottom)==null||c.dispose(),(d=this._fillControl)==null||d.dispose(),(u=this._selectionShape)==null||u.dispose(),(h=this._rowHeaderBackground)==null||h.dispose(),(m=this._rowHeaderBorder)==null||m.dispose(),(_=this._rowHeaderGroup)==null||_.dispose(),(g=this._rowHeaderBackground)==null||g.dispose(),(S=this._columnHeaderBackground)==null||S.dispose(),(v=this._columnHeaderBorder)==null||v.dispose(),(I=this._columnHeaderGroup)==null||I.dispose(),(b=this._topLeftWidget)==null||b.dispose(),(R=this._topCenterWidget)==null||R.dispose(),(T=this._topRightWidget)==null||T.dispose(),(E=this._middleLeftWidget)==null||E.dispose(),(O=this._middleRightWidget)==null||O.dispose(),(y=this._bottomLeftWidget)==null||y.dispose(),(x=this._bottomCenterWidget)==null||x.dispose(),(A=this._bottomRightWidget)==null||A.dispose(),this._dispose$.next(this),this._dispose$.complete()}getCurrentCellInfo(){const e=this.model.currentCell;if(e){let t;if(e.isMerged){const n=e.mergeInfo;t={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn,startX:n.startX,endX:n.endX,startY:n.startY,endY:n.endY}}else{const{actualRow:n,actualColumn:o,startX:r,endX:s,startY:a,endY:c}=e;t={startRow:n,endRow:n,startColumn:o,endColumn:o,startX:r,endX:s,startY:a,endY:c}}return t}}getValue(){return{...this._selectionModel.getValue(),style:this._selectionStyle}}getRange(){return this._selectionModel.getValue().rangeWithCoord}enableHelperSelection(){this._isHelperSelection=!0}disableHelperSelection(){this._isHelperSelection=!1}updateStyleId(e){this._selectionStyle!=null&&(this._selectionStyle.id=e)}_updateControl(e,t,n){const{startX:o,startY:r,endX:s,endY:a}=this._selectionModel,c=this._defaultStyle;e==null&&(e=c);const{stroke:d=c.stroke,widgets:u=c.widgets,hasAutoFill:h=c.hasAutoFill,AutofillStroke:m=c.AutofillStroke,strokeDash:_}=e;let{strokeWidth:g=c.strokeWidth,AutofillSize:S=c.AutofillSize,AutofillStrokeWidth:v=c.AutofillStrokeWidth}=e;const I=this._getScale();g/=I,S/=I,v/=I;const b=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/I,R=g+b,T=w.FIX_ONE_PIXEL_BLUR_OFFSET/I;this.leftControl.transformByState({height:w.fixLineWidthByScale(a-r,I),left:-R/2+T,width:g,strokeWidth:b,top:-b/2+T}),this.leftControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.rightControl.transformByState({height:w.fixLineWidthByScale(a-r,I),left:w.fixLineWidthByScale(s-o,I)-R/2+T,width:g,strokeWidth:b,top:-b/2+T}),this.rightControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.topControl.transformByState({width:w.fixLineWidthByScale(s-o,I)+g,top:-R/2+T,left:-R/2+T,height:g,strokeWidth:b}),this.topControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),this.bottomControl.transformByState({width:w.fixLineWidthByScale(s-o,I)+g,top:w.fixLineWidthByScale(a-r,I)-R/2+T,height:g,left:-R/2+T,strokeWidth:b}),this.bottomControl.setProps({fill:d,stroke:f.SELECTION_CONTROL_BORDER_BUFFER_COLOR}),_==null?this.dashRect.hide():(this.dashRect.transformByState({height:a-r,width:s-o,strokeWidth:g,left:-1,top:-1}),this.dashRect.setProps({strokeDashArray:[0,_]}),this.dashRect.show()),h===!0&&!this._hasWidgets(u)?(this.fillControl.setProps({fill:d,stroke:m}),this.fillControl.transformByState({width:S-v,height:S-v,left:s-o-S/2,top:a-r-S/2,strokeWidth:v}),this.fillControl.show()):this.fillControl.hide(),this._updateBackgroundControl(e),this._updateBackgroundTitle(e,t,n),this._updateWidgets(e),this.selectionShape.show(),this.selectionShape.translate(o,r),this._selectionStyle=e,this._rowHeaderWidth=t||0,this._columnHeaderHeight=n||0,this.selectionShape.makeDirtyNoDebounce(!0)}_initialize(){this._defaultStyle=f.getNormalSelectionStyle(this._themeService),this._selectionModel=new Ar;const e=this._zIndex;this._leftControl=new w.Rect("__SpreadsheetSelectionShapeLeftControl__"+e,{zIndex:e}),this._rightControl=new w.Rect("__SpreadsheetSelectionShapeRightControl__"+e,{zIndex:e}),this._topControl=new w.Rect("__SpreadsheetSelectionTopControl__"+e,{zIndex:e}),this._bottomControl=new w.Rect("__SpreadsheetSelectionBottomControl__"+e,{zIndex:e}),this._backgroundControlTop=new w.Rect("__SpreadsheetSelectionBackgroundControlTop__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlBottom=new w.Rect("__SpreadsheetSelectionBackgroundControlBottom__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleLeft=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleLeft__"+e,{zIndex:e-1,evented:!1}),this._backgroundControlMiddleRight=new w.Rect("__SpreadsheetSelectionBackgroundControlMiddleRight__"+e,{zIndex:e-1,evented:!1}),this._fillControl=new w.Rect("__SpreadsheetSelectionFillControl__"+e,{zIndex:e+1}),this._dashRect=new w.Rect("__SpreadsheetDragDashControl__"+e,{zIndex:e+2,evented:!1,stroke:"#fff"});const t=[this._fillControl,this._leftControl,this._rightControl,this._topControl,this._bottomControl,this._backgroundControlTop,this._backgroundControlMiddleLeft,this._backgroundControlMiddleRight,this._backgroundControlBottom,this._dashRect];this._widgetRects=this._initialWidget(),this._selectionShape=new w.Group("__SpreadsheetSelectionShape__"+e,...t,...this._widgetRects),this._selectionShape.hide(),this._selectionShape.evented=!1,this._selectionShape.zIndex=e,this.getScene().addObject(this._selectionShape),this._initialTitle()}_initialTitle(){const e=this._zIndex;this._rowHeaderBackground=new w.Rect("__SpreadSheetSelectionRowHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderBorder=new w.Rect("__SpreadSheetSelectionRowHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._rowHeaderGroup=new w.Group("__SpreadSheetSelectionRowHeaderGroup__"+e,this._rowHeaderBackground,this._rowHeaderBorder),this._rowHeaderGroup.hide(),this._rowHeaderGroup.evented=!1,this._rowHeaderGroup.zIndex=e,this._columnHeaderBackground=new w.Rect("__SpreadSheetSelectionColumnHeaderBackground__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderBorder=new w.Rect("__SpreadSheetSelectionColumnHeaderBorder__"+e,{zIndex:e-1,evented:!1}),this._columnHeaderGroup=new w.Group("__SpreadSheetSelectionColumnHeaderGroup__"+e,this._columnHeaderBackground,this._columnHeaderBorder),this._columnHeaderGroup.hide(),this._columnHeaderGroup.evented=!1,this._columnHeaderGroup.zIndex=e,this.getScene().addObjects([this._rowHeaderGroup,this._columnHeaderGroup],w.DEFAULT_SELECTION_LAYER_INDEX)}_initialWidget(){const e=this._zIndex;return this._topLeftWidget=new w.Rect("__SpreadSheetSelectionTopLeftWidget__"+e,{zIndex:e+1}),this._topCenterWidget=new w.Rect("__SpreadSheetSelectionTopCenterWidget__"+e,{zIndex:e+1}),this._topRightWidget=new w.Rect("__SpreadSheetSelectionTopRightWidget__"+e,{zIndex:e+1}),this._middleLeftWidget=new w.Rect("__SpreadSheetSelectionMiddleLeftWidget__"+e,{zIndex:e+1}),this._middleRightWidget=new w.Rect("__SpreadSheetSelectionMiddleRightWidget__"+e,{zIndex:e+1}),this._bottomLeftWidget=new w.Rect("__SpreadSheetSelectionBottomLeftWidget__"+e,{zIndex:e+1}),this._bottomCenterWidget=new w.Rect("__SpreadSheetSelectionBottomCenterWidget__"+e,{zIndex:e+1}),this._bottomRightWidget=new w.Rect("__SpreadSheetSelectionBottomRightWidget__"+e,{zIndex:e+1}),[this._topLeftWidget,this._topCenterWidget,this._topRightWidget,this._middleLeftWidget,this._middleRightWidget,this._bottomLeftWidget,this._bottomCenterWidget,this._bottomRightWidget]}_updateBackgroundTitle(e,t,n){const{startX:o,startY:r,endX:s,endY:a,rangeType:c}=this._selectionModel,d=this._defaultStyle;e==null&&(e=d);const u=this._getScale(),{stroke:h,hasRowHeader:m,rowHeaderFill:_=d.rowHeaderFill,rowHeaderStroke:g=d.rowHeaderStroke,hasColumnHeader:S,columnHeaderFill:v=d.columnHeaderFill,columnHeaderStroke:I=d.columnHeaderStroke}=e;let{rowHeaderStrokeWidth:b=d.rowHeaderStrokeWidth,columnHeaderStrokeWidth:R=d.columnHeaderStrokeWidth}=e;if(b/=u,R/=u,S===!0){let T=v;this._isHeaderHighlight&&c===l.RANGE_TYPE.COLUMN&&(T=new l.ColorKit(h).setAlpha(Di).toString()),this._columnHeaderBackground.setProps({fill:T}),this._columnHeaderBackground.resize(s-o,n),this._columnHeaderBorder.setProps({fill:I}),this._columnHeaderBorder.transformByState({width:s-o,height:R,top:n-R+1/u}),this._columnHeaderGroup.show(),this._columnHeaderGroup.translate(o,0)}else this._columnHeaderGroup.hide();if(this._columnHeaderGroup.makeDirty(!0),m===!0){let T=_;this._isHeaderHighlight&&c===l.RANGE_TYPE.ROW&&(T=new l.ColorKit(h).setAlpha(Di).toString()),this._rowHeaderBackground.setProps({fill:T}),this._rowHeaderBackground.resize(t,a-r),this._rowHeaderBorder.setProps({fill:g}),this._rowHeaderBorder.transformByState({width:b,height:a-r,left:t-b+1/u}),this._rowHeaderGroup.show(),this._rowHeaderGroup.translate(0,r)}else this._rowHeaderGroup.hide();this._rowHeaderGroup.makeDirty(!0)}_updateBackgroundControl(e){const{startX:t,startY:n,endX:o,endY:r}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const a=this._getScale(),{fill:c=s.fill}=e;let{strokeWidth:d=s.strokeWidth}=e;d/=a;const u=this._selectionModel.highlightToSelection();if(!u){this._backgroundControlTop.resize(o-t,r-n),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlBottom.resize(0,0),this._backgroundControlMiddleLeft.resize(0,0),this._backgroundControlMiddleRight.resize(0,0);return}const{startX:h,startY:m,endX:_,endY:g}=u,S=d/2,v={left:-S,top:-S,width:o-t+S*2,height:m-n+S};v.height<0&&(v.width=0,v.height=0),this._backgroundControlTop.transformByState(v);const I={left:-S,top:m-n,width:h-t+S,height:g-m};I.width<0&&(I.width=0,I.height=0),this._backgroundControlMiddleLeft.transformByState(I);const b={left:_-t-S,top:m-n,width:o-_+S*2,height:g-m};b.width<0&&(b.width=0,b.height=0),this._backgroundControlMiddleRight.transformByState(b);const R={left:-S,top:g-n,width:o-t+S*2,height:r-g+S};R.height<0&&(R.width=0,R.height=0),this._backgroundControlBottom.transformByState(R),this._backgroundControlTop.setProps({fill:c}),this._backgroundControlMiddleLeft.setProps({fill:c}),this._backgroundControlMiddleRight.setProps({fill:c}),this._backgroundControlBottom.setProps({fill:c})}_updateWidgets(e){const{startX:t,startY:n,endX:o,endY:r}=this._selectionModel,s=this._defaultStyle;e==null&&(e=s);const{stroke:a=s.stroke,widgets:c=s.widgets,widgetStroke:d=s.widgetStroke}=e,u=this._getScale();let{widgetSize:h=s.widgetSize,widgetStrokeWidth:m=s.widgetStrokeWidth}=e;h/=u,m/=u;const _={left:-h/2,center:(o-t)/2-h/2,right:o-t-h/2,top:-h/2,middle:(r-n)/2-h/2,bottom:r-n-h/2},g=h-m;this._widgetRects.forEach(S=>{S.setProps({fill:a,stroke:d})}),c.tl===!0?(this._topLeftWidget.transformByState({height:g,width:g,left:_.left,top:_.top,strokeWidth:m}),this._topLeftWidget.show()):this._topLeftWidget.hide(),c.tc===!0?(this._topCenterWidget.transformByState({height:g,width:g,left:_.center,top:_.top,strokeWidth:m}),this._topCenterWidget.show()):this._topCenterWidget.hide(),c.tr===!0?(this._topRightWidget.transformByState({height:g,width:g,left:_.right,top:_.top,strokeWidth:m}),this._topRightWidget.show()):this._topRightWidget.hide(),c.ml===!0?(this._middleLeftWidget.transformByState({height:g,width:g,left:_.left,top:_.middle,strokeWidth:m}),this._middleLeftWidget.show()):this._middleLeftWidget.hide(),c.mr===!0?(this._middleRightWidget.transformByState({height:g,width:g,left:_.right,top:_.middle,strokeWidth:m}),this._middleRightWidget.show()):this._middleRightWidget.hide(),c.bl===!0?(this._bottomLeftWidget.transformByState({height:g,width:g,left:_.left,top:_.bottom,strokeWidth:m}),this._bottomLeftWidget.show()):this._bottomLeftWidget.hide(),c.bc===!0?(this._bottomCenterWidget.transformByState({height:g,width:g,left:_.center,top:_.bottom,strokeWidth:m}),this._bottomCenterWidget.show()):this._bottomCenterWidget.hide(),c.br===!0?(this._bottomRightWidget.transformByState({height:g,width:g,left:_.right,top:_.bottom,strokeWidth:m}),this._bottomRightWidget.show()):this._bottomRightWidget.hide()}_hasWidgets(e){if(e==null)return!1;const t=Object.keys(e);if(t.length===0)return!1;for(const n of t)if(e[n]===!0)return!0;return!0}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}const Hi="__SpreadsheetHelperSelectionTempRect",Pr=35;class Ni{constructor(e,t,n,o){C(this,"_startOffsetX",0);C(this,"_startOffsetY",0);C(this,"_relativeSelectionPositionRow",0);C(this,"_relativeSelectionPositionColumn",0);C(this,"_relativeSelectionRowLength",0);C(this,"_relativeSelectionColumnLength",0);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_helperSelection");C(this,"_scrollTimer");C(this,"_targetSelection",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});C(this,"_isInMergeState",!1);C(this,"_fillControlColors",[]);this._control=e,this._skeleton=t,this._scene=n,this._themeService=o,this._initialControl(),this._initialWidget(),this._initialFill(),this._control.dispose$.subscribe(()=>{this.dispose()})}get isHelperSelection(){return this._control.isHelperSelection}dispose(){var e,t;(e=this._scrollTimer)==null||e.dispose(),this._fillControlColors=[],this._clearObserverEvent(),(t=this._helperSelection)==null||t.dispose()}_clearObserverEvent(){this._scene.onPointerMoveObserver.remove(this._moveObserver),this._scene.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_initialControl(){const{leftControl:e,rightControl:t,topControl:n,bottomControl:o}=this._control;[e,t,n,o].forEach(r=>{r.onPointerEnterObserver.add(()=>{r.setCursor(w.CURSOR_TYPE.MOVE)}),r.onPointerLeaveObserver.add(()=>{r.resetCursor()}),r.onPointerDownObserver.add(this._controlEvent.bind(this))})}_controlMoving(e,t){var O;const n=this._scene,o=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,r,s,o),{row:c,column:d}=a,u=this._skeleton.getRowCount()-1,h=this._skeleton.getColumnCount()-1;let m=c+this._relativeSelectionPositionRow;m<0&&(m=0);let _=m+this._relativeSelectionRowLength;_>u&&(_=u,_-m<this._relativeSelectionRowLength&&(m=_-this._relativeSelectionRowLength));let g=d+this._relativeSelectionPositionColumn;g<0&&(g=0);let S=g+this._relativeSelectionColumnLength;S>h&&(S=h,S-g<this._relativeSelectionColumnLength&&(g=S-this._relativeSelectionColumnLength));const v=this._skeleton.getNoMergeCellPositionByIndex(m,g,r,s),I=this._skeleton.getNoMergeCellPositionByIndex(_,S,r,s),b=(v==null?void 0:v.startY)||0,R=(I==null?void 0:I.endY)||0,T=(v==null?void 0:v.startX)||0,E=(I==null?void 0:I.endX)||0;(O=this._helperSelection)==null||O.transformByState({left:T,top:b,width:E-T,height:R-b}),this._targetSelection={startY:b,endY:R,startX:T,endX:E,startRow:m,endRow:_,startColumn:g,endColumn:S},this._control.selectionMoving$.next(this._targetSelection)}_controlEvent(e){const{offsetX:t,offsetY:n}=e,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([t,n])),{x:s,y:a}=r,c=o.getScrollXYByRelativeCoords(r),{scaleX:d,scaleY:u}=o.getAncestorScale(),h=this._skeleton.getCellPositionByOffset(s,a,d,u,c);this._startOffsetX=s,this._startOffsetY=a;const{row:m,column:_}=h,{startRow:g,startColumn:S,endRow:v,endColumn:I}=this._control.model;let b=0,R=0;m<g?b-=1:m>v&&(b+=1),_<S?R-=1:_>I&&(R+=1),this._relativeSelectionPositionRow=g-m+b,this._relativeSelectionPositionColumn=S-_+R,this._relativeSelectionRowLength=v-g,this._relativeSelectionColumnLength=I-S;const T=this._control.selectionStyle,E=this._getScale();this.isHelperSelection&&(this._helperSelection=new w.Rect(Hi,{stroke:T.stroke,strokeWidth:T.strokeWidth/E}),o.addObject(this._helperSelection));const O=w.ScrollTimer.create(o);O.startScroll(s,a),this._scrollTimer=O,o.disableEvent(),this._moveObserver=o.onPointerMoveObserver.add(y=>{const{offsetX:x,offsetY:A}=y,{x:H,y:D}=o.getRelativeCoord(w.Vector2.FromArray([x,A]));this._controlMoving(H,D),o.setCursor(w.CURSOR_TYPE.MOVE),O.scrolling(H,D,()=>{this._controlMoving(H,D)})}),this._upObserver=o.onPointerUpObserver.add(y=>{var A,H;(A=this._helperSelection)==null||A.dispose();const x=this._scene;x.resetCursor(),this._clearObserverEvent(),x.enableEvent(),(H=this._scrollTimer)==null||H.dispose(),this._control.selectionMoved$.next(this._targetSelection)})}_initialWidget(){const{topLeftWidget:e,topCenterWidget:t,topRightWidget:n,middleLeftWidget:o,middleRightWidget:r,bottomLeftWidget:s,bottomCenterWidget:a,bottomRightWidget:c}=this._control,d=[w.CURSOR_TYPE.NORTH_WEST_RESIZE,w.CURSOR_TYPE.NORTH_RESIZE,w.CURSOR_TYPE.NORTH_EAST_RESIZE,w.CURSOR_TYPE.WEST_RESIZE,w.CURSOR_TYPE.EAST_RESIZE,w.CURSOR_TYPE.SOUTH_WEST_RESIZE,w.CURSOR_TYPE.SOUTH_RESIZE,w.CURSOR_TYPE.SOUTH_EAST_RESIZE];[e,t,n,o,r,s,a,c].forEach((u,h)=>{u.onPointerEnterObserver.add(m=>{u.setCursor(d[h])}),u.onPointerLeaveObserver.add(m=>{u.resetCursor()}),u.onPointerDownObserver.add(m=>{this._widgetEvent(m,d[h])})})}_widgetMoving(e,t,n){const o=this._scene,r=o.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:s,scaleY:a}=o.getAncestorScale(),c=this._skeleton.getCellPositionByOffset(e,t,s,a,r),{row:d,column:u}=c,{rowHeaderWidth:h,columnHeaderHeight:m}=this._skeleton;this._skeleton.getRowCount()-1,this._skeleton.getColumnCount()-1;let _=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,v=u;n===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(_=d,g=u,S=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.NORTH_RESIZE?(_=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength):n===w.CURSOR_TYPE.NORTH_EAST_RESIZE?(_=d,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow,v=u):n===w.CURSOR_TYPE.WEST_RESIZE?(_=this._relativeSelectionPositionRow,g=u,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.EAST_RESIZE?S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength:n===w.CURSOR_TYPE.SOUTH_WEST_RESIZE?(_=this._relativeSelectionPositionRow,g=u,S=d,v=this._relativeSelectionPositionColumn):n===w.CURSOR_TYPE.SOUTH_RESIZE&&(_=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=d,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength);const{startRow:I,startColumn:b,endRow:R,endColumn:T}=this._swapPositions(_,g,S,v),E=this._skeleton.getNoMergeCellPositionByIndex(I,b,s,a),O=this._skeleton.getNoMergeCellPositionByIndex(R,T,s,a),y=(E==null?void 0:E.startY)||0,x=(O==null?void 0:O.endY)||0,A=(E==null?void 0:E.startX)||0,H=(O==null?void 0:O.endX)||0;this._targetSelection={startY:y,endY:x,startX:A,endX:H,startRow:_,endRow:S,startColumn:g,endColumn:v},this._control.update(this._targetSelection,h,m,this._control.selectionStyle),this._control.clearHighlight(),this._control.selectionScaling$.next(this._targetSelection)}_widgetEvent(e,t){const{offsetX:n,offsetY:o}=e,r=this._scene,s=r.getRelativeCoord(w.Vector2.FromArray([n,o])),{x:a,y:c}=s;this._startOffsetX=n,this._startOffsetY=o;const{startRow:d,startColumn:u,endRow:h,endColumn:m}=this._control.model;this._relativeSelectionPositionRow=d,this._relativeSelectionPositionColumn=u,this._relativeSelectionRowLength=h-d,this._relativeSelectionColumnLength=m-u,t===w.CURSOR_TYPE.NORTH_WEST_RESIZE?(this._relativeSelectionPositionRow=h,this._relativeSelectionPositionColumn=m):t===w.CURSOR_TYPE.NORTH_RESIZE?this._relativeSelectionPositionRow=h:t===w.CURSOR_TYPE.NORTH_EAST_RESIZE?this._relativeSelectionPositionRow=h:t===w.CURSOR_TYPE.WEST_RESIZE?this._relativeSelectionPositionColumn=m:t===w.CURSOR_TYPE.SOUTH_WEST_RESIZE&&(this._relativeSelectionPositionColumn=m);const _=w.ScrollTimer.create(r);_.startScroll(a,c),this._scrollTimer=_,r.disableEvent(),this._moveObserver=r.onPointerMoveObserver.add(g=>{const{offsetX:S,offsetY:v}=g,{x:I,y:b}=r.getRelativeCoord(w.Vector2.FromArray([S,v]));this._widgetMoving(I,b,t),r.setCursor(t),_.scrolling(I,b,()=>{this._widgetMoving(I,b,t)})}),this._upObserver=r.onPointerUpObserver.add(g=>{var v;const S=this._scene;S.resetCursor(),this._clearObserverEvent(),S.enableEvent(),(v=this._scrollTimer)==null||v.dispose(),this._control.selectionScaled$.next(this._targetSelection)})}_initialFill(){const{fillControl:e}=this._control;e.onPointerEnterObserver.add(t=>{e.setCursor(w.CURSOR_TYPE.CROSSHAIR)}),e.onPointerLeaveObserver.add(t=>{e.resetCursor()}),e.onPointerDownObserver.add(this._fillEvent.bind(this))}_fillMoving(e,t){var H,D,N;const n=this._scene,o=n.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:r,scaleY:s}=n.getAncestorScale(),a=this._skeleton.getCellPositionByOffset(e,t,r,s,o),{row:c,column:d}=a,u=n.getRelativeCoord(w.Vector2.FromArray([e,t])),h=this._skeleton.getRowCount()-1,m=this._skeleton.getColumnCount()-1;let _=this._relativeSelectionPositionRow,g=this._relativeSelectionPositionColumn,S=this._relativeSelectionPositionRow+this._relativeSelectionRowLength,v=this._relativeSelectionPositionColumn+this._relativeSelectionColumnLength,I=!1,b=!0;if((d<g||d>v)&&c>=_&&c<=S){const U=this._FillRuler(d,g,v,this._relativeSelectionColumnLength,m);g=U.startRowOrColumn,v=U.endRowOrColumn,I=U.isLighten,b=!1}else if((c<_||c>S)&&d>=g&&d<=v){const U=this._FillRuler(c,_,S,this._relativeSelectionRowLength,h);_=U.startRowOrColumn,S=U.endRowOrColumn,I=U.isLighten}else if(Math.abs(this._startOffsetX-u.x-o.x)/2>Math.abs(this._startOffsetY-u.y-o.y)){const U=this._FillRuler(d,g,v,this._relativeSelectionColumnLength,m);g=U.startRowOrColumn,v=U.endRowOrColumn,I=U.isLighten,b=!1}else{const U=this._FillRuler(c,_,S,this._relativeSelectionRowLength,h);_=U.startRowOrColumn,S=U.endRowOrColumn,I=U.isLighten}const R=this._skeleton.getNoMergeCellPositionByIndex(_,g,r,s),T=this._skeleton.getNoMergeCellPositionByIndex(S,v,r,s),E=(R==null?void 0:R.startY)||0,O=(T==null?void 0:T.endY)||0,y=(R==null?void 0:R.startX)||0,x=(T==null?void 0:T.endX)||0;I?this._controlHandler((U,V)=>{const $=new l.ColorKit(this._fillControlColors[V]).lighten(Pr).toRgbString();U.setProps({fill:$})}):this._controlHandler((U,V)=>{U.setProps({fill:this._fillControlColors[V]})});const A=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/this._getScale();_===S&&b===!0||g===v&&b===!1?(H=this._helperSelection)==null||H.hide():((D=this._helperSelection)==null||D.transformByState({left:y-A/2,top:E-A/2,width:x-y,height:O-E}),(N=this._helperSelection)==null||N.show()),this._targetSelection={startY:E,endY:O,startX:y,endX:x,startRow:_,endRow:S,startColumn:g,endColumn:v},this._control.selectionFilling$.next(this._targetSelection)}_fillEvent(e){const{offsetX:t,offsetY:n}=e,o=this._scene,r=o.getRelativeCoord(w.Vector2.FromArray([t,n])),{x:s,y:a}=r;this._startOffsetX=s,this._startOffsetY=a;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=this._control.model;this._isInMergeState=this._hasMergeInRange(c,d,u,h),this._relativeSelectionPositionRow=c,this._relativeSelectionPositionColumn=d,this._relativeSelectionRowLength=u-c,this._relativeSelectionColumnLength=h-d;const m=this._control.selectionStyle;let _=m==null?void 0:m.stroke,g=m==null?void 0:m.strokeWidth;const S=f.getNormalSelectionStyle(this._themeService);_==null&&(_=S.stroke),g==null&&(g=S.strokeWidth);const v=this._getScale();g/=v;const I=f.SELECTION_CONTROL_BORDER_BUFFER_WIDTH/v,b=new l.ColorKit(_).darken(2).toRgbString();this.isHelperSelection&&(this._helperSelection=new w.Rect(Hi,{stroke:b,strokeWidth:g+I/2}),o.addObject(this._helperSelection));const R=w.ScrollTimer.create(o);R.startScroll(s,a),this._scrollTimer=R,o.disableEvent(),this._controlHandler(T=>{this._fillControlColors.push(T.fill)}),this._moveObserver=o.onPointerMoveObserver.add(T=>{const{offsetX:E,offsetY:O}=T,{x:y,y:x}=o.getRelativeCoord(w.Vector2.FromArray([E,O]));this._fillMoving(y,x),o.setCursor(w.CURSOR_TYPE.CROSSHAIR),R.scrolling(y,x,()=>{this._fillMoving(y,x)})}),this._upObserver=o.onPointerUpObserver.add(T=>{var O,y;(O=this._helperSelection)==null||O.dispose();const E=this._scene;E.resetCursor(),this._clearObserverEvent(),E.enableEvent(),(y=this._scrollTimer)==null||y.dispose(),this._control.refreshSelectionFilled(this._targetSelection),this._isInMergeState=!1,this._controlHandler((x,A)=>{x.setProps({fill:this._fillControlColors[A]})}),this._fillControlColors=[]})}_hasMergeInRange(e,t,n,o){const r=this._skeleton.mergeData;if(!r)return!1;for(const s of r){const{startRow:a,startColumn:c,endRow:d,endColumn:u}=s,h={left:t,top:e,right:o,bottom:n},m={left:c,top:a,right:u,bottom:d};if(w.isRectIntersect(h,m))return!0}return!1}_swapPositions(e,t,n,o){const r=Math.min(e,n),s=Math.min(t,o),a=Math.max(e,n),c=Math.max(t,o);return{startRow:r,startColumn:s,endRow:a,endColumn:c}}_controlHandler(e){const{leftControl:t,rightControl:n,topControl:o,bottomControl:r,backgroundControlTop:s,backgroundControlMiddleLeft:a,backgroundControlMiddleRight:c,backgroundControlBottom:d,fillControl:u}=this._control,h=[t,n,o,r,s,a,c,d,u];for(let m=0,_=h.length;m<_;m++){const g=h[m];e(g,m)}}_FillRuler(e,t,n,o,r){let s=!1;if(e<t)if(this._isInMergeState&&e<t){const a=t-e,c=o+1,d=Math.ceil(a/c);let u=t-d*c;u<0&&(u=t-(d-1)*c),t=u}else t=e;else if(e>=t&&e<=n)s=!0,n=e;else if(this._isInMergeState&&e>n){const a=e-n,c=o+1,d=Math.ceil(a/c);let u=n+d*c;u>r&&(u=n+(d-1)*c),n=u}else n=e;return{rowOrColumn:e,startRowOrColumn:t,endRowOrColumn:n,isLighten:s}}_getScale(){const{scaleX:e,scaleY:t}=this._scene.getAncestorScale();return Math.max(e,t)}}var Dr=Object.defineProperty,Hr=Object.getOwnPropertyDescriptor,Nr=(i,e,t,n)=>{for(var o=n>1?void 0:n?Hr(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Dr(e,t,o),o},Li=(i,e)=>(t,n)=>e(t,n,i);P.SelectionRenderService=class{constructor(e,t){C(this,"hasSelection",!1);C(this,"_downObserver");C(this,"_moveObserver");C(this,"_upObserver");C(this,"_controlFillConfig$",new B.BehaviorSubject(null));C(this,"controlFillConfig$",this._controlFillConfig$.asObservable());C(this,"_selectionControls",[]);C(this,"_startSelectionRange",{startY:0,endY:0,startX:0,endX:0,startRow:-1,endRow:-1,startColumn:-1,endColumn:-1});C(this,"_startOffsetX",0);C(this,"_startOffsetY",0);C(this,"_scrollTimer");C(this,"_cancelDownObserver");C(this,"_cancelUpObserver");C(this,"_skeleton");C(this,"_scene");C(this,"_isHeaderHighlight",!0);C(this,"_isDetectMergedCell",!0);C(this,"_selectionStyle");C(this,"_isSelectionEnabled",!0);C(this,"_isShowPreviousEnable",0);C(this,"_isRemainLastEnable",!0);C(this,"_isSkipRemainLastEnable",!1);C(this,"_selectionMoveEnd$",new B.BehaviorSubject([]));C(this,"selectionMoveEnd$",this._selectionMoveEnd$.asObservable());C(this,"_selectionMoving$",new B.Subject);C(this,"selectionMoving$",this._selectionMoving$.asObservable());C(this,"_selectionMoveStart$",new B.Subject);C(this,"selectionMoveStart$",this._selectionMoveStart$.asObservable());C(this,"_activeViewport");this._themeService=e,this._shortcutService=t,this._selectionStyle=f.getNormalSelectionStyle(this._themeService)}enableHeaderHighlight(){this._isHeaderHighlight=!0}disableHeaderHighlight(){this._isHeaderHighlight=!1}enableDetectMergedCell(){this._isDetectMergedCell=!0}disableDetectMergedCell(){this._isDetectMergedCell=!1}setStyle(e){this._selectionStyle=e}resetStyle(){this.setStyle(f.getNormalSelectionStyle(this._themeService))}enableSelection(){this._isSelectionEnabled=!0}disableSelection(){this._isSelectionEnabled=!1}enableShowPrevious(){this._isShowPreviousEnable=!0}disableShowPrevious(){this._isShowPreviousEnable=!1}enableRemainLast(){this._isRemainLastEnable=!0}disableRemainLast(){this._isRemainLastEnable=!1}enableSkipRemainLast(){this._isSkipRemainLastEnable=!0}disableSkipRemainLast(){this._isSkipRemainLastEnable=!1}getViewPort(){return this._activeViewport}addControlToCurrentByRangeData(e){const t=this.getCurrentControls();if(!t)return;const{rangeWithCoord:n,primaryWithCoord:o}=e,r=this._skeleton;let s=e.style;s==null&&(s=f.getNormalSelectionStyle(this._themeService));const a=this._scene;if(a==null||r==null)return;const c=new jt(a,t.length,this._isHeaderHighlight,this._themeService);new Ni(c,r,a,this._themeService);const{rowHeaderWidth:d,columnHeaderHeight:u}=r;c.update(n,d,u,s,o),this._isHeaderHighlight?c.enableHeaderHighlight():c.disableHeaderHighlight(),t.push(c)}changeRuntime(e,t,n){this._skeleton=e,this._scene=t,this._activeViewport=n||t.getViewports()[0]}getSelectionDataWithStyle(){return this._selectionControls.map(t=>t.getValue())}getCurrentControls(){return this._selectionControls}_clearSelectionControls(){const e=this.getCurrentControls();if(e.length>0){for(const t of e)t.dispose();e.length=0}}getActiveSelections(){const e=this.getCurrentControls();if(e&&e.length>0)return e==null?void 0:e.map(n=>{const o=n.model,r=o.currentCell;let s=null;return r&&(s={actualRow:r.actualRow,actualColumn:r.actualColumn,isMerged:r.isMerged,isMergedMainCell:r.isMergedMainCell,startRow:r.mergeInfo.startRow,startColumn:r.mergeInfo.startColumn,endRow:r.mergeInfo.endRow,endColumn:r.mergeInfo.endColumn}),{range:{startRow:o.startRow,startColumn:o.startColumn,endRow:o.endRow,endColumn:o.endColumn},primary:s}})}getActiveRange(){const e=this.getCurrentControls(),t=e&&e[e.length-1].model;return t&&{startRow:t.startRow,startColumn:t.startColumn,endRow:t.endRow,endColumn:t.endColumn}}getActiveSelection(){const e=this.getCurrentControls();return e&&e[e.length-1]}endSelection(){this._endSelection()}reset(){this._clearSelectionControls(),this._moveObserver=null,this._upObserver=null,this._downObserver=null}resetAndEndSelection(){this.endSelection(),this.reset()}eventTrigger(e,t=0,n=l.RANGE_TYPE.NORMAL,o,r=w.ScrollTimerType.ALL){if(this._isSelectionEnabled===!1)return;const s=this._skeleton,{offsetX:a,offsetY:c}=e,d=this._scene;if(d==null||s==null)return;o!=null&&(this._activeViewport=o);const u=d.getRelativeCoord(w.Vector2.FromArray([a,c]));let{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const _=d.getScrollXYByRelativeCoords(u),{scaleX:g,scaleY:S}=d.getAncestorScale();n===l.RANGE_TYPE.ROW?h=0:n===l.RANGE_TYPE.COLUMN&&(m=0);const v=this._getSelectedRangeWithMerge(h,m,g,S,_);if(!v)return!1;const{rangeWithCoord:I,primaryWithCoord:b}=v,{startRow:R,startColumn:T,endColumn:E,endRow:O,startY:y,endY:x,startX:A,endX:H}=I,{rowHeaderWidth:D,columnHeaderHeight:N}=s,U={startColumn:T,startRow:R,endColumn:E,endRow:O,startY:y,endY:x,startX:A,endX:H,rangeType:n};this._startSelectionRange=U;let V=this.getActiveSelection();const $=this.getCurrentControls();if(!$)return!1;for(const K of $){if(e.button===2&&K.model.isInclude(U)){V=K;return}if(K.model.isEqual(U)){V=K;break}e.shiftKey||K.clearHighlight()}if($.length>0&&!e.ctrlKey&&!e.shiftKey&&!this._isShowPreviousEnable&&!this._isRemainLastEnable){for(const K of $)K.dispose();$.length=0}const X=V&&V.model.currentCell;if(V&&e.shiftKey&&X){const{actualRow:K,actualColumn:q,mergeInfo:W}=X,te=Math.min(K,U.startRow,W.startRow),J=Math.max(K,U.endRow,W.endRow),Pe=Math.min(q,U.startColumn,W.startColumn),ce=Math.max(q,U.endColumn,W.endColumn),ve=s.getMergeBounding(te,Pe,J,ce),_t=s.getNoMergeCellPositionByIndex(ve.startRow,ve.startColumn,g,S),Qe=s.getNoMergeCellPositionByIndex(ve.endRow,ve.endColumn,g,S),De={startColumn:ve.startColumn,startRow:ve.startRow,endColumn:ve.endColumn,endRow:ve.endRow,startY:_t.startY,endY:Qe.endY,startX:_t.startX,endX:Qe.endX,rangeType:n},he=s.getCellByIndex(K,q,g,S);this._startSelectionRange={startColumn:he.mergeInfo.startColumn,startRow:he.mergeInfo.startRow,endColumn:he.mergeInfo.endColumn,endRow:he.mergeInfo.endRow,startY:he.mergeInfo.startY||0,endY:he.mergeInfo.endY||0,startX:he.mergeInfo.startX||0,endX:he.mergeInfo.endX||0,rangeType:n},V.update(De,D,N,this._selectionStyle,X)}else this._isRemainLastEnable&&V&&!e.ctrlKey&&!e.shiftKey&&!this._isSkipRemainLastEnable?V.update(U,D,N,this._selectionStyle,b):(V=new jt(d,$.length+t,this._isHeaderHighlight,this._themeService),new Ni(V,s,d,this._themeService),V.update(U,D,N,this._selectionStyle,b),$.push(V));this._selectionMoveStart$.next(this.getSelectionDataWithStyle()),this.hasSelection=!0,this._endSelection(),d.disableEvent();const Q=w.ScrollTimer.create(this._scene,r);Q.startScroll(h,m,o),this._scrollTimer=Q,this._addCancelObserver(),(n===l.RANGE_TYPE.ROW||n===l.RANGE_TYPE.COLUMN)&&this._moving(h,m,V,n),this._moveObserver=d.onPointerMoveObserver.add(K=>{const{offsetX:q,offsetY:W}=K,{x:te,y:J}=d.getRelativeCoord(w.Vector2.FromArray([q,W]));this._moving(te,J,V,n),Q.scrolling(te,J,()=>{this._moving(te,J,V,n)})}),this._upObserver=d.onPointerUpObserver.add(K=>{this._endSelection(),this._selectionMoveEnd$.next(this.getSelectionDataWithStyle()),this._shortcutService.setDisable(!1)}),this._shortcutService.setDisable(!0)}convertSelectionRangeToData(e){const{range:t,primary:n,style:o}=e;let r=this.convertRangeDataToSelection(t);return r==null&&(r={startRow:-1,startColumn:-1,endRow:-1,endColumn:-1,startY:0,endY:0,startX:0,endX:0,rangeType:l.RANGE_TYPE.NORMAL}),{rangeWithCoord:r,primaryWithCoord:this.convertCellRangeToInfo(n),style:o}}convertRangeDataToSelection(e){const{startRow:t,startColumn:n,endRow:o,endColumn:r,rangeType:s}=e,a=this._scene,c=this._skeleton;if(a==null||c==null)return;const{scaleX:d,scaleY:u}=a.getAncestorScale(),h=c.getNoMergeCellPositionByIndex(t,n,d,u),m=c.getNoMergeCellPositionByIndex(o,r,d,u);return{startRow:t,startColumn:n,endRow:o,endColumn:r,rangeType:s,startY:(h==null?void 0:h.startY)||0,endY:(m==null?void 0:m.endY)||0,startX:(h==null?void 0:h.startX)||0,endX:(m==null?void 0:m.endX)||0}}convertCellRangeToInfo(e){if(e==null)return;const t=this._scene,n=this._skeleton;if(t==null||n==null)return;const{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:a,startRow:c,startColumn:d,endRow:u,endColumn:h}=e,{scaleX:m,scaleY:_}=t.getAncestorScale(),g=n.getNoMergeCellPositionByIndex(o,r,m,_),S=n.getNoMergeCellPositionByIndex(c,d,m,_),v=n.getNoMergeCellPositionByIndex(u,h,m,_);return{actualRow:o,actualColumn:r,isMerged:s,isMergedMainCell:a,startX:g.startX,startY:g.startY,endX:g.endX,endY:g.endY,mergeInfo:{startRow:c,startColumn:d,endRow:u,endColumn:h,startY:(S==null?void 0:S.startY)||0,endY:(v==null?void 0:v.endY)||0,startX:(S==null?void 0:S.startX)||0,endX:(v==null?void 0:v.endX)||0}}}_moving(e,t,n,o){const r=this._skeleton,s=this._scene;if(s==null||r==null)return!1;const{startRow:a,startColumn:c,endRow:d,endColumn:u}=this._startSelectionRange,h=s.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY]),this._activeViewport),{scaleX:m,scaleY:_}=s.getAncestorScale(),{rowHeaderWidth:g,columnHeaderHeight:S}=r;o===l.RANGE_TYPE.ROW?e=1/0:o===l.RANGE_TYPE.COLUMN&&(t=1/0);const v=this._getSelectedRangeWithMerge(e,t,m,_,h);if(!v)return!1;const{rangeWithCoord:I,primaryWithCoord:b}=v,{startRow:R,startColumn:T,endColumn:E,endRow:O}=I,y=Math.min(R,a),x=Math.min(T,c),A=Math.max(O,d),H=Math.max(E,u);let D={startRow:y,startColumn:x,endRow:A,endColumn:H};if(this._isDetectMergedCell&&(D=r.getSelectionBounding(y,x,A,H)),!D)return!1;const{startRow:N,startColumn:U,endRow:V,endColumn:$}=D,X=r.getNoMergeCellPositionByIndex(N,U,m,_),Q=r.getNoMergeCellPositionByIndex(V,$,m,_),K={startColumn:U,startRow:N,endColumn:$,endRow:V,startY:(X==null?void 0:X.startY)||0,endY:(Q==null?void 0:Q.endY)||0,startX:(X==null?void 0:X.startX)||0,endX:(Q==null?void 0:Q.endX)||0},{startRow:q,endRow:W,startColumn:te,endColumn:J}=(n==null?void 0:n.model)||{startRow:-1,endRow:-1,startColumn:-1,endColumn:-1};(te!==U||q!==N||J!==$||W!==V)&&n!=null&&(n.update(K,g,S),this._selectionMoving$.next(this.getSelectionDataWithStyle()))}_endSelection(){var n,o;const e=this._scene;if(e==null)return;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),e.enableEvent(),(n=this._scrollTimer)==null||n.dispose();const t=(o=e.getEngine())==null?void 0:o.activeScene;t==null||t.onPointerDownObserver.remove(this._cancelDownObserver),t==null||t.onPointerUpObserver.remove(this._cancelUpObserver)}_addCancelObserver(){var n;const e=this._scene;if(e==null)return;const t=(n=e.getEngine())==null?void 0:n.activeScene;t==null||t===e||(t.onPointerDownObserver.remove(this._cancelDownObserver),t.onPointerUpObserver.remove(this._cancelUpObserver),this._cancelDownObserver=t.onPointerDownObserver.add(o=>{this._endSelection()}),this._cancelUpObserver=t.onPointerUpObserver.add(o=>{this._endSelection()}))}_getSelectedRangeWithMerge(e,t,n,o,r){var I;if(this._isDetectMergedCell){const b=(I=this._skeleton)==null?void 0:I.calculateCellIndexByPosition(e,t,n,o,r),R=l.makeCellToSelection(b);return R==null?void 0:{primaryWithCoord:b,rangeWithCoord:R}}const s=this._skeleton;if(s==null)return;const a=s.getCellPositionByOffset(e,t,n,o,r),{row:c,column:d}=a,u=s.getNoMergeCellPositionByIndex(c,d,n,o),{startX:h,startY:m,endX:_,endY:g}=u,S={startY:m,endY:g,startX:h,endX:_,startRow:c,endRow:c,startColumn:d,endColumn:d};return{primaryWithCoord:{actualRow:c,actualColumn:d,isMerged:!1,isMergedMainCell:!1,startY:m,endY:g,startX:h,endX:_,mergeInfo:S},rangeWithCoord:S}}},P.SelectionRenderService=Nr([Li(0,L.Inject(l.ThemeService)),Li(1,M.IShortcutService)],P.SelectionRenderService);const se=L.createIdentifier("deprecated.univer.sheet.selection-render-service");var Lr=Object.defineProperty,Ur=Object.getOwnPropertyDescriptor,kr=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ur(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Lr(e,t,o),o},Ui=(i,e)=>(t,n)=>e(t,n,i);P.SheetSkeletonManagerService=class{constructor(e,t){C(this,"_currentSkeleton",{unitId:"",sheetId:""});C(this,"_sheetSkeletonParam",[]);C(this,"_currentSkeleton$",new B.BehaviorSubject(null));C(this,"currentSkeleton$",this._currentSkeleton$.asObservable());C(this,"_currentSkeletonBefore$",new B.BehaviorSubject(null));C(this,"currentSkeletonBefore$",this._currentSkeletonBefore$.asObservable());this._currentUniverService=e,this._localeService=t}dispose(){this._currentSkeletonBefore$.complete(),this._currentSkeleton$.complete(),this._sheetSkeletonParam=[]}getCurrent(){return this._getCurrentBySearch(this._currentSkeleton)}setCurrent(e){const t=this._getCurrentBySearch(e);if(t!=null)this._reCalculate(t);else{const{unitId:o,sheetId:r}=e,s=this._currentUniverService.getUniverSheetInstance(e.unitId),a=s==null?void 0:s.getSheetBySheetId(e.sheetId);if(a==null||s==null)return;const c=this._buildSkeleton(a,s);this._sheetSkeletonParam.push({unitId:o,sheetId:r,skeleton:c,dirty:!1})}this._currentSkeleton=e;const n=this.getCurrent();return this._currentSkeletonBefore$.next(n),this._currentSkeleton$.next(n),this.getCurrent()}reCalculate(){const e=this.getCurrent();e!=null&&this._reCalculate(e)}_reCalculate(e){e.dirty&&(e.skeleton.makeDirty(!0),e.dirty=!1),e.skeleton.calculate()}makeDirtyCurrent(e=!0){this.makeDirty(this._currentSkeleton,e)}makeDirty(e,t=!0){const n=this._getCurrentBySearch(e);n!=null&&(n.dirty=t)}_getCurrentBySearch(e){const t=this._sheetSkeletonParam.find(n=>n.unitId===e.unitId&&n.sheetId===e.sheetId);return t!=null&&(t.commandId=e.commandId),t}_buildSkeleton(e,t){const n=e.getConfig();return w.SpreadsheetSkeleton.create(e,n,e.getCellMatrix(),t.getStyles(),this._localeService)}},P.SheetSkeletonManagerService=kr([Ui(0,l.IUniverInstanceService),Ui(1,L.Inject(l.LocaleService))],P.SheetSkeletonManagerService);var Br=Object.defineProperty,Vr=Object.getOwnPropertyDescriptor,Fr=(i,e,t,n)=>{for(var o=n>1?void 0:n?Vr(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Br(e,t,o),o},Fe=(i,e)=>(t,n)=>e(t,n,i);const Wr=1e4,zt=L.createIdentifier("univer.mark-selection-service");P.MarkSelectionService=class extends l.Disposable{constructor(t,n,o,r,s,a,c){super();C(this,"_shapeMap",new Map);this._currentService=t,this._renderManagerService=n,this._selectionRenderService=o,this._commandService=r,this._sheetSkeletonManagerService=s,this._themeService=a,this._selectionManagerService=c,this._addRemoveListener(),this._addRefreshListener()}addShape(t,n=Wr){const o=this._currentService.getCurrentUniverSheetInstance(),r=o.getActiveSheet().getSheetId(),s=l.Tools.generateRandomId();return this._shapeMap.set(s,{selection:t,subUnitId:r,unitId:o.getUnitId(),zIndex:n,control:null}),this.refreshShapes(),s}refreshShapes(){const t=this._currentService.getCurrentUniverSheetInstance().getUnitId(),n=this._currentService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();setTimeout(()=>{this._shapeMap.forEach(o=>{var b;const{unitId:r,subUnitId:s,selection:a,control:c,zIndex:d}=o;if(r!==t||s!==n){c&&c.dispose();return}const{style:u}=a,{scene:h}=this._renderManagerService.getRenderById(r)||{},{rangeWithCoord:m,primaryWithCoord:_}=this._selectionRenderService.convertSelectionRangeToData(a),g=(b=this._sheetSkeletonManagerService.getCurrent())==null?void 0:b.skeleton;if(!h||!g)return;const{rowHeaderWidth:S,columnHeaderHeight:v}=g,I=new jt(h,d,!1,this._themeService);I.update(m,S,v,u,_),o.control=I})},0)}removeShape(t){const n=this._shapeMap.get(t);if(!n)return;const{control:o}=n;o&&o.dispose(),this._shapeMap.delete(t)}removeAllShapes(){for(const t of this._shapeMap.values()){const{control:n}=t;n&&n.dispose()}this._shapeMap.clear()}_addRemoveListener(){const t=[Ie.id,f.SetRangeValuesMutation.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this.removeAllShapes()}))}_addRefreshListener(){const t=[f.SetWorksheetActiveOperation.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{t.includes(n.id)&&this.refreshShapes()}))}},P.MarkSelectionService=Fr([Fe(0,l.IUniverInstanceService),Fe(1,w.IRenderManagerService),Fe(2,se),Fe(3,l.ICommandService),Fe(4,L.Inject(P.SheetSkeletonManagerService)),Fe(5,L.Inject(l.ThemeService)),Fe(6,L.Inject(f.SelectionManagerService))],P.MarkSelectionService);const jr=10,zr=6;function Xr(){return l.Tools.generateRandomId(zr)}function Yr(i){const e=i.match(/data-copy-id="([^\s]+)"/);return e&&e[1]?e[1]:null}class $r{constructor(){C(this,"_cache",new l.LRUMap(jr))}set(e,t){this._cache.set(e,t)}get(e){return this._cache.get(e)}del(e){this._cache.delete(e)}clear(){this._cache.clear()}}const Un=new $r;function Zr(i){const e=new DOMParser,t=`<x-univer id="univer-root">${i}</x-univer>`;return e.parseFromString(t,"text/html").querySelector("#univer-root")}function Gr(i){const e=i.style,t={};for(let n=0;n<e.length;n++){const o=e[n],r=e.getPropertyValue(o);switch(o){case"margin-top":{const s=parseInt(r);t.spaceAbove=/pt/.test(r)?kn(s):s;break}case"margin-bottom":{const s=parseInt(r);t.spaceBelow=/pt/.test(r)?kn(s):s;break}}}return Object.getOwnPropertyNames(t).length?t:null}function kn(i){return i/.75}function Bn(i){const e=i.style,t={},n=i.tagName.toLowerCase();switch(n){case"b":case"em":case"strong":{t.bl=l.BooleanNumber.TRUE;break}case"s":{t.st={s:l.BooleanNumber.TRUE};break}case"u":{t.ul={s:l.BooleanNumber.TRUE};break}case"i":{t.it=l.BooleanNumber.TRUE;break}case"sub":case"sup":{t.va=n==="sup"?l.BaselineOffset.SUPERSCRIPT:l.BaselineOffset.SUBSCRIPT;break}}for(let o=0;o<e.length;o++){const r=e[o],s=e.getPropertyValue(r);switch(r){case"font-family":{t.ff=s;break}case"font-size":{const a=parseInt(s);Number.isNaN(a)||(t.fs=/pt$/.test(s)?kn(a):a);break}case"font-style":{s==="italic"&&(t.it=l.BooleanNumber.TRUE);break}case"font-weight":{Number(s)>400&&(t.bl=l.BooleanNumber.TRUE);break}case"text-decoration":{/underline/.test(s)?t.ul={s:l.BooleanNumber.TRUE}:/overline/.test(s)?t.ol={s:l.BooleanNumber.TRUE}:/line-through/.test(s)&&(t.st={s:l.BooleanNumber.TRUE});break}case"color":{const a=new l.ColorKit(s);a.isValid&&(t.cl={rgb:a.toRgbString()});break}case"background-color":{const a=new l.ColorKit(s);a.isValid&&(t.bg={rgb:a.toRgbString()});break}}}return t}function ki(i,e){const t=i.tagName.toLowerCase();return typeof e=="string"?t===e:Array.isArray(e)?e.some(n=>n===t):e(i)}const Dn=class Dn{constructor(e){C(this,"styleCache",new Map);C(this,"styleRules",[]);C(this,"afterProcessRules",[]);C(this,"getCurrentSkeleton");this.getCurrentSkeleton=e.getCurrentSkeleton}static use(e){if(this.pluginList.includes(e))throw new Error(`Univer paste plugin ${e.name} already added`);this.pluginList.push(e)}convert(e){const t=Dn.pluginList.find(m=>m.checkPasteType(e));t&&(this.styleRules=[...t.stylesRules],this.afterProcessRules=[...t.afterProcessRules]);const n=new l.ObjectMatrix,o=Zr(e),r={dataStream:"",textRuns:[]},s=[],a=e.match(/<table.*?>([\s\S]*?)<\/table>/gi),c=[];this.process(null,o==null?void 0:o.childNodes,r,c);const{paragraphs:d,dataStream:u,textRuns:h}=r;if(d){const m=d.map(_=>_.startIndex+1);m.unshift(0);for(let _=0;_<m.length;_++){let g;_===m.length-1?g=`${u.substring(m[_])}\r
|
|
2
|
+
`:g=`${u.substring(m[_],m[_+1]-1)}\r
|
|
3
|
+
`;const S=[];h==null||h.forEach(I=>{I.st>=m[_]&&I.ed<=m[_+1]&&S.push({st:I.st-m[_],ed:I.ed-m[_],ts:I.ts})});const v=this._generateDocumentDataModelSnapshot({body:{dataStream:g,textRuns:S}});n.setValue(n.getLength(),0,{v:g,p:v}),s.push({}),a&&c.forEach(I=>{const b=n.getLength();if(I.index===_){const R=a.shift(),{cellMatrix:T,colProperties:E,rowProperties:O}=this._parseTable(R);T&&T.forValue((y,x,A)=>{n.setValue(b+y,x,A)}),s.push(...O)}})}}else{if(u){const m=this._generateDocumentDataModelSnapshot({body:r});n.setValue(0,0,{v:u,p:m}),s.push({})}a&&a.forEach(m=>{const _=n.getLength(),{cellMatrix:g}=this._parseTable(m);g&&g.forValue((S,v,I)=>{n.setValue(_+S,v,I)}),s.push(...s)})}return{rowProperties:[],colProperties:[],cellMatrix:n}}_parseTable(e){const t=new l.ObjectMatrix;Qr(e);const{rowProperties:n,rowCount:o,cellMatrix:r}=Kr(e);return r&&r.forValue((s,a,c)=>{var u;const d=M.handleStringToStyle(void 0,(u=c.properties)==null?void 0:u.style);t.setValue(s,a,{v:c.content,s:d,rowSpan:c.rowSpan,colSpan:c.colSpan})}),{rowProperties:[],colProperties:[],cellMatrix:t}}_generateDocumentDataModelSnapshot(e){var a;const t=this.getCurrentSkeleton();if(t==null)return null;const{skeleton:n}=t,o=(a=n.getBlankCellDocumentModel())==null?void 0:a.documentModel,s={...o==null?void 0:o.getSnapshot(),...e};return o==null||o.reset(s),o==null?void 0:o.getSnapshot()}process(e,t,n,o){var r,s;for(const a of t)if(a.nodeName.toLowerCase()==="table")o.push({index:((r=n==null?void 0:n.paragraphs)==null?void 0:r.length)||0});else if(a.nodeType===Node.TEXT_NODE){const c=(s=a.nodeValue)==null?void 0:s.replace(/[\r\n]/g,"");let d;e&&this.styleCache.has(e)&&(d=this.styleCache.get(e));const u={dataStream:"",textRuns:[]};n.dataStream+=c,u.dataStream+=c,d&&Object.getOwnPropertyNames(d).length&&(n.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}),u.textRuns.push({st:n.dataStream.length-c.length,ed:n.dataStream.length,ts:d}))}else if(a.nodeType===Node.ELEMENT_NODE){const c=e?this.styleCache.get(e):{},d=this.styleRules.find(({filter:_})=>ki(a,_)),u=d?d.getStyle(a):Bn(a);this.styleCache.set(a,{...c,...u});const{childNodes:h}=a;this.process(a,h,n,o);const m=this.afterProcessRules.find(({filter:_})=>ki(a,_));m&&m.handler(n,a)}}};C(Dn,"pluginList",[]);let ft=Dn;function Kr(i){const e=/<tr([\s\S]*?)>([\s\S]*?)<\/tr>/gi,t=i.matchAll(e);if(!t)return{rowProperties:[],rowCount:0,colCount:0,cellMatrix:null};const n=Array.from(t),o=n.map(a=>Vn(a[1])),{colCount:r,cellMatrix:s}=Jr(n.map(a=>a[2]));return{rowProperties:o,rowCount:o.length,colCount:r,cellMatrix:s}}function Jr(i){const e=new l.ObjectMatrix,t=new Map,n=/<td([\s\S]*?)>([\s\S]*?)<\/td>/gi;let o=0,r=0,s=0;return i.forEach((a,c)=>{const d=c===0,u=a.matchAll(n);r=0,Array.from(u).forEach(h=>{const m=Vn(h[1]),_=h[2].replace(/ /g," "),g=m.rowspan?+m.rowspan:1,S=m.colspan?+m.colspan:1;if(!d){for(let I=r;I<o;I++)if(!(t.get(I)>=s)){r=I;break}}const v={content:_,properties:m};S>1&&(v.colSpan=+S),g>1&&(v.rowSpan=+g),d&&(o+=S);for(let I=r;I<r+S;I++)t.set(I,s+g-1);e.setValue(s,r,v),r+=S}),s+=1}),{colCount:o,cellMatrix:e}}function Vn(i){if(!i)return{};const e=/([\w-]+)="([^"]*)"/gi,t=i.matchAll(e),n={};return Array.from(t).forEach(o=>{const[r,s,a]=o;n[s]=a}),n}function Qr(i){const e=/<colgroup([\s\S]*?)>(.*?)<\/colgroup>/,t=i.match(e);if(!t||!t[2])return null;const n=/<col([\s\S]*?)>/g,o=t[2].matchAll(n);return o?Array.from(o).map(r=>Vn(r[1])):null}const qr={name:"univer-doc-paste-plugin-lark",checkPasteType(i){return/lark-record-clipboard/i.test(i)},stylesRules:[{filter:["s"],getStyle(i){const e=Bn(i);return{st:{s:l.BooleanNumber.TRUE},...e}}}],afterProcessRules:[{filter(i){return i.tagName==="DIV"&&/ace-line/i.test(i.className)},handler(i){i.paragraphs==null&&(i.paragraphs=[]),i.paragraphs.push({startIndex:i.dataStream.length}),i.dataStream+="\r"}}]},es={name:"univer-doc-paste-plugin-word",checkPasteType(i){return/word|mso/i.test(i)},stylesRules:[{filter:["b"],getStyle(i){const e=Bn(i);return{bl:l.BooleanNumber.TRUE,...e}}}],afterProcessRules:[{filter(i){return i.tagName==="P"&&/mso/i.test(i.className)},handler(i,e){i.paragraphs==null&&(i.paragraphs=[]);const t={startIndex:i.dataStream.length},n=Gr(e);n&&(t.paragraphStyle=n),i.paragraphs.push(t),i.dataStream+="\r"}}]};var We=(i=>(i.COPY="COPY",i.CUT="CUT",i))(We||{});function ts(i,e,t,n){const o=t.map(c=>{var d;return(d=c.onCopyRow)==null?void 0:d.call(c,i)}).filter(c=>!!c),r=Fn(o),s=Wn(r),a=e.map(c=>ns(i,c,t,n)).filter(c=>!!c).join("");return`<tr${s}>${a}</tr>`}function ns(i,e,t,n){const o=n.getValue(i,e),r=t.map(d=>{var u;return(u=d.onCopyCellStyle)==null?void 0:u.call(d,i,e,o==null?void 0:o.rowSpan,o==null?void 0:o.colSpan)}).filter(d=>!!d),s=Fn(r),a=Wn(s),c=t.reduce((d,u)=>{var h;return d||((h=u.onCopyCellContent)==null?void 0:h.call(u,i,e))||""},"");return`<td${a}>${c}</td>`}function is(i,e){return`<colgroup>${i.map(n=>{const o=e.map(a=>{var c;return(c=a.onCopyColumn)==null?void 0:c.call(a,n)}).filter(a=>!!a),r=Fn(o);return`<col ${Wn(r)}>`}).join("")}</colgroup>`}function Fn(i){return i.reduce((e,t)=>(Object.keys(t).forEach(o=>{e[o]?e[o]+=`;${t[o]}`:e[o]=t[o]}),e),{})}function Wn(i){return Object.keys(i).reduce((e,t)=>(e+=` ${t}="${i[t]}"`,e),"")}function os(i,e){const t=[];for(let n=i;n<=e;n++)t.push(n);return t}class rs{convert(e,t,n){const{startColumn:o,endColumn:r}=t,s=is(os(o,r),n),a=[];return e.forRow((d,u)=>{a.push(ts(d,u,n,e))}),`<google-sheets-html-origin><table xmlns="http://www.w3.org/1999/xhtml" cellspacing="0" cellpadding="0" dir="ltr" border="1" style="table-layout:fixed;font-size:10pt;font-family:Arial;width:0px;border-collapse:collapse;border:none">${s}
|
|
4
|
+
<tbody>${a.join("")}</tbody></table>`}}var ss=Object.defineProperty,as=Object.getOwnPropertyDescriptor,ls=(i,e,t,n)=>{for(var o=n>1?void 0:n?as(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ss(e,t,o),o},He=(i,e)=>(t,n)=>e(t,n,i);const de={DEFAULT_COPY:"default-copy",DEFAULT_PASTE:"default-paste",SPECIAL_PASTE_VALUE:"special-paste-value",SPECIAL_PASTE_FORMAT:"special-paste-format",SPECIAL_PASTE_COL_WIDTH:"special-paste-col-width",SPECIAL_PASTE_BESIDES_BORDER:"special-paste-besides-border"};ft.use(es),ft.use(qr);const qe=L.createIdentifier("sheet.clipboard-service");P.SheetClipboardService=class extends l.Disposable{constructor(t,n,o,r,s,a,c,d){super();C(this,"_clipboardHooks",[]);C(this,"_clipboardHooks$",new B.BehaviorSubject([]));C(this,"clipboardHooks$",this._clipboardHooks$.asObservable());C(this,"_htmlToUSM");C(this,"_usmToHtml");C(this,"_copyMarkId",null);C(this,"_pasteType",de.DEFAULT_PASTE);this._logService=t,this._currentUniverService=n,this._selectionManagerService=o,this._clipboardInterfaceService=r,this._undoRedoService=s,this._commandService=a,this._markSelectionService=c,this._sheetSkeletonManagerService=d,this._htmlToUSM=new ft({getCurrentSkeleton:()=>this._sheetSkeletonManagerService.getCurrent()}),this._usmToHtml=new rs}async copy(t=We.COPY){const n=this._selectionManagerService.getLast();if(!n)return!1;const o=this._clipboardHooks;o.reduce((I,b)=>{var T;const R=(T=b.getFilteredOutRows)==null?void 0:T.call(b);return R==null||R.forEach(E=>I.add(E)),I},new Set);const{startColumn:r,startRow:s,endColumn:a,endRow:c}=n.range,d=this._currentUniverService.getCurrentUniverSheetInstance(),u=d.getActiveSheet(),h=u.getMatrixWithMergedCells(s,r,c,a),m=new l.ObjectMatrix;for(let I=s;I<=c;I++)for(let b=r;b<=a;b++){const R=h.getValue(I,b);R?m.setValue(I-s,b-r,{...Bi(),...l.Tools.deepClone(R)}):m.setValue(I-s,b-r,Bi())}o.forEach(I=>{var b;return(b=I.onBeforeCopy)==null?void 0:b.call(I,d.getUnitId(),u.getSheetId(),n.range)});let _=this._usmToHtml.convert(h,n.range,o);const g=cs(m),S=Xr();_=_.replace(/(<[a-z]+)/,(I,b)=>`${b} data-copy-id="${S}"`),Un.set(S,{unitId:d.getUnitId(),subUnitId:u.getSheetId(),range:n.range,matrix:m,copyType:t}),await this._clipboardInterfaceService.write(g,_),this._markSelectionService.removeAllShapes();const v=this._selectionManagerService.createCopyPasteSelection();return this._copyMarkId=this._markSelectionService.addShape({...n,style:v}),o.forEach(I=>{var b;return(b=I.onAfterCopy)==null?void 0:b.call(I)}),!0}async cut(){return this.copy(We.CUT)}async paste(t,n=de.DEFAULT_PASTE){const o=t.types,r=o.indexOf(M.PLAIN_TEXT_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(M.PLAIN_TEXT_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"",s=o.indexOf(M.HTML_CLIPBOARD_MIME_TYPE)!==-1?await t.getType(M.HTML_CLIPBOARD_MIME_TYPE).then(a=>a&&a.text()):"";return s?this._pasteHTML(s,n):r?this._pastePlainText(r):(this._logService.error("[SheetClipboardService]","No valid data on clipboard"),!1)}addClipboardHook(t){if(this._clipboardHooks.findIndex(o=>o.hookName===t.hookName)!==-1)return this._logService.error("[SheetClipboardService]","hook already exists",t.hookName),{dispose:()=>{}};const n=this._clipboardHooks.findIndex(o=>{const r=o.priority||0;return(t.priority||0)<r});return this._clipboardHooks.splice(n!==-1?n:this._clipboardHooks.length,0,t),this._notifyClipboardHook(),l.toDisposable(()=>{const o=this._clipboardHooks.indexOf(t);o>-1&&(this._clipboardHooks.splice(o,1),this._notifyClipboardHook())})}getClipboardHooks(){return this._clipboardHooks}_notifyClipboardHook(){this._clipboardHooks$.next(this._clipboardHooks)}async _pastePlainText(t){const n=this._getPastingTarget();if(!n.selection)return!1;const o=n.selection.range,r={[o.startRow]:{[o.endColumn]:{v:t}}},s={unitId:n.unitId,subUnitId:n.subUnitId,cellValue:r};return this._commandService.syncExecuteCommand(f.SetRangeValuesMutation.id,s)}async _pasteHTML(t,n){const o=Yr(t);return o?this._pasteInternal(o,n):this._pasteExternal(t,n)}async _pasteExternal(t,n){const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:a}=o;if(!r)return!1;const{rowProperties:c,colProperties:d,cellMatrix:u}=this._htmlToUSM.convert(t),{startColumn:h,endColumn:m,startRow:_,endRow:g}=u.getDataRange(),S=g-_+1,v=m-h+1;if(!u)return!1;const I=this._transformPastedData(S,v,u,r.range);return I?this._pasteUSM({rowProperties:c,colProperties:d,cellMatrix:u},{unitId:s,subUnitId:a,pastedRange:I},n):!1}async _pasteInternal(t,n){var b;const o=this._getPastingTarget(),{selection:r,unitId:s,subUnitId:a}=o,c=l.Tools.deepClone(Un.get(t)),{range:d,matrix:u}=c||{};if(!r||!u||!c||!d||!r||!u||!c)return!1;const h=(b=this._currentUniverService.getUniverSheetInstance(s))==null?void 0:b.getStyles();u.forValue((R,T,E)=>{if(typeof E.s=="string"){const O=l.Tools.deepClone(E);O.s=h==null?void 0:h.getStyleByCell(E),u.setValue(R,T,O)}});const{startColumn:m,endColumn:_,startRow:g,endRow:S}=d,v=this._transformPastedData(S-g+1,_-m+1,u,r.range);if(!v)return!1;const I=this._pasteUSM({cellMatrix:u},{unitId:s,subUnitId:a,pastedRange:v},n,{range:d,unitId:c.unitId,subUnitId:c.subUnitId,copyType:c.copyType,copyId:t});return c.copyType===We.CUT&&(Un.del(t),this._copyMarkId&&this._markSelectionService.removeShape(this._copyMarkId),this._copyMarkId=null),I}_pasteUSM(t,n,o,r){const{rowProperties:s,colProperties:a,cellMatrix:c}=t,{unitId:d,subUnitId:u,pastedRange:h}=n,{startColumn:m,endColumn:_}=h,g=_-m+1,S=this._clipboardHooks,v=[];if(S.some(x=>{var A;return v.push(x)&&((A=x.onBeforePaste)==null?void 0:A.call(x,d,u,h))===!1}))return v.forEach(x=>{var A;return(A=x.onAfterPaste)==null?void 0:A.call(x,!1)}),!1;if(!c)return!1;const b=r?{copyRange:r.range,copyType:r.copyType,unitId:r.unitId,subUnitId:r.subUnitId}:{copyType:We.COPY},R=[],T=[];S.filter(x=>x.specialPasteInfo&&o===x.hookName||!x.specialPasteInfo&&o===de.DEFAULT_PASTE).forEach(x=>{var D,N,U;if(s){const V=(D=x.onPasteRows)==null?void 0:D.call(x,h,s,o);V&&(R.push(...V.redos),T.push(...V.undos))}const A=(N=x.onPasteColumns)==null?void 0:N.call(x,h,a||new Array(g).map(()=>({})),o);A&&(R.push(...A.redos),T.push(...A.undos));const H=(U=x.onPasteCells)==null?void 0:U.call(x,h,c,o,b);H&&(R.push(...H.redos),T.push(...H.undos))});const O=this._getSetSelectionOperation(d,u,h,c);O&&R.push(O),this._logService.log("[SheetClipboardService]","pasting mutations",{undoMutationsInfo:T,redoMutationsInfo:R});const y=R.every(x=>this._commandService.executeCommand(x.id,x.params));return y&&this._undoRedoService.pushUndoRedo({unitID:d,undoMutations:T,redoMutations:R}),y}_getSetSelectionOperation(t,n,o,r){var S;const s=(S=this._currentUniverService.getUniverSheetInstance(t))==null?void 0:S.getSheetBySheetId(n);if(!s)return null;const{startRow:a,startColumn:c}=o,d={startRow:a,endRow:a,startColumn:c,endColumn:c},u=f.getPrimaryForRange(d,s),h=r.getValue(0,0),m=(h==null?void 0:h.rowSpan)||1,_=(h==null?void 0:h.colSpan)||1;if(m>1||_>1){const v={startRow:a,endRow:a+m-1,startColumn:c,endColumn:c+_-1};u.startRow=v.startRow,u.endRow=v.endRow,u.startColumn=v.startColumn,u.endColumn=v.endColumn,u.isMerged=!0,u.isMergedMainCell=!0}const g={unitId:t,subUnitId:n,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:o,primary:u,style:null}]};return{id:f.SetSelectionsOperation.id,params:g}}_getPastingTarget(){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=this._selectionManagerService.getLast();return{unitId:t.getUnitId(),subUnitId:n.getSheetId(),selection:o}}_transformPastedData(t,n,o,r){const{startRow:s,startColumn:a,endRow:c,endColumn:d}=r,u=c-s+1,h=d-a+1,S=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData().filter(E=>l.Rectangle.intersects({startRow:s,startColumn:a,endRow:c,endColumn:d},E)),v=S[0];let I=0,b=0,R=0,T=0;if(v&&(I=v.startRow,b=v.startColumn,R=v.endRow,T=v.endColumn),u%t===0&&h%n===0)if(S.length>0&&(u!==t||h!==n))if(I===s&&b===a&&R===c&&T===d)if(_s(o))for(let O=0;O<u;O++)for(let y=0;y<h;y++){const x=o.getValue(O%t,y%n);x&&o.setValue(O,y,x)}else o.forValue((O,y,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan});else for(let E=0;E<u;E++)for(let O=0;O<h;O++){const y=o.getValue(E%t,O%n);y&&o.setValue(E,O,y)}else for(let E=0;E<u;E++)for(let O=0;O<h;O++){const y=o.getValue(E%t,O%n);y&&o.setValue(E,O,y)}else if(S.length>0)if(this._topLeftCellsMatch(t,n,r))r.endRow=s+t-1,r.endColumn=a+n-1;else{if(c>v.endRow||d>v.endColumn)return alert("We can't do that to a merged cell "),null;o.forValue((O,y,x)=>{x.s=null,delete x.colSpan,delete x.rowSpan})}else r.endRow=s+t-1,r.endColumn=a+n-1;return r}_topLeftCellsMatch(t,n,o){const s=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startRow:a,startColumn:c,endRow:d,endColumn:u}=o,h=hs(a+t-1,c,c+t-1,s),m=ms(c+n-1,a,a+t-1,s);return!h&&!m}},P.SheetClipboardService=ls([He(0,l.ILogService),He(1,l.IUniverInstanceService),He(2,L.Inject(f.SelectionManagerService)),He(3,M.IClipboardInterfaceService),He(4,l.IUndoRedoService),He(5,l.ICommandService),He(6,zt),He(7,L.Inject(P.SheetSkeletonManagerService))],P.SheetClipboardService);function cs(i){let e="";return i.forRow((t,n)=>{const o=[];n.forEach(r=>{const s=i.getValue(t,r);if(s){const a=ds(s);o.push(a)}}),e+=o.join(" "),t!==i.getLength()-1&&(e+=`
|
|
5
|
+
`)}),e}function ds(i){const e=i.v;return us((e==null?void 0:e.toString())||"")}const us=i=>i.replace(/&/g,"&").replace(/\ufeff/g,"").replace(/</g,"<").replace(/>/g,">");function hs(i,e,t,n){return n.getMergeData().some(o=>o.startRow<=i&&i<o.endRow&&e<=o.startColumn&&o.startColumn<=t)}function ms(i,e,t,n){return n.getMergeData().some(o=>o.startColumn<=i&&i<o.endColumn&&e<=o.startRow&&o.startRow<=t)}function _s(i){let e=0;return i.forValue((t,n,o)=>{if(o&&e++,e>1)return!1}),e>1}function Bi(){return{p:null,v:null,s:null,f:null,si:null,t:null}}const Vi={id:M.CopyCommand.id,name:"sheet.command.copy",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:Y,handler:async i=>i.get(qe).copy()},Ss={id:M.CutCommand.id,name:"sheet.command.cut",type:l.CommandType.COMMAND,multi:!0,priority:1e3,preconditions:Y,handler:async i=>i.get(qe).cut()},et={id:M.PasteCommand.id,type:l.CommandType.COMMAND,multi:!0,name:"sheet.command.paste",priority:1e3,preconditions:Y,handler:async(i,e)=>{const t=i.get(l.ILogService);if(t.log("[SheetPasteCommand]","the focusing element is",document.activeElement),!document.execCommand("paste")){t.log("[SheetPasteCommand]","failed to execute paste command on the activeElement, trying to use clipboard API.");const r=await i.get(M.IClipboardInterfaceService).read(),s=i.get(qe);return r.length!==0?s.paste(r[0],e==null?void 0:e.value):!1}return!1}},Fi={id:"sheet.command.paste-value",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(et.id,{value:de.SPECIAL_PASTE_VALUE})},Wi={id:"sheet.command.paste-format",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(et.id,{value:de.SPECIAL_PASTE_FORMAT})},ji={id:"sheet.command.paste-col-width",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(et.id,{value:de.SPECIAL_PASTE_COL_WIDTH})},zi={id:"sheet.command.paste-besides-border",type:l.CommandType.COMMAND,handler:async i=>i.get(l.ICommandService).executeCommand(et.id,{value:de.SPECIAL_PASTE_BESIDES_BORDER})};function Ne(i,e,t,n,o=!0,r=1,s=!0){let a={...i};n==null&&(n={startRow:0,endRow:t.getRowCount()-1,startColumn:0,endColumn:t.getColumnCount()-1});let c;switch(e){case l.Direction.UP:for(c=i.startRow-r;c>-1&&!t.getRowVisible(c);)c-=1;c>=n.startRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.endRow,a.endRow=n.endRow,o&&(a=Ne(a,l.Direction.LEFT,t,n,!1)));break;case l.Direction.DOWN:for(c=i.endRow+r;c<t.getRowCount()&&!t.getRowVisible(c);)c+=1;c<=n.endRow?(a.startRow=c,a.endRow=c):s&&(a.startRow=n.startRow,a.endRow=n.startRow,o&&(a=Ne(a,l.Direction.RIGHT,t,n,!1)));break;case l.Direction.LEFT:for(c=i.startColumn-r;c>-1&&!t.getColVisible(c);)c-=1;c>=n.startColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.endColumn,a.endColumn=n.endColumn,o&&(a=Ne(a,l.Direction.UP,t,n,!1)));break;case l.Direction.RIGHT:for(c=i.endColumn+r;c<t.getColumnCount()&&!t.getColVisible(c);)c+=1;c<=n.endColumn?(a.startColumn=c,a.endColumn=c):s&&(a.startColumn=n.startColumn,a.endColumn=n.startColumn,o&&(a=Ne(a,l.Direction.DOWN,t,n,!1)));break}return a}function jn(i,e,t){const n={...i},{startRow:o,startColumn:r,endRow:s,endColumn:a}=pt(i,e,t);let c=vt(t,o,r,s,a).hasValue,d=!0,u=!0;for(;u;){if(l.Direction.UP===e){let h=n.startRow-1;for(;h>-1&&!t.getRowVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:_}=vt(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(_.getLength()!==0){let g=h;_.forValue(S=>{g=Math.min(S,g)}),n.startRow=g}else n.startRow=h;if(n.endRow=n.startRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.DOWN===e){let h=n.endRow+1;for(;h<t.getRowCount()&&!t.getRowVisible(h);)h+=1;if(h===t.getRowCount()){u=!1;break}const{hasValue:m,matrix:_}=vt(t,h,n.startColumn,h,n.endColumn);if(c&&!m&&!d){u=!1;break}else{if(_.getLength()!==0){let g=h;_.forValue((S,v,I)=>{g=Math.max(S+(I.rowSpan||1)-1,g)}),n.endRow=g}else n.endRow=h;if(n.startRow=n.endRow,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.LEFT===e){let h=n.startColumn-1;for(;h>-1&&!t.getColVisible(h);)h-=1;if(h===-1){u=!1;break}const{hasValue:m,matrix:_}=vt(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(_.getLength()!==0){let g=h;_.forValue((S,v)=>{g=Math.min(v,g)}),n.startColumn=g}else n.startColumn=h;if(n.endColumn=n.startColumn,!c&&m){u=!1;break}c=m,d=!1}}if(l.Direction.RIGHT===e){let h=n.endColumn+1;for(;h<t.getColumnCount()&&!t.getColVisible(h);)h+=1;if(h===t.getColumnCount()){u=!1;break}const{hasValue:m,matrix:_}=vt(t,n.startRow,h,n.endRow,h);if(c&&!m&&!d){u=!1;break}else{if(_.getLength()!==0){let g=h;_.forValue((S,v,I)=>{g=Math.max(v+(I.colSpan||1)-1,g)}),n.endColumn=g}else n.endColumn=h;if(n.startColumn=n.endColumn,!c&&m){u=!1;break}c=m,d=!1}}}return f.alignToMergedCellsBorders(n,t,!0)}function Xi(i,e,t){return Ne(i,e,t,void 0,!1,1,!1)}function gs(i,e,t){const n=jn(i,e,t);return f.alignToMergedCellsBorders(l.Rectangle.union(n,i),t,!0)}function fs(i,e,t){const n=Xi(i,e,t),o={startRow:Math.min(i.startRow,n.startRow),startColumn:Math.min(i.startColumn,n.startColumn),endRow:Math.max(i.endRow,n.endRow),endColumn:Math.max(i.endColumn,n.endColumn)};return f.alignToMergedCellsBorders(l.Rectangle.union(i,o),t)}function ps(i,e,t,n){const o=l.getReverseDirection(t),r=jn(pt(i,o,n),t,n);return t===l.Direction.UP&&r.startRow<=i.startRow?f.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.DOWN&&r.endRow>=i.endRow?f.alignToMergedCellsBorders({...e,startColumn:i.startColumn,endColumn:i.endColumn},n,!0):t===l.Direction.LEFT&&r.startColumn<=i.startColumn?f.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):t===l.Direction.RIGHT&&r.endColumn>=i.endColumn?f.alignToMergedCellsBorders({...e,startRow:i.startRow,endRow:i.endRow},n,!0):l.Rectangle.union(l.Rectangle.clone(e),r)}function vs(i,e,t){const n=l.getReverseDirection(e),o=pt(i,n,t),r=pt(i,e,t),s=Xi(o,e,t);return f.alignToMergedCellsBorders(l.Rectangle.union(r,s),t,!1)}function Cs(i,e,t){const{left:n,right:o,up:r,down:s}=e,a=t.getMaxRows(),c=t.getMaxColumns();let d=!0;const u={...i};for(;d;){if(d=!1,r&&u.startRow!==0){const h=u.startRow-1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((_,g,S)=>{S.v&&(u.startRow=Math.min(_,u.startRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),d=!0)})}if(s&&u.endRow!==a-1){const h=u.endRow+1;t.getMatrixWithMergedCells(h,u.startColumn,h,u.endColumn).forValue((_,g,S)=>{S.v&&(u.endRow=Math.max(_+(S.rowSpan!==void 0?S.rowSpan-1:0),u.endRow),u.startColumn=Math.min(g,u.startColumn),u.endColumn=Math.max(g,u.endColumn),d=!0)})}if(n&&u.startColumn!==0){const h=u.startColumn-1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((_,g,S)=>{S.v&&(u.startColumn=Math.min(g,u.startColumn),u.startRow=Math.min(_,u.startRow),u.endRow=Math.max(_,u.endRow),d=!0)})}if(o&&u.endColumn!==c-1){const h=u.endColumn+1;t.getMatrixWithMergedCells(u.startRow,h,u.endRow,h).forValue((_,g,S)=>{S.v&&(u.endColumn=Math.max(g+(S.colSpan!==void 0?S.colSpan-1:0),u.endColumn),u.startRow=Math.min(_,u.startRow),u.endRow=Math.max(_,u.endRow),d=!0)})}}return u}function Yi(i){return{startRow:0,startColumn:0,endRow:i.getMaxRows()-1,endColumn:i.getMaxColumns()-1,rangeType:l.RANGE_TYPE.NORMAL}}function pt(i,e,t){let n;switch(e){case l.Direction.UP:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.startRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.DOWN:n={startRow:i.endRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.LEFT:n={startRow:i.startRow,startColumn:i.startColumn,endRow:i.endRow,endColumn:i.startColumn,rangeType:l.RANGE_TYPE.NORMAL};break;case l.Direction.RIGHT:n={startRow:i.startRow,startColumn:i.endColumn,endRow:i.endRow,endColumn:i.endColumn,rangeType:l.RANGE_TYPE.NORMAL};break;default:throw new Error("Invalid direction")}return f.alignToMergedCellsBorders(n,t,!1)}function vt(i,e,t,n,o){let r=!1;const s=i.getMatrixWithMergedCells(e,t,n,o).forValue((a,c,d)=>{if(d.v)return r=!0,!1});return{hasValue:r,matrix:s}}function zn(i,e,t){const n=l.Rectangle.clone(i);if(e==null)return n;switch(t){case l.Direction.UP:case l.Direction.DOWN:n.startColumn=n.endColumn=e.actualColumn;break;case l.Direction.LEFT:case l.Direction.RIGHT:n.startRow=n.endRow=e.actualRow;break}return n}function Is(i,e,t){const{primary:n,range:o}=i,r=l.Rectangle.clone(o);switch(e){case l.Direction.UP:case l.Direction.DOWN:r.startRow=n.startRow,r.endRow=n.endRow;break;case l.Direction.LEFT:case l.Direction.RIGHT:r.startColumn=n.startColumn,r.endColumn=n.endColumn;break}const s=pt(r,e,t);switch(e){case l.Direction.DOWN:return o.startRow<s.startRow;case l.Direction.UP:return o.endRow>s.endRow;case l.Direction.LEFT:return s.endColumn<o.endColumn;case l.Direction.RIGHT:return s.startColumn>o.startColumn}}var Me=(i=>(i[i.moveStopeOne=0]="moveStopeOne",i[i.moveGap=1]="moveGap",i[i.moveStepPage=2]="moveStepPage",i[i.moveStepEnd=3]="moveStepEnd",i))(Me||{});const me={id:"sheet.command.move-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{direction:r,jumpOver:s}=e,{range:a,primary:c}=o,d=zn(a,c,r),u=s===1?jn(d,r,n):Ne(d,r,n),h=f.getCellAtRowCol(u.startRow,u.startColumn,n);return l.Rectangle.equals(h,d)?!1:(i.get(M.ShortcutExperienceService).remove({unitId:t.getUnitId(),sheetId:n.getSheetId(),keycode:M.KeyCode.TAB}),i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:t.getUnitId(),sheetId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:l.Rectangle.clone(h),primary:{startRow:h.startRow,startColumn:h.startColumn,endRow:h.endRow,endColumn:h.endColumn,actualRow:u.startRow,actualColumn:u.startColumn,isMerged:h.isMerged,isMergedMainCell:h.startRow===u.startRow&&h.startColumn===u.startColumn}}]}))}},je={id:"sheet.command.move-selection-enter-tab",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast(),r=t.getUnitId(),s=n.getSheetId();if(!o)return!1;const{direction:a,keycode:c}=e,{range:d,primary:u}=o;let h=zn(d,u,a);const m=i.get(M.ShortcutExperienceService),_=m.getCurrentBySearch({unitId:r,sheetId:s,keycode:M.KeyCode.TAB});let g;const{startRow:S,endRow:v,startColumn:I,endColumn:b}=d;if(l.Rectangle.equals(d,u)){if(c===M.KeyCode.TAB)_==null&&m.addOrUpdate({unitId:r,sheetId:s,keycode:M.KeyCode.TAB,selection:o});else{const E=_==null?void 0:_.selection;if(E!=null){const{range:O,primary:y}=E;h=zn(O,y,a)}m.remove({unitId:r,sheetId:s,keycode:M.KeyCode.TAB})}const R=Ne(h,a,n),T=f.getCellAtRowCol(R.startRow,R.startColumn,n);if(l.Rectangle.equals(T,h))return!1;g={range:l.Rectangle.clone(T),primary:{startRow:T.startRow,startColumn:T.startColumn,endRow:T.endRow,endColumn:T.endColumn,actualRow:R.startRow,actualColumn:R.startColumn,isMerged:T.isMerged,isMergedMainCell:T.startRow===R.startRow&&T.startColumn===R.startColumn}}}else{m.remove({unitId:r,sheetId:s,keycode:M.KeyCode.TAB});const R=l.Tools.deepClone(u),T=Ne({startRow:R.startRow,startColumn:R.startColumn,endRow:R.endRow,endColumn:R.endColumn},a,n,{startRow:S,endRow:v,startColumn:I,endColumn:b}),E=f.getCellAtRowCol(T.startRow,T.startColumn,n);g={range:l.Rectangle.clone(d),primary:{startRow:E.startRow,startColumn:E.startColumn,endRow:E.endRow,endColumn:E.endColumn,actualRow:T.startRow,actualColumn:T.startColumn,isMerged:E.isMerged,isMergedMainCell:E.startRow===T.startRow&&E.startColumn===T.startColumn}}}return i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:r,sheetId:s,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[g]})}},be={id:"sheet.command.expand-selection",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const t=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=i.get(f.SelectionManagerService).getLast();if(!o)return!1;const{range:r,primary:s}=o,{jumpOver:a,direction:c}=e,u=Is(o,c,n)?a===1?ps(r,{...l.Rectangle.clone(s),rangeType:l.RANGE_TYPE.NORMAL},c,n):vs(r,c,n):a===1?gs(r,c,n):fs(r,c,n);return l.Rectangle.equals(u,r)?!1:i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:t.getUnitId(),sheetId:n.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:u,primary:s}]})}};let Re=[],Xn="";const $i={id:"sheet.command.select-all",type:l.CommandType.COMMAND,onDispose(){Re=[],Xn=""},handler:async(i,e={expandToGapFirst:!0,loop:!1})=>{const t=i.get(f.SelectionManagerService).getLast(),n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),o=n.getActiveSheet();if(!t||!o)return!1;const r=`${n.getUnitId()}|${o.getSheetId()}`;r!==Xn&&(Re=[],Xn=r);const s=o.getMaxRows(),a=o.getMaxColumns(),{expandToGapFirst:c,loop:d}=e,{range:u,primary:h}=t,m=u.endColumn===a-1&&u.endRow===s-1&&u.startRow===0&&u.startColumn===0;Re.some(g=>l.Rectangle.equals(g,u))||(Re=[],Re.push(u));let _;if(m)if(d){if(Re.findIndex(S=>l.Rectangle.equals(S,u))!==Re.length-1)return!1;_=Re[0]}else return!1;else c?(_=Cs(u,{left:!0,right:!0,up:!0,down:!0},o),l.Rectangle.equals(_,u)&&(_=Yi(o))):_=Yi(o);return Re.some(g=>l.Rectangle.equals(g,_))||Re.push(_),i.get(l.ICommandService).executeCommand(f.SetSelectionsOperation.id,{unitId:n.getUnitId(),sheetId:o.getSheetId(),pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:_,primary:h}]})}};class Le{constructor(){C(this,"_scrollInfo",new Map);C(this,"_currentScroll",null);C(this,"_scrollInfo$",new B.BehaviorSubject(null));C(this,"scrollInfo$",this._scrollInfo$.asObservable())}dispose(){this._scrollInfo$.complete()}setCurrentScroll(e){this._currentScroll=e,this._refresh(e)}getScrollByParam(e){return this._getCurrentScroll(e)}getCurrentScroll(){return this._getCurrentScroll(this._currentScroll)}addOrReplace(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e})}addOrReplaceNoRefresh(e){this._currentScroll!=null&&this._addByParam({...this._currentScroll,...e},!1)}addOrReplaceByParam(e){this._addByParam(e)}clear(){this._currentScroll!=null&&this._clearByParam(this._currentScroll)}_addByParam(e,t=!0){const{unitId:n,sheetId:o,sheetViewStartColumn:r,sheetViewStartRow:s,offsetX:a,offsetY:c}=e;this._scrollInfo.has(n)||this._scrollInfo.set(n,new Map),this._scrollInfo.get(n).set(o,{sheetViewStartRow:s,sheetViewStartColumn:r,offsetX:a,offsetY:c}),t===!0&&this._refresh({unitId:n,sheetId:o})}_clearByParam(e){this._addByParam({...e,sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),this._refresh(e)}_getCurrentScroll(e){var o;if(e==null)return;const{unitId:t,sheetId:n}=e;return(o=this._scrollInfo.get(t))==null?void 0:o.get(n)}_refresh(e){this._scrollInfo$.next(this._getCurrentScroll(e))}}const tt={id:"sheet.operation.set-scroll",type:l.CommandType.OPERATION,handler:(i,e)=>{if(!e)return!1;const t=i.get(Le),r=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId).getSheetBySheetId(e.sheetId),{xSplit:s,ySplit:a}=r.getConfig().freeze;return t.addOrReplaceByParam({...e,sheetViewStartRow:e.sheetViewStartRow-a,sheetViewStartColumn:e.sheetViewStartColumn-s}),!0}},Xt={id:"sheet.operation.set-editor-resize",type:l.CommandType.OPERATION,handler:(i,e)=>!0},Ee={id:"sheet.operation.set-zoom-ratio",type:l.CommandType.OPERATION,handler:(i,e)=>{const t=i.get(l.IUniverInstanceService).getUniverSheetInstance(e.unitId);if(!t)return!1;const n=t.getSheetBySheetId(e.subUnitId);return n?(n.getConfig().zoomRatio=e.zoomRatio,!0):!1}};var re=(i=>(i.MAIN="__SpreadsheetRender__",i.ROW="__SpreadsheetRowHeader__",i.COLUMN="__SpreadsheetColumnHeader__",i.LEFT_TOP="__SpreadsheetLeftTopPlaceholder__",i))(re||{}),j=(i=>(i.VIEW_MAIN="viewMain",i.VIEW_MAIN_LEFT_TOP="viewMainLeftTop",i.VIEW_MAIN_TOP="viewMainTop",i.VIEW_MAIN_LEFT="viewMainLeft",i.VIEW_ROW_TOP="viewRowTop",i.VIEW_ROW_BOTTOM="viewRowBottom",i.VIEW_COLUMN_LEFT="viewColumnLeft",i.VIEW_COLUMN_RIGHT="viewColumnRight",i.VIEW_LEFT_TOP="viewLeftTop",i))(j||{});const Zi=0,Ue=2,Yn=[10,400],Gi=1001;var Ki={exports:{}},Yt={};/**
|
|
6
|
+
* @license React
|
|
7
|
+
* react-jsx-runtime.production.min.js
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*/var Ms=k,bs=Symbol.for("react.element"),Rs=Symbol.for("react.fragment"),ws=Object.prototype.hasOwnProperty,Ts=Ms.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Es={key:!0,ref:!0,__self:!0,__source:!0};function Ji(i,e,t){var n,o={},r=null,s=null;t!==void 0&&(r=""+t),e.key!==void 0&&(r=""+e.key),e.ref!==void 0&&(s=e.ref);for(n in e)ws.call(e,n)&&!Es.hasOwnProperty(n)&&(o[n]=e[n]);if(i&&i.defaultProps)for(n in e=i.defaultProps,e)o[n]===void 0&&(o[n]=e[n]);return{$$typeof:bs,type:i,key:r,ref:s,props:o,_owner:Ts.current}}Yt.Fragment=Rs,Yt.jsx=Ji,Yt.jsxs=Ji,Ki.exports=Yt;var p=Ki.exports,_e=function(){return _e=Object.assign||function(i){for(var e,t=1,n=arguments.length;t<n;t++){e=arguments[t];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i[o]=e[o])}return i},_e.apply(this,arguments)},Os=function(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(i);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(i,n[o])&&(t[n[o]]=i[n[o]]);return t},ue=k.forwardRef(function(i,e){var t=i.icon,n=i.id,o=i.className,r=i.extend,s=Os(i,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),c=k.useRef("_".concat(As()));return Qi(t,"".concat(n),{defIds:t.defIds,idSuffix:c.current},_e({ref:e,className:a},s),r)});function Qi(i,e,t,n,o){return k.createElement(i.tag,_e(_e({key:e},ys(i,t,o)),n),(xs(i,t).children||[]).map(function(r,s){return Qi(r,"".concat(e,"-").concat(i.tag,"-").concat(s),t,void 0,o)}))}function ys(i,e,t){var n=_e({},i.attrs);t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1);var o=e.defIds;return!o||o.length===0||(i.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(r){var s=r[0],a=r[1];typeof a=="string"&&(n[s]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function xs(i,e){var t,n=e.defIds;return!n||n.length===0?i:i.tag==="defs"&&(!((t=i.children)===null||t===void 0)&&t.length)?_e(_e({},i),{children:i.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?_e(_e({},o),{attrs:_e(_e({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):i}function As(){return Math.random().toString(36).substring(2,8)}ue.displayName="UniverIcon";var Ps={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M11.5261 12.834V14.634C11.5261 14.9654 11.7948 15.234 12.1261 15.234V15.234C12.4575 15.234 12.7261 14.9654 12.7261 14.634V12.834H14.5262C14.8576 12.834 15.1262 12.5654 15.1262 12.234V12.234C15.1262 11.9027 14.8576 11.634 14.5262 11.634H12.7261V9.83401C12.7261 9.50264 12.4575 9.23401 12.1261 9.23401V9.23401C11.7948 9.23401 11.5261 9.50264 11.5261 9.83401V11.634H9.72622C9.39485 11.634 9.12622 11.9027 9.12622 12.234V12.234C9.12622 12.5654 9.39485 12.834 9.72622 12.834H11.5261Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M3.05352 1.9613C2.39077 1.9613 1.85352 2.49856 1.85352 3.1613V6.7613C1.85352 7.42405 2.39077 7.9613 3.05352 7.9613H6.65352C7.31626 7.9613 7.85352 7.42405 7.85352 6.7613V3.1613C7.85352 2.49856 7.31626 1.9613 6.65352 1.9613H3.05352zM6.65352 3.1613H3.05352L3.05352 6.7613H6.65352V3.1613zM3.05352 9.23401C2.39077 9.23401 1.85352 9.77127 1.85352 10.434V14.034C1.85352 14.6968 2.39077 15.234 3.05352 15.234H6.65352C7.31626 15.234 7.85352 14.6968 7.85352 14.034V10.434C7.85352 9.77127 7.31626 9.23401 6.65352 9.23401H3.05352zM6.65352 10.434H3.05352L3.05352 14.034H6.65352V10.434zM10.3262 7.9613C9.66348 7.9613 9.12622 7.42405 9.12622 6.7613V3.1613C9.12622 2.49856 9.66348 1.9613 10.3262 1.9613H13.9262C14.589 1.9613 15.1262 2.49856 15.1262 3.1613V6.7613C15.1262 7.42405 14.589 7.9613 13.9262 7.9613H10.3262zM10.3262 6.7613V3.1613L13.9262 3.1613V6.7613H10.3262z",fillRule:"evenodd",clipRule:"evenodd"}}]},qi=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"autofill",ref:e,icon:Ps}))});qi.displayName="Autofill";const Ds=qi;var Hs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M14.6152 4.52067C14.8732 4.77869 14.8732 5.19703 14.6152 5.45505L6.61862 13.4514C6.46241 13.6077 6.20915 13.6077 6.05294 13.4514L1.73512 9.13354C1.4771 8.87551 1.4771 8.45718 1.73513 8.19915C1.99315 7.94113 2.41149 7.94114 2.66951 8.19916L6.19436 11.7241C6.27247 11.8022 6.3991 11.8022 6.47721 11.7241L13.6808 4.52067C13.9388 4.26264 14.3571 4.26264 14.6152 4.52067Z",fillRule:"evenodd",clipRule:"evenodd"}}]},eo=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"check-mark-single",ref:e,icon:Hs}))});eo.displayName="CheckMarkSingle";const $t=eo;var Ns={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.48712 4.59907C5.23328 4.34523 4.82172 4.34523 4.56788 4.59907C4.31404 4.85291 4.31404 5.26447 4.56788 5.51831L7.9973 8.94773L4.56773 12.3773C4.31389 12.6311 4.31389 13.0427 4.56773 13.2965C4.82157 13.5504 5.23313 13.5504 5.48697 13.2965L8.91654 9.86697L12.3461 13.2965C12.5999 13.5503 13.0114 13.5503 13.2653 13.2965C13.5191 13.0426 13.5191 12.6311 13.2653 12.3772L9.83577 8.94773L13.2651 5.51836C13.519 5.26452 13.519 4.85296 13.2651 4.59912C13.0113 4.34528 12.5997 4.34528 12.3459 4.59912L8.91654 8.02849L5.48712 4.59907Z"}}]},to=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"close-single",ref:e,icon:Ns}))});to.displayName="CloseSingle";const Ls=to;var Us={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1213",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.54 0.32H16.54V16.32H0.54z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_102_1213)"},children:[{tag:"path",attrs:{d:"M1.76539 1.27148C1.89532 1.2465 2.05784 1.23193 2.25712 1.23193H7.39957C7.59852 1.23193 7.76228 1.24644 7.89394 1.27682 8.02979 1.30817 8.13912 1.36697 8.22237 1.45577 8.30591 1.54488 8.35813 1.6636 8.38857 1.80057L8.38913 1.80311C8.41406 1.93772 8.42854 2.10966 8.42854 2.31825V7.47982C8.42854 7.67924 8.41396 7.84153 8.38908 7.97584 8.36281 8.11247 8.3041 8.22717 8.22073 8.31054 8.13704 8.39424 8.02807 8.4472 7.89934 8.4781 7.77208 8.50864 7.60803 8.52313 7.41869 8.52313H2.25712C2.06419 8.52313 1.90591 8.51354 1.77494 8.48836 1.64209 8.46281 1.53156 8.41527 1.4464 8.33054 1.3606 8.24999 1.30815 8.13434 1.27781 8.00286 1.2476 7.87192 1.22815 7.69892 1.22815 7.47982V2.27524C1.22815 2.07123 1.24271 1.90413 1.26761 1.76966 1.29388 1.63303 1.35259 1.51833 1.43596 1.43496 1.52104 1.34988 1.63137 1.30236 1.76275 1.27204L1.76539 1.27148zM2.56975 2.39137C2.49306 2.39568 2.45433 2.41469 2.43395 2.43562 2.41191 2.46884 2.39718 2.51452 2.39715 2.57614L2.40631 4.24285H4.26296V2.39137H2.56975zM5.44152 2.39615V4.24285H7.24998V2.51898C7.24998 2.47398 7.24652 2.44245 7.24141 2.42201 7.23917 2.41305 7.23709 2.40806 7.23591 2.40567 7.22586 2.40059 7.20631 2.39615 7.16061 2.39615H5.44152zM2.40708 5.39751L2.41626 7.22616C2.41626 7.26829 2.41965 7.29933 2.42492 7.32085 2.42882 7.33675 2.43309 7.34502 2.43572 7.34893 2.43572 7.34893 2.43928 7.35079 2.44202 7.35193 2.44831 7.35455 2.45718 7.35739 2.46908 7.35996 2.49304 7.36512 2.52583 7.36847 2.56777 7.36847H4.26774V5.39751H2.40708zM5.44152 5.39751V7.36847H7.09848C7.1739 7.36847 7.21416 7.35941 7.23151 7.35088 7.23281 7.34891 7.23591 7.34357 7.23933 7.33216 7.24553 7.3115 7.24998 7.27978 7.24998 7.23608V5.39751H5.44152zM9.19356 8.15082C9.3235 8.12583 9.48601 8.11127 9.6853 8.11127H14.8277C15.0267 8.11127 15.1905 8.12577 15.3221 8.15616 15.458 8.18751 15.5673 8.2463 15.6506 8.33511 15.7341 8.42421 15.7863 8.54294 15.8167 8.67991L15.8173 8.68245C15.8422 8.81705 15.8567 8.98899 15.8567 9.19759V14.3592C15.8567 14.5586 15.8421 14.7209 15.8173 14.8552 15.791 14.9918 15.7323 15.1065 15.6489 15.1899 15.5652 15.2736 15.4562 15.3265 15.3275 15.3574 15.2003 15.388 15.0362 15.4025 14.8469 15.4025H9.6853C9.49237 15.4025 9.33408 15.3929 9.20312 15.3677 9.07027 15.3421 8.95974 15.2946 8.87458 15.2099 8.78878 15.1293 8.73633 15.0137 8.70599 14.8822 8.67578 14.7513 8.65633 14.5783 8.65633 14.3592V9.15457C8.65633 8.95057 8.67088 8.78346 8.69579 8.649 8.72206 8.51237 8.78077 8.39767 8.86414 8.3143 8.94922 8.22922 9.05955 8.1817 9.19093 8.15138L9.19356 8.15082zM9.99793 9.27071C9.92124 9.27501 9.88251 9.29403 9.86212 9.31496 9.84009 9.34817 9.82536 9.39386 9.82533 9.45548L9.83448 11.1222H11.6911V9.27071H9.99793zM12.8697 9.27549V11.1222H14.6782V9.39831C14.6782 9.35332 14.6747 9.32178 14.6696 9.30135 14.6673 9.29238 14.6653 9.2874 14.6641 9.285 14.654 9.27992 14.6345 9.27549 14.5888 9.27549H12.8697zM9.83525 12.2768L9.84444 14.1055C9.84444 14.1476 9.84783 14.1787 9.8531 14.2002 9.85699 14.2161 9.86127 14.2244 9.86389 14.2283L9.86689 14.2298 9.87019 14.2313C9.87648 14.2339 9.88535 14.2367 9.89726 14.2393 9.92122 14.2445 9.95401 14.2478 9.99594 14.2478H11.6959V12.2768H9.83525zM12.8697 12.2768V14.2478H14.5267C14.6021 14.2478 14.6423 14.2387 14.6597 14.2302 14.661 14.2282 14.6641 14.2229 14.6675 14.2115 14.6737 14.1908 14.6782 14.1591 14.6782 14.1154V12.2768H12.8697z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{d:"M10.0049 2.46747C10.0049 2.06363 10.3323 1.73625 10.7361 1.73625H12.9298C14.1413 1.73625 15.1234 2.71838 15.1234 3.9299V6.12354C15.1234 6.52738 14.796 6.85476 14.3922 6.85476 13.9883 6.85476 13.661 6.52738 13.661 6.12354V3.9299C13.661 3.52606 13.3336 3.19868 12.9298 3.19868H10.7361C10.3323 3.19868 10.0049 2.87131 10.0049 2.46747zM3.42396 10.5108C3.42396 10.107 3.09658 9.77962 2.69274 9.77962 2.2889 9.77962 1.96152 10.107 1.96152 10.5108V12.7045C1.96152 13.916 2.94365 14.8981 4.15517 14.8981H6.34882C6.75266 14.8981 7.08003 14.5707 7.08003 14.1669 7.08003 13.7631 6.75266 13.4357 6.34882 13.4357H4.15517C3.75134 13.4357 3.42396 13.1083 3.42396 12.7045V10.5108z"}}]}]},no=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"convert-single",ref:e,icon:Us}))});no.displayName="ConvertSingle";const ks=no;var Bs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_371_77",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.87 0.63H16.87V16.63H0.87z"}}]},{tag:"g",attrs:{mask:"url(#mask0_371_77)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.72636 13.5549C9.25212 14.1041 8.48323 14.1041 8.00899 13.5549L1.22579 5.70056C0.46078 4.81474 1.00259 3.30013 2.08448 3.30013L15.6509 3.30013C16.7328 3.30013 17.2746 4.81474 16.5096 5.70056L9.72636 13.5549Z"}}]}]},io=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"dropdown-single",ref:e,icon:Bs}))});io.displayName="DropdownSingle";const oo=io;var Vs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.90535 4.99197C2.23194 4.82196 2.63451 4.94889 2.80452 5.27548C2.96702 5.58764 3.22397 5.8971 3.57667 6.18615C4.57587 7.00507 6.2535 7.58331 8.21318 7.58331C10.1728 7.58331 11.8505 7.00508 12.8497 6.18616C13.2024 5.8971 13.4593 5.58763 13.6218 5.27549C13.7918 4.94889 14.1944 4.82196 14.521 4.99196C14.8476 5.16197 14.9745 5.56454 14.8045 5.89113C14.5439 6.39185 14.1596 6.83646 13.6948 7.2174C13.6514 7.25301 13.6071 7.28815 13.5621 7.3228L15.0214 8.78205C15.2817 9.0424 15.2817 9.46451 15.0214 9.72486C14.761 9.98521 14.3389 9.98521 14.0785 9.72486L12.3889 8.03522C11.8643 8.28584 11.2846 8.48827 10.6659 8.63563L11.2065 10.6532C11.3018 11.0088 11.0907 11.3744 10.7351 11.4697C10.3794 11.565 10.0139 11.3539 9.91857 10.9983L9.34529 8.85869C8.97555 8.89693 8.59724 8.91664 8.21318 8.91664C7.82639 8.91664 7.44544 8.89665 7.07321 8.85788L6.49971 10.9983C6.40441 11.354 6.03886 11.565 5.68321 11.4697C5.32757 11.3744 5.11651 11.0089 5.2118 10.6532L5.75288 8.63382C5.13793 8.48682 4.5615 8.28539 4.03968 8.03629L2.35121 9.72477C2.09086 9.98512 1.66875 9.98512 1.4084 9.72477C1.14805 9.46442 1.14805 9.04231 1.4084 8.78196L2.86611 7.32424C2.82044 7.28912 2.77557 7.2535 2.73152 7.2174C2.26668 6.83645 1.88248 6.39184 1.62183 5.89114C1.45182 5.56455 1.57876 5.16198 1.90535 4.99197Z"}}]},ro=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"eyelash-single",ref:e,icon:Vs}))});ro.displayName="EyelashSingle";const Fs=ro;var Ws={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_367_60",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.06 0.78H16.06V16.78H0.06z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_367_60)"},children:[{tag:"path",attrs:{d:"M5.54303 5.67809C5.41486 5.67809 5.31977 5.55923 5.34791 5.43419L5.43336 5.05446C5.53338 4.62534 5.71701 4.25903 5.99076 3.96308 6.28977 3.63984 6.73293 3.49761 7.27633 3.49761 7.47741 3.49761 7.69254 3.52131 7.92082 3.56601 7.93983 3.56973 7.95869 3.57361 7.9774 3.57766 8.18885 3.62335 8.41593 3.52833 8.49925 3.32869L8.72661 2.78395C8.81351 2.57574 8.71072 2.3376 8.49476 2.27229 8.46253 2.26255 8.42923 2.25268 8.39485 2.24269 8.10639 2.15986 7.76287 2.11572 7.35969 2.11572 6.29909 2.11572 5.50608 2.38292 4.95354 2.88796 4.38882 3.40424 3.98783 4.14273 3.76308 5.11976L2.31598 11.3345C2.2402 11.6722 2.14495 12.0353 2.02739 12.4247 1.90869 12.8169 1.76625 13.2031 1.60116 13.5809 1.43472 13.9595 1.24707 14.3197 1.0385 14.6607.972389 14.7687.904093 14.8718.833608 14.9698.744025 15.0945.813644 15.2766.965497 15.2989 1.6153 15.3945 2.29684 15.2198 2.66091 14.6732 2.80556 14.456 2.94673 14.2082 3.08403 13.9287 3.44529 13.1932 3.78416 12.1538 4.09761 10.801L4.94794 7.15889C4.96907 7.06839 5.04977 7.00436 5.14271 7.00436H7.10372C7.28864 7.00436 7.44946 6.87761 7.49265 6.6978L7.61908 6.17153C7.67951 5.91998 7.48886 5.67809 7.23015 5.67809H5.54303zM13.8 5.86392L11.9914 8.11319 10.8878 5.92109C10.8211 5.77368 10.6743 5.67896 10.5125 5.67896H9.79183C9.48739 5.67896 9.28816 5.99784 9.42165 6.27145L10.8878 9.19857 8.27677 12.2928C8.04481 12.5594 8.23414 12.9751 8.58749 12.9751H9.16501C9.28566 12.9751 9.43944 12.9258 9.5177 12.834L11.5897 10.4084 12.5966 12.7046C12.6575 12.8666 12.8119 12.9751 12.9851 12.9751H13.779C14.062 12.9751 14.2207 12.7611 14.1216 12.4959L12.6517 9.42983C12.6517 9.42983 14.8799 6.59898 15.0802 6.32247 15.2756 6.05285 15.0812 5.67896 14.7482 5.67896H14.145C14.0064 5.67896 13.9122 5.73242 13.8 5.86392z"}}]}]},so=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"fx-single",ref:e,icon:Ws}))});so.displayName="FxSingle";const js=so;var zs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_249",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.37 0.77H16.37V16.77H0.37z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_249)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.12107 2.86418C9.12107 2.45648 8.78669 2.12598 8.37422 2.12598C7.96175 2.12598 7.62737 2.45648 7.62737 2.86418V8.03164H2.39931C1.98684 8.03164 1.65247 8.36214 1.65247 8.76984C1.65247 9.17754 1.98684 9.50805 2.39931 9.50805H7.62737V14.6754C7.62737 15.0831 7.96175 15.4136 8.37422 15.4136C8.78669 15.4136 9.12107 15.0831 9.12107 14.6754V9.50805H14.3489C14.7613 9.50805 15.0957 9.17754 15.0957 8.76984C15.0957 8.36214 14.7613 8.03164 14.3489 8.03164H9.12107V2.86418Z"}}]}]},ao=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"increase-single",ref:e,icon:zs}))});ao.displayName="IncreaseSingle";const Xs=ao;var Ys={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_556",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.56 0.77H16.56V16.77H0.56z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_556)"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M1.19318 4.76988C1.70089 4.26222 2.524 4.26226 3.03166 4.76997L8.13929 9.87808C8.3736 10.1124 8.75352 10.1124 8.98784 9.8781L14.0959 4.77C14.6036 4.26232 15.4267 4.26232 15.9344 4.77C16.4421 5.27768 16.4421 6.1008 15.9344 6.60848L9.97775 12.5651C9.19667 13.3462 7.93029 13.3462 7.14925 12.5651L1.1931 6.60836C0.685438 6.10065 0.685477 5.27753 1.19318 4.76988Z",fillRule:"evenodd",clipRule:"evenodd"}}]}]},lo=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"more-down-single",ref:e,icon:Ys}))});lo.displayName="MoreDownSingle";const $n=lo;var $s={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.52628 3.57095C5.81918 3.26411 6.29405 3.26411 6.58695 3.57095L11.0869 8.28525C11.3798 8.59209 11.3798 9.08958 11.0869 9.39642L6.51623 14.04C6.22334 14.3468 5.74846 14.3468 5.45557 14.04C5.16268 13.7331 5.16268 13.2357 5.45557 12.9288L9.35939 8.979C9.43544 8.90205 9.43652 8.77857 9.36182 8.70031L5.52628 4.68212C5.23339 4.37528 5.23339 3.87779 5.52628 3.57095Z",fillRule:"evenodd",clipRule:"evenodd"}}]},co=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"more-single",ref:e,icon:$s}))});co.displayName="MoreSingle";const Zn=co;var Zs={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_102_1204",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#DCDCDC",d:"M0.25 0.41H16.25V16.41H0.25z"}}]},{tag:"g",attrs:{mask:"url(#mask0_102_1204)"},children:[{tag:"rect",attrs:{width:12.62,height:2.79,x:1.94,y:12.66,fill:"colorChannel1",rx:1.4}},{tag:"path",attrs:{fill:"currentColor",d:"M7.99664 2.57069C7.59302 2.05771 7.10966 1.68854 6.63466 1.50243C6.11882 1.30028 5.40184 1.25862 4.95066 1.83566C4.5486 2.34994 4.581 3.10899 4.82709 3.91045C4.93826 4.27259 5.11865 4.62903 5.37541 4.97266C5.38713 4.98834 5.39945 5.00329 5.41229 5.01752C5.4217 5.02789 5.4314 5.03788 5.44133 5.04746C5.45477 5.06043 5.46874 5.07267 5.48315 5.08419L3.75659 6.81071C3.51774 7.04955 3.51774 7.43683 3.75659 7.67569L7.48775 11.4068C7.72666 11.6457 8.11394 11.6457 8.35278 11.4068L13.0831 6.67651C13.3219 6.43766 13.3219 6.05039 13.0831 5.81155L9.35191 2.08037C9.11306 1.84153 8.72579 1.84153 8.48695 2.08037L7.99664 2.57069ZM7.71181 4.91288C7.72271 4.98224 7.73182 5.05302 7.73898 5.12518C7.77251 5.46131 8.07213 5.70663 8.40825 5.6731C8.74438 5.6396 8.98972 5.33994 8.9562 5.00382C8.90804 4.52113 8.79269 4.0731 8.6291 3.66819L8.91946 3.37784L11.7856 6.24403L10.8608 7.16886H5.12843L7.6582 4.63909C7.67903 4.72777 7.69702 4.81905 7.71181 4.91288ZM7.12302 3.44433C6.8246 3.02658 6.47279 2.75283 6.18833 2.64136C6.05252 2.58814 5.96546 2.58477 5.92656 2.58984C5.92268 2.59037 5.91947 2.59093 5.91678 2.59147L5.91208 2.59257C5.89185 2.62604 5.78612 2.86628 5.99645 3.5514C6.0626 3.76685 6.1728 3.99252 6.34325 4.2241L7.12302 3.44433Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.4434 11.9528C12.8956 11.9528 13.2622 11.5862 13.2622 11.134C13.2622 10.854 12.9483 10.3347 12.7092 9.9798C12.5801 9.78823 12.3066 9.78823 12.1776 9.97981C11.9385 10.3347 11.6246 10.854 11.6246 11.134C11.6246 11.5862 11.9912 11.9528 12.4434 11.9528Z"}}]}]},uo=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"paint-bucket",ref:e,icon:Zs}))});uo.displayName="PaintBucket";const Gs=uo;var Ks={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.80805 1.53809C2.10674 1.53809 1.53821 2.10661 1.53821 2.80793V13.6016C1.53821 14.3029 2.10674 14.8714 2.80805 14.8714H9.74456C10.2968 14.8714 10.7446 14.4237 10.7446 13.8714V13.6016V11.128C10.7446 10.9623 10.8789 10.828 11.0446 10.828H13.6017H13.8715C14.4238 10.828 14.8715 10.3803 14.8715 9.82802V2.80793C14.8715 2.10661 14.303 1.53809 13.6017 1.53809H2.80805ZM9.17472 13.6016C9.3404 13.6016 9.47472 13.4673 9.47472 13.3016V11.128C9.47472 10.9623 9.3404 10.828 9.17472 10.828H6.91757C6.75189 10.828 6.61757 10.9623 6.61757 11.128V13.3016C6.61757 13.4673 6.75189 13.6016 6.91757 13.6016H9.17472ZM13.6017 9.25817C13.6017 9.42386 13.4674 9.55818 13.3017 9.55818H11.0446C10.8789 9.55818 10.7446 9.42386 10.7446 9.25818V7.17177C10.7446 7.00608 10.8789 6.87177 11.0446 6.87177H13.3017C13.4674 6.87177 13.6017 7.00608 13.6017 7.17177V9.25817ZM9.17472 9.55818C9.3404 9.55818 9.47472 9.42386 9.47472 9.25818V7.17177C9.47472 7.00608 9.3404 6.87177 9.17472 6.87177H6.91757C6.75189 6.87177 6.61757 7.00608 6.61757 7.17177V9.25817C6.61757 9.42386 6.75189 9.55818 6.91757 9.55818H9.17472ZM13.6017 5.30193C13.6017 5.46761 13.4674 5.60193 13.3017 5.60193H11.0446C10.8789 5.60193 10.7446 5.46761 10.7446 5.30193V3.10793C10.7446 2.94224 10.8789 2.80793 11.0446 2.80793H13.3017C13.4674 2.80793 13.6017 2.94224 13.6017 3.10793V5.30193ZM9.17472 5.60193C9.3404 5.60193 9.47472 5.46761 9.47472 5.30193V3.10793C9.47472 2.94224 9.3404 2.80793 9.17472 2.80793H6.91757C6.75189 2.80793 6.61757 2.94224 6.61757 3.10793V5.30193C6.61757 5.46761 6.75189 5.60193 6.91757 5.60193H9.17472ZM5.34773 3.10793C5.34773 2.94224 5.21342 2.80793 5.04773 2.80793H3.10805C2.94236 2.80793 2.80805 2.94224 2.80805 3.10793V5.30193C2.80805 5.46761 2.94236 5.60193 3.10805 5.60193H5.04773C5.21342 5.60193 5.34773 5.46761 5.34773 5.30193V3.10793ZM5.34773 7.17177C5.34773 7.00608 5.21342 6.87177 5.04773 6.87177H3.10805C2.94236 6.87177 2.80805 7.00608 2.80805 7.17177V9.25817C2.80805 9.42386 2.94236 9.55818 3.10805 9.55818H5.04773C5.21342 9.55818 5.34773 9.42386 5.34773 9.25818V7.17177ZM5.34773 11.128C5.34773 10.9623 5.21342 10.828 5.04773 10.828H3.10805C2.94236 10.828 2.80805 10.9623 2.80805 11.128V13.3016C2.80805 13.4673 2.94236 13.6016 3.10805 13.6016H5.04773C5.21342 13.6016 5.34773 13.4673 5.34773 13.3016V11.128Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M12.3869 12.1183C12.361 11.9546 12.5342 11.8323 12.6798 11.9114L14.9901 13.1655C15.1577 13.2565 15.1137 13.5049 14.932 13.5378C14.9212 13.5398 14.9102 13.5417 14.8996 13.5446L13.8966 13.8224L13.1603 14.7467C13.0651 14.9084 12.8197 14.8618 12.7904 14.6764L12.3869 12.1183Z"}}]},ho=k.forwardRef(function(i,e){return k.createElement(ue,Object.assign({},i,{id:"select-range-single",ref:e,icon:Ks}))});ho.displayName="SelectRangeSingle";const Js=ho,ze={rangeSelector:"univer-range-selector",rangeSelectorEditor:"univer-range-selector-editor",rangeSelectorIcon:"univer-range-selector-icon",rangeSelectorActive:"univer-range-selector-active"};function Qs(i){const{onChange:e,onActive:t}=i,[n,o]=k.useState(!1),r=k.useRef(null),s=F.useDependency(l.LocaleService),a=F.useDependency(f.SelectionManagerService);k.useEffect(()=>{var m;if(n){t(n);const _=a.selectionMoveEnd$.subscribe(g=>{const S=["A1","B2:C3","Sheet2!A1:B2","D10:E11,F1:G2,H3:I4"],v=Math.floor(Math.random()*S.length),I=S[v];r.current&&(r.current.innerHTML=I)});return document.addEventListener("click",c),()=>{document.removeEventListener("click",c),_.unsubscribe()}}e(((m=r.current)==null?void 0:m.innerHTML)||"")},[n]);function c(m){var v,I,b;if(((v=m.target)==null?void 0:v.closest('[data-range-selector="true"]'))||m.target===r.current)return;const g=(I=m.target)==null?void 0:I.closest(`.${ze.rangeSelector}`);(g==null?void 0:g.querySelector(`.${ze.rangeSelectorEditor}`))!==r.current&&(o(!1),(b=r.current)==null||b.blur())}function d(m){m.stopPropagation(),m.key==="Enter"&&(m.preventDefault(),m.currentTarget.blur(),o(!1))}function u(){o(!0)}function h(){var m;if(!n){(m=r.current)==null||m.focus();return}o(!n)}return p.jsxs("div",{className:n?`${ze.rangeSelector} ${ze.rangeSelectorActive}`:ze.rangeSelector,children:[p.jsx("div",{ref:r,className:ze.rangeSelectorEditor,contentEditable:!0,"data-placeholder":s.t("rangeSelector.placeholder"),onKeyDown:d,onFocus:u}),p.jsx(ne.Tooltip,{title:s.t("rangeSelector.tooltip"),placement:"bottom",children:p.jsx("button",{className:ze.rangeSelectorIcon,onClick:h,children:p.jsx(Js,{})})})]})}const Gn={零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Zt=["零","一","二","三","四","五","六","七","八","九"],mo=["","万","亿","万亿","亿亿"],qs=["","十","百","千"],_o={十:{value:10,secUnit:!1},百:{value:100,secUnit:!1},千:{value:1e3,secUnit:!1},万:{value:1e4,secUnit:!0},亿:{value:1e8,secUnit:!0}};function Oe(i){if(!i)return 0;let e=0,t=0,n=0,o=!1;const r=i.split("");for(let s=0;s<r.length;s++){const a=Gn[r[s]];if(typeof a<"u")n=a,s===r.length-1&&(t+=n);else{const c=_o[r[s]],d=c.value;o=c.secUnit,o?(t=(t+n)*d,e+=t,t=0):t+=n*d,n=0}}return e+t}function ea(i){let e="",t="",n=0,o=!0;for(;i>0;){const r=i%10;r===0?o||(o=!0,t=Zt[r]+t):(o=!1,e=Zt[r],e+=qs[n],t=e+t),n++,i=Math.floor(i/10)}return t}function ta(i){let e=0,t="",n="",o=!1;if(i===0)return Zt[0];for(;i>0;){const r=i%1e4;o&&(n=Zt[0]+n),t=ea(r),t+=r!==0?mo[e]:mo[0],n=t+n,o=r<1e3&&r>0,i=Math.floor(i/1e4),e++}return n}function na(i){if(!i)return!1;let e=!0;if(i)if(i.length===1)i==="日"||i in Gn?e=!0:e=!1;else{const t=i.split("");for(let n=0;n<t.length;n++)if(!(t[n]in Gn||t[n]in _o)){e=!1;break}}return e}function Gt(i){if(!i)return{isExtendNumber:!1};const e=/0|([1-9]+[0-9]*)/g,t=e.test(i);if(t){const n=i.match(e);if(n&&n.length>0){const o=n[n.length-1],r=i.lastIndexOf(o),s=i.substr(0,r),a=i.substr(r+o.length);return{isExtendNumber:!0,matchTxt:Number(o),beforeTxt:s,afterTxt:a}}return{isExtendNumber:!1}}return{isExtendNumber:t}}function ia(i){let e;return i.length===2&&(i==="周一"||i==="周二"||i==="周三"||i==="周四"||i==="周五"||i==="周六"||i==="周日")?e=!0:e=!1,e}function oa(i){let e;return i.length===3&&(i==="星期一"||i==="星期二"||i==="星期三"||i==="星期四"||i==="星期五"||i==="星期六"||i==="星期日")?e=!0:e=!1,e}function ra(i,e){let t=0;for(let n=0;n<i.length&&i[n]<e;n++)t++;return t}function Ct(i){let e=!0;const t=i[1]-i[0];for(let n=1;n<i.length;n++)if(i[n]-i[n-1]!==t){e=!1;break}return e}function sa(i,e,t){const n=[],o=Math.floor(e/i),r=e%i;let s=0;if(o>0){for(let a=0;a<o;a++)for(let c=0;c<t.length;c++)n[t[c]+a*i]=s,s++;for(let a=0;a<t.length&&t[a]<r;a++)n[t[a]+i*o]=s,s++}else for(let a=0;a<t.length&&t[a]<r;a++)n[t[a]]=s,s++;return n}function Xe(i,e){const t=[];for(let n=1;n<=e;n++){const o=(n-1)%i.length,r=l.Tools.deepClone(i[o]);t.push(r)}return t}function aa(i,e){var n;const t=[];for(let o=1;o<=e;o++){const r=(o-1)%i.length,s={s:(n=i[r])==null?void 0:n.s};t.push(s)}return t}function la(i){let e=!0;const t=i[1]/i[0];for(let n=1;n<i.length;n++)if(i[n]/i[n-1]!==t){e=!1;break}return e}function ca(i){const e=[];for(let t=1;t<=i;t++)e.push(t);return e}function da(i,e,t){var r,s,a,c,d,u,h;const n=[],o=[];for(let m=0;m<i.length;m++)o.push(Number((r=i[m])==null?void 0:r.v));if(i.length>2&&la(o))for(let m=1;m<=e;m++){const _=(m-1)%i.length,g=l.Tools.deepClone(i[_]);let S;t===l.Direction.DOWN||t===l.Direction.RIGHT?S=Number((s=i[i.length-1])==null?void 0:s.v)*(Number((a=i[1])==null?void 0:a.v)/Number((c=i[0])==null?void 0:c.v))**m:(t===l.Direction.UP||t===l.Direction.LEFT)&&(S=Number((d=i[0])==null?void 0:d.v)/(Number((u=i[1])==null?void 0:u.v)/Number((h=i[0])==null?void 0:h.v))**m),g&&(g.v=S,n.push(g))}else{const m=ca(i.length);for(let _=1;_<=e;_++){const g=(_-1)%i.length,S=l.Tools.deepClone(i[g]);let v;t===l.Direction.DOWN||t===l.Direction.RIGHT?v=So(i.length+_,o,m):v=So(1-_,o,m),S&&(S.v=v,n.push(S))}}return n}function So(i,e,t){function n(u){let h=0;for(let m=0;m<u.length;m++)h+=u[m];return h/u.length}const o=n(t),r=n(e);let s=0,a=0;for(let u=0;u<t.length;u++)s+=(t[u]-o)*(e[u]-r),a+=(t[u]-o)*(t[u]-o);let c;a===0?c=1:c=s/a;const d=r-c*o;return Math.round((d+c*i)*1e5)/1e5}function go(i,e,t){var r;const n=[],o=/0|([1-9]+[0-9]*)/g;for(let s=1;s<=e;s++){const a=(s-1)%i.length,c=l.Tools.deepClone(i[a]),d=`${(r=i[i.length-1])==null?void 0:r.v}`,u=d==null?void 0:d.match(o),h=u==null?void 0:u[u.length-1],m=Math.abs(Number(h)+t*s);if(!d||!h)continue;const _=d.lastIndexOf(h),g=d.substr(0,_)+m.toString()+d.substr(_+h.length);c&&(c.v=g,n.push(c))}return n}function nt(i,e,t,n=0){var a,c;const o=[["日","一","二","三","四","五","六"],["周日","周一","周二","周三","周四","周五","周六"],["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]];if(n>=o.length)return[];const r=o[n],s=[];for(let d=1;d<=e;d++){const u=(d-1)%i.length,h=l.Tools.deepClone(i[u]);let m=0;if(((a=i[i.length-1])==null?void 0:a.v)===r[0])m=7+t*d;else{const g=`${(c=i[i.length-1])==null?void 0:c.v}`;if(g){const S=g.substr(g.length-1,1);m=Oe(S)+t*d}}m<0&&(m=Math.ceil(Math.abs(m)/7)*7+m);const _=m%7;h&&(h.v=r[_],s.push(h))}return s}function fo(i,e,t){var o;const n=[];for(let r=1;r<=e;r++){const s=(r-1)%i.length,a=l.Tools.deepClone(i[s]),c=`${(o=i[i.length-1])==null?void 0:o.v}`,d=Oe(c)+t*r;let u;d<=0?u="零":u=ta(d),a&&(a.v=u,n.push(a))}return n}const It={enWeek1:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],enWeek2:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],enMonth1:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],enMonth2:["January","February","March","April","May","June","July","August","September","October","November","December"],chnMonth1:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],chnMonth2:["正月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"],chHour1:["子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥"],chHour2:["子时","丑时","寅时","卯时","辰时","巳时","午时","未时","申时","酉时","戌时","亥时"],chYear1:["甲","乙","丙","丁","戊","己","庚","辛","壬","癸"],chSeason1:["春","夏","秋","冬"],chSeason2:["春季","夏季","秋季","冬季"]};function ua(i){let e=!1;return Object.keys(It).forEach(t=>{It[t].includes(i)&&(e=!0)}),e}function Kn(i){let e="";const t=[];return Object.keys(It).forEach(n=>{It[n].includes(i)&&(e=n,t.push(...It[n]))}),{name:e,series:t}}function po(i,e,t,n){var s;const o=n.length,r=[];for(let a=1;a<=e;a++){const c=(a-1)%i.length,d=l.Tools.deepClone(i[c]),u=`${(s=i[i.length-1])==null?void 0:s.v}`,m=(n.indexOf(u)+t*a)%o;d&&(d.v=n[m],r.push(d))}return r}function ha(i,e){const t=[];let n;if(e.startRow<i.startRow)n=l.Direction.UP;else if(e.endRow>i.endRow)n=l.Direction.DOWN;else if(e.startColumn<i.startColumn)n=l.Direction.LEFT;else if(e.endColumn>i.endColumn)n=l.Direction.RIGHT;else return[];if(n===l.Direction.DOWN||n===l.Direction.UP){const o=i.endRow-i.startRow+1,r=e.endRow-e.startRow+1,s=r/o,a=r%o,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.DOWN){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow+(d+1)*o,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow+(s+1)*o,col:i.startColumn},relativeRange:{startRow:0,startColumn:0,endRow:a-1,endColumn:i.endColumn-i.startColumn}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow-(d+1)*o,col:i.startColumn},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow-(s+1)*o,col:i.startColumn},relativeRange:{startRow:o-a,endRow:o-1,startColumn:0,endColumn:i.endColumn-i.startColumn}})}}if(n===l.Direction.RIGHT||n===l.Direction.LEFT){const o=i.endColumn-i.startColumn+1,r=e.endColumn-e.startColumn+1,s=r/o,a=r%o,c={startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:i.endColumn-i.startColumn};if(n===l.Direction.RIGHT){for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(d+1)*o},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn+(s+1)*o},relativeRange:{startRow:0,startColumn:0,endRow:i.endRow-i.startRow,endColumn:a-1}})}else{for(let d=0;d<s;d++)t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(d+1)*o},relativeRange:c});a>0&&t.push({repeatStartCell:{row:i.startRow,col:i.startColumn-(s+1)*o},relativeRange:{startRow:0,startColumn:o-a,endRow:i.endRow-i.startRow,endColumn:o-1}})}}return t}var ie=(i=>(i.NUMBER="number",i.DATE="date",i.EXTEND_NUMBER="extendNumber",i.CHN_NUMBER="chnNumber",i.CHN_WEEK2="chnWeek2",i.CHN_WEEK3="chnWeek3",i.LOOP_SERIES="loopSeries",i.FORMULA="formula",i.OTHER="other",i))(ie||{}),z=(i=>(i.COPY="0",i.SERIES="1",i.ONLY_FORMAT="2",i.NO_FORMAT="3",i))(z||{});const ma={type:ie.NUMBER,priority:1e3,match:i=>typeof(i==null?void 0:i.v)=="number"||!isNaN(Number(i==null?void 0:i.v)),isContinue:(i,e)=>i.type===ie.NUMBER,applyFunctions:{[z.SERIES]:(i,e,t)=>{const{data:n}=i;return(t===l.Direction.LEFT||t===l.Direction.UP)&&n.reverse(),da(n,e,t)}}},vo={type:ie.OTHER,priority:0,match:()=>!0,isContinue:(i,e)=>i.type===ie.OTHER},_a={type:ie.EXTEND_NUMBER,priority:900,match:i=>Gt(`${i==null?void 0:i.v}`||"").isExtendNumber,isContinue:(i,e)=>{var t;if(i.type===ie.EXTEND_NUMBER){const{beforeTxt:n,afterTxt:o}=Gt(`${(t=i.cellData)==null?void 0:t.v}`||""),{beforeTxt:r,afterTxt:s}=Gt(`${e==null?void 0:e.v}`||"");if(n===r&&o===s)return!0}return!1},applyFunctions:{[z.SERIES]:(i,e,t)=>{var s;const{data:n}=i;let o;if(n.length===1)return o=t===l.Direction.DOWN||t===l.Direction.RIGHT?1:-1,go(n,e,o);const r=[];for(let a=0;a<n.length;a++){const c=`${(s=n[a])==null?void 0:s.v}`;c&&r.push(Number(Gt(c).matchTxt))}return(t===l.Direction.UP||t===l.Direction.LEFT)&&(n.reverse(),r.reverse()),Ct(r)?(o=r[1]-r[0],go(n,e,o)):Xe(n,e)}}},Sa={type:ie.CHN_NUMBER,priority:830,match:i=>!!na(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===ie.CHN_NUMBER,applyFunctions:{[z.SERIES]:(i,e,t)=>{var c,d,u;const{data:n}=i,o=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){const h=`${(c=n[0])==null?void 0:c.v}`;let m;return o?m=-1:m=1,h&&(h==="日"||Oe(h)<7)?nt(n,e,m):fo(n,e,m)}let r=!1;for(let h=0;h<n.length;h++)if(((d=n[h])==null?void 0:d.v)==="日"){r=!0;break}const s=[];let a=0;for(let h=0;h<n.length;h++){const m=`${(u=n[h])==null?void 0:u.v}`;m==="日"?h===0?s.push(0):(a++,s.push(a*7)):r&&Oe(m)>0&&Oe(m)<7?s.push(Oe(m)+a*7):s.push(Oe(m))}if(o&&(n.reverse(),s.reverse()),Ct(s)){if(r||s[s.length-1]<6&&s[0]>0||s[0]<6&&s[s.length-1]>0){const m=s[1]-s[0];return nt(n,e,m)}const h=s[1]-s[0];return fo(n,e,h)}return Xe(n,e)}}},ga={type:ie.CHN_WEEK2,priority:820,match:i=>!!ia(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===ie.CHN_WEEK2,applyFunctions:{[z.SERIES]:(i,e,t)=>{var a;const{data:n}=i,o=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,nt(n,e,c,1)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`,u=d==null?void 0:d.substr(d.length-1,1);d==="周日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Oe(u)+s*7)}if(o&&(n.reverse(),r.reverse()),Ct(r)){const c=r[1]-r[0];return nt(n,e,c,1)}return Xe(n,e)}}},fa={type:ie.CHN_WEEK3,priority:810,match:i=>oa(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>i.type===ie.CHN_WEEK3,applyFunctions:{[z.SERIES]:(i,e,t)=>{var a;const{data:n}=i,o=t===l.Direction.LEFT||t===l.Direction.UP;if(n.length===1){let c;return o?c=-1:c=1,nt(n,e,c,2)}const r=[];let s=0;for(let c=0;c<n.length;c++){const d=`${(a=n[c])==null?void 0:a.v}`;if(d){const u=d.substr(d.length-1,1);d==="星期日"?c===0?r.push(0):(s++,r.push(s*7)):r.push(Oe(u)+s*7)}}if(o&&(n.reverse(),r.reverse()),Ct(r)){const c=r[1]-r[0];return nt(n,e,c,2)}return Xe(n,e)}}},pa={type:ie.LOOP_SERIES,priority:800,match:i=>ua(`${i==null?void 0:i.v}`||""),isContinue:(i,e)=>{var t;return i.type===ie.LOOP_SERIES?Kn(`${(t=i.cellData)==null?void 0:t.v}`||"").name===Kn(`${e==null?void 0:e.v}`||"").name:!1},applyFunctions:{[z.SERIES]:(i,e,t)=>{var c,d;const{data:n}=i,o=t===l.Direction.LEFT||t===l.Direction.UP,{series:r}=Kn(`${(c=n[0])==null?void 0:c.v}`||"");if(n.length===1){let u;return o?u=-1:u=1,po(n,e,u,r)}const s=[];let a=0;for(let u=0;u<n.length;u++){const h=`${(d=n[u])==null?void 0:d.v}`;h&&(h===r[0]?u===0?s.push(0):(a++,s.push(a*r.length)):s.push(r.indexOf(h)+a*7))}if(o&&(n.reverse(),s.reverse()),Ct(s)){const u=s[1]-s[0];return po(n,e,u,r)}return Xe(n,e)}}};var va=Object.defineProperty,Ca=Object.getOwnPropertyDescriptor,Ia=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ca(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&va(e,t,o),o},Jn=(i,e)=>(t,n)=>e(t,n,i);P.AutoFillService=class extends l.Disposable{constructor(t,n,o){super();C(this,"_rules",[]);C(this,"_hooks",[]);C(this,"_applyType$",new B.BehaviorSubject(z.SERIES));C(this,"_isFillingStyle",!0);C(this,"_sourceRange",null);C(this,"_destRange",null);C(this,"_applyRange",null);C(this,"applyType$",this._applyType$.asObservable());C(this,"_menu$",new B.BehaviorSubject([{label:"autoFill.copy",value:z.COPY,disable:!1},{label:"autoFill.series",value:z.SERIES,disable:!1},{label:"autoFill.formatOnly",value:z.ONLY_FORMAT,disable:!1},{label:"autoFill.noFormat",value:z.NO_FORMAT,disable:!1}]));C(this,"menu$",this._menu$.asObservable());this._sheetInterceptorService=t,this._univerInstanceService=n,this._selectionManagerService=o,this._init()}_init(){this._rules=[ma,_a,Sa,ga,fa,pa,vo].sort((t,n)=>n.priority-t.priority),this._isFillingStyle=!0}addHook(t){if(this._hooks.find(n=>n.hookName===t.hookName))throw new Error(`Add hook failed, hook name '${t.hookName}' already exist!`);return this._hooks.push(t),l.toDisposable(()=>{const n=this._hooks.findIndex(o=>o===t);n>-1&&this._hooks.splice(n,1)})}registerRule(t){if(this._rules.find(o=>o.type===t.type))throw new Error(`Registry rule failed, type '${t.type}' already exist!`);const n=this._rules.findIndex(o=>o.priority<t.priority);this._rules.splice(n===-1?this._rules.length:n,0,t)}getRules(){return this._rules}getHooks(){return this._hooks}getApplyType(){return this._applyType$.getValue()}setApplyType(t){this._applyType$.next(t)}isFillingStyle(){return this._isFillingStyle}setFillingStyle(t){this._isFillingStyle=t}setRanges(t,n,o){this._sourceRange=n,this._destRange=t,this._applyRange=o}getRanges(){return{sourceRange:this._sourceRange,destRange:this._destRange,applyRange:this._applyRange}}setDisableApplyType(t,n){this._menu$.next(this._menu$.getValue().map(o=>o.value===t?{...o,disable:n}:o))}},P.AutoFillService=Ia([l.OnLifecycle(l.LifecycleStages.Rendered,P.AutoFillService),Jn(0,L.Inject(f.SheetInterceptorService)),Jn(1,L.Inject(l.IUniverInstanceService)),Jn(2,L.Inject(f.SelectionManagerService))],P.AutoFillService);const Mt=L.createIdentifier("univer.auto-fill-service");var Ma=Object.defineProperty,ba=Object.getOwnPropertyDescriptor,Ra=(i,e,t,n)=>{for(var o=n>1?void 0:n?ba(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Ma(e,t,o),o},bt=(i,e)=>(t,n)=>e(t,n,i);P.AutoFillController=class extends l.Disposable{constructor(t,n,o,r,s){super();C(this,"_direction",null);C(this,"_beforeApplyData",[]);C(this,"_applyType",z.SERIES);C(this,"_hasFillingStyle",!0);C(this,"_copyData",[]);this._univerInstanceService=t,this._selectionRenderService=n,this._commandService=o,this._autoFillService=r,this._selectionManagerService=s,this._init()}_init(){this._onSelectionControlFillChanged(),this._onApplyTypeChanged(),[Vt,Ft].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_handleDbClickFill(t){const n=this._detectFillRange(t);n.endRow<=t.endRow||this._handleFill(t,n)}_detectFillRange(t){var m,_,g,S,v,I;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=t,a=(m=this._univerInstanceService.getCurrentUniverSheetInstance())==null?void 0:m.getActiveSheet();if(!a)return t;const c=a.getCellMatrix(),d=a.getMaxRows()-1,u=a.getMaxColumns()-1;let h=o;if(r>0&&((_=c.getValue(n,r-1))==null?void 0:_.v)!=null){let b=n;for(;((g=c.getValue(b,r-1))==null?void 0:g.v)!=null&&b<d;)b+=1;h=b}else if(s<u&&((S=c.getValue(o,s+1))==null?void 0:S.v)!=null){let b=n;for(;((v=c.getValue(b,s+1))==null?void 0:v.v)!=null&&b<d;)b++;h=b}for(let b=o+1;b<=h;b++)for(let R=r;R<=s;R++)if(((I=c.getValue(b,R))==null?void 0:I.v)!=null){h=b-1;break}return{startColumn:r,endColumn:s,startRow:n,endRow:h}}_handleFill(t,n){if(!(t.startColumn===n.startColumn&&t.startRow===n.startRow&&t.endColumn===n.endColumn&&t.endRow===n.endRow)){if(n.endColumn<t.endColumn&&n.endColumn>t.startColumn){this._commandService.executeCommand(Ft.id,{clearRange:{startRow:n.startRow,endRow:n.endRow,startColumn:n.endColumn+1,endColumn:t.endColumn},selectionRange:n});return}if(n.endRow<t.endRow&&n.endRow>t.startRow){this._commandService.executeCommand(Ft.id,{clearRange:{startRow:n.endRow+1,endRow:t.endRow,startColumn:n.startColumn,endColumn:n.endColumn},selectionRange:n});return}this._presetAndCacheData(t,n)}}_onSelectionControlFillChanged(){const t=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{t.dispose();const n=this._selectionManagerService.getCurrent();if((n==null?void 0:n.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(r=>{t.add(l.toDisposable(r.selectionFilled$.subscribe(s=>{if(s==null)return;const a={startColumn:r.model.startColumn,endColumn:r.model.endColumn,startRow:r.model.startRow,endRow:r.model.endRow},c={startColumn:s.startColumn,endColumn:s.endColumn,startRow:s.startRow,endRow:s.endRow};this._handleFill(a,c)}))),t.add(l.toDisposable(r.fillControl.onDblclickObserver.add(()=>{const s={startColumn:r.model.startColumn,endColumn:r.model.endColumn,startRow:r.model.startRow,endRow:r.model.endRow};this._handleDbClickFill(s)})))})})))}_onApplyTypeChanged(){this.disposeWithMe(l.toDisposable(this._autoFillService.applyType$.subscribe(t=>{t===z.NO_FORMAT?(this._applyType=z.SERIES,this._hasFillingStyle=!1):(this._applyType=t||z.SERIES,this._hasFillingStyle=!0),this._fillData()})))}_getApplyData(t,n,o,r,s,a=!0){const c=[],d=Math.floor(o/n),u=o%n,h=this._autoFillService.getRules();if(!a&&s===z.ONLY_FORMAT)return console.error("ERROR: only format can not be applied when hasStyle is false"),[];const m={};h.forEach(_=>{m[_.type]=[]}),h.forEach(_=>{const{type:g,applyFunctions:S={}}=_,v=t[g];v&&v.forEach(I=>{const b=ra(I.index,u),R=I.index.length*d+b,T=this._applyFunctions(I,R,r,s,S,t),E=sa(n,o,I.index);m[g].push({data:T,index:E})})});for(let _=0;_<o;_++)h.forEach(g=>{const{type:S}=g,v=m[S];for(let I=0;I<v.length;I++)_ in v[I].index&&c.push(v[I].data[v[I].index[_]])});return c}_applyFunctions(t,n,o,r,s,a){const{data:c}=t,d=o===l.Direction.UP||o===l.Direction.LEFT;if(r===z.COPY){const u=s==null?void 0:s[z.COPY];return u?u(t,n,o,a):(d&&c.reverse(),Xe(c,n))}if(r===z.SERIES){const u=s==null?void 0:s[z.SERIES];return u?u(t,n,o,a):(d&&c.reverse(),s!=null&&s[z.COPY]?s[z.COPY](t,n,o,a):Xe(c,n))}if(r===z.ONLY_FORMAT){const u=s==null?void 0:s[z.ONLY_FORMAT];return u?u(t,n,o,a):aa(c,n)}}_getCopyData(t,n){const{startRow:o,startColumn:r,endRow:s,endColumn:a}=t,c=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),d=this._autoFillService.getRules(),u=[],h=n===l.Direction.DOWN||n===l.Direction.UP;let m,_,g,S;h?(m=r,_=a,g=o,S=s):(m=o,_=s,g=r,S=a);for(let v=m;v<=_;v++){const I=this._getEmptyCopyDataPiece(),b={type:void 0,cellData:void 0};for(let R=g;R<=S;R++){let T;h?T=c.getValue(R,v):T=c.getValue(v,R);const{type:E,isContinue:O}=d.find(y=>y.match(T))||vo;if(O(b,T)){const y=I[E],x=y[y.length-1];x.data.push(T),x.index.push(R-g)}else{const y=I[E];y?y.push({data:[T],index:[R-g]}):I[E]=[{data:[T],index:[R-g]}]}b.type=E,b.cellData=T}u.push(I)}return u}_getEmptyCopyDataPiece(){const t={};return this._autoFillService.getRules().forEach(n=>{t[n.type]=[]}),t}_getMergeApplyData(t,n,o,r){const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),a=[];for(let c=t.startRow;c<=t.endRow;c++)for(let d=t.startColumn;d<=t.endColumn;d++){const{isMergedMainCell:u,startRow:h,startColumn:m,endRow:_,endColumn:g}=w.getCellInfoInMergeData(c,d,s);if(u){if(o===l.Direction.DOWN){let S=h+r,v=_+r;for(;v<=n.endRow;)a.push({startRow:S,startColumn:m,endRow:v,endColumn:g}),S+=r,v+=r}else if(o===l.Direction.UP){let S=h-r,v=_-r;for(;S>=n.startRow;)a.push({startRow:S,startColumn:m,endRow:v,endColumn:g}),S-=r,v-=r}else if(o===l.Direction.RIGHT){let S=m+r,v=g+r;for(;v<=n.endColumn;)a.push({startRow:h,startColumn:S,endRow:_,endColumn:v}),S+=r,v+=r}else if(o===l.Direction.LEFT){const S=m-r,v=g-r;for(;S>=n.startColumn;)a.push({startRow:h,startColumn:S,endRow:_,endColumn:v})}}}return a}_presetAndCacheData(t,n){const o={startRow:n.startRow,endRow:n.endRow,startColumn:n.startColumn,endColumn:n.endColumn};let r=null;if(n.startRow<t.startRow)r=l.Direction.UP,o.endRow=t.startRow-1;else if(n.endRow>t.endRow)r=l.Direction.DOWN,o.startRow=t.endRow+1;else if(n.startColumn<t.startColumn)r=l.Direction.LEFT,o.endColumn=t.startColumn-1;else if(n.endColumn>t.endColumn)r=l.Direction.RIGHT,o.startColumn=t.endColumn+1;else return;this._direction=r;const s=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getCellMatrix(),a=[];for(let c=o.startRow;c<=o.endRow;c++){const d=[];for(let u=o.startColumn;u<=o.endColumn;u++)d.push(l.Tools.deepClone(s.getValue(c,u)));a.push(d)}this._beforeApplyData=a,this._autoFillService.setRanges(n,t,o),this._copyData=this._getCopyData(t,r),this._hasSeries(this._copyData)?(this._autoFillService.setDisableApplyType(z.SERIES,!1),this._autoFillService.setApplyType(z.SERIES)):(this._autoFillService.setDisableApplyType(z.SERIES,!0),this._autoFillService.setApplyType(z.COPY))}_fillData(){const{destRange:t,sourceRange:n,applyRange:o}=this._autoFillService.getRanges(),r=this._applyType,s=this._hasFillingStyle,a=this._direction;if(!t||!n||!o||a==null)return;const{startRow:c,startColumn:d,endRow:u,endColumn:h}=n,{startRow:m,startColumn:_,endRow:g,endColumn:S}=o,v=this._copyData;let I;a===l.Direction.DOWN||a===l.Direction.UP?I=u-c+1:I=h-d+1;const b=[];if(a===l.Direction.DOWN||a===l.Direction.UP){const A=g-m+1,H=[];for(let D=_;D<=S;D++){const N=v[D-_],U=this._getApplyData(N,I,A,a,r,s);H.push(U)}for(let D=0;D<H[0].length;D++){const N=[];for(let U=0;U<H.length;U++)N.push({v:null,s:null,...this._beforeApplyData[D][U],...H[U][D]});b.push(N)}}else{const A=S-_+1;for(let H=m;H<=g;H++){const D=v[H-m],N=this._getApplyData(D,I,A,a,r,s),U=[];for(let V=0;V<N.length;V++)U.push({v:null,s:null,...this._beforeApplyData[H-m][V],...N[V]});b.push(U)}}let R;const T=this._univerInstanceService.getCurrentUniverSheetInstance().getStyles();s?(R=this._getMergeApplyData(n,t,a,I),b.forEach(A=>{A.forEach(H=>{H&&T&&T&&(H.s=T.getStyleByCell(H))})})):b.forEach((A,H)=>{A.forEach((D,N)=>{D&&T&&(D.s=T.getStyleByCell(this._beforeApplyData[H][N])||null)})});const E=this._autoFillService.getHooks(),O=[],y=[],x=this._hasFillingStyle?r:z.NO_FORMAT;E.forEach(A=>{const{hook:H}=A,{redos:D,undos:N}=H==null?void 0:H[x](n,o);O.push(...D),y.push(...N)}),this._commandService.executeCommand(Vt.id,{selectionRange:t,applyRange:o,applyDatas:b,unitId:this._univerInstanceService.getCurrentUniverSheetInstance().getUnitId(),subUnitId:this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),extendMutations:{undo:y,redo:O},applyMergeRanges:R})}_hasSeries(t){return t.some(n=>Object.keys(n).some(r=>{var s;return!!((s=n[r])!=null&&s.length&&![ie.OTHER,ie.FORMULA].includes(r))}))}},P.AutoFillController=Ra([l.OnLifecycle(l.LifecycleStages.Steady,P.AutoFillController),bt(0,l.IUniverInstanceService),bt(1,se),bt(2,l.ICommandService),bt(3,Mt),bt(4,L.Inject(f.SelectionManagerService))],P.AutoFillController);const Qn={type:l.CommandType.COMMAND,id:"sheet.command.set-range-bold",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(G.SetInlineFormatBoldCommand.id):e.executeCommand(f.SetBoldCommand.id)}},qn={type:l.CommandType.COMMAND,id:"sheet.command.set-range-italic",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(G.SetInlineFormatItalicCommand.id):e.executeCommand(f.SetItalicCommand.id)}},ei={type:l.CommandType.COMMAND,id:"sheet.command.set-range-underline",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(G.SetInlineFormatUnderlineCommand.id):e.executeCommand(f.SetUnderlineCommand.id)}},ti={type:l.CommandType.COMMAND,id:"sheet.command.set-range-stroke",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(G.SetInlineFormatStrikethroughCommand.id):e.executeCommand(f.SetStrikeThroughCommand.id)}},Co={type:l.CommandType.COMMAND,id:"sheet.command.set-range-subscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(G.SetInlineFormatSubscriptCommand.id):!1}},Io={type:l.CommandType.COMMAND,id:"sheet.command.set-range-superscript",handler:async i=>{const e=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?e.executeCommand(G.SetInlineFormatSuperscriptCommand.id):!1}},Mo={type:l.CommandType.COMMAND,id:"sheet.command.set-range-fontsize",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(G.SetInlineFormatFontSizeCommand.id,e):t.executeCommand(f.SetFontSizeCommand.id,e)}},bo={type:l.CommandType.COMMAND,id:"sheet.command.set-range-font-family",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(G.SetInlineFormatFontFamilyCommand.id,e):t.executeCommand(f.SetFontFamilyCommand.id,e)}},Kt={type:l.CommandType.COMMAND,id:"sheet.command.set-range-text-color",handler:async(i,e)=>{const t=i.get(l.ICommandService);return i.get(l.IContextService).getContextValue(l.FOCUSING_EDITOR)?t.executeCommand(G.SetInlineFormatTextColorCommand.id,e):t.executeCommand(f.SetTextColorCommand.id,e)}};function Ro(i,e){return e.some(t=>wa(i,t))}function wa(i,e){const{startRow:t,startColumn:n,endColumn:o,endRow:r}=e,s=i.getMatrixWithMergedCells(t,n,r,o);let a=!1;return s.forValue((c,d,u)=>{if(u&&(c!==t||d!==n)&&i.cellHasValue(u))return a=!0,!1}),a}function wo(i,e,t,n){const o=[],r=[],s=t.getSheetId();return n.forEach(a=>{const c=Ta(t,a),d={unitId:e,subUnitId:s,cellValue:c.getData()},u=f.SetRangeValuesUndoMutationFactory(i,d);o.push({id:f.SetRangeValuesMutation.id,params:u}),r.push({id:f.SetRangeValuesMutation.id,params:d})}),{undos:o,redos:r}}function Ta(i,e){const{startRow:t,startColumn:n,endColumn:o,endRow:r}=e,s=i.getMatrixWithMergedCells(t,n,r,o),a=new l.ObjectMatrix;return s.forValue((c,d,u)=>{u&&(c!==t||d!==n)&&a.setValue(c,d,null)}),a}var Ea=Object.defineProperty,Oa=Object.getOwnPropertyDescriptor,ya=(i,e,t,n)=>{for(var o=n>1?void 0:n?Oa(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Ea(e,t,o),o},ni=(i,e)=>(t,n)=>e(t,n,i),Se=(i=>(i[i.OFF=0]="OFF",i[i.ONCE=1]="ONCE",i[i.INFINITE=2]="INFINITE",i))(Se||{});const it=L.createIdentifier("univer.format-painter-service");let ii=class extends l.Disposable{constructor(e,t,n){super();C(this,"status$");C(this,"_selectionFormat");C(this,"_markId",null);C(this,"_status$");this._selectionManagerService=e,this._univerInstanceService=t,this._markSelectionService=n,this._status$=new B.BehaviorSubject(0),this.status$=this._status$.asObservable(),this._selectionFormat={styles:new l.ObjectMatrix,merges:[]}}setStatus(e){e!==0&&this._getSelectionRangeFormat(),this._updateRangeMark(e),this._status$.next(e)}getStatus(){return this._status$.getValue()}_updateRangeMark(e){if(this._markSelectionService.removeAllShapes(),this._markId=null,e!==0){const t=this._selectionManagerService.getLast();if(t){const n=this._selectionManagerService.createCopyPasteSelection();this._markId=this._markSelectionService.addShape({...t,style:n})}}}_getSelectionRangeFormat(){const e=this._selectionManagerService.getLast(),t=e==null?void 0:e.range;if(!t)return;const{startRow:n,endRow:o,startColumn:r,endColumn:s}=t,a=this._univerInstanceService.getCurrentUniverSheetInstance(),d=(a==null?void 0:a.getActiveSheet()).getCellMatrix(),u=this._univerInstanceService.getCurrentUniverSheetInstance().getActiveSheet().getMergeData(),h=a.getStyles(),m=new l.ObjectMatrix;for(let _=n;_<=o;_++)for(let g=r;g<=s;g++){const S=d.getValue(_,g);m.setValue(_,g,h.getStyleByCell(S)||{});const{isMergedMainCell:v,...I}=w.getCellInfoInMergeData(_,g,u);v&&this._selectionFormat.merges.push({startRow:I.startRow,startColumn:I.startColumn,endRow:I.endRow,endColumn:I.endColumn})}this._selectionFormat.styles=m}getSelectionFormat(){return this._selectionFormat}};ii=ya([ni(0,L.Inject(f.SelectionManagerService)),ni(1,l.IUniverInstanceService),ni(2,zt)],ii);const oi={id:"sheet.operation.set-format-painter",type:l.CommandType.OPERATION,handler:(i,e)=>e?(i.get(it).setStatus(e.status),!0):!1},To={type:l.CommandType.COMMAND,id:"sheet.command.set-infinite-format-painter",handler:async i=>{const t=i.get(it).getStatus();let n;return t!==Se.OFF?n=Se.OFF:n=Se.INFINITE,i.get(l.ICommandService).executeCommand(oi.id,{status:n})}},ri={type:l.CommandType.COMMAND,id:"sheet.command.set-once-format-painter",handler:async i=>{const t=i.get(it).getStatus();let n;return t!==Se.OFF?n=Se.OFF:n=Se.ONCE,i.get(l.ICommandService).executeCommand(oi.id,{status:n})}},Eo={type:l.CommandType.COMMAND,id:"sheet.command.apply-format-painter",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),o=i.get(l.IUniverInstanceService),r=i.get(f.SelectionManagerService),s=i.get(f.SheetInterceptorService),{styleValues:a,styleRange:c,mergeRanges:d,unitId:u=o.getCurrentUniverSheetInstance().getUnitId(),subUnitId:h=o.getCurrentUniverSheetInstance().getActiveSheet().getSheetId()}=e,m=c?[c]:r.getSelectionRanges();if(!m||!m.length)return!1;const _=new l.ObjectMatrix;let g;if(l.Tools.isArray(a))for(let V=0;V<m.length;V++){const{startRow:$,startColumn:X,endRow:Q,endColumn:K}=m[V];for(let q=0;q<=Q-$;q++)for(let W=0;W<=K-X;W++)_.setValue(q+$,W+X,a[q][W])}else if(l.isICellData(a))for(let V=0;V<m.length;V++){const{startRow:$,startColumn:X}=m[V];_.setValue($,X,a)}else g=a;const S={subUnitId:h,unitId:u,cellValue:g??_.getMatrix()},v=f.SetRangeValuesUndoMutationFactory(i,S);if(!s.fetchThroughInterceptors(f.INTERCEPTOR_POINT.PERMISSION)(null,{id:f.SetRangeValuesCommand.id,params:S}))return!1;const I=t.syncExecuteCommand(f.SetRangeValuesMutation.id,S),{undos:b,redos:R}=s.onCommandExecute({id:f.SetRangeValuesCommand.id,params:{...S,range:m}}),T=f.getAddMergeMutationRangeByType(d),E=o.getUniverSheetInstance(u).getSheetBySheetId(h),O=[],y=[],x=Ro(E,T),A={unitId:u,subUnitId:h,ranges:T},H={unitId:u,subUnitId:h,ranges:T};O.push({id:f.RemoveWorksheetMergeMutation.id,params:A}),O.push({id:f.AddWorksheetMergeMutation.id,params:H});const D=f.RemoveMergeUndoMutationFactory(i,A),N=f.AddMergeUndoMutationFactory(i,H);if(y.push({id:f.RemoveWorksheetMergeMutation.id,params:N}),y.push({id:f.AddWorksheetMergeMutation.id,params:D}),x){const V=wo(i,u,E,T);O.unshift(...V.redos),y.push(...V.undos)}const U=await l.sequenceExecute([...R,...O],t);return I&&U.result?(n.pushUndoRedo({unitID:u,undoMutations:[{id:f.SetRangeValuesMutation.id,params:v},...b,...y],redoMutations:[{id:f.SetRangeValuesMutation.id,params:S},...R,...O]}),!0):!1}},Jt={type:l.CommandType.COMMAND,id:"sheet.command.set-selection-frozen",handler:async(i,e)=>{const{type:t}=e||{},n=i.get(l.IUniverInstanceService),o=i.get(l.IUndoRedoService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),a=i.get(l.ICommandService),d=i.get(f.SelectionManagerService).getSelections();if(!d)return!1;const u=d[(d==null?void 0:d.length)-1],{range:h}=u,m=i.get(Le),{sheetViewStartRow:_=0,sheetViewStartColumn:g=0}=m.getCurrentScroll()||{};let S,v,I,b;const{startRow:R,startColumn:T,rangeType:E}=h;if(E===l.RANGE_TYPE.ROW||t===1)S=R,I=R-_,v=-1,b=0;else if(E===l.RANGE_TYPE.COLUMN||t===2)S=-1,I=0,v=T,b=T-g;else if(E===l.RANGE_TYPE.NORMAL)S=R,I=R-_,v=T,b=T-g;else return!1;const O={unitId:r,subUnitId:s,startRow:S,startColumn:v,xSplit:b,ySplit:I},y=f.SetFrozenMutationFactory(i,O);return a.syncExecuteCommand(f.SetFrozenMutation.id,O)&&o.pushUndoRedo({unitID:r,undoMutations:[{id:f.SetFrozenMutation.id,params:y}],redoMutations:[{id:f.SetFrozenMutation.id,params:O}]}),!0}},Oo={type:l.CommandType.COMMAND,id:"sheet.command.set-row-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Jt.id,{type:1}),!0)},yo={type:l.CommandType.COMMAND,id:"sheet.command.set-col-frozen",handler:async i=>(i.get(l.ICommandService).executeCommand(Jt.id,{type:2}),!0)},xo={type:l.CommandType.COMMAND,id:"sheet.command.cancel-frozen",handler:async i=>{const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(l.IUndoRedoService),o=t.getCurrentUniverSheetInstance().getUnitId(),r=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId(),s={unitId:o,subUnitId:r,startRow:-1,startColumn:-1,xSplit:0,ySplit:0},a=f.SetFrozenMutationFactory(i,s);return e.syncExecuteCommand(f.SetFrozenMutation.id,s)&&n.pushUndoRedo({unitID:o,undoMutations:[{id:f.SetFrozenMutation.id,params:a}],redoMutations:[{id:f.SetFrozenMutation.id,params:s}]}),!0}},ot="UI_PLUGIN_SHEETS",Qt=`${ot}_COLOR_PICKER_COMPONENT`,Ao={uiPluginSheetsFontFamily:"univer-ui-plugin-sheets-font-family",uiPluginSheetsFontFamilyItem:"univer-ui-plugin-sheets-font-family-item"},xa=i=>{const{value:e}=i,t=F.useDependency(l.LocaleService);return p.jsx("div",{className:Ao.uiPluginSheetsFontFamily,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},Aa=i=>{const{value:e}=i,t=F.useDependency(l.LocaleService);return p.jsx("span",{className:Ao.uiPluginSheetsFontFamilyItem,style:{fontFamily:e},children:t.t(`fontFamily.${(`${e}`??"").replace(/\s/g,"")}`)})},Po=`${ot}_FONT_FAMILY_COMPONENT`,ae=`${ot}_FONT_FAMILY_ITEM_COMPONENT`,Do={uiPluginSheetsFontSize:"univer-ui-plugin-sheets-font-size",uiPluginSheetsFontSizeInput:"univer-ui-plugin-sheets-font-size-input"},Pa=i=>{const{value:e,min:t,max:n,onChange:o}=i,[r,s]=k.useState(Number(e??0)),a=k.useMemo(()=>Number(e??r),[e]);function c(u){u!==null&&s(u)}function d(u){u.stopPropagation(),u.code==="Enter"&&o(r.toString())}return p.jsx("div",{className:Do.uiPluginSheetsFontSize,children:p.jsx(ne.InputNumber,{className:Do.uiPluginSheetsFontSizeInput,value:a,controls:!1,min:t,max:n,onKeyDown:d,onChange:c})})},Ho=`${ot}_FONT_SIZE_COMPONENT`,si=`${ot}_MENU_ITEM_INPUT_COMPONENT`,ai={sheetsUiContextMenuInput:"univer-sheets-ui-context-menu-input",sheetsUiContextMenuInputContainer:"univer-sheets-ui-context-menu-input-container",sheetsUiContextMenuInputNumber:"univer-sheets-ui-context-menu-input-number"},Da=i=>{const{prefix:e,suffix:t,value:n,onChange:o}=i,r=F.useDependency(l.LocaleService),[s,a]=k.useState(),c=u=>{a(u==null?void 0:u.toString()),o((u==null?void 0:u.toString())??"")};k.useEffect(()=>{a(n)},[n]);function d(u){u.key==="Backspace"&&u.stopPropagation()}return p.jsxs("div",{className:ai.sheetsUiContextMenuInput,children:[r.t(e),p.jsx("span",{className:ai.sheetsUiContextMenuInputContainer,onClick:u=>u.stopPropagation(),children:p.jsx(ne.InputNumber,{className:ai.sheetsUiContextMenuInputNumber,value:Number(s),precision:0,onKeyDown:d,onChange:c})}),r.t(t)]})};var ee=(i=>(i.ROW_HEADER_CONTEXT_MENU="rowHeaderContextMenu",i.COL_HEADER_CONTEXT_MENU="colHeaderContextMenu",i.SHEET_BAR="sheetBar",i))(ee||{});function Ha(i){const e=i.get(it);return{id:ri.id,subId:To.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON,icon:"BrushSingle",title:"Format Painter",tooltip:"toolbar.formatPainter",positions:[M.MenuPosition.TOOLBAR_START],activated$:new B.Observable(t=>{let n=!1;const o=e.status$.subscribe(r=>{n=r!==Se.OFF,t.next(n)});return t.next(n),()=>{o.unsubscribe()}})}}function Na(i){const e=i.get(l.ICommandService),t=i.get(f.SheetPermissionService),n=i.get(l.IUniverInstanceService),o=i.get(f.SelectionManagerService),r=n.getCurrentUniverSheetInstance().getUnitId(),s=n.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Qn.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON,icon:"BoldSingle",title:"Set bold",tooltip:"toolbar.bold",positions:[M.MenuPosition.TOOLBAR_START],disabled$:new B.Observable(a=>{var d;const c=(d=t.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new B.Observable(a=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=o.getLast())==null?void 0:g.primary,m=n.getCurrentUniverSheetInstance().getActiveSheet();let _=l.FontWeight.NORMAL;if(h!=null){const S=m.getRange(h.startRow,h.startColumn);_=S==null?void 0:S.getFontWeight()}a.next(_===l.FontWeight.BOLD)});return a.next(!1),c.dispose})}}function La(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:qn.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON,icon:"ItalicSingle",title:"Set italic",tooltip:"toolbar.italic",positions:[M.MenuPosition.TOOLBAR_START],disabled$:new B.Observable(a=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new B.Observable(a=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=n.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let _=l.FontItalic.NORMAL;if(h!=null){const S=m.getRange(h.startRow,h.startColumn);_=S==null?void 0:S.getFontStyle()}a.next(_===l.FontItalic.ITALIC)});return a.next(!1),c.dispose})}}function Ua(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:ei.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON,icon:"UnderlineSingle",title:"Set underline",tooltip:"toolbar.underline",positions:[M.MenuPosition.TOOLBAR_START],disabled$:new B.Observable(a=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new B.Observable(a=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=n.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let _;if(h!=null){const S=m.getRange(h.startRow,h.startColumn);_=S==null?void 0:S.getUnderline()}a.next(!!(_&&_.s))});return a.next(!1),c.dispose})}}function ka(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:ti.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON,icon:"StrikethroughSingle",title:"Set strike through",tooltip:"toolbar.strikethrough",positions:[M.MenuPosition.TOOLBAR_START],disabled$:new B.Observable(a=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),activated$:new B.Observable(a=>{const c=e.onCommandExecuted(d=>{var g;const u=d.id;if(u!==f.SetRangeValuesMutation.id&&u!==f.SetSelectionsOperation.id)return;const h=(g=n.getLast())==null?void 0:g.primary,m=t.getCurrentUniverSheetInstance().getActiveSheet();let _;if(h!=null){const S=m.getRange(h.startRow,h.startColumn);_=S==null?void 0:S.getStrikeThrough()}a.next(!!(_&&_.s))});return a.next(!1),c.dispose})}}function Ba(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SheetPermissionService),o=t.getCurrentUniverSheetInstance().getUnitId(),r=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Co.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON,icon:"FontSizeReduceSingleSingle",tooltip:"toolbar.subscript",positions:[M.MenuPosition.TOOLBAR_START],disabled$:new B.Observable(s=>{var c;const a=(c=n.getEditable$(o,r))==null?void 0:c.subscribe(d=>{s.next(!d.value)});return()=>{a==null||a.unsubscribe()}}),activated$:new B.Observable(s=>{const a=e.onCommandExecuted(c=>{});return s.next(!1),a.dispose})}}function Va(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SheetPermissionService),o=t.getCurrentUniverSheetInstance().getUnitId(),r=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Io.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON,icon:"FontSizeIncreaseSingle",tooltip:"toolbar.superscript",positions:[M.MenuPosition.TOOLBAR_START],disabled$:new B.Observable(s=>{var c;const a=(c=n.getEditable$(o,r))==null?void 0:c.subscribe(d=>{s.next(!d.value)});return()=>{a==null||a.unsubscribe()}}),activated$:new B.Observable(s=>{const a=e.onCommandExecuted(c=>{});return s.next(!1),a.dispose})}}const Fa=[{label:"9",value:9},{label:"10",value:10},{label:"11",value:11},{label:"12",value:12},{label:"14",value:14},{label:"16",value:16},{label:"18",value:18},{label:"20",value:20},{label:"22",value:22},{label:"24",value:24},{label:"26",value:26},{label:"28",value:28},{label:"36",value:36},{label:"48",value:48},{label:"72",value:72}],No=[{label:ae,value:"Times New Roman"},{label:ae,value:"Arial"},{label:ae,value:"Tahoma"},{label:ae,value:"Verdana"},{label:ae,value:"Microsoft YaHei"},{label:ae,value:"SimSun"},{label:ae,value:"SimHei"},{label:ae,value:"Kaiti"},{label:ae,value:"FangSong"},{label:ae,value:"NSimSun"},{label:ae,value:"STXinwei"},{label:ae,value:"STXingkai"},{label:ae,value:"STLiti"}];function Wa(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:bo.id,tooltip:"toolbar.font",group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.SELECTOR,label:Po,positions:[M.MenuPosition.TOOLBAR_START],selections:No,disabled$:new B.Observable(a=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),value$:new B.Observable(a=>{const c=No[0].value,d=e.onCommandExecuted(u=>{var S;const h=u.id;if(h!==f.SetRangeValuesMutation.id&&h!==f.SetSelectionsOperation.id)return;const m=(S=n.getLast())==null?void 0:S.primary,_=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(m!=null){const v=_.getRange(m.startRow,m.startColumn);g=v==null?void 0:v.getFontFamily()}a.next(g??c)});return a.next(c),d.dispose})}}function ja(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService),o=i.get(f.SheetPermissionService),r=t.getCurrentUniverSheetInstance().getUnitId(),s=t.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();return{id:Mo.id,group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.SELECTOR,tooltip:"toolbar.fontSize",label:{name:Ho,props:{min:1,max:400}},positions:[M.MenuPosition.TOOLBAR_START],selections:Fa,disabled$:new B.Observable(a=>{var d;const c=(d=o.getEditable$(r,s))==null?void 0:d.subscribe(u=>{a.next(!u.value)});return()=>{c==null||c.unsubscribe()}}),value$:new B.Observable(a=>{const d=e.onCommandExecuted(u=>{var S;const h=u.id;if(h!==f.SetRangeValuesMutation.id&&h!==f.SetSelectionsOperation.id)return;const m=(S=n.getLast())==null?void 0:S.primary,_=t.getCurrentUniverSheetInstance().getActiveSheet();let g;if(m!=null){const v=_.getRange(m.startRow,m.startColumn);g=v==null?void 0:v.getFontSize()}a.next(g??14)});return a.next(14),d.dispose})}}function za(){return{id:f.ResetTextColorCommand.id,type:M.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:Kt.id}}function Xa(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:Kt.id,icon:"FontColor",tooltip:"toolbar.textColor.main",group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON_SELECTOR,positions:[M.MenuPosition.TOOLBAR_START],selections:[{label:{name:Qt,hoverable:!1}}],value$:new B.Observable(n=>{const o=t.getCurrentTheme().textColor,r=e.onCommandExecuted(s=>{if(s.id===Kt.id){const a=s.params.value;n.next(a??o)}});return n.next(o),r.dispose})}}function Ya(){return{id:f.ResetBackgroundColorCommand.id,type:M.MenuItemType.BUTTON,title:"toolbar.resetColor",icon:"NoColor",positions:f.SetBackgroundColorCommand.id}}function $a(i){const e=i.get(l.ICommandService),t=i.get(l.ThemeService);return{id:f.SetBackgroundColorCommand.id,tooltip:"toolbar.fillColor.main",group:M.MenuGroup.TOOLBAR_FORMAT,type:M.MenuItemType.BUTTON_SELECTOR,positions:[M.MenuPosition.TOOLBAR_START],icon:"PaintBucket",selections:[{label:{name:Qt,hoverable:!1}}],value$:new B.Observable(n=>{const o=t.getCurrentTheme().primaryColor,r=e.onCommandExecuted(s=>{if(s.id===f.SetBackgroundColorCommand.id){const a=s.params.value;n.next(a??o)}});return n.next(o),r.dispose})}}const Lo=[{label:"align.left",icon:"LeftJustifyingSingle",value:l.HorizontalAlign.LEFT},{label:"align.center",icon:"HorizontallySingle",value:l.HorizontalAlign.CENTER},{label:"align.right",icon:"RightJustifyingSingle",value:l.HorizontalAlign.RIGHT}];function Za(i){const e=i.get(l.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetHorizontalTextAlignCommand.id,icon:Lo[0].icon,positions:[M.MenuPosition.TOOLBAR_START],tooltip:"toolbar.horizontalAlignMode.main",group:M.MenuGroup.TOOLBAR_LAYOUT,type:M.MenuItemType.SELECTOR,selections:Lo,value$:new B.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetHorizontalTextAlignCommand.id&&s!==f.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getHorizontalAlignment()}n.next(d??l.HorizontalAlign.LEFT)});return n.next(l.HorizontalAlign.LEFT),o.dispose})}}const Uo=[{label:"align.top",icon:"AlignTopSingle",value:l.VerticalAlign.TOP},{label:"align.middle",icon:"VerticalCenterSingle",value:l.VerticalAlign.MIDDLE},{label:"align.bottom",icon:"AlignBottomSingle",value:l.VerticalAlign.BOTTOM}];function Ga(i){const e=i.get(l.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetVerticalTextAlignCommand.id,icon:Uo[0].icon,tooltip:"toolbar.verticalAlignMode.main",group:M.MenuGroup.TOOLBAR_LAYOUT,type:M.MenuItemType.SELECTOR,positions:[M.MenuPosition.TOOLBAR_START],selections:Uo,value$:new B.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetVerticalTextAlignCommand.id&&s!==f.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getVerticalAlignment()}n.next(d??l.VerticalAlign.TOP)});return n.next(l.VerticalAlign.TOP),o.dispose})}}const ko=[{label:"textWrap.overflow",icon:"OverflowSingle",value:l.WrapStrategy.OVERFLOW},{label:"textWrap.wrap",icon:"AutowrapSingle",value:l.WrapStrategy.WRAP},{label:"textWrap.clip",icon:"TruncationSingle",value:l.WrapStrategy.CLIP}];function Ka(i){const e=i.get(l.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetTextWrapCommand.id,tooltip:"toolbar.textWrapMode.main",icon:ko[0].icon,group:M.MenuGroup.TOOLBAR_LAYOUT,type:M.MenuItemType.SELECTOR,positions:[M.MenuPosition.TOOLBAR_START],selections:ko,value$:new B.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetTextWrapCommand.id&&s!==f.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getWrapStrategy()}n.next(d??l.WrapStrategy.OVERFLOW)});return n.next(l.WrapStrategy.OVERFLOW),o.dispose})}}const Bo=[{label:"textRotate.none",icon:"NoRotationSingle",value:0},{label:"textRotate.angleUp",icon:"LeftRotationFortyFiveDegreesSingle",value:-45},{label:"textRotate.angleDown",icon:"RightRotationFortyFiveDegreesSingle",value:45},{label:"textRotate.vertical",icon:"VerticalTextSingle",value:"v"},{label:"textRotate.rotationUp",icon:"LeftRotationNinetyDegreesSingle",value:-90},{label:"textRotate.rotationDown",icon:"RightRotationNinetyDegreesSingle",value:90}];function Ja(i){const e=i.get(l.IUniverInstanceService),t=i.get(f.SelectionManagerService);return{id:f.SetTextRotationCommand.id,tooltip:"toolbar.textRotateMode.main",icon:Bo[0].icon,group:M.MenuGroup.TOOLBAR_LAYOUT,type:M.MenuItemType.SELECTOR,selections:Bo,positions:[M.MenuPosition.TOOLBAR_START],value$:new B.Observable(n=>{const o=i.get(l.ICommandService).onCommandExecuted(r=>{var u;const s=r.id;if(s!==f.SetTextRotationCommand.id&&s!==f.SetSelectionsOperation.id)return;const a=(u=t.getLast())==null?void 0:u.primary,c=e.getCurrentUniverSheetInstance().getActiveSheet();let d;if(a!=null){const h=c.getRange(a.startRow,a.startColumn);d=h==null?void 0:h.getTextRotation()}(d==null?void 0:d.v)===l.BooleanNumber.TRUE?n.next("v"):n.next((d&&d.a)??0)});return n.next(0),o.dispose})}}function Qa(){return{id:M.CopyCommand.id,group:M.MenuGroup.CONTEXT_MENU_FORMAT,type:M.MenuItemType.BUTTON,title:"rightClick.copy",icon:"Copy",positions:[M.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function qa(){return{id:M.PasteCommand.id,group:M.MenuGroup.CONTEXT_MENU_FORMAT,type:M.MenuItemType.BUTTON,title:"rightClick.paste",icon:"PasteSpecial",positions:[M.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}const rt="sheet.menu.paste-special";function el(){return{id:rt,group:M.MenuGroup.CONTEXT_MENU_FORMAT,type:M.MenuItemType.SUBITEMS,icon:"PasteSpecial",title:"rightClick.pasteSpecial",positions:[M.MenuPosition.CONTEXT_MENU,"colHeaderContextMenu","rowHeaderContextMenu"]}}function tl(){return{id:Fi.id,type:M.MenuItemType.BUTTON,title:"rightClick.pasteValue",positions:[rt]}}function nl(){return{id:Wi.id,type:M.MenuItemType.BUTTON,title:"rightClick.pasteFormat",positions:[rt]}}function il(){return{id:ji.id,type:M.MenuItemType.BUTTON,title:"rightClick.pasteColWidth",positions:[rt]}}function ol(){return{id:zi.id,type:M.MenuItemType.BUTTON,title:"rightClick.pasteBesidesBorder",positions:[rt]}}function rl(){return{id:f.SetWorksheetRowIsAutoHeightCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"AutoHeight",title:"rightClick.fitContent"}}const Rt="sheet.menu.sheet-frozen";function sl(){return{id:Rt,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:[M.MenuPosition.CONTEXT_MENU]}}const li="sheet.header-menu.sheet-frozen";function al(){return{id:li,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.SUBITEMS,title:"rightClick.freeze",icon:"FreezeToSelectedSingle",positions:["rowHeaderContextMenu","colHeaderContextMenu"]}}function ll(){return{id:Jt.id,type:M.MenuItemType.BUTTON,positions:[Rt,li],title:"rightClick.freeze",icon:"FreezeToSelectedSingle"}}function cl(){return{id:Oo.id,type:M.MenuItemType.BUTTON,positions:[Rt],title:"rightClick.freezeRow",icon:"FreezeRowSingle"}}function dl(){return{id:yo.id,type:M.MenuItemType.BUTTON,positions:[Rt],title:"rightClick.freezeCol",icon:"FreezeColumnSingle"}}function ul(){return{id:xo.id,type:M.MenuItemType.BUTTON,positions:[Rt,li],title:"rightClick.cancelFreeze",icon:"CancelFreezeSingle"}}function hl(){return{id:f.SetRowHiddenCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedRow"}}function ml(){return{id:f.SetColHiddenCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],icon:"Hide",title:"rightClick.hideSelectedColumn"}}function _l(i){const e=i.get(l.IUniverInstanceService),t=i.get(f.SelectionManagerService);function n(){var a;const r=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.ROW);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!r.getRowVisible(d))return!0;return!1}))}const o=i.get(l.ICommandService);return{id:f.SetSelectedRowsVisibleCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,positions:["rowHeaderContextMenu"],title:"rightClick.showHideRow",hidden$:new B.Observable(r=>{const s=o.onCommandExecuted(a=>{(a.id===f.SetSelectionsOperation.id||a.id===f.SetRowHiddenMutation.id||a.id===f.SetRowVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function Sl(i){const e=i.get(l.IUniverInstanceService),t=i.get(f.SelectionManagerService);function n(){var a;const r=e.getCurrentUniverSheetInstance().getActiveSheet(),s=(a=t.getSelections())==null?void 0:a.map(c=>c.range).filter(c=>c.rangeType===l.RANGE_TYPE.COLUMN);return!!(s!=null&&s.some(c=>{for(let d=c.startRow;d<=c.endRow;d++)if(!r.getColVisible(d))return!0;return!1}))}const o=i.get(l.ICommandService);return{id:f.SetSelectedColsVisibleCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,positions:["colHeaderContextMenu"],title:"rightClick.showHideColumn",hidden$:new B.Observable(r=>{const s=o.onCommandExecuted(a=>{(a.id===f.SetSelectionsOperation.id||a.id===f.SetColHiddenMutation.id||a.id===f.SetColVisibleMutation.id)&&r.next(!n())});return r.next(!n()),()=>s.dispose()})}}function gl(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetRowHeightCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,icon:"AdjustHeight",positions:["rowHeaderContextMenu"],label:{name:si,props:{prefix:"rightClick.rowHeight",suffix:"px"}},value$:new B.Observable(o=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d;a!=null&&(d=c.getRowHeight(a.startRow)),o.next(d??0)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function fl(i){const e=i.get(l.ICommandService),t=i.get(l.IUniverInstanceService),n=i.get(f.SelectionManagerService);return{id:f.SetColWidthCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,icon:"AdjustWidth",positions:["colHeaderContextMenu"],label:{name:si,props:{prefix:"rightClick.columnWidth",suffix:"px"}},value$:new B.Observable(o=>{function r(){var u;const a=(u=n.getLast())==null?void 0:u.primary,c=t.getCurrentUniverSheetInstance().getActiveSheet();let d=0;a!=null&&(d=c.getColumnWidth(a.startColumn)),o.next(d)}const s=e.onCommandExecuted(a=>{const c=a.id;if(c===f.SetRangeValuesMutation.id||c===f.SetSelectionsOperation.id)return r()});return r(),s.dispose})}}function le(i,e){const n=i.getCurrentUniverSheetInstance().getUnitId(),o=e.getRenderById(n);if(o==null)return;const{components:r,mainComponent:s,scene:a,engine:c}=o,d=s,u=r.get(re.ROW),h=r.get(re.COLUMN),m=r.get(re.LEFT_TOP);return{spreadsheet:d,spreadsheetRowHeader:u,spreadsheetColumnHeader:h,spreadsheetLeftTopPlaceholder:m,scene:a,engine:c}}function ci(i,e,t,n){const{scaleX:o,scaleY:r}=t.getAncestorScale(),{startX:s,startY:a,endX:c,endY:d}=n.getCellByIndex(i,e,o,r);return{startX:s,startY:a,endX:c,endY:d}}function st(i,e,t,n,o){const r=t.getRelativeCoord(w.Vector2.FromArray([i,e])),{x:s,y:a}=r,c=t.getScrollXYByRelativeCoords(r,o),{scaleX:d,scaleY:u}=t.getAncestorScale(),h=n.getCellPositionByOffset(s,a,d,u,c),{row:m,column:_}=h,g=n.getNoMergeCellPositionByIndex(m,_,d,u),{startX:S,startY:v,endX:I,endY:b}=g;return{startX:S,startY:v,endX:I,endY:b,row:m,column:_}}function qt(i,e,t,n){const o=t.getRelativeCoord(w.Vector2.FromArray([i,e])),r=t.getViewport(j.VIEW_MAIN),s=t.getScrollXYByRelativeCoords(o,r),{scaleX:a,scaleY:c}=t.getAncestorScale(),{x:d,y:u}=s,h=i/a+d,m=e/c+u;return{x:h,y:m}}const pl={spreadsheetLabel:"Spreadsheet",spreadsheetRightLabel:"more Sheets",toolbar:{undo:"Undo",redo:"Redo",formatPainter:"Paint format",currencyFormat:"Format as currency",percentageFormat:"Format as percent",numberDecrease:"Decrease decimal places",numberIncrease:"Increase decimal places",moreFormats:"More formats",font:"Font",fontSize:"Font size",bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",subscript:"Subscript",superscript:"Superscript",underline:"Underline",textColor:{main:"Text color",right:"Choose color"},resetColor:"Reset",customColor:"CUSTOM",alternatingColors:"Alternating colors",confirmColor:"OK",cancelColor:"Cancel",collapse:"Collapse",fillColor:{main:"Fill color",right:"Choose color"},border:{main:"Border",right:"Border style"},mergeCell:{main:"Merge cells",right:"Choose merge type"},horizontalAlignMode:{main:"Horizontal align",right:"Alignment"},verticalAlignMode:{main:"Vertical align",right:"Alignment"},textWrapMode:{main:"Text wrap",right:"Text wrap mode"},textRotateMode:{main:"Text rotate",right:"Text rotate mode"},freezeTopRow:"Freeze top row",sortAndFilter:"Sort and filter",findAndReplace:"Find and replace",sum:"SUM",autoSum:"Auto SUM",moreFunction:"More functions",conditionalFormat:"Conditional format",comment:"Comment",pivotTable:"Pivot Table",chart:"Chart",screenshot:"Screenshot",splitColumn:"Split text",insertImage:"Insert image",insertLink:"Insert link",dataValidation:"Data validation",protection:"Protect the sheet",clearText:"Clear color",noColorSelectedText:"No color is selected",toolMore:"More",toolLess:"Less",toolClose:"Close",toolMoreTip:"More features",moreOptions:"More options",cellFormat:"Cell format config",print:"Print",borderMethod:{top:"Upper frame line",bottom:"Lower frame line",left:"Left frame line",right:"Right frame line"},more:"More"},defaultFmt:{Automatic:{text:"Automatic",value:"General",example:""},Number:{text:"Number",value:"##0.00",example:"1000.12"},Percent:{text:"Percent",value:"#0.00%",example:"12.21%"},PlainText:{text:"Plain text",value:"@",example:""},Scientific:{text:"Scientific",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"Accounting",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"Ten Thousand",value:"w",example:"1亿2000万2500"},Currency:{text:"Currency",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"Date",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"Time",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"Time 24H",value:"hh:mm",example:"15:00"},DateTime:{text:"Date time",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"Date time 24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"Custom Formats",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"More currency formats",moreDateTime:"More date and time formats",moreNumber:"More number formats",titleCurrency:"Currency formats",decimalPlaces:"Decimal places",titleDateTime:"Date and time formats",titleNumber:"Number formats"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"Microsoft YaHei",SimSun:"SimSun",SimHei:"SimHei",Kaiti:"Kaiti",FangSong:"FangSong",NSimSun:"NSimSun",STXinwei:"STXinwei",STXingkai:"STXingkai",STLiti:"STLiti",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"Normal",layoutBtn:"Page Layout",pageBtn:"Page break preview",menuItemPrint:"Print (Ctrl+P)",menuItemAreas:"Print areas",menuItemRows:"Print title rows",menuItemColumns:"Print title columns"},align:{left:"left",center:"center",right:"right",top:"top",middle:"middle",bottom:"bottom"},dateFmtList:[{name:"1930-08-05",value:"yyyy-MM-dd"},{name:"1930/8/5",value:"yyyy/MM/dd"},{name:"08-05",value:"MM-dd"},{name:"8-5",value:"M-d"},{name:"13:30:30",value:"h:mm:ss"},{name:"13:30",value:"h:mm"},{name:"PM 01:30",value:"AM/PM hh:mm"},{name:"PM 1:30",value:"AM/PM h:mm"},{name:"PM 1:30:30",value:"AM/PM h:mm:ss"},{name:"08-05 PM 01:30",value:"MM-dd AM/PM hh:mm"}],numFmtList:[{name:"1235",value:"0"},{name:"1234.56",value:"0.00"},{name:"1,235",value:"#,##0"},{name:"1,234.56",value:"#,##0.00"},{name:"1,235",value:"#,##0_);(#,##0)"},{name:"1,235",value:"#,##0_);[Red](#,##0)"},{name:"1,234.56",value:"#,##0.00_);(#,##0.00)"},{name:"1,234.56",value:"#,##0.00_);[Red](#,##0.00)"},{name:"$1,235",value:"$#,##0_);($#,##0)"},{name:"$1,235",value:"$#,##0_);[Red]($#,##0)"},{name:"$1,234.56",value:"$#,##0.00_);($#,##0.00)"},{name:"$1,234.56",value:"$#,##0.00_);[Red]($#,##0.00)"},{name:"1234.56",value:"@"},{name:"123456%",value:"0%"},{name:"123456.00%",value:"0.00%"},{name:"1.23E+03",value:"0.00E+00"},{name:"1.2E+3",value:"##0.0E+0"},{name:"1234 5/9",value:"# ?/?"},{name:"1234 14/25",value:"# ??/??"},{name:"$ 1,235",value:'_($* #,##0_);_(...($* "-"_);_(@_)'},{name:"1,235",value:'_(* #,##0_);_(*..._(* "-"_);_(@_)'},{name:"$ 1,234.56",value:'_($* #,##0.00_);_(...($* "-"_);_(@_)'},{name:"1,234.56",value:'_(* #,##0.00_);...* "-"??_);_(@_)'}],button:{confirm:"OK",cancel:"Cancel",close:"Close",update:"Update",delete:"Delete",insert:"Insert",prevPage:"Previous",nextPage:"Next",total:"total:"},punctuation:{tab:"Tab",semicolon:"semicolond",comma:"comma",space:"space"},colorPicker:{collapse:"Collapse",customColor:"CUSTOM",change:"Change",confirmColor:"OK",cancelColor:"Cancel"},borderLine:{borderTop:"borderTop",borderBottom:"borderBottom",borderLeft:"borderLeft",borderRight:"borderRight",borderNone:"borderNone",borderAll:"borderAll",borderOutside:"borderOutside",borderInside:"borderInside",borderHorizontal:"borderHorizontal",borderVertical:"borderVertical",borderColor:"borderColor",borderSize:"borderSize",borderType:"borderType"},merge:{all:"Merge all",vertical:"Vertical merge",horizontal:"Horizontal merge",cancel:"Cancel merge",overlappingError:"Cannot merge overlapping areas",partiallyError:"Cannot perform this operation on partially merged cells",confirm:{title:"Continue merging would only keep the upper-left cell value, discard other values. Are you sure to continue?",cancel:"Cancel merging",confirm:"Continue merging"}},textWrap:{overflow:"Overflow",wrap:"Wrap",clip:"Clip"},textRotate:{none:"None",angleUp:"Tilt Up",angleDown:"Tilt Down",vertical:"Stack Vertically",rotationUp:"Rotate Up",rotationDown:"Rotate Down"},sheetConfig:{delete:"Delete",copy:"Copy",rename:"Rename",changeColor:"Change color",hide:"Hide",unhide:"Unhide",moveLeft:"Move left",moveRight:"Move right",resetColor:"Reset color",cancelText:"Cancel",chooseText:"Confirm color",tipNameRepeat:"The name of the tab page cannot be repeated! Please revise",noMoreSheet:"The workbook contains at least one visual worksheet. To delete the selected worksheet, please insert a new worksheet or show a hidden worksheet.",confirmDelete:"Are you sure to delete",redoDelete:"Can be undo by Ctrl+Z",noHide:"Can't hide, at least keep one sheet tag",chartEditNoOpt:"This operation is not allowed in chart editing mode!",sheetNameSpecCharError:`The name cannot contain:[ ] : ? * / ' "`,sheetNameCannotIsEmptyError:"The sheet name cannot be empty"},rightClick:{copy:"Copy",copyAs:"Copy as",cut:"Cut",paste:"Paste",pasteSpecial:"Paste Special",pasteValue:"Paste Value",pasteFormat:"Paste Format",pasteColWidth:"Paste Column Width",pasteBesidesBorder:"Paste Besides Border Styles",insert:"Insert",insertRow:"Insert Row",insertRowBefore:"Insert Row Before",insertColumn:"Insert Column",insertColumnBefore:"Insert Column Before",delete:"Delete",deleteCell:"Delete Cell",insertCell:"Insert Cell",deleteSelected:"Delete Selected ",hide:"Hide",hideSelected:"Hide Selected ",showHide:"Show Hidden",toTopAdd:"Towards Top Add",toBottomAdd:"Towards Bottom Add",toLeftAdd:"Towards Left Add",toRightAdd:"Towards Right Add",deleteSelectedRow:"Delete Selected row",deleteSelectedColumn:"Delete Selected column",hideSelectedRow:"Hide Selected Row",showHideRow:"Show Selected Row",rowHeight:"Row Height",hideSelectedColumn:"Hide Selected Column",showHideColumn:"Show Hide Column",columnWidth:"Column Width",to:"Towards",left:"Left",right:"Right",top:"Top",bottom:"Bottom",moveLeft:"Move Left",moveUp:"Move up",moveRight:"Move Right",moveDown:"Move Down",add:"Add",row:"Row",column:"Column",width:"Width",height:"Height",number:"Number",confirm:"Confirm",orderAZ:"A-Z order",orderZA:"Z-A order",clearSelection:"Clear",clearContent:"Clear Contents",clearFormat:"Clear Formats",clearAll:"Clear All",matrix:"Matrix operation",sortSelection:"Sort",filterSelection:"Filter",chartGeneration:"Create Chart",firstLineTitle:"First Line Title",untitled:"Untitled",array1:"One-dimensional array",array2:"Two-dimensional array",array3:"Multidimensional Arrays",diagonal:"Diagonal",antiDiagonal:"Anti-diagonal",diagonalOffset:"Diagonal offset",offset:"Offset",boolean:"Boolean",flip:"Flip",upAndDown:"Up and down",leftAndRight:"Left and right",clockwise:"Clockwise",counterclockwise:"Counterclockwise",transpose:"Transpose",matrixCalculation:"Matrix Calculation",plus:"Plus",minus:"Minus",multiply:"Multiply",divided:"Divided",power:"Power",root:"Root",log:"Log",delete0:"Delete 0 values at both ends",removeDuplicate:"Remove duplicate values",byRow:"By row",byCol:"By column",generateNewMatrix:"Generate new matrix",fitContent:"Fit for data",freeze:"Freeze",freezeCol:"Freeze to this column",freezeRow:"Freeze to this row",cancelFreeze:"Cancel freeze"},info:{tooltip:"Tooltip",notChangeMerge:"You cannot make partial changes to the merged cells",detailUpdate:"New opened",detailSave:"Local cache restored",row:"",column:"",loading:"Loading...",copy:"Copy",return:"Exit",rename:"Rename",tips:"Rename",noName:"Untitled spreadsheet",wait:"waiting for update",add:"Add",addLast:"more rows at bottom",backTop:"Back to the top",pageInfo:"Total ${total},${totalPage} page,current ${currentPage}",nextPage:"Next",tipInputNumber:"Please enter the number",tipInputNumberLimit:"The increase range is limited to 1-100",tipRowHeightLimit:"Row height must be between 0 ~ 545",tipColumnWidthLimit:"The column width must be between 0 ~ 2038",pageInfoFull:"Total ${total},${totalPage} page,All data displayed"},clipboard:{paste:{exceedMaxCells:"The number of cells pasted exceeds the maximum number of cells"}},statusbar:{sum:"sum",average:"average",min:"min",max:"max",count:"numerical count",countA:"count",clickToCopy:"click to copy",copied:"copied!"},autoFill:{copy:"Copy Cell",series:"Fill Series",formatOnly:"Format Only",noFormat:"No Format"},rangeSelector:{placeholder:"Select range or input value",tooltip:"Select range"},shortcut:{sheet:{"zoom-in":"Zoom in","zoom-out":"Zoom out","reset-zoom":"Reset zoom level","select-below-cell":"Select the cell below","select-up-cell":"Select the cell above","select-left-cell":"Select the left cell","select-right-cell":"Select the right cell","select-next-cell":"Select the next cell","select-previous-cell":"Select the previous cell","select-up-value-cell":"Select the cell above that has value","select-below-value-cell":"Select the cell below that has value","select-left-value-cell":"Select the cell left that has value","select-right-value-cell":"Select the cell right that has value","expand-selection-down":"Expand selection down","expand-selection-up":"Expand selection up","expand-selection-left":"Expand selection left","expand-selection-right":"Expand selection right","expand-selection-to-left-gap":"Expand selection to the left gap","expand-selection-to-below-gap":"Expand selection to the below gap","expand-selection-to-right-gap":"Expand selection to the right gap","expand-selection-to-up-gap":"Expand selection to the up gap","select-all":"Select all","toggle-editing":"Toggle editing","delete-and-start-editing":"Clear and start editing","abort-editing":"Abort editing","break-line":"Break line","set-bold":"Toggle bold","set-italic":"Toggle italic","set-underline":"Toggle underline","set-strike-through":"Toggle strike through"}},"sheet-view":"Sheet View","sheet-edit":"Sheet Edit"},Vo={spreadsheetLabel:"插件",spreadsheetRightLabel:"更多 Sheets",toolbar:{undo:"撤销",redo:"重做",formatPainter:"格式刷",currencyFormat:"货币格式",percentageFormat:"百分比格式",numberDecrease:"减少小数位数",numberIncrease:"增加小数位数",moreFormats:"更多格式",font:"字体",fontSize:"字号",bold:"粗体",italic:"斜体",strikethrough:"删除线",subscript:"下标",superscript:"上标",underline:"下划线",textColor:{main:"文本颜色",right:"颜色选择"},resetColor:"重置颜色",customColor:"自定义",alternatingColors:"交替颜色",confirmColor:"确定颜色",cancelColor:"取消",collapse:"收起",fillColor:{main:"单元格颜色",right:"颜色选择"},border:{main:"边框",right:"边框类型"},mergeCell:{main:"合并单元格",right:"选择合并类型"},horizontalAlignMode:{main:"水平对齐",right:"对齐方式"},verticalAlignMode:{main:"垂直对齐",right:"对齐方式"},textWrapMode:{main:"文本换行",right:"换行方式"},textRotateMode:{main:"文本旋转",right:"旋转方式"},freezeTopRow:"冻结首行",sortAndFilter:"排序和筛选",findAndReplace:"查找替换",sum:"求和",autoSum:"自动求和",moreFunction:"更多函数",conditionalalFormat:"条件格式",comment:"批注",pivotTable:"数据透视表",chart:"图表",screenshot:"截图",splitColumn:"分列",insertImage:"插入图片",insertLink:"插入链接",dataValidation:"数据验证",protection:"保护工作表内容",clearText:"清除颜色选择",noColorSelectedText:"没有颜色被选择",toolMore:"更多",toolLess:"少于",toolClose:"收起",toolMoreTip:"更多功能",moreOptions:"更多选项",cellFormat:"设置单元格格式",print:"打印",borderMethod:{top:"上框线",bottom:"下框线",left:"左框线",right:"右框线"},more:"更多"},defaultFmt:{Automatic:{text:"自动",value:"General",example:""},Number:{text:"数字",value:"##0.00",example:"1000.12"},Percent:{text:"百分比",value:"#0.00%",example:"12.21%"},PlainText:{text:"纯文本",value:"@",example:""},Scientific:{text:"科学计数",value:"0.00E+00",example:"1.01E+5"},Accounting:{text:"会计",value:"¥(0.00)",example:"¥(1200.09)"},Thousand:{text:"万元",value:"w",example:"1亿2000万2500"},Currency:{text:"货币",value:"¥0.00",example:"¥1200.09"},Digit:{text:"万元2位小数",value:"w0.00",example:"2万2500.55"},Date:{text:"日期",value:"yyyy-MM-dd",example:"2017-11-29"},Time:{text:"时间",value:"hh:mm AM/PM",example:"3:00 PM"},Time24H:{text:"时间24H",value:"hh:mm",example:"15:00"},DateTime:{text:"日期时间",value:"yyyy-MM-dd hh:mm AM/PM",example:"2017-11-29 3:00 PM"},DateTime24H:{text:"日期时间24H",value:"yyyy-MM-dd hh:mm",example:"2017-11-29 15:00"},CustomFormats:{text:"自定义格式",value:"fmtOtherSelf",example:""}},format:{moreCurrency:"更多货币格式",moreDateTime:"更多日期与时间格式",moreNumber:"更多数字格式",titleCurrency:"货币格式",decimalPlaces:"小数位数",titleDateTime:"日期与时间格式",titleNumber:"数字格式"},fontFamily:{TimesNewRoman:"Times New Roman",Arial:"Arial",Tahoma:"Tahoma",Verdana:"Verdana",MicrosoftYaHei:"微软雅黑",SimSun:"宋体",SimHei:"黑体",Kaiti:"楷体",FangSong:"仿宋",NSimSun:"新宋体",STXinwei:"华文新魏",STXingkai:"华文行楷",STLiti:"华文隶书",HanaleiFill:"HanaleiFill",Anton:"Anton",Pacifico:"Pacifico"},print:{normalBtn:"常规视图",layoutBtn:"页面布局",pageBtn:"分页预览",menuItemPrint:"打印(Ctrl+P)",menuItemAreas:"打印区域",menuItemRows:"打印标题行",menuItemColumns:"打印标题列"},align:{left:"左对齐",center:"中间对齐",right:"右对齐",top:"顶部对齐",middle:"居中对齐",bottom:"底部对齐"},button:{confirm:"确定",cancel:"取消",close:"关闭",update:"Update",delete:"Delete",insert:"新建",prevPage:"上一页",nextPage:"下一页",total:"总共:"},punctuation:{tab:"Tab 键",semicolon:"分号",comma:"逗号",space:"空格"},colorPicker:{collapse:"收起",customColor:"自定义",change:"切换",confirmColor:"确定",cancelColor:"取消"},borderLine:{borderTop:"上框线",borderBottom:"下框线",borderLeft:"左框线",borderRight:"右框线",borderNone:"无",borderAll:"所有",borderOutside:"外侧",borderInside:"内侧",borderHorizontal:"内侧横线",borderVertical:"内侧竖线",borderColor:"边框颜色",borderSize:"边框粗细",borderType:"边框线类型"},merge:{all:"全部合并",vertical:"垂直合并",horizontal:"水平合并",cancel:"取消合并",overlappingError:"不能合并重叠区域",partiallyError:"无法对部分合并单元格执行此操作",confirm:{title:"合并单元格仅保存左上角单元格的值,是否继续?",cancel:"取消合并",confirm:"继续合并"}},textWrap:{overflow:"溢出",wrap:"自动换行",clip:"截断"},textRotate:{none:"无旋转",angleUp:"向上倾斜",angleDown:"向下倾斜",vertical:"竖排文字",rotationUp:"向上90°",rotationDown:"向下90°"},sheetConfig:{delete:"删除",copy:"复制",rename:"重命名",changeColor:"更改颜色",hide:"隐藏",unhide:"取消隐藏",moveLeft:"向左移",moveRight:"向右移",resetColor:"重置颜色",cancelText:"取消",chooseText:"确定颜色",tipNameRepeat:"标签页的名称不能重复!请重新修改",noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",confirmDelete:"是否删除",redoDelete:"可以通过Ctrl+Z撤销删除",noHide:"不能隐藏, 至少保留一个sheet标签",chartEditNoOpt:"图表编辑模式下不允许该操作!",sheetNameSpecCharError:`名称不能超过31个字符,首尾不能是' 且名称不能包含:\r
|
|
14
|
+
[ ] : \\ ? * /`,sheetNameCannotIsEmptyError:"名称不能为空"},rightClick:{copy:"复制",copyAs:"复制为",cut:"剪切",paste:"粘贴",pasteSpecial:"选择性粘贴",pasteValue:"仅粘贴值",pasteFormat:"仅粘贴格式",pasteColWidth:"仅粘贴列宽",pasteBesidesBorder:"仅粘贴边框以外内容",insert:"插入",delete:"删除",insertRow:"插入行",insertRowBefore:"在上方插入行",insertColumn:"插入列",insertColumnBefore:"在左侧插入列",deleteCell:"删除单元格",insertCell:"插入单元格",deleteSelected:"删除选中",hide:"隐藏",hideSelected:"隐藏选中",showHide:"显示隐藏",toTopAdd:"向上增加",toBottomAdd:"向下增加",toLeftAdd:"向左增加",toRightAdd:"向右增加",deleteSelectedRow:"删除选中行",deleteSelectedColumn:"删除选中列",hideSelectedRow:"隐藏选中行",showHideRow:"显示隐藏行",rowHeight:"行高",hideSelectedColumn:"隐藏选中列",showHideColumn:"显示隐藏列",columnWidth:"列宽",to:"向",left:"左",right:"右",top:"上",bottom:"下",moveLeft:"左移",moveUp:"上移",moveRight:"右移",moveDown:"下移",add:"增加",row:"行",column:"列",width:"宽",height:"高",number:"数字",confirm:"确认",orderAZ:"A-Z顺序排列",orderZA:"Z-A降序排列",clearSelection:"清除",clearContent:"清除内容",clearFormat:"清除格式",clearAll:"清除全部",matrix:"矩阵操作选区",sortSelection:"排序选区",filterSelection:"筛选选区",chartGeneration:"图表生成",firstLineTitle:"首行为标题",untitled:"无标题",array1:"一维数组",array2:"二维数组",array3:"多维数组",diagonal:"对角线",antiDiagonal:"反对角线",diagonalOffset:"对角偏移",offset:"偏移量",boolean:"布尔值",flip:"翻转",upAndDown:"上下",leftAndRight:"左右",clockwise:"顺时针",counterclockwise:"逆时针",transpose:"转置",matrixCalculation:"矩阵计算",plus:"加",minus:"减",multiply:"乘",divided:"除",power:"次方",root:"次方根",log:"log",delete0:"删除两端0值",removeDuplicate:"删除重复值",byRow:"按行",byCol:"按列",generateNewMatrix:"生成新矩阵",fitContent:"适合数据",freeze:"冻结",freezeCol:"冻结列",freezeRow:"冻结行",cancelFreeze:"取消冻结"},info:{tooltip:"提示",notChangeMerge:"不能对合并单元格做部分更改",detailUpdate:"新打开",detailSave:"已恢复本地缓存",row:"行",column:"列",loading:"渲染中···",copy:"副本",return:"返回",rename:"重命名",tips:"重命名",noName:"无标题的电子表格",wait:"待更新",add:"添加",addLast:"在底部添加",backTop:"回到顶部",pageInfo:"共${total}条,${totalPage}页,当前已显示${currentPage}页",nextPage:"下一页",tipInputNumber:"请输入数字",tipInputNumberLimit:"增加范围限制在1-100",tipRowHeightLimit:"行高必须在0 ~ 545之间",tipColumnWidthLimit:"列宽必须在0 ~ 2038之间",pageInfoFull:"共${total}条,${totalPage}页,已显示全部数据"},clipboard:{paste:{exceedMaxCells:"粘贴区域超出最大单元格数"}},statusbar:{sum:"求和",average:"平均值",min:"最小值",max:"最大值",count:"数值计数",countA:"计数",clickToCopy:"点击复制数值",copied:"数据复制成功,快去粘贴数据吧!"},autoFill:{copy:"复制单元格",series:"填充序列",formatOnly:"仅填充格式",noFormat:"不带格式填充"},rangeSelector:{placeholder:"选择范围或输入值",tooltip:"选择范围"},shortcut:{sheet:{"zoom-in":"放大","zoom-out":"缩小","reset-zoom":"恢复缩放","select-below-cell":"选择下方单元格","select-up-cell":"选择上方单元格","select-left-cell":"选择左侧单元格","select-right-cell":"选择右侧单元格","select-next-cell":"选择后一个单元格","select-previous-cell":"选择前一个单元格","select-up-value-cell":"选择上方有值的单元格","select-below-value-cell":"选择下方有值的单元格","select-left-value-cell":"选择左侧有值的单元格","select-right-value-cell":"选择右侧有值的单元格","expand-selection-down":"向下扩展选区","expand-selection-up":"向上扩展选区","expand-selection-left":"向左扩展选区","expand-selection-right":"向右扩展选区","expand-selection-to-left-gap":"向左扩展选区到下一个边界","expand-selection-to-below-gap":"向下扩展选区到下一个边界","expand-selection-to-right-gap":"向右扩展选区到下一个边界","expand-selection-to-up-gap":"向上扩展选区到下一个边界","select-all":"全选","toggle-editing":"开始 / 结束编辑","delete-and-start-editing":"清空并开始编辑","abort-editing":"放弃编辑","break-line":"换行","set-bold":"切换粗体","set-italic":"切换斜体","set-underline":"切换下划线","set-strike-through":"切换删除线"}},"sheet-view":"浏览表格","sheet-edit":"编辑表格"},vl=(i,e,t=!1)=>{const n=h=>h.endRow-h.startRow+1,o=h=>h.endColumn-h.startColumn+1,r=n(e)%n(i),s=o(e)%o(i),a={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:o(i)-1},c=Math.floor(n(e)/n(i)),d=Math.floor(o(e)/o(i)),u=[];if(!r&&!s)for(let h=1;h<=c;h++)for(let m=1;m<=d;m++){const _=n(i)*(h-1),g=o(i)*(m-1),S={startRow:_+e.startRow,endRow:_+e.startRow,startColumn:g+e.startColumn,endColumn:g+e.startColumn};u.push({repeatRelativeRange:a,startRange:S})}else if(!r&&s&&!t)for(let h=1;h<=c;h++){const m=n(i)*(h-1),_=0,g={startRow:m+e.startRow,endRow:m+e.startRow,startColumn:_+e.startColumn,endColumn:_+e.startColumn};u.push({repeatRelativeRange:a,startRange:g})}else if(r&&!s&&!t)for(let h=1;h<=d;h++){const _=o(i)*(h-1),g={startRow:0+e.startRow,endRow:0+e.startRow,startColumn:_+e.startColumn,endColumn:_+e.startColumn};u.push({repeatRelativeRange:a,startRange:g})}else{const h={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};u.push({startRange:h,repeatRelativeRange:a})}return u};class Fo{constructor(){C(this,"_state",null);C(this,"_rect",null);C(this,"_focus",!1);C(this,"_state$",new B.BehaviorSubject(null));C(this,"state$",this._state$.asObservable());C(this,"_rect$",new B.BehaviorSubject(null));C(this,"rect$",this._rect$.asObservable());C(this,"_focus$",new B.BehaviorSubject(this._focus));C(this,"focus$",this._focus$.asObservable())}dispose(){this._state$.complete(),this._state=null,this._rect$.complete(),this._rect=null}setState(e){this._state=e,this._refresh(e)}getRect(){return this._rect}setRect(e){this._rect=e,this._rect$.next(e)}getState(){return this._state}setFocus(e=!1){this._focus=e,this._focus$.next(e)}_refresh(e){this._state$.next(e)}}const wt=L.createIdentifier("univer.sheet-cell-editor-manager.service");class Cl{constructor(){C(this,"_position",null);C(this,"_position$",new B.BehaviorSubject(null));C(this,"position$",this._position$.asObservable());C(this,"_focus",!1);C(this,"_focus$",new B.BehaviorSubject(this._focus));C(this,"focus$",this._focus$.asObservable());C(this,"_fxBtnClick$",new B.BehaviorSubject(!1));C(this,"fxBtnClick$",this._fxBtnClick$.asObservable())}dispose(){this._position$.complete(),this._focus$.complete(),this._position=null,this._focus=!1}setPosition(e){this._position=e,this._refresh(e)}getPosition(){return this._position}setFocus(e=!1){this._focus=e,this._focus$.next(e)}handleFxBtnClick(e){this._fxBtnClick$.next(e)}_refresh(e){this._position$.next(e)}}const en=L.createIdentifier("univer.sheet-formula-editor-manager.service");var Il=Object.defineProperty,Ml=Object.getOwnPropertyDescriptor,bl=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ml(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Il(e,t,o),o},Wo=(i,e)=>(t,n)=>e(t,n,i);let tn=class extends l.Disposable{constructor(e,t){super();C(this,"_previousSheetIndex",-1);this._commandService=e,this._univerInstanceService=t,this.disposeWithMe(this._commandService.onCommandExecuted((n,o)=>{if(n.id===f.RemoveSheetMutation.id)return this._beforeAdjustActiveSheetOnRemoveSheet(n)})),this.disposeWithMe(this._commandService.onCommandExecuted((n,o)=>{if(n.id===f.RemoveSheetMutation.id)return this._adjustActiveSheetOnRemoveSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&n.params.hidden)return this._adjustActiveSheetOnHideSheet(n);if(!(o!=null&&o.fromCollab)){if(n.id===f.InsertSheetMutation.id)return this._adjustActiveSheetOnInsertSheet(n);if(n.id===f.SetWorksheetHideMutation.id&&!n.params.hidden)return this._adjustActiveSheetOnShowSheet(n)}}))}_adjustActiveSheetOnHideSheet(e){const{unitId:t,subUnitId:n}=e.params,o=this._univerInstanceService.getUniverSheetInstance(t);if(!o||(o==null?void 0:o.getRawActiveSheet())!==n)return;const s=o.getActiveSheetIndex(),a=Rl(o,s);this._switchToNextSheet(t,a)}_beforeAdjustActiveSheetOnRemoveSheet(e){const{unitId:t,subUnitId:n}=e.params,o=this._univerInstanceService.getUniverSheetInstance(t);if(!o)return;const r=o.getSheetBySheetId(n);r&&(this._previousSheetIndex=o.getSheetIndex(r))}_adjustActiveSheetOnRemoveSheet(e){if(this._previousSheetIndex===-1)return;const{unitId:t}=e.params,n=this._univerInstanceService.getUniverSheetInstance(t);if(!n||n.getRawActiveSheet())return;const r=this._previousSheetIndex,s=r>=1?r-1:0,a=n.getSheetByIndex(s);if(!a)throw new Error("[ActiveWorksheetController]: cannot find the next sheet!");this._switchToNextSheet(t,a.getSheetId())}_adjustActiveSheetOnInsertSheet(e){const{unitId:t,sheet:n}=e.params;this._switchToNextSheet(t,n.id)}_adjustActiveSheetOnShowSheet(e){const{unitId:t,subUnitId:n}=e.params;this._switchToNextSheet(t,n)}_switchToNextSheet(e,t){this._commandService.executeCommand(f.SetWorksheetActiveOperation.id,{unitId:e,subUnitId:t})}};tn=bl([l.OnLifecycle(l.LifecycleStages.Ready,tn),Wo(0,l.ICommandService),Wo(1,l.IUniverInstanceService)],tn);function Rl(i,e){const t=i.getSheetSize();for(let n=e;n>-1;n--){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}for(let n=e;n<t;n++){const o=i.getSheetByIndex(n);if(!o.getConfig().hidden)return o.getSheetId()}throw new Error("[ActiveWorksheetController]: could not find the next unhidden sheet! Collaboration error perhaps.")}var wl=Object.defineProperty,Tl=Object.getOwnPropertyDescriptor,El=(i,e,t,n)=>{for(var o=n>1?void 0:n?Tl(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&wl(e,t,o),o},Tt=(i,e)=>(t,n)=>e(t,n,i);let nn=class{constructor(i,e,t,n,o){this._injector=i,this._sheetInterceptorService=e,this._selectionManagerService=t,this._univerInstanceService=n,this._sheetSkeletonManagerService=o,this._initialize()}_getUndoRedoParamsOfAutoHeight(i){const{_univerInstanceService:e,_sheetSkeletonManagerService:t,_injector:n}=this,{skeleton:o}=t.getCurrent(),r=o.calculateAutoHeightInRange(i),s=e.getCurrentUniverSheetInstance(),a=s.getUnitId(),d={subUnitId:s.getActiveSheet().getSheetId(),unitId:a,rowsAutoHeightInfo:r},u=f.SetWorksheetRowAutoHeightMutationFactory(n,d);return{undos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:u}],redos:[{id:f.SetWorksheetRowAutoHeightMutation.id,params:d}]}}_initialize(){const{_sheetInterceptorService:i,_selectionManagerService:e}=this;i.interceptCommand({getMutations:t=>t.id!==f.SetRangeValuesCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.range)}),i.interceptCommand({getMutations:t=>t.id!==f.SetWorksheetRowIsAutoHeightCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),i.interceptCommand({getMutations:t=>t.id!==f.DeltaColumnWidthCommand.id&&t.id!==f.SetColWidthCommand.id?{redos:[],undos:[]}:this._getUndoRedoParamsOfAutoHeight(t.params.ranges)}),i.interceptCommand({getMutations:t=>{var r;if(t.id!==f.SetStyleCommand.id)return{redos:[],undos:[]};if(!["ff","fs","tr","tb"].includes((r=t.params)==null?void 0:r.style.type))return{redos:[],undos:[]};const o=e.getSelectionRanges();return o!=null&&o.length?this._getUndoRedoParamsOfAutoHeight(o):{redos:[],undos:[]}}})}};nn=El([l.OnLifecycle(l.LifecycleStages.Ready,nn),Tt(0,L.Inject(L.Injector)),Tt(1,L.Inject(f.SheetInterceptorService)),Tt(2,L.Inject(f.SelectionManagerService)),Tt(3,L.Inject(l.IUniverInstanceService)),Tt(4,L.Inject(P.SheetSkeletonManagerService))],nn);function Ol(i,e,t,n,o,r){const s=[],a=[];if(o.copyType===We.CUT){const{undos:c,redos:d}=yl(i,t,n,o,r);s.push(...d),a.push(...c)}else{const{undos:c,redos:d}=Xo(t,n,i,e,r);s.push(...d),a.push(...c);const{undos:u,redos:h}=jo(t,n,i,e,r);s.push(...h),a.push(...u);const{undos:m,redos:_}=zo(t,n,i,e,r);s.push(..._),a.push(...m);const{undos:g,redos:S}=di(t,n,i,e,r);s.push(...S),a.push(...g)}return{undos:a,redos:s}}function yl(i,e,t,n,o){let r=[],s=[];const{copyRange:a}=n;if(a){const c=o.get(l.IUniverInstanceService),d=o.get(f.SheetInterceptorService),u=c.getUniverSheetInstance(e),h=u==null?void 0:u.getSheetBySheetId(t);if(h){const m=h.getRange(a).getValues(),_=m.reduce((T,E,O)=>(E.forEach((y,x)=>{T.setValue(a.startRow+O,a.startColumn+x,null)}),T),new l.ObjectMatrix),g=m.reduce((T,E,O)=>(E.forEach((y,x)=>{T.setValue(a.startRow+O,a.startColumn+x,y)}),T),new l.ObjectMatrix),S=m.reduce((T,E,O)=>(E.forEach((y,x)=>{T.setValue(i.startRow+O,i.startColumn+x,y)}),T),new l.ObjectMatrix),v=h.getRange(i).getValues().reduce((T,E,O)=>(E.forEach((y,x)=>{T.setValue(i.startRow+O,i.startColumn+x,y)}),T),new l.ObjectMatrix),I={from:_.getMatrix(),to:S.getMatrix(),unitId:e,subUnitId:t},b={from:g.getMatrix(),to:v.getMatrix(),unitId:e,subUnitId:t},R=d.onCommandExecute({id:f.MoveRangeCommand.id,params:{toRange:i,fromRange:a}});r=[{id:f.MoveRangeMutation.id,params:I},...R.redos,{id:f.SetSelectionsOperation.id,params:{unitId:e,sheetId:t,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:i}]}}],s=[{id:f.SetSelectionsOperation.id,params:{unitId:e,sheetId:t,pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,selections:[{range:a}]}},...R.undos,{id:f.MoveRangeMutation.id,params:b}]}}return{undos:s,redos:r}}function jo(i,e,t,n,o){const r=[],s=[],{startColumn:a,startRow:c}=t,d=new l.ObjectMatrix;n.forValue((m,_,g)=>{d.setValue(m+c,_+a,{v:g.v})});const u={unitId:i,subUnitId:e,cellValue:d.getData()};r.push({id:f.SetRangeValuesMutation.id,params:u});const h=f.SetRangeValuesUndoMutationFactory(o,u);return s.push({id:f.SetRangeValuesMutation.id,params:h}),{undos:s,redos:r}}function zo(i,e,t,n,o){const r=[],s=[],{startColumn:a,startRow:c}=t,d=new l.ObjectMatrix;n.forValue((m,_,g)=>{var S;d.setValue(m+c,_+a,{s:g.s}),(S=g.p)!=null&&S.body&&d.setValue(m+c,_+a,{p:g.p})});const u={unitId:i,subUnitId:e,cellValue:d.getData()};r.push({id:f.SetRangeValuesMutation.id,params:u});const h=f.SetRangeValuesUndoMutationFactory(o,u);return s.push({id:f.SetRangeValuesMutation.id,params:h}),{undos:s,redos:r}}function Xo(i,e,t,n,o){const r=[],s=[],a=new l.ObjectMatrix,{startColumn:c,startRow:d}=t;if(n.forValue((u,h,m)=>{m.s&&a.setValue(u+d,h+c,{s:null})}),a.getLength()>0){const u={subUnitId:e,unitId:i,cellValue:a.getData()};r.push({id:f.SetRangeValuesMutation.id,params:u});const h=f.SetRangeValuesUndoMutationFactory(o,u);s.push({id:f.SetRangeValuesMutation.id,params:h})}return{undos:s,redos:r}}function di(i,e,t,n,o){const r=[],s=[],{startColumn:a,startRow:c,endColumn:d,endRow:u}=t;let h=!1;const m=[];if(n.forValue((S,v,I)=>{if(I.rowSpan){const b=I.colSpan||1,R={startRow:c+S,endRow:c+S+I.rowSpan-1,startColumn:a+v,endColumn:a+v+b-1};m.push(R),h=!0}else if(I.colSpan){const b=I.rowSpan||1,R={startRow:c+S,endRow:c+S+b-1,startColumn:a+v,endColumn:a+v+I.colSpan-1};m.push(R),h=!0}}),h){const v=o.get(l.IUniverInstanceService).getUniverSheetInstance(i),I=v==null?void 0:v.getSheetBySheetId(e);if(v&&I){const R=I.getMergeData().filter(O=>l.Rectangle.intersects({startRow:c,startColumn:a,endRow:u,endColumn:d},O)),T={unitId:i,subUnitId:e,ranges:R};r.push({id:f.RemoveWorksheetMergeMutation.id,params:T});const E=f.RemoveMergeUndoMutationFactory(o,T);s.push({id:f.AddWorksheetMergeMutation.id,params:E})}}const _={unitId:i,subUnitId:e,ranges:m};r.push({id:f.AddWorksheetMergeMutation.id,params:_});const g=f.AddMergeUndoMutationFactory(o,_);return s.push({id:f.RemoveWorksheetMergeMutation.id,params:g}),{undos:s,redos:r}}var xl=Object.defineProperty,Al=Object.getOwnPropertyDescriptor,Pl=(i,e,t,n)=>{for(var o=n>1?void 0:n?Al(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&xl(e,t,o),o},Ye=(i,e)=>(t,n)=>e(t,n,i);let on=class extends l.Disposable{constructor(i,e,t,n,o,r,s){super(),this._currentUniverSheet=i,this._commandService=e,this._configService=t,this._sheetClipboardService=n,this._messageService=o,this._injector=r,this._localService=s,this._init()}_init(){[Vi,Ss,et].forEach(e=>this.disposeWithMe(this._commandService.registerAsMultipleCommand(e))),[Fi,Wi,ji,zi].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e))),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initCopyingHooks())),this.disposeWithMe(this._sheetClipboardService.addClipboardHook(this._initPastingHook()));const i=this._initSpecialPasteHooks().map(e=>this._sheetClipboardService.addClipboardHook(e));this.disposeWithMe({dispose:()=>i.forEach(e=>e.dispose())})}_initCopyingHooks(){const i=this;let e=null;return{hookName:de.DEFAULT_COPY,isDefaultHook:!0,onBeforeCopy(t,n){e=i._getWorksheet(t,n)},onCopyCellContent(t,n){const o=e.getCell(t,n);return`${o==null?void 0:o.v}`||""},onCopyCellStyle:(t,n,o,r)=>{const s={};(o||r)&&(s.rowspan=`${o||1}`,s.colspan=`${r||1}`);const c=e.getRange(t,n).getTextStyle();let d="";return c&&(d=l.handleStyleToString(c)),d&&(s.style=d),s},onCopyColumn(t){return{width:`${e.getColumnWidth(t)}`}},onCopyRow(t){return{style:`height: ${e.getRowHeight(t)}px;`}},onAfterCopy(){e=null}}}_initPastingHook(){const i=this;let e=null,t=null,n=null;return{hookName:de.DEFAULT_PASTE,isDefaultHook:!0,onBeforePaste(o,r,s){n=i._getWorksheet(o,r),e=o,t=r;const a=i._configService.getConfig(f.MAX_CELL_PER_SHEET_KEY),{endRow:c,endColumn:d}=s;return a&&c*d>a?(i._messageService.show({type:ne.MessageType.Error,content:i._localService.t("clipboard.paste.exceedMaxCells")}),!1):!0},onPasteRows(o,r){const s=[],a=n.getMaxRows(),c=o.endRow-a,d=r.length-c;if(c>0){const m={};r.slice(d).forEach((g,S)=>{const v=g==null?void 0:g.style;if(!v)return;const I=v.split(";");let b=l.DEFAULT_WORKSHEET_ROW_HEIGHT;I.find(R=>{R=R.toLowerCase();const T=M.textTrim(R.substr(0,R.indexOf(":"))),E=M.textTrim(R.substr(R.indexOf(":")+1));return T==="height"?(b=parseFloat(E),!0):!1}),m[S]={h:b,hd:l.BooleanNumber.FALSE}});const _={unitId:e,subUnitId:t,range:{...o,startRow:a},rowInfo:m};s.push({id:f.InsertRowMutation.id,params:_})}const u={};r.slice(0,d).forEach((m,_)=>{const g=m.style;if(!g)return;const S=g.split(";");let v=l.DEFAULT_WORKSHEET_ROW_HEIGHT;S.find(I=>{I=I.toLowerCase();const b=M.textTrim(I.substr(0,I.indexOf(":"))),R=M.textTrim(I.substr(I.indexOf(":")+1));return b==="height"?(v=parseFloat(R),!0):!1}),u[_]=v});const h={unitId:e,subUnitId:t,ranges:[{...o,endRow:Math.min(o.endRow,a)}],rowHeight:u};return s.push({id:f.SetWorksheetRowHeightMutation.id,params:h}),{redos:s,undos:[]}},onPasteColumns(o,r,s){const a=[],c=n.getMaxColumns(),d=o.endColumn-c,u=r.length-d;if(d>0){const m={unitId:e,subUnitId:t,range:{...o,startColumn:c},colInfo:r.slice(u).map(_=>({w:_.width?+_.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH,hd:l.BooleanNumber.FALSE}))};a.push({id:f.InsertColMutation.id,params:m})}const h={unitId:e,subUnitId:t,ranges:[{...o,endRow:Math.min(o.endColumn,c)}],colWidth:r.slice(0,u).map(m=>m.width?+m.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return a.push({id:f.SetWorksheetColWidthMutation.id,params:h}),{redos:a,undos:[]}},onPasteCells(o,r,s,a){return i._onPasteCells(o,r,e,t,s,a)},onAfterPaste(o){n=null}}}_onPasteCells(i,e,t,n,o,r){const s={get:this._injector.get.bind(this._injector)};return Ol(i,e,t,n,r,s)}_initSpecialPasteHooks(){const i={get:this._injector.get.bind(this._injector)},e=this,t={hookName:de.SPECIAL_PASTE_VALUE,specialPasteInfo:{label:"specialPaste.value"},onPasteCells:(s,a,c,d)=>{const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),h=u.getUnitId(),m=u.getActiveSheet().getSheetId();return jo(h,m,s,a,i)}},n={hookName:de.SPECIAL_PASTE_FORMAT,specialPasteInfo:{label:"specialPaste.format"},onPasteCells(s,a,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),h=u.getUnitId(),m=u.getActiveSheet().getSheetId(),_=[],g=[],{undos:S,redos:v}=Xo(h,m,s,a,i);_.push(...v),g.push(...S);const{undos:I,redos:b}=di(h,m,s,a,i);_.push(...b),g.push(...I);const{undos:R,redos:T}=zo(h,m,s,a,i);return _.push(...T),g.push(...R),{undos:g,redos:_}}},o={hookName:de.SPECIAL_PASTE_COL_WIDTH,specialPasteInfo:{label:"specialPaste.colWidth"},onPasteCells(){return{undos:[],redos:[]}},onPasteColumns(s,a,c){const d=e._currentUniverSheet.getCurrentUniverSheetInstance(),u=d.getUnitId(),h=d.getActiveSheet().getSheetId(),m=[],g=e._getWorksheet(u,h).getMaxColumns(),S=s.endColumn-g,v=a.length-S,I={unitId:u,subUnitId:h,ranges:[{...s,endRow:Math.min(s.endColumn,g)}],colWidth:a.slice(0,v).map(b=>b.width?+b.width:l.DEFAULT_WORKSHEET_COLUMN_WIDTH)};return m.push({id:f.SetWorksheetColWidthMutation.id,params:I}),m.push({id:f.SetWorksheetColWidthMutation.id,params:I}),{redos:m,undos:[]}}},r={hookName:de.SPECIAL_PASTE_BESIDES_BORDER,specialPasteInfo:{label:"specialPaste.besidesBorder"},onPasteCells(s,a,c,d){const u=e._currentUniverSheet.getCurrentUniverSheetInstance(),h=u.getUnitId(),m=u.getActiveSheet().getSheetId(),_=[],g=[],{startColumn:S,startRow:v,endColumn:I,endRow:b}=s,R=new l.ObjectMatrix;a.forValue((x,A,H)=>{const D=H.s;typeof D=="object"&&R.setValue(x+v,A+S,{s:{...D,bd:void 0},v:H.v})});const T={unitId:h,subUnitId:m,cellValue:R.getData()};_.push({id:f.SetRangeValuesMutation.id,params:T});const E=f.SetRangeValuesUndoMutationFactory(i,T);g.push({id:f.SetRangeValuesMutation.id,params:E});const{undos:O,redos:y}=di(h,m,s,a,i);return g.push(...O),_.push(...y),{redos:_,undos:g}}};return[t,n,o,r]}_getWorksheet(i,e){var n;const t=(n=this._currentUniverSheet.getUniverSheetInstance(i))==null?void 0:n.getSheetBySheetId(e);if(!t)throw new Error(`[SheetClipboardController]: cannot find a worksheet with unitId ${i} and subUnitId ${e}.`);return t}};on=Pl([l.OnLifecycle(l.LifecycleStages.Rendered,on),Ye(0,l.IUniverInstanceService),Ye(1,l.ICommandService),Ye(2,l.IConfigService),Ye(3,qe),Ye(4,M.IMessageService),Ye(5,L.Inject(L.Injector)),Ye(6,L.Inject(l.LocaleService))],on);var Dl=Object.defineProperty,Hl=Object.getOwnPropertyDescriptor,Nl=(i,e,t,n)=>{for(var o=n>1?void 0:n?Hl(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Dl(e,t,o),o},Et=(i,e)=>(t,n)=>e(t,n,i);let rn=class extends l.Disposable{constructor(i,e,t,n,o){super(),this._currentUniverService=i,this._contextMenuService=e,this._renderManagerService=t,this._selectionManagerService=n,this._selectionRenderService=o,this._currentUniverService.currentSheet$.subscribe(r=>{if(r==null)throw new Error("workbook is null");this._addListeners()})}_addListeners(){const i=le(this._currentUniverService,this._renderManagerService);if(!i)return;const e=i.spreadsheet.onPointerDownObserver,t=e.add(a=>{if(a.button===2){const c=this._selectionManagerService.getSelections(),d=c==null?void 0:c[0];if(!d)return;const u=d.range.rangeType,h=this._selectionRenderService.convertSelectionRangeToData(d).rangeWithCoord,m=()=>{if(!h)return!1;const g=a.offsetX,S=a.offsetY;switch(u){case l.RANGE_TYPE.ROW:return h.startY<=S&&h.endY>=S;case l.RANGE_TYPE.COLUMN:return h.startX<=g&&h.endX>=g;default:return h.startX<=g&&h.endX>=g&&h.startY<=S&&h.endY>=S}},_=g=>{this._contextMenuService.triggerContextMenu(a,g)};m()?u===l.RANGE_TYPE.COLUMN?_(ee.COL_HEADER_CONTEXT_MENU):u===l.RANGE_TYPE.ROW?_(ee.ROW_HEADER_CONTEXT_MENU):_(M.MenuPosition.CONTEXT_MENU):_(M.MenuPosition.CONTEXT_MENU)}});this.disposeWithMe(l.toDisposable(()=>e.remove(t)));const o=i.spreadsheetRowHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,ee.ROW_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(o)));const s=i.spreadsheetColumnHeader.onPointerDownObserver.add(a=>{a.button===2&&this._contextMenuService.triggerContextMenu(a,ee.COL_HEADER_CONTEXT_MENU)});this.disposeWithMe(l.toDisposable(()=>e.remove(s)))}};rn=Nl([l.OnLifecycle(l.LifecycleStages.Rendered,rn),Et(0,l.IUniverInstanceService),Et(1,M.IContextMenuService),Et(2,w.IRenderManagerService),Et(3,L.Inject(f.SelectionManagerService)),Et(4,se)],rn);var Ll=Object.defineProperty,Ul=Object.getOwnPropertyDescriptor,kl=(i,e,t,n)=>{for(var o=n>1?void 0:n?Ul(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Ll(e,t,o),o},ui=(i,e)=>(t,n)=>e(t,n,i);let sn=class extends l.RxDisposable{constructor(i,e,t){super(),this._currentUniverService=i,this._renderManagerService=e,this._undoRedoService=t,this._initialize(),this._commandExecutedListener()}_initialize(){this._initialNormalInput(),this._listenEditorBlur()}_listenEditorBlur(){this._currentUniverService.currentDoc$.pipe(B.takeUntil(this.dispose$)).subscribe(i=>{if(i==null)return;i.getUnitId()!==l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._undoRedoService.clearUndoRedo(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)})}_initialNormalInput(){const i={};this._currentUniverService.getCurrentUniverSheetInstance().getSheets().forEach(e=>{const t=e.getConfig();i[e.getSheetId()]={cellData:new l.ObjectMatrix(t.cellData),rowCount:t.rowCount,columnCount:t.columnCount}})}_commandExecutedListener(){}_getDocObject(){return G.getDocObject(this._currentUniverService,this._renderManagerService)}};sn=kl([l.OnLifecycle(l.LifecycleStages.Steady,sn),ui(0,l.IUniverInstanceService),ui(1,w.IRenderManagerService),ui(2,L.Inject(l.IUndoRedoService))],sn);const Yo=[M.KeyCode.ARROW_DOWN,M.KeyCode.ARROW_UP,M.KeyCode.ARROW_LEFT,M.KeyCode.ARROW_RIGHT],Bl=[M.KeyCode.ENTER,M.KeyCode.TAB,...Yo];function Vl(){const i=[];for(const e of Yo)i.push({id:gt.id,binding:e,preconditions:t=>Wt(t),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:e,isShift:!1}}),i.push({id:gt.id,binding:e|M.MetaKeys.SHIFT,preconditions:t=>Wt(t),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:e,isShift:!0}});return i}const Fl={id:Ie.id,binding:M.KeyCode.ENTER,description:"shortcut.sheet.toggle-editing",group:"4_sheet-edit",preconditions:i=>Wt(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:M.KeyCode.ENTER}},Wl={id:Ie.id,binding:M.KeyCode.TAB,preconditions:i=>Wt(i),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:M.KeyCode.TAB}},jl={id:Ie.id,binding:M.KeyCode.ESC,description:"shortcut.sheet.abort-editing",group:"4_sheet-edit",preconditions:i=>i.getContextValue(l.FOCUSING_EDITOR),staticParameters:{visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:M.KeyCode.ESC}},zl={id:G.BreakLineCommand.id,description:"shortcut.sheet.break-line",group:"4_sheet-edit",preconditions:i=>i.getContextValue(l.FOCUSING_EDITOR),binding:M.KeyCode.ENTER|M.MetaKeys.ALT},Xl={id:G.DeleteLeftCommand.id,preconditions:i=>Er(i)||Ai(i),binding:M.KeyCode.BACKSPACE},Yl={id:Ie.id,description:"shortcut.sheet.delete-and-start-editing",group:"4_sheet-edit",preconditions:i=>Tr(i)&&!Ai(i),binding:M.KeyCode.BACKSPACE,staticParameters:{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:M.KeyCode.BACKSPACE}};var $l=Object.defineProperty,Zl=Object.getOwnPropertyDescriptor,Gl=(i,e,t,n)=>{for(var o=n>1?void 0:n?Zl(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&$l(e,t,o),o},we=(i,e)=>(t,n)=>e(t,n,i);let an=class extends l.Disposable{constructor(e,t,n,o,r,s,a,c,d,u){super();C(this,"_onInputSubscription");C(this,"_cursorChangeObservers");C(this,"_editorVisiblePrevious",!1);C(this,"_isCursorChange",0);this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._editorBridgeService=o,this._contextService=r,this._cellEditorManagerService=s,this._lexerTreeBuilder=a,this._undoRedoService=c,this._sheetInterceptorService=d,this._selectionManagerService=u,this._initialize(),this._commandExecutedListener()}dispose(){var n;(n=this._onInputSubscription)==null||n.unsubscribe();const e=this._getEditorObject();if(e==null)return;const{document:t}=e;t.onPointerDownObserver.remove(this._cursorChangeObservers)}_initialize(){this._initialExitInput(),this._cursorStateListener()}_initialExitInput(){this._onInputSubscription=this._editorBridgeService.visible$.subscribe(e=>{const{visible:t,keycode:n,eventType:o}=e;if(t===this._editorVisiblePrevious)return;if(this._editorVisiblePrevious=t,t===!0){this._isCursorChange=o===w.DeviceInputEventType.PointerDown?2:1;return}this._isCursorChange=0;const r=this._selectionManagerService.getSelections(),s=this._selectionManagerService.getCurrent();if(s==null)return;const{unitId:a,sheetId:c,pluginName:d}=s;if(this._exitInput(e),n===M.KeyCode.ESC){this._commandService.syncExecuteCommand(f.SetSelectionsOperation.id,{unitId:a,subUnitId:c,pluginName:d,selections:r});return}const u=this._editorBridgeService.getState();if(u==null)return;const{unitId:h,sheetId:m,row:_,column:g,documentLayoutObject:S}=u;if(S==null||(this._moveCursor(n),this._editorBridgeService.getEditorDirty()===!1))return;const I=this._currentUniverService.getUniverSheetInstance(h),b=I==null?void 0:I.getSheetBySheetId(m);if(b==null)return;const R=l.Tools.deepClone(b.getCellRaw(_,g)||{}),E=S.documentModel.getSnapshot(),O=E.body;if(O==null)return;const y=O.dataStream;let A=y.substring(y.length-2,y.length)===l.DEFAULT_EMPTY_DOCUMENT_VALUE?y.substring(0,y.length-2):y;if(l.isFormulaString(A)){if(R.f===A)return;const N=this._lexerTreeBuilder.checkIfAddBracket(A);for(let U=0;U<N;U++)A+=Z.matchToken.CLOSE_BRACKET;R.f=A,R.v=null,R.p=null}else if(O.textRuns&&O.textRuns.length>1)R.p=E,R.v=null,R.f=null;else{if(A==R.v||A==""&&R.v==null)return;R.v=A,R.f=null,R.p=null}const H={subUnitId:m,unitId:h,workbook:I,worksheet:b,row:_,col:g},D=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT)(R,H);this._commandService.executeCommand(f.SetRangeValuesCommand.id,{subUnitId:m,unitId:h,range:{startRow:_,startColumn:g,endRow:_,endColumn:g},value:D}),a===h&&m!==c&&this._commandService.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:m,unitId:h})})}_exitInput(e){this._contextService.setContextValue(l.FOCUSING_EDITOR_INPUT_FORMULA,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR,!1),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!1),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._cellEditorManagerService.setState({show:e.visible});const t=this._editorBridgeService.getCurrentEditorId();t!=null&&(this._undoRedoService.clearUndoRedo(t),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))}_moveCursor(e){if(e==null||!Bl.includes(e))return;let t=l.Direction.LEFT;switch(e){case M.KeyCode.ENTER:t=l.Direction.DOWN;break;case M.KeyCode.TAB:t=l.Direction.RIGHT;break;case M.KeyCode.ARROW_DOWN:t=l.Direction.DOWN;break;case M.KeyCode.ARROW_UP:t=l.Direction.UP;break;case M.KeyCode.ARROW_LEFT:t=l.Direction.LEFT;break;case M.KeyCode.ARROW_RIGHT:t=l.Direction.RIGHT;break}e===M.KeyCode.ENTER||e===M.KeyCode.TAB?this._commandService.executeCommand(je.id,{keycode:e,direction:t}):this._commandService.executeCommand(me.id,{direction:t})}_cursorStateListener(){const e=this._getEditorObject();if(e==null)return;const{document:t}=e;this._cursorChangeObservers=t.onPointerDownObserver.add(()=>{this._isCursorChange===1&&(this._isCursorChange=2)})}_commandExecutedListener(){const e=[gt.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=t.params,{keycode:o,isShift:r}=n;if(o!=null&&this._isCursorChange===2){this._moveInEditor(o,r);return}this._editorBridgeService.changeVisible(n)}}))}_moveInEditor(e,t){let n=l.Direction.LEFT;e===M.KeyCode.ARROW_DOWN?n=l.Direction.DOWN:e===M.KeyCode.ARROW_UP?n=l.Direction.UP:e===M.KeyCode.ARROW_RIGHT&&(n=l.Direction.RIGHT),t?this._commandService.executeCommand(G.MoveSelectionOperation.id,{direction:n}):this._commandService.executeCommand(G.MoveCursorOperation.id,{direction:n})}_getEditorObject(){return Bt(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};an=Gl([l.OnLifecycle(l.LifecycleStages.Steady,an),we(0,l.IUniverInstanceService),we(1,w.IRenderManagerService),we(2,l.ICommandService),we(3,Ce),we(4,l.IContextService),we(5,wt),we(6,L.Inject(Z.LexerTreeBuilder)),we(7,l.IUndoRedoService),we(8,L.Inject(f.SheetInterceptorService)),we(9,L.Inject(f.SelectionManagerService))],an);var Kl=Object.defineProperty,Jl=Object.getOwnPropertyDescriptor,Ql=(i,e,t,n)=>{for(var o=n>1?void 0:n?Jl(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Kl(e,t,o),o},Te=(i,e)=>(t,n)=>e(t,n,i);let ln=class extends l.RxDisposable{constructor(e,t,n,o,r,s,a,c,d,u){super();C(this,"_loadedMap",new Set);this._univerInstanceService=e,this._renderManagerService=t,this._editorBridgeService=n,this._docSkeletonManagerService=o,this._docViewModelManagerService=r,this._commandService=s,this._contextService=a,this._formulaEditorManagerService=c,this._undoRedoService=d,this._textSelectionManagerService=u,this._initialize()}_initialize(){this._syncFormulaEditorContent(),this._commandExecutedListener(),this._syncEditorSize(),this._listenFxBtnClick(),this._renderManagerService.currentRender$.pipe(B.takeUntil(this.dispose$)).subscribe(e=>{e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._loadedMap.has(e)||(this._initialMain(e),this._loadedMap.add(e)))}),this._textSelectionManagerService.textSelection$.pipe(B.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const{unitId:t}=e;t!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!1),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))})}_listenFxBtnClick(){this._formulaEditorManagerService.fxBtnClick$.pipe(B.takeUntil(this.dispose$)).subscribe(()=>{var t;if(this._contextService.getContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN)&&!this._contextService.getContextValue(l.FOCUSING_EDITOR)){this._univerInstanceService.setCurrentUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0);const n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.PointerDown});const r=(t=n==null?void 0:n.getBody())==null?void 0:t.dataStream;if(r==null)return;let s=r.startsWith("=")?r:`=${r}`;s=s.replace(/\r\n$/,"");const a=[{startOffset:s.length,endOffset:s.length}],c={unitId:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:s},segmentId:""};this._commandService.executeCommand(G.CoverContentCommand.id,c),this._textSelectionManagerService.replaceTextRanges(a)}})}_initialMain(e){const t=this._renderManagerService.getRenderById(e);if(t==null)return;const{mainComponent:n}=t;n!=null&&this.disposeWithMe(l.toDisposable(n.onPointerDownObserver.add(()=>{this._contextService.setContextValue(l.FOCUSING_FORMULA_EDITOR,!0),this._undoRedoService.clearUndoRedo(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),this._editorBridgeService.isVisible().visible===!1&&this._editorBridgeService.changeVisible({visible:!0,eventType:w.DeviceInputEventType.PointerDown})})))}_syncEditorSize(){this._formulaEditorManagerService.position$.pipe(B.takeUntil(this.dispose$)).subscribe(e=>{if(e==null)return;const t=Bt(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,this._renderManagerService),n=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(t==null||n==null)return;const{width:o,height:r}=e,{engine:s}=t;n.updateDocumentDataPageSize(o),this._autoScroll(),requestIdleCallback(()=>{s.resizeBySize(o,r)})})}_syncFormulaEditorContent(){this._editorBridgeService.state$.pipe(B.takeUntil(this.dispose$)).subscribe(e=>{e==null||this._editorBridgeService.isForceKeepVisible()||this._editorSyncHandler(e)}),this._editorBridgeService.visible$.pipe(B.takeUntil(this.dispose$)).subscribe(e=>{if(e==null||e.visible===!1||this._editorBridgeService.isForceKeepVisible())return;const t=this._editorBridgeService.getState();t!=null&&this._editorSyncHandler(t)})}_editorSyncHandler(e){var s;const t=(s=e.documentLayoutObject.documentModel)==null?void 0:s.getBody();let n=t==null?void 0:t.dataStream,o=t==null?void 0:t.paragraphs,r=[];n==null||o==null||(e.isInArrayFormulaRange===!0&&this._editorBridgeService.isVisible().eventType===w.DeviceInputEventType.Dblclick?(n=`\r
|
|
15
|
+
`,o=[{startIndex:0}]):e.isInArrayFormulaRange===!0&&(r=(t==null?void 0:t.textRuns)||[]),this._syncContentAndRender(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,n,o,r),this._autoScroll())}_commandExecutedListener(){const e=[G.RichTextEditingMutation.id,Xt.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var o,r;if(e.includes(n.id)){const s=n.params,{unitId:a}=s;if(t.includes(a)){const c=this._univerInstanceService.getUniverDocInstance(a),d=(o=c==null?void 0:c.getBody())==null?void 0:o.dataStream,u=(r=c==null?void 0:c.getBody())==null?void 0:r.paragraphs,h=a===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY?l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY;if(d==null||u==null)return;this._syncContentAndRender(h,d,u),this._autoScroll()}}}))}_syncContentAndRender(e,t,n,o=[]){var h;const r=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY],s=this._docSkeletonManagerService.getSkeletonByUnitId(e),a=this._univerInstanceService.getUniverDocInstance(e),c=this._docViewModelManagerService.getViewModel(e);if(a==null||c==null||s==null)return;a.getBody().dataStream=t,a.getBody().paragraphs=n,e===l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY&&(a.getBody().textRuns=[]),o.length>0&&(a.getBody().textRuns=o),c.reset(a);const{skeleton:d}=s,u=this._renderManagerService.getRenderById(e);u!=null&&(d.calculate(),r.includes(e)&&((h=u.mainComponent)==null||h.makeDirty()))}_autoScroll(){var g,S;const e=(g=this._docSkeletonManagerService.getSkeletonByUnitId(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:g.skeleton,t=this._formulaEditorManagerService.getPosition(),n=this._renderManagerService.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY),o=this._univerInstanceService.getUniverDocInstance(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY);if(e==null||t==null||n==null||o==null)return;const{marginTop:r=0,marginBottom:s=0}=o.getSnapshot().documentStyle,{scene:a,mainComponent:c}=n;let{actualHeight:d}=e.getActualSize();d+=r+s;const{width:u,height:h}=t,m=a.getViewport(G.VIEWPORT_KEY.VIEW_MAIN);let _=m==null?void 0:m.getScrollBar();d>h?_==null?m&&new w.ScrollBar(m,{enableHorizontal:!1}):m==null||m.resetSizeAndScrollBar():(_=null,m==null||m.scrollTo({x:0,y:0}),(S=m==null?void 0:m.getScrollBar())==null||S.dispose()),a.transformByState({width:u,height:d}),c==null||c.resize(u,d)}};ln=Ql([l.OnLifecycle(l.LifecycleStages.Steady,ln),Te(0,l.IUniverInstanceService),Te(1,w.IRenderManagerService),Te(2,Ce),Te(3,L.Inject(G.DocSkeletonManagerService)),Te(4,L.Inject(G.DocViewModelManagerService)),Te(5,l.ICommandService),Te(6,l.IContextService),Te(7,en),Te(8,l.IUndoRedoService),Te(9,L.Inject(G.TextSelectionManagerService))],ln);var ql=Object.defineProperty,ec=Object.getOwnPropertyDescriptor,tc=(i,e,t,n)=>{for(var o=n>1?void 0:n?ec(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ql(e,t,o),o},nc=(i,e)=>(t,n)=>e(t,n,i);let cn=class extends l.Disposable{constructor(i){super(),this._currentUniverService=i,setTimeout(()=>{this._initialize()},0)}_initialize(){this._currentUniverService.createDoc({id:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{}});const i={id:l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY,body:{dataStream:`${l.DEFAULT_EMPTY_DOCUMENT_VALUE}`,textRuns:[],paragraphs:[{startIndex:0}]},documentStyle:{pageSize:{width:1/0,height:1/0},marginTop:5,marginBottom:5,marginRight:0,marginLeft:0,paragraphLineGapDefault:0,renderConfig:{horizontalAlign:l.HorizontalAlign.UNSPECIFIED,verticalAlign:l.VerticalAlign.UNSPECIFIED,centerAngle:0,vertexAngle:0,wrapStrategy:l.WrapStrategy.WRAP}}};this._currentUniverService.createDoc(i)}};cn=tc([l.OnLifecycle(l.LifecycleStages.Rendered,cn),nc(0,l.IUniverInstanceService)],cn);const $o={sheetFooterBarHeight:"36",sheetContainer:"univer-sheet-container"};var ic=Object.defineProperty,oc=Object.getOwnPropertyDescriptor,rc=(i,e,t,n)=>{for(var o=n>1?void 0:n?oc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ic(e,t,o),o},ge=(i,e)=>(t,n)=>e(t,n,i);const Zo=-1e3,Go=5,sc=2;let dn=class extends l.Disposable{constructor(e,t,n,o,r,s,a,c,d,u,h){super();C(this,"_onInputSubscription");C(this,"_onInputActivateSubscription");C(this,"_editorVisiblePrevious",!1);this._docSkeletonManagerService=e,this._docViewModelManagerService=t,this._contextService=n,this._currentUniverService=o,this._renderManagerService=r,this._editorBridgeService=s,this._cellEditorManagerService=a,this._textSelectionRenderManager=c,this._textSelectionManagerService=d,this._commandService=u,this._localService=h,this._initialize(),this._commandExecutedListener()}dispose(){var e,t;(e=this._onInputSubscription)==null||e.unsubscribe(),(t=this._onInputActivateSubscription)==null||t.unsubscribe()}_initialize(){this._initialEditFocusListener(),this._initialStartEdit(),this._initialKeyboardListener(),this._initialCursorSync(),this._listenEditorFocus()}_listenEditorFocus(){const e=this._getEditorObject();e!=null&&this.disposeWithMe(l.toDisposable(e.document.onPointerDownObserver.add(()=>{var t;if(this._editorBridgeService.isVisible()){const n=this._editorBridgeService.getState(),o=this._editorBridgeService.getCurrentEditorId();if(n==null||o==null)return;const r=(t=this._docSkeletonManagerService.getSkeletonByUnitId(o))==null?void 0:t.skeleton;if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u}=n;this._fitTextSize(s,c,r,a,d,u)}})))}_initialCursorSync(){this._cellEditorManagerService.focus$.subscribe(()=>{this._textSelectionRenderManager.sync()})}_initialEditFocusListener(){this._onInputSubscription=this._editorBridgeService.state$.subscribe(e=>{if(e==null||this._editorBridgeService.isForceKeepVisible())return;const{position:t,documentLayoutObject:n,scaleX:o,editorUnitId:r}=e;if(this._getEditorObject()==null)return;const{startX:a,endX:c}=t,{textRotation:d,wrapStrategy:u,documentModel:h}=n,{a:m}=d;h.updateDocumentId(r),u===l.WrapStrategy.WRAP&&m===0&&h.updateDocumentDataPageSize((c-a)/o),this._currentUniverService.changeDoc(r,h),this._contextService.setContextValue(l.FOCUSING_EDITOR_BUT_HIDDEN,!0),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}]),this._textSelectionRenderManager.activate(Zo,Zo)})}_fitTextSize(e,t,n,o,r=1,s=1){const{startX:a,startY:c,endX:d,endY:u}=e,h=o.documentModel;if(h==null)return;const{actualWidth:m,actualHeight:_}=this._predictingSize(e,t,n,o,r,s),{verticalAlign:g,paddingData:S,fill:v}=o;let I=d-a,b=u-c;if(I<m&&(I=m),b<_)b=_,h.updateDocumentDataMargin(S);else{let R=S.t||0;g===l.VerticalAlign.MIDDLE?R=(b-_)/2:g===l.VerticalAlign.BOTTOM&&(R=b-_),R/=s,R=R<(S.t||0)?S.t||0:R,h.updateDocumentDataMargin({t:R})}n.calculate(),this._editAreaProcessing(I,b,e,t,v)}_predictingSize(e,t,n,o,r=1,s=1){const{startX:a,endX:c}=e,{textRotation:d,wrapStrategy:u}=o,h=o.documentModel,{a:m}=d,_=document.body.clientWidth;if(u===l.WrapStrategy.WRAP&&m===0){const{actualWidth:v,actualHeight:I}=n.getActualSize();return{actualWidth:v*r,actualHeight:I*s}}h==null||h.updateDocumentDataPageSize((_-a-t.left)/r),n.calculate();const g=n.getActualSize();let S=c-a;return S<g.actualWidth*r+Go*r&&(S=g.actualWidth*r+Go),h==null||h.updateDocumentDataPageSize(S/r),h==null||h.updateDocumentRenderConfig({horizontalAlign:l.HorizontalAlign.UNSPECIFIED}),{actualWidth:S,actualHeight:g.actualHeight*s}}_editAreaProcessing(e,t,n,o,r,s=1,a=1){var R;const c=this._getEditorObject();if(c==null)return;const{startX:d,startY:u}=n,{document:h,scene:m,engine:_}=c,g=m.getViewport(G.VIEWPORT_KEY.VIEW_MAIN),S=document.body.clientHeight-u-parseFloat($o.sheetFooterBarHeight)-o.top-sc*2,v=document.body.clientWidth-d-o.left;let I=t,b=g==null?void 0:g.getScrollBar();I>S?(I=S,b==null?g&&new w.ScrollBar(g,{enableHorizontal:!1}):g==null||g.resetSizeAndScrollBar()):(b=null,(R=g==null?void 0:g.getScrollBar())==null||R.dispose()),e+=(b==null?void 0:b.barSize)||0,e>v&&(e=v),e=Math.round(e),t=Math.round(t),I=Math.round(t),m.transformByState({width:e,height:t}),h.resize(e,t),this._addBackground(m,e,t,r),requestIdleCallback(()=>{_.resizeBySize(e,I)}),this._cellEditorManagerService.setState({startX:d,startY:u,endX:e+d,endY:I+u,show:!0})}_addBackground(e,t,n,o){const r="_backgroundRectHelperColor_",s=e.getObject(r);s==null&&o==null||(s==null?e.addObjects([new w.Rect(r,{width:t,height:n,fill:o,evented:!1})],G.DOCS_COMPONENT_MAIN_LAYER_INDEX):o==null?s.dispose():(s.setProps({fill:o}),s.transformByState({width:t,height:n})))}_initialStartEdit(){this._onInputActivateSubscription=this._editorBridgeService.visible$.subscribe(e=>{var T,E,O;const{visible:t,eventType:n,keycode:o}=e;if(t===this._editorVisiblePrevious||(this._editorVisiblePrevious=t,t===!1))return;const r=this._editorBridgeService.getState();if(r==null)return;const{position:s,documentLayoutObject:a,canvasOffset:c,scaleX:d,scaleY:u,editorUnitId:h,unitId:m,isInArrayFormulaRange:_=!1}=r,g=this._getEditorObject();if(g==null)return;const{document:S,scene:v}=g;this._contextService.setContextValue(l.FOCUSING_EDITOR,!0);const{documentModel:I}=a,b=this._docSkeletonManagerService.getSkeletonByUnitId(h);if(b==null||I==null)return;const{skeleton:R}=b;if(this._fitTextSize(s,c,R,a,d,u),n===w.DeviceInputEventType.Keyboard||n===w.DeviceInputEventType.Dblclick&&_){const y=l.Tools.deepClone(I.snapshot),x=(T=this._docViewModelManagerService.getCurrent())==null?void 0:T.docViewModel;this._resetBodyStyle(y.body),I.reset(y),x.reset(I),S.makeDirty(),(o===M.KeyCode.BACKSPACE||n===w.DeviceInputEventType.Dblclick)&&(R.calculate(),this._editorBridgeService.changeEditorDirty(!0)),this._textSelectionManagerService.replaceTextRanges([{startOffset:0,endOffset:0}])}else if(n===w.DeviceInputEventType.Dblclick){const y=I.getBody().dataStream.length-2||0;(E=v.getViewport(G.VIEWPORT_KEY.VIEW_MAIN))==null||E.scrollTo({y:1/0}),this._textSelectionManagerService.replaceTextRanges([{startOffset:y,endOffset:y}])}(O=this._renderManagerService.getRenderById(m))==null||O.scene.resetCursor()})}_resetBodyStyle(e){e.dataStream=l.DEFAULT_EMPTY_DOCUMENT_VALUE,e.textRuns!=null&&(e.textRuns.length===1?(e.textRuns[0].st=0,e.textRuns[0].ed=1):e.textRuns=void 0),e.paragraphs!=null&&(e.paragraphs.length===1?e.paragraphs[0].startIndex=0:e.paragraphs=[{startIndex:0}]),e.sectionBreaks!=null&&(e.sectionBreaks=void 0),e.tables!=null&&(e.tables=void 0),e.customRanges!=null&&(e.customRanges=void 0),e.customBlocks!=null&&(e.customBlocks=void 0)}_initialKeyboardListener(){this._textSelectionRenderManager.onInputBefore$.subscribe(e=>{this._contextService.getContextValue(l.FOCUSING_FORMULA_EDITOR)||this._showEditorByKeyboard(e)})}_showEditorByKeyboard(e){if(e==null)return;const t=e.event;this._commandService.executeCommand(Ie.id,{visible:!0,eventType:w.DeviceInputEventType.Keyboard,keycode:t.which})}_commandExecutedListener(){const e=[G.RichTextEditingMutation.id,Xt.id],t=[l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{var o;if(e.includes(n.id)){const r=n.params,{unitId:s}=r,a=this._editorBridgeService.getCurrentEditorId();if(a==null)return;this._editorBridgeService.changeEditorDirty(!0);const c=(o=this._docSkeletonManagerService.getSkeletonByUnitId(a))==null?void 0:o.skeleton;if(c==null||!t.includes(s))return;const d=this._editorBridgeService.getState();if(d==null)return;const{position:u,documentLayoutObject:h,canvasOffset:m,scaleX:_,scaleY:g}=d;this._fitTextSize(u,m,c,h,_,g)}}))}_getEditorObject(){return Bt(this._editorBridgeService.getCurrentEditorId(),this._renderManagerService)}};dn=rc([l.OnLifecycle(l.LifecycleStages.Steady,dn),ge(0,L.Inject(G.DocSkeletonManagerService)),ge(1,L.Inject(G.DocViewModelManagerService)),ge(2,l.IContextService),ge(3,l.IUniverInstanceService),ge(4,w.IRenderManagerService),ge(5,Ce),ge(6,wt),ge(7,w.ITextSelectionRenderManager),ge(8,L.Inject(G.TextSelectionManagerService)),ge(9,l.ICommandService),ge(10,L.Inject(l.LocaleService))],dn);const Ko={id:"sheet.operation.set-activate-cell-edit",type:l.CommandType.OPERATION,handler:(i,e)=>(i.get(Ce).setState(e),!0)};var ac=Object.defineProperty,lc=Object.getOwnPropertyDescriptor,cc=(i,e,t,n)=>{for(var o=n>1?void 0:n?lc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ac(e,t,o),o},ke=(i,e)=>(t,n)=>e(t,n,i);let un=class extends l.Disposable{constructor(i,e,t,n,o,r,s,a){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._editorBridgeService=o,this._selectionManagerService=r,this._selectionRenderService=s,this._themeService=a,this._initialize(),this._commandExecutedListener()}dispose(){}_initialize(){this._initialSelectionListener(),this._initialEventListener()}_initialSelectionListener(){this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{this._selectionListener(i)}),this._selectionManagerService.selectionMoveStart$.subscribe(i=>{this._selectionListener(i)})}_selectionListener(i){var D,N;const e=this._selectionManagerService.getCurrent();if((e==null?void 0:e.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;const t=this._sheetSkeletonManagerService.getCurrent(),n=this._getSheetObject();if(t==null||n==null)return;const{skeleton:o,unitId:r,sheetId:s}=t,{scene:a,engine:c}=n;if(i==null||i.length===0||o==null||i[i.length-1]==null)return;const{primary:d}=i[i.length-1];if(d==null)return;const{startRow:u,startColumn:h}=d,m=this._selectionRenderService.convertCellRangeToInfo(d);if(m==null)return;const _=l.makeCellToSelection(m);if(_==null)return;const g=w.getCanvasOffsetByEngine(c);let{startX:S,startY:v,endX:I,endY:b}=_;const{scaleX:R,scaleY:T}=a.getAncestorScale(),E=a.getScrollXY(this._selectionRenderService.getViewPort());S=o.convertTransformToOffsetX(S,R,E),v=o.convertTransformToOffsetY(v,T,E),I=o.convertTransformToOffsetX(I,R,E),b=o.convertTransformToOffsetY(b,T,E);const O=this._currentUniverService.getCurrentUniverSheetInstance(),y=O.getActiveSheet(),x={workbook:O,worksheet:y,unitId:O.getUnitId(),subUnitId:y.getSheetId(),row:u,col:h},A=this._editorBridgeService.interceptor.fetchThroughInterceptors(this._editorBridgeService.interceptor.getInterceptPoints().BEFORE_CELL_EDIT)(y.getCell(u,h),x);let H=A&&o.getCellDocumentModelWithFormula(A);if((!H||H.documentModel==null)&&(H=o.getBlankCellDocumentModel(A)),(D=H.documentModel)==null||D.setZoomRatio(Math.max(R,T)),(A==null?void 0:A.isInArrayFormulaRange)===!0){const U=(N=H.documentModel)==null?void 0:N.getBody();U&&(U.textRuns=[{st:0,ed:U.dataStream.length-2,ts:{cl:{rgb:this._themeService.getCurrentTheme().textColorSecondary}}}])}this._commandService.executeCommand(Ko.id,{position:{startX:S,startY:v,endX:I,endY:b},scaleX:R,scaleY:T,canvasOffset:g,row:u,column:h,unitId:r,sheetId:s,documentLayoutObject:H,editorUnitId:l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,isInArrayFormulaRange:A==null?void 0:A.isInArrayFormulaRange})}_initialEventListener(){const i=this._getSheetObject();if(i==null)return;const{spreadsheet:e,spreadsheetColumnHeader:t,spreadsheetLeftTopPlaceholder:n,spreadsheetRowHeader:o}=i;e.onDblclickObserver.add(()=>{this._commandService.executeCommand(Ie.id,{visible:!0,eventType:w.DeviceInputEventType.Dblclick})}),e.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),t.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),n.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this)),o.onPointerDownObserver.add(this._keepVisibleHideEditor.bind(this))}_keepVisibleHideEditor(){this._editorBridgeService.isForceKeepVisible()||this._hideEditor()}_hideEditor(){this._editorBridgeService.isVisible().visible===!0&&(this._selectionManagerService.makeDirty(!1),this._commandService.executeCommand(Ie.id,{visible:!1,eventType:w.DeviceInputEventType.PointerDown}),setTimeout(()=>{this._selectionManagerService.makeDirty(!0)},0))}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}_commandExecutedListener(){const i=f.COMMAND_LISTENER_SKELETON_CHANGE;this.disposeWithMe(this._commandService.onCommandExecuted((e,t)=>{t!=null&&t.fromCollab||(e.id===f.SetWorksheetActiveOperation.id?this._keepVisibleHideEditor():i.includes(e.id)&&this._hideEditor())}))}};un=cc([l.OnLifecycle(l.LifecycleStages.Rendered,un),ke(0,L.Inject(P.SheetSkeletonManagerService)),ke(1,l.IUniverInstanceService),ke(2,l.ICommandService),ke(3,w.IRenderManagerService),ke(4,Ce),ke(5,L.Inject(f.SelectionManagerService)),ke(6,se),ke(7,L.Inject(l.ThemeService))],un);var dc=Object.defineProperty,uc=Object.getOwnPropertyDescriptor,hc=(i,e,t,n)=>{for(var o=n>1?void 0:n?uc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&dc(e,t,o),o},Ot=(i,e)=>(t,n)=>e(t,n,i);let hn=class extends l.Disposable{constructor(i,e,t,n,o){super(),this._commandService=i,this._formatPainterService=e,this._currentUniverService=t,this._renderManagerService=n,this._selectionManagerService=o,this._initialize()}_initialize(){this._commandExecutedListener(),this._bindFormatPainterStatus()}_bindFormatPainterStatus(){this._formatPainterService.status$.subscribe(i=>{const{scene:e}=this._getSheetObject()||{};e&&(i!==Se.OFF?e.setDefaultCursor(w.CURSOR_TYPE.CELL):e.setDefaultCursor(w.CURSOR_TYPE.DEFAULT))})}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{if(i.id===f.SetSelectionsOperation.id&&this._formatPainterService.getStatus()!==Se.OFF){const{selections:e}=i.params,{range:t}=e[e.length-1];this._applyFormatPainter(t),this._formatPainterService.getStatus()===Se.ONCE&&this._commandService.executeCommand(ri.id)}}))}async _applyFormatPainter(i){const{styles:e,merges:t}=this._formatPainterService.getSelectionFormat(),n=this._currentUniverService.getCurrentUniverSheetInstance().getUnitId(),o=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getSheetId();if(!e)return;const{startRow:r,startColumn:s,endRow:a,endColumn:c}=e.getDataRange(),d=a-r+1,u=c-s+1,h=Array.from({length:i.endRow-i.startRow+1},()=>Array.from({length:i.endColumn-i.startColumn+1},()=>({}))),m=[];h.forEach((g,S)=>{g.forEach((v,I)=>{const b=S%d+r,R=I%u+s,T=e.getValue(b,R);T&&(h[S][I].s=T)})}),t.forEach(g=>{const S={startRow:g.startRow-r,startColumn:g.startColumn-s,endRow:g.endRow-r,endColumn:g.endColumn-s},v=Math.floor((i.endRow-i.startRow+1)/d),I=Math.floor((i.endColumn-i.startColumn+1)/u);for(let b=0;b<v;b++)for(let R=0;R<I;R++)m.push({startRow:S.startRow+b*d+i.startRow,startColumn:S.startColumn+R*u+i.startColumn,endRow:S.endRow+b*d+i.startRow,endColumn:S.endColumn+R*u+i.startColumn})});const _={subUnitId:o,unitId:n,styleRange:i,styleValues:h,mergeRanges:m};await this._commandService.executeCommand(Eo.id,_)}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}};hn=hc([l.OnLifecycle(l.LifecycleStages.Rendered,hn),Ot(0,l.ICommandService),Ot(1,it),Ot(2,l.IUniverInstanceService),Ot(3,w.IRenderManagerService),Ot(4,L.Inject(f.SelectionManagerService))],hn);const mn={id:"sheet.command.set-scroll-relative",type:l.CommandType.COMMAND,handler:async(i,e={offsetX:0,offsetY:0})=>{const t=i.get(l.ICommandService),n=i.get(Le),r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),s=r.getActiveSheet(),{xSplit:a,ySplit:c}=s.getConfig().freeze,d=n.getCurrentScroll(),{offsetX:u=0,offsetY:h=0}=e||{},{sheetViewStartRow:m=0,sheetViewStartColumn:_=0,offsetX:g=0,offsetY:S=0}=d||{};return t.executeCommand(tt.id,{unitId:r.getUnitId(),sheetId:s.getSheetId(),sheetViewStartRow:m+c,sheetViewStartColumn:_+a,offsetX:g+u,offsetY:S+h})}},$e={id:"sheet.command.scroll-view",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const n=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),o=n.getActiveSheet(),s=i.get(Le).getCurrentScroll();if(!o)return!1;const a=i.get(l.ICommandService),{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:u,offsetY:h}=e,{sheetViewStartColumn:m,sheetViewStartRow:_,offsetX:g,offsetY:S}=s||{};return a.executeCommand(tt.id,{unitId:n.getUnitId(),sheetId:o.getSheetId(),sheetViewStartRow:c??m,sheetViewStartColumn:d??_,offsetX:u??g,offsetY:h??S})}};l.CommandType.COMMAND;var mc=Object.defineProperty,_c=Object.getOwnPropertyDescriptor,Sc=(i,e,t,n)=>{for(var o=n>1?void 0:n?_c(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&mc(e,t,o),o},Be=(i,e)=>(t,n)=>e(t,n,i);const gc="__SpreadsheetFreezeRowMainName__",fc="__SpreadsheetFreezeRowHeaderName__",pc="__SpreadsheetFreezeColumnMainName__",vc="__SpreadsheetFreezeColumnHeaderName__",hi=4,Cc=.01;let _n=class extends l.Disposable{constructor(e,t,n,o,r,s,a,c){super();C(this,"_rowFreezeHeaderRect");C(this,"_rowFreezeMainRect");C(this,"_columnFreezeHeaderRect");C(this,"_columnFreezeMainRect");C(this,"_freezeDownObservers",[]);C(this,"_freezeMoveObservers",[]);C(this,"_freezeLeaveObservers",[]);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_viewportObservers",[]);C(this,"_changeToRow",-1);C(this,"_changeToColumn",-1);C(this,"_changeToOffsetX",0);C(this,"_changeToOffsetY",0);C(this,"_freeze_normal_header_color","");C(this,"_freeze_normal_main_color","");C(this,"_freeze_active_color","");C(this,"_freeze_hover_color","");this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._scrollManagerService=a,this._themeService=c,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._themeChangeListener()}_createFreeze(e=0){var E;const t=this._getFreeze();if(t==null)return;const n=(E=this._sheetSkeletonManagerService.getCurrent())==null?void 0:E.skeleton;if(n==null)return;const{startRow:o,startColumn:r}=t,s=this._getPositionByIndex(o,r);if(s==null)return;const a=this._getSheetObject();if(a==null)return;const c=a.engine,d=(c==null?void 0:c.width)||0,u=(c==null?void 0:c.height)||0,h=a.scene,{startX:m,startY:_}=s,{rowTotalHeight:g,columnTotalWidth:S,rowHeaderWidthAndMarginLeft:v,columnHeaderHeightAndMarginTop:I}=n,b=d>S+v?d:S+I,R=u>g+I?u:g+I;this._changeToRow=o,this._changeToColumn=r,this._changeToOffsetX=m,this._changeToOffsetY=_;const T=hi/Math.max(h.scaleX,h.scaleY);if(e===0){this._rowFreezeHeaderRect=new w.Rect(fc,{fill:this._freeze_normal_header_color,width:v,height:T,left:0,top:_-T,zIndex:3});let O=this._freeze_normal_header_color;(o===-1||o===0)&&(O=this._freeze_normal_main_color),this._rowFreezeMainRect=new w.Rect(gc,{fill:O,width:b*2,height:T,left:v,top:_-T,zIndex:3}),h.addObjects([this._rowFreezeHeaderRect,this._rowFreezeMainRect],Ue)}else{this._columnFreezeHeaderRect=new w.Rect(vc,{fill:this._freeze_normal_header_color,width:T,height:I,left:m-T,top:0,zIndex:3});let O=this._freeze_normal_header_color;(r===-1||r===0)&&(O=this._freeze_normal_main_color),this._columnFreezeMainRect=new w.Rect(pc,{fill:O,width:T,height:R*2,left:m-T,top:I,zIndex:3}),h.addObjects([this._columnFreezeHeaderRect,this._columnFreezeMainRect],Ue)}this._eventBinding(e)}_eventBinding(e=0){let t=this._rowFreezeHeaderRect,n=this._rowFreezeMainRect;e===1&&(t=this._columnFreezeHeaderRect,n=this._columnFreezeMainRect);const o=this._getSheetObject();if(o==null)return;const{scene:r}=o;this._freezeMoveObservers.push(t==null?void 0:t.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freeze_hover_color,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeMoveObservers.push(n==null?void 0:n.onPointerEnterObserver.add(()=>{t==null||t.setProps({fill:this._freeze_hover_color,zIndex:4}),r.setCursor(w.CURSOR_TYPE.GRAB)})),this._freezeLeaveObservers.push(t==null?void 0:t.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freeze_normal_header_color,zIndex:3}),r.resetCursor()})),this._freezeLeaveObservers.push(n==null?void 0:n.onPointerLeaveObserver.add(()=>{t==null||t.setProps({fill:this._freeze_normal_header_color,zIndex:3}),r.resetCursor()})),this._freezeDownObservers.push(t==null?void 0:t.onPointerDownObserver.add(s=>{this._FreezeDown(s,t,n,e)})),this._freezeDownObservers.push(n==null?void 0:n.onPointerDownObserver.add(s=>{this._FreezeDown(s,t,n,e)}))}_getCurrentLastVisibleRow(){var u;const e=this._getSheetObject();if(e==null)return;const t=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton;if(t==null)return;const n=e.scene,o=Math.max(n.scaleX,n.scaleY),r=this._scrollManagerService.getCurrentScroll(),s=(e.engine.height-t.columnHeaderHeight)/o,a=(r==null?void 0:r.sheetViewStartRow)??0,c=a===0?-((r==null?void 0:r.offsetY)??0):t.rowHeightAccumulation[a-1]-((r==null?void 0:r.offsetY)??0);let d=0;for(let h=a,m=t.rowHeightAccumulation.length;h<m;h++)if(t.rowHeightAccumulation[h]-c>s){d=h;break}return d}_FreezeDown(e,t,n,o=0){var h;const r=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(r==null)return;const s=this._getSheetObject();if(s==null)return;const{scene:a}=s;a.setCursor(w.CURSOR_TYPE.GRABBING),a.disableEvent();const c=this._getCurrentLastVisibleRow(),d=c===void 0?1/0:r.rowHeightAccumulation[c],u=a.getViewport(j.VIEW_MAIN);this._moveObserver=a.onPointerMoveObserver.add(m=>{var b,R,T,E;const{startX:_,startY:g,row:S,column:v}=st(m.offsetX,m.offsetY,a,r,u);a.setCursor(w.CURSOR_TYPE.GRABBING);const I=hi/Math.max(a.scaleX,a.scaleY);o===0?((b=t.transformByState({top:Math.min(g,d)-I/2}))==null||b.setProps({fill:this._freeze_active_color}),(R=n.transformByState({top:Math.min(g,d)-I/2}))==null||R.setProps({fill:this._freeze_normal_header_color}),this._changeToRow=c===void 0?S:Math.min(S,c),this._changeToOffsetY=Math.min(g,d)):((T=t.transformByState({left:_-I/2}))==null||T.setProps({fill:this._freeze_active_color}),(E=n.transformByState({left:_-I/2}))==null||E.setProps({fill:this._freeze_normal_header_color}),this._changeToColumn=v,this._changeToOffsetX=_)}),this._upObserver=a.onPointerUpObserver.add(()=>{var y;a.resetCursor(),a.enableEvent(),this._clearObserverEvent();const{rowHeaderWidthAndMarginLeft:m,columnHeaderHeightAndMarginTop:_}=r;o===0&&(this._changeToRow===0||this._changeToRow===-1)||o===1&&(this._changeToColumn===0||this._changeToColumn===-1)?(t.setProps({fill:this._freeze_normal_header_color}),n.setProps({fill:this._freeze_normal_main_color})):(t==null||t.setProps({fill:this._freeze_normal_header_color}),n==null||n.setProps({fill:this._freeze_normal_header_color}));const g=hi/Math.max(a.scaleX,a.scaleY);o===0?(this._changeToRow===0||this._changeToRow===-1)&&(t.transformByState({top:_-g}),n.transformByState({top:_-g})):(this._changeToColumn===0||this._changeToColumn===-1)&&(t.transformByState({left:m-g}),n.transformByState({left:m-g}));const S=this._scrollManagerService.getCurrentScroll()||{sheetViewStartRow:0,sheetViewStartColumn:0},{sheetViewStartRow:v,sheetViewStartColumn:I}=S;if(I==null||v==null)return;const b=this._currentUniverService.getCurrentUniverSheetInstance(),R=b.getActiveSheet(),T=(y=R.getConfig())==null?void 0:y.freeze;let E=(T==null?void 0:T.xSplit)||0,O=(T==null?void 0:T.ySplit)||0;o===0&&(O=this._changeToRow-v,O=O<0?0:O),o===1&&(E=this._changeToColumn-I,E=E<0?0:E),this._commandService.executeCommand(f.SetFrozenCommand.id,{startRow:this._changeToRow,startColumn:this._changeToColumn,ySplit:O,xSplit:E,unitId:b.getUnitId(),subUnitId:R.getSheetId()})})}_updateViewport(e=-1,t=-1,n=0,o=0){var H;const r=this._getSheetObject();if(r==null)return;const{scene:s}=r,a=(H=this._sheetSkeletonManagerService.getCurrent())==null?void 0:H.skeleton;if(a==null)return;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=a,u=s.getViewport(j.VIEW_COLUMN_LEFT),h=s.getViewport(j.VIEW_COLUMN_RIGHT),m=s.getViewport(j.VIEW_ROW_TOP),_=s.getViewport(j.VIEW_ROW_BOTTOM),g=s.getViewport(j.VIEW_LEFT_TOP),S=s.getViewport(j.VIEW_MAIN),v=s.getViewport(j.VIEW_MAIN_LEFT_TOP),I=s.getViewport(j.VIEW_MAIN_LEFT),b=s.getViewport(j.VIEW_MAIN_TOP);if(u==null||h==null||m==null||_==null||g==null||S==null||v==null||I==null||b==null)return;const{scaleX:R,scaleY:T}=s.getAncestorScale();this._viewportObservers.forEach(D=>{S.onScrollAfterObserver.remove(D)}),h.resize({left:c,top:0,height:d,right:0}),_.resize({left:0,top:d,bottom:0,width:c}),g.resize({left:0,top:0,width:c,height:d}),this._viewportObservers.push(S.onScrollAfterObserver.add(D=>{const{scrollX:N,scrollY:U,actualScrollX:V,actualScrollY:$}=D;h.updateScroll({scrollX:N,actualScrollX:V}).makeDirty(!0),_.updateScroll({scrollY:U,actualScrollY:$}).makeDirty(!0)}));let E=!0,O=!0;v.enable(),(e===-1||e===0)&&(E=!1),(t===-1||t===0)&&(O=!1);const y=a.getNoMergeCellPositionByIndexWithNoHeader(e-n,t-o,R,T),x=a.getNoMergeCellPositionByIndexWithNoHeader(e,t,R,T);v.disable(),b.disable(),I.disable(),m.disable(),u.disable(),v.resetPadding(),b.resetPadding(),I.resetPadding(),m.resetPadding(),u.resetPadding();const A=this._scrollManagerService.getCurrentScroll();if(E===!1&&O===!1)S.resize({left:c,top:d,bottom:0,right:0}),S.resetPadding(),this._commandService.executeCommand($e.id,A??{sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0});else if(E===!0&&O===!1){const D=x.startY-y.startY;S.resize({left:c,top:d+D,bottom:0,right:0}),S.setPadding({startY:y.startY,endY:x.startY,startX:0,endX:0}),this._commandService.executeCommand($e.id,A??{sheetViewStartRow:0,offsetY:0}),b.resize({left:c,top:d,height:D,right:0}),b.updateScroll({actualScrollY:y.startY,x:S.scrollX,actualScrollX:S.actualScrollX}).makeDirty(!0),m.resize({left:0,top:d,width:c,height:D}),m.updateScroll({actualScrollY:y.startY}).makeDirty(!0),_.resize({left:0,top:d+D,bottom:0,width:c}),this._viewportObservers.push(S.onScrollAfterObserver.add(N=>{const{scrollX:U,actualScrollX:V}=N;b.updateScroll({scrollX:U,actualScrollX:V}).makeDirty(!0)})),b.enable(),m.enable()}else if(E===!1&&O===!0){const D=x.startX-y.startX;S.resize({left:c+D,top:d,bottom:0,right:0}),S.setPadding({startX:y.startX,endX:x.startX,startY:0,endY:0}),this._commandService.executeCommand($e.id,A??{sheetViewStartColumn:0,offsetX:0}),I.resize({left:c,top:d,width:D,bottom:0,right:0}),I.updateScroll({actualScrollX:y.startX,y:S.scrollY,actualScrollY:S.actualScrollY}).makeDirty(!0),u.resize({left:c,top:0,width:D,height:d}),u.updateScroll({actualScrollX:y.startX}).makeDirty(!0),h.resize({left:c+D,top:0,height:d,right:0}),this._viewportObservers.push(S.onScrollAfterObserver.add(N=>{const{scrollY:U,actualScrollY:V}=N;I.updateScroll({scrollY:U,actualScrollY:V}).makeDirty(!0)})),I.enable(),u.enable()}else{const D=x.startX-y.startX,N=x.startY-y.startY;S.resize({left:c+D,top:d+N,bottom:0,right:0}),S.setPadding({startY:y.startY,endY:x.startY,startX:y.startX,endX:x.startX}),this._commandService.executeCommand($e.id,{sheetViewStartRow:0,sheetViewStartColumn:0,offsetX:0,offsetY:0}),I.resize({left:c,top:d+N,width:D,bottom:0}),I.updateScroll({actualScrollX:y.startX,y:S.scrollY,actualScrollY:S.actualScrollY}).makeDirty(!0),b.resize({left:c+D,top:d,height:N,right:0}),b.updateScroll({actualScrollY:y.startY,x:S.scrollX,actualScrollX:S.actualScrollX}).makeDirty(!0),v.resize({left:c,top:d,width:D,height:N}),v.updateScroll({actualScrollX:y.startX,actualScrollY:y.startY}).makeDirty(!0),m.resize({left:0,top:d,width:c,height:N}),m.updateScroll({actualScrollY:y.startY}).makeDirty(!0),_.resize({left:0,top:d+N,bottom:0,width:c}),u.resize({left:c,top:0,width:D,height:d}),u.updateScroll({actualScrollX:y.startX}).makeDirty(!0),h.resize({left:c+D,top:0,height:d,right:0}),this._viewportObservers.forEach(U=>{S.onScrollAfterObserver.remove(U)}),this._viewportObservers.push(S.onScrollAfterObserver.add(U=>{const{scrollX:V,scrollY:$,actualScrollX:X,actualScrollY:Q}=U;_.updateScroll({scrollY:$,actualScrollY:Q}).makeDirty(!0),h.updateScroll({scrollX:V,actualScrollX:X}).makeDirty(!0),I.updateScroll({scrollY:$,actualScrollY:Q}).makeDirty(!0),b.updateScroll({scrollX:V,actualScrollX:X}).makeDirty(!0)})),v.enable(),b.enable(),I.enable(),m.enable(),u.enable()}}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(e=>{[f.SetWorksheetActiveOperation.id].includes((e==null?void 0:e.commandId)||"")&&this._refreshCurrent()})))}_refreshCurrent(){const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getConfig().freeze,{startRow:o=-1,startColumn:r=-1,ySplit:s=0,xSplit:a=0}=n;this._refreshFreeze(o,r,s,a)}_themeChangeListener(){this._themeChange(this._themeService.getCurrentTheme()),this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(e=>{this._clearFreeze(),this._themeChange(e),this._refreshCurrent()})))}_themeChange(e){this._freeze_normal_header_color=e.grey400,this._freeze_normal_main_color=new l.ColorKit(e.grey400).setAlpha(Cc).toRgbString(),this._freeze_active_color=e.primaryColor,this._freeze_hover_color=e.grey500}_commandExecutedListener(){const e=[f.SetFrozenMutation.id,Ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(e.includes(t.id)){const n=this._currentUniverService.getCurrentUniverSheetInstance(),o=n.getActiveSheet(),r=t.params,{unitId:s,subUnitId:a}=r;if(!(s===n.getUnitId()&&a===o.getSheetId())||o.getConfig().freeze==null)return;const{startRow:d=-1,startColumn:u=-1,ySplit:h=0,xSplit:m=0}=o.getConfig().freeze;this._refreshFreeze(d,u,h,m)}else if(t.id===f.DeltaRowHeightCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorRow<n.startRow&&this._refreshCurrent()}else if(t.id===f.DeltaColumnWidthCommand.id){const n=this._getFreeze();t.params&&n&&t.params.anchorCol<n.startColumn&&this._refreshCurrent()}else if(t.id===f.SetWorksheetRowAutoHeightMutation.id){const n=t.params,o=this._getFreeze();if(o&&o.startRow>-1&&n.rowsAutoHeightInfo.some(r=>r.row<o.startRow)){const r=this._sheetSkeletonManagerService.currentSkeleton$.subscribe(()=>{this._refreshCurrent(),setTimeout(()=>{r.unsubscribe()})})}}}))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_clearFreeze(){var n,o,r,s;(n=this._rowFreezeHeaderRect)==null||n.dispose(),(o=this._rowFreezeMainRect)==null||o.dispose(),(r=this._columnFreezeHeaderRect)==null||r.dispose(),(s=this._columnFreezeMainRect)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;[...this._freezeDownObservers,...this._freezeMoveObservers,...this._freezeLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),t.onPointerMoveObserver.remove(a),t.onPointerLeaveObserver.remove(a)}),t.onPointerEnterObserver.remove(this._moveObserver),t.onPointerMoveObserver.remove(this._upObserver)}_getPositionByIndex(e,t){var u;const n=this._getSheetObject();if(n==null)return;const{scaleX:o,scaleY:r}=n.scene.getAncestorScale(),s=(u=this._sheetSkeletonManagerService.getCurrent())==null?void 0:u.skeleton,a=s==null?void 0:s.getNoMergeCellPositionByIndex(e,t,o,r);if(s==null)return;if(a!=null&&(!isNaN(a.endX)||!isNaN(a.endY)))return a;const{rowHeaderWidthAndMarginLeft:c,columnHeaderHeightAndMarginTop:d}=s;return{startX:c,endX:c,startY:d,endY:d}}_getFreeze(){var t;const e=(t=this._sheetSkeletonManagerService.getCurrent())==null?void 0:t.skeleton.getWorksheetConfig();if(e!=null)return e.freeze}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}_refreshFreeze(e,t,n,o){this._clearFreeze(),this._createFreeze(0),this._createFreeze(1),this._updateViewport(e,t,n,o)}};_n=Sc([l.OnLifecycle(l.LifecycleStages.Rendered,_n),Be(0,L.Inject(P.SheetSkeletonManagerService)),Be(1,l.IUniverInstanceService),Be(2,l.ICommandService),Be(3,w.IRenderManagerService),Be(4,se),Be(5,L.Inject(f.SelectionManagerService)),Be(6,L.Inject(Le)),Be(7,L.Inject(l.ThemeService))],_n);var mi=(i=>(i[i.NORMAL=0]="NORMAL",i[i.HIGHLIGHT=1]="HIGHLIGHT",i))(mi||{});const Ic="rgba(0, 0, 0, 0.15)",ye="rgb(0, 0, 0)",Sn="rgb(255, 255, 255, 1)";class Mc extends w.Shape{constructor(t,n){super(t,n);C(this,"_size",12);C(this,"_iconRatio",.4);C(this,"_mode",0);this.setShapeProps(n)}setShapeProps(t){t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),this.transformByState({width:this._size,height:this._size})}_draw(t){this._mode===1&&w.Rect.drawWith(t,{width:this._size,height:this._size,radius:this._size,fill:Ic});const n=this._size*.5*this._iconRatio,o=Math.PI/180*60,r=n*Math.sin(o),s=n*Math.cos(o);w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-r+this._size/2,y:-s+this._size/2},{x:r+this._size/2,y:-s+this._size/2},{x:this._size/2,y:n+this._size/2}]],fill:ye})}}var bc=Object.defineProperty,Rc=Object.getOwnPropertyDescriptor,wc=(i,e,t,n)=>{for(var o=n>1?void 0:n?Rc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&bc(e,t,o),o},yt=(i,e)=>(t,n)=>e(t,n,i);const Tc="__SpreadsheetHeaderMenuSHAPEControllerShape__",Ec="__SpreadsheetHeaderMenuMAINControllerShape__",Oc="rgba(0, 0, 0, 0.1)";let gn=class extends l.Disposable{constructor(e,t,n,o,r){super();C(this,"_hoverRect");C(this,"_hoverMenu");C(this,"_currentColumn",1/0);C(this,"_observers",[]);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._contextMenuService=o,this._selectionManagerService=r,this._initialize()}dispose(){var o,r;(o=this._hoverRect)==null||o.dispose(),(r=this._hoverMenu)==null||r.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerEnterObserver.remove(s),t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerEnterObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)})}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._hoverRect=new w.Rect(Tc,{fill:Oc,evented:!1}),this._hoverMenu=new Mc(Ec,{zIndex:100,visible:!1}),t.addObjects([this._hoverRect,this._hoverMenu],Ue),this._initialHover(0),this._initialHover(1),this._initialHoverMenu()}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetColumnHeader:n,spreadsheetRowHeader:o}=t,r=e===0?o:n;this._observers.push(r==null?void 0:r.onPointerEnterObserver.add(()=>{var s;(s=this._hoverRect)==null||s.show()})),this._observers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var v,I,b;const a=(v=this._sheetSkeletonManagerService.getCurrent())==null?void 0:v.skeleton;if(a==null)return;const c=this._getSheetObject();if(c==null)return;const{rowHeaderWidth:d,columnHeaderHeight:u}=a,{startX:h,startY:m,endX:_,endY:g,column:S}=st(s.offsetX,s.offsetY,c.scene,a);if(e===0)(I=this._hoverRect)==null||I.transformByState({width:d,height:g-m,left:0,top:m});else{if(this._currentColumn=S,(b=this._hoverRect)==null||b.transformByState({width:_-h,height:u,left:h,top:0}),this._hoverMenu==null)return;if(_-h<u*2){this._hoverMenu.hide();return}const R=u*.8;this._hoverMenu.transformByState({left:_-u,top:u/2-R/2}),this._hoverMenu.setShapeProps({size:R}),this._hoverMenu.show()}})),this._observers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._hoverRect)==null||s.hide(),(a=this._hoverMenu)==null||a.hide()}))}_initialHoverMenu(){this._hoverMenu!=null&&(this._hoverMenu.onPointerEnterObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:mi.HIGHLIGHT,visible:!0}),e.scene.setCursor(w.CURSOR_TYPE.POINTER))}),this._hoverMenu.onPointerLeaveObserver.add(()=>{if(this._hoverMenu==null)return;const e=this._getSheetObject();e!=null&&(this._hoverMenu.setProps({mode:mi.NORMAL,visible:!1}),e.scene.resetCursor())}),this._hoverMenu.onPointerDownObserver.add(e=>{const t=this._getSheetObject();if(t==null)return;const n=this._currentColumn,o=this._selectionManagerService.getSelectionRanges();(o==null?void 0:o.find(s=>{const{startColumn:a,endColumn:c}=s;return n>=a&&a<=c}))==null?t.spreadsheetColumnHeader.onPointerDownObserver.notifyObservers(e):(e.stopPropagation(),e.preventDefault(),this._contextMenuService.triggerContextMenu(e,ee.COL_HEADER_CONTEXT_MENU))}))}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}};gn=wc([l.OnLifecycle(l.LifecycleStages.Rendered,gn),yt(0,L.Inject(P.SheetSkeletonManagerService)),yt(1,l.IUniverInstanceService),yt(2,w.IRenderManagerService),yt(3,M.IContextMenuService),yt(4,L.Inject(f.SelectionManagerService))],gn);var yc=Object.defineProperty,xc=Object.getOwnPropertyDescriptor,Ac=(i,e,t,n)=>{for(var o=n>1?void 0:n?xc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&yc(e,t,o),o},at=(i,e)=>(t,n)=>e(t,n,i);const Pc="__SpreadsheetHeaderMoveControllerBackground__",Dc="__SpreadsheetHeaderMoveControllerShapeLine__",Hc="rgba(0, 0, 0, 0.1)",Nc="rgb(119, 119, 119)",Lc=4;let fn=class extends l.Disposable{constructor(e,t,n,o,r,s){super();C(this,"_startOffsetX",-1/0);C(this,"_startOffsetY",-1/0);C(this,"_moveHelperBackgroundShape");C(this,"_moveHelperLineShape");C(this,"_sheetObject");C(this,"_rowOrColumnDownObservers",[]);C(this,"_rowOrColumnMoveObservers",[]);C(this,"_rowOrColumnLeaveObservers",[]);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_scrollTimer");C(this,"_changeFromColumn",-1);C(this,"_changeFromRow",-1);C(this,"_changeToColumn",-1);C(this,"_changeToRow",-1);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._renderManagerService=n,this._commandService=o,this._selectionRenderService=r,this._selectionManagerService=s,this._initialize()}dispose(){var r,s;(r=this._moveHelperBackgroundShape)==null||r.dispose(),(s=this._moveHelperLineShape)==null||s.dispose();const e=this._getSheetObject();if(e==null)return;const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n,scene:o}=e;[...this._rowOrColumnDownObservers,...this._rowOrColumnMoveObservers,...this._rowOrColumnLeaveObservers].forEach(a=>{t.onPointerDownObserver.remove(a),n.onPointerDownObserver.remove(a)}),o.onPointerMoveObserver.remove(this._moveObserver),o.onPointerUpObserver.remove(this._upObserver),this._scrollTimer.dispose()}_initialize(){const e=this._getSheetObject();e!=null&&(this._sheetObject=e,this._initialRowOrColumn(0),this._initialRowOrColumn(1))}_initialRowOrColumn(e=0){const{spreadsheetColumnHeader:t,spreadsheetRowHeader:n,scene:o}=this._sheetObject,r=e===0?n:t;this._rowOrColumnMoveObservers.push(r==null?void 0:r.onPointerMoveObserver.add(s=>{var h;const a=(h=this._sheetSkeletonManagerService.getCurrent())==null?void 0:h.skeleton;if(a==null)return;const{row:c,column:d}=st(s.offsetX,s.offsetY,o,a);if(this._checkInHeaderRange(e===0?c:d,e)===!1){o.resetCursor(),this._selectionRenderService.enableSelection();return}o.setCursor(w.CURSOR_TYPE.GRAB),this._selectionRenderService.disableSelection()})),this._rowOrColumnLeaveObservers.push(r==null?void 0:r.onPointerLeaveObserver.add(()=>{var s,a;(s=this._moveHelperBackgroundShape)==null||s.hide(),(a=this._moveHelperLineShape)==null||a.hide(),o.resetCursor(),this._selectionRenderService.enableSelection()})),this._rowOrColumnDownObservers.push(r==null?void 0:r.onPointerDownObserver.add(s=>{var b;const a=(b=this._sheetSkeletonManagerService.getCurrent())==null?void 0:b.skeleton;if(a==null)return;const{offsetX:c,offsetY:d}=s,u=o.getRelativeCoord(w.Vector2.FromArray([c,d])),{x:h,y:m}=u;this._startOffsetX=h,this._startOffsetY=m;const{row:_,column:g}=st(s.offsetX,s.offsetY,o,a);e===0?this._changeFromRow=_:this._changeFromColumn=g;const S=this._checkInHeaderRange(e===0?_:g,e);if(S===!1)return;this._newBackgroundAndLine(),o.setCursor(w.CURSOR_TYPE.GRABBING),o.disableEvent();const v=w.ScrollTimer.create(o),I=o.getViewport(j.VIEW_MAIN);v.startScroll(h,m,I),this._scrollTimer=v,this._moveObserver=o.onPointerMoveObserver.add(R=>{const{offsetX:T,offsetY:E}=R,{x:O,y}=o.getRelativeCoord(w.Vector2.FromArray([T,E]));o.setCursor(w.CURSOR_TYPE.GRABBING),this._columnMoving(O,y,S,e),v.scrolling(O,y,()=>{this._columnMoving(O,y,S,e)})}),this._upObserver=o.onPointerUpObserver.add(()=>{var R;this._disposeBackgroundAndLine(),o.resetCursor(),o.enableEvent(),this._clearObserverEvent(),(R=this._scrollTimer)==null||R.dispose(),e===0?(this._changeFromRow!==this._changeToRow&&this._changeToRow!==-1&&this._commandService.executeCommand(f.MoveRowsCommand.id,{fromRow:this._changeFromRow,toRow:this._changeToRow}),this._changeToRow=this._changeFromRow=-1):(this._changeFromColumn!==this._changeToColumn&&this._changeToColumn!==-1&&this._commandService.executeCommand(f.MoveColsCommand.id,{fromCol:this._changeFromColumn,toCol:this._changeToColumn}),this._changeToColumn=this._changeFromColumn=-1)})}))}_columnMoving(e,t,n,o){var Q,K,q,W,te,J,Pe;const{scene:r}=this._sheetObject,s=(Q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:Q.skeleton;if(s==null)return;const{rowHeaderWidth:a,columnHeaderHeight:c,rowTotalHeight:d,columnTotalWidth:u}=s,h=r.getScrollXYByRelativeCoords(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),{scaleX:m,scaleY:_}=r.getAncestorScale(),g=s.getCellPositionByOffset(e,t,m,_,h),{row:S,column:v}=g,I=s.getNoMergeCellPositionByIndex(S,v,m,_),{startX:b,startY:R,endX:T,endY:E}=I,O=this._selectionRenderService.convertRangeDataToSelection(n.range);if(O==null)return;const y=Math.max(m,m),{startX:x,endX:A,startY:H,endY:D,startRow:N,startColumn:U,endRow:V,endColumn:$}=O;o===0?(K=this._moveHelperBackgroundShape)==null||K.transformByState({height:D-H,width:u+a,left:0,top:H+(t-this._startOffsetY)/y}):(q=this._moveHelperBackgroundShape)==null||q.transformByState({height:d+c,width:A-x,left:x+(e-this._startOffsetX)/y,top:0}),(W=this._moveHelperBackgroundShape)==null||W.show();const X=Lc/y;if(o===0){let ce=0;if(S<=N)ce=R-X/2,this._changeToRow=S;else if(S>V)ce=E-X/2,this._changeToRow=S+1;else return;(te=this._moveHelperLineShape)==null||te.transformByState({height:X,width:u,left:a,top:ce})}else{let ce=0;if(v<=U)ce=b-X/2,this._changeToColumn=v;else if(v>$)ce=T-X/2,this._changeToColumn=v+1;else return;(J=this._moveHelperLineShape)==null||J.transformByState({height:d,width:X,left:ce,top:c})}(Pe=this._moveHelperLineShape)==null||Pe.show()}_checkInHeaderRange(e,t=0){const n=this._selectionManagerService.getSelections(),o=n==null?void 0:n.find(s=>{const a=s.range,{startRow:c,endRow:d,startColumn:u,endColumn:h}=a;return t===1?e>=u&&e<=h:e>=c&&e<=d}),r=o==null?void 0:o.range;return o==null||r==null||r.rangeType===l.RANGE_TYPE.ALL||r.rangeType===l.RANGE_TYPE.NORMAL||r.rangeType===l.RANGE_TYPE.ROW&&t!==0||r.rangeType===l.RANGE_TYPE.COLUMN&&t!==1?!1:o}_clearObserverEvent(){const{scene:e}=this._sheetObject;e.onPointerMoveObserver.remove(this._moveObserver),e.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_newBackgroundAndLine(){const{scene:e}=this._sheetObject;this._moveHelperBackgroundShape=new w.Rect(Pc,{fill:Hc,evented:!1,zIndex:100}),this._moveHelperLineShape=new w.Rect(Dc,{fill:Nc,evented:!1,zIndex:100}),e.addObjects([this._moveHelperBackgroundShape,this._moveHelperLineShape],Ue)}_disposeBackgroundAndLine(){var e,t;(e=this._moveHelperBackgroundShape)==null||e.dispose(),(t=this._moveHelperLineShape)==null||t.dispose()}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}};fn=Ac([l.OnLifecycle(l.LifecycleStages.Rendered,fn),at(0,L.Inject(P.SheetSkeletonManagerService)),at(1,l.IUniverInstanceService),at(2,w.IRenderManagerService),at(3,l.ICommandService),at(4,se),at(5,L.Inject(f.SelectionManagerService))],fn);var _i=(i=>(i[i.VERTICAL=0]="VERTICAL",i[i.HORIZONTAL=1]="HORIZONTAL",i))(_i||{});const Uc="rgba(120, 120, 120, 0.01)",Si="rgb(68, 71, 70)",xt=12,gi=4;class Jo extends w.Shape{constructor(t,n){super(t,n);C(this,"_size",xt);C(this,"_color",Si);C(this,"_mode",0);this.setShapeProps(n)}get size(){return this._size}get mode(){return this._mode}get color(){return this._color}_draw(t){let{width:n,height:o}=this,r=0,s=0;const a=this.getScene(),{scaleX:c,scaleY:d}=a.getAncestorScale(),u=Math.max(c,d),h=xt/u,m=gi/u;this.mode===0?(n=m,r=h-m):(o=m,s=h-m),w.Rect.drawWith(t,{width:this.width,height:this.height,left:0,top:0,fill:Uc}),w.Rect.drawWith(t,{width:n,height:o,fill:Si,radius:m}),t.save(),t.transform(1,0,0,1,r,s),w.Rect.drawWith(t,{width:n,height:o,fill:Si,radius:m}),t.restore()}setShapeProps(t){return t!=null&&t.size&&(this._size=t.size),t!=null&&t.mode&&(this._mode=t.mode),t!=null&&t.color&&(this._color=t.color),this.mode===0?this.transformByState({width:xt,height:this.size}):this.transformByState({width:this.size,height:xt}),this}}var kc=Object.defineProperty,Bc=Object.getOwnPropertyDescriptor,Vc=(i,e,t,n)=>{for(var o=n>1?void 0:n?Bc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&kc(e,t,o),o},At=(i,e)=>(t,n)=>e(t,n,i);const Fc="__SpreadsheetHeaderResizeControllerShapeRow__",Wc="__SpreadsheetHeaderResizeControllerShapeColumn__",Qo="__SpreadsheetHeaderResizeControllerShapeHelper__",qo="rgb(199, 199, 199)",jc=2;let pn=class extends l.Disposable{constructor(e,t,n,o,r){super();C(this,"_currentRow",0);C(this,"_currentColumn",0);C(this,"_rowResizeRect");C(this,"_columnResizeRect");C(this,"_observers",[]);C(this,"_moveObserver");C(this,"_upObserver");C(this,"_resizeHelperShape");C(this,"_startOffsetX",1/0);C(this,"_startOffsetY",1/0);this._sheetSkeletonManagerService=e,this._currentUniverService=t,this._commandService=n,this._renderManagerService=o,this._editorBridgeService=r,this._initialize()}dispose(){var o,r;(o=this._rowResizeRect)==null||o.dispose(),this._rowResizeRect=null,(r=this._columnResizeRect)==null||r.dispose(),this._columnResizeRect=null;const e=this._getSheetObject();if(e==null)throw new Error("sheetObject is null");const{spreadsheetRowHeader:t,spreadsheetColumnHeader:n}=e;this._observers.forEach(s=>{t.onPointerMoveObserver.remove(s),t.onPointerLeaveObserver.remove(s),n.onPointerMoveObserver.remove(s),n.onPointerLeaveObserver.remove(s)}),this._observers=[]}_initialize(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;this._rowResizeRect=new Jo(Fc,{visible:!1,mode:_i.HORIZONTAL,zIndex:100}),this._columnResizeRect=new Jo(Wc,{visible:!1,mode:_i.VERTICAL,zIndex:100}),t.addObjects([this._rowResizeRect,this._columnResizeRect],Ue),this._initialHover(0),this._initialHover(1),this._initialHoverResize(0),this._initialHoverResize(1)}_initialHover(e=0){const t=this._getSheetObject();if(t==null)return;const{spreadsheetRowHeader:n,spreadsheetColumnHeader:o,scene:r}=t,s=e===0?n:o;this._observers.push(s==null?void 0:s.onPointerMoveObserver.add((a,c)=>{var y;const d=(y=this._sheetSkeletonManagerService.getCurrent())==null?void 0:y.skeleton;if(d==null||this._rowResizeRect==null||this._columnResizeRect==null)return;const{rowHeaderWidth:u,columnHeaderHeight:h}=d,{startX:m,startY:_,endX:g,endY:S,row:v,column:I}=st(a.offsetX,a.offsetY,r,d),b=qt(a.offsetX,a.offsetY,r),{scaleX:R,scaleY:T}=r.getAncestorScale(),E=Math.max(R,T),O=xt/E;if(e===0){let x=_-O/2;if(b.y<=_+O/2&&b.y>=_)this._currentRow=v-1;else if(b.y>=S-O/2&&b.y<=S)this._currentRow=v,x=S-O/2;else{this._rowResizeRect.hide();return}if(this._currentRow===-1)return;const A=u/3;this._rowResizeRect.transformByState({left:u/2-A/2,top:x}),this._rowResizeRect.setShapeProps({size:A}),this._rowResizeRect.show()}else{let x=m-O/2;if(b.x<=m+O/2&&b.x>=m)this._currentColumn=I-1;else if(b.x>=g-O/2&&b.x<=g)this._currentColumn=I,x=g-O/2;else{this._columnResizeRect.hide();return}if(this._currentColumn===-1)return;const A=h*.7;this._columnResizeRect.transformByState({left:x,top:h/2-A/2}),this._columnResizeRect.setShapeProps({size:A}),this._columnResizeRect.show()}})),this._observers.push(s==null?void 0:s.onPointerLeaveObserver.add((a,c)=>{var d,u;(d=this._rowResizeRect)==null||d.hide(),(u=this._columnResizeRect)==null||u.hide()}))}_initialHoverResize(e=0){const t=this._getSheetObject();if(t==null)return;const{scene:n}=t,o=e===0?this._rowResizeRect:this._columnResizeRect;if(o==null)return;const r=n.getEngine(),s=(r==null?void 0:r.width)||0,a=(r==null?void 0:r.height)||0;this.disposeWithMe(l.toDisposable(o.onPointerEnterObserver.add(()=>{o!=null&&(o.show(),n.setCursor(e===0?w.CURSOR_TYPE.ROW_RESIZE:w.CURSOR_TYPE.COLUMN_RESIZE))}))),this.disposeWithMe(l.toDisposable(o.onPointerLeaveObserver.add(()=>{o!=null&&(o.hide(),n.resetCursor())}))),this.disposeWithMe(l.toDisposable(o.onPointerDownObserver.add((c,d)=>{var q,W,te,J,Pe,ce,ve;const u=(q=this._sheetSkeletonManagerService.getCurrent())==null?void 0:q.skeleton;if(u==null)return;const h=this._getSheetObject();if(h==null)return;const{scene:m}=h,_=m.getViewport(j.VIEW_MAIN),g=(((te=(W=_==null?void 0:_.getScrollBar())==null?void 0:W.horizonBarRect)==null?void 0:te.height)||0)+10,S=(((Pe=(J=_==null?void 0:_.getScrollBar())==null?void 0:J.verticalBarRect)==null?void 0:Pe.width)||0)+10,v=qt(c.offsetX,c.offsetY,m),{scaleX:I,scaleY:b}=m.getAncestorScale();this._startOffsetX=v.x,this._startOffsetY=v.y;const R=u.getOffsetByPositionX(this._currentColumn),T=u.getOffsetByPositionY(this._currentRow),E=u.getNoMergeCellPositionByIndex(this._currentRow,this._currentColumn,I,b);let O=!1,y=0,x=0;const{columnTotalWidth:A,rowHeaderWidth:H,rowTotalHeight:D,columnHeaderHeight:N}=u,U=s>A+H?s:A+H,V=a>D+N?a:D+N,$=Math.max(I,b),X=gi/$;e===0?this._resizeHelperShape=new w.Rect(Qo,{width:U,height:X,fill:qo,left:0,top:T-X/2}):this._resizeHelperShape=new w.Rect(Qo,{width:X,height:V,fill:qo,left:R-X/2,top:0});const Q=((ce=this._columnResizeRect)==null?void 0:ce.left)||0,K=((ve=this._rowResizeRect)==null?void 0:ve.top)||0;m.addObject(this._resizeHelperShape,Ue),m.disableEvent(),this._editorBridgeService.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown}),this._moveObserver=m.onPointerMoveObserver.add(_t=>{var pr,vr,Cr,Ir,Mr,br;const Qe=m.getRelativeCoord(w.Vector2.FromArray([this._startOffsetX,this._startOffsetY])),De=m.getScrollXYByRelativeCoords(Qe,_),he=qt(_t.offsetX,_t.offsetY,m),{x:Hn,y:Nn}=he,{scaleX:_h,scaleY:Sh}=m.getAncestorScale(),gh=Math.max(_h,Sh),Ln=gi/gh;y=Hn-this._startOffsetX-Ln/2,x=Nn-this._startOffsetY-Ln/2,Math.abs(e===0?x:y)>=jc&&(O=!0),e===0?(x<-(E.endY-E.startY)+2&&(x=-(E.endY-E.startY)+2),x>a-g+De.y-E.startY&&(x=a-g+De.y-E.startY),O&&((pr=this._resizeHelperShape)==null||pr.transformByState({top:T+x}),(vr=this._rowResizeRect)==null||vr.transformByState({top:K+x+Ln/2}),(Cr=this._rowResizeRect)==null||Cr.show(),m.setCursor(w.CURSOR_TYPE.ROW_RESIZE))):(y<-(E.endX-E.startX)+2&&(y=-(E.endX-E.startX)+2),y>s-S+De.x-E.startX&&(y=s-S+De.x-E.startX),O&&((Ir=this._resizeHelperShape)==null||Ir.transformByState({left:R+y}),(Mr=this._columnResizeRect)==null||Mr.transformByState({left:Q+y+Ln/2}),(br=this._columnResizeRect)==null||br.show(),m.setCursor(w.CURSOR_TYPE.COLUMN_RESIZE)))}),this._upObserver=m.onPointerUpObserver.add(_t=>{var he,Hn,Nn;const Qe=le(this._currentUniverService,this._renderManagerService);if(Qe==null)return;this._clearObserverEvent(),(he=this._resizeHelperShape)==null||he.dispose(),this._resizeHelperShape=null;const{scene:De}=Qe;De.enableEvent(),O&&(De.resetCursor(),(Hn=this._rowResizeRect)==null||Hn.hide(),(Nn=this._columnResizeRect)==null||Nn.hide(),e===0?this._commandService.executeCommand(f.DeltaRowHeightCommand.id,{deltaY:x,anchorRow:this._currentRow}):this._commandService.executeCommand(f.DeltaColumnWidthCommand.id,{deltaX:y,anchorCol:this._currentColumn}))})}))),this.disposeWithMe(l.toDisposable(o.onDblclickObserver.add(()=>{var c;if(e===0){const d=this._getSheetObject();if(d==null)return;const{scene:u}=d;u.resetCursor(),this._commandService.executeCommand(f.SetWorksheetRowIsAutoHeightCommand.id,{anchorRow:this._currentRow}),(c=this._rowResizeRect)==null||c.hide()}})))}_clearObserverEvent(){const e=this._getSheetObject();if(e==null)return;const{scene:t}=e;t.onPointerMoveObserver.remove(this._moveObserver),t.onPointerUpObserver.remove(this._upObserver),this._moveObserver=null,this._upObserver=null}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}};pn=Vc([l.OnLifecycle(l.LifecycleStages.Rendered,pn),At(0,L.Inject(P.SheetSkeletonManagerService)),At(1,l.IUniverInstanceService),At(2,l.ICommandService),At(3,w.IRenderManagerService),At(4,Ce)],pn);var fi=(i=>(i[i.ROW=0]="ROW",i[i.COLUMN=1]="COLUMN",i))(fi||{});const Pt=12,zc=.4;class er extends w.Shape{constructor(t,n,o){super(t,n);C(this,"_size",Pt);C(this,"_iconRatio",zc);C(this,"_hovered",!0);C(this,"_hasPrevious",!0);C(this,"_hasNext",!0);C(this,"_unhideType");n&&this.setShapeProps(n),this.onPointerEnterObserver.add(()=>this.setShapeProps({hovered:!0})),this.onPointerLeaveObserver.add(()=>this.setShapeProps({hovered:!1})),this.onPointerDownObserver.add(()=>o==null?void 0:o())}setShapeProps(t){t.type!==void 0&&(this._unhideType=t.type),t.hovered!==void 0&&(this._hovered=t.hovered),t.hasPrevious!==void 0&&(this._hasPrevious=t.hasPrevious),t.hasNext!==void 0&&(this._hasNext=t.hasNext),this.transformByState({width:this._size*(this._unhideType===1?2:1),height:this._size*(this._unhideType===0?2:1)})}_draw(t){this._unhideType===0?this._drawOnRow(t):this._drawOnCol(t)}_drawOnRow(t){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(t,{width:this._size,height:this._size,stroke:ye,fill:Sn}):w.Rect.drawWith(t,{width:this._size,height:2*this._size,stroke:ye,fill:Sn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size/2-s},{x:this._size/2-s,y:this._size/2+r},{x:this._size/2+s,y:this._size/2+r}]],fill:ye}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:this._size/2,y:this._size*a/2+s},{x:this._size/2-s,y:this._size*a/2-r},{x:this._size/2+s,y:this._size*a/2-r}]],fill:ye})}}_drawOnCol(t){this._hovered&&(!this._hasNext||!this._hasPrevious?w.Rect.drawWith(t,{width:this._size,height:this._size,stroke:ye,fill:Sn}):w.Rect.drawWith(t,{width:2*this._size,height:this._size,stroke:ye,fill:Sn}));const n=this._size*.5*this._iconRatio,o=Math.PI/3,r=n*Math.cos(o),s=n*Math.sin(o);if(this._hasPrevious&&w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:-r+this._size/2,y:this._size/2},{x:this._size/2+s,y:this._size/2-s},{x:this._size/2+s,y:this._size/2+s}]],fill:ye}),this._hasNext){const a=this._hasPrevious?3:1;w.RegularPolygon.drawWith(t,{pointsGroup:[[{x:r+this._size*a/2,y:this._size/2},{x:-s+this._size*a/2,y:this._size/2-s},{x:-s+this._size*a/2,y:this._size/2+s}]],fill:ye})}}}var Xc=Object.defineProperty,Yc=Object.getOwnPropertyDescriptor,$c=(i,e,t,n)=>{for(var o=n>1?void 0:n?Yc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Xc(e,t,o),o},vn=(i,e)=>(t,n)=>e(t,n,i);const tr="__SpreadsheetHeaderUnhideSHAPEControllerShape__",Zc=[f.SetRowHiddenMutation.id,f.SetRowVisibleMutation.id,f.SetColHiddenMutation.id,f.SetColVisibleMutation.id];let Cn=class extends l.RxDisposable{constructor(e,t,n,o){super();C(this,"_shapes",new Map);this._sheetSkeletonManagerService=e,this._cmdSrv=t,this._univerInstanceService=n,this._rendererManagerService=o,this._init()}dispose(){super.dispose()}_init(){if(!this._getSheetObject())return;const t=this._univerInstanceService.getCurrentUniverSheetInstance(),n=t.getActiveSheet();n&&this._initForWorksheet(t,n),this._sheetSkeletonManagerService.currentSkeleton$.pipe(B.takeUntil(this.dispose$)).subscribe(o=>{if(o){const r=this._univerInstanceService.getUniverSheetInstance(o.unitId),s=r.getSheetBySheetId(o.sheetId);this._updateWorksheet(r,s)}}),this.disposeWithMe(this._cmdSrv.onCommandExecuted(o=>{if(!Zc.includes(o.id)||!o.params||!o.params.unitId||!o.params.subUnitId)return;const r=this._univerInstanceService.getUniverSheetInstance(o.params.unitId),s=r==null?void 0:r.getSheetBySheetId(o.params.subUnitId);s&&this._updateWorksheet(r,s)}))}_initForWorksheet(e,t){var m;const n=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(!n)return;const o=t.getHiddenRows(),r=t.getHiddenCols(),s=this._getSheetObject();if(!s)return;const{scene:a}=s,c=t.getRowCount(),d=o.map(_=>{const{startRow:g,endRow:S}=_,v=ci(g,0,a,n),I=g!==0,b=S!==c-1;return new er(tr,{type:fi.ROW,hovered:!1,hasPrevious:I,hasNext:b,top:v.startY-(I?Pt:0),left:v.startX-Pt},()=>this._cmdSrv.executeCommand(f.SetSpecificRowsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[_]}))}),u=t.getColumnCount(),h=r.map(_=>{const{startColumn:g,endColumn:S}=_,v=ci(0,g,a,n),I=g!==0,b=S!==u-1;return new er(tr,{type:fi.COLUMN,hovered:!1,hasPrevious:I,hasNext:b,left:v.startX-(I?Pt:0),top:20-Pt},()=>this._cmdSrv.executeCommand(f.SetSpecificColsVisibleCommand.id,{unitId:e.getUnitId(),subUnitId:t.getSheetId(),ranges:[_]}))});a.addObjects(h,Gi),a.addObjects(d,Gi),this._shapes.set(l.getWorksheetUID(e,t),{cols:h,rows:d})}_updateWorksheet(e,t){const n=this._shapes.get(l.getWorksheetUID(e,t));n==null||n.cols.forEach(o=>o.dispose()),n==null||n.rows.forEach(o=>o.dispose()),this._initForWorksheet(e,t)}_getSheetObject(){return le(this._univerInstanceService,this._rendererManagerService)}};Cn=$c([l.OnLifecycle(l.LifecycleStages.Rendered,Cn),vn(0,L.Inject(P.SheetSkeletonManagerService)),vn(1,l.ICommandService),vn(2,l.IUniverInstanceService),vn(3,w.IRenderManagerService)],Cn);var Gc=Object.defineProperty,Kc=Object.getOwnPropertyDescriptor,Jc=(i,e,t,n)=>{for(var o=n>1?void 0:n?Kc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Gc(e,t,o),o},pi=(i,e)=>(t,n)=>e(t,n,i);let In=class extends l.Disposable{constructor(e,t,n){super();C(this,"_initialize",()=>{const e=new l.DisposableCollection;this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(()=>{e.dispose();const t=this._selectionManagerService.getCurrent();if((t==null?void 0:t.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)return;this._selectionRenderService.getCurrentControls().forEach(o=>{e.add(l.toDisposable(o.selectionMoved$.subscribe(r=>{if(!r)return;const s=o.model.getRange(),a={startRow:s.startRow,startColumn:s.startColumn,endRow:s.endRow,endColumn:s.endColumn,rangeType:s.rangeType},c={startRow:r.startRow,startColumn:r.startColumn,endRow:r.endRow,endColumn:r.endColumn,rangeType:s.rangeType};if(a.startRow===c.startRow&&a.startColumn===c.startColumn||c.startRow<0||c.startColumn<0)return;const d={fromRange:a,toRange:c};this._commandService.executeCommand(f.MoveRangeCommand.id,d)})))})})))});this._selectionRenderService=e,this._selectionManagerService=t,this._commandService=n,this._initialize()}};In=Jc([l.OnLifecycle(l.LifecycleStages.Steady,In),pi(0,L.Inject(se)),pi(1,L.Inject(f.SelectionManagerService)),pi(2,L.Inject(l.ICommandService))],In);var Qc=Object.defineProperty,qc=Object.getOwnPropertyDescriptor,ed=(i,e,t,n)=>{for(var o=n>1?void 0:n?qc(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&Qc(e,t,o),o},lt=(i,e)=>(t,n)=>e(t,n,i);let Dt=class extends l.Disposable{constructor(i,e,t,n,o,r){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionManagerService=o,this._scrollManagerService=r,this._initialize()}dispose(){super.dispose()}_initialize(){this._scrollEventBinding(),this._scrollSubscribeBinding(),this._skeletonListener()}_scrollEventBinding(){var t;const i=(t=this._getSheetObject())==null?void 0:t.scene;if(i==null)return;const e=i.getViewport(j.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollAfterObserver.add(n=>{var m;const o=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(o==null||n.isTrigger===!1)return;const r=this._getSheetObject();if(o==null||r==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,{row:c,column:d,rowOffset:u,columnOffset:h}=o.getDecomposedOffset(s,a);this._scrollManagerService.addOrReplaceNoRefresh({sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})}))),this.disposeWithMe(l.toDisposable(e==null?void 0:e.onScrollByBarObserver.add(n=>{var m;const o=(m=this._sheetSkeletonManagerService.getCurrent())==null?void 0:m.skeleton;if(o==null||n.isTrigger===!1)return;const r=this._getSheetObject();if(o==null||r==null)return;const{actualScrollX:s=0,actualScrollY:a=0}=n,{row:c,column:d,rowOffset:u,columnOffset:h}=o.getDecomposedOffset(s,a);this._commandService.executeCommand($e.id,{sheetViewStartRow:c,sheetViewStartColumn:d,offsetX:h,offsetY:u})})))}scrollToVisible(i){var H,D,N;let e,t;const n=this._selectionManagerService.getLast();if(n==null)return;const{actualRow:o,actualColumn:r}=n.primary,{rowHeightAccumulation:s,columnWidthAccumulation:a}=((H=this._sheetSkeletonManagerService.getCurrent())==null?void 0:H.skeleton)??{};if(s==null||a==null)return;const c=(D=this._getSheetObject())==null?void 0:D.scene;if(c==null)return;const d=c.getViewport(j.VIEW_MAIN);if(d==null||this._getSheetObject()==null)return;const h=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet(),{startColumn:m,startRow:_,ySplit:g,xSplit:S}=h.getFreeze(),v=d.getBounding(),I=(N=this._sheetSkeletonManagerService.getCurrent())==null?void 0:N.skeleton;if(I==null)return;const{startRow:b,startColumn:R,endRow:T,endColumn:E}=I.getRowColumnSegment(v);if(o>=_&&r>=m-S&&(o<=b&&(e=o),o>=T)){const U=s[o]-d.height;for(let V=b;V<=o;V++)if(s[V]>=U){e=V+1;break}}if(r>=m&&o>=_-g&&(r<=R&&(t=r),r>=E)){const U=a[r]-d.width;for(let V=R;V<=r;V++)if(a[V]>=U){t=V+1;break}}if(e===void 0&&t===void 0)return;const{sheetViewStartColumn:O,sheetViewStartRow:y,offsetX:x,offsetY:A}=this._scrollManagerService.getCurrentScroll()||{};this._commandService.executeCommand($e.id,{sheetViewStartRow:e??y,sheetViewStartColumn:t??O,offsetX:t===void 0?x:0,offsetY:e===void 0?A:0})}_scrollSubscribeBinding(){this.disposeWithMe(l.toDisposable(this._scrollManagerService.scrollInfo$.subscribe(i=>{var v;const e=(v=this._sheetSkeletonManagerService.getCurrent())==null?void 0:v.skeleton,t=this._getSheetObject();if(e==null||t==null)return;const n=t.scene,{scaleX:o,scaleY:r}=t.scene.getAncestorScale(),s=n.getViewport(j.VIEW_MAIN);if(s==null)return;if(i==null){s.scrollTo({x:0,y:0});return}const{sheetViewStartRow:a,sheetViewStartColumn:c,offsetX:d,offsetY:u}=i,{startX:h,startY:m}=e.getCellByIndexWithNoHeader(a,c,o,r),_=h+d,g=m+u,S=s.getBarScroll(_,g);s.scrollTo(S)})))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t}=i;this._renderManagerService.getRenderById(e)!=null&&(this._updateSceneSize(i),this._scrollManagerService.setCurrentScroll({unitId:e,sheetId:t}))})))}_updateSceneSize(i){var c;if(i==null)return;const{skeleton:e,unitId:t}=i,n=(c=this._renderManagerService.getRenderById(t))==null?void 0:c.scene;if(e==null||n==null)return;const{rowTotalHeight:o,columnTotalWidth:r,rowHeaderWidthAndMarginLeft:s,columnHeaderHeightAndMarginTop:a}=e;n==null||n.transformByState({width:s+r,height:a+o})}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}};Dt=ed([l.OnLifecycle(l.LifecycleStages.Rendered,Dt),lt(0,L.Inject(P.SheetSkeletonManagerService)),lt(1,l.IUniverInstanceService),lt(2,l.ICommandService),lt(3,w.IRenderManagerService),lt(4,L.Inject(f.SelectionManagerService)),lt(5,L.Inject(Le))],Dt);var td=Object.defineProperty,nd=Object.getOwnPropertyDescriptor,id=(i,e,t,n)=>{for(var o=n>1?void 0:n?nd(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&td(e,t,o),o},nr=(i,e)=>(t,n)=>e(t,n,i);const od=[me.id,je.id];let Mn=class extends l.Disposable{constructor(i,e){super(),this._commandService=i,this._scrollController=e,this.disposeWithMe(this._commandService.onCommandExecuted(t=>{if(od.includes(t.id)){const n=t.params;this._scrollController.scrollToVisible(n.direction)}}))}};Mn=id([l.OnLifecycle(l.LifecycleStages.Rendered,Mn),nr(0,l.ICommandService),nr(1,L.Inject(Dt))],Mn);var rd=Object.defineProperty,sd=Object.getOwnPropertyDescriptor,ad=(i,e,t,n)=>{for(var o=n>1?void 0:n?sd(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&rd(e,t,o),o},Ze=(i,e)=>(t,n)=>e(t,n,i);let bn=class extends l.Disposable{constructor(i,e,t,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._themeService=s,this._initialize()}_initialize(){const i=this._currentUniverService.getCurrentUniverSheetInstance(),e=i.getActiveSheet(),t=this._getSheetObject();if(t==null)return;this._initViewMainListener(t),this._initRowHeader(t),this._initColumnHeader(t),this._initLeftTop(t),this._initSelectionChangeListener(),this._initThemeChangeListener(),this._initSkeletonChangeListener(),this._initCommandListener(),this._initUserActionSyncListener();const n=i.getUnitId(),o=e.getSheetId();this._selectionManagerService.setCurrentSelection({pluginName:f.NORMAL_SELECTION_PLUGIN_NAME,unitId:n,sheetId:o})}_initViewMainListener(i){const{spreadsheet:e,scene:t}=i,n=t.getViewport(j.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((o,r)=>{this._selectionRenderService.enableDetectMergedCell(),this._selectionRenderService.eventTrigger(o,e.zIndex+1,l.RANGE_TYPE.NORMAL,n),o.button!==2&&r.stopPropagation()})))}_initThemeChangeListener(){this.disposeWithMe(l.toDisposable(this._themeService.currentTheme$.subscribe(()=>{this._selectionRenderService.resetStyle();const i=this._selectionManagerService.getSelections(),e=this._selectionManagerService.getCurrent();if(!(i==null||(e==null?void 0:e.pluginName)!==f.NORMAL_SELECTION_PLUGIN_NAME)){this._selectionRenderService.reset();for(const t of i){if(t==null)continue;const n=this._selectionRenderService.convertSelectionRangeToData(t);n.style=f.getNormalSelectionStyle(this._themeService),this._selectionRenderService.addControlToCurrentByRangeData(n)}}})))}_initRowHeader(i){const{spreadsheetRowHeader:e,spreadsheet:t,scene:n}=i,o=n.getViewport(j.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((r,s)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(r,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.ROW,o,w.ScrollTimerType.Y),r.button!==2&&s.stopPropagation()})))}_initColumnHeader(i){const{spreadsheetColumnHeader:e,spreadsheet:t,scene:n}=i,o=n.getViewport(j.VIEW_MAIN);this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((r,s)=>{this._selectionRenderService.disableDetectMergedCell(),this._selectionRenderService.eventTrigger(r,((t==null?void 0:t.zIndex)||1)+1,l.RANGE_TYPE.COLUMN,o,w.ScrollTimerType.X),r.button!==2&&s.stopPropagation()})))}_initLeftTop(i){const{spreadsheetLeftTopPlaceholder:e}=i;this.disposeWithMe(l.toDisposable(e==null?void 0:e.onPointerDownObserver.add((t,n)=>{var r;const o=(r=this._sheetSkeletonManagerService.getCurrent())==null?void 0:r.skeleton;o!=null&&(this._selectionManagerService.replace([this._getAllRange(o)]),t.button!==2&&n.stopPropagation())})))}_initSelectionChangeListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{if(this._selectionRenderService.reset(),i!=null)for(const e of i){if(e==null)continue;const t=this._selectionRenderService.convertSelectionRangeToData(e);this._selectionRenderService.addControlToCurrentByRangeData(t)}})))}_initUserActionSyncListener(){this._selectionRenderService.selectionMoveStart$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_START)}),this._selectionRenderService.selectionMoving$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVING)}),this._selectionRenderService.selectionMoveEnd$.subscribe(i=>{this._move(i,f.SelectionMoveType.MOVE_END)})}_move(i,e){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getUnitId(),o=t.getActiveSheet().getSheetId(),r=this._selectionManagerService.getCurrent();i==null||i.length===0||this._commandService.executeCommand(f.SetSelectionsOperation.id,{unitId:n,subUnitId:o,type:e,pluginName:(r==null?void 0:r.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME,selections:i.map(s=>f.convertSelectionDataToRange(s))})}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}_initCommandListener(){const i=[Ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=e.params,{unitId:r,subUnitId:s}=o;if(!(r===t.getUnitId()&&s===n.getSheetId()))return;this._selectionManagerService.refreshSelection()}}))}_initSkeletonChangeListener(){this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{unitId:e,sheetId:t,skeleton:n}=i,o=this._renderManagerService.getRenderById(e);if(o==null)return;const{scene:r}=o,s=r.getViewport(j.VIEW_MAIN);this._selectionRenderService.changeRuntime(n,r,s);const a=this._selectionManagerService.getCurrent(),c=(a==null?void 0:a.pluginName)||f.NORMAL_SELECTION_PLUGIN_NAME;this._selectionManagerService.setCurrentSelection({pluginName:c,unitId:e,sheetId:t}),c===f.NORMAL_SELECTION_PLUGIN_NAME&&this._selectionManagerService.getLast()==null&&this._selectionManagerService.add([this._getZeroRange(n)])})}_getAllRange(i){return{range:{startRow:0,startColumn:0,endRow:i.getRowCount()-1,endColumn:i.getColumnCount()-1},primary:this._getZeroRange(i).primary,style:null}}_getZeroRange(i){const e=i.mergeData;return f.transformCellDataToSelectionData(0,0,e)||{range:{startRow:0,startColumn:0,endRow:0,endColumn:0},primary:{actualRow:0,actualColumn:0,startRow:0,startColumn:0,endRow:0,endColumn:0,isMerged:!1,isMergedMainCell:!1},style:null}}};bn=ad([l.OnLifecycle(l.LifecycleStages.Rendered,bn),Ze(0,L.Inject(P.SheetSkeletonManagerService)),Ze(1,l.IUniverInstanceService),Ze(2,l.ICommandService),Ze(3,w.IRenderManagerService),Ze(4,se),Ze(5,L.Inject(f.SelectionManagerService)),Ze(6,L.Inject(l.ThemeService))],bn);var ld=Object.defineProperty,cd=Object.getOwnPropertyDescriptor,dd=(i,e,t,n)=>{for(var o=n>1?void 0:n?cd(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&ld(e,t,o),o},ct=(i,e)=>(t,n)=>e(t,n,i);let Rn=class extends l.Disposable{constructor(i,e,t,n,o,r){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._renderManagerService=t,this._commandService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._initialize(),this._commandExecutedListener()}dispose(){super.dispose()}_initialize(){this._initialRenderRefresh()}_initialRenderRefresh(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeleton$.subscribe(i=>{if(i==null)return;const{skeleton:e,unitId:t,sheetId:n}=i,o=this._currentUniverService.getUniverSheetInstance(t),r=o==null?void 0:o.getSheetBySheetId(n);if(o==null||r==null)return;const s=this._renderManagerService.getRenderById(t);if(s==null)return;const{mainComponent:a,components:c,scene:d}=s,u=a,h=c.get(re.ROW),m=c.get(re.COLUMN),_=c.get(re.LEFT_TOP),{rowHeaderWidth:g,columnHeaderHeight:S}=e;u==null||u.updateSkeleton(e),h==null||h.updateSkeleton(e),m==null||m.updateSkeleton(e),_==null||_.transformByState({width:g,height:S})})))}_commandExecutedListener(){this.disposeWithMe(this._commandService.onCommandExecuted(i=>{var n,o;const e=this._currentUniverService.getCurrentUniverSheetInstance(),t=e.getUnitId();if(f.COMMAND_LISTENER_SKELETON_CHANGE.includes(i.id)){const r=e.getActiveSheet(),s=r.getSheetId(),a=i.params,{unitId:c,subUnitId:d}=a;if(!(c===e.getUnitId()&&d===r.getSheetId()))return;i.id!==f.SetWorksheetActiveOperation.id&&this._sheetSkeletonManagerService.makeDirty({unitId:c,sheetId:s,commandId:i.id},!0),this._sheetSkeletonManagerService.setCurrent({unitId:c,sheetId:s,commandId:i.id})}else f.COMMAND_LISTENER_VALUE_CHANGE.includes(i.id)&&this._sheetSkeletonManagerService.reCalculate();i.type===l.CommandType.MUTATION&&((o=(n=this._renderManagerService.getRenderById(t))==null?void 0:n.mainComponent)==null||o.makeDirty())}))}};Rn=dd([l.OnLifecycle(l.LifecycleStages.Rendered,Rn),ct(0,L.Inject(P.SheetSkeletonManagerService)),ct(1,l.IUniverInstanceService),ct(2,w.IRenderManagerService),ct(3,l.ICommandService),ct(4,se),ct(5,L.Inject(f.SelectionManagerService))],Rn);const xe={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge",handler:async(i,e)=>{const t=i.get(l.ICommandService),n=i.get(l.IUndoRedoService),o=i.get(l.IUniverInstanceService),r=i.get(M.IConfirmService),s=i.get(l.LocaleService),a=e.unitId,c=e.subUnitId,d=e.selections,u=f.getAddMergeMutationRangeByType(d,e.value),h=o.getUniverSheetInstance(a).getSheetBySheetId(c),m=[],_=[],g=Ro(h,u);if(g&&!await r.confirm({id:"merge.confirm.add-worksheet-merge",title:{title:"merge.confirm.title"},cancelText:s.t("merge.confirm.cancel"),confirmText:s.t("merge.confirm.confirm")}))return!1;const S={unitId:a,subUnitId:c,ranges:u},v={unitId:a,subUnitId:c,ranges:u};m.push({id:f.RemoveWorksheetMergeMutation.id,params:S}),m.push({id:f.AddWorksheetMergeMutation.id,params:v});const I=f.RemoveMergeUndoMutationFactory(i,S),b=f.AddMergeUndoMutationFactory(i,v);if(_.push({id:f.RemoveWorksheetMergeMutation.id,params:b}),_.push({id:f.AddWorksheetMergeMutation.id,params:I}),g){const T=wo(i,a,h,u);m.unshift(...T.redos),_.push(...T.undos)}return l.sequenceExecute(m,t).result?(n.pushUndoRedo({unitID:a,undoMutations:_,redoMutations:m}),!0):!1}},ir={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-all",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const a=r.getUnitId(),c=s.getSheetId();return e.executeCommand(xe.id,{selections:n,unitId:a,subUnitId:c})}},or={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-vertical",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const a=r.getUnitId(),c=s.getSheetId();return e.executeCommand(xe.id,{value:l.Dimension.COLUMNS,selections:n,unitId:a,subUnitId:c})}},rr={type:l.CommandType.COMMAND,id:"sheet.command.add-worksheet-merge-horizontal",handler:async i=>{const e=i.get(l.ICommandService),n=i.get(f.SelectionManagerService).getSelectionRanges();if(!(n!=null&&n.length))return!1;const r=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance();if(!r)return!1;const s=r.getActiveSheet();if(!s)return!1;const a=r.getUnitId(),c=s.getSheetId();return e.executeCommand(xe.id,{value:l.Dimension.ROWS,selections:n,unitId:a,subUnitId:c})}},sr={id:"sheet.command.refill",type:l.CommandType.COMMAND,handler:async(i,e)=>(i.get(Mt).setApplyType(e.type),!0)},dt=L.createIdentifier("univer.sheetbar-service");class ud extends l.Disposable{constructor(){super();C(this,"renameId$");C(this,"scroll$");C(this,"scrollX$");C(this,"addSheet$");C(this,"_renameId$");C(this,"_scroll$");C(this,"_scrollX$");C(this,"_addSheet$");C(this,"_currentHandler",null);this._renameId$=new B.Subject,this.renameId$=this._renameId$.asObservable(),this._scroll$=new B.Subject,this.scroll$=this._scroll$.asObservable(),this._scrollX$=new B.Subject,this.scrollX$=this._scrollX$.asObservable(),this._addSheet$=new B.Subject,this.addSheet$=this._addSheet$.asObservable()}setRenameId(t){this._renameId$.next(t)}setScroll(t){this._scroll$.next(t)}setScrollX(t){this._scrollX$.next(t)}setAddSheet(t){this._addSheet$.next(t)}triggerSheetBarMenu(){var t;(t=this._currentHandler)==null||t.handleSheetBarMenu()}registerSheetBarMenuHandler(t){if(this._currentHandler)throw new Error("There is already a context menu handler!");return this._currentHandler=t,l.toDisposable(()=>{this._currentHandler=null})}}const ar={id:"sheet.command.rename-sheet",type:l.CommandType.OPERATION,handler:async(i,e)=>{const t=i.get(dt);return e&&t.setRenameId(e.subUnitId),!0}},wn={id:"sheet.command.change-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{delta:t,reset:n}=e,o=i.get(l.IUniverInstanceService).getCurrentUniverSheetInstance(),r=o.getActiveSheet(),s=o.getUnitId(),a=r.getSheetId();let c=n?100:Math.round((r.getConfig().zoomRatio+t)*100);c=Math.max(Yn[0],c),c=Math.min(Yn[1],c);const d=c/100;return i.get(l.ICommandService).executeCommand(Ee.id,{unitId:s,subUnitId:a,zoomRatio:d})}},vi={id:"sheet.command.set-zoom-ratio",type:l.CommandType.COMMAND,handler:async(i,e)=>{if(!e)return!1;const{unitId:t,subUnitId:n,zoomRatio:o}=e;return i.get(l.ICommandService).executeCommand(Ee.id,{unitId:t,subUnitId:n,zoomRatio:o})}},lr={id:"ui-sheet.command.show-menu-list",type:l.CommandType.OPERATION,handler:async i=>(i.get(dt).triggerSheetBarMenu(),!0)},hd=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M0.98999 1.08218H-0.0100098V0.0821838H0.98999V1.08218Z",fill:"black"}),p.jsx("path",{d:"M5.78992 1.08218H2.78992V0.0821838H5.78992V1.08218Z",fill:"black"}),p.jsx("path",{d:"M7.58984 1.08218H8.58984V0.0821838H7.58984V1.08218Z",fill:"black"}),p.jsx("path",{d:"M14.9152 1.08218H13.9152V0.0821838H14.9152V1.08218Z",fill:"black"}),p.jsx("path",{d:"M16.7151 1.08218H19.7151V0.0821838H16.7151V1.08218Z",fill:"black"}),p.jsx("path",{d:"M22.515 1.08218H21.515V0.0821838H22.515V1.08218Z",fill:"black"}),p.jsx("path",{d:"M27.8405 1.08218H28.8405V0.0821838H27.8405V1.08218Z",fill:"black"}),p.jsx("path",{d:"M33.6404 1.08218H30.6404V0.0821838H33.6404V1.08218Z",fill:"black"}),p.jsx("path",{d:"M35.4403 1.08218H36.4403V0.0821838H35.4403V1.08218Z",fill:"black"}),p.jsx("path",{d:"M42.7657 1.08218H41.7657V0.0821838H42.7657V1.08218Z",fill:"black"}),p.jsx("path",{d:"M44.5657 1.08218H47.5657V0.0821838H44.5657V1.08218Z",fill:"black"}),p.jsx("path",{d:"M50.3656 1.08218H49.3656V0.0821838H50.3656V1.08218Z",fill:"black"}),p.jsx("path",{d:"M55.691 1.08218H56.691V0.0821838H55.691V1.08218Z",fill:"black"}),p.jsx("path",{d:"M61.491 1.08218H58.491V0.0821838H61.491V1.08218Z",fill:"black"}),p.jsx("path",{d:"M63.2909 1.08218H64.2909V0.0821838H63.2909V1.08218Z",fill:"black"}),p.jsx("path",{d:"M70.6163 1.08218H69.6163V0.0821838H70.6163V1.08218Z",fill:"black"}),p.jsx("path",{d:"M72.4163 1.08218H75.4163V0.0821838H72.4163V1.08218Z",fill:"black"}),p.jsx("path",{d:"M78.2162 1.08218H77.2162V0.0821838H78.2162V1.08218Z",fill:"black"}),p.jsx("path",{d:"M83.5416 1.08218H84.5416V0.0821838H83.5416V1.08218Z",fill:"black"}),p.jsx("path",{d:"M89.3416 1.08218H86.3416V0.0821838H89.3416V1.08218Z",fill:"black"}),p.jsx("path",{d:"M91.1415 1.08218H92.1415V0.0821838H91.1415V1.08218Z",fill:"black"}),p.jsx("path",{d:"M98.4669 1.08218H97.4669V0.0821838H98.4669V1.08218Z",fill:"black"}),p.jsx("path",{d:"M100.267 1.08218H103.267V0.0821838H100.267V1.08218Z",fill:"black"}),p.jsx("path",{d:"M106.067 1.08218H105.067V0.0821838H106.067V1.08218Z",fill:"black"}),p.jsx("path",{d:"M111.392 1.08218H112.392V0.0821838H111.392V1.08218Z",fill:"black"}),p.jsx("path",{d:"M117.192 1.08218H114.192V0.0821838H117.192V1.08218Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.08218H119.992V0.0821838H118.992V1.08218Z",fill:"black"})]}),md=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 1.15771H0.98999V0.157715H-0.0100098V1.15771Z",fill:"black"}),p.jsx("path",{d:"M2.78992 1.15771H5.78992V0.157715H2.78992V1.15771Z",fill:"black"}),p.jsx("path",{d:"M8.58984 1.15771H7.58984V0.157715H8.58984V1.15771Z",fill:"black"}),p.jsx("path",{d:"M10.3899 1.15771H11.3899V0.157715H10.3899V1.15771Z",fill:"black"}),p.jsx("path",{d:"M19.0903 1.15771H18.0903V0.157715H19.0903V1.15771Z",fill:"black"}),p.jsx("path",{d:"M20.8903 1.15771H23.8903V0.157715H20.8903V1.15771Z",fill:"black"}),p.jsx("path",{d:"M26.6902 1.15771H25.6902V0.157715H26.6902V1.15771Z",fill:"black"}),p.jsx("path",{d:"M28.4902 1.15771H29.4902V0.157715H28.4902V1.15771Z",fill:"black"}),p.jsx("path",{d:"M37.1907 1.15771H36.1907V0.157715H37.1907V1.15771Z",fill:"black"}),p.jsx("path",{d:"M38.9906 1.15771H41.9906V0.157715H38.9906V1.15771Z",fill:"black"}),p.jsx("path",{d:"M44.7905 1.15771H43.7905V0.157715H44.7905V1.15771Z",fill:"black"}),p.jsx("path",{d:"M46.5906 1.15771H47.5906V0.157715H46.5906V1.15771Z",fill:"black"}),p.jsx("path",{d:"M55.291 1.15771H54.291V0.157715H55.291V1.15771Z",fill:"black"}),p.jsx("path",{d:"M57.0909 1.15771H60.0909V0.157715H57.0909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M62.8909 1.15771H61.8909V0.157715H62.8909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M64.6909 1.15771H65.6909V0.157715H64.6909V1.15771Z",fill:"black"}),p.jsx("path",{d:"M73.3914 1.15771H72.3914V0.157715H73.3914V1.15771Z",fill:"black"}),p.jsx("path",{d:"M75.1913 1.15771H78.1913V0.157715H75.1913V1.15771Z",fill:"black"}),p.jsx("path",{d:"M80.9912 1.15771H79.9912V0.157715H80.9912V1.15771Z",fill:"black"}),p.jsx("path",{d:"M82.7913 1.15771H83.7913V0.157715H82.7913V1.15771Z",fill:"black"}),p.jsx("path",{d:"M91.4917 1.15771H90.4917V0.157715H91.4917V1.15771Z",fill:"black"}),p.jsx("path",{d:"M93.2916 1.15771H96.2916V0.157715H93.2916V1.15771Z",fill:"black"}),p.jsx("path",{d:"M99.0916 1.15771H98.0916V0.157715H99.0916V1.15771Z",fill:"black"}),p.jsx("path",{d:"M100.892 1.15771H101.892V0.157715H100.892V1.15771Z",fill:"black"}),p.jsx("path",{d:"M109.592 1.15771H108.592V0.157715H109.592V1.15771Z",fill:"black"}),p.jsx("path",{d:"M111.392 1.15771H114.392V0.157715H111.392V1.15771Z",fill:"black"}),p.jsx("path",{d:"M117.192 1.15771H116.192V0.157715H117.192V1.15771Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.15771H119.992V0.157715H118.992V1.15771Z",fill:"black"})]}),_d=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00842285 1.22449H2.99158V0.224487H-0.00842285V1.22449Z",fill:"black"}),p.jsx("path",{d:"M6.14941 1.22449H9.14941V0.224487H6.14941V1.22449Z",fill:"black"}),p.jsx("path",{d:"M15.3073 1.22449H12.3073V0.224487H15.3073V1.22449Z",fill:"black"}),p.jsx("path",{d:"M18.4651 1.22449H21.4651V0.224487H18.4651V1.22449Z",fill:"black"}),p.jsx("path",{d:"M27.6229 1.22449H24.6229V0.224487H27.6229V1.22449Z",fill:"black"}),p.jsx("path",{d:"M30.7808 1.22449H33.7808V0.224487H30.7808V1.22449Z",fill:"black"}),p.jsx("path",{d:"M39.9386 1.22449H36.9386V0.224487H39.9386V1.22449Z",fill:"black"}),p.jsx("path",{d:"M43.0964 1.22449H46.0964V0.224487H43.0964V1.22449Z",fill:"black"}),p.jsx("path",{d:"M52.2543 1.22449H49.2543V0.224487H52.2543V1.22449Z",fill:"black"}),p.jsx("path",{d:"M55.4121 1.22449H58.4121V0.224487H55.4121V1.22449Z",fill:"black"}),p.jsx("path",{d:"M64.5699 1.22449H61.5699V0.224487H64.5699V1.22449Z",fill:"black"}),p.jsx("path",{d:"M67.7278 1.22449H70.7278V0.224487H67.7278V1.22449Z",fill:"black"}),p.jsx("path",{d:"M76.8856 1.22449H73.8856V0.224487H76.8856V1.22449Z",fill:"black"}),p.jsx("path",{d:"M80.0435 1.22449H83.0435V0.224487H80.0435V1.22449Z",fill:"black"}),p.jsx("path",{d:"M89.2013 1.22449H86.2013V0.224487H89.2013V1.22449Z",fill:"black"}),p.jsx("path",{d:"M92.3591 1.22449H95.3591V0.224487H92.3591V1.22449Z",fill:"black"}),p.jsx("path",{d:"M101.517 1.22449H98.517V0.224487H101.517V1.22449Z",fill:"black"}),p.jsx("path",{d:"M104.675 1.22449H107.675V0.224487H104.675V1.22449Z",fill:"black"}),p.jsx("path",{d:"M113.833 1.22449H110.833V0.224487H113.833V1.22449Z",fill:"black"}),p.jsx("path",{d:"M116.99 1.22449H119.99V0.224487H116.99V1.22449Z",fill:"black"})]}),Sd=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00976562 1.65707H0.990234V0.657074H-0.00976562V1.65707Z",fill:"black"}),p.jsx("path",{d:"M2.32361 1.65707H3.32361V0.657074H2.32361V1.65707Z",fill:"black"}),p.jsx("path",{d:"M5.65698 1.65707H4.65698V0.657074H5.65698V1.65707Z",fill:"black"}),p.jsx("path",{d:"M6.99036 1.65707H7.99036V0.657074H6.99036V1.65707Z",fill:"black"}),p.jsx("path",{d:"M10.3237 1.65707H9.32373V0.657074H10.3237V1.65707Z",fill:"black"}),p.jsx("path",{d:"M11.6571 1.65707H12.6571V0.657074H11.6571V1.65707Z",fill:"black"}),p.jsx("path",{d:"M14.9905 1.65707H13.9905V0.657074H14.9905V1.65707Z",fill:"black"}),p.jsx("path",{d:"M16.3239 1.65707H17.3239V0.657074H16.3239V1.65707Z",fill:"black"}),p.jsx("path",{d:"M19.6572 1.65707H18.6572V0.657074H19.6572V1.65707Z",fill:"black"}),p.jsx("path",{d:"M20.9906 1.65707H21.9906V0.657074H20.9906V1.65707Z",fill:"black"}),p.jsx("path",{d:"M24.324 1.65707H23.324V0.657074H24.324V1.65707Z",fill:"black"}),p.jsx("path",{d:"M25.6573 1.65707H26.6573V0.657074H25.6573V1.65707Z",fill:"black"}),p.jsx("path",{d:"M28.9907 1.65707H27.9907V0.657074H28.9907V1.65707Z",fill:"black"}),p.jsx("path",{d:"M30.3241 1.65707H31.3241V0.657074H30.3241V1.65707Z",fill:"black"}),p.jsx("path",{d:"M33.6575 1.65707H32.6575V0.657074H33.6575V1.65707Z",fill:"black"}),p.jsx("path",{d:"M34.9908 1.65707H35.9908V0.657074H34.9908V1.65707Z",fill:"black"}),p.jsx("path",{d:"M38.3242 1.65707H37.3242V0.657074H38.3242V1.65707Z",fill:"black"}),p.jsx("path",{d:"M39.6576 1.65707H40.6576V0.657074H39.6576V1.65707Z",fill:"black"}),p.jsx("path",{d:"M42.991 1.65707H41.991V0.657074H42.991V1.65707Z",fill:"black"}),p.jsx("path",{d:"M44.3243 1.65707H45.3243V0.657074H44.3243V1.65707Z",fill:"black"}),p.jsx("path",{d:"M47.6577 1.65707H46.6577V0.657074H47.6577V1.65707Z",fill:"black"}),p.jsx("path",{d:"M48.9911 1.65707H49.9911V0.657074H48.9911V1.65707Z",fill:"black"}),p.jsx("path",{d:"M52.3245 1.65707H51.3245V0.657074H52.3245V1.65707Z",fill:"black"}),p.jsx("path",{d:"M53.6578 1.65707H54.6578V0.657074H53.6578V1.65707Z",fill:"black"}),p.jsx("path",{d:"M56.9912 1.65707H55.9912V0.657074H56.9912V1.65707Z",fill:"black"}),p.jsx("path",{d:"M58.3246 1.65707H59.3246V0.657074H58.3246V1.65707Z",fill:"black"}),p.jsx("path",{d:"M61.658 1.65707H60.658V0.657074H61.658V1.65707Z",fill:"black"}),p.jsx("path",{d:"M62.9913 1.65707H63.9913V0.657074H62.9913V1.65707Z",fill:"black"}),p.jsx("path",{d:"M66.3247 1.65707H65.3247V0.657074H66.3247V1.65707Z",fill:"black"}),p.jsx("path",{d:"M67.6581 1.65707H68.6581V0.657074H67.6581V1.65707Z",fill:"black"}),p.jsx("path",{d:"M70.9915 1.65707H69.9915V0.657074H70.9915V1.65707Z",fill:"black"}),p.jsx("path",{d:"M72.3248 1.65707H73.3248V0.657074H72.3248V1.65707Z",fill:"black"}),p.jsx("path",{d:"M75.6582 1.65707H74.6582V0.657074H75.6582V1.65707Z",fill:"black"}),p.jsx("path",{d:"M76.9916 1.65707H77.9916V0.657074H76.9916V1.65707Z",fill:"black"}),p.jsx("path",{d:"M80.325 1.65707H79.325V0.657074H80.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M81.6583 1.65707H82.6583V0.657074H81.6583V1.65707Z",fill:"black"}),p.jsx("path",{d:"M84.9917 1.65707H83.9917V0.657074H84.9917V1.65707Z",fill:"black"}),p.jsx("path",{d:"M86.3251 1.65707H87.3251V0.657074H86.3251V1.65707Z",fill:"black"}),p.jsx("path",{d:"M89.6584 1.65707H88.6584V0.657074H89.6584V1.65707Z",fill:"black"}),p.jsx("path",{d:"M90.9918 1.65707H91.9918V0.657074H90.9918V1.65707Z",fill:"black"}),p.jsx("path",{d:"M94.3252 1.65707H93.3252V0.657074H94.3252V1.65707Z",fill:"black"}),p.jsx("path",{d:"M95.6586 1.65707H96.6586V0.657074H95.6586V1.65707Z",fill:"black"}),p.jsx("path",{d:"M98.9919 1.65707H97.9919V0.657074H98.9919V1.65707Z",fill:"black"}),p.jsx("path",{d:"M100.325 1.65707H101.325V0.657074H100.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M103.659 1.65707H102.659V0.657074H103.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M104.992 1.65707H105.992V0.657074H104.992V1.65707Z",fill:"black"}),p.jsx("path",{d:"M108.325 1.65707H107.325V0.657074H108.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M109.659 1.65707H110.659V0.657074H109.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M112.992 1.65707H111.992V0.657074H112.992V1.65707Z",fill:"black"}),p.jsx("path",{d:"M114.325 1.65707H115.325V0.657074H114.325V1.65707Z",fill:"black"}),p.jsx("path",{d:"M117.659 1.65707H116.659V0.657074H117.659V1.65707Z",fill:"black"}),p.jsx("path",{d:"M118.992 1.65707H119.992V0.657074H118.992V1.65707Z",fill:"black"})]}),gd=()=>p.jsx("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 2.42035H-0.0090332V0.420349H119.991V2.42035Z",fill:"black"})}),fd=()=>p.jsxs("svg",{width:"120",height:"3",viewBox:"0 0 120 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 2.47614H1.98999V0.476135H-0.0100098V2.47614Z",fill:"black"}),p.jsx("path",{d:"M3.99014 2.47614H9.99014V0.476135H3.99014V2.47614Z",fill:"black"}),p.jsx("path",{d:"M13.9901 2.47614H11.9901V0.476135H13.9901V2.47614Z",fill:"black"}),p.jsx("path",{d:"M21.1904 2.47614H23.1904V0.476135H21.1904V2.47614Z",fill:"black"}),p.jsx("path",{d:"M31.1906 2.47614H25.1906V0.476135H31.1906V2.47614Z",fill:"black"}),p.jsx("path",{d:"M33.1906 2.47614H35.1906V0.476135H33.1906V2.47614Z",fill:"black"}),p.jsx("path",{d:"M44.3909 2.47614H42.3909V0.476135H44.3909V2.47614Z",fill:"black"}),p.jsx("path",{d:"M46.391 2.47614H52.391V0.476135H46.391V2.47614Z",fill:"black"}),p.jsx("path",{d:"M56.391 2.47614H54.391V0.476135H56.391V2.47614Z",fill:"black"}),p.jsx("path",{d:"M63.5913 2.47614H65.5913V0.476135H63.5913V2.47614Z",fill:"black"}),p.jsx("path",{d:"M73.5915 2.47614H67.5915V0.476135H73.5915V2.47614Z",fill:"black"}),p.jsx("path",{d:"M75.5915 2.47614H77.5915V0.476135H75.5915V2.47614Z",fill:"black"}),p.jsx("path",{d:"M86.7917 2.47614H84.7917V0.476135H86.7917V2.47614Z",fill:"black"}),p.jsx("path",{d:"M88.7919 2.47614H94.7919V0.476135H88.7919V2.47614Z",fill:"black"}),p.jsx("path",{d:"M98.7919 2.47614H96.7919V0.476135H98.7919V2.47614Z",fill:"black"}),p.jsx("path",{d:"M105.992 2.47614H107.992V0.476135H105.992V2.47614Z",fill:"black"}),p.jsx("path",{d:"M115.992 2.47614H109.992V0.476135H115.992V2.47614Z",fill:"black"}),p.jsx("path",{d:"M117.992 2.47614H119.992V0.476135H117.992V2.47614Z",fill:"black"})]}),pd=()=>p.jsxs("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.0100098 2.00415H1.98999V0.00415039H-0.0100098V2.00415Z",fill:"black"}),p.jsx("path",{d:"M3.99014 2.00415H9.99014V0.00415039H3.99014V2.00415Z",fill:"black"}),p.jsx("path",{d:"M13.9901 2.00415H11.9901V0.00415039H13.9901V2.00415Z",fill:"black"}),p.jsx("path",{d:"M15.9901 2.00415H17.9901V0.00415039H15.9901V2.00415Z",fill:"black"}),p.jsx("path",{d:"M27.4905 2.00415H25.4905V0.00415039H27.4905V2.00415Z",fill:"black"}),p.jsx("path",{d:"M29.4906 2.00415H35.4906V0.00415039H29.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M39.4906 2.00415H37.4906V0.00415039H39.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M41.4906 2.00415H43.4906V0.00415039H41.4906V2.00415Z",fill:"black"}),p.jsx("path",{d:"M52.991 2.00415H50.991V0.00415039H52.991V2.00415Z",fill:"black"}),p.jsx("path",{d:"M54.9911 2.00415H60.9911V0.00415039H54.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M64.9911 2.00415H62.9911V0.00415039H64.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M66.9911 2.00415H68.9911V0.00415039H66.9911V2.00415Z",fill:"black"}),p.jsx("path",{d:"M78.4915 2.00415H76.4915V0.00415039H78.4915V2.00415Z",fill:"black"}),p.jsx("path",{d:"M80.4916 2.00415H86.4916V0.00415039H80.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M90.4916 2.00415H88.4916V0.00415039H90.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M92.4916 2.00415H94.4916V0.00415039H92.4916V2.00415Z",fill:"black"}),p.jsx("path",{d:"M103.992 2.00415H101.992V0.00415039H103.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M105.992 2.00415H111.992V0.00415039H105.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M115.992 2.00415H113.992V0.00415039H115.992V2.00415Z",fill:"black"}),p.jsx("path",{d:"M117.992 2.00415H119.992V0.00415039H117.992V2.00415Z",fill:"black"})]}),vd=()=>p.jsxs("svg",{width:"118",height:"3",viewBox:"0 0 118 3",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("path",{d:"M-0.00854492 2.94815H1.99146V0.948151H-0.00854492V2.94815Z",fill:"black"}),p.jsx("path",{d:"M6.09668 2.94815H8.09668V0.948151H6.09668V2.94815Z",fill:"black"}),p.jsx("path",{d:"M14.2019 2.94815H12.2019V0.948151H14.2019V2.94815Z",fill:"black"}),p.jsx("path",{d:"M18.3071 2.94815H20.3071V0.948151H18.3071V2.94815Z",fill:"black"}),p.jsx("path",{d:"M26.4124 2.94815H24.4124V0.948151H26.4124V2.94815Z",fill:"black"}),p.jsx("path",{d:"M30.5176 2.94815H32.5176V0.948151H30.5176V2.94815Z",fill:"black"}),p.jsx("path",{d:"M38.6228 2.94815H36.6228V0.948151H38.6228V2.94815Z",fill:"black"}),p.jsx("path",{d:"M42.728 2.94815H44.728V0.948151H42.728V2.94815Z",fill:"black"}),p.jsx("path",{d:"M50.8333 2.94815H48.8333V0.948151H50.8333V2.94815Z",fill:"black"}),p.jsx("path",{d:"M54.9385 2.94815H56.9385V0.948151H54.9385V2.94815Z",fill:"black"}),p.jsx("path",{d:"M63.0437 2.94815H61.0437V0.948151H63.0437V2.94815Z",fill:"black"}),p.jsx("path",{d:"M67.1489 2.94815H69.1489V0.948151H67.1489V2.94815Z",fill:"black"}),p.jsx("path",{d:"M75.2542 2.94815H73.2542V0.948151H75.2542V2.94815Z",fill:"black"}),p.jsx("path",{d:"M79.3594 2.94815H81.3594V0.948151H79.3594V2.94815Z",fill:"black"}),p.jsx("path",{d:"M87.4645 2.94815H85.4645V0.948151H87.4645V2.94815Z",fill:"black"}),p.jsx("path",{d:"M91.5697 2.94815H93.5697V0.948151H91.5697V2.94815Z",fill:"black"}),p.jsx("path",{d:"M99.6749 2.94815H97.6749V0.948151H99.6749V2.94815Z",fill:"black"}),p.jsx("path",{d:"M103.78 2.94815H105.78V0.948151H103.78V2.94815Z",fill:"black"}),p.jsx("path",{d:"M111.885 2.94815H109.885V0.948151H111.885V2.94815Z",fill:"black"}),p.jsx("path",{d:"M115.991 2.94815H117.991V0.948151H115.991V2.94815Z",fill:"black"})]}),Cd=()=>p.jsx("svg",{width:"120",height:"4",viewBox:"0 0 120 4",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 3.86215H-0.0090332V0.862152H119.991V3.86215Z",fill:"black"})}),cr=()=>p.jsx("svg",{width:"120",height:"2",viewBox:"0 0 120 2",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:p.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M119.991 1.15668H-0.0090332V0.156677H119.991V1.15668Z",fill:"black"})});function dr(i){const{type:e=l.BorderStyleTypes.THIN}=i;switch(e){case l.BorderStyleTypes.DASH_DOT:return p.jsx(hd,{});case l.BorderStyleTypes.DASH_DOT_DOT:return p.jsx(md,{});case l.BorderStyleTypes.DASHED:return p.jsx(_d,{});case l.BorderStyleTypes.HAIR:return p.jsx(Sd,{});case l.BorderStyleTypes.MEDIUM:return p.jsx(gd,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT:return p.jsx(fd,{});case l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT:return p.jsx(pd,{});case l.BorderStyleTypes.MEDIUM_DASHED:return p.jsx(vd,{});case l.BorderStyleTypes.THICK:return p.jsx(Cd,{});case l.BorderStyleTypes.THIN:return p.jsx(cr,{});default:return p.jsx(cr,{})}}const Ae={uiPluginSheetsBorderPanel:"univer-ui-plugin-sheets-border-panel",uiPluginSheetsBorderPanelPosition:"univer-ui-plugin-sheets-border-panel-position",uiPluginSheetsBorderPanelPositionItem:"univer-ui-plugin-sheets-border-panel-position-item",uiPluginSheetsBorderPanelStyles:"univer-ui-plugin-sheets-border-panel-styles",uiPluginSheetsBorderPanelBoard:"univer-ui-plugin-sheets-border-panel-board",uiPluginSheetsBorderPanelButton:"univer-ui-plugin-sheets-border-panel-button",uiPluginSheetsBorderPanelMoreIcon:"univer-ui-plugin-sheets-border-panel-more-icon"},ur=`${ot}_BORDER_PANEL_COMPONENT`,hr=[{label:"borderLine.borderTop",icon:"UpBorder",value:"top"},{label:"borderLine.borderBottom",icon:"DownBorder",value:"bottom"},{label:"borderLine.borderLeft",icon:"LeftBorder",value:"left"},{label:"borderLine.borderRight",icon:"RightBorder",value:"right"},{label:"borderLine.borderNone",icon:"NoBorderSingle",value:"none"},{label:"borderLine.borderAll",icon:"AllBorderSingle",value:"all"},{label:"borderLine.borderOutside",icon:"OuterBorder",value:"outside"},{label:"borderLine.borderInside",icon:"InnerBorder",value:"inside"},{label:"borderLine.borderHorizontal",icon:"InnerBorder",value:"horizontal"},{label:"borderLine.borderVertical",icon:"InnerBorder",value:"vertical"}],Id=[{label:l.BorderStyleTypes.THIN,value:l.BorderStyleTypes.THIN},{label:l.BorderStyleTypes.HAIR,value:l.BorderStyleTypes.HAIR},{label:l.BorderStyleTypes.DOTTED,value:l.BorderStyleTypes.DOTTED},{label:l.BorderStyleTypes.DASHED,value:l.BorderStyleTypes.DASHED},{label:l.BorderStyleTypes.DASH_DOT,value:l.BorderStyleTypes.DASH_DOT},{label:l.BorderStyleTypes.DASH_DOT_DOT,value:l.BorderStyleTypes.DASH_DOT_DOT},{label:l.BorderStyleTypes.MEDIUM,value:l.BorderStyleTypes.MEDIUM},{label:l.BorderStyleTypes.MEDIUM_DASHED,value:l.BorderStyleTypes.MEDIUM_DASHED},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT},{label:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT,value:l.BorderStyleTypes.MEDIUM_DASH_DOT_DOT},{label:l.BorderStyleTypes.THICK,value:l.BorderStyleTypes.THICK}];function Md(i){const e=F.useDependency(M.ComponentManager),{onChange:t,value:n}=i;function o(a,c){t==null||t({...n,[c]:a})}function r(a){const c=e.get(a);return c&&p.jsx(c,{extend:{colorChannel1:"rgb(var(--primary-color))"}})}function s(a){a.stopPropagation()}return p.jsxs("section",{className:Ae.uiPluginSheetsBorderPanel,children:[p.jsx("div",{className:Ae.uiPluginSheetsBorderPanelPosition,children:hr.map(a=>p.jsx("div",{className:Ae.uiPluginSheetsBorderPanelPositionItem,onClick:()=>o(a.value,"type"),children:r(a.icon)},a.value))}),p.jsxs("div",{className:Ae.uiPluginSheetsBorderPanelStyles,children:[p.jsx("div",{children:p.jsx(ne.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{className:Ae.uiPluginSheetsBorderPanelBoard,onClick:s,children:p.jsx(ne.ColorPicker,{onChange:a=>o(a,"color")})}),children:p.jsxs("a",{className:Ae.uiPluginSheetsBorderPanelButton,onClick:s,children:[p.jsx(Gs,{extend:{colorChannel1:n.color??"rgb(var(--primary-color))"}}),p.jsx("span",{className:Ae.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx($n,{})})]})})}),p.jsx("div",{children:p.jsx(ne.Dropdown,{align:{offset:[0,18]},overlay:p.jsx("section",{onClick:s,children:p.jsx(ne.Menu,{children:Id.map(a=>p.jsx(ne.MenuItem,{eventKey:a.value.toString(),onClick:()=>o(a.value,"style"),children:p.jsx(dr,{type:a.value})},a.value))})}),children:p.jsxs("a",{className:Ae.uiPluginSheetsBorderPanelButton,onClick:s,children:[p.jsx(dr,{type:l.BorderStyleTypes.THIN}),p.jsx("span",{className:Ae.uiPluginSheetsBorderPanelMoreIcon,children:p.jsx($n,{})})]})})})]})]})}const bd={countBar:"univer-count-bar"},Rd=[50,80,100,130,150,170,200,400];function wd(){const i=F.useDependency(l.ICommandService),e=F.useDependency(l.IUniverInstanceService),t=r(),[n,o]=k.useState(t);k.useEffect(()=>i.onCommandExecuted(c=>{if(c.id===Ee.id||c.id===f.SetWorksheetActivateCommand.id){const d=r();o(d)}}).dispose,[i]);function r(){const a=e.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()*100||100;return Math.round(a)}function s(a){o(a);const c=e.getCurrentUniverSheetInstance();if(!c)return;const d=c.getActiveSheet();if(!d)return;const u=a/100;i.executeCommand(vi.id,{unitId:c.getUnitId(),subUnitId:d.getSheetId(),zoomRatio:u})}return p.jsx(ne.Slider,{min:Yn[0],value:n,shortcuts:Rd,onChange:s})}function Td(i){return p.jsx("section",{className:bd.countBar,children:p.jsx(wd,{})})}const mr={editorContainer:"univer-editor-container",editorInput:"univer-editor-input"},Tn=-1e3,_r={width:0,height:0,top:Tn,left:Tn},Ed=()=>{const[i,e]=k.useState({..._r}),t=k.useRef(null),n=F.useDependency(w.IRenderManagerService),o=F.useDependency(wt);return k.useEffect(()=>{const r=t.current;if(!r)return;const s=n.currentRender$.pipe(Ti.switchMap(()=>{var c;const a=(c=n.getRenderById(l.DOCS_NORMAL_EDITOR_UNIT_ID_KEY))==null?void 0:c.engine;return a==null||a.setContainer(r),o.state$})).subscribe(a=>{if(a==null)return;const{startX:c=Tn,startY:d=Tn,endX:u=0,endY:h=0,show:m=!1}=a;if(!m)e({..._r});else{e({width:u-c,height:h-d,left:c-1.5,top:d-1.5});const _=t.current;if(!_)return;const{left:g,top:S,width:v,height:I}=_.getBoundingClientRect();o.setRect({left:g,top:S,width:v,height:I})}});return()=>{s.unsubscribe()}},[]),k.useEffect(()=>{o.setFocus(!0)},[i]),p.jsx("div",{className:mr.editorContainer,style:{left:i.left,top:i.top,width:i.width,height:i.height},children:p.jsx("div",{className:mr.editorInput,ref:t})})},oe={formulaBox:"univer-formula-box",nameRanges:"univer-name-ranges",nameRangesInput:"univer-name-ranges-input",formulaBar:"univer-formula-bar",formulaIcon:"univer-formula-icon",formulaIconWrapper:"univer-formula-icon-wrapper",iconContainer:"univer-icon-container",iconContainerSuccess:"univer-icon-container-success",formulaActive:"univer-formula-active",iconContainerError:"univer-icon-container-error",formulaInput:"univer-formula-input",formulaContent:"univer-formula-content",arrowContainer:"univer-arrow-container"};function Od(){const[i,e]=k.useState(oe.formulaGrey),[t,n]=k.useState(0),o=k.useRef(null),r=F.useDependency(w.IRenderManagerService),s=F.useDependency(en),a=F.useDependency(Ce);k.useEffect(()=>{const m=o.current;if(!m)return;const _=r.currentRender$.subscribe(S=>{var I;if(S!==l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY)return;const v=(I=r.getRenderById(l.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY))==null?void 0:I.engine;v==null||v.setContainer(m)}),g=new ResizeObserver(()=>{const S=m.getBoundingClientRect();s.setPosition(S)});return g.observe(m),a.visible$.subscribe(S=>{e(S.visible?oe.formulaActive:oe.formulaGrey)}),()=>{g.unobserve(m),_.unsubscribe()}},[]);function c(){n(t===0?1:0)}function d(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:w.DeviceInputEventType.Keyboard,keycode:M.KeyCode.ESC})}function u(){a.isVisible().visible&&a.changeVisible({visible:!1,eventType:w.DeviceInputEventType.PointerDown})}function h(){s.handleFxBtnClick(!0)}return p.jsxs("div",{className:oe.formulaBox,style:{height:t===0?"28px":"82px"},children:[p.jsx("div",{className:oe.nameRanges,children:p.jsx("div",{className:oe.nameRangesInput})}),p.jsxs("div",{className:oe.formulaBar,children:[p.jsx("div",{className:oe.formulaIcon,children:p.jsxs("div",{className:oe.formulaIconWrapper,children:[p.jsx("span",{className:St(oe.iconContainer,oe.iconContainerError,i),onClick:d,children:p.jsx(Ls,{})}),p.jsx("span",{className:St(oe.iconContainer,oe.iconContainerSuccess,i),onClick:u,children:p.jsx($t,{})}),p.jsx("span",{className:oe.iconContainer,onClick:h,children:p.jsx(js,{})})]})}),p.jsxs("div",{className:oe.formulaInput,children:[p.jsx("div",{className:oe.formulaContent,ref:o}),p.jsx("div",{className:oe.arrowContainer,onClick:c,children:t===0?p.jsx(oo,{}):p.jsx(oo,{style:{transform:"rotateZ(180deg)"}})})]})]})]})}const Ge={operateContainer:"univer-operate-container",autoFillPopupMenu:"univer-auto-fill-popup-menu",autoFillPopupMenuItem:"univer-auto-fill-popup-menu-item",autoFillPopupMenuItemIcon:"univer-auto-fill-popup-menu-item-icon",autoFillPopupMenuItemTitle:"univer-auto-fill-popup-menu-item-title",autoFillPopupMenuItemHide:"univer-auto-fill-popup-menu-item-hide",btnContainer:"univer-btn-container",btnContainerExpand:"univer-btn-container-expand"},yd=()=>{const[,i]=k.useState({});return k.useCallback(()=>i({}),[])},xd=()=>{var q;const i=F.useDependency(l.ICommandService),e=F.useDependency(P.SheetSkeletonManagerService),t=F.useDependency(l.IUniverInstanceService),n=F.useDependency(w.IRenderManagerService),o=F.useDependency(se),r=F.useDependency(Mt),s=F.useDependency(l.LocaleService),[a,c]=k.useState([]),[d,u]=k.useState(!1),[h,m]=k.useState({row:-1,col:-1}),[_,g]=k.useState(z.SERIES),[S,v]=k.useState(!1),I=()=>{v(!0)},b=()=>{v(!1)},R=yd(),T=le(t,n);if(T==null)return null;const{scene:E}=T;if(k.useEffect(()=>{const W=[Ie.id,Ft.id,Ee.id,f.SetRangeValuesMutation.id];return i.onCommandExecuted(J=>{if(J.id===Vt.id){const{endColumn:Pe,endRow:ce}=(J==null?void 0:J.params).selectionRange;m({row:ce,col:Pe})}J.id===tt.id&&R(),W.includes(J.id)&&m({row:-1,col:-1})}).dispose},[R,i]),k.useEffect(()=>l.toDisposable(r.menu$.subscribe(te=>{c(te.map(J=>({...J,index:te.indexOf(J)})))})).dispose,[r]),k.useEffect(()=>l.toDisposable(r.applyType$.subscribe(te=>{g(te)})).dispose,[r]),k.useEffect(()=>{function W(){u(!1)}return document.addEventListener("wheel",W),()=>{document.removeEventListener("wheel",W)}},[d]),h.col<0||h.row<0)return null;const O=(q=e.getCurrent())==null?void 0:q.skeleton,y=o.getViewPort(),x=E==null?void 0:E.scaleX,A=E==null?void 0:E.scaleY,H=E==null?void 0:E.getScrollXY(y);if(!x||!E||!x||!A||!H)return null;const D=(O==null?void 0:O.getNoMergeCellPositionByIndex(h.row,h.col,x,A).endX)||0,N=(O==null?void 0:O.getNoMergeCellPositionByIndex(h.row,h.col,x,A).endY)||0,U=O==null?void 0:O.convertTransformToOffsetX(D,x,H),V=O==null?void 0:O.convertTransformToOffsetY(N,A,H);if(U==null||V==null)return null;const $=W=>{u(W)},X=W=>{i.executeCommand(sr.id,{type:W.value})},Q=d||S,K=a.filter(W=>!W.disable);return p.jsx("div",{onMouseEnter:I,onMouseLeave:b,style:{left:`${U+2}px`,top:`${V+2}px`,position:"absolute"},children:p.jsx(ne.Dropdown,{placement:"bottomLeft",trigger:["click"],overlay:p.jsx("ul",{className:Ge.autoFillPopupMenu,children:K.map(W=>p.jsxs("li",{onClick:()=>X(W),className:Ge.autoFillPopupMenuItem,children:[p.jsx("span",{className:Ge.autoFillPopupMenuItemIcon,children:W.value===_&&p.jsx($t,{style:{color:"rgb(var(--green-700, #409f11))"}})}),p.jsx("span",{className:Ge.autoFillPopupMenuItemTitle,children:s.t(W.label)})]},W.index))}),visible:d,onVisibleChange:$,children:p.jsxs("div",{className:St(Ge.btnContainer,{[Ge.btnContainerExpand]:d}),children:[p.jsx(Ds,{style:{color:"#35322B"},extend:{colorChannel1:"rgb(var(--green-700, #409f11))"}}),Q&&p.jsx($n,{style:{color:"#CCCCCC",fontSize:"8px",marginLeft:"8px"}})]})})})},Ad=()=>p.jsx("div",{className:Ge.operateContainer,children:p.jsx(xd,{})}),En={sheetBar:"univer-sheet-bar",sheetBarOptions:"univer-sheet-bar-options",sheetBarOptionsDivider:"univer-sheet-bar-options-divider"},Pd={sheetBarBtn:"univer-sheet-bar-btn"};function On(i){const{children:e,className:t,style:n,disabled:o=!1,onClick:r,...s}=i,a=c=>{if(o){c.preventDefault();return}r&&r(c)};return p.jsx("button",{className:Pd.sheetBarBtn,style:n,disabled:o,onClick:a,...s,children:e})}const Ve={sheetBarMenu:"univer-sheet-bar-menu",sheetBarMenuItem:"univer-sheet-bar-menu-item",sheetBarMenuItemIcon:"univer-sheet-bar-menu-item-icon",sheetBarMenuItemHide:"univer-sheet-bar-menu-item-hide",sheetBarMenuItemSelect:"univer-sheet-bar-menu-item-select",sheetBarMenuItemLabel:"univer-sheet-bar-menu-item-label"};function Dd(i){const{style:e}=i,[t,n]=k.useState([]),[o,r]=k.useState(!1),s=F.useDependency(l.IUniverInstanceService),a=F.useDependency(l.ICommandService),c=F.useDependency(dt),d=s.getCurrentUniverSheetInstance(),u=S=>{const{sheetId:v}=S;v&&(S.hidden?a.executeCommand(f.SetWorksheetShowCommand.id,{value:v}):S.selected||a.executeCommand(f.SetWorksheetActivateCommand.id,{unitId:d.getUnitId(),subUnitId:v}),r(!1))};k.useEffect(()=>{m();const S=new l.DisposableCollection;return S.add(h()),S.add(c.registerSheetBarMenuHandler({handleSheetBarMenu:_})),()=>{S.dispose()}},[]);const h=()=>a.onCommandExecuted(S=>{switch(S.id){case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:m();break}}),m=()=>{const v=d.getSheets().map((I,b)=>({label:I.getName(),index:`${b}`,sheetId:I.getSheetId(),hidden:I.isSheetHidden()===l.BooleanNumber.TRUE,selected:I.getStatus()===l.BooleanNumber.TRUE}));n(v)};function _(){r(!0)}const g=S=>{r(S)};return p.jsx(ne.Dropdown,{placement:"topLeft",trigger:["click"],overlay:p.jsx("ul",{className:Ve.sheetBarMenu,style:{...e},children:t.map(S=>p.jsxs("li",{onClick:()=>u(S),className:S.selected?`${Ve.sheetBarMenuItem} ${Ve.sheetBarMenuItemSelect}`:S.hidden?`${Ve.sheetBarMenuItem} ${Ve.sheetBarMenuItemHide}`:Ve.sheetBarMenuItem,children:[p.jsx("span",{className:Ve.sheetBarMenuItemIcon,children:S.selected?p.jsx($t,{}):S.hidden?p.jsx(Fs,{}):p.jsx($t,{})}),p.jsx("span",{className:Ve.sheetBarMenuItemLabel,children:S.label})]},S.index))}),visible:o,onVisibleChange:g,children:p.jsx(On,{children:p.jsx(ks,{})})})}const fe={slideTabBarContainer:"univer-slide-tab-bar-container",slideTabBar:"univer-slide-tab-bar",slideTabItem:"univer-slide-tab-item",slideTabActive:"univer-slide-tab-active",slideTabSpan:"univer-slide-tab-span",slideTabSpanEdit:"univer-slide-tab-span-edit"};function Hd(i){const{sheetId:e,label:t,color:n,selected:o}=i,[r,s]=k.useState(!1),[a,c]=k.useState(o),d=F.useDependency(l.ICommandService),u=F.useDependency(l.ThemeService);k.useEffect(()=>{c(o)},[o]);const h=_=>{s(_)},m=_=>{const g=u.getCurrentTheme(),S=g.textColor,v=g.colorWhite;return new l.ColorKit(_).isDark()?v:S};return p.jsx(ne.Dropdown,{visible:r,trigger:["contextMenu"],overlay:p.jsx(M.Menu,{menuType:ee.SHEET_BAR,onOptionSelect:_=>{const{label:g,value:S}=_;d.executeCommand(g,{value:S,subUnitId:e}),s(!1)}}),onVisibleChange:h,children:p.jsx("div",{"data-id":e,className:a?`${fe.slideTabActive} ${fe.slideTabItem}`:fe.slideTabItem,style:{backgroundColor:!a&&n?n:"",color:!a&&n?m(n):"",boxShadow:a&&n?`0px 0px 12px rgba(0, 0, 0, 0.2), inset 0px -2px 0px 0px ${n}`:""},children:p.jsx("span",{className:fe.slideTabSpan,children:t})},e)})}const Nd={easeOutStrong(i,e,t,n){return-t*((i=i/n-1)*i*i*i-1)+e},backOut(i,e,t,n,o){return typeof o>"u"&&(o=.7),t*((i=i/n-1)*i*((o+1)*i+o)+1)+e}},Ld={loop:!1,begin:0,end:0,duration:300,delay:0,type:"easeOutStrong",receive(i){},success(i){},cancel(i){},complete(i){}};class Ud{constructor(e){C(this,"_config");C(this,"_status",0);C(this,"_start",0);C(this,"_handle",0);C(this,"_delayHandle",null);this._config={...Ld,...e},this._config.loop&&(this._config.complete=()=>{},this._config.success=()=>{this.request()})}static success(...e){let t=0;return new Promise(n=>{for(let o=0;o<e.length;o++){const r=e[o],s=r._config,a=s.success;s.loop||(s.success=d=>{t++,a&&a.call(r,d),t===e.length&&n()})}})}request(){this._config.delay===0?(this._status=0,this._start=Date.now(),this._fakeHandle()):(this._delayHandle&&clearTimeout(this._delayHandle),this._delayHandle=setTimeout(()=>{this._status=0,this._start=Date.now(),this._fakeHandle()},this._config.delay))}cancel(){this._status=1,this._delayHandle&&clearTimeout(this._delayHandle),cancelAnimationFrame(this._handle)}_fakeHandle(){let e=Date.now()-this._start;e=e>=this._config.duration?this._config.duration:e;const n=Nd[this._config.type](e,this._config.begin,this._config.end-this._config.begin,this._config.duration,.7).toFixed(2);if(this._config.receive(n),this._status===1){this._config.cancel(n),this._config.complete(n);return}if(e===this._config.duration){this._config.success(n),this._config.complete(n);return}this._handle=requestAnimationFrame(()=>{this._fakeHandle()})}}class Ke{constructor(e,t){C(this,"_slideTabItem");C(this,"_animate");C(this,"_midline",0);C(this,"_translateX");C(this,"_scrollbar");C(this,"_slideTabBar");C(this,"_editMode");C(this,"_placeholder");this._slideTabItem=e,this._animate=null,this._translateX=0,this._editMode=!1,this._slideTabBar=t,this._placeholder=null,this._scrollbar=t.getScrollbar(),this.update()}static midline(e){return e.getBoundingRect().x+e.getBoundingRect().width/2}static leftLine(e){return e.getBoundingRect().x}static rightLine(e){return e.getBoundingRect().x+e.getBoundingRect().width}static make(e,t){const n=[];return e.forEach(o=>n.push(new Ke(o,t))),n}getSlideTabItem(){return this._slideTabItem}isEditMode(){return this._editMode}classList(){return this._slideTabItem.classList}primeval(){return this._slideTabItem}translateX(e){return this._translateX=e,this._slideTabItem.style.transform=`translateX(${e}px)`,this.getTranslateXDirection()}editor(e){let t=!0;if(this._editMode===!1){const n=this.primeval().querySelector("span"),o=d=>{if(!this.emptyCheck()){if(this._editMode=!1,n&&(n.removeAttribute("contentEditable"),n.removeEventListener("blur",o),n.removeEventListener("compositionstart",s),n.removeEventListener("compositionend",a),n.removeEventListener("input",c),n.removeEventListener("keydown",r),n.classList.remove(this._slideTabBar.getConfig().slideTabBarSpanEditClassName)),this._slideTabBar.removeListener(),this._slideTabBar.updateItems(),this._slideTabBar.getConfig().onChangeName){const u=(n==null?void 0:n.innerText)||"",h=this.getId();this._slideTabBar.getConfig().onChangeName(h,u)}e&&e(d)}};let r=d=>{n&&(d.stopPropagation(),d.key==="Enter"&&n.blur())};const s=d=>{t=!1},a=d=>{t=!0},c=d=>{if(!n)return;const u=50;setTimeout(()=>{if(t){const h=n.innerText;h.length>u&&(n.innerText=h.substring(0,u),Ht.keepLastIndex(n))}},0)};n&&(n.setAttribute("contentEditable","true"),n.addEventListener("blur",o),n.addEventListener("compositionstart",s),n.addEventListener("compositionend",a),n.addEventListener("input",c),n.addEventListener("keydown",r),n.classList.add(this._slideTabBar.getConfig().slideTabBarSpanEditClassName),this._editMode=!0,Ht.keepSelectAll(n))}}emptyCheck(){const e=this.primeval().querySelector("span");return e&&e.innerText.trim()===""?(this._slideTabBar.getConfig().onEmptyAlert(),!0):!1}animate(){return{translateX:e=>{this._translateX!==e&&(this._animate&&(this._animate.cancel(),this._animate=null),this._animate=new Ud({begin:this._translateX,end:e,receive:t=>{this._slideTabItem.style.transform=`translateX(${t}px)`}}),this._translateX=e,this._animate.request())},cancel:()=>{this._animate&&(this._animate.cancel(),this._animate=null)}}}after(e){this._slideTabItem.after(e._slideTabItem||e)}update(){this._midline=Ke.midline(this)}disableFixed(){if(this._placeholder){const e=this._slideTabBar.primeval();this._slideTabItem.style.removeProperty("position"),this._slideTabItem.style.removeProperty("left"),this._slideTabItem.style.removeProperty("top"),this._slideTabItem.style.removeProperty("width"),this._slideTabItem.style.removeProperty("height"),this._slideTabItem.style.removeProperty("box-shadow"),this._slideTabItem.style.removeProperty("background"),this._slideTabItem.style.removeProperty("padding"),this._slideTabItem.style.removeProperty("boxSizing"),this._slideTabItem.style.removeProperty("fontSize"),this._slideTabItem.style.removeProperty("color"),this._slideTabItem.style.removeProperty("borderRadius"),this._placeholder.after(this._slideTabItem),e.removeChild(this._placeholder),this._placeholder=null}}enableFixed(){const e=document.createElement("div"),t=this.getBoundingRect(),n=getComputedStyle(this._slideTabItem),o=this._slideTabItem.querySelector("span");if(this._placeholder=e,this._placeholder.style.width=`${t.width}px`,this._placeholder.style.height=`${t.height}px`,this._placeholder.style.flexShrink="0",this._placeholder.style.margin=n.margin,this._slideTabItem.style.background=n.background,o){const r=getComputedStyle(o).padding;this._slideTabItem.style.padding=r}this._slideTabItem.style.boxSizing=n.boxSizing,this._slideTabItem.style.fontSize=n.fontSize,this._slideTabItem.style.color=n.color,this._slideTabItem.style.borderRadius=n.borderRadius,this._slideTabItem.style.left=`${t.x-this.getScrollbar().getScrollX()}px`,this._slideTabItem.style.top=`${t.y}px`,this._slideTabItem.style.width=`${t.width}px`,this._slideTabItem.style.height=`${t.height}px`,this._slideTabItem.style.boxShadow="0px 0px 1px 1px rgba(82,82,82,0.1)",this._slideTabItem.style.position="fixed",this._slideTabItem.after(e),document.body.appendChild(this._slideTabItem)}addEventListener(e,t,n){this._slideTabItem.addEventListener(e,t,n)}removeEventListener(e,t,n){this._slideTabItem.removeEventListener(e,t,n)}getScrollbar(){return this._scrollbar}getMidLine(){return this._midline}getBoundingRect(){const e=this._slideTabItem.getBoundingClientRect();return e.x+=this._scrollbar.getScrollX(),e}getWidth(){return this.getBoundingRect().width}getTranslateXDirection(){const e=Ke.midline(this);return e>this._midline?1:e<this._midline?-1:0}equals(e){return e&&e._slideTabItem===this._slideTabItem}getId(){return this._slideTabItem.dataset.id||""}}class kd{constructor(e){C(this,"_slideTabBar");C(this,"_scrollX");const t=e.primeval();this._scrollX=t.scrollLeft,this._slideTabBar=e}scrollX(e){const t=this._slideTabBar.primeval();t.scrollLeft=e,this._scrollX=t.scrollLeft}scrollRight(){const e=this._slideTabBar.primeval();e.scrollLeft=e.scrollWidth,this._scrollX=e.scrollLeft}getScrollX(){return this._scrollX}}const mt=class mt{constructor(e){C(this,"_activeTabItemIndex",0);C(this,"_slideTabBar");C(this,"_slideTabItems",[]);C(this,"_config");C(this,"_downActionX",0);C(this,"_moveActionX",0);C(this,"_compareIndex",0);C(this,"_activeTabItem",null);C(this,"_moveAction");C(this,"_upAction");C(this,"_downAction");C(this,"_wheelAction");C(this,"_scrollIncremental",0);C(this,"_compareDirection",0);C(this,"_autoScrollTime",null);C(this,"_slideScrollbar");C(this,"_longPressTimer",null);C(this,"_leftBoundingLine",0);C(this,"_rightBoundingLine",0);C(this,"_leftMoveX",0);C(this,"_rightMoveX",0);if(e.slideTabBarContainer==null)throw new Error("not found slide-tab-bar root element");const t=e.slideTabBarContainer.querySelector(`.${e.slideTabBarClassName??"slide-tab-bar"}`);if(t==null)throw new Error("not found slide-tab-bar");this._slideTabBar=t,this._slideScrollbar=new kd(this),this._config=e,this._initConfig();let n=0,o=0,r=0;this._downAction=s=>{var E,O,y,x,A;const a=(O=(E=s.target)==null?void 0:E.closest(`.${e.slideTabBarItemClassName}`))==null?void 0:O.getAttribute("data-id"),c=this._slideTabItems.findIndex(H=>H.getId()===a);if(a==null||c===-1)return;if(this._activeTabItemIndex!==c){(y=this._activeTabItem)==null||y.removeEventListener("pointermove",this._moveAction),(x=this._activeTabItem)==null||x.removeEventListener("pointerup",this._upAction),this.removeListener(),this._config.onChangeTab(s,a);return}if(this._compareIndex=c,this._downActionX=s.pageX,this._moveActionX=0,this._scrollIncremental=0,this._activeTabItem=this._slideTabItems[c],!this._activeTabItem){console.error("Not found active slide-tab-item in sheet bar");return}const d=this._activeTabItem.getSlideTabItem();d==null||d.setPointerCapture(s.pointerId),(A=this._activeTabItem)==null||A.addEventListener("pointerup",this._upAction);const{x:u,width:h}=this._activeTabItem.getBoundingRect(),{x:m,width:_}=this.getBoundingRect(),g=this._slideScrollbar.getScrollX();if(this._leftBoundingLine=this._downActionX-(u-g),this._rightBoundingLine=u-g+h-this._downActionX,this._leftMoveX=u-m-g,this._rightMoveX=m+_-(u+h)+g,s.button===2||this._hasEditItem())return;const{pageX:S,pageY:v}=s,I=Date.now(),b=I-r<=mt.DoubleClickDelay,R=Math.abs(S-n)<10,T=Math.abs(v-o)<10;b&&R&&T&&this._activeTabItem.editor(),n=S,o=v,r=I,this._longPressTimer=setTimeout(()=>{var H,D;(H=this._activeTabItem)==null||H.enableFixed(),this._startAutoScroll(),d&&(d.setPointerCapture(s.pointerId),d.style.cursor="move",(D=this._activeTabItem)==null||D.addEventListener("pointermove",this._moveAction))},mt.LongPressDelay)},this._upAction=s=>{var c,d,u;if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),!this._activeTabItem)return;this._closeAutoScroll(),this._activeTabItem.disableFixed(),this.updateItems();const a=(c=this._activeTabItem)==null?void 0:c.getSlideTabItem();a&&(a.style.cursor="",a.releasePointerCapture(s.pointerId),(d=this._activeTabItem)==null||d.removeEventListener("pointermove",this._moveAction),(u=this._activeTabItem)==null||u.removeEventListener("pointerup",this._upAction),this._config.onSlideEnd&&this._activeTabItemIndex!==this._compareIndex&&(this.removeListener(),this._config.onSlideEnd(s,this._compareIndex||0)),this._scrollIncremental=0,this._downActionX=0,this._moveActionX=0,this._compareIndex=0)},this._moveAction=s=>{this._activeTabItem&&(this._moveActionX=s.pageX-this._downActionX,this._moveActionX<=-this._leftMoveX?this._moveActionX=-this._leftMoveX:this._moveActionX>=this._rightMoveX&&(this._moveActionX=this._rightMoveX),this._scrollIncremental=0,this._scrollLeft(s),this._scrollRight(s))},this._wheelAction=s=>{this.setScroll(s.deltaY)},this.addListener()}static checkedSkipSlide(e){let t=e.target;for(;t!=null&&t!==document.body;){if(t.getAttribute("data-slide-skip"))return!0;t=t.parentElement}return!1}static keepLastIndex(e){setTimeout(()=>{const t=window.getSelection();t&&(t.selectAllChildren(e),t.collapseToEnd())})}static keepSelectAll(e){setTimeout(()=>{const t=window.getSelection();if(!t)return;const n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)})}update(e){this._config.currentIndex=e,this._initConfig(),this.removeListener(),this.addListener()}primeval(){return this._slideTabBar}updateItems(){for(let e=0;e<this._slideTabItems.length;e++)this._slideTabItems[e].animate().cancel(),this._slideTabItems[e].translateX(0),this._slideTabItems[e].update()}getScrollbar(){return this._slideScrollbar}getConfig(){return this._config}getBoundingRect(){return this._slideTabBar.getBoundingClientRect()}getSlideTabItems(){return this._slideTabItems}getActiveItem(){return this._activeTabItem}isLeftEnd(){return this._slideTabBar.scrollLeft===0}isRightEnd(){const e=this._slideTabBar.parentElement;return e?this._slideTabBar.scrollWidth-e.clientWidth===this._slideTabBar.scrollLeft:!1}addListener(){this._slideTabBar.addEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.addEventListener("pointerdown",this._downAction)})}removeListener(){this._slideTabBar.removeEventListener("wheel",this._wheelAction),this._slideTabItems.forEach(e=>{e.removeEventListener("pointerdown",this._downAction)})}setScroll(e){if(this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+e),e>0){const t=this.calculateLeftScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX();this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}flipPage(e){if(e>0){const t=this.calculateLeftScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}else if(e<0){const t=this.calculateRightScrollX(!0);this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+t)}this._config.onScroll({leftEnd:this.isLeftEnd(),rightEnd:this.isRightEnd()})}calculateLeftScrollX(e){let t=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left+r.width,a=o.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c<s&&c+d+n*2>s?(t=e?c-r.left-n:c+d-s+n,!0):!1}),t}calculateRightScrollX(e){let t=0;const n=4;return this._slideTabItems.some(o=>{const r=this._slideTabBar.getBoundingClientRect(),s=r.left,a=o.getSlideTabItem().getBoundingClientRect(),c=a.left,d=a.width;return c-n*2<s&&c+d>s?(t=e?c+d-r.left-r.width+n:c-s-n,!0):!1}),t}destroy(){this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=[],this._activeTabItem=null,this.removeListener()}_hasEditItem(){for(let e=0;e<this._slideTabItems.length;e++)if(this._slideTabItems[e].isEditMode())return!0;return!1}_autoScrollFrame(){if(this._activeTabItem)switch(this._compareDirection=this._activeTabItem.translateX(this._moveActionX),this._compareDirection){case 1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareRight();break}case 0:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareIndex=this._activeTabItemIndex;break}case-1:{this._slideScrollbar.scrollX(this._slideScrollbar.getScrollX()+this._scrollIncremental),this._compareLeft();break}}this._autoScrollTime=requestAnimationFrame(()=>{this._autoScrollFrame()})}_startAutoScroll(){this._autoScrollTime==null&&this._autoScrollFrame()}_closeAutoScroll(){this._autoScrollTime&&cancelAnimationFrame(this._autoScrollTime),this._autoScrollTime=null}_scrollLeft(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n<this._leftBoundingLine&&(this._scrollIncremental=-Math.min(Math.abs(n-this._leftBoundingLine)*.1,50))}_scrollRight(e){const t=this.getBoundingRect(),n=e.pageX-t.x;n>t.width-this._rightBoundingLine&&(this._scrollIncremental=Math.min(Math.abs(n-(t.width-this._rightBoundingLine))*.1,50))}_sortedItems(){if(this._activeTabItem!=null&&this._activeTabItemIndex!=null&&this._compareIndex!=null&&(this._slideTabItems.splice(this._activeTabItemIndex,1),this._slideTabItems.splice(this._compareIndex,0,this._activeTabItem),this._config.slideTabBarItemAutoSort))for(let e=0;e<this._slideTabItems.length;e++){const t=this._slideTabItems[e],n=this._slideTabItems[e+1];n&&t.after(n)}}_compareLeft(){if(this._activeTabItem&&this._activeTabItemIndex){const e=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let r=0;r<e&&!(r>=e);r++)n.push(this._slideTabItems[r]);for(let r=e+1;r<t;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=n.length-1;r>=0;r--){const s=n[r];Ke.leftLine(this._activeTabItem)<s.getMidLine()?(s.animate().translateX(this._activeTabItem.getWidth()),this._compareIndex=r,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_compareRight(){if(this._activeTabItem){const e=this._slideTabItems.findIndex(r=>r.equals(this._activeTabItem)),t=this._slideTabItems.length,n=[];for(let r=e+1;r<t;r++)n.push(this._slideTabItems[r]);for(let r=0;r<e;r++)this._slideTabItems[r].animate().translateX(0);let o=!0;for(let r=0;r<n.length;r++){const s=n[r];Ke.rightLine(this._activeTabItem)>s.getMidLine()?(s.animate().translateX(-this._activeTabItem.getWidth()),this._compareIndex=e+r+1,o=!1):(s.animate().translateX(0),o&&(this._compareIndex=this._activeTabItemIndex))}}}_initConfig(){const e=this._slideTabBar.querySelectorAll(`.${this._config.slideTabBarItemClassName??"slide-tab-item"}`);this._downActionX=0,this._moveActionX=0,this._compareDirection=0,this._compareIndex=0,this._slideTabItems=Ke.make(e,this),this._activeTabItemIndex=this._config.currentIndex,this._activeTabItem=this._slideTabItems[this._activeTabItemIndex]}};C(mt,"LongPressDelay",500),C(mt,"DoubleClickDelay",300);let Ht=mt;function Bd(){const[i,e]=k.useState([]),[t,n]=k.useState(""),[o,r]=k.useState(""),s=k.useRef({slideTabBar:null}),a=k.useRef(null),c=F.useDependency(l.IUniverInstanceService),d=F.useDependency(l.ICommandService),u=F.useDependency(dt),h=F.useDependency(l.LocaleService),m=F.useDependency(M.IConfirmService),_=c.getCurrentUniverSheetInstance();k.useEffect(()=>{I();const A=g(),H=v(),D=[b(),R(),T(),E()];return()=>{H.dispose(),A.destroy(),D.forEach(N=>N.unsubscribe())}},[]),k.useEffect(()=>{i.length>0&&S()},[i]);const g=()=>{const A=new Ht({slideTabBarClassName:fe.slideTabBar,slideTabBarItemActiveClassName:fe.slideTabActive,slideTabBarItemClassName:fe.slideTabItem,slideTabBarSpanEditClassName:fe.slideTabSpanEdit,slideTabBarItemAutoSort:!0,slideTabBarContainer:a.current,currentIndex:0,onChangeName:(H,D)=>{d.executeCommand(f.SetWorksheetNameCommand.id,{subUnitId:H,name:D})},onSlideEnd:(H,D)=>{d.executeCommand(f.SetWorksheetOrderCommand.id,{order:D})},onChangeTab:(H,D)=>{d.executeCommand(f.SetWorksheetActivateCommand.id,{subUnitId:D})},onScroll:H=>{u.setScroll(H)},onEmptyAlert:()=>{const H="slideTabBarAlert";m.open({id:H,children:{title:h.t("sheetConfig.sheetNameCannotIsEmptyError")},title:{title:"There was a problem"},onClose(){m.close(H)},onConfirm(){m.close(H)}})}});return s.current.slideTabBar=A,x(A),A},S=()=>{var H;const A=i.findIndex(D=>D.selected);(H=s.current.slideTabBar)==null||H.update(A)},v=()=>d.onCommandExecuted(A=>{switch(A.id){case f.SetTabColorMutation.id:case f.SetWorksheetHideMutation.id:case f.RemoveSheetMutation.id:case f.SetWorksheetNameMutation.id:case f.InsertSheetMutation.id:case f.SetWorksheetOrderMutation.id:case f.SetWorksheetActiveOperation.id:I();break}}),I=()=>{const A=_.getActiveSheet().getSheetId();n(A);const D=_.getSheets().filter(N=>!N.isSheetHidden()).map((N,U)=>({sheetId:N.getSheetId(),label:N.getName(),index:U,selected:N.getStatus()===l.BooleanNumber.TRUE,color:N.getTabColor()??void 0}));e(D)},b=()=>u.scroll$.subscribe(A=>{O(A)}),R=()=>u.scrollX$.subscribe(A=>{var H;(H=s.current.slideTabBar)==null||H.flipPage(A)}),T=()=>u.renameId$.subscribe(()=>{var A,H;(H=(A=s.current.slideTabBar)==null?void 0:A.getActiveItem())==null||H.editor()}),E=()=>u.addSheet$.subscribe(()=>{var A;(A=s.current.slideTabBar)==null||A.getScrollbar().scrollRight()}),O=A=>{const{leftEnd:H,rightEnd:D}=A;let N="";H&&D?N="":H&&!D?N="inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&D?N="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2)":!H&&!D&&(N="inset 10px 0px 10px -10px rgba(0, 0, 0, 0.2), inset -10px 0px 10px -10px rgba(0, 0, 0, 0.2)"),r(N)},y=A=>{u.setScroll({leftEnd:A.isLeftEnd(),rightEnd:A.isRightEnd()})},x=A=>{var N;const H=(N=a.current)==null?void 0:N.querySelector(`.${fe.slideTabBar}`);if(!H)return;new ResizeObserver(()=>{y(A)}).observe(H)};return p.jsx("div",{className:fe.slideTabBarContainer,ref:a,children:p.jsx("div",{className:fe.slideTabBar,style:{boxShadow:o},children:i.map(A=>k.createElement(Hd,{...A,key:A.sheetId,selected:t===A.sheetId}))})})}const Sr=100,Vd=()=>{const[i,e]=k.useState(!0),[t,n]=k.useState(!0),o=F.useDependency(l.ICommandService),r=F.useDependency(dt);k.useEffect(()=>{const u=r.scroll$.subscribe(h=>{s(h)});return()=>{u.unsubscribe()}},[]);const s=u=>{const{leftEnd:h,rightEnd:m}=u;e(h),n(m)},a=()=>{o.executeCommand(f.InsertSheetCommand.id),setTimeout(()=>{r.setAddSheet(0)},0)},c=()=>{r.setScrollX(-Sr)},d=()=>{r.setScrollX(Sr)};return p.jsxs("div",{className:En.sheetBar,children:[p.jsxs("div",{className:En.sheetBarOptions,children:[p.jsx(On,{onClick:a,children:p.jsx(Xs,{})}),p.jsx(Dd,{})]}),p.jsx(Bd,{}),(!i||!t)&&p.jsxs("div",{className:`${En.sheetBarOptions} ${En.sheetBarOptionsDivider}`,children:[p.jsx(On,{disabled:i,onClick:c,children:p.jsx(Zn,{style:{transform:"rotateZ(180deg)"}})}),p.jsx(On,{disabled:t,onClick:d,children:p.jsx(Zn,{})})]})]})};class Fd{constructor(){C(this,"_functions",[{func:Z.FUNCTION_NAMES_MATH.SUM,filter:e=>{var t,n;return(((t=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.MAX,filter:e=>{var t,n;return(((t=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.MIN,filter:e=>{var t,n;return(((t=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.AVERAGE,filter:e=>{var t,n;return(((t=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.COUNT,filter:e=>{var t,n;return(((t=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:t.value)??0)>1&&(((n=e.find(o=>o.func===Z.FUNCTION_NAMES_STATISTICAL.COUNT))==null?void 0:n.value)??0)>0}},{func:Z.FUNCTION_NAMES_STATISTICAL.COUNTA,filter:e=>{var t;return(((t=e.find(n=>n.func===Z.FUNCTION_NAMES_STATISTICAL.COUNTA))==null?void 0:t.value)??0)>1}}]);C(this,"_state$",new B.BehaviorSubject(null));C(this,"state$",this._state$.asObservable())}dispose(){this._state$.complete()}setState(e){const t=[];e==null||e.forEach(n=>{const o=this._functions.find(r=>r.func===n.func);o&&(o.filter===void 0||o.filter(e))&&t.push(n)}),this._state$.next(t)}getState(){return this._state$.getValue()}getFunctions(){return this._functions}addFunctions(e){this._functions.push(...e)}}const Ci=L.createIdentifier("univer.sheet-status-bar.service"),pe={statusBar:"univer-status-bar",singleMode:"univer-single-mode",statusBarDiv:"univer-status-bar-div",statisticList:"univer-statistic-list",statisticListTwoRow:"univer-statistic-list-two-row",statisticListRow:"univer-statistic-list-row",statisticItem:"univer-statistic-item",statisticPicker:"univer-statistic-picker",statisticPickerItem:"univer-statistic-picker-item",statisticMore:"univer-statistic-more"},ut={[Z.FUNCTION_NAMES_MATH.SUM]:"statusbar.sum",[Z.FUNCTION_NAMES_STATISTICAL.AVERAGE]:"statusbar.average",[Z.FUNCTION_NAMES_STATISTICAL.MIN]:"statusbar.min",[Z.FUNCTION_NAMES_STATISTICAL.MAX]:"statusbar.max",[Z.FUNCTION_NAMES_STATISTICAL.COUNT]:"statusbar.count",[Z.FUNCTION_NAMES_STATISTICAL.COUNTA]:"statusbar.countA",[Z.FUNCTION_NAMES_COMPATIBILITY.CONCATENATE]:"concatenate"},Ii=i=>{const e=F.useDependency(l.LocaleService),t=F.useDependency(M.IMessageService),n=F.useDependency(M.IClipboardInterfaceService),o=gr(i.value),r=async()=>{await n.writeText(i.value.toString()),t.show({type:ne.MessageType.Success,content:e.t("statusbar.copied")})};return p.jsx(ne.Tooltip,{title:e.t("statusbar.clickToCopy"),placement:"top",children:p.jsx("div",{className:pe.statisticItem,onClick:r,children:p.jsx("span",{children:`${e.t((ut==null?void 0:ut[i.name])||i.name)}: ${o}`})},i.name)})};function gr(i){return typeof i!="number"?"Invalid input":i>=1e8?i.toExponential(2):i.toLocaleString()}const fr=800,Wd=()=>{const[i,e]=k.useState(window.innerWidth<fr),[t,n]=k.useState(!0),o=F.useDependency(l.LocaleService),r=F.useDependency(Ci),s=r.getFunctions().map((_,g)=>({name:_.func,value:0,show:i?g<1:g<3,disable:!1})),[a,c]=k.useState(s),d=a.filter(_=>!_.disable),u=a.filter(_=>_.show&&!_.disable),h=_=>{const g=a.map(S=>(S.name===_.name?S.show=!S.show:i&&(S.show=!1),S));c(g)};k.useEffect(()=>{const _=r.state$.subscribe(g=>{if(!g||g.length===0)n(!1);else{n(!0);const S=a.map(v=>{const I=g.find(b=>b.func===v.name);return I?(v.value=I.value,v.disable=!1):v.disable=!0,v});c(S)}});return()=>{_.unsubscribe()}},[r]);const m=()=>{const _=window.innerWidth<fr;if(i!==_){if(_){const g=a.findIndex(v=>v.show),S=a.map((v,I)=>(I===g?v.show=!0:v.show=!1,v));c(S)}e(_)}};return k.useEffect(()=>(window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}),[]),t&&p.jsxs("div",{className:St(pe.statusBar,{[pe.singleMode]:i}),children:[p.jsx("div",{className:St(pe.statisticList,{[pe.statisticListTwoRow]:u.length>3}),children:u.length>3?p.jsxs(p.Fragment,{children:[p.jsx("div",{className:pe.statisticListRow,children:u.slice(0,3).map(_=>p.jsx(Ii,{..._},_.name))}),p.jsx("div",{className:pe.statisticListRow,children:u.slice(3).map(_=>p.jsx(Ii,{..._},_.name))})]}):u.map(_=>p.jsx(Ii,{..._},_.name))}),p.jsx(ne.Dropdown,{placement:"topRight",overlay:p.jsx("div",{className:pe.statisticPicker,children:d==null?void 0:d.map(_=>p.jsxs("a",{className:pe.statisticPickerItem,children:[p.jsx(ne.Checkbox,{value:_.name,checked:_.show,onChange:()=>h&&h(_)}),p.jsx("span",{children:`${o.t((ut==null?void 0:ut[_.name])||_.name)}: ${gr(_.value)}`})]},_.name))}),children:p.jsx("div",{className:pe.statisticMore,children:p.jsx(Zn,{})})}),p.jsx("div",{className:pe.statusBarDiv})]})};function jd(){return p.jsxs("section",{className:$o.sheetContainer,"data-range-selector":!0,children:[p.jsx(Vd,{}),p.jsx(Wd,{}),p.jsx(Td,{})]})}function zd(){return p.jsx(p.Fragment,{children:p.jsx(Od,{})})}function Xd(){return p.jsxs(p.Fragment,{children:[p.jsx(Ed,{}),p.jsx(Ad,{})]})}function Yd(i){const e=i.get(f.BorderStyleManagerService);return{id:f.SetBorderBasicCommand.id,icon:new B.Observable(t=>{const n="AllBorderSingle",o=i.get(f.BorderStyleManagerService),r=i.get(l.ICommandService).onCommandExecuted(s=>{if(s.id!==f.SetBorderBasicCommand.id)return;const{type:c}=o.getBorderInfo(),d=hr.find(h=>h.value===c),u=(d==null?void 0:d.icon)??n;t.next(u)});return t.next(n),r.dispose}),group:M.MenuGroup.TOOLBAR_FORMAT,tooltip:"toolbar.border.main",positions:[M.MenuPosition.TOOLBAR_START],type:M.MenuItemType.BUTTON_SELECTOR,selections:[{label:{name:ur,hoverable:!1},value$:e.borderInfo$}],value$:e.borderInfo$}}const yn="sheet.menu.clear-selection";function $d(){return{id:yn,group:M.MenuGroup.CONTEXT_MENU_FORMAT,type:M.MenuItemType.SUBITEMS,icon:"ClearFormat",title:"rightClick.clearSelection",positions:[M.MenuPosition.CONTEXT_MENU,ee.COL_HEADER_CONTEXT_MENU,ee.ROW_HEADER_CONTEXT_MENU]}}function Zd(){return{id:f.ClearSelectionContentCommand.id,type:M.MenuItemType.BUTTON,title:"rightClick.clearContent",positions:[yn]}}function Gd(){return{id:f.ClearSelectionFormatCommand.id,type:M.MenuItemType.BUTTON,title:"rightClick.clearFormat",positions:[yn]}}function Kd(){return{id:f.ClearSelectionAllCommand.id,type:M.MenuItemType.BUTTON,title:"rightClick.clearAll",positions:[yn]}}const Nt="sheet.menu.delete";function Jd(){return{id:Nt,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.SUBITEMS,title:"rightClick.delete",icon:"Reduce",positions:[M.MenuPosition.CONTEXT_MENU]}}function Qd(){return{id:f.RemoveColCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,icon:"DeleteColumn",positions:[Nt,ee.COL_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedColumn"}}function qd(){return{id:f.RemoveRowCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,icon:"DeleteRow",positions:[Nt,ee.ROW_HEADER_CONTEXT_MENU],title:"rightClick.deleteSelectedRow"}}function eu(){return{id:f.DeleteRangeMoveLeftCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,title:"rightClick.moveLeft",icon:"DeleteCellShiftLeft",positions:[Nt]}}function tu(){return{id:f.DeleteRangeMoveUpCommand.id,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.BUTTON,title:"rightClick.moveUp",icon:"DeleteCellShiftUp",positions:[Nt]}}const Mi="sheet.menu.col-insert";function nu(){return{id:Mi,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[ee.COL_HEADER_CONTEXT_MENU]}}const bi="sheet.menu.row-insert";function iu(){return{id:bi,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[ee.ROW_HEADER_CONTEXT_MENU]}}const Lt="sheet.menu.cell-insert";function ou(){return{id:Lt,group:M.MenuGroup.CONTEXT_MENU_LAYOUT,type:M.MenuItemType.SUBITEMS,title:"rightClick.insert",icon:"Insert",positions:[M.MenuPosition.CONTEXT_MENU]}}function ru(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertRowBeforeCommand.id,type:M.MenuItemType.BUTTON,title:"rightClick.insertRowBefore",icon:"InsertRowAbove",positions:[bi,Lt],hidden$:new B.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function su(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertRowAfterCommand.id,type:M.MenuItemType.BUTTON,positions:[bi],title:"rightClick.insertRow",icon:"InsertRowBelow",hidden$:new B.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function au(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertColBeforeCommand.id,type:M.MenuItemType.BUTTON,positions:[Mi,Lt],title:"rightClick.insertColumnBefore",icon:"LeftInsertColumn",hidden$:new B.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function lu(i){const e=i.get(f.SelectionManagerService);return{id:f.InsertColAfterCommand.id,type:M.MenuItemType.BUTTON,positions:[Mi],title:"rightClick.insertColumn",icon:"RightInsertColumn",hidden$:new B.Observable(t=>{const n=e.getSelections();t.next((n==null?void 0:n.length)!==1)})}}function cu(){return{id:f.InsertRangeMoveRightCommand.id,type:M.MenuItemType.BUTTON,title:"rightClick.moveRight",icon:"InsertCellShiftRight",positions:[Lt]}}function du(){return{id:f.InsertRangeMoveDownCommand.id,type:M.MenuItemType.BUTTON,title:"rightClick.moveDown",icon:"InsertCellDown",positions:[Lt]}}function uu(i){return{id:xe.id,icon:"MergeAllSingle",tooltip:"toolbar.mergeCell.main",positions:[M.MenuPosition.TOOLBAR_START],group:M.MenuGroup.TOOLBAR_LAYOUT,type:M.MenuItemType.SUBITEMS}}function hu(i){return{id:ir.id,type:M.MenuItemType.BUTTON,title:"merge.all",icon:"MergeAllSingle",positions:[xe.id]}}function mu(i){return{id:or.id,type:M.MenuItemType.BUTTON,title:"merge.vertical",icon:"VerticalIntegrationSingle",positions:[xe.id]}}function _u(i){return{id:rr.id,type:M.MenuItemType.BUTTON,title:"merge.horizontal",icon:"HorizontalMergeSingle",positions:[xe.id]}}function Su(i){return{id:f.RemoveWorksheetMergeCommand.id,type:M.MenuItemType.BUTTON,title:"merge.cancel",icon:"CancelMergeSingle",positions:[xe.id]}}function gu(){return{id:f.RemoveSheetCommand.id,type:M.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.delete"}}function fu(){return{id:f.CopySheetCommand.id,type:M.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.copy"}}function pu(){return{id:ar.id,type:M.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.rename"}}function vu(){return{id:f.SetTabColorCommand.id,title:"sheetConfig.changeColor",positions:[ee.SHEET_BAR],type:M.MenuItemType.SELECTOR,selections:[{label:{name:Qt,hoverable:!1}}]}}function Cu(){return{id:f.SetWorksheetHideCommand.id,type:M.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.hide"}}function Iu(){return{id:lr.id,type:M.MenuItemType.BUTTON,positions:[ee.SHEET_BAR],title:"sheetConfig.unhide"}}const Mu={id:f.SetRowHiddenCommand.id,preconditions:i=>Y(i),binding:M.KeyCode.Digit9|M.MetaKeys.CTRL_COMMAND},bu={id:f.SetColHiddenCommand.id,preconditions:i=>Y(i),binding:M.KeyCode.Digit0|M.MetaKeys.CTRL_COMMAND|M.MetaKeys.SHIFT},Ru={id:me.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_DOWN,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.DOWN}},wu={id:me.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_UP,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.UP}},Tu={id:me.id,description:"shortcut.sheet.select-left-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_LEFT,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.LEFT}},Eu={id:me.id,description:"shortcut.sheet.select-right-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_RIGHT,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.RIGHT}},Ou={id:je.id,description:"shortcut.sheet.select-next-cell",group:"3_sheet-view",binding:M.KeyCode.TAB,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.RIGHT,keycode:M.KeyCode.TAB}},yu={id:je.id,description:"shortcut.sheet.select-previous-cell",group:"3_sheet-view",binding:M.KeyCode.TAB|M.MetaKeys.SHIFT,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.LEFT,keycode:M.KeyCode.TAB}},xu={id:je.id,description:"shortcut.sheet.select-below-cell",group:"3_sheet-view",binding:M.KeyCode.ENTER,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.DOWN,keycode:M.KeyCode.ENTER}},Au={id:je.id,description:"shortcut.sheet.select-up-cell",group:"3_sheet-view",binding:M.KeyCode.ENTER|M.MetaKeys.SHIFT,priority:100,preconditions:Y,staticParameters:{direction:l.Direction.UP,keycode:M.KeyCode.ENTER}},Pu={id:me.id,description:"shortcut.sheet.select-below-value-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_DOWN|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.DOWN,jumpOver:Me.moveGap}},Du={id:me.id,description:"shortcut.sheet.select-up-value-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_UP|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.UP,jumpOver:Me.moveGap}},Hu={id:me.id,description:"shortcut.sheet.select-left-value-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_LEFT|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.LEFT,jumpOver:Me.moveGap}},Nu={id:me.id,description:"shortcut.sheet.select-right-value-cell",group:"3_sheet-view",binding:M.KeyCode.ARROW_RIGHT|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.RIGHT,jumpOver:Me.moveGap}},Lu={id:be.id,description:"shortcut.sheet.expand-selection-down",group:"3_sheet-view",binding:M.KeyCode.ARROW_DOWN|M.MetaKeys.SHIFT,preconditions:Y,staticParameters:{direction:l.Direction.DOWN}},Uu={id:be.id,description:"shortcut.sheet.expand-selection-up",group:"3_sheet-view",binding:M.KeyCode.ARROW_UP|M.MetaKeys.SHIFT,preconditions:Y,staticParameters:{direction:l.Direction.UP}},ku={id:be.id,description:"shortcut.sheet.expand-selection-left",group:"3_sheet-view",binding:M.KeyCode.ARROW_LEFT|M.MetaKeys.SHIFT,preconditions:Y,staticParameters:{direction:l.Direction.LEFT}},Bu={id:be.id,description:"shortcut.sheet.expand-selection-right",group:"3_sheet-view",binding:M.KeyCode.ARROW_RIGHT|M.MetaKeys.SHIFT,preconditions:Y,staticParameters:{direction:l.Direction.RIGHT}},Vu={id:be.id,description:"shortcut.sheet.expand-selection-to-below-gap",group:"3_sheet-view",binding:M.KeyCode.ARROW_DOWN|M.MetaKeys.SHIFT|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.DOWN,jumpOver:Me.moveGap}},Fu={id:be.id,description:"shortcut.sheet.expand-selection-to-up-gap",group:"3_sheet-view",binding:M.KeyCode.ARROW_UP|M.MetaKeys.SHIFT|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.UP,jumpOver:Me.moveGap}},Wu={id:be.id,description:"shortcut.sheet.expand-selection-to-left-gap",group:"3_sheet-view",binding:M.KeyCode.ARROW_LEFT|M.MetaKeys.SHIFT|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.LEFT,jumpOver:Me.moveGap}},ju={id:be.id,description:"shortcut.sheet.expand-selection-to-right-gap",group:"3_sheet-view",binding:M.KeyCode.ARROW_RIGHT|M.MetaKeys.SHIFT|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{direction:l.Direction.RIGHT,jumpOver:Me.moveGap}},zu={id:$i.id,description:"shortcut.sheet.select-all",group:"3_sheet-view",binding:M.KeyCode.A|M.MetaKeys.CTRL_COMMAND,preconditions:Y,staticParameters:{expandToGapFirst:!0,loop:!0}},Xu={id:Qn.id,description:"shortcut.sheet.set-bold",group:"4_sheet-edit",preconditions:i=>Y(i),binding:M.KeyCode.B|M.MetaKeys.CTRL_COMMAND},Yu={id:qn.id,description:"shortcut.sheet.set-italic",group:"4_sheet-edit",preconditions:i=>Y(i),binding:M.KeyCode.I|M.MetaKeys.CTRL_COMMAND},$u={id:ei.id,description:"shortcut.sheet.set-underline",group:"4_sheet-edit",preconditions:i=>Y(i),binding:M.KeyCode.U|M.MetaKeys.CTRL_COMMAND},Zu={id:ti.id,description:"shortcut.sheet.set-strike-through",group:"4_sheet-edit",preconditions:i=>Y(i),binding:M.KeyCode.X|M.MetaKeys.SHIFT|M.MetaKeys.CTRL_COMMAND},Gu={id:f.ClearSelectionContentCommand.id,preconditions:i=>Y(i),binding:M.KeyCode.DELETE,mac:M.KeyCode.BACKSPACE},Ku={id:wn.id,description:"shortcut.sheet.zoom-in",binding:M.KeyCode.EQUAL|M.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:.2}},Ju={id:wn.id,description:"shortcut.sheet.zoom-out",binding:M.KeyCode.MINUS|M.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{delta:-.2}},Qu={id:wn.id,description:"shortcut.sheet.reset-zoom",binding:M.KeyCode.Digit0|M.MetaKeys.CTRL_COMMAND,group:"3_sheet-view",staticParameters:{reset:!0}};var qu=Object.defineProperty,eh=Object.getOwnPropertyDescriptor,th=(i,e,t,n)=>{for(var o=n>1?void 0:n?eh(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&qu(e,t,o),o},ht=(i,e)=>(t,n)=>e(t,n,i);let xn=class extends l.Disposable{constructor(i,e,t,n,o,r){super(),this._injector=i,this._componentManager=e,this._commandService=t,this._shortcutService=n,this._menuService=o,this._uiController=r,this._init()}_initCustomComponents(){const i=this._componentManager;this.disposeWithMe(i.register(si,Da)),this.disposeWithMe(i.register(ur,Md)),this.disposeWithMe(i.register(Qt,ne.ColorPicker)),this.disposeWithMe(i.register(Po,xa)),this.disposeWithMe(i.register(ae,Aa)),this.disposeWithMe(i.register(Ho,Pa))}_initCommands(){[ir,xe,rr,or,wn,be,me,je,ar,$e,$i,Ko,Xt,f.SetBoldCommand,gt,Ie,Qn,qn,ei,ti,Co,Io,Mo,bo,Kt,f.SetItalicCommand,f.SetStrikeThroughCommand,f.SetFontFamilyCommand,f.SetFontSizeCommand,oi,To,ri,Eo,tt,mn,Jt,Oo,yo,xo,f.SetSelectionsOperation,f.SetUnderlineCommand,vi,Ee,lr,sr].forEach(i=>{this.disposeWithMe(this._commandService.registerCommand(i))})}_initMenus(){[Qa,qa,el,tl,nl,il,ol,Zd,Gd,Kd,$d,nu,iu,ou,ru,su,au,lu,qd,hl,_l,ml,Sl,Qd,gl,rl,fl,Jd,eu,tu,cu,du,ll,cl,dl,ul,sl,al,Ha,Na,La,Ua,ka,Ba,Va,Wa,ja,za,Xa,Ya,$a,Yd,uu,hu,mu,_u,Su,Za,Ga,Ka,Ja,gu,fu,pu,vu,Cu,Iu].forEach(i=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(i)))})}_initShortcuts(){[Ru,wu,Tu,Eu,Ou,yu,xu,Au,Pu,Du,Hu,Nu,Lu,Uu,ku,Bu,Vu,Fu,Wu,ju,zu,Ku,Ju,Qu,Xu,Yu,$u,Zu,Gu,...Vl(),Fl,Wl,zl,Xl,Yl,jl,Mu,bu].forEach(i=>{this.disposeWithMe(this._shortcutService.registerShortcut(i))})}_initWorkbenchParts(){this.disposeWithMe(this._uiController.registerHeaderComponent(()=>F.connectInjector(zd,this._injector))),this.disposeWithMe(this._uiController.registerFooterComponent(()=>F.connectInjector(jd,this._injector))),this.disposeWithMe(this._uiController.registerContentComponent(()=>F.connectInjector(Xd,this._injector)))}_init(){this._initCustomComponents(),this._initCommands(),this._initMenus(),this._initShortcuts(),this._initWorkbenchParts()}};xn=th([l.OnLifecycle(l.LifecycleStages.Ready,xn),ht(0,L.Inject(L.Injector)),ht(1,L.Inject(M.ComponentManager)),ht(2,l.ICommandService),ht(3,M.IShortcutService),ht(4,M.IMenuService),ht(5,M.IUIController)],xn);var nh=Object.defineProperty,ih=Object.getOwnPropertyDescriptor,oh=(i,e,t,n)=>{for(var o=n>1?void 0:n?ih(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&nh(e,t,o),o},Ut=(i,e)=>(t,n)=>e(t,n,i);let An=class extends l.Disposable{constructor(i,e,t,n,o){super(),this._univerInstanceService=i,this._selectionManagerService=e,this._functionService=t,this._statusBarService=n,this._formulaDataModel=o,this._init()}_init(){this._registerSelectionListener()}_registerSelectionListener(){this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoving$.subscribe(i=>{i&&this._calculateSelection(i.map(e=>e.range))}))),this.disposeWithMe(l.toDisposable(this._selectionManagerService.selectionMoveEnd$.subscribe(i=>{i&&this._calculateSelection(i.map(e=>e.range))})))}_calculateSelection(i){const e=this._univerInstanceService.getCurrentUniverSheetInstance(),t=e.getUnitId(),n=e.getActiveSheet().getSheetId(),o={},r=this._formulaDataModel.getArrayFormulaCellData();if(this._univerInstanceService.getCurrentUniverSheetInstance().getSheets().forEach(s=>{const a=s.getConfig();o[s.getSheetId()]={cellData:new l.ObjectMatrix(a.cellData),rowCount:a.rowCount,columnCount:a.columnCount}}),i!=null&&i.length){const s=i.map(u=>new Z.RangeReferenceObject(u,n,t));s.forEach(u=>{u.setUnitData({[t]:o}),r&&u.setArrayFormulaCellData(Z.convertUnitDataToRuntime(r))});const c=this._statusBarService.getFunctions().map(u=>{const h=this._functionService.getExecutor(u.func);if(!(!h||!(h==null?void 0:h.calculate(...s)).getValue))return{func:u.func,value:(h==null?void 0:h.calculate(...s)).getValue()}});if(c.every(u=>u===void 0))return;const d=c.filter(u=>u!==void 0);this._statusBarService.setState(d)}else this._statusBarService.setState(null)}_isSingleCell(i){return i.startRow===i.endRow&&i.startColumn===i.endColumn}};An=oh([l.OnLifecycle(l.LifecycleStages.Ready,An),Ut(0,l.IUniverInstanceService),Ut(1,L.Inject(f.SelectionManagerService)),Ut(2,Z.IFunctionService),Ut(3,Ci),Ut(4,L.Inject(Z.FormulaDataModel))],An);var rh=Object.defineProperty,sh=Object.getOwnPropertyDescriptor,ah=(i,e,t,n)=>{for(var o=n>1?void 0:n?sh(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&rh(e,t,o),o},Je=(i,e)=>(t,n)=>e(t,n,i);let Pn=class extends l.Disposable{constructor(i,e,t,n,o,r,s){super(),this._sheetSkeletonManagerService=i,this._currentUniverService=e,this._commandService=t,this._renderManagerService=n,this._selectionRenderService=o,this._selectionManagerService=r,this._scrollManagerService=s,this._initialize()}dispose(){super.dispose()}_initialize(){this._skeletonListener(),this._commandExecutedListener(),this._zoomEventBinding()}_zoomEventBinding(){var e;const i=(e=this._getSheetObject())==null?void 0:e.scene;i!=null&&(i.getViewport(j.VIEW_MAIN),this.disposeWithMe(l.toDisposable(i.onMouseWheelObserver.add((t,n)=>{if(!t.ctrlKey)return;const o=Math.abs(t.deltaX);let r=o<40?.2:o<80?.4:.2;r*=t.deltaY>0?-1:1,i.scaleX<1&&(r/=2);const s=this._currentUniverService.getCurrentUniverSheetInstance(),a=s.getActiveSheet(),c=a.getZoomRatio();let d=+parseFloat(`${c+r}`).toFixed(1);d=d>=4?4:d<=.1?.1:d,this._commandService.executeCommand(vi.id,{zoomRatio:Math.round(d*10)/10,unitId:s.getUnitId(),subUnitId:a.getSheetId()}),t.preventDefault()}))))}_skeletonListener(){this.disposeWithMe(l.toDisposable(this._sheetSkeletonManagerService.currentSkeletonBefore$.subscribe(i=>{if(i==null)return;const n=this._currentUniverService.getCurrentUniverSheetInstance().getActiveSheet().getZoomRatio()||1;this._updateViewZoom(n)})))}_commandExecutedListener(){const i=[Ee.id];this.disposeWithMe(this._commandService.onCommandExecuted(e=>{if(i.includes(e.id)){const t=this._currentUniverService.getCurrentUniverSheetInstance(),n=t.getActiveSheet(),o=e.params,{unitId:r,subUnitId:s}=o;if(!(r===t.getUnitId()&&s===n.getSheetId()))return;const a=n.getConfig().zoomRatio||1;this._updateViewZoom(a)}}))}_updateViewZoom(i){const e=this._getSheetObject();e==null||e.scene.scale(i,i),e==null||e.spreadsheet.makeForceDirty()}_getSheetObject(){return le(this._currentUniverService,this._renderManagerService)}};Pn=ah([l.OnLifecycle(l.LifecycleStages.Rendered,Pn),Je(0,L.Inject(P.SheetSkeletonManagerService)),Je(1,l.IUniverInstanceService),Je(2,l.ICommandService),Je(3,w.IRenderManagerService),Je(4,se),Je(5,L.Inject(f.SelectionManagerService)),Je(6,L.Inject(Le))],Pn);var lh=Object.defineProperty,ch=Object.getOwnPropertyDescriptor,dh=(i,e,t,n)=>{for(var o=n>1?void 0:n?ch(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&lh(e,t,o),o},kt=(i,e)=>(t,n)=>e(t,n,i);P.SheetCanvasView=class extends l.RxDisposable{constructor(t,n,o,r,s){super();C(this,"_scene");C(this,"_currentWorkbook");C(this,"_loadedMap",new Set);C(this,"_isLoadedEditor",!1);C(this,"_fps$",new B.BehaviorSubject(""));C(this,"fps$",this._fps$.asObservable());this._currentUniverService=t,this._commandService=n,this._renderManagerService=o,this._selectionRenderService=r,this._sheetSkeletonManagerService=s,this._currentUniverService.currentSheet$.subscribe(a=>{if(a==null)return;const c=a.getUnitId();this._loadedMap.has(c)||(this._currentWorkbook=a,this._addNewRender(),this._loadedMap.add(c))})}dispose(){this._fps$.complete()}_addNewRender(){const t=this._currentWorkbook,n=t.getUnitId(),o=t.getContainer(),r=t.getParentRenderUnitId();if(o!=null&&r!=null)throw new Error("container or parentRenderUnitId can only exist one");const s=o==null&&r!=null;s?this._renderManagerService.createRenderWithParent(n,r):this._renderManagerService.createRender(n);const a=this._renderManagerService.getRenderById(n);if(a==null)return;const{scene:c,engine:d}=a;c.openTransformer(),this._scene=c,c.addLayer(new w.Layer(c,[],0),new w.Layer(c,[],2)),a!=null&&this._addComponent(a),t.getShouldRenderLoopImmediately()&&!s&&d.runRenderLoop(()=>{c.render(),this._fps$.next(Math.round(d.getFps()).toString())}),this._renderManagerService.setCurrent(n)}_addComponent(t){const n=this._scene,o=this._currentWorkbook,r=o.getActiveSheet(),s=o.getUnitId(),a=r.getSheetId();this._addViewport(r);const c=new w.Spreadsheet(re.MAIN),d=new w.SpreadsheetRowHeader(re.ROW),u=new w.SpreadsheetColumnHeader(re.COLUMN),h=new w.Rect(re.LEFT_TOP,{zIndex:2,left:-1,top:-1,fill:"rgb(248, 249, 250)",stroke:"rgb(217, 217, 217)",strokeWidth:1});t.mainComponent=c,t.components.set(re.MAIN,c),t.components.set(re.ROW,d),t.components.set(re.COLUMN,u),t.components.set(re.LEFT_TOP,h),n.addObjects([c],Zi),n.addObjects([d,u,h],Ue),n.enableLayerCache(Zi,Ue),this._sheetSkeletonManagerService.setCurrent({sheetId:a,unitId:s})}_addViewport(t){const n=this._scene;if(n==null)return;const{rowHeader:o,columnHeader:r}=t.getConfig(),s=new w.Viewport(j.VIEW_MAIN,n,{left:o.width,top:r.height,bottom:0,right:0,isWheelPreventDefaultX:!0}),a=new w.Viewport(j.VIEW_ROW_TOP,n,{active:!1,isWheelPreventDefaultX:!0}),c=new w.Viewport(j.VIEW_ROW_BOTTOM,n,{left:0,top:r.height,bottom:0,width:o.width,isWheelPreventDefaultX:!0}),d=new w.Viewport(j.VIEW_COLUMN_LEFT,n,{active:!1,isWheelPreventDefaultX:!0}),u=new w.Viewport(j.VIEW_COLUMN_RIGHT,n,{left:o.width,top:0,height:r.height,right:0,isWheelPreventDefaultX:!0}),h=new w.Viewport(j.VIEW_LEFT_TOP,n,{left:0,top:0,width:o.width,height:r.height,isWheelPreventDefaultX:!0}),m=new w.Viewport(j.VIEW_MAIN_LEFT_TOP,n,{isWheelPreventDefaultX:!0,active:!1}),_=new w.Viewport(j.VIEW_MAIN_LEFT,n,{isWheelPreventDefaultX:!0,active:!1}),g=new w.Viewport(j.VIEW_MAIN_TOP,n,{isWheelPreventDefaultX:!0,active:!1});n.onMouseWheelObserver.add((S,v)=>{if(S.ctrlKey)return;let I=0,b=0;const R=s.limitedScroll();if(S.inputIndex===w.PointerInput.MouseWheelX){const E=Math.abs(S.deltaX);S.deltaX>0?I=E:I=-E,this._commandService.executeCommand(mn.id,{offsetX:I}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?R!=null&&R.isLimitedX||v.stopPropagation():s.isWheelPreventDefaultX?S.preventDefault():R!=null&&R.isLimitedX||S.preventDefault()}if(S.inputIndex===w.PointerInput.MouseWheelY){let E=Math.abs(S.deltaY);S.shiftKey?(E*=3,S.deltaY>0?I=E:I=-E,this._commandService.executeCommand(mn.id,{offsetX:I}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?R!=null&&R.isLimitedX||v.stopPropagation():s.isWheelPreventDefaultX?S.preventDefault():R!=null&&R.isLimitedX||S.preventDefault()):(S.deltaY>0?b=E:b=-E,this._commandService.executeCommand(mn.id,{offsetY:b}),n.getParent().classType===w.RENDER_CLASS_TYPE.SCENE_VIEWER?R!=null&&R.isLimitedY||v.stopPropagation():s.isWheelPreventDefaultY?S.preventDefault():R!=null&&R.isLimitedY||S.preventDefault())}S.inputIndex,w.PointerInput.MouseWheelZ,this._scene.makeDirty(!0)}),new w.ScrollBar(s),n.addViewport(s,d,u,a,c,h,m,_,g).attachControl()}},P.SheetCanvasView=dh([l.OnLifecycle(l.LifecycleStages.Ready,P.SheetCanvasView),kt(0,l.IUniverInstanceService),kt(1,l.ICommandService),kt(2,w.IRenderManagerService),kt(3,se),kt(4,L.Inject(P.SheetSkeletonManagerService))],P.SheetCanvasView);var uh=Object.defineProperty,hh=Object.getOwnPropertyDescriptor,mh=(i,e,t,n)=>{for(var o=n>1?void 0:n?hh(e,t):e,r=i.length-1,s;r>=0;r--)(s=i[r])&&(o=(n?s(e,t,o):s(o))||o);return n&&o&&uh(e,t,o),o},Ri=(i,e)=>(t,n)=>e(t,n,i);P.UniverSheetsUIPlugin=(wi=class extends l.Plugin{constructor(e,t,n,o){super(xi),this._injector=t,this._localeService=n,this._currentUniverService=o,this._localeService.load({zhCN:Vo})}onStarting(e){[[P.SheetCanvasView],[Ce,{useClass:Pi}],[qe,{useClass:P.SheetClipboardService}],[dt,{useClass:ud}],[it,{useClass:ii}],[wt,{useClass:Fo}],[en,{useClass:Cl}],[Mt,{useClass:P.AutoFillService}],[Le],[P.SheetSkeletonManagerService],[se,{useClass:P.SelectionRenderService}],[Ci,{useClass:Fd}],[zt,{useClass:P.MarkSelectionService}],[tn],[nn],[un],[an],[ln],[hn],[_n],[gn],[fn],[pn],[Cn],[cn],[In],[Dt],[bn],[on],[rn],[Mn],[Rn],[xn],[dn],[Pn],[P.AutoFillController],[An],[sn]].forEach(t=>e.add(t))}onReady(){this._markSheetAsFocused()}_markSheetAsFocused(){const e=this._currentUniverService;e.currentSheet$.pipe(Ti.filter(t=>!!t)).subscribe(t=>{e.focusUniverInstance(t.getUnitId())})}},C(wi,"type",l.PluginType.Sheet),wi),P.UniverSheetsUIPlugin=mh([Ri(1,L.Inject(L.Injector)),Ri(2,L.Inject(l.LocaleService)),Ri(3,l.IUniverInstanceService)],P.UniverSheetsUIPlugin),P.APPLY_TYPE=z,P.AutoFillCommand=Vt,P.COPY_TYPE=We,P.CellEditorManagerService=Fo,P.DATA_TYPE=ie,P.DefaultRightMenuConfig=Ei,P.DefaultSheetContainerConfig=yi,P.DefaultSheetUIConfig=Rr,P.DefaultToolbarConfig=Oi,P.EditorBridgeService=Pi,P.ExpandSelectionCommand=be,P.IAutoFillService=Mt,P.ICellEditorManagerService=wt,P.IEditorBridgeService=Ce,P.IFormulaEditorManagerService=en,P.IMarkSelectionService=zt,P.ISelectionRenderService=se,P.ISheetClipboardService=qe,P.JumpOver=Me,P.MoveSelectionCommand=me,P.PASTE_SPECIAL_MENU_ID=rt,P.RangeSelector=Qs,P.SHEET_UI_PLUGIN_NAME=xi,P.SelectionShape=jt,P.SetCellEditVisibleArrowOperation=gt,P.SetEditorResizeOperation=Xt,P.SetScrollOperation=tt,P.SetZoomRatioOperation=Ee,P.SheetCopyCommand=Vi,P.SheetPasteCommand=et,P.VIEWPORT_KEY=j,P.enUS=pl,P.getAutoFillRepeatRange=ha,P.getCoordByCell=ci,P.getCoordByOffset=st,P.getEditorObject=Bt,P.getRepeatRange=vl,P.getSheetObject=le,P.getTransformCoord=qt,P.whenEditorInputFormulaActivated=Or,P.zhCN=Vo,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
|