/*!
 * Built by Revolist OU ❤️
 */
'use strict';

var column_service = require('./column.service-C1Qvcf5l.js');
var column_drag_plugin = require('./column.drag.plugin-_W9mYaRy.js');
var headerCellRenderer = require('./header-cell-renderer-QrcXXSkF.js');
var cellRenderer = require('./cell-renderer-Dcz022q7.js');
var index$1 = require('./index-DxaSE5uZ.js');
var textEditor = require('./text-editor-B4W-m-r-.js');
var edit_utils = require('./edit.utils-pKeiYFLJ.js');
var index = require('./index-Dq8Xzj5l.js');
var dimension_helpers = require('./dimension.helpers-B9HgANnM.js');
var viewport_store = require('./viewport.store-BscUCiUk.js');
var filter_button = require('./filter.button-w6LWnyhi.js');
require('./debounce-CcpHiH2p.js');

const REVOGRID_EVENTS = new Map([
    ['contentsizechanged', 'contentsizechanged'],
    ['beforeedit', 'beforeedit'],
    ['beforerangeedit', 'beforerangeedit'],
    ['afteredit', 'afteredit'],
    ['beforeautofill', 'beforeautofill'],
    ['beforerange', 'beforerange'],
    ['afterfocus', 'afterfocus'],
    ['roworderchanged', 'roworderchanged'],
    ['beforesorting', 'beforesorting'],
    ['beforesourcesortingapply', 'beforesourcesortingapply'],
    ['beforesortingapply', 'beforesortingapply'],
    ['rowdragstart', 'rowdragstart'],
    ['headerclick', 'headerclick'],
    ['beforecellfocus', 'beforecellfocus'],
    ['beforefocuslost', 'beforefocuslost'],
    ['beforesourceset', 'beforesourceset'],
    ['beforeanysource', 'beforeanysource'],
    ['aftersourceset', 'aftersourceset'],
    ['afteranysource', 'afteranysource'],
    ['beforecolumnsgather', 'beforecolumnsgather'],
    ['beforecolumnsset', 'beforecolumnsset'],
    ['beforecolumnapplied', 'beforecolumnapplied'],
    ['aftercolumnsset', 'aftercolumnsset'],
    ['beforefilterapply', 'beforefilterapply'],
    ['beforefiltertrimmed', 'beforefiltertrimmed'],
    ['beforetrimmed', 'beforetrimmed'],
    ['aftertrimmed', 'aftertrimmed'],
    ['viewportscroll', 'viewportscroll'],
    ['beforeexport', 'beforeexport'],
    ['beforeeditstart', 'beforeeditstart'],
    ['aftercolumnresize', 'aftercolumnresize'],
    ['beforerowdefinition', 'beforerowdefinition'],
    ['filterconfigchanged', 'filterconfigchanged'],
    ['sortingconfigchanged', 'sortingconfigchanged'],
    ['rowheaderschanged', 'rowheaderschanged'],
    ['beforegridrender', 'beforegridrender'],
    ['aftergridrender', 'aftergridrender'],
    ['aftergridinit', 'aftergridinit'],
    ['additionaldatachanged', 'additionaldatachanged'],
    ['afterthemechanged', 'afterthemechanged'],
    ['created', 'created'],
    ['beforepaste', 'beforepaste'],
    ['beforepasteapply', 'beforepasteapply'],
    ['pasteregion', 'pasteregion'],
    ['afterpasteapply', 'afterpasteapply'],
    ['beforecut', 'beforecut'],
    ['clearregion', 'clearregion'],
    ['beforecopy', 'beforecopy'],
    ['beforecopyapply', 'beforecopyapply'],
    ['copyregion', 'copyregion'],
    ['beforerowrender', 'beforerowrender'],
    ['afterrender', 'afterrender'],
    ['beforecellrender', 'beforecellrender'],
    ['beforedatarender', 'beforedatarender'],
    ['dragstartcell', 'dragstartcell'],
    ['celleditinit', 'celleditinit'],
    ['closeedit', 'closeedit'],
    ['filterChange', 'filterChange'],
    ['resetChange', 'resetChange'],
    ['beforefocusrender', 'beforefocusrender'],
    ['beforescrollintoview', 'beforescrollintoview'],
    ['afterfocus', 'afterfocus'],
    ['beforeheaderclick', 'beforeheaderclick'],
    ['headerresize', 'headerresize'],
    ['beforeheaderresize', 'beforeheaderresize'],
    ['headerdblclick', 'headerdblclick'],
    ['beforeheaderrender', 'beforeheaderrender'],
    ['beforegroupheaderrender', 'beforegroupheaderrender'],
    ['afterheaderrender', 'afterheaderrender'],
    ['columndragstart', 'columndragstart'],
    ['columndragmousemove', 'columndragmousemove'],
    ['beforecolumndragend', 'beforecolumndragend'],
    ['columndragend', 'columndragend'],
    ['rowdragstartinit', 'rowdragstartinit'],
    ['rowdragendinit', 'rowdragendinit'],
    ['rowdragmoveinit', 'rowdragmoveinit'],
    ['rowdragmousemove', 'rowdragmousemove'],
    ['rowdropinit', 'rowdropinit'],
    ['roworderchange', 'roworderchange'],
    ['beforecopyregion', 'beforecopyregion'],
    ['beforepasteregion', 'beforepasteregion'],
    ['celleditapply', 'celleditapply'],
    ['beforecellfocusinit', 'beforecellfocusinit'],
    ['beforenextvpfocus', 'beforenextvpfocus'],
    ['setedit', 'setedit'],
    ['beforeapplyrange', 'beforeapplyrange'],
    ['beforesetrange', 'beforesetrange'],
    ['setrange', 'setrange'],
    ['beforeeditrender', 'beforeeditrender'],
    ['selectall', 'selectall'],
    ['canceledit', 'canceledit'],
    ['settemprange', 'settemprange'],
    ['beforesettemprange', 'beforesettemprange'],
    ['applyfocus', 'applyfocus'],
    ['focuscell', 'focuscell'],
    ['beforerangedataapply', 'beforerangedataapply'],
    ['selectionchangeinit', 'selectionchangeinit'],
    ['beforerangecopyapply', 'beforerangecopyapply'],
    ['rangeeditapply', 'rangeeditapply'],
    ['clipboardrangecopy', 'clipboardrangecopy'],
    ['clipboardrangepaste', 'clipboardrangepaste'],
    ['beforekeydown', 'beforekeydown'],
    ['beforekeyup', 'beforekeyup'],
    ['beforecellsave', 'beforecellsave'],
    ['celledit', 'celledit'],
    ['scrollview', 'scrollview'],
    ['ref', 'ref'],
    ['scrollvirtual', 'scrollvirtual'],
    ['scrollviewport', 'scrollviewport'],
    ['resizeviewport', 'resizeviewport'],
    ['scrollchange', 'scrollchange'],
    ['scrollviewportsilent', 'scrollviewportsilent'],
    ['html', 'html']
]);

