/*
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 { AnchoredCategorySeries } from "./AnchoredCategorySeries";
import { NumericXAxis } from "./NumericXAxis";
import { DependencyProperty } from "igniteui-angular-core";
import { CategoryYAxis } from "./CategoryYAxis";
import { IVerticalAnchoredCategorySeriesInteractionManager_$type } from "./IVerticalAnchoredCategorySeriesInteractionManager";
import { DVContainer } from "igniteui-angular-core";
import { runOn, typeCast, EnumUtil, markType, markDep } from "igniteui-angular-core";
import { Axis } from "./Axis";
import { ScalerParams } from "./ScalerParams";
import { AxisRange } from "./AxisRange";
import { Rect } from "igniteui-angular-core";
import { TrendLineType_$type } from "igniteui-angular-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
/**
 * @hidden
 */
export let VerticalAnchoredCategorySeries = /*@__PURE__*/ (() => {
    class VerticalAnchoredCategorySeries extends AnchoredCategorySeries {
        constructor() {
            super(...arguments);
            this.ut = null;
        }
        bv() {
            if (this.xAxis != null && this.xAxis.cg) {
                return 4;
            }
            return 3;
        }
        bw() {
            return 1;
        }
        kx() {
            super.kx();
            this.xAxis = null;
            this.yAxis = null;
        }
        get uu() {
            if (this.ut == null) {
                this.ut = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, () => this.cn.n);
            }
            return this.ut;
        }
        get_isVertical() {
            return true;
        }
        rs() {
            return this.yAxis;
        }
        sd() {
            return this.xAxis;
        }
        getOffsetValue() {
            return this.ry.r(this.rs(), this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
        }
        getCategoryWidth() {
            return this.yAxis.getCategorySize(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
        }
        hj(a, b) {
            return this.hk(a, b, this.rs(), runOn(this, this.sr), this.valueColumn);
        }
        hl(a, b) {
            return this.hm(a, b, this.rs(), runOn(this, this.sr), this.valueColumn);
        }
        f5(a, b, c, d, e) {
            if (this.valueColumn == null) {
                return Number.POSITIVE_INFINITY;
            }
            return this.f6(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.sr));
        }
        aq(a) {
            if (a.isEmpty && this.cd != null) {
                a = this.cd.s9;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.pv(this.b0);
            let c = this.rs();
            let d = new ScalerParams(0, a, this.cd.to, c.cg, this.getEffectiveViewport());
            let e = (c.el(b.top, d));
            let f = (c.el(b.bottom, d));
            if (!c.cg) {
                let g = e;
                e = f;
                f = g;
            }
            e -= this.tw;
            f += this.tw;
            let h = null;
            if (c.cm) {
                h = c;
                e = h.i$f(e);
                f = h.i$f(f);
            }
            else {
                e = Math.floor(e);
                f = Math.ceil(f);
            }
            if (isNaN_(e) || isNaN_(f)) {
                return null;
            }
            e = Math.max(0, Math.min(this.valueColumn.count - 1, e));
            f = Math.max(0, Math.min(this.valueColumn.count - 1, f));
            let i = 1.7976931348623157E+308;
            let j = -1.7976931348623157E+308;
            if (truncate(e) <= truncate(f)) {
                for (let k = truncate(e); k <= truncate(f); k++) {
                    let l = k;
                    if (h != null) {
                        l = h.i$b._inner[k];
                    }
                    let m = this.valueColumn.item(l);
                    if (this.valueColumn.mayContainUnknowns) {
                        if (isInfinity(m) || isNaN_(m)) {
                            continue;
                        }
                    }
                    i = Math.min(i, m);
                    j = Math.max(j, m);
                }
            }
            let n = new AxisRange(i, j);
            n = this.ao(n, this.sd(), a);
            return n;
        }
        bp() {
            if (this.bq == 0) {
                return 1;
            }
            else {
                return super.bp();
            }
        }
        p1(a) {
            if (!this.hasMarkers || !this.qj()) {
                return Rect.empty;
            }
            return this.uu.e$b(this, this.rt.m, a, runOn(this, this.u2));
        }
        u2(a) {
            return this.tl.c9(a);
        }
        ex(a, b) {
            if (this.ew(a, b)) {
                return true;
            }
            if (this.qk(a, b)) {
                return true;
            }
            return false;
        }
        gl(a, b, c) {
            if (this.cd == null) {
                return NaN;
            }
            let d = this.getEffectiveViewport1(this.b0);
            let e = this.rs();
            let f = new ScalerParams(0, this.cd.s9, this.b0.bu, e.cg, d);
            let g = this.ry.r(e, this.cd.s9, this.b0.bu, d);
            return this.gn(this.valueColumn, a, e, f, g, runOn(this, this.sr), b, c);
        }
        pq(a, b, c) {
            let d = this.rs();
            return this.ps(a, b, c, this.ry.r(d, this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0)), this.sd(), d, null, null, null);
        }
        fetchXAxis() {
            return this.xAxis;
        }
        fetchYAxis() {
            return this.yAxis;
        }
        t8(a) {
            this.xAxis = typeCast(NumericXAxis.$, a);
        }
        t9(a) {
            this.yAxis = typeCast(CategoryYAxis.$, a);
        }
        sn() {
            return this.xAxis != null && this.xAxis.c0();
        }
        rm(a, b) {
            return this.ti(a, b, this.yAxis);
        }
        f7(a) {
            return this.uu.e$a(this, a);
        }
        sr(a) {
            return this.f9(a, this.rs());
        }
        hf(a) {
            return truncate(Math.round(this.f7(a)));
        }
        hv(a) {
            let b = this.hf(a);
            return b >= 0 && this.ck != null && b < this.ck.count ? this.ck.item(b) : null;
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            switch (b) {
                case VerticalAnchoredCategorySeries.$$p[0]:
                    if (c != d) {
                        this.k4(typeCast(Axis.$, c));
                        this.mc(typeCast(Axis.$, d));
                        this.r2.cr.g(this.fv);
                        if (this.cd != null) {
                            this.cd.l5();
                        }
                        this.ml(false);
                        this.ls();
                    }
                    break;
                case VerticalAnchoredCategorySeries.$$p[1]:
                    if (c != d) {
                        this.k4(typeCast(Axis.$, c));
                        this.mc(typeCast(Axis.$, d));
                        this.r2.cr.g(this.fv);
                        this.sn();
                        this.ml(false);
                        this.ls();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.tl.c2 = CategoryTrendLineManagerFactory.a(this.tl.c2, this.yAxis, this.nd, this, this.cn);
                    }
                    break;
            }
        }
        ux(a) {
            if (typeCast(CategoryYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        uw(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        get useHighMarkerFidelity() {
            return this.so;
        }
    }
    VerticalAnchoredCategorySeries.$t = markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::u0', [NumericXAxis.$, null], 'YAxis::u1', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
})();
