/*
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.u1 = null;
        }
        bw() {
            if (this.xAxis != null && this.xAxis.cg) {
                return 4;
            }
            return 3;
        }
        bx() {
            return 1;
        }
        kz() {
            super.kz();
            this.xAxis = null;
            this.yAxis = null;
        }
        get u2() {
            if (this.u1 == null) {
                this.u1 = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, () => this.co.n);
            }
            return this.u1;
        }
        get_isVertical() {
            return true;
        }
        rw() {
            return this.yAxis;
        }
        sh() {
            return this.xAxis;
        }
        getOffsetValue() {
            return this.r2.r(this.rw(), this.b1.bv, this.b1.bu, this.getEffectiveViewport1(this.b1));
        }
        getCategoryWidth() {
            return this.yAxis.getCategorySize(this.b1.bv, this.b1.bu, this.getEffectiveViewport1(this.b1));
        }
        hm(a, b) {
            return this.hn(a, b, this.rw(), runOn(this, this.sv), this.valueColumn);
        }
        ho(a, b) {
            return this.hp(a, b, this.rw(), runOn(this, this.sv), this.valueColumn);
        }
        f7(a, b, c, d, e) {
            if (this.valueColumn == null) {
                return Number.POSITIVE_INFINITY;
            }
            return this.f8(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.sv));
        }
        ar(a) {
            if (a.isEmpty && this.ce != null) {
                a = this.ce.ta;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.pz(this.b1);
            let c = this.rw();
            let d = new ScalerParams(0, a, this.ce.tp, 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.t3;
            f += this.t3;
            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.ap(n, this.sh(), a);
            return n;
        }
        bq() {
            if (this.br == 0) {
                return 1;
            }
            else {
                return super.bq();
            }
        }
        p5(a) {
            if (!this.hasMarkers || !this.qn()) {
                return Rect.empty;
            }
            return this.u2.e$b(this, this.rx.m, a, runOn(this, this.va));
        }
        va(a) {
            return this.tp.c9(a);
        }
        ez(a, b) {
            if (this.ey(a, b)) {
                return true;
            }
            if (this.qo(a, b)) {
                return true;
            }
            return false;
        }
        gn(a, b, c) {
            if (this.ce == null) {
                return NaN;
            }
            let d = this.getEffectiveViewport1(this.b1);
            let e = this.rw();
            let f = new ScalerParams(0, this.ce.ta, this.b1.bu, e.cg, d);
            let g = this.r2.r(e, this.ce.ta, this.b1.bu, d);
            return this.gp(this.valueColumn, a, e, f, g, runOn(this, this.sv), b, c);
        }
        ps(a, b, c) {
            let d = this.rw();
            return this.pu(a, b, c, this.r2.r(d, this.b1.bv, this.b1.bu, this.getEffectiveViewport1(this.b1)), this.sh(), d, null, null, null);
        }
        fetchXAxis() {
            return this.xAxis;
        }
        fetchYAxis() {
            return this.yAxis;
        }
        uf(a) {
            this.xAxis = typeCast(NumericXAxis.$, a);
        }
        ug(a) {
            this.yAxis = typeCast(CategoryYAxis.$, a);
        }
        sr() {
            return this.xAxis != null && this.xAxis.c0();
        }
        rq(a, b) {
            return this.tm(a, b, this.yAxis);
        }
        f9(a) {
            return this.u2.e$a(this, a);
        }
        sv(a) {
            return this.gb(a, this.rw());
        }
        hi(a) {
            return truncate(Math.round(this.f9(a)));
        }
        hy(a) {
            let b = this.hi(a);
            return b >= 0 && this.cl != null && b < this.cl.count ? this.cl.item(b) : null;
        }
        l9(a, b, c, d) {
            super.l9(a, b, c, d);
            switch (b) {
                case VerticalAnchoredCategorySeries.$$p[0]:
                    if (c != d) {
                        this.k6(typeCast(Axis.$, c));
                        this.me(typeCast(Axis.$, d));
                        this.r6.cr.g(this.fx);
                        if (this.ce != null) {
                            this.ce.l6();
                        }
                        this.mn(false);
                        this.lu();
                    }
                    break;
                case VerticalAnchoredCategorySeries.$$p[1]:
                    if (c != d) {
                        this.k6(typeCast(Axis.$, c));
                        this.me(typeCast(Axis.$, d));
                        this.r6.cr.g(this.fx);
                        this.sr();
                        this.mn(false);
                        this.lu();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.tp.c2 = CategoryTrendLineManagerFactory.a(this.tp.c2, this.yAxis, this.nf, this, this.co);
                    }
                    break;
            }
        }
        u5(a) {
            if (typeCast(CategoryYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        u4(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        get useHighMarkerFidelity() {
            return this.ss;
        }
    }
    VerticalAnchoredCategorySeries.$t = markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::u8', [NumericXAxis.$, null], 'YAxis::u9', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
})();
