/*
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 { __extends } from "tslib";
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
 */
var VerticalAnchoredCategorySeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(VerticalAnchoredCategorySeries, _super);
    function VerticalAnchoredCategorySeries() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.ut = null;
        return _this;
    }
    VerticalAnchoredCategorySeries.prototype.bv = function () {
        if (this.xAxis != null && this.xAxis.cg) {
            return 4;
        }
        return 3;
    };
    VerticalAnchoredCategorySeries.prototype.bw = function () {
        return 1;
    };
    VerticalAnchoredCategorySeries.prototype.kx = function () {
        _super.prototype.kx.call(this);
        this.xAxis = null;
        this.yAxis = null;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "uu", {
        get: function () {
            var _this = this;
            if (this.ut == null) {
                this.ut = DVContainer.instance.createInstance(IVerticalAnchoredCategorySeriesInteractionManager_$type, function () { return _this.cn.n; });
            }
            return this.ut;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.prototype.get_isVertical = function () {
        return true;
    };
    VerticalAnchoredCategorySeries.prototype.rs = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.sd = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.getOffsetValue = function () {
        return this.ry.r(this.rs(), this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
    };
    VerticalAnchoredCategorySeries.prototype.getCategoryWidth = function () {
        return this.yAxis.getCategorySize(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
    };
    VerticalAnchoredCategorySeries.prototype.hj = function (a, b) {
        return this.hk(a, b, this.rs(), runOn(this, this.sr), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.hl = function (a, b) {
        return this.hm(a, b, this.rs(), runOn(this, this.sr), this.valueColumn);
    };
    VerticalAnchoredCategorySeries.prototype.f5 = function (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));
    };
    VerticalAnchoredCategorySeries.prototype.aq = function (a) {
        if (a.isEmpty && this.cd != null) {
            a = this.cd.s9;
        }
        if (this.valueColumn == null) {
            return null;
        }
        var b = this.pv(this.b0);
        var c = this.rs();
        var d = new ScalerParams(0, a, this.cd.to, c.cg, this.getEffectiveViewport());
        var e = (c.el(b.top, d));
        var f = (c.el(b.bottom, d));
        if (!c.cg) {
            var g = e;
            e = f;
            f = g;
        }
        e -= this.tw;
        f += this.tw;
        var 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));
        var i = 1.7976931348623157E+308;
        var j = -1.7976931348623157E+308;
        if (truncate(e) <= truncate(f)) {
            for (var k = truncate(e); k <= truncate(f); k++) {
                var l = k;
                if (h != null) {
                    l = h.i$b._inner[k];
                }
                var 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);
            }
        }
        var n = new AxisRange(i, j);
        n = this.ao(n, this.sd(), a);
        return n;
    };
    VerticalAnchoredCategorySeries.prototype.bp = function () {
        if (this.bq == 0) {
            return 1;
        }
        else {
            return _super.prototype.bp.call(this);
        }
    };
    VerticalAnchoredCategorySeries.prototype.p1 = function (a) {
        if (!this.hasMarkers || !this.qj()) {
            return Rect.empty;
        }
        return this.uu.e$b(this, this.rt.m, a, runOn(this, this.u2));
    };
    VerticalAnchoredCategorySeries.prototype.u2 = function (a) {
        return this.tl.c9(a);
    };
    VerticalAnchoredCategorySeries.prototype.ex = function (a, b) {
        if (this.ew(a, b)) {
            return true;
        }
        if (this.qk(a, b)) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.gl = function (a, b, c) {
        if (this.cd == null) {
            return NaN;
        }
        var d = this.getEffectiveViewport1(this.b0);
        var e = this.rs();
        var f = new ScalerParams(0, this.cd.s9, this.b0.bu, e.cg, d);
        var 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);
    };
    VerticalAnchoredCategorySeries.prototype.pq = function (a, b, c) {
        var 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);
    };
    VerticalAnchoredCategorySeries.prototype.fetchXAxis = function () {
        return this.xAxis;
    };
    VerticalAnchoredCategorySeries.prototype.fetchYAxis = function () {
        return this.yAxis;
    };
    VerticalAnchoredCategorySeries.prototype.t8 = function (a) {
        this.xAxis = typeCast(NumericXAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.t9 = function (a) {
        this.yAxis = typeCast(CategoryYAxis.$, a);
    };
    VerticalAnchoredCategorySeries.prototype.sn = function () {
        return this.xAxis != null && this.xAxis.c0();
    };
    VerticalAnchoredCategorySeries.prototype.rm = function (a, b) {
        return this.ti(a, b, this.yAxis);
    };
    VerticalAnchoredCategorySeries.prototype.f7 = function (a) {
        return this.uu.e$a(this, a);
    };
    VerticalAnchoredCategorySeries.prototype.sr = function (a) {
        return this.f9(a, this.rs());
    };
    VerticalAnchoredCategorySeries.prototype.hf = function (a) {
        return truncate(Math.round(this.f7(a)));
    };
    VerticalAnchoredCategorySeries.prototype.hv = function (a) {
        var b = this.hf(a);
        return b >= 0 && this.ck != null && b < this.ck.count ? this.ck.item(b) : null;
    };
    VerticalAnchoredCategorySeries.prototype.l7 = function (a, b, c, d) {
        _super.prototype.l7.call(this, 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":
                var 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;
        }
    };
    VerticalAnchoredCategorySeries.prototype.ux = function (a) {
        if (typeCast(CategoryYAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    VerticalAnchoredCategorySeries.prototype.uw = function (a) {
        if (typeCast(NumericXAxis.$, a) !== null) {
            return true;
        }
        return false;
    };
    Object.defineProperty(VerticalAnchoredCategorySeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.so;
        },
        enumerable: false,
        configurable: true
    });
    VerticalAnchoredCategorySeries.$t = markType(VerticalAnchoredCategorySeries, 'VerticalAnchoredCategorySeries', AnchoredCategorySeries.$);
    VerticalAnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, VerticalAnchoredCategorySeries, 'raisePropertyChanged', ['XAxis::u0', [NumericXAxis.$, null], 'YAxis::u1', [CategoryYAxis.$, null]]);
    return VerticalAnchoredCategorySeries;
}(AnchoredCategorySeries));
export { VerticalAnchoredCategorySeries };
