/**
 * DevExtreme (cjs/__internal/grids/grid_core/column_fixing/m_column_fixing.js)
 * Version: 23.1.8 (build 24063-0109)
 * Build date: Sun Mar 03 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.columnFixingModule = void 0;
var _translator = require("../../../../animation/translator");
var _renderer = _interopRequireDefault(require("../../../../core/renderer"));
var _browser = _interopRequireDefault(require("../../../../core/utils/browser"));
var _extend = require("../../../../core/utils/extend");
var _iterator = require("../../../../core/utils/iterator");
var _position = require("../../../../core/utils/position");
var _size = require("../../../../core/utils/size");
var _style = require("../../../../core/utils/style");
var _type = require("../../../../core/utils/type");
var _events_engine = _interopRequireDefault(require("../../../../events/core/events_engine"));
var _wheel = require("../../../../events/core/wheel");
var _message = _interopRequireDefault(require("../../../../localization/message"));
var _ui = _interopRequireDefault(require("../../../../ui/scroll_view/ui.scrollable"));
var _m_utils = _interopRequireDefault(require("../m_utils"));
var _m_columns_view = require("../views/m_columns_view");

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}
var CONTENT_CLASS = "content";
var CONTENT_FIXED_CLASS = "content-fixed";
var MASTER_DETAIL_CELL_CLASS = "dx-master-detail-cell";
var FIRST_CELL_CLASS = "dx-first-cell";
var LAST_CELL_CLASS = "dx-last-cell";
var HOVER_STATE_CLASS = "dx-state-hover";
var FIXED_COL_CLASS = "dx-col-fixed";
var FIXED_COLUMNS_CLASS = "dx-fixed-columns";
var POINTER_EVENTS_NONE_CLASS = "dx-pointer-events-none";
var COMMAND_TRANSPARENT = "transparent";
var GROUP_ROW_CLASS = "dx-group-row";
var DETAIL_ROW_CLASS = "dx-master-detail-row";
var getTransparentColumnIndex = function(fixedColumns) {
    var transparentColumnIndex = -1;
    (0, _iterator.each)(fixedColumns, (function(index, column) {
        if (column.command === COMMAND_TRANSPARENT) {
            transparentColumnIndex = index;
            return false
        }
        return
    }));
    return transparentColumnIndex
};
var normalizeColumnWidths = function(fixedColumns, widths, fixedWidths) {
    var fixedColumnIndex = 0;
    if (fixedColumns && widths && fixedWidths) {
        for (var i = 0; i < fixedColumns.length; i++) {
            if (fixedColumns[i].command === COMMAND_TRANSPARENT) {
                fixedColumnIndex += fixedColumns[i].colspan
            } else {
                if (widths[fixedColumnIndex] < fixedWidths[i]) {
                    widths[fixedColumnIndex] = fixedWidths[i]
                }
                fixedColumnIndex++
            }
        }
    }
    return widths
};
var baseFixedColumns = function(Base) {
    return function(_Base) {
        _inheritsLoose(BaseFixedColumnsExtender, _Base);

        function BaseFixedColumnsExtender() {
            return _Base.apply(this, arguments) || this
        }
        var _proto = BaseFixedColumnsExtender.prototype;
        _proto.init = function() {
            _Base.prototype.init.call(this);
            this._isFixedTableRendering = false;
            this._isFixedColumns = false
        };
        _proto._createCol = function(column) {
            return _Base.prototype._createCol.call(this, column).toggleClass(FIXED_COL_CLASS, !!(this._isFixedTableRendering && (column.fixed || column.command && column.command !== COMMAND_TRANSPARENT)))
        };
        _proto._correctColumnIndicesForFixedColumns = function(fixedColumns, change) {
            var transparentColumnIndex = getTransparentColumnIndex(fixedColumns);
            var transparentColspan = fixedColumns[transparentColumnIndex].colspan;
            var columnIndices = change && change.columnIndices;
            if (columnIndices) {
                change.columnIndices = columnIndices.map((function(columnIndices) {
                    if (columnIndices) {
                        return columnIndices.map((function(columnIndex) {
                            if (columnIndex < transparentColumnIndex) {
                                return columnIndex
                            }
                            if (columnIndex >= transparentColumnIndex + transparentColspan) {
                                return columnIndex - transparentColspan + 1
                            }
                            return -1
                        })).filter((function(columnIndex) {
                            return columnIndex >= 0
                        }))
                    }
                }))
            }
        };
        _proto._partialUpdateFixedTable = function(fixedColumns) {
            var fixedTableElement = this._fixedTableElement;
            var $rows = this._getRowElementsCore(fixedTableElement);
            var $colgroup = fixedTableElement.children("colgroup");
            $colgroup.replaceWith(this._createColGroup(fixedColumns));
            for (var i = 0; i < $rows.length; i++) {
                this._partialUpdateFixedRow((0, _renderer.default)($rows[i]), fixedColumns)
            }
        };
        _proto._partialUpdateFixedRow = function($row, fixedColumns) {
            var _a;
            var cellElements = $row.get(0).childNodes;
            var transparentColumnIndex = getTransparentColumnIndex(fixedColumns);
            var transparentColumn = fixedColumns[transparentColumnIndex];
            var columnIndexOffset = this._columnsController.getColumnIndexOffset();
            var groupCellOptions;
            var colIndex = columnIndexOffset + 1;
            var colspan = transparentColumn.colspan;
            if ($row.hasClass(DETAIL_ROW_CLASS)) {
                cellElements[0].setAttribute("colspan", null === (_a = this._columnsController.getVisibleColumns()) || void 0 === _a ? void 0 : _a.length);
                return
            }
            if ($row.hasClass(GROUP_ROW_CLASS)) {
                groupCellOptions = this._getGroupCellOptions({
                    row: $row.data("options"),
                    columns: this._columnsController.getVisibleColumns()
                });
                colspan = groupCellOptions.colspan - Math.max(0, cellElements.length - (groupCellOptions.columnIndex + 2))
            }
            for (var j = 0; j < cellElements.length; j++) {
                var needUpdateColspan = groupCellOptions ? j === groupCellOptions.columnIndex + 1 : j === transparentColumnIndex;
                cellElements[j].setAttribute("aria-colindex", colIndex);
                if (needUpdateColspan) {
                    cellElements[j].setAttribute("colspan", colspan);
                    colIndex += colspan
                } else {
                    colIndex++
                }
            }
        };
        _proto._renderTable = function(options) {
            var _a;
            var $fixedTable;
            var fixedColumns = this.getFixedColumns();
            this._isFixedColumns = !!fixedColumns.length;
            var $table = _Base.prototype._renderTable.call(this, options);
            if (this._isFixedColumns) {
                var change = null === options || void 0 === options ? void 0 : options.change;
                var $fixedDataRows = this._getRowElements(this._fixedTableElement);
                var needPartialUpdate = (null === change || void 0 === change ? void 0 : change.virtualColumnsScrolling) && $fixedDataRows.length === (null === (_a = null === change || void 0 === change ? void 0 : change.items) || void 0 === _a ? void 0 : _a.length);
                this._isFixedTableRendering = true;
                if (needPartialUpdate && true !== this.option("scrolling.legacyMode")) {
                    this._partialUpdateFixedTable(fixedColumns);
                    this._isFixedTableRendering = false
                } else {
                    var columnIndices = null === change || void 0 === change ? void 0 : change.columnIndices;
                    this._correctColumnIndicesForFixedColumns(fixedColumns, change);
                    $fixedTable = this._createTable(fixedColumns);
                    this._renderRows($fixedTable, (0, _extend.extend)({}, options, {
                        columns: fixedColumns
                    }));
                    this._updateContent($fixedTable, change, true);
                    if (columnIndices) {
                        change.columnIndices = columnIndices
                    }
                    this._isFixedTableRendering = false
                }
            } else {
                this._fixedTableElement && this._fixedTableElement.parent().remove();
                this._fixedTableElement = null
            }
            return $table
        };
        _proto._renderRow = function($table, options) {
            var fixedCorrection;
            var cells = options.row.cells;
            _Base.prototype._renderRow.apply(this, arguments);
            if (this._isFixedTableRendering && cells && cells.length) {
                fixedCorrection = 0;
                var fixedCells = options.row.cells || [];
                cells = cells.slice();
                options.row.cells = cells;
                for (var i = 0; i < fixedCells.length; i++) {
                    if (fixedCells[i].column && fixedCells[i].column.command === COMMAND_TRANSPARENT) {
                        fixedCorrection = (fixedCells[i].column.colspan || 1) - 1;
                        continue
                    }
                    cells[i + fixedCorrection] = fixedCells[i]
                }
            }
        };
        _proto._createCell = function(options) {
            var that = this;
            var column = options.column;
            var columnCommand = column && column.command;
            var rowType = options.rowType;
            var $cell = _Base.prototype._createCell.apply(that, arguments);
            var fixedColumns;
            var prevFixedColumn;
            var transparentColumnIndex;
            if (that._isFixedTableRendering || "filter" === rowType) {
                fixedColumns = that.getFixedColumns();
                transparentColumnIndex = getTransparentColumnIndex(fixedColumns);
                prevFixedColumn = fixedColumns[transparentColumnIndex - 1]
            }
            if (that._isFixedTableRendering) {
                if (columnCommand === COMMAND_TRANSPARENT) {
                    $cell.addClass(POINTER_EVENTS_NONE_CLASS).toggleClass(FIRST_CELL_CLASS, 0 === transparentColumnIndex || prevFixedColumn && "expand" === prevFixedColumn.command).toggleClass(LAST_CELL_CLASS, fixedColumns.length && transparentColumnIndex === fixedColumns.length - 1);
                    if ("freeSpace" !== rowType) {
                        _m_utils.default.setEmptyText($cell)
                    }
                }
            } else if ("filter" === rowType) {
                $cell.toggleClass(FIRST_CELL_CLASS, options.columnIndex === transparentColumnIndex)
            }
            var isRowAltStyle = that.option("rowAlternationEnabled") && options.isAltRow;
            var isSelectAllCell = "multiple" === that.option("selection.mode") && 0 === options.columnIndex && "header" === options.rowType;
            if (_browser.default.mozilla && options.column.fixed && "group" !== options.rowType && !isRowAltStyle && !isSelectAllCell) {
                $cell.addClass(FIXED_COL_CLASS)
            }
            return $cell
        };
        _proto._getContent = function(isFixedTableRendering) {
            var _a;
            return isFixedTableRendering ? null === (_a = this._fixedTableElement) || void 0 === _a ? void 0 : _a.parent() : _Base.prototype._getContent.apply(this, arguments)
        };
        _proto._wrapTableInScrollContainer = function($table, isFixedTableRendering) {
            var $scrollContainer = _Base.prototype._wrapTableInScrollContainer.apply(this, arguments);
            if (this._isFixedTableRendering || isFixedTableRendering) {
                $scrollContainer.addClass(this.addWidgetPrefix(CONTENT_FIXED_CLASS))
            }
            return $scrollContainer
        };
        _proto._renderCellContent = function($cell, options) {
            var isEmptyCell;
            var column = options.column;
            var isFixedTableRendering = this._isFixedTableRendering;
            var isGroupCell = "group" === options.rowType && (0, _type.isDefined)(column.groupIndex);
            if (isFixedTableRendering && isGroupCell && !column.command && !column.groupCellTemplate) {
                $cell.css("pointerEvents", "none")
            }
            if (!isFixedTableRendering && this._isFixedColumns) {
                isEmptyCell = column.fixed || column.command && false !== column.fixed;
                if (isGroupCell) {
                    isEmptyCell = false;
                    if (options.row.summaryCells && options.row.summaryCells.length) {
                        var columns = this._columnsController.getVisibleColumns();
                        var alignByFixedColumnCellCount = this._getAlignByColumnCellCount ? this._getAlignByColumnCellCount(column.colspan, {
                            columns: columns,
                            row: options.row,
                            isFixed: true
                        }) : 0;
                        if (alignByFixedColumnCellCount > 0) {
                            var transparentColumnIndex = getTransparentColumnIndex(this._columnsController.getFixedColumns());
                            isEmptyCell = columns.length - alignByFixedColumnCellCount < transparentColumnIndex
                        }
                    }
                }
                if (isEmptyCell) {
                    if (column.command && "buttons" !== column.type || "group" === options.rowType) {
                        $cell.html("&nbsp;").addClass(column.cssClass);
                        return
                    }
                    $cell.addClass("dx-hidden-cell")
                }
            }
            if (column.command !== COMMAND_TRANSPARENT) {
                _Base.prototype._renderCellContent.apply(this, arguments)
            }
        };
        _proto._getCellElementsCore = function(rowIndex) {
            var _this = this;
            var cellElements = _Base.prototype._getCellElementsCore.apply(this, arguments);
            var isGroupRow = null === cellElements || void 0 === cellElements ? void 0 : cellElements.parent().hasClass(GROUP_ROW_CLASS);
            var headerRowIndex = "columnHeadersView" === this.name ? rowIndex : void 0;
            if (this._fixedTableElement && cellElements) {
                var fixedColumns = this.getFixedColumns(headerRowIndex);
                var fixedCellElements = this._getRowElements(this._fixedTableElement).eq(rowIndex).children("td");
                (0, _iterator.each)(fixedCellElements, (function(columnIndex, cell) {
                    if (isGroupRow) {
                        if (cellElements[columnIndex] && "hidden" !== cell.style.visibility) {
                            cellElements[columnIndex] = cell
                        }
                    } else {
                        var fixedColumn = fixedColumns[columnIndex];
                        if (fixedColumn) {
                            if (fixedColumn.command === COMMAND_TRANSPARENT) {
                                if (fixedCellElements.eq(columnIndex).hasClass(MASTER_DETAIL_CELL_CLASS)) {
                                    cellElements[columnIndex] = cell || cellElements[columnIndex]
                                }
                            } else {
                                var fixedColumnIndex = _this._columnsController.getVisibleIndexByColumn(fixedColumn, headerRowIndex);
                                cellElements[fixedColumnIndex] = cell || cellElements[fixedColumnIndex]
                            }
                        }
                    }
                }))
            }
            return cellElements
        };
        _proto.getColumnWidths = function(fixedTableElement) {
            var result = _Base.prototype.getColumnWidths.call(this);
            var fixedColumns = this.getFixedColumns();
            var fixedWidths = this._fixedTableElement && result.length ? _Base.prototype.getColumnWidths.call(this, this._fixedTableElement) : void 0;
            return normalizeColumnWidths(fixedColumns, result, fixedWidths)
        };
        _proto.getTableElement = function(isFixedTableRendering) {
            isFixedTableRendering = this._isFixedTableRendering || isFixedTableRendering;
            var tableElement = isFixedTableRendering ? this._fixedTableElement : _Base.prototype.getTableElement.call(this);
            return tableElement
        };
        _proto.setTableElement = function(tableElement, isFixedTableRendering) {
            if (this._isFixedTableRendering || isFixedTableRendering) {
                this._fixedTableElement = tableElement.addClass(POINTER_EVENTS_NONE_CLASS)
            } else {
                _Base.prototype.setTableElement.call(this, tableElement)
            }
        };
        _proto.getColumns = function(rowIndex) {
            var $tableElement = this.getTableElement();
            if (this._isFixedTableRendering) {
                return this.getFixedColumns(rowIndex)
            }
            return _Base.prototype.getColumns.call(this, rowIndex, $tableElement)
        };
        _proto.getRowIndex = function($row) {
            var $fixedTable = this._fixedTableElement;
            if ($fixedTable && $fixedTable.find($row).length) {
                return this._getRowElements($fixedTable).index($row)
            }
            return _Base.prototype.getRowIndex.call(this, $row)
        };
        _proto.getTableElements = function() {
            var result = _Base.prototype.getTableElements.apply(this, arguments);
            if (this._fixedTableElement) {
                result = (0, _renderer.default)([result.get(0), this._fixedTableElement.get(0)])
            }
            return result
        };
        _proto.getFixedColumns = function(rowIndex) {
            return this._columnsController.getFixedColumns(rowIndex)
        };
        _proto.getFixedColumnsOffset = function() {
            var offset = {
                left: 0,
                right: 0
            };
            var $transparentColumn;
            if (this._fixedTableElement) {
                $transparentColumn = this.getTransparentColumnElement();
                var positionTransparentColumn = $transparentColumn.position();
                offset = {
                    left: positionTransparentColumn.left,
                    right: (0, _size.getOuterWidth)(this.element(), true) - ((0, _size.getOuterWidth)($transparentColumn, true) + positionTransparentColumn.left)
                }
            }
            return offset
        };
        _proto.getTransparentColumnElement = function() {
            return this._fixedTableElement && this._fixedTableElement.find(".".concat(POINTER_EVENTS_NONE_CLASS)).first()
        };
        _proto.getFixedTableElement = function() {
            return this._fixedTableElement
        };
        _proto.isFixedColumns = function() {
            return this._isFixedColumns
        };
        _proto._resizeCore = function() {
            _Base.prototype._resizeCore.call(this);
            this.synchronizeRows()
        };
        _proto.setColumnWidths = function(options) {
            var _a;
            var widths = options.widths;
            var visibleColumns = this._columnsController.getVisibleColumns();
            var isColumnWidthsSynced = (null === widths || void 0 === widths ? void 0 : widths.length) && visibleColumns.some((function(column) {
                return (0, _type.isDefined)(column.visibleWidth)
            }));
            var isColumnWidthChanged = null === (_a = options.optionNames) || void 0 === _a ? void 0 : _a.width;
            _Base.prototype.setColumnWidths.call(this, options);
            if (this._fixedTableElement) {
                var hasAutoWidth = null === widths || void 0 === widths ? void 0 : widths.some((function(width) {
                    return "auto" === width || !(0, _type.isDefined)(width)
                }));
                var needVisibleColumns = hasAutoWidth && (!isColumnWidthsSynced || !this.isScrollbarVisible(true));
                var columns = needVisibleColumns ? visibleColumns : this.getFixedColumns();
                this.setFixedTableColumnWidths(columns, widths)
            }
            var wordWrapEnabled = this.option("wordWrapEnabled");
            var needSynchronizeRows = isColumnWidthsSynced || isColumnWidthChanged && wordWrapEnabled;
            if (needSynchronizeRows) {
                this.synchronizeRows()
            }
        };
        _proto.setFixedTableColumnWidths = function(columns, widths) {
            if (!this._fixedTableElement || !widths) {
                return
            }
            var $cols = this._fixedTableElement.children("colgroup").children("col");
            $cols.toArray().forEach((function(col) {
                return col.removeAttribute("style")
            }));
            var columnIndex = 0;
            columns.forEach((function(column) {
                if (column.colspan) {
                    columnIndex += column.colspan;
                    return
                }
                var colWidth = (0, _m_columns_view.normalizeWidth)(widths[columnIndex]);
                if ((0, _type.isDefined)(colWidth)) {
                    (0, _style.setWidth)($cols.eq(columnIndex), colWidth)
                }
                columnIndex += 1
            }))
        };
        _proto._getClientHeight = function(element) {
            var boundingClientRectElement = element.getBoundingClientRect && (0, _position.getBoundingRect)(element);
            return boundingClientRectElement && boundingClientRectElement.height ? boundingClientRectElement.height : element.clientHeight
        };
        _proto.synchronizeRows = function() {
            var _this2 = this;
            var rowHeights = [];
            var fixedRowHeights = [];
            var rowIndex;
            var $rowElements;
            var $fixedRowElements;
            var $contentElement;
            this.waitAsyncTemplates(true).done((function() {
                if (_this2._isFixedColumns && _this2._tableElement && _this2._fixedTableElement) {
                    var heightTable = _this2._getClientHeight(_this2._tableElement.get(0));
                    var heightFixedTable = _this2._getClientHeight(_this2._fixedTableElement.get(0));
                    $rowElements = _this2._getRowElements(_this2._tableElement);
                    $fixedRowElements = _this2._getRowElements(_this2._fixedTableElement);
                    $contentElement = _this2._findContentElement();
                    if (heightTable !== heightFixedTable) {
                        $contentElement && $contentElement.css("height", heightTable);
                        $rowElements.css("height", "");
                        $fixedRowElements.css("height", "");
                        for (rowIndex = 0; rowIndex < $rowElements.length; rowIndex++) {
                            rowHeights.push(_this2._getClientHeight($rowElements.get(rowIndex)));
                            fixedRowHeights.push(_this2._getClientHeight($fixedRowElements.get(rowIndex)))
                        }
                        for (rowIndex = 0; rowIndex < $rowElements.length; rowIndex++) {
                            var rowHeight = rowHeights[rowIndex];
                            var fixedRowHeight = fixedRowHeights[rowIndex];
                            if (rowHeight > fixedRowHeight) {
                                $fixedRowElements.eq(rowIndex).css("height", rowHeight)
                            } else if (rowHeight < fixedRowHeight) {
                                $rowElements.eq(rowIndex).css("height", fixedRowHeight)
                            }
                        }
                        $contentElement && $contentElement.css("height", "")
                    }
                }
            }))
        };
        _proto.setScrollerSpacing = function(width, hWidth) {
            var rtlEnabled = this.option("rtlEnabled");
            _Base.prototype.setScrollerSpacing.call(this, width);
            this.element().children(".".concat(this.addWidgetPrefix(CONTENT_FIXED_CLASS))).css({
                paddingLeft: rtlEnabled ? width : "",
                paddingRight: !rtlEnabled ? width : ""
            })
        };
        return BaseFixedColumnsExtender
    }(Base)
};
var columnHeadersView = function(Base) {
    return function(_baseFixedColumns) {
        _inheritsLoose(ColumnHeadersViewFixedColumnsExtender, _baseFixedColumns);

        function ColumnHeadersViewFixedColumnsExtender() {
            return _baseFixedColumns.apply(this, arguments) || this
        }
        var _proto2 = ColumnHeadersViewFixedColumnsExtender.prototype;
        _proto2._getRowVisibleColumns = function(rowIndex) {
            if (this._isFixedTableRendering) {
                return this.getFixedColumns(rowIndex)
            }
            return _baseFixedColumns.prototype._getRowVisibleColumns.call(this, rowIndex)
        };
        _proto2.getContextMenuItems = function(options) {
            var _this3 = this;
            var column = options.column;
            var columnFixingOptions = this.option("columnFixing");
            var items = _baseFixedColumns.prototype.getContextMenuItems.call(this, options);
            if (options.row && "header" === options.row.rowType) {
                if (true === columnFixingOptions.enabled && column && column.allowFixing) {
                    var onItemClick = function(params) {
                        switch (params.itemData.value) {
                            case "none":
                                _this3._columnsController.columnOption(column.index, "fixed", false);
                                break;
                            case "left":
                                _this3._columnsController.columnOption(column.index, {
                                    fixed: true,
                                    fixedPosition: "left"
                                });
                                break;
                            case "right":
                                _this3._columnsController.columnOption(column.index, {
                                    fixed: true,
                                    fixedPosition: "right"
                                })
                        }
                    };
                    items = items || [];
                    items.push({
                        text: columnFixingOptions.texts.fix,
                        beginGroup: true,
                        items: [{
                            text: columnFixingOptions.texts.leftPosition,
                            value: "left",
                            disabled: column.fixed && (!column.fixedPosition || "left" === column.fixedPosition),
                            onItemClick: onItemClick
                        }, {
                            text: columnFixingOptions.texts.rightPosition,
                            value: "right",
                            disabled: column.fixed && "right" === column.fixedPosition,
                            onItemClick: onItemClick
                        }]
                    }, {
                        text: columnFixingOptions.texts.unfix,
                        value: "none",
                        disabled: !column.fixed,
                        onItemClick: onItemClick
                    })
                }
            }
            return items
        };
        _proto2.getFixedColumnElements = function(rowIndex) {
            if ((0, _type.isDefined)(rowIndex)) {
                return this._fixedTableElement && this._getRowElements(this._fixedTableElement).eq(rowIndex).children()
            }
            var columnElements = this.getColumnElements();
            var $transparentColumnElement = this.getTransparentColumnElement();
            if (columnElements && $transparentColumnElement && $transparentColumnElement.length) {
                var transparentColumnIndex = getTransparentColumnIndex(this.getFixedColumns());
                columnElements.splice(transparentColumnIndex, $transparentColumnElement.get(0).colSpan, $transparentColumnElement.get(0))
            }
            return columnElements
        };
        _proto2.getColumnWidths = function() {
            var fixedWidths;
            var result = _baseFixedColumns.prototype.getColumnWidths.call(this);
            var $fixedColumnElements = this.getFixedColumnElements();
            var fixedColumns = this.getFixedColumns();
            if (this._fixedTableElement) {
                if ($fixedColumnElements && $fixedColumnElements.length) {
                    fixedWidths = this._getWidths($fixedColumnElements)
                } else {
                    fixedWidths = _baseFixedColumns.prototype.getColumnWidths.call(this, this._fixedTableElement)
                }
            }
            return normalizeColumnWidths(fixedColumns, result, fixedWidths)
        };
        return ColumnHeadersViewFixedColumnsExtender
    }(baseFixedColumns(Base))
};
var rowsView = function(Base) {
    return function(_baseFixedColumns2) {
        _inheritsLoose(RowsViewFixedColumnsExtender, _baseFixedColumns2);

        function RowsViewFixedColumnsExtender() {
            return _baseFixedColumns2.apply(this, arguments) || this
        }
        var _proto3 = RowsViewFixedColumnsExtender.prototype;
        _proto3._detachHoverEvents = function() {
            var element = this.element();
            if (this._fixedTableElement && this._tableElement) {
                _events_engine.default.off(element, "mouseover mouseout", ".dx-data-row")
            }
        };
        _proto3._attachHoverEvents = function() {
            var _this4 = this;
            if (this._fixedTableElement && this._tableElement) {
                _events_engine.default.on(this.element(), "mouseover mouseout", ".dx-data-row", this.createAction((function(args) {
                    var event = args.event;
                    var rowIndex = _this4.getRowIndex((0, _renderer.default)(event.target).closest(".dx-row"));
                    var isHover = "mouseover" === event.type;
                    if (rowIndex >= 0) {
                        _this4._tableElement && _this4._getRowElements(_this4._tableElement).eq(rowIndex).toggleClass(HOVER_STATE_CLASS, isHover);
                        _this4._fixedTableElement && _this4._getRowElements(_this4._fixedTableElement).eq(rowIndex).toggleClass(HOVER_STATE_CLASS, isHover)
                    }
                })))
            }
        };
        _proto3._getScrollDelay = function() {
            var _a;
            var hasResizeTimeout = null === (_a = this.getController("resizing")) || void 0 === _a ? void 0 : _a.hasResizeTimeout();
            if (hasResizeTimeout) {
                return this.option("scrolling.updateTimeout")
            }
            return _browser.default.mozilla ? 60 : 0
        };
        _proto3._findContentElement = function(isFixedTableRendering) {
            var _this5 = this;
            var $content;
            var scrollTop;
            var contentClass = this.addWidgetPrefix(CONTENT_CLASS);
            var element = this.element();
            isFixedTableRendering = this._isFixedTableRendering || isFixedTableRendering;
            if (element && isFixedTableRendering) {
                $content = element.children(".".concat(contentClass));
                var scrollable = this.getScrollable();
                if (!$content.length && scrollable) {
                    $content = (0, _renderer.default)("<div>").addClass(contentClass);
                    _events_engine.default.on($content, "scroll", (function(e) {
                        var target = e.target;
                        var scrollDelay = _this5._getScrollDelay();
                        clearTimeout(_this5._fixedScrollTimeout);
                        _this5._fixedScrollTimeout = setTimeout((function() {
                            scrollTop = (0, _renderer.default)(target).scrollTop();
                            scrollable.scrollTo({
                                y: scrollTop
                            })
                        }), scrollDelay)
                    }));
                    _events_engine.default.on($content, _wheel.name, (function(e) {
                        var $nearestScrollable = (0, _renderer.default)(e.target).closest(".dx-scrollable");
                        var shouldScroll = false;
                        if (scrollable && scrollable.$element().is($nearestScrollable)) {
                            shouldScroll = true
                        } else {
                            var nearestScrollableInstance = $nearestScrollable.length && _ui.default.getInstance($nearestScrollable.get(0));
                            var nearestScrollableHasVerticalScrollbar = nearestScrollableInstance && nearestScrollableInstance.scrollHeight() - nearestScrollableInstance.clientHeight() > 0;
                            shouldScroll = nearestScrollableInstance && !nearestScrollableHasVerticalScrollbar
                        }
                        if (shouldScroll) {
                            scrollTop = scrollable.scrollTop();
                            scrollable.scrollTo({
                                y: scrollTop - e.delta
                            });
                            var scrollableTop = scrollable.scrollTop() + scrollable.clientHeight();
                            var scrollableHeight = scrollable.scrollHeight() + _this5.getScrollbarWidth();
                            var isPreventDefault = scrollable.scrollTop() > 0 && scrollableTop < scrollableHeight;
                            if (isPreventDefault) {
                                return false
                            }
                        }
                        return
                    }));
                    $content.appendTo(element)
                }
                return $content
            }
            return _baseFixedColumns2.prototype._findContentElement.call(this)
        };
        _proto3._updateScrollable = function() {
            _baseFixedColumns2.prototype._updateScrollable.call(this);
            var scrollable = this.getScrollable();
            if (null === scrollable || void 0 === scrollable ? void 0 : scrollable._disposed) {
                return
            }
            var scrollTop = scrollable && scrollable.scrollOffset().top;
            this._updateFixedTablePosition(scrollTop)
        };
        _proto3._renderContent = function(contentElement, tableElement, isFixedTableRendering) {
            if (this._isFixedTableRendering || isFixedTableRendering) {
                return contentElement.empty().addClass("".concat(this.addWidgetPrefix(CONTENT_CLASS), " ").concat(this.addWidgetPrefix(CONTENT_FIXED_CLASS))).append(tableElement)
            }
            return _baseFixedColumns2.prototype._renderContent.call(this, contentElement, tableElement)
        };
        _proto3._getGroupCellOptions = function(options) {
            if (this._isFixedTableRendering) {
                return _baseFixedColumns2.prototype._getGroupCellOptions.call(this, (0, _extend.extend)({}, options, {
                    columns: this._columnsController.getVisibleColumns()
                }))
            }
            return _baseFixedColumns2.prototype._getGroupCellOptions.call(this, options)
        };
        _proto3._renderGroupedCells = function($row, options) {
            return _baseFixedColumns2.prototype._renderGroupedCells.call(this, $row, (0, _extend.extend)({}, options, {
                columns: this._columnsController.getVisibleColumns()
            }))
        };
        _proto3._renderGroupSummaryCells = function($row, options) {
            if (this._isFixedTableRendering) {
                _baseFixedColumns2.prototype._renderGroupSummaryCells.call(this, $row, (0, _extend.extend)({}, options, {
                    columns: this._columnsController.getVisibleColumns()
                }))
            } else {
                _baseFixedColumns2.prototype._renderGroupSummaryCells.call(this, $row, options)
            }
        };
        _proto3._hasAlignByColumnSummaryItems = function(columnIndex, options) {
            var result = _baseFixedColumns2.prototype._hasAlignByColumnSummaryItems.apply(this, arguments);
            var column = options.columns[columnIndex];
            if (options.isFixed) {
                return column.fixed && (result || "right" === column.fixedPosition)
            }
            return result && (!this._isFixedColumns || !column.fixed)
        };
        _proto3._renderGroupSummaryCellsCore = function($groupCell, options, groupCellColSpan, alignByColumnCellCount) {
            var alignByFixedColumnCellCount;
            if (this._isFixedTableRendering) {
                options.isFixed = true;
                alignByFixedColumnCellCount = this._getAlignByColumnCellCount(groupCellColSpan, options);
                options.isFixed = false;
                var startColumnIndex = options.columns.length - alignByFixedColumnCellCount;
                options = (0, _extend.extend)({}, options, {
                    columns: this.getFixedColumns()
                });
                var transparentColumnIndex = getTransparentColumnIndex(options.columns);
                if (startColumnIndex < transparentColumnIndex) {
                    alignByFixedColumnCellCount -= options.columns[transparentColumnIndex].colspan - 1 || 0;
                    groupCellColSpan -= options.columns[transparentColumnIndex].colspan - 1 || 0
                } else if (alignByColumnCellCount > 0) {
                    $groupCell.css("visibility", "hidden")
                }
                alignByColumnCellCount = alignByFixedColumnCellCount
            }
            _baseFixedColumns2.prototype._renderGroupSummaryCellsCore.call(this, $groupCell, options, groupCellColSpan, alignByColumnCellCount)
        };
        _proto3._getSummaryCellIndex = function(columnIndex, columns) {
            if (this._isFixedTableRendering) {
                var transparentColumnIndex = getTransparentColumnIndex(columns);
                if (columnIndex > transparentColumnIndex) {
                    columnIndex += columns[transparentColumnIndex].colspan - 1
                }
                return columnIndex
            }
            return _baseFixedColumns2.prototype._getSummaryCellIndex.apply(this, arguments)
        };
        _proto3._renderCore = function(change) {
            this._detachHoverEvents();
            var deferred = _baseFixedColumns2.prototype._renderCore.call(this, change);
            var isFixedColumns = this._isFixedColumns;
            this.element().toggleClass(FIXED_COLUMNS_CLASS, isFixedColumns);
            if (this.option("hoverStateEnabled") && isFixedColumns) {
                this._attachHoverEvents()
            }
            return deferred
        };
        _proto3.setRowsOpacity = function(columnIndex, value) {
            _baseFixedColumns2.prototype.setRowsOpacity.call(this, columnIndex, value);
            var $rows = this._getRowElements(this._fixedTableElement);
            this._setRowsOpacityCore($rows, this.getFixedColumns(), columnIndex, value)
        };
        _proto3.optionChanged = function(args) {
            _baseFixedColumns2.prototype.optionChanged.call(this, args);
            if ("hoverStateEnabled" === args.name && this._isFixedColumns) {
                args.value ? this._attachHoverEvents() : this._detachHoverEvents()
            }
        };
        _proto3.getCellIndex = function($cell) {
            var $fixedTable = this._fixedTableElement;
            var cellIndex = 0;
            if ($fixedTable && $cell.is("td") && $cell.closest($fixedTable).length) {
                var columns = this.getFixedColumns();
                (0, _iterator.each)(columns, (function(index, column) {
                    if (index === $cell[0].cellIndex) {
                        return false
                    }
                    if (column.colspan) {
                        cellIndex += column.colspan;
                        return
                    }
                    cellIndex++;
                    return
                }));
                return cellIndex
            }
            return _baseFixedColumns2.prototype.getCellIndex.apply(this, arguments)
        };
        _proto3._updateFixedTablePosition = function(scrollTop, needFocus) {
            if (this._fixedTableElement && this._tableElement) {
                var $focusedElement;
                var editorFactory = this.getController("editorFactory");
                this._fixedTableElement.parent().scrollTop(scrollTop);
                if (needFocus && editorFactory) {
                    $focusedElement = editorFactory.focus();
                    $focusedElement && editorFactory.focus($focusedElement)
                }
            }
        };
        _proto3.setScrollerSpacing = function(vWidth, hWidth) {
            var styles = {
                marginBottom: 0
            };
            var $fixedContent = this.element().children(".".concat(this.addWidgetPrefix(CONTENT_FIXED_CLASS)));
            if ($fixedContent.length && this._fixedTableElement) {
                $fixedContent.css(styles);
                this._fixedTableElement.css(styles);
                styles[this.option("rtlEnabled") ? "marginLeft" : "marginRight"] = vWidth;
                styles.marginBottom = hWidth;
                var useNativeScrolling = this._scrollable && this._scrollable.option("useNative");
                (useNativeScrolling ? $fixedContent : this._fixedTableElement).css(styles)
            }
        };
        _proto3._getElasticScrollTop = function(e) {
            var elasticScrollTop = 0;
            if (e.scrollOffset.top < 0) {
                elasticScrollTop = -e.scrollOffset.top
            } else if (e.reachedBottom) {
                var $scrollableContent = (0, _renderer.default)(e.component.content());
                var $scrollableContainer = (0, _renderer.default)(e.component.container());
                var maxScrollTop = Math.max($scrollableContent.get(0).clientHeight - $scrollableContainer.get(0).clientHeight, 0);
                elasticScrollTop = Math.min(maxScrollTop - e.scrollOffset.top, 0)
            }
            return Math.floor(elasticScrollTop)
        };
        _proto3._applyElasticScrolling = function(e) {
            if (this._fixedTableElement) {
                var elasticScrollTop = this._getElasticScrollTop(e);
                if (0 !== Math.ceil(elasticScrollTop)) {
                    (0, _translator.move)(this._fixedTableElement, {
                        top: elasticScrollTop
                    })
                } else {
                    this._fixedTableElement.css("transform", "")
                }
            }
        };
        _proto3._handleScroll = function(e) {
            this._updateFixedTablePosition(e.scrollOffset.top, true);
            this._applyElasticScrolling(e);
            _baseFixedColumns2.prototype._handleScroll.call(this, e)
        };
        _proto3._updateContentPosition = function(isRender) {
            _baseFixedColumns2.prototype._updateContentPosition.apply(this, arguments);
            if (!isRender) {
                this._updateFixedTablePosition(this._scrollTop)
            }
        };
        _proto3._afterRowPrepared = function(e) {
            if (this._isFixedTableRendering) {
                return
            }
            _baseFixedColumns2.prototype._afterRowPrepared.call(this, e)
        };
        _proto3._scrollToElement = function($element) {
            _baseFixedColumns2.prototype._scrollToElement.call(this, $element, this.getFixedColumnsOffset())
        };
        _proto3.dispose = function() {
            _baseFixedColumns2.prototype.dispose.apply(this, arguments);
            clearTimeout(this._fixedScrollTimeout)
        };
        return RowsViewFixedColumnsExtender
    }(baseFixedColumns(Base))
};
var footerView = function(Base) {
    return function(_baseFixedColumns3) {
        _inheritsLoose(FooterViewFixedColumnsExtender, _baseFixedColumns3);

        function FooterViewFixedColumnsExtender() {
            return _baseFixedColumns3.apply(this, arguments) || this
        }
        return FooterViewFixedColumnsExtender
    }(baseFixedColumns(Base))
};
var normalizeColumnIndicesByPoints = function(columns, fixedColumns, pointsByColumns) {
    var transparentColumnIndex = getTransparentColumnIndex(fixedColumns);
    var correctIndex = columns.length - fixedColumns.length;
    (0, _iterator.each)(pointsByColumns, (function(_, point) {
        if (point.index > transparentColumnIndex) {
            point.columnIndex += correctIndex;
            point.index += correctIndex
        }
    }));
    return pointsByColumns
};
var draggingHeader = function(Base) {
    return function(_Base2) {
        _inheritsLoose(DraggingHeaderColumnFixingExtender, _Base2);

        function DraggingHeaderColumnFixingExtender() {
            return _Base2.apply(this, arguments) || this
        }
        var _proto4 = DraggingHeaderColumnFixingExtender.prototype;
        _proto4._generatePointsByColumns = function(options) {
            var visibleColumns = options.columns;
            var targetDraggingPanel = options.targetDraggingPanel;
            if (targetDraggingPanel && "headers" === targetDraggingPanel.getName() && targetDraggingPanel.isFixedColumns()) {
                if (options.sourceColumn.fixed) {
                    if (!options.rowIndex) {
                        options.columnElements = targetDraggingPanel.getFixedColumnElements(0)
                    }
                    options.columns = targetDraggingPanel.getFixedColumns(options.rowIndex);
                    var pointsByColumns = _Base2.prototype._generatePointsByColumns.call(this, options);
                    normalizeColumnIndicesByPoints(visibleColumns, options.columns, pointsByColumns);
                    return pointsByColumns
                }
            }
            return _Base2.prototype._generatePointsByColumns.call(this, options)
        };
        _proto4._pointCreated = function(point, columns, location, sourceColumn) {
            var result = _Base2.prototype._pointCreated.apply(this, arguments);
            var targetColumn = columns[point.columnIndex];
            var $transparentColumn = this._columnHeadersView.getTransparentColumnElement();
            if (!result && "headers" === location && $transparentColumn && $transparentColumn.length) {
                var boundingRect = (0, _position.getBoundingRect)($transparentColumn.get(0));
                if (sourceColumn && sourceColumn.fixed) {
                    return "right" === sourceColumn.fixedPosition ? point.x < boundingRect.right : point.x > boundingRect.left
                }
                if (targetColumn && targetColumn.fixed && "right" !== targetColumn.fixedPosition) {
                    return true
                }
                return point.x < boundingRect.left || point.x > boundingRect.right
            }
            return result
        };
        return DraggingHeaderColumnFixingExtender
    }(Base)
};
var columnsResizer = function(Base) {
    return function(_Base3) {
        _inheritsLoose(ColumnResizerColumnFixingExtender, _Base3);

        function ColumnResizerColumnFixingExtender() {
            return _Base3.apply(this, arguments) || this
        }
        var _proto5 = ColumnResizerColumnFixingExtender.prototype;
        _proto5._generatePointsByColumns = function() {
            var that = this;
            var columnsController = that._columnsController;
            var columns = columnsController && that._columnsController.getVisibleColumns();
            var fixedColumns = columnsController && that._columnsController.getFixedColumns();
            var transparentColumnIndex = getTransparentColumnIndex(fixedColumns);
            var correctIndex = columns.length - fixedColumns.length;
            var cells = that._columnHeadersView.getFixedColumnElements();
            _Base3.prototype._generatePointsByColumns.call(this);
            if (cells && cells.length > 0) {
                that._pointsByFixedColumns = _m_utils.default.getPointsByColumns(cells, (function(point) {
                    if (point.index > transparentColumnIndex) {
                        point.columnIndex += correctIndex;
                        point.index += correctIndex
                    }
                    return that._pointCreated(point, columns.length, columns)
                }))
            }
        };
        _proto5._getTargetPoint = function(pointsByColumns, currentX, deltaX) {
            var $transparentColumn = this._columnHeadersView.getTransparentColumnElement();
            if ($transparentColumn && $transparentColumn.length) {
                var boundingRect = (0, _position.getBoundingRect)($transparentColumn.get(0));
                if (currentX <= boundingRect.left || currentX >= boundingRect.right) {
                    return _Base3.prototype._getTargetPoint.call(this, this._pointsByFixedColumns, currentX, deltaX)
                }
            }
            return _Base3.prototype._getTargetPoint.call(this, pointsByColumns, currentX, deltaX)
        };
        return ColumnResizerColumnFixingExtender
    }(Base)
};
var columnFixingModule = {
    defaultOptions: function() {
        return {
            columnFixing: {
                enabled: false,
                texts: {
                    fix: _message.default.format("dxDataGrid-columnFixingFix"),
                    unfix: _message.default.format("dxDataGrid-columnFixingUnfix"),
                    leftPosition: _message.default.format("dxDataGrid-columnFixingLeftPosition"),
                    rightPosition: _message.default.format("dxDataGrid-columnFixingRightPosition")
                }
            }
        }
    },
    extenders: {
        views: {
            columnHeadersView: columnHeadersView,
            rowsView: rowsView,
            footerView: footerView
        },
        controllers: {
            draggingHeader: draggingHeader,
            columnsResizer: columnsResizer
        }
    }
};
exports.columnFixingModule = columnFixingModule;
