/* *
 *
 *  Independent Resizing Mode class
 *
 *  (c) 2020-2026 Highsoft AS
 *
 *  Integration of this software requires a license.
 *  - For commercial use, see www.highcharts.com/license
 *  - For non-commercial, see www.highcharts.com/license-eula
 *
 *
 *  Authors:
 *  - Dawid Draguła
 *
 * */
'use strict';
import ResizingMode from './ResizingMode.js';
/* *
 *
 *  Class
 *
 * */
class IndependentResizingMode extends ResizingMode {
    constructor() {
        /* *
         *
         *  Properties
         *
         * */
        super(...arguments);
        this.type = 'independent';
    }
    /* *
     *
     *  Methods
     *
     * */
    resize(resizer, diff) {
        const column = resizer.draggedColumn;
        if (!column) {
            return;
        }
        // Set the width of the resized column.
        const width = this.columnWidths[column.id] = Math.round(ResizingMode.fitWidth(column, (resizer.columnStartWidth ?? 0) + diff) * 10) / 10;
        this.columnWidthUnits[column.id] = 0; // Set to px
        // Change width units of all columns to px.
        const vp = this.viewport;
        for (let i = 0; i < vp.columns.length; ++i) {
            const col = vp.columns[i];
            if (col.id === column.id) {
                continue;
            }
            const colWidth = this.columnWidths[col.id] = col.getWidth();
            this.columnWidthUnits[col.id] = 0; // Set to px
            col.setOptions({ width: colWidth });
        }
        column.setOptions({ width });
    }
}
/* *
 *
 *  Default Export
 *
 * */
export default IndependentResizingMode;
