"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get ManualColumnResize () {
        return ManualColumnResize;
    },
    get PLUGIN_KEY () {
        return PLUGIN_KEY;
    },
    get PLUGIN_PRIORITY () {
        return PLUGIN_PRIORITY;
    }
});
const _base = require("../base");
const _element = require("../../helpers/dom/element");
const _array = require("../../helpers/array");
const _number = require("../../helpers/number");
const _translations = require("../../translations");
const _utils = require("./utils");
function _check_private_redeclaration(obj, privateCollection) {
    if (privateCollection.has(obj)) {
        throw new TypeError("Cannot initialize the same private elements twice on an object");
    }
}
function _class_apply_descriptor_get(receiver, descriptor) {
    if (descriptor.get) {
        return descriptor.get.call(receiver);
    }
    return descriptor.value;
}
function _class_apply_descriptor_set(receiver, descriptor, value) {
    if (descriptor.set) {
        descriptor.set.call(receiver, value);
    } else {
        if (!descriptor.writable) {
            throw new TypeError("attempted to set read only private field");
        }
        descriptor.value = value;
    }
}
function _class_extract_field_descriptor(receiver, privateMap, action) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to " + action + " private field on non-instance");
    }
    return privateMap.get(receiver);
}
function _class_private_field_get(receiver, privateMap) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
    return _class_apply_descriptor_get(receiver, descriptor);
}
function _class_private_field_init(obj, privateMap, value) {
    _check_private_redeclaration(obj, privateMap);
    privateMap.set(obj, value);
}
function _class_private_field_set(receiver, privateMap, value) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
    _class_apply_descriptor_set(receiver, descriptor, value);
    return value;
}
function _class_private_method_get(receiver, privateSet, fn) {
    if (!privateSet.has(receiver)) {
        throw new TypeError("attempted to get private field on non-instance");
    }
    return fn;
}
function _class_private_method_init(obj, privateSet) {
    _check_private_redeclaration(obj, privateSet);
    privateSet.add(obj);
}
const PLUGIN_KEY = 'manualColumnResize';
const PLUGIN_PRIORITY = 130;
var /**
   * @type {HTMLTableHeaderCellElement}
   */ _currentTH = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _currentCol = /*#__PURE__*/ new WeakMap(), /**
   * @type {number[]}
   */ _selectedCols = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _currentWidth = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _newSize = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _startY = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _startWidth = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _startOffset = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _horizontalScaleFactor = /*#__PURE__*/ new WeakMap(), /**
   * @type {HTMLElement}
   */ _handle = /*#__PURE__*/ new WeakMap(), /**
   * @type {HTMLElement}
   */ _guide = /*#__PURE__*/ new WeakMap(), /**
   * @type {boolean}
   */ _pressed = /*#__PURE__*/ new WeakMap(), /**
   * @type {boolean}
   */ _isTriggeredByRMB = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _dblclick = /*#__PURE__*/ new WeakMap(), /**
   * @type {number}
   */ _autoresizeTimeout = /*#__PURE__*/ new WeakMap(), /**
   * PhysicalIndexToValueMap to keep and track widths for physical column indexes.
   *
   * @type {PhysicalIndexToValueMap}
   */ _columnWidthsMap = /*#__PURE__*/ new WeakMap(), /**
   * Disposer function for the column widths map observer. Called on disable to clean up.
   *
   * @type {Function|null}
   */ _disposeMapObserver = /*#__PURE__*/ new WeakMap(), /**
   * Private pool to save configuration from updateSettings.
   *
   * @type {object}
   */ _config = /*#__PURE__*/ new WeakMap(), /**
   * Callback to call on map's `init` local hook.
   *
   * @private
   */ _onMapInit = /*#__PURE__*/ new WeakSet(), /**
   * 'mouseover' event callback - set the handle position.
   *
   * @param {MouseEvent} event The mouse event.
   */ _onMouseOver = /*#__PURE__*/ new WeakSet(), /**
   * 'mousedown' event callback.
   *
   * @param {MouseEvent} event The mouse event.
   */ _onMouseDown = /*#__PURE__*/ new WeakSet(), /**
   * 'mousemove' event callback - refresh the handle and guide positions, cache the new column width.
   *
   * @param {MouseEvent} event The mouse event.
   */ _onMouseMove = /*#__PURE__*/ new WeakSet(), /**
   * 'mouseup' event callback - apply the column resizing.
   *
   * @fires Hooks#beforeColumnResize
   * @fires Hooks#afterColumnResize
   */ _onMouseUp = /*#__PURE__*/ new WeakSet(), /**
   * Callback for "contextmenu" event triggered on element showing move handle. It removes handle and guide elements.
   */ _onContextMenu = /*#__PURE__*/ new WeakSet(), /**
   * Modifies the provided column width, based on the plugin settings.
   *
   * @param {number} width Column width.
   * @param {number} column Visual column index.
   * @returns {number}
   */ _onModifyColWidth = /*#__PURE__*/ new WeakSet(), /**
   * Modifies the provided column stretched width. This hook decides if specified column should be stretched or not.
   *
   * @param {number} stretchedWidth Stretched width.
   * @param {number} column Visual column index.
   * @returns {number}
   */ _onBeforeStretchingColumnWidth = /*#__PURE__*/ new WeakSet(), /**
   * `beforeColumnResize` hook callback.
   */ _onBeforeColumnResize = /*#__PURE__*/ new WeakSet();