/**
 * Automatically adds new rows when pasted data is larger than current rows
 * @event newRows - is triggered when new rows are added. Data of new rows can be filled with default values. If the event is prevented, no rows will be added
 */
class AutoAddRowsPlugin extends column_drag_plugin.BasePlugin {
    constructor(revogrid, providers) {
        super(revogrid, providers);
        this.addEventListener('beforepasteapply', evt => this.handleBeforePasteApply(evt));
    }
    handleBeforePasteApply(event) {
        const start = this.providers.selection.focused;
        const isEditing = this.providers.selection.edit != null;
        if (!start || isEditing) {
            return;
        }
        const rowLength = this.providers.data.stores.rgRow.store.get('items').length;
        const endRow = start.y + event.detail.parsed.length;
        if (rowLength < endRow) {
            const count = endRow - rowLength;
            const newRows = Array.from({ length: count }, (_, i) => ({
                index: rowLength + i,
                data: {},
            }));
            const event = this.emit('newRows', { newRows: newRows });
            if (event.defaultPrevented) {
                return;
            }
            const items = [
                ...this.providers.data.stores.rgRow.store.get('source'),
                ...event.detail.newRows.map(j => j.data),
            ];
            this.providers.data.setData(items);
        }
    }
}

exports.GROUPING_ROW_TYPE = column_service.GROUPING_ROW_TYPE;
exports.GROUP_COLUMN_PROP = column_service.GROUP_COLUMN_PROP;
exports.GROUP_DEPTH = column_service.GROUP_DEPTH;
exports.GROUP_EXPANDED = column_service.GROUP_EXPANDED;
exports.GROUP_EXPAND_BTN = column_service.GROUP_EXPAND_BTN;
exports.GROUP_EXPAND_EVENT = column_service.GROUP_EXPAND_EVENT;
exports.GROUP_ORIGINAL_INDEX = column_service.GROUP_ORIGINAL_INDEX;
exports.PSEUDO_GROUP_COLUMN = column_service.PSEUDO_GROUP_COLUMN;
exports.PSEUDO_GROUP_ITEM = column_service.PSEUDO_GROUP_ITEM;
exports.PSEUDO_GROUP_ITEM_ID = column_service.PSEUDO_GROUP_ITEM_ID;
exports.PSEUDO_GROUP_ITEM_VALUE = column_service.PSEUDO_GROUP_ITEM_VALUE;
exports.columnTypes = column_service.columnTypes;
exports.cropCellToMax = column_service.cropCellToMax;
exports.gatherGroup = column_service.gatherGroup;
exports.gatherGrouping = column_service.gatherGrouping;
exports.getCellData = column_service.getCellData;
exports.getCellDataParsed = column_service.getCellDataParsed;
exports.getCellRaw = column_service.getCellRaw;
exports.getColumnByProp = column_service.getColumnByProp;
exports.getColumnSizes = column_service.getColumnSizes;
exports.getColumnType = column_service.getColumnType;
exports.getColumns = column_service.getColumns;
exports.getExpanded = column_service.getExpanded;
exports.getGroupingName = column_service.getGroupingName;
exports.getParsedGroup = column_service.getParsedGroup;
exports.getRange = column_service.getRange;
exports.getSource = column_service.getSource;
exports.isColGrouping = column_service.isColGrouping;
exports.isGrouping = column_service.isGrouping;
exports.isGroupingColumn = column_service.isGroupingColumn;
exports.isRangeSingleCell = column_service.isRangeSingleCell;
exports.isRowType = column_service.isRowType;
exports.isSameGroup = column_service.isSameGroup;
exports.measureEqualDepth = column_service.measureEqualDepth;
exports.nextCell = column_service.nextCell;
exports.rowTypes = column_service.rowTypes;
exports.AutoSizeColumnPlugin = column_drag_plugin.AutoSizeColumnPlugin;
exports.BEFORE_COLUMN_DRAG_END_EVENT = column_drag_plugin.BEFORE_COLUMN_DRAG_END_EVENT;
exports.BasePlugin = column_drag_plugin.BasePlugin;
exports.COLUMN_DRAG_END_EVENT = column_drag_plugin.COLUMN_DRAG_END_EVENT;
exports.COLUMN_DRAG_MOVE_EVENT = column_drag_plugin.COLUMN_DRAG_MOVE_EVENT;
exports.COLUMN_DRAG_START_EVENT = column_drag_plugin.COLUMN_DRAG_START_EVENT;
Object.defineProperty(exports, "ColumnAutoSizeMode", {
    enumerable: true,
    get: function () { return column_drag_plugin.ColumnAutoSizeMode; }
});
exports.ColumnMovePlugin = column_drag_plugin.ColumnMovePlugin;
exports.DimensionStore = column_drag_plugin.DimensionStore;
exports.ExportCsv = column_drag_plugin.ExportCsv;
exports.ExportFilePlugin = column_drag_plugin.ExportFilePlugin;
exports.FILTER_CONFIG_CHANGED_EVENT = column_drag_plugin.FILTER_CONFIG_CHANGED_EVENT;
exports.FILTER_TRIMMED_TYPE = column_drag_plugin.FILTER_TRIMMED_TYPE;
exports.FILTE_PANEL = column_drag_plugin.FILTE_PANEL;
exports.FilterPlugin = column_drag_plugin.FilterPlugin;
exports.GroupingRowPlugin = column_drag_plugin.GroupingRowPlugin;
exports.SelectionStore = column_drag_plugin.SelectionStore;
exports.SortingPlugin = column_drag_plugin.SortingPlugin;
exports.StretchColumn = column_drag_plugin.StretchColumn;
exports.defaultCellCompare = column_drag_plugin.defaultCellCompare;
exports.descCellCompare = column_drag_plugin.descCellCompare;
exports.doCollapse = column_drag_plugin.doCollapse;
exports.doExpand = column_drag_plugin.doExpand;
exports.filterCoreFunctionsIndexedByType = column_drag_plugin.filterCoreFunctionsIndexedByType;
exports.filterNames = column_drag_plugin.filterNames;
exports.filterTypes = column_drag_plugin.filterTypes;
exports.getComparer = column_drag_plugin.getComparer;
exports.getLeftRelative = column_drag_plugin.getLeftRelative;
exports.getNextOrder = column_drag_plugin.getNextOrder;
exports.getSortingIndex = column_drag_plugin.getSortingIndex;
exports.hasActiveSorting = column_drag_plugin.hasActiveSorting;
exports.isStretchPlugin = column_drag_plugin.isStretchPlugin;
exports.sortIndexByItems = column_drag_plugin.sortIndexByItems;
exports.dispatch = headerCellRenderer.dispatch;
exports.dispatchByEvent = headerCellRenderer.dispatchByEvent;
exports.CellRenderer = cellRenderer.CellRenderer;
exports.GroupingRowRenderer = cellRenderer.GroupingRowRenderer;
exports.SortingSign = cellRenderer.SortingSign;
exports.expandEvent = cellRenderer.expandEvent;
exports.expandSvgIconVNode = cellRenderer.expandSvgIconVNode;
exports.applyMixins = index$1.applyMixins;
exports.findPositionInArray = index$1.findPositionInArray;
exports.getScrollbarSize = index$1.getScrollbarSize;
exports.mergeSortedArray = index$1.mergeSortedArray;
exports.pushSorted = index$1.pushSorted;
exports.range = index$1.range;
exports.scaleValue = index$1.scaleValue;
exports.timeout = index$1.timeout;
exports.TextEditor = textEditor.TextEditor;
exports.isAll = edit_utils.isAll;
exports.isClear = edit_utils.isClear;
exports.isCopy = edit_utils.isCopy;
exports.isCtrlKey = edit_utils.isCtrlKey;
exports.isCtrlMetaKey = edit_utils.isCtrlMetaKey;
exports.isCut = edit_utils.isCut;
exports.isEditInput = edit_utils.isEditInput;
exports.isEditorCtrConstructible = edit_utils.isEditorCtrConstructible;
exports.isEnterKeyValue = edit_utils.isEnterKeyValue;
exports.isMetaKey = edit_utils.isMetaKey;
exports.isPaste = edit_utils.isPaste;
exports.isShortcutModifier = edit_utils.isShortcutModifier;
exports.isTab = edit_utils.isTab;
exports.isTabKeyValue = edit_utils.isTabKeyValue;
exports.h = index.h;
exports.CELL_CLASS = dimension_helpers.CELL_CLASS;
exports.CELL_HANDLER_CLASS = dimension_helpers.CELL_HANDLER_CLASS;
exports.DATA_COL = dimension_helpers.DATA_COL;
exports.DATA_ROW = dimension_helpers.DATA_ROW;
exports.DISABLED_CLASS = dimension_helpers.DISABLED_CLASS;
exports.DRAGGABLE_CLASS = dimension_helpers.DRAGGABLE_CLASS;
exports.DRAGG_TEXT = dimension_helpers.DRAGG_TEXT;
exports.DRAG_ICON_CLASS = dimension_helpers.DRAG_ICON_CLASS;
exports.DataStore = dimension_helpers.DataStore;
exports.EDIT_INPUT_WR = dimension_helpers.EDIT_INPUT_WR;
exports.FOCUS_CLASS = dimension_helpers.FOCUS_CLASS;
exports.GRID_INTERNALS = dimension_helpers.GRID_INTERNALS;
exports.HEADER_ACTUAL_ROW_CLASS = dimension_helpers.HEADER_ACTUAL_ROW_CLASS;
exports.HEADER_CLASS = dimension_helpers.HEADER_CLASS;
exports.HEADER_ROW_CLASS = dimension_helpers.HEADER_ROW_CLASS;
exports.HEADER_SORTABLE_CLASS = dimension_helpers.HEADER_SORTABLE_CLASS;
exports.MIN_COL_SIZE = dimension_helpers.MIN_COL_SIZE;
exports.MOBILE_CLASS = dimension_helpers.MOBILE_CLASS;
exports.RESIZE_INTERVAL = dimension_helpers.RESIZE_INTERVAL;
exports.ROW_FOCUSED_CLASS = dimension_helpers.ROW_FOCUSED_CLASS;
exports.ROW_HEADER_TYPE = dimension_helpers.ROW_HEADER_TYPE;
exports.SELECTION_BORDER_CLASS = dimension_helpers.SELECTION_BORDER_CLASS;
exports.TMP_SELECTION_BG_CLASS = dimension_helpers.TMP_SELECTION_BG_CLASS;
exports.calculateDimensionData = dimension_helpers.calculateDimensionData;
Object.defineProperty(exports, "codesLetter", {
    enumerable: true,
    get: function () { return dimension_helpers.codesLetter; }
});
exports.gatherTrimmedItems = dimension_helpers.gatherTrimmedItems;
exports.getItemByIndex = dimension_helpers.getItemByIndex;
exports.getItemByPosition = dimension_helpers.getItemByPosition;
exports.getPhysical = dimension_helpers.getPhysical;
exports.getSourceItem = dimension_helpers.getSourceItem;
exports.getSourceItemVirtualIndexByProp = dimension_helpers.getSourceItemVirtualIndexByProp;
exports.getSourcePhysicalIndex = dimension_helpers.getSourcePhysicalIndex;
exports.getVisibleSourceItem = dimension_helpers.getVisibleSourceItem;
Object.defineProperty(exports, "keyValues", {
    enumerable: true,
    get: function () { return dimension_helpers.keyValues; }
});
exports.proxyPlugin = dimension_helpers.proxyPlugin;
exports.setItems = dimension_helpers.setItems;
exports.setSourceByPhysicalIndex = dimension_helpers.setSourceByPhysicalIndex;
exports.setSourceByVirtualIndex = dimension_helpers.setSourceByVirtualIndex;
exports.setStore = dimension_helpers.setStore;
exports.trimmedPlugin = dimension_helpers.trimmedPlugin;
exports.ViewportStore = viewport_store.ViewportStore;
exports.addMissingItems = viewport_store.addMissingItems;
exports.calculateRowHeaderSize = viewport_store.calculateRowHeaderSize;
exports.clampViewportCoordinate = viewport_store.clampViewportCoordinate;
exports.getFirstItem = viewport_store.getFirstItem;
exports.getItems = viewport_store.getItems;
exports.getLastItem = viewport_store.getLastItem;
exports.getUpdatedItemsByPosition = viewport_store.getUpdatedItemsByPosition;
exports.getViewportMaxCoordinate = viewport_store.getViewportMaxCoordinate;
exports.isActiveRange = viewport_store.isActiveRange;
exports.isActiveRangeOutsideLastItem = viewport_store.isActiveRangeOutsideLastItem;
exports.recombineByOffset = viewport_store.recombineByOffset;
exports.setItemSizes = viewport_store.setItemSizes;
exports.updateMissingAndRange = viewport_store.updateMissingAndRange;
exports.AND_OR_BUTTON = filter_button.AND_OR_BUTTON;
exports.AndOrButton = filter_button.AndOrButton;
exports.FILTER_BUTTON_ACTIVE = filter_button.FILTER_BUTTON_ACTIVE;
exports.FILTER_BUTTON_CLASS = filter_button.FILTER_BUTTON_CLASS;
exports.FILTER_PROP = filter_button.FILTER_PROP;
exports.FilterButton = filter_button.FilterButton;
exports.TRASH_BUTTON = filter_button.TRASH_BUTTON;
exports.TrashButton = filter_button.TrashButton;
exports.isFilterBtn = filter_button.isFilterBtn;
exports.AutoAddRowsPlugin = AutoAddRowsPlugin;
exports.REVOGRID_EVENTS = REVOGRID_EVENTS;
