/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { StackedBarBucketCalculator } from "./StackedBarBucketCalculator";
import { StackedBarSeries } from "./StackedBarSeries";
import { BarFragment } from "./BarFragment";
import { ScalerParams } from "./ScalerParams";
import { typeCast, markType } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
export let Stacked100BarBucketCalculator = /*@__PURE__*/ (() => {
    class Stacked100BarBucketCalculator extends StackedBarBucketCalculator {
        constructor(a) {
            super(a);
        }
        getBucket(a) {
            return super.getBucket(a);
        }
        getBucket1(a, b, c, d, e, f) {
            let g = typeCast(StackedBarSeries.$, this.c.ct);
            let h = [NaN, NaN, NaN];
            let i = typeCast(BarFragment.$, a);
            if (i == null || i.logicalSeriesLink == null) {
                return h;
            }
            let j = a.valueColumn.item(c);
            let k = 0;
            let l = 0;
            let m = NaN;
            let n = NaN;
            let o = Number.NEGATIVE_INFINITY;
            let p = Number.POSITIVE_INFINITY;
            let q = g.getEffectiveViewport1(this.c);
            let r = Math.min(g.te != null ? g.te.length : 0, g.td != null ? g.td.length : 0);
            let s = c * this.d;
            let t = Math.min(s + this.d - 1, r - 1);
            for (let u = s; u <= t; ++u) {
                j = a.valueColumn.item(u);
                k = Math.abs(g.te[u]) + g.td[u];
                if (j < l) {
                    p = Math.min(p, (i.logicalSeriesLink.a0._inner[u] + j) / k * 100);
                    o = Math.max(o, i.logicalSeriesLink.a0._inner[u] / k * 100);
                }
                else {
                    p = Math.min(p, i.logicalSeriesLink.az._inner[u] / k * 100);
                    o = Math.max(o, (i.logicalSeriesLink.az._inner[u] + j) / k * 100);
                }
                if (!isNaN_(m)) {
                    if (!isNaN_(p)) {
                        m = Math.min(m, p);
                        n = Math.max(n, p);
                    }
                    if (!isNaN_(o)) {
                        m = Math.min(m, o);
                        n = Math.max(n, o);
                    }
                }
                else {
                    m = p;
                    n = o;
                }
            }
            let v = new ScalerParams(0, d, e, g.xAxis.cg, q);
            h = [f.f._inner[b - this.e][0], g.xAxis.ei(n, v), g.xAxis.ei(m, v)];
            return h;
        }
    }
    Stacked100BarBucketCalculator.$t = markType(Stacked100BarBucketCalculator, 'Stacked100BarBucketCalculator', StackedBarBucketCalculator.$);
    return Stacked100BarBucketCalculator;
})();