class ManualColumnResize extends _base.BasePlugin {
    static get PLUGIN_KEY() {
        return PLUGIN_KEY;
    }
    static get PLUGIN_PRIORITY() {
        return PLUGIN_PRIORITY;
    }
    /**
   * @private
   * @returns {string}
   */ get inlineDir() {
        return this.hot.isRtl() ? 'right' : 'left';
    }
    /**
   * Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
   * hook and if it returns `true` then the {@link ManualColumnResize#enablePlugin} method is called.
   *
   * @returns {boolean}
   */ isEnabled() {
        return this.hot.getSettings()[PLUGIN_KEY];
    }
    /**
   * Enables the plugin functionality for this Handsontable instance.
   */ enablePlugin() {
        if (this.enabled) {
            return;
        }
        _class_private_field_set(this, _columnWidthsMap, new _translations.PhysicalIndexToValueMap());
        _class_private_field_get(this, _columnWidthsMap).addLocalHook('init', ()=>_class_private_method_get(this, _onMapInit, onMapInit).call(this));
        this.hot.columnIndexMapper.registerMap(this.pluginName, _class_private_field_get(this, _columnWidthsMap));
        _class_private_field_set(this, _disposeMapObserver, this.hot.columnIndexMapper.observeMapChange(_class_private_field_get(this, _columnWidthsMap), ()=>{
            this.hot.view?.invalidateColumnWidthCache();
        }));
        this.addHook('modifyColWidth', (...args)=>_class_private_method_get(this, _onModifyColWidth, onModifyColWidth).call(this, ...args), 1);
        this.addHook('beforeStretchingColumnWidth', (...args)=>_class_private_method_get(this, _onBeforeStretchingColumnWidth, onBeforeStretchingColumnWidth).call(this, ...args), 1);
        this.addHook('beforeColumnResize', (...args)=>_class_private_method_get(this, _onBeforeColumnResize, onBeforeColumnResize).call(this, ...args));
        this.bindEvents();
        super.enablePlugin();
    }
    /**
   * Updates the plugin's state.
   *
   * This method is executed when [`updateSettings()`](@/api/core.md#updatesettings) is invoked with any of the following configuration options:
   *  - [`manualColumnResize`](@/api/options.md#manualcolumnresize)
   */ updatePlugin() {
        this.disablePlugin();
        this.enablePlugin();
        super.updatePlugin();
    }
    /**
   * Disables the plugin functionality for this Handsontable instance.
   */ disablePlugin() {
        if (_class_private_field_get(this, _disposeMapObserver)) {
            _class_private_field_get(this, _disposeMapObserver).call(this);
            _class_private_field_set(this, _disposeMapObserver, null);
        }
        _class_private_field_set(this, _config, _class_private_field_get(this, _columnWidthsMap).getValues());
        this.hot.columnIndexMapper.unregisterMap(this.pluginName);
        super.disablePlugin();
    }
    /**
   * Sets the new width for specified column index.
   *
   * @param {number} column Visual column index.
   * @param {number} width Column width (no less than 20px).
   * @returns {number} Returns new width.
   */ setManualSize(column, width) {
        const newWidth = Math.max(width, 20);
        const physicalColumn = this.hot.toPhysicalColumn(column);
        _class_private_field_get(this, _columnWidthsMap).setValueAtIndex(physicalColumn, newWidth);
        return newWidth;
    }
    /**
   * Clears the cache for the specified column index.
   *
   * @param {number} column Visual column index.
   */ clearManualSize(column) {
        const physicalColumn = this.hot.toPhysicalColumn(column);
        _class_private_field_get(this, _columnWidthsMap).setValueAtIndex(physicalColumn, null);
    }
    /**
   * Set the resize handle position.
   *
   * @private
   * @param {HTMLCellElement} TH TH HTML element.
   */ setupHandlePosition(TH) {
        if (!TH.parentNode || _class_private_field_get(this, _dblclick) > 1) {
            return;
        }
        _class_private_field_set(this, _currentTH, TH);
        const { _wt: wt } = this.hot.view;
        const cellCoords = wt.wtTable.getCoords(_class_private_field_get(this, _currentTH));
        const col = cellCoords.col;
        // Ignore column headers.
        if (col < 0) {
            return;
        }
        const headerHeight = (0, _element.outerHeight)(_class_private_field_get(this, _currentTH));
        // Read "fixedColumnsStart" through the Walkontable as in that context, the fixed columns
        // are modified (reduced by the number of hidden columns) by TableView module.
        const fixedColumn = col < wt.getSetting('fixedColumnsStart');
        let relativeHeaderPosition;
        if (fixedColumn) {
            relativeHeaderPosition = wt.wtOverlays.topInlineStartCornerOverlay.getRelativeCellPosition(_class_private_field_get(this, _currentTH), cellCoords.row, cellCoords.col);
        }
        // If the TH is not a child of the top-left overlay, recalculate using
        // the top overlay - as this overlay contains the rest of the headers.
        if (!relativeHeaderPosition) {
            relativeHeaderPosition = wt.wtOverlays.topOverlay.getRelativeCellPosition(_class_private_field_get(this, _currentTH), cellCoords.row, cellCoords.col);
        }
        _class_private_field_set(this, _currentCol, this.hot.columnIndexMapper.getVisualFromRenderableIndex(col));
        _class_private_field_set(this, _selectedCols, []);
        const isFullColumnSelected = this.hot.selection.isSelectedByCorner() || this.hot.selection.isSelectedByColumnHeader();
        if (this.hot.selection.isSelected() && isFullColumnSelected) {
            const selectionRanges = this.hot.getSelectedRange();
            (0, _array.arrayEach)(selectionRanges, (selectionRange)=>{
                const fromColumn = selectionRange.getTopStartCorner().col;
                const toColumn = selectionRange.getBottomEndCorner().col;
                // Add every selected column for resize action.
                (0, _number.rangeEach)(fromColumn, toColumn, (columnIndex)=>{
                    if (!_class_private_field_get(this, _selectedCols).includes(columnIndex)) {
                        _class_private_field_get(this, _selectedCols).push(columnIndex);
                    }
                });
            });
        }
        // Resizing element beyond the current selection (also when there is no selection).
        if (!_class_private_field_get(this, _selectedCols).includes(_class_private_field_get(this, _currentCol))) {
            _class_private_field_set(this, _selectedCols, [
                _class_private_field_get(this, _currentCol)
            ]);
        }
        _class_private_field_set(this, _startOffset, relativeHeaderPosition.start - 6);
        _class_private_field_set(this, _startWidth, (0, _element.outerWidth)(_class_private_field_get(this, _currentTH)));
        _class_private_field_set(this, _horizontalScaleFactor, (0, _utils.getElementScaleFactor)(_class_private_field_get(this, _currentTH)));
        _class_private_field_get(this, _handle).style.top = `${relativeHeaderPosition.top}px`;
        _class_private_field_get(this, _handle).style[this.inlineDir] = `${_class_private_field_get(this, _startOffset) + _class_private_field_get(this, _startWidth)}px`;
        _class_private_field_get(this, _handle).style.height = `${headerHeight}px`;
        this.hot.rootElement.appendChild(_class_private_field_get(this, _handle));
    }
    /**
   * Refresh the resize handle position.
   *
   * @private
   */ refreshHandlePosition() {
        _class_private_field_get(this, _handle).style[this.inlineDir] = `${_class_private_field_get(this, _startOffset) + _class_private_field_get(this, _currentWidth)}px`;
    }
    /**
   * Sets the resize guide position.
   *
   * @private
   */ setupGuidePosition() {
        const handleHeight = parseInt((0, _element.outerHeight)(_class_private_field_get(this, _handle)), 10);
        const handleBottomPosition = parseInt(_class_private_field_get(this, _handle).style.top, 10) + handleHeight;
        const tableHeight = this.hot.view.getTableHeight();
        (0, _element.addClass)(_class_private_field_get(this, _handle), 'active');
        (0, _element.addClass)(_class_private_field_get(this, _guide), 'active');
        _class_private_field_get(this, _guide).style.top = `${handleBottomPosition}px`;
        this.refreshGuidePosition();
        _class_private_field_get(this, _guide).style.height = `${tableHeight - handleHeight}px`;
        this.hot.rootElement.appendChild(_class_private_field_get(this, _guide));
    }
    /**
   * Refresh the resize guide position.
   *
   * @private
   */ refreshGuidePosition() {
        _class_private_field_get(this, _guide).style[this.inlineDir] = _class_private_field_get(this, _handle).style[this.inlineDir];
    }
    /**
   * Hides both the resize handle and resize guide.
   *
   * @private
   */ hideHandleAndGuide() {
        (0, _element.removeClass)(_class_private_field_get(this, _handle), 'active');
        (0, _element.removeClass)(_class_private_field_get(this, _guide), 'active');
    }
    /**
   * Checks if provided element is considered a column header.
   *
   * @private
   * @param {HTMLElement} element HTML element.
   * @returns {boolean}
   */ checkIfColumnHeader(element) {
        const thead = (0, _element.closest)(element, [
            'THEAD'
        ], this.hot.rootElement);
        const { topOverlay, topInlineStartCornerOverlay } = this.hot.view._wt.wtOverlays;
        return [
            topOverlay.clone.wtTable.THEAD,
            topInlineStartCornerOverlay.clone.wtTable.THEAD
        ].includes(thead);
    }
    /**
   * Gets the TH element from the provided element.
   *
   * @private
   * @param {HTMLElement} element HTML element.
   * @returns {HTMLElement}
   */ getClosestTHParent(element) {
        if (element.tagName !== 'TABLE') {
            if (element.tagName === 'TH') {
                return element;
            }
            return this.getClosestTHParent(element.parentNode);
        }
        return null;
    }
    /**
   * Auto-size row after doubleclick - callback.
   *
   * @private
   * @fires Hooks#beforeColumnResize
   * @fires Hooks#afterColumnResize
   */ afterMouseDownTimeout() {
        const render = ()=>{
            this.hot.view.adjustElementsSize();
            this.hot.render();
        };
        const resize = (column, forceRender)=>{
            const hookNewSize = this.hot.runHooks('beforeColumnResize', _class_private_field_get(this, _newSize), column, true);
            if (hookNewSize !== undefined) {
                _class_private_field_set(this, _newSize, hookNewSize);
            }
            this.setManualSize(column, _class_private_field_get(this, _newSize)); // double click sets by auto row size plugin
            this.hot.runHooks('afterColumnResize', _class_private_field_get(this, _newSize), column, true);
            if (forceRender) {
                render();
            }
        };
        if (_class_private_field_get(this, _dblclick) >= 2) {
            const selectedColsLength = _class_private_field_get(this, _selectedCols).length;
            if (selectedColsLength > 1) {
                (0, _array.arrayEach)(_class_private_field_get(this, _selectedCols), (selectedCol)=>{
                    resize(selectedCol);
                });
                render();
            } else {
                (0, _array.arrayEach)(_class_private_field_get(this, _selectedCols), (selectedCol)=>{
                    resize(selectedCol, true);
                });
            }
        }
        _class_private_field_set(this, _dblclick, 0);
        _class_private_field_set(this, _autoresizeTimeout, null);
    }
    /**
   * Binds the mouse events.
   *
   * @private
   */ bindEvents() {
        const { rootWindow, rootElement } = this.hot;
        this.eventManager.addEventListener(rootElement, 'mouseover', (e)=>_class_private_method_get(this, _onMouseOver, onMouseOver).call(this, e));
        this.eventManager.addEventListener(rootElement, 'mousedown', (e)=>_class_private_method_get(this, _onMouseDown, onMouseDown).call(this, e));
        this.eventManager.addEventListener(rootWindow, 'mousemove', (e)=>_class_private_method_get(this, _onMouseMove, onMouseMove).call(this, e));
        this.eventManager.addEventListener(rootWindow, 'mouseup', ()=>_class_private_method_get(this, _onMouseUp, onMouseUp).call(this));
        this.eventManager.addEventListener(_class_private_field_get(this, _handle), 'contextmenu', ()=>_class_private_method_get(this, _onContextMenu, onContextMenu).call(this));
    }
    /**
   * Destroys the plugin instance.
   */ destroy() {
        super.destroy();
    }
    constructor(hotInstance){
        super(hotInstance), _class_private_method_init(this, _onMapInit), _class_private_method_init(this, _onMouseOver), _class_private_method_init(this, _onMouseDown), _class_private_method_init(this, _onMouseMove), _class_private_method_init(this, _onMouseUp), _class_private_method_init(this, _onContextMenu), _class_private_method_init(this, _onModifyColWidth), _class_private_method_init(this, _onBeforeStretchingColumnWidth), _class_private_method_init(this, _onBeforeColumnResize), _class_private_field_init(this, _currentTH, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _currentCol, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _selectedCols, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _currentWidth, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _newSize, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _startY, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _startWidth, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _startOffset, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _horizontalScaleFactor, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _handle, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _guide, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _pressed, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _isTriggeredByRMB, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _dblclick, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _autoresizeTimeout, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _columnWidthsMap, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _disposeMapObserver, {
            writable: true,
            value: void 0
        }), _class_private_field_init(this, _config, {
            writable: true,
            value: void 0
        }), _class_private_field_set(this, _currentTH, null), _class_private_field_set(this, _currentCol, null), _class_private_field_set(this, _selectedCols, []), _class_private_field_set(this, _currentWidth, null), _class_private_field_set(this, _newSize, null), _class_private_field_set(this, _startY, null), _class_private_field_set(this, _startWidth, null), _class_private_field_set(this, _startOffset, null), _class_private_field_set(this, _horizontalScaleFactor, 1), _class_private_field_set(this, _handle, this.hot.rootDocument.createElement('DIV')), _class_private_field_set(this, _guide, this.hot.rootDocument.createElement('DIV')), _class_private_field_set(this, _pressed, null), _class_private_field_set(this, _isTriggeredByRMB, false), _class_private_field_set(this, _dblclick, 0), _class_private_field_set(this, _autoresizeTimeout, null), _class_private_field_set(this, _disposeMapObserver, null);
        (0, _element.addClass)(_class_private_field_get(this, _handle), 'manualColumnResizer');
        (0, _element.addClass)(_class_private_field_get(this, _guide), 'manualColumnResizerGuide');
    }
}
function onMapInit() {
    const initialSetting = this.hot.getSettings()[PLUGIN_KEY];
    if (Array.isArray(initialSetting)) {
        this.hot.batchExecution(()=>{
            initialSetting.forEach((width, physicalIndex)=>{
                _class_private_field_get(this, _columnWidthsMap).setValueAtIndex(physicalIndex, width);
            });
        }, true);
        _class_private_field_set(this, _config, initialSetting);
    } else if (initialSetting === true && Array.isArray(_class_private_field_get(this, _config))) {
        this.hot.batchExecution(()=>{
            _class_private_field_get(this, _config).forEach((width, physicalIndex)=>{
                _class_private_field_get(this, _columnWidthsMap).setValueAtIndex(physicalIndex, width);
            });
        }, true);
    }
}
function onMouseOver(event) {
    // Workaround for #6926 - if the `event.target` is temporarily detached, we can skip this callback and wait for
    // the next `onmouseover`.
    if ((0, _element.isDetached)(event.target)) {
        return;
    }
    // A "mouseover" action is triggered right after executing "contextmenu" event. It should be ignored.
    if (_class_private_field_get(this, _isTriggeredByRMB) === true) {
        return;
    }
    if (this.checkIfColumnHeader(event.target)) {
        const th = this.getClosestTHParent(event.target);
        if (!th) {
            return;
        }
        const colspan = th.getAttribute('colspan');
        if (th && (colspan === null || colspan === '1')) {
            if (!_class_private_field_get(this, _pressed)) {
                this.setupHandlePosition(th);
            }
        }
    }
}
function onMouseDown(event) {
    if (event.target.parentNode !== this.hot.rootElement) {
        return;
    }
    if ((0, _element.hasClass)(event.target, 'manualColumnResizer')) {
        this.setupHandlePosition(_class_private_field_get(this, _currentTH));
        this.setupGuidePosition();
        _class_private_field_set(this, _pressed, true);
        if (_class_private_field_get(this, _autoresizeTimeout) === null) {
            _class_private_field_set(this, _autoresizeTimeout, this.hot._registerTimeout(()=>this.afterMouseDownTimeout(), 500));
        }
        _class_private_field_set(this, _dblclick, _class_private_field_get(this, _dblclick) + 1);
        this.startX = event.pageX;
        _class_private_field_set(this, _newSize, _class_private_field_get(this, _startWidth));
    }
}
function onMouseMove(event) {
    if (_class_private_field_get(this, _pressed)) {
        const visualChange = (event.pageX - this.startX) * this.hot.getDirectionFactor();
        const change = (0, _utils.normalizeVisualDelta)(visualChange, _class_private_field_get(this, _horizontalScaleFactor));
        _class_private_field_set(this, _currentWidth, _class_private_field_get(this, _startWidth) + change);
        (0, _array.arrayEach)(_class_private_field_get(this, _selectedCols), (selectedCol)=>{
            _class_private_field_set(this, _newSize, this.setManualSize(selectedCol, _class_private_field_get(this, _currentWidth)));
        });
        this.refreshHandlePosition();
        this.refreshGuidePosition();
    }
}
function onMouseUp() {
    const render = ()=>{
        this.hot.view.adjustElementsSize();
        this.hot.render();
    };
    const resize = (column, forceRender)=>{
        this.hot.runHooks('beforeColumnResize', _class_private_field_get(this, _newSize), column, false);
        if (forceRender) {
            render();
        }
        this.hot.runHooks('afterColumnResize', _class_private_field_get(this, _newSize), column, false);
    };
    if (_class_private_field_get(this, _pressed)) {
        this.hideHandleAndGuide();
        _class_private_field_set(this, _pressed, false);
        if (_class_private_field_get(this, _newSize) !== _class_private_field_get(this, _startWidth)) {
            const selectedColsLength = _class_private_field_get(this, _selectedCols).length;
            if (selectedColsLength > 1) {
                (0, _array.arrayEach)(_class_private_field_get(this, _selectedCols), (selectedCol)=>{
                    resize(selectedCol);
                });
                render();
            } else {
                (0, _array.arrayEach)(_class_private_field_get(this, _selectedCols), (selectedCol)=>{
                    resize(selectedCol, true);
                });
            }
        }
        this.setupHandlePosition(_class_private_field_get(this, _currentTH));
    }
}
function onContextMenu() {
    this.hideHandleAndGuide();
    this.hot.rootElement.removeChild(_class_private_field_get(this, _handle));
    this.hot.rootElement.removeChild(_class_private_field_get(this, _guide));
    _class_private_field_set(this, _pressed, false);
    _class_private_field_set(this, _isTriggeredByRMB, true);
    // There is thrown "mouseover" event right after opening a context menu. This flag inform that handle
    // shouldn't be drawn just after removing it.
    this.hot._registerMicrotask(()=>{
        _class_private_field_set(this, _isTriggeredByRMB, false);
    });
}
function onModifyColWidth(width, column) {
    let newWidth = width;
    if (this.enabled) {
        const physicalColumn = this.hot.toPhysicalColumn(column);
        const columnWidth = _class_private_field_get(this, _columnWidthsMap).getValueAtIndex(physicalColumn);
        if (this.hot.getSettings()[PLUGIN_KEY] && columnWidth) {
            newWidth = columnWidth;
        }
    }
    return newWidth;
}
function onBeforeStretchingColumnWidth(stretchedWidth, column) {
    const width = _class_private_field_get(this, _columnWidthsMap).getValueAtIndex(this.hot.toPhysicalColumn(column));
    if (typeof width === 'number') {
        return width;
    }
    return stretchedWidth;
}
function onBeforeColumnResize() {
    // clear the header height cache information
    this.hot.view._wt.wtViewport.resetHasOversizedColumnHeadersMarked();
}
