/*
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-react-core";
import { CategoryYAxis } from "./CategoryYAxis";
import { IVerticalAnchoredCategorySeriesInteractionManager_$type } from "./IVerticalAnchoredCategorySeriesInteractionManager";
import { DVContainer } from "igniteui-react-core";
import { runOn, typeCast, EnumUtil, markType, markDep } from "igniteui-react-core";
import { Axis } from "./Axis";
import { ScalerParams } from "./ScalerParams";
import { AxisRange } from "./AxisRange";
import { Rect } from "igniteui-react-core";
import { TrendLineType_$type } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
/**
 * @hidden
 */
export let VerticalAnchoredCategorySeries = /*@__PURE__*/ (() => {
    class VerticalAnchoredCategorySeries extends AnchoredCategorySeries {
        constructor() {
            super(...arguments);
            this.yw = null;
        }
        ce() {
            if (this.xAxis != null && this.xAxis.ch) {
                return 4;
            }
            return 3;
        }
        cf() {
            return 1;
        }
        ng() {
            super.ng();
            this.xAxis = null;
            this.yAxis = null;
        }
        get yx() {
            if (this.yw == null) {
                this.yw = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, () => this.c9.n);
            }
            return this.yw;
        }
        get_isVertical() {
            return true;
        }
        vl() {
            return this.yAxis;
        }
        v6() {
            return this.xAxis;
        }
        getOffsetValue() {
            return this.vr.r(this.vl(), this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj));
        }
        getCategoryWidth() {
            return this.yAxis.getCategorySize(this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj));
        }
        jd(a, b) {
            return this.je(a, b, this.vl(), runOn(this, this.wl), this.valueColumn);
        }
        jf(a, b) {
            return this.jg(a, b, this.vl(), runOn(this, this.wl), this.valueColumn);
        }
        ht(a, b, c, d, e) {
            if (this.valueColumn == null) {
                return Number.POSITIVE_INFINITY;
            }
            return this.hu(a, b, this.yAxis, d, e, this.valueColumn.count, runOn(this, this.wl));
        }
        ar(a) {
            if (a.isEmpty && this.cy != null) {
                a = this.cy.tn;
            }
            if (this.valueColumn == null) {
                return null;
            }
            let b = this.to(this.cj);
            let c = this.vl();
            let d = new ScalerParams(0, a, this.cy.t2, c.ch, this.getEffectiveViewport());
            let e = (c.em(b.top, d));
            let f = (c.em(b.bottom, d));
            if (!c.ch) {
                let g = e;
                e = f;
                f = g;
            }
            e -= this.xt;
            f += this.xt;
            let h = null;
            if (c.cn) {
                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.v6(), a);
            return n;
        }
        bx() {
            if (this.by == 0) {
                return 1;
            }
            else {
                return super.bx();
            }
        }
        tu(a) {
            if (!this.hasMarkers || !this.uc()) {
                return Rect.empty;
            }
            return this.yx.e$b(this, this.vm.m, a, runOn(this, this.y5));
        }
        y5(a) {
            return this.xf.dc(a);
        }
        f4(a, b) {
            if (this.f3(a, b)) {
                return true;
            }
            if (this.ud(a, b)) {
                return true;
            }
            return false;
        }
        h9(a, b, c) {
            if (this.cy == null) {
                return NaN;
            }
            let d = this.getEffectiveViewport1(this.cj);
            let e = this.vl();
            let f = new ScalerParams(0, this.cy.tn, this.cj.bx, e.ch, d);
            let g = this.vr.r(e, this.cy.tn, this.cj.bx, d);
            return this.ib(this.valueColumn, a, e, f, g, runOn(this, this.wl), b, c);
        }
        th(a, b, c) {
            let d = this.vl();
            return this.tj(a, b, c, this.vr.r(d, this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj)), this.v6(), d, null, null, null);
        }
        fetchXAxis() {
            return this.xAxis;
        }
        fetchYAxis() {
            return this.yAxis;
        }
        x9(a) {
            this.xAxis = typeCast(NumericXAxis.$, a);
        }
        ya(a) {
            this.yAxis = typeCast(CategoryYAxis.$, a);
        }
        wh() {
            return this.xAxis != null && this.xAxis.c1();
        }
        vf(a, b) {
            return this.xc(a, b, this.yAxis);
        }
        hv(a) {
            return this.yx.e$a(this, a);
        }
        wl(a) {
            return this.hx(a, this.vl());
        }
        i8(a) {
            return truncate(Math.round(this.hv(a)));
        }
        jr(a) {
            let b = this.i8(a);
            return b >= 0 && this.c6 != null && b < this.c6.count ? this.c6.item(b) : null;
        }
        o8(a, b, c, d) {
            super.o8(a, b, c, d);
            switch (b) {
                case VerticalAnchoredCategorySeries.$$p[0]:
                    if (c != d) {
                        this.np(typeCast(Axis.$, c));
                        this.pf(typeCast(Axis.$, d));
                        this.vv.cu.g(this.hj);
                        if (this.cy != null) {
                            this.cy.mf();
                        }
                        this.pp(false);
                        this.ol();
                    }
                    break;
                case VerticalAnchoredCategorySeries.$$p[1]:
                    if (c != d) {
                        this.np(typeCast(Axis.$, c));
                        this.pf(typeCast(Axis.$, d));
                        this.vv.cu.g(this.hj);
                        this.wh();
                        this.pp(false);
                        this.ol();
                    }
                    break;
                case "TrendLineType":
                    let e = EnumUtil.getEnumValue(TrendLineType_$type, d);
                    if (e != 0) {
                        this.xf.c5 = CategoryTrendLineManagerFactory.a(this.xf.c5, this.yAxis, this.qr, this, this.c9);
                    }
                    break;
            }
        }
        y0(a) {
            if (typeCast(CategoryYAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        yz(a) {
            if (typeCast(NumericXAxis.$, a) !== null) {
                return true;
            }
            return false;
        }
        get useHighMarkerFidelity() {
            return this.wi;
        }
    }
    VerticalAnchoredCategorySeries.$t = /*@__PURE__*/ markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::y3', [NumericXAxis.$, null], 'YAxis::y4', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
})();
