export function initCellResize(el, ev, downXRef, startWRef) {
    ev.preventDefault();
    ev.stopPropagation();
    const cStart = Number(el.dataset.cStart);
    if (!cStart)
        return null;
    const span = Number(el.getAttribute('colspan')) || 1;
    const col = Math.max(0, cStart + span - 1 - 1);
    downXRef.value = ev.clientX;
    startWRef.value = el.getBoundingClientRect().width;
    const target = ev.currentTarget;
    target.setPointerCapture(ev.pointerId);
    el.dispatchEvent(new CustomEvent('nile-column-resize', {
        detail: { col, widthPx: startWRef.value },
        bubbles: true,
        composed: true,
    }));
    el.dispatchEvent(new CustomEvent('nile-resize-start', { bubbles: true, composed: true }));
    return { target, col };
}
export function cellResizeMove(el, col, startW, downX, e) {
    const widthPx = Math.max(40, Math.round(startW + (e.clientX - downX)));
    el.dispatchEvent(new CustomEvent('nile-column-resize', {
        detail: { col, widthPx },
        bubbles: true,
        composed: true,
    }));
}
export function cellResizeDone(el, col, ev, target, move) {
    target.releasePointerCapture(ev.pointerId);
    target.removeEventListener('pointermove', move);
    el.dispatchEvent(new CustomEvent('nile-resize-end', { bubbles: true, composed: true, detail: { col: col } }));
}
//# sourceMappingURL=nile-grid-cell-item.utils.js.map