"use strict";

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.updateHoverPosition = void 0;

const ts_types_1 = require("../../ts-types"), col_1 = require("./col"), row_1 = require("./row"), single_1 = require("./single");

function updateHoverPosition(state, col, row) {
    var _a;
    const {table: table} = state, {scenegraph: scenegraph} = table, {highlightScope: highlightScope, singleStyle: singleStyle, disableHeader: disableHeader, cellPos: cellPos, cellPosContainHeader: cellPosContainHeader} = state.hover, prevHoverCellCol = cellPos.col, prevHoverCellRow = cellPos.row;
    if (highlightScope === ts_types_1.HighlightScope.none || disableHeader && (cellPosContainHeader.col !== col || cellPosContainHeader.row !== row)) {
        const prevHoverCellCol = cellPosContainHeader.col, prevHoverCellRow = cellPosContainHeader.row;
        scenegraph.hideHoverIcon(prevHoverCellCol, prevHoverCellRow), scenegraph.showHoverIcon(col, row), 
        cellPosContainHeader.col = col, cellPosContainHeader.row = row;
    }
    if ((disableHeader && table.isHeader(col, row) || highlightScope === ts_types_1.HighlightScope.none) && (col = -1, 
    row = -1), prevHoverCellCol === col && prevHoverCellRow === row) return;
    cellPos.col = col, cellPos.row = row, (null === (_a = state.table.options.customConfig) || void 0 === _a ? void 0 : _a.disableBuildInChartActive) || (scenegraph.deactivateChart(prevHoverCellCol, prevHoverCellRow), 
    scenegraph.activateChart(col, row));
    let updateScenegraph = !1;
    const {ranges: ranges, highlightScope: selectMode} = state.select;
    if (-1 !== prevHoverCellCol && -1 !== prevHoverCellRow && (updateScenegraph = clearHover(scenegraph, prevHoverCellCol, prevHoverCellRow, ranges, singleStyle, highlightScope, selectMode), 
    disableHeader || scenegraph.hideHoverIcon(prevHoverCellCol, prevHoverCellRow)), 
    -1 === col || -1 === row) return cellPos.col = -1, cellPos.row = -1, void (!updateScenegraph || prevHoverCellCol === col && prevHoverCellRow === row || state.table.scenegraph.updateNextFrame());
    highlightScope === ts_types_1.HighlightScope.single ? updateScenegraph = !!(0, single_1.updateSingleHover)(scenegraph, col, row, ranges, selectMode) || updateScenegraph : highlightScope === ts_types_1.HighlightScope.row ? updateScenegraph = !!(0, 
    row_1.updateRowHover)(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph : highlightScope === ts_types_1.HighlightScope.column ? updateScenegraph = !!(0, 
    col_1.updateColHover)(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph : highlightScope === ts_types_1.HighlightScope.cross && (updateScenegraph = !!(0, 
    row_1.updateRowHover)(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph, 
    updateScenegraph = !!(0, col_1.updateColHover)(scenegraph, col, row, ranges, selectMode, singleStyle) || updateScenegraph), 
    highlightScope === ts_types_1.HighlightScope.none || disableHeader || scenegraph.showHoverIcon(col, row), 
    updateScenegraph && state.table.scenegraph.updateNextFrame();
}

function clearHover(scenegraph, col, row, selectRanges, singleStyle, mode, selectMode) {
    let updateScenegraph = !1;
    return mode === ts_types_1.HighlightScope.single ? updateScenegraph = !!(0, single_1.clearSingleHover)(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph : mode === ts_types_1.HighlightScope.row ? updateScenegraph = !!(0, 
    row_1.clearRowHover)(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph : mode === ts_types_1.HighlightScope.column ? updateScenegraph = !!(0, 
    col_1.clearColHover)(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph : mode === ts_types_1.HighlightScope.cross && (updateScenegraph = !!(0, 
    row_1.clearRowHover)(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph, 
    updateScenegraph = !!(0, col_1.clearColHover)(scenegraph, col, row, selectRanges, selectMode) || updateScenegraph), 
    updateScenegraph;
}

exports.updateHoverPosition = updateHoverPosition;
//# sourceMappingURL=update-position.js.map
