import { TABLE_EVENT_TYPE } from "../../../core/TABLE_EVENT_TYPE";

import { getCellEventArgsSet } from "../../util";

export function bindDBClickAutoColumnWidthEvent(table) {
    table.on(TABLE_EVENT_TYPE.DBLCLICK_CELL, (e => {
        var _a, _b, _c;
        if (e.federatedEvent) {
            const eventArgsSet = getCellEventArgsSet(e.federatedEvent), resizeCol = table.scenegraph.getResizeColAt(eventArgsSet.abstractPos.x, eventArgsSet.abstractPos.y, null === (_a = eventArgsSet.eventArgs) || void 0 === _a ? void 0 : _a.targetCell), disableDblclickAutoResizeColWidth = null !== (_b = table.options.disableDblclickAutoResizeColWidth) && void 0 !== _b ? _b : null === (_c = table.options.resize) || void 0 === _c ? void 0 : _c.disableDblclickAutoResizeColWidth;
            if (table.eventManager.checkCellFillhandle(eventArgsSet)) table.fireListeners(TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE, {}); else if (table._canResizeColumn(resizeCol.col, resizeCol.row) && resizeCol.col >= 0 && !disableDblclickAutoResizeColWidth) {
                table.scenegraph.updateAutoColWidth(resizeCol.col), table.internalProps._widthResizedColMap.add(resizeCol.col), 
                table.scenegraph.updateChartSizeForResizeColWidth(resizeCol.col);
                const state = table.stateManager;
                state.columnResize.col < state.table.frozenColCount && !state.table.isPivotTable() && !state.table.transpose && state.table.scenegraph.component.setFrozenColumnShadow(state.table.frozenColCount - 1, state.columnResize.isRightFrozen), 
                (state.columnResize.col >= state.table.colCount - state.table.rightFrozenColCount && !state.table.isPivotTable() && !state.table.transpose || state.table.options.rightFrozenColCount) && state.table.scenegraph.component.setRightFrozenColumnShadow(state.table.colCount - state.table.rightFrozenColCount);
                const colWidths = [];
                for (let col = 0; col < table.colCount; col++) colWidths.push(table.getColWidth(col));
                table.fireListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN_END, {
                    col: resizeCol.col,
                    colWidths: colWidths
                });
            }
        }
    }));
}
//# sourceMappingURL=dbclick-auto-column-width.js.map
