/**
    @module discreteBuffer
    Adds left/right padding to a point or time scale.
    @private
*/ var discreteBuffer = function discreteBuffer(// eslint-disable-next-line @typescript-eslint/no-explicit-any
scale, data, discrete) {
    if (scale.padding) scale.padding(0.5);
    else {
        var uniqueValues = Array.from(new Set(data.map(function(d) {
            return +d[discrete];
        })));
        var closest = uniqueValues.reduce(function(acc, curr, i, arr) {
            if (!i) return acc;
            var prev = arr[i - 1];
            if (!acc || curr - prev < acc) return curr - prev;
            else return acc;
        }, 0);
        var domain = scale.domain().slice();
        if (discrete === "y") domain.reverse();
        domain[0] = new Date(+domain[0] - closest / 2);
        domain[1] = new Date(+domain[1] + closest / 2);
        if (discrete === "y") domain.reverse();
        scale.domain(domain);
    }
};
export default discreteBuffer;
