/**
 * DevExtreme (cjs/__internal/grids/grid_core/adaptivity/m_adaptivity.js)
 * Version: 23.1.10 (build 24175-0109)
 * Build date: Sun Jun 23 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.adaptivityModule = exports.AdaptiveColumnsController = void 0;
var _guid = _interopRequireDefault(require("../../../../core/guid"));
var _renderer = _interopRequireDefault(require("../../../../core/renderer"));
var _common = require("../../../../core/utils/common");
var _deferred = require("../../../../core/utils/deferred");
var _dom = require("../../../../core/utils/dom");
var _extend = require("../../../../core/utils/extend");
var _iterator = require("../../../../core/utils/iterator");
var _size = require("../../../../core/utils/size");
var _type = require("../../../../core/utils/type");
var _click = require("../../../../events/click");
var _events_engine = _interopRequireDefault(require("../../../../events/core/events_engine"));
var _remove = require("../../../../events/remove");
var _index = require("../../../../events/utils/index");
var _message = _interopRequireDefault(require("../../../../localization/message"));
var _form = _interopRequireDefault(require("../../../../ui/form"));
var _themes = require("../../../../ui/themes");
var _m_modules = _interopRequireDefault(require("../m_modules"));
var _m_utils = _interopRequireDefault(require("../m_utils"));

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 COLUMN_HEADERS_VIEW = "columnHeadersView";
var ROWS_VIEW = "rowsView";
var FOOTER_VIEW = "footerView";
var COLUMN_VIEWS = [COLUMN_HEADERS_VIEW, ROWS_VIEW, FOOTER_VIEW];
var ADAPTIVE_NAMESPACE = "dxDataGridAdaptivity";
var HIDDEN_COLUMNS_WIDTH = "adaptiveHidden";
var ADAPTIVE_ROW_TYPE = "detailAdaptive";
var FORM_ITEM_CONTENT_CLASS = "dx-field-item-content";
var FORM_ITEM_MODIFIED = "dx-item-modified";
var HIDDEN_COLUMN_CLASS = "hidden-column";
var ADAPTIVE_COLUMN_BUTTON_CLASS = "adaptive-more";
var ADAPTIVE_COLUMN_NAME_CLASS = "dx-command-adaptive";
var COMMAND_ADAPTIVE_HIDDEN_CLASS = "dx-command-adaptive-hidden";
var ADAPTIVE_DETAIL_ROW_CLASS = "dx-adaptive-detail-row";
var ADAPTIVE_ITEM_TEXT_CLASS = "dx-adaptive-item-text";
var MASTER_DETAIL_CELL_CLASS = "dx-master-detail-cell";
var LAST_DATA_CELL_CLASS = "dx-last-data-cell";
var ADAPTIVE_COLUMN_NAME = "adaptive";
var EDIT_MODE_BATCH = "batch";
var EDIT_MODE_ROW = "row";
var EDIT_MODE_FORM = "form";
var EDIT_MODE_POPUP = "popup";
var REVERT_TOOLTIP_CLASS = "revert-tooltip";
var GROUP_CELL_CLASS = "dx-group-cell";
var GROUP_ROW_CLASS = "dx-group-row";
var EXPAND_ARIA_NAME = "dxDataGrid-ariaAdaptiveExpand";
var COLLAPSE_ARIA_NAME = "dxDataGrid-ariaAdaptiveCollapse";
var LEGACY_SCROLLING_MODE = "scrolling.legacyMode";

function getColumnId(that, column) {
    return that._columnsController.getColumnId(column)
}

function getDataCellElements($row) {
    return $row.find("td:not(.dx-datagrid-hidden-column):not([class*='dx-command-'])")
}

function adaptiveCellTemplate(container, options) {
    var $adaptiveColumnButton;
    var $container = (0, _renderer.default)(container);
    var adaptiveColumnsController = options.component.getController("adaptiveColumns");
    if ("data" === options.rowType) {
        $adaptiveColumnButton = (0, _renderer.default)("<span>").addClass(adaptiveColumnsController.addWidgetPrefix(ADAPTIVE_COLUMN_BUTTON_CLASS));
        _events_engine.default.on($adaptiveColumnButton, (0, _index.addNamespace)(_click.name, ADAPTIVE_NAMESPACE), adaptiveColumnsController.createAction((function() {
            adaptiveColumnsController.toggleExpandAdaptiveDetailRow(options.key)
        })));
        $adaptiveColumnButton.appendTo($container)
    } else {
        _m_utils.default.setEmptyText($container)
    }
}

function focusCellHandler(e) {
    var _a;
    var $nextCell = null === (_a = e.data) || void 0 === _a ? void 0 : _a.$nextCell;
    _events_engine.default.off($nextCell, "focus", focusCellHandler);
    _events_engine.default.trigger($nextCell, "dxclick")
}
var AdaptiveColumnsController = function(_modules$ViewControll) {
    _inheritsLoose(AdaptiveColumnsController, _modules$ViewControll);

    function AdaptiveColumnsController() {
        return _modules$ViewControll.apply(this, arguments) || this
    }
    var _proto = AdaptiveColumnsController.prototype;
    _proto.init = function() {
        var _this = this;
        this._columnsController = this.getController("columns");
        this._dataController = this.getController("data");
        this._editingController = this.getController("editing");
        this._keyboardNavigationController = this.getController("keyboardNavigation");
        this._rowsView = this.getView("rowsView");
        this._columnsController.addCommandColumn({
            type: ADAPTIVE_COLUMN_NAME,
            command: ADAPTIVE_COLUMN_NAME,
            visible: true,
            adaptiveHidden: true,
            cssClass: ADAPTIVE_COLUMN_NAME_CLASS,
            alignment: "center",
            width: "auto",
            cellTemplate: adaptiveCellTemplate,
            fixedPosition: "right"
        });
        this._columnsController.columnsChanged.add((function() {
            var isAdaptiveVisible = !!_this.updateHidingQueue(_this._columnsController.getColumns()).length;
            _this._columnsController.columnOption("command:adaptive", "adaptiveHidden", !isAdaptiveVisible, true)
        }));
        this._hidingColumnsQueue = [];
        this._hiddenColumns = [];
        this.createAction("onAdaptiveDetailRowPreparing");
        _modules$ViewControll.prototype.init.call(this)
    };
    _proto.optionChanged = function(args) {
        if ("columnHidingEnabled" === args.name) {
            this._columnsController.columnOption("command:adaptive", "adaptiveHidden", !args.value)
        }
        _modules$ViewControll.prototype.optionChanged.call(this, args)
    };
    _proto.publicMethods = function() {
        return ["isAdaptiveDetailRowExpanded", "expandAdaptiveDetailRow", "collapseAdaptiveDetailRow"]
    };
    _proto._isRowEditMode = function() {
        var editMode = this._getEditMode();
        return editMode === EDIT_MODE_ROW
    };
    _proto._isItemModified = function(item, cellOptions) {
        var columnIndex = this._columnsController.getVisibleIndex(item.column.index);
        var rowIndex = this._dataController.getRowIndexByKey(cellOptions.key);
        var row = this._dataController.items()[rowIndex + 1];
        return row && row.modifiedValues && (0, _type.isDefined)(row.modifiedValues[columnIndex])
    };
    _proto._renderFormViewTemplate = function(item, cellOptions, $container) {
        var that = this;
        var column = item.column;
        var focusAction = that.createAction((function() {
            if (that._editingController.isEditing()) {
                _events_engine.default.trigger($container, _click.name)
            }
        }));
        var rowData = cellOptions.row.data;
        var value = column.calculateCellValue(rowData);
        var displayValue = _m_utils.default.getDisplayValue(column, value, rowData, cellOptions.rowType);
        var text = _m_utils.default.formatValue(displayValue, column);
        var isCellOrBatchEditMode = this._editingController.isCellOrBatchEditMode();
        var rowsView = that._rowsView;
        if (column.allowEditing && this._keyboardNavigationController.isKeyboardEnabled()) {
            $container.attr("tabIndex", that.option("tabIndex"));
            if (isCellOrBatchEditMode) {
                _events_engine.default.off($container, "focus", focusAction);
                _events_engine.default.on($container, "focus", focusAction)
            }
        }
        if (column.cellTemplate) {
            var templateOptions = (0, _extend.extend)({}, cellOptions, {
                value: value,
                displayValue: displayValue,
                text: text,
                column: column
            });
            rowsView.renderTemplate($container, column.cellTemplate, templateOptions, (0, _dom.isElementInDom)($container)).done((function() {
                rowsView._cellPrepared($container, cellOptions)
            }))
        } else {
            var container = $container.get(0);
            if (column.encodeHtml) {
                container.textContent = text
            } else {
                container.innerHTML = text
            }
            $container.addClass(ADAPTIVE_ITEM_TEXT_CLASS);
            if (!(0, _type.isDefined)(text) || "" === text) {
                $container.html("&nbsp;")
            }
            if (!that._isRowEditMode()) {
                if (that._isItemModified(item, cellOptions)) {
                    $container.addClass(FORM_ITEM_MODIFIED)
                }
            }
            rowsView._cellPrepared($container, cellOptions)
        }
    };
    _proto._getTemplate = function(item, cellOptions, updateForm) {
        var that = this;
        var column = item.column;
        var editingController = this._editingController;
        return function(options, container) {
            var $container = (0, _renderer.default)(container);
            var columnIndex = that._columnsController.getVisibleIndex(column.index);
            var templateOptions = (0, _extend.extend)({}, cellOptions);
            var renderFormTemplate = function() {
                var isItemEdited = that._isItemEdited(item);
                templateOptions.value = cellOptions.row.values[columnIndex];
                if (isItemEdited || column.showEditorAlways) {
                    editingController.renderFormEditorTemplate(templateOptions, item, options, $container, !isItemEdited)
                } else {
                    templateOptions.column = column;
                    templateOptions.columnIndex = columnIndex;
                    that._renderFormViewTemplate(item, templateOptions, $container)
                }
            };
            renderFormTemplate();
            if (templateOptions.watch) {
                var dispose = templateOptions.watch((function() {
                    return {
                        isItemEdited: that._isItemEdited(item),
                        value: cellOptions.row.values[columnIndex]
                    }
                }), (function() {
                    $container.contents().remove();
                    $container.removeClass(ADAPTIVE_ITEM_TEXT_CLASS);
                    renderFormTemplate()
                }));
                _events_engine.default.on($container, _remove.removeEvent, dispose)
            }
        }
    };
    _proto._isVisibleColumnsValid = function(visibleColumns) {
        if (visibleColumns < 2) {
            return false
        }
        if (visibleColumns.length - function() {
                var result = 0;
                for (var j = 0; j < visibleColumns.length; j++) {
                    var visibleColumn = visibleColumns[j];
                    if (visibleColumn.command) {
                        result++
                    }
                }
                return result
            }() <= 1) {
            return false
        }
        return true
    };
    _proto._calculatePercentWidths = function(widths, visibleColumns) {
        var that = this;
        var percentWidths = 0;
        visibleColumns.forEach((function(item, index) {
            if (widths[index] !== HIDDEN_COLUMNS_WIDTH) {
                percentWidths += that._getItemPercentWidth(item)
            }
        }));
        return percentWidths
    };
    _proto._isPercentWidth = function(width) {
        return (0, _type.isString)(width) && width.endsWith("%")
    };
    _proto._isColumnHidden = function(column) {
        return this._hiddenColumns.filter((function(hiddenColumn) {
            return hiddenColumn.index === column.index
        })).length > 0
    };
    _proto._getAverageColumnsWidth = function(containerWidth, columns, columnsCanFit) {
        var that = this;
        var fixedColumnsWidth = 0;
        var columnsWithoutFixedWidthCount = 0;
        columns.forEach((function(column) {
            if (!that._isColumnHidden(column)) {
                var width = column.width;
                if ((0, _type.isDefined)(width) && !isNaN(parseFloat(width))) {
                    fixedColumnsWidth += that._isPercentWidth(width) ? that._calculatePercentWidth({
                        visibleIndex: column.visibleIndex,
                        columnsCount: columns.length,
                        columnsCanFit: columnsCanFit,
                        bestFitWidth: column.bestFitWidth,
                        columnWidth: width,
                        containerWidth: containerWidth
                    }) : parseFloat(width)
                } else {
                    columnsWithoutFixedWidthCount++
                }
            }
        }));
        return (containerWidth - fixedColumnsWidth) / columnsWithoutFixedWidthCount
    };
    _proto._calculateColumnWidth = function(column, containerWidth, contentColumns, columnsCanFit) {
        var columnId = getColumnId(this, column);
        var widthOption = this._columnsController.columnOption(columnId, "width");
        var bestFitWidth = this._columnsController.columnOption(columnId, "bestFitWidth");
        var columnsCount = contentColumns.length;
        var colWidth;
        if (widthOption && "auto" !== widthOption) {
            if (this._isPercentWidth(widthOption)) {
                colWidth = this._calculatePercentWidth({
                    visibleIndex: column.visibleIndex,
                    columnsCount: columnsCount,
                    columnsCanFit: columnsCanFit,
                    bestFitWidth: bestFitWidth,
                    columnWidth: widthOption,
                    containerWidth: containerWidth
                })
            } else {
                return parseFloat(widthOption)
            }
        } else {
            var columnAutoWidth = this.option("columnAutoWidth");
            colWidth = columnAutoWidth || !!column.command ? bestFitWidth : this._getAverageColumnsWidth(containerWidth, contentColumns, columnsCanFit)
        }
        return colWidth
    };
    _proto._calculatePercentWidth = function(options) {
        var columnFitted = options.visibleIndex < options.columnsCount - 1 && options.columnsCanFit;
        var partialWidth = options.containerWidth * parseFloat(options.columnWidth) / 100;
        var resultWidth = options.columnsCanFit && partialWidth < options.bestFitWidth ? options.bestFitWidth : partialWidth;
        return columnFitted ? options.containerWidth * parseFloat(options.columnWidth) / 100 : resultWidth
    };
    _proto._getNotTruncatedColumnWidth = function(column, containerWidth, contentColumns, columnsCanFit) {
        var columnId = getColumnId(this, column);
        var widthOption = this._columnsController.columnOption(columnId, "width");
        var bestFitWidth = this._columnsController.columnOption(columnId, "bestFitWidth");
        if (widthOption && "auto" !== widthOption && !this._isPercentWidth(widthOption)) {
            return parseFloat(widthOption)
        }
        var colWidth = this._calculateColumnWidth(column, containerWidth, contentColumns, columnsCanFit);
        return colWidth < bestFitWidth ? null : colWidth
    };
    _proto._getItemPercentWidth = function(item) {
        var result = 0;
        if (item.width && this._isPercentWidth(item.width)) {
            result = parseFloat(item.width)
        }
        return result
    };
    _proto._getCommandColumnsWidth = function() {
        var that = this;
        var columns = that._columnsController.getVisibleColumns();
        var colWidth = 0;
        (0, _iterator.each)(columns, (function(index, column) {
            if (column.index < 0 || column.command) {
                colWidth += that._columnsController.columnOption(getColumnId(that, column), "bestFitWidth") || 0
            }
        }));
        return colWidth
    };
    _proto._isItemEdited = function(item) {
        if (this.isFormOrPopupEditMode()) {
            return false
        }
        if (this._isRowEditMode()) {
            var editRowKey = this.option("editing.editRowKey");
            if ((0, _common.equalByValue)(editRowKey, this._dataController.adaptiveExpandedKey())) {
                return true
            }
        } else {
            var rowIndex = this._dataController.getRowIndexByKey(this._dataController.adaptiveExpandedKey()) + 1;
            var columnIndex = this._columnsController.getVisibleIndex(item.column.index);
            return this._editingController.isEditCell(rowIndex, columnIndex)
        }
        return
    };
    _proto._getFormItemsByHiddenColumns = function(hiddenColumns) {
        var items = [];
        (0, _iterator.each)(hiddenColumns, (function(_, column) {
            items.push({
                column: column,
                name: column.name,
                dataField: column.dataField,
                visibleIndex: column.visibleIndex
            })
        }));
        return items
    };
    _proto._getAdaptiveColumnVisibleIndex = function(visibleColumns) {
        for (var i = 0; i < visibleColumns.length; i++) {
            var column = visibleColumns[i];
            if (column.command === ADAPTIVE_COLUMN_NAME) {
                return i
            }
        }
        return
    };
    _proto._hideAdaptiveColumn = function(resultWidths, visibleColumns) {
        var visibleIndex = this._getAdaptiveColumnVisibleIndex(visibleColumns);
        if ((0, _type.isDefined)(visibleIndex)) {
            resultWidths[visibleIndex] = HIDDEN_COLUMNS_WIDTH;
            this._hideVisibleColumn({
                isCommandColumn: true,
                visibleIndex: visibleIndex
            })
        }
    };
    _proto._showHiddenCellsInView = function(_ref) {
        var $cells = _ref.$cells,
            isCommandColumn = _ref.isCommandColumn;
        var cssClassNameToRemove = this.addWidgetPrefix(HIDDEN_COLUMN_CLASS);
        if (isCommandColumn) {
            cssClassNameToRemove = COMMAND_ADAPTIVE_HIDDEN_CLASS;
            $cells.attr({
                tabIndex: 0,
                "aria-hidden": null
            }).removeClass(cssClassNameToRemove)
        } else {
            $cells.removeClass(cssClassNameToRemove)
        }
    };
    _proto._showHiddenColumns = function() {
        for (var i = 0; i < COLUMN_VIEWS.length; i++) {
            var view = this.getView(COLUMN_VIEWS[i]);
            if (view && view.isVisible() && view.element()) {
                var viewName = view.name;
                var $hiddenCommandCells = view.element().find(".".concat(COMMAND_ADAPTIVE_HIDDEN_CLASS));
                this._showHiddenCellsInView({
                    viewName: viewName,
                    $cells: $hiddenCommandCells,
                    isCommandColumn: true
                });
                var $hiddenCells = view.element().find(".".concat(this.addWidgetPrefix(HIDDEN_COLUMN_CLASS)));
                this._showHiddenCellsInView({
                    viewName: viewName,
                    $cells: $hiddenCells
                })
            }
        }
    };
    _proto._isCellValid = function($cell) {
        return $cell && $cell.length && !$cell.hasClass(MASTER_DETAIL_CELL_CLASS) && !$cell.hasClass(GROUP_CELL_CLASS)
    };
    _proto._hideVisibleColumn = function(_ref2) {
        var isCommandColumn = _ref2.isCommandColumn,
            visibleIndex = _ref2.visibleIndex;
        var that = this;
        COLUMN_VIEWS.forEach((function(viewName) {
            var view = that.getView(viewName);
            view && that._hideVisibleColumnInView({
                view: view,
                isCommandColumn: isCommandColumn,
                visibleIndex: visibleIndex
            })
        }))
    };
    _proto._hideVisibleColumnInView = function(_ref3) {
        var view = _ref3.view,
            isCommandColumn = _ref3.isCommandColumn,
            visibleIndex = _ref3.visibleIndex;
        var viewName = view.name;
        var $cellElement;
        var column = this._columnsController.getVisibleColumns()[visibleIndex];
        var editFormRowIndex = this._editingController && this._editingController.getEditFormRowIndex();
        if (view && view.isVisible() && column) {
            var rowsCount = view.getRowsCount();
            var $rowElements = view._getRowElements();
            for (var rowIndex = 0; rowIndex < rowsCount; rowIndex++) {
                var cancelClassAdding = rowIndex === editFormRowIndex && viewName === ROWS_VIEW && "popup" !== this.option("editing.mode");
                if (!cancelClassAdding) {
                    var currentVisibleIndex = viewName === COLUMN_HEADERS_VIEW ? this._columnsController.getVisibleIndex(column.index, rowIndex) : visibleIndex;
                    if (currentVisibleIndex >= 0) {
                        var $rowElement = $rowElements.eq(rowIndex);
                        $cellElement = this._findCellElementInRow($rowElement, currentVisibleIndex);
                        this._isCellValid($cellElement) && this._hideVisibleCellInView({
                            viewName: viewName,
                            isCommandColumn: isCommandColumn,
                            $cell: $cellElement
                        })
                    }
                }
            }
        }
    };
    _proto._findCellElementInRow = function($rowElement, visibleColumnIndex) {
        var $rowCells = $rowElement.children();
        var visibleIndex = visibleColumnIndex;
        var cellIsInsideGroup = false;
        if ($rowElement.hasClass(GROUP_ROW_CLASS)) {
            var $groupCell = $rowElement.find(".".concat(GROUP_CELL_CLASS));
            var colSpan = $groupCell.attr("colspan");
            if ($groupCell.length && (0, _type.isDefined)(colSpan)) {
                var groupCellLength = parseInt(colSpan);
                var endGroupIndex = $groupCell.index() + groupCellLength - 1;
                if (visibleColumnIndex > endGroupIndex) {
                    visibleIndex = visibleColumnIndex - groupCellLength + 1
                } else {
                    cellIsInsideGroup = true
                }
            }
        }
        var $cellElement = !cellIsInsideGroup ? $rowCells.eq(visibleIndex) : void 0;
        return $cellElement
    };
    _proto._hideVisibleCellInView = function(_ref4) {
        var $cell = _ref4.$cell,
            isCommandColumn = _ref4.isCommandColumn;
        var cssClassNameToAdd = isCommandColumn ? COMMAND_ADAPTIVE_HIDDEN_CLASS : this.addWidgetPrefix(HIDDEN_COLUMN_CLASS);
        $cell.attr({
            tabIndex: -1,
            "aria-hidden": true
        }).addClass(cssClassNameToAdd)
    };
    _proto._getEditMode = function() {
        return this._editingController.getEditMode()
    };
    _proto.isFormOrPopupEditMode = function() {
        var editMode = this._getEditMode();
        return editMode === EDIT_MODE_FORM || editMode === EDIT_MODE_POPUP
    };
    _proto.hideRedundantColumns = function(resultWidths, visibleColumns, hiddenQueue) {
        this._hiddenColumns = [];
        if (this._isVisibleColumnsValid(visibleColumns) && hiddenQueue.length) {
            var totalWidth = 0;
            var $rootElement = this.component.$element();
            var rootElementWidth = (0, _size.getWidth)($rootElement) - this._getCommandColumnsWidth();
            var getVisibleContentColumns = function() {
                var _this2 = this;
                return visibleColumns.filter((function(item) {
                    return !item.command && 0 === _this2._hiddenColumns.filter((function(i) {
                        return i.index === item.index
                    })).length
                }))
            }.bind(this);
            var visibleContentColumns = getVisibleContentColumns();
            var contentColumnsCount = visibleContentColumns.length;
            var i;
            var hasHiddenColumns;
            var needHideColumn;
            do {
                needHideColumn = false;
                totalWidth = 0;
                var percentWidths = this._calculatePercentWidths(resultWidths, visibleColumns);
                var columnsCanFit = percentWidths < 100 && 0 !== percentWidths;
                for (i = 0; i < visibleColumns.length; i++) {
                    var visibleColumn = visibleColumns[i];
                    var columnWidth = this._getNotTruncatedColumnWidth(visibleColumn, rootElementWidth, visibleContentColumns, columnsCanFit);
                    var columnId = getColumnId(this, visibleColumn);
                    var widthOption = this._columnsController.columnOption(columnId, "width");
                    var minWidth = this._columnsController.columnOption(columnId, "minWidth");
                    var columnBestFitWidth = this._columnsController.columnOption(columnId, "bestFitWidth");
                    if (resultWidths[i] === HIDDEN_COLUMNS_WIDTH) {
                        hasHiddenColumns = true;
                        continue
                    }
                    if (!columnWidth && !visibleColumn.command && !visibleColumn.fixed) {
                        needHideColumn = true;
                        break
                    }
                    if (!widthOption || "auto" === widthOption) {
                        columnWidth = Math.max(columnBestFitWidth || 0, minWidth || 0)
                    }
                    if (visibleColumn.command !== ADAPTIVE_COLUMN_NAME || hasHiddenColumns) {
                        totalWidth += columnWidth
                    }
                }
                needHideColumn = needHideColumn || totalWidth > (0, _size.getWidth)($rootElement);
                if (needHideColumn) {
                    var column = hiddenQueue.pop();
                    var visibleIndex = this._columnsController.getVisibleIndex(column.index);
                    rootElementWidth += this._calculateColumnWidth(column, rootElementWidth, visibleContentColumns, columnsCanFit);
                    this._hideVisibleColumn({
                        visibleIndex: visibleIndex
                    });
                    resultWidths[visibleIndex] = HIDDEN_COLUMNS_WIDTH;
                    this._hiddenColumns.push(column);
                    visibleContentColumns = getVisibleContentColumns()
                }
            } while (needHideColumn && visibleContentColumns.length > 1 && hiddenQueue.length);
            if (contentColumnsCount === visibleContentColumns.length) {
                this._hideAdaptiveColumn(resultWidths, visibleColumns)
            }
        } else {
            this._hideAdaptiveColumn(resultWidths, visibleColumns)
        }
    };
    _proto.getAdaptiveDetailItems = function() {
        return this._$itemContents
    };
    _proto.getItemContentByColumnIndex = function(visibleColumnIndex) {
        var $itemContent;
        for (var i = 0; i < this._$itemContents.length; i++) {
            $itemContent = this._$itemContents.eq(i);
            var item = $itemContent.data("dx-form-item");
            if (item && item.column && this._columnsController.getVisibleIndex(item.column.index) === visibleColumnIndex) {
                return $itemContent
            }
        }
    };
    _proto.toggleExpandAdaptiveDetailRow = function(key, alwaysExpanded) {
        if (!(this.isFormOrPopupEditMode() && this._editingController.isEditing())) {
            this._dataController.toggleExpandAdaptiveDetailRow(key, alwaysExpanded)
        }
    };
    _proto.createFormByHiddenColumns = function(container, options) {
        var that = this;
        var $container = (0, _renderer.default)(container);
        var userFormOptions = {
            items: that._getFormItemsByHiddenColumns(that._hiddenColumns),
            formID: "dx-".concat(new _guid.default)
        };
        var defaultFormOptions = (0, _themes.isMaterial)() ? {
            colCount: 2
        } : {};
        this.executeAction("onAdaptiveDetailRowPreparing", {
            formOptions: userFormOptions
        });
        that._$itemContents = null;
        that._form = that._createComponent((0, _renderer.default)("<div>").appendTo($container), _form.default, (0, _extend.extend)(defaultFormOptions, userFormOptions, {
            customizeItem: function(item) {
                var column = item.column || that._columnsController.columnOption(item.name || item.dataField);
                if (column) {
                    item.label = item.label || {};
                    item.label.text = item.label.text || column.caption;
                    item.column = column;
                    item.template = that._getTemplate(item, options, that.updateForm.bind(that))
                }
                userFormOptions.customizeItem && userFormOptions.customizeItem.call(this, item)
            },
            onContentReady: function(e) {
                userFormOptions.onContentReady && userFormOptions.onContentReady.call(this, e);
                that._$itemContents = $container.find(".".concat(FORM_ITEM_CONTENT_CLASS))
            }
        }))
    };
    _proto.hasAdaptiveDetailRowExpanded = function() {
        return (0, _type.isDefined)(this._dataController.adaptiveExpandedKey())
    };
    _proto.updateForm = function(hiddenColumns) {
        if (this.hasAdaptiveDetailRowExpanded()) {
            if (this._form && (0, _type.isDefined)(this._form._contentReadyAction)) {
                if (hiddenColumns && hiddenColumns.length) {
                    this._form.option("items", this._getFormItemsByHiddenColumns(hiddenColumns))
                } else {
                    this._form.repaint()
                }
            }
        }
    };
    _proto.updateHidingQueue = function(columns) {
        var hideableColumns = columns.filter((function(column) {
            return column.visible && !column.type && !column.fixed && !((0, _type.isDefined)(column.groupIndex) && column.groupIndex >= 0)
        }));
        var columnsHasHidingPriority;
        var i;
        this._hidingColumnsQueue = [];
        if (this.option("allowColumnResizing") && "widget" === this.option("columnResizingMode")) {
            return this._hidingColumnsQueue
        }
        for (i = 0; i < hideableColumns.length; i++) {
            if ((0, _type.isDefined)(hideableColumns[i].hidingPriority) && hideableColumns[i].hidingPriority >= 0) {
                columnsHasHidingPriority = true;
                this._hidingColumnsQueue[hideableColumns[i].hidingPriority] = hideableColumns[i]
            }
        }
        if (columnsHasHidingPriority) {
            this._hidingColumnsQueue.reverse()
        } else if (this.option("columnHidingEnabled")) {
            for (i = 0; i < hideableColumns.length; i++) {
                var visibleIndex = this._columnsController.getVisibleIndex(hideableColumns[i].index);
                this._hidingColumnsQueue[visibleIndex] = hideableColumns[i]
            }
        }
        this._hidingColumnsQueue = this._hidingColumnsQueue.filter(Object);
        return this._hidingColumnsQueue
    };
    _proto.getHiddenColumns = function() {
        return this._hiddenColumns
    };
    _proto.hasHiddenColumns = function() {
        return this._hiddenColumns.length > 0
    };
    _proto.getHidingColumnsQueue = function() {
        return this._hidingColumnsQueue
    };
    _proto.isAdaptiveDetailRowExpanded = function(key) {
        var dataController = this._dataController;
        return dataController.adaptiveExpandedKey() && (0, _common.equalByValue)(dataController.adaptiveExpandedKey(), key)
    };
    _proto.expandAdaptiveDetailRow = function(key) {
        if (!this.hasAdaptiveDetailRowExpanded()) {
            this.toggleExpandAdaptiveDetailRow(key)
        }
    };
    _proto.collapseAdaptiveDetailRow = function() {
        if (this.hasAdaptiveDetailRowExpanded()) {
            this.toggleExpandAdaptiveDetailRow()
        }
    };
    _proto.updateCommandAdaptiveAriaLabel = function(key, label) {
        var rowIndex = this._dataController.getRowIndexByKey(key);
        if (-1 === rowIndex) {
            return
        }
        var $row = (0, _renderer.default)(this.component.getRowElement(rowIndex));
        this.setCommandAdaptiveAriaLabel($row, label)
    };
    _proto.setCommandAdaptiveAriaLabel = function($row, labelName) {
        var $adaptiveCommand = $row.find(".dx-command-adaptive");
        $adaptiveCommand.attr("aria-label", _message.default.format(labelName))
    };
    return AdaptiveColumnsController
}(_m_modules.default.ViewController);
exports.AdaptiveColumnsController = AdaptiveColumnsController;
var keyboardNavigation = function(Base) {
    return function(_Base) {
        _inheritsLoose(AdaptivityKeyboardNavigationExtender, _Base);

        function AdaptivityKeyboardNavigationExtender() {
            return _Base.apply(this, arguments) || this
        }
        var _proto2 = AdaptivityKeyboardNavigationExtender.prototype;
        _proto2._isCellValid = function($cell, isClick) {
            return _Base.prototype._isCellValid.call(this, $cell, isClick) && !$cell.hasClass(this.addWidgetPrefix(HIDDEN_COLUMN_CLASS)) && !$cell.hasClass(COMMAND_ADAPTIVE_HIDDEN_CLASS)
        };
        _proto2._processNextCellInMasterDetail = function($nextCell, $cell) {
            _Base.prototype._processNextCellInMasterDetail.call(this, $nextCell, $cell);
            var isCellOrBatchMode = this._editingController.isCellOrBatchEditMode();
            var isEditing = this._editingController.isEditing();
            if (isEditing && $nextCell && isCellOrBatchMode && !this._isInsideEditForm($nextCell)) {
                _events_engine.default.off($nextCell, "focus", focusCellHandler);
                _events_engine.default.on($nextCell, "focus", {
                    $nextCell: $nextCell
                }, focusCellHandler);
                _events_engine.default.trigger($cell, "focus")
            }
        };
        _proto2._isCellElement = function($cell) {
            return _Base.prototype._isCellElement.call(this, $cell) || $cell.hasClass(ADAPTIVE_ITEM_TEXT_CLASS)
        };
        return AdaptivityKeyboardNavigationExtender
    }(Base)
};
var rowsView = function(Base) {
    return function(_Base2) {
        _inheritsLoose(AdaptivityRowsViewExtender, _Base2);

        function AdaptivityRowsViewExtender() {
            return _Base2.apply(this, arguments) || this
        }
        var _proto3 = AdaptivityRowsViewExtender.prototype;
        _proto3._getCellTemplate = function(options) {
            var that = this;
            var column = options.column;
            if (options.rowType === ADAPTIVE_ROW_TYPE && "detail" === column.command) {
                return function(container, options) {
                    that._adaptiveColumnsController.createFormByHiddenColumns((0, _renderer.default)(container), options)
                }
            }
            return _Base2.prototype._getCellTemplate.call(this, options)
        };
        _proto3._createRow = function(row) {
            var $row = _Base2.prototype._createRow.apply(this, arguments);
            if (row && row.rowType === ADAPTIVE_ROW_TYPE && row.key === this._dataController.adaptiveExpandedKey()) {
                $row.addClass(ADAPTIVE_DETAIL_ROW_CLASS)
            }
            return $row
        };
        _proto3._renderCells = function($row, options) {
            _Base2.prototype._renderCells.call(this, $row, options);
            var adaptiveColumnsController = this._adaptiveColumnsController;
            var hidingColumnsQueueLength = adaptiveColumnsController.getHidingColumnsQueue().length;
            var hiddenColumnsLength = adaptiveColumnsController.getHiddenColumns().length;
            if (hidingColumnsQueueLength && !hiddenColumnsLength) {
                getDataCellElements($row).last().addClass(LAST_DATA_CELL_CLASS)
            }
            if ("data" === options.row.rowType) {
                adaptiveColumnsController.setCommandAdaptiveAriaLabel($row, EXPAND_ARIA_NAME)
            }
        };
        _proto3._getColumnIndexByElementCore = function($element) {
            var $itemContent = $element.closest(".".concat(FORM_ITEM_CONTENT_CLASS));
            if ($itemContent.length && $itemContent.closest(this.component.$element()).length) {
                var formItem = $itemContent.length ? $itemContent.first().data("dx-form-item") : null;
                return formItem && formItem.column && this._columnsController.getVisibleIndex(formItem.column.index)
            }
            return _Base2.prototype._getColumnIndexByElementCore.call(this, $element)
        };
        _proto3._cellPrepared = function($cell, options) {
            _Base2.prototype._cellPrepared.apply(this, arguments);
            if (options.row.rowType !== ADAPTIVE_ROW_TYPE && options.column.visibleWidth === HIDDEN_COLUMNS_WIDTH) {
                $cell.addClass(this.addWidgetPrefix(HIDDEN_COLUMN_CLASS))
            }
        };
        _proto3.getCell = function(cellPosition, rows) {
            var item = this._dataController.items()[null === cellPosition || void 0 === cellPosition ? void 0 : cellPosition.rowIndex];
            if ((null === item || void 0 === item ? void 0 : item.rowType) === ADAPTIVE_ROW_TYPE) {
                var $adaptiveDetailItems = this._adaptiveColumnsController.getAdaptiveDetailItems();
                return _Base2.prototype.getCell.call(this, cellPosition, rows, $adaptiveDetailItems)
            }
            return _Base2.prototype.getCell.apply(this, arguments)
        };
        _proto3._getCellElement = function(rowIndex, columnIdentifier) {
            var item = this._dataController.items()[rowIndex];
            if (item && item.rowType === ADAPTIVE_ROW_TYPE) {
                return this._adaptiveColumnsController.getItemContentByColumnIndex(columnIdentifier)
            }
            return _Base2.prototype._getCellElement.apply(this, arguments)
        };
        _proto3.getContextMenuItems = function(options) {
            var _a;
            if (options.row && "detailAdaptive" === options.row.rowType) {
                var view = this._columnHeadersView;
                var formItem = (0, _renderer.default)(options.targetElement).closest(".dx-field-item-label").next().data("dx-form-item");
                options.column = formItem ? formItem.column : options.column;
                return view.getContextMenuItems && view.getContextMenuItems(options)
            }
            return null === (_a = _Base2.prototype.getContextMenuItems) || void 0 === _a ? void 0 : _a.call(this, options)
        };
        _proto3.isClickableElement = function($target) {
            var _a, _b;
            var isClickable = null !== (_b = null === (_a = _Base2.prototype.isClickableElement) || void 0 === _a ? void 0 : _a.call(this, $target)) && void 0 !== _b ? _b : false;
            return isClickable || !!$target.closest(".".concat(ADAPTIVE_COLUMN_NAME_CLASS)).length
        };
        return AdaptivityRowsViewExtender
    }(Base)
};
var exportExtender = function(Base) {
    return function(_Base3) {
        _inheritsLoose(AdaptivityExportExtender, _Base3);

        function AdaptivityExportExtender() {
            return _Base3.apply(this, arguments) || this
        }
        var _proto4 = AdaptivityExportExtender.prototype;
        _proto4._updateColumnWidth = function(column, width) {
            _Base3.prototype._updateColumnWidth.call(this, column, column.visibleWidth === HIDDEN_COLUMNS_WIDTH ? column.bestFitWidth : width)
        };
        return AdaptivityExportExtender
    }(Base)
};
var columnsResizer = function(Base) {
    return function(_Base4) {
        _inheritsLoose(AdaptivityColumnsResizerExtender, _Base4);

        function AdaptivityColumnsResizerExtender() {
            return _Base4.apply(this, arguments) || this
        }
        var _proto5 = AdaptivityColumnsResizerExtender.prototype;
        _proto5._pointCreated = function(point, cellsLength, columns) {
            var result = _Base4.prototype._pointCreated.call(this, point, cellsLength, columns);
            var currentColumn = columns[point.columnIndex] || {};
            var nextColumnIndex = this._getNextColumnIndex(point.columnIndex);
            var nextColumn = columns[nextColumnIndex] || {};
            var hasHiddenColumnsOnly = nextColumnIndex !== point.columnIndex + 1 && nextColumn.command;
            var hasAdaptiveHiddenWidth = currentColumn.visibleWidth === HIDDEN_COLUMNS_WIDTH || hasHiddenColumnsOnly;
            return result || hasAdaptiveHiddenWidth
        };
        _proto5._getNextColumnIndex = function(currentColumnIndex) {
            var visibleColumns = this._columnsController.getVisibleColumns();
            var index = _Base4.prototype._getNextColumnIndex.call(this, currentColumnIndex);
            while (visibleColumns[index] && visibleColumns[index].visibleWidth === HIDDEN_COLUMNS_WIDTH) {
                index++
            }
            return index
        };
        return AdaptivityColumnsResizerExtender
    }(Base)
};
var draggingHeader = function(Base) {
    return function(_Base5) {
        _inheritsLoose(AdaptivityDraggingHeaderExtender, _Base5);

        function AdaptivityDraggingHeaderExtender() {
            return _Base5.apply(this, arguments) || this
        }
        var _proto6 = AdaptivityDraggingHeaderExtender.prototype;
        _proto6._pointCreated = function(point, columns, location, sourceColumn) {
            var result = _Base5.prototype._pointCreated.call(this, point, columns, location, sourceColumn);
            var column = columns[point.columnIndex - 1] || {};
            var hasAdaptiveHiddenWidth = column.visibleWidth === HIDDEN_COLUMNS_WIDTH;
            return result || hasAdaptiveHiddenWidth
        };
        return AdaptivityDraggingHeaderExtender
    }(Base)
};
var editing = function(Base) {
    return function(_Base6) {
        _inheritsLoose(AdaptivityEditingExtender, _Base6);

        function AdaptivityEditingExtender() {
            return _Base6.apply(this, arguments) || this
        }
        var _proto7 = AdaptivityEditingExtender.prototype;
        _proto7._isRowEditMode = function() {
            return this.getEditMode() === EDIT_MODE_ROW
        };
        _proto7._getFormEditItemTemplate = function(cellOptions, column) {
            if (this.getEditMode() !== EDIT_MODE_ROW && "detailAdaptive" === cellOptions.rowType) {
                cellOptions.columnIndex = this._columnsController.getVisibleIndex(column.index);
                return this.getColumnTemplate(cellOptions)
            }
            return _Base6.prototype._getFormEditItemTemplate.call(this, cellOptions, column)
        };
        _proto7._closeEditItem = function($targetElement) {
            var $itemContents = $targetElement.closest(".".concat(FORM_ITEM_CONTENT_CLASS));
            var rowIndex = this._dataController.getRowIndexByKey(this._dataController.adaptiveExpandedKey()) + 1;
            var formItem = $itemContents.length ? $itemContents.first().data("dx-form-item") : null;
            var columnIndex = formItem && formItem.column && this._columnsController.getVisibleIndex(formItem.column.index);
            if (!this.isEditCell(rowIndex, columnIndex)) {
                _Base6.prototype._closeEditItem.call(this, $targetElement)
            }
        };
        _proto7._beforeUpdateItems = function(rowIndices, rowIndex) {
            if (!this._adaptiveColumnsController.isFormOrPopupEditMode() && this._adaptiveColumnsController.hasHiddenColumns()) {
                var items = this._dataController.items();
                var item = items[rowIndex];
                var oldExpandRowIndex = _m_utils.default.getIndexByKey(this._dataController.adaptiveExpandedKey(), items);
                this._isForceRowAdaptiveExpand = !this._adaptiveColumnsController.hasAdaptiveDetailRowExpanded();
                if (oldExpandRowIndex >= 0) {
                    rowIndices.push(oldExpandRowIndex + 1)
                }
                rowIndices.push(rowIndex + 1);
                this._dataController.adaptiveExpandedKey(item.key)
            }
        };
        _proto7._afterInsertRow = function(key) {
            _Base6.prototype._afterInsertRow.apply(this, arguments);
            if (this._adaptiveColumnsController.hasHiddenColumns()) {
                this._adaptiveColumnsController.toggleExpandAdaptiveDetailRow(key, this.isRowEditMode());
                this._isForceRowAdaptiveExpand = true
            }
        };
        _proto7._collapseAdaptiveDetailRow = function() {
            if (this._isRowEditMode() && this._isForceRowAdaptiveExpand) {
                this._adaptiveColumnsController.collapseAdaptiveDetailRow();
                this._isForceRowAdaptiveExpand = false
            }
        };
        _proto7._cancelEditAdaptiveDetailRow = function() {
            if (this._adaptiveColumnsController.hasHiddenColumns()) {
                this._collapseAdaptiveDetailRow()
            }
        };
        _proto7._afterSaveEditData = function() {
            var _this3 = this;
            _Base6.prototype._afterSaveEditData.apply(this, arguments);
            var deferred = new _deferred.Deferred;
            if (this._isRowEditMode() && this._adaptiveColumnsController.hasHiddenColumns()) {
                (0, _deferred.when)(this._validatingController.validate(true)).done((function(isValid) {
                    if (isValid) {
                        _this3._cancelEditAdaptiveDetailRow()
                    }
                    deferred.resolve()
                }))
            } else {
                deferred.resolve()
            }
            return deferred.promise()
        };
        _proto7._beforeCancelEditData = function() {
            _Base6.prototype._beforeCancelEditData.call(this);
            this._cancelEditAdaptiveDetailRow()
        };
        _proto7._getRowIndicesForCascadeUpdating = function(row) {
            var rowIndices = _Base6.prototype._getRowIndicesForCascadeUpdating.apply(this, arguments);
            if (this._adaptiveColumnsController.isAdaptiveDetailRowExpanded(row.key)) {
                rowIndices.push(row.rowType === ADAPTIVE_ROW_TYPE ? row.rowIndex - 1 : row.rowIndex + 1)
            }
            return rowIndices
        };
        _proto7._beforeCloseEditCellInBatchMode = function(rowIndices) {
            var expandedKey = this._dataController._adaptiveExpandedKey;
            if (expandedKey) {
                var rowIndex = _m_utils.default.getIndexByKey(expandedKey, this._dataController.items());
                if (rowIndex > -1) {
                    rowIndices.unshift(rowIndex)
                }
            }
        };
        _proto7.editRow = function(rowIndex) {
            if (this._adaptiveColumnsController.isFormOrPopupEditMode()) {
                this._adaptiveColumnsController.collapseAdaptiveDetailRow()
            }
            return _Base6.prototype.editRow.call(this, rowIndex)
        };
        _proto7.deleteRow = function(rowIndex) {
            var rowKey = this._dataController.getKeyByRowIndex(rowIndex);
            if (this.getEditMode() === EDIT_MODE_BATCH && this._adaptiveColumnsController.isAdaptiveDetailRowExpanded(rowKey)) {
                this._adaptiveColumnsController.collapseAdaptiveDetailRow()
            }
            _Base6.prototype.deleteRow.call(this, rowIndex)
        };
        return AdaptivityEditingExtender
    }(Base)
};
var data = function(Base) {
    return function(_Base7) {
        _inheritsLoose(AdaptivityDataControllerExtender, _Base7);

        function AdaptivityDataControllerExtender() {
            return _Base7.apply(this, arguments) || this
        }
        var _proto8 = AdaptivityDataControllerExtender.prototype;
        _proto8._processItems = function(items, change) {
            var changeType = change.changeType;
            items = _Base7.prototype._processItems.apply(this, arguments);
            if ("loadingAll" === changeType || !(0, _type.isDefined)(this._adaptiveExpandedKey)) {
                return items
            }
            var expandRowIndex = _m_utils.default.getIndexByKey(this._adaptiveExpandedKey, items);
            var newMode = false === this.option(LEGACY_SCROLLING_MODE);
            if (expandRowIndex >= 0) {
                var item = items[expandRowIndex];
                items.splice(expandRowIndex + 1, 0, {
                    visible: true,
                    rowType: ADAPTIVE_ROW_TYPE,
                    key: item.key,
                    data: item.data,
                    node: item.node,
                    modifiedValues: item.modifiedValues,
                    isNewRow: item.isNewRow,
                    values: item.values
                })
            } else if ("refresh" === changeType && !(newMode && change.repaintChangesOnly)) {
                this._adaptiveExpandedKey = void 0
            }
            return items
        };
        _proto8._getRowIndicesForExpand = function(key) {
            var rowIndices = _Base7.prototype._getRowIndicesForExpand.apply(this, arguments);
            if (this._adaptiveColumnsController.isAdaptiveDetailRowExpanded(key)) {
                var lastRowIndex = rowIndices[rowIndices.length - 1];
                rowIndices.push(lastRowIndex + 1)
            }
            return rowIndices
        };
        _proto8.adaptiveExpandedKey = function(value) {
            if ((0, _type.isDefined)(value)) {
                this._adaptiveExpandedKey = value
            } else {
                return this._adaptiveExpandedKey
            }
        };
        _proto8.toggleExpandAdaptiveDetailRow = function(key, alwaysExpanded) {
            var oldExpandLoadedRowIndex = _m_utils.default.getIndexByKey(this._adaptiveExpandedKey, this._items);
            var newExpandLoadedRowIndex = _m_utils.default.getIndexByKey(key, this._items);
            if (oldExpandLoadedRowIndex >= 0 && oldExpandLoadedRowIndex === newExpandLoadedRowIndex && !alwaysExpanded) {
                key = void 0;
                newExpandLoadedRowIndex = -1
            }
            var oldKey = this._adaptiveExpandedKey;
            this._adaptiveExpandedKey = key;
            if (oldExpandLoadedRowIndex >= 0) {
                oldExpandLoadedRowIndex++
            }
            if (newExpandLoadedRowIndex >= 0) {
                newExpandLoadedRowIndex++
            }
            var rowIndexDelta = this.getRowIndexDelta();
            this.updateItems({
                allowInvisibleRowIndices: true,
                changeType: "update",
                rowIndices: [oldExpandLoadedRowIndex - rowIndexDelta, newExpandLoadedRowIndex - rowIndexDelta]
            });
            this._adaptiveColumnsController.updateCommandAdaptiveAriaLabel(key, COLLAPSE_ARIA_NAME);
            this._adaptiveColumnsController.updateCommandAdaptiveAriaLabel(oldKey, EXPAND_ARIA_NAME)
        };
        return AdaptivityDataControllerExtender
    }(Base)
};
var editorFactory = function(Base) {
    return function(_Base8) {
        _inheritsLoose(AdaptivityEditorFactoryExtender, _Base8);

        function AdaptivityEditorFactoryExtender() {
            return _Base8.apply(this, arguments) || this
        }
        var _proto9 = AdaptivityEditorFactoryExtender.prototype;
        _proto9._needHideBorder = function($element) {
            return _Base8.prototype._needHideBorder.call(this, $element) || (null === $element || void 0 === $element ? void 0 : $element.hasClass("dx-field-item-content")) && (null === $element || void 0 === $element ? void 0 : $element.find(".dx-checkbox").length)
        };
        _proto9._getFocusCellSelector = function() {
            return "".concat(_Base8.prototype._getFocusCellSelector.call(this), ", .dx-adaptive-detail-row .dx-field-item > .dx-field-item-content")
        };
        _proto9._getRevertTooltipsSelector = function() {
            return "".concat(_Base8.prototype._getRevertTooltipsSelector.call(this), ", .dx-field-item-content .").concat(this.addWidgetPrefix(REVERT_TOOLTIP_CLASS))
        };
        return AdaptivityEditorFactoryExtender
    }(Base)
};
var columns = function(Base) {
    return function(_Base9) {
        _inheritsLoose(AdaptivityColumnsExtender, _Base9);

        function AdaptivityColumnsExtender() {
            return _Base9.apply(this, arguments) || this
        }
        var _proto10 = AdaptivityColumnsExtender.prototype;
        _proto10._isColumnVisible = function(column) {
            return _Base9.prototype._isColumnVisible.call(this, column) && !column.adaptiveHidden
        };
        return AdaptivityColumnsExtender
    }(Base)
};
var resizing = function(Base) {
    return function(_Base10) {
        _inheritsLoose(AdaptivityResizingControllerExtender, _Base10);

        function AdaptivityResizingControllerExtender() {
            return _Base10.apply(this, arguments) || this
        }
        var _proto11 = AdaptivityResizingControllerExtender.prototype;
        _proto11.dispose = function() {
            _Base10.prototype.dispose.apply(this, arguments);
            clearTimeout(this._updateScrollableTimeoutID)
        };
        _proto11._needBestFit = function() {
            return _Base10.prototype._needBestFit.call(this) || !!this._adaptiveColumnsController.getHidingColumnsQueue().length
        };
        _proto11._correctColumnWidths = function(resultWidths, visibleColumns) {
            var adaptiveController = this._adaptiveColumnsController;
            var oldHiddenColumns = adaptiveController.getHiddenColumns();
            var hidingColumnsQueue = adaptiveController.updateHidingQueue(this._columnsController.getColumns());
            adaptiveController.hideRedundantColumns(resultWidths, visibleColumns, hidingColumnsQueue);
            var hiddenColumns = adaptiveController.getHiddenColumns();
            if (adaptiveController.hasAdaptiveDetailRowExpanded()) {
                if (oldHiddenColumns.length !== hiddenColumns.length) {
                    adaptiveController.updateForm(hiddenColumns)
                }
            }!hiddenColumns.length && adaptiveController.collapseAdaptiveDetailRow();
            return _Base10.prototype._correctColumnWidths.apply(this, arguments)
        };
        _proto11._toggleBestFitMode = function(isBestFit) {
            isBestFit && this._adaptiveColumnsController._showHiddenColumns();
            _Base10.prototype._toggleBestFitMode.call(this, isBestFit)
        };
        _proto11._needStretch = function() {
            var adaptiveColumnsController = this._adaptiveColumnsController;
            return _Base10.prototype._needStretch.apply(this, arguments) || adaptiveColumnsController.getHidingColumnsQueue().length || adaptiveColumnsController.hasHiddenColumns()
        };
        return AdaptivityResizingControllerExtender
    }(Base)
};
var adaptivityModule = {
    defaultOptions: function() {
        return {
            columnHidingEnabled: false,
            onAdaptiveDetailRowPreparing: null
        }
    },
    controllers: {
        adaptiveColumns: AdaptiveColumnsController
    },
    extenders: {
        views: {
            rowsView: rowsView
        },
        controllers: {
            export: exportExtender,
            columnsResizer: columnsResizer,
            draggingHeader: draggingHeader,
            editing: editing,
            resizing: resizing,
            data: data,
            editorFactory: editorFactory,
            columns: columns,
            keyboardNavigation: keyboardNavigation
        }
    }
};
exports.adaptivityModule = adaptivityModule;
