function limitEvents(hiddenCnts, segIsHidden, colPlacements, _moreLinkConsumesLevel, isPlacementInBounds) {
    var colCnt = hiddenCnts.length;
    var segIsVisible = {}; // TODO: instead, use segIsHidden with true/false?
    var visibleColPlacements = []; // will mirror colPlacements
    for (var col = 0; col < colCnt; col++) {
        visibleColPlacements.push([]);
    }
    for (var col = 0; col < colCnt; col++) {
        var placements = colPlacements[col];
        var level = 0;
        for (var _i = 0, placements_2 = placements; _i < placements_2.length; _i++) {
            var placement = placements_2[_i];
            if (isPlacementInBounds(placement, level)) {
                recordVisible(placement);
            }
            else {
                recordHidden(placement, level, _moreLinkConsumesLevel);
            }
            // only considered a level if the seg had height
            if (placement.top !== placement.bottom) {
                level++;
            }
        }
    }
    function recordVisible(placement) {
        var seg = placement.seg;
        var instanceId = seg.eventRange.instance.instanceId;
        if (!segIsVisible[instanceId]) {
            segIsVisible[instanceId] = true;
            for (var col = seg.firstCol; col <= seg.lastCol; col++) {
                visibleColPlacements[col].push(placement);
            }
        }
    }
    function recordHidden(placement, currentLevel, moreLinkConsumesLevel) {
        var seg = placement.seg;
        var instanceId = seg.eventRange.instance.instanceId;
        if (!segIsHidden[instanceId]) {
            segIsHidden[instanceId] = true;
            for (var col = seg.firstCol; col <= seg.lastCol; col++) {
                var hiddenCnt = ++hiddenCnts[col];
                if (moreLinkConsumesLevel && hiddenCnt === 1) {
                    var doomedLevel = currentLevel - 1;
                    while (visibleColPlacements[col].length > doomedLevel) {
                        recordHidden(visibleColPlacements[col].pop(), // removes
                        visibleColPlacements[col].length, // will execute after the pop. will be the index of the removed placement
                        false);
                    }
                }
            }
        }
    }
}
/*
populates the given hiddenCnts/segIsHidden, which are supplied empty.
TODO: return them instead
*/
populates the given hiddenCnts/segIsHidden, which are supplied empty.
TODO: return them instead
populates the given hiddenCnts / segIsHidden which are supplied empty . TODO : return them instead
function limitEvents(hiddenCnts, segIsHidden, colPlacements, _moreLinkConsumesLevel, isPlacementInBounds) {
    var colCnt = hiddenCnts.length;
    var segIsVisible = {}; 
    var visibleColPlacements = []; 
    for (var col = 0; col < colCnt; col++) {
        visibleColPlacements.push([]);
    }
    for (var col = 0; col < colCnt; col++) {
        var placements = colPlacements[col];
        var level = 0;
        for (var _i = 0, placements_2 = placements; _i < placements_2.length; _i++) {
            var placement = placements_2[_i];
            if (isPlacementInBounds(placement, level)) {
                recordVisible(placement);
            }
            else {
                recordHidden(placement, level, _moreLinkConsumesLevel);
            }
            if (placement.top !== placement.bottom) {
                level++;
            }
        }
    }
    function recordVisible(placement) {
        var seg = placement.seg;
        var instanceId = seg.eventRange.instance.instanceId;
        if (!segIsVisible[instanceId]) {
            segIsVisible[instanceId] = true;
            for (var col = seg.firstCol; col <= seg.lastCol; col++) {
                visibleColPlacements[col].push(placement);
            }
        }
    }
    function recordHidden(placement, currentLevel, moreLinkConsumesLevel) {
        var seg = placement.seg;
        var instanceId = seg.eventRange.instance.instanceId;
        if (!segIsHidden[instanceId]) {
            segIsHidden[instanceId] = true;
            for (var col = seg.firstCol; col <= seg.lastCol; col++) {
                var hiddenCnt = ++hiddenCnts[col];
                if (moreLinkConsumesLevel && hiddenCnt === 1) {
                    var doomedLevel = currentLevel - 1;
                    while (visibleColPlacements[col].length > doomedLevel) {
                        recordHidden(visibleColPlacements[col].pop(), 
                        visibleColPlacements[col].length, 
                        false);
                    }
                }
            }
        }
    }
}
function limitEvents ( hiddenCnts , segIsHidden , colPlacements , _moreLinkConsumesLevel , isPlacementInBounds ) { var colCnt = hiddenCnts . length ; var segIsVisible = { } ; var visibleColPlacements = [ ] ; for ( var col = 0 ; col < colCnt ; col ++ ) { visibleColPlacements . push ( [ ] ) ; } for ( var col = 0 ; col < colCnt ; col ++ ) { var placements = colPlacements [ col ] ; var level = 0 ; for ( var _i = 0 , placements_2 = placements ; _i < placements_2 . length ; _i ++ ) { var placement = placements_2 [ _i ] ; if ( isPlacementInBounds ( placement , level ) ) { recordVisible ( placement ) ; } else { recordHidden ( placement , level , _moreLinkConsumesLevel ) ; } if ( placement . top !== placement . bottom ) { level ++ ; } } } function recordVisible ( placement ) { var seg = placement . seg ; var instanceId = seg . eventRange . instance . instanceId ; if ( ! segIsVisible [ instanceId ] ) { segIsVisible [ instanceId ] = true ; for ( var col = seg . firstCol ; col <= seg . lastCol ; col ++ ) { visibleColPlacements [ col ] . push ( placement ) ; } } } function recordHidden ( placement , currentLevel , moreLinkConsumesLevel ) { var seg = placement . seg ; var instanceId = seg . eventRange . instance . instanceId ; if ( ! segIsHidden [ instanceId ] ) { segIsHidden [ instanceId ] = true ; for ( var col = seg . firstCol ; col <= seg . lastCol ; col ++ ) { var hiddenCnt = ++ hiddenCnts [ col ] ; if ( moreLinkConsumesLevel && hiddenCnt === 1 ) { var doomedLevel = currentLevel - 1 ; while ( visibleColPlacements [ col ] . length > doomedLevel ) { recordHidden ( visibleColPlacements [ col ] . pop ( ) , visibleColPlacements [ col ] . length , false ) ; } } } } } }
populates the given hiddenCnts/segIsHidden, which are supplied empty.
populates the given hiddenCnts / segIsHidden which are supplied empty .
// TODO: instead, use segIsHidden with true/false? // will mirror colPlacements // only considered a level if the seg had height // removes // will execute after the pop. will be the index of the removed placement