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

export function fireMoveColEventListeners(table, endMoveColSuccess, e) {
    var _a, _b, _c, _d, _e, _f, _g, _h;
    if (endMoveColSuccess && -1 !== (null === (_a = table.stateManager.columnMove) || void 0 === _a ? void 0 : _a.colSource) && -1 !== (null === (_b = table.stateManager.columnMove) || void 0 === _b ? void 0 : _b.rowSource) && -1 !== (null === (_c = table.stateManager.columnMove) || void 0 === _c ? void 0 : _c.colTarget) && -1 !== (null === (_d = table.stateManager.columnMove) || void 0 === _d ? void 0 : _d.rowTarget)) {
        if (table.hasListeners(TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION)) {
            const {colSource: colSource, rowSource: rowSource, colTarget: colTarget, rowTarget: rowTarget} = table.stateManager.columnMove, rowSourceSize = null !== (_e = table.stateManager.columnMove.rowSourceSize) && void 0 !== _e ? _e : 0, rowTargetSize = null !== (_f = table.stateManager.columnMove.rowTargetSize) && void 0 !== _f ? _f : 0;
            table.fireListeners(TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION, {
                target: {
                    col: colTarget,
                    row: rowTarget + rowTargetSize - rowSourceSize
                },
                source: {
                    col: colSource,
                    row: rowSource
                },
                event: e
            });
        }
    } else if (!endMoveColSuccess && table.hasListeners(TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION_FAIL)) {
        const rowSourceSize = null !== (_g = table.stateManager.columnMove.rowSourceSize) && void 0 !== _g ? _g : 0, rowTargetSize = null !== (_h = table.stateManager.columnMove.rowTargetSize) && void 0 !== _h ? _h : 0;
        table.fireListeners(TABLE_EVENT_TYPE.CHANGE_HEADER_POSITION_FAIL, {
            target: {
                col: table.stateManager.columnMove.colTarget,
                row: table.stateManager.columnMove.rowTarget + rowTargetSize - rowSourceSize
            },
            source: {
                col: table.stateManager.columnMove.colSource,
                row: table.stateManager.columnMove.rowSource
            },
            event: e
        });
    }
}
//# sourceMappingURL=helper.js.map