/*
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 { CategorySeries } from "./CategorySeries";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { IHasSingleValueCategory_$type } from "./IHasSingleValueCategory";
import { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline";
import { ITrendLineSeries_$type } from "./ITrendLineSeries";
import { IAnchoredCategorySeriesInteractionManager_$type } from "./IAnchoredCategorySeriesInteractionManager";
import { DVContainer } from "igniteui-react-core";
import { Point_$type, enumGetBox, typeCast, runOn, delegateCombine, markType, markDep } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { Series } from "./Series";
import { TrendLineType_$type } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { PenLineCap_$type } from "igniteui-react-core";
import { DoubleCollection } from "igniteui-react-core";
import { CategoryFrame } from "./CategoryFrame";
import { ICategoryScaler_$type } from "./ICategoryScaler";
import { IScaler_$type } from "./IScaler";
import { CategorySeriesView } from "./CategorySeriesView";
import { CategorySeriesMarkerCollisionAvoidance_$type } from "./CategorySeriesMarkerCollisionAvoidance";
import { ConsolidatedItemHitTestBehavior_$type } from "./ConsolidatedItemHitTestBehavior";
import { CategoryFramePreparer } from "./CategoryFramePreparer";
import { DataLegendSeriesValueInfo } from "igniteui-react-core";
import { DataLegendSeriesContext } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { ISortingAxis_$type } from "./ISortingAxis";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { NumericAxisBase } from "./NumericAxisBase";
import { CategoryBucketCalculator } from "./CategoryBucketCalculator";
import { AxisRange } from "./AxisRange";
import { NumericYAxis } from "./NumericYAxis";
import { ScalerParams } from "./ScalerParams";
import { SeriesLayerPropertyOverlay } from "./SeriesLayerPropertyOverlay";
import { CategoryMarkerManager } from "./CategoryMarkerManager";
import { CollisionAvoider } from "./CollisionAvoider";
import { NonCollisionAvoider } from "./NonCollisionAvoider";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { CategoryTrendLineManagerFactory } from "./CategoryTrendLineManagerFactory";
/**
 * @hidden
 */
var AnchoredCategorySeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnchoredCategorySeries, _super);
    function AnchoredCategorySeries() {
        var _this = _super.call(this) || this;
        _this.xj = null;
        _this.xo = false;
        _this.xl = null;
        _this.xg = null;
        _this.xv = null;
        _this.xu = null;
        _this.xn = true;
        _this.xp = 0;
        _this.xq = 0;
        _this.vr = new CategoryFramePreparer(1, _this, _this.vv, _this, _this, _this.vv.cu);
        return _this;
    }
    Object.defineProperty(AnchoredCategorySeries.prototype, "xk", {
        get: function () {
            var _this = this;
            if (this.xj == null) {
                this.xj = DVContainer.instance.createInstance(IAnchoredCategorySeriesInteractionManager_$type, function () { return _this.c9.n; });
            }
            return this.xj;
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.prototype.getHostReferenceValue = function () {
        return this.h2();
    };
    AnchoredCategorySeries.prototype.kz = function () {
        return AnchoredCategorySeries.$$p[5];
    };
    AnchoredCategorySeries.prototype.cg = function () {
        var a = new AnchoredCategorySeriesView(this);
        return a;
    };
    AnchoredCategorySeries.prototype.o0 = function (a) {
        _super.prototype.o0.call(this, a);
        this.xf = a;
    };
    AnchoredCategorySeries.prototype.ju = function (a, b) {
        var c = this.lv(b);
        if (c == AnchoredCategorySeries.$$p[5]) {
            return this.jv(a, b, this.x5);
        }
        if (c == AnchoredCategorySeries.$$p[1]) {
            return this.jv(a, b, this.xx);
        }
        return _super.prototype.ju.call(this, a, b);
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "valueColumn", {
        get: function () {
            return this.xl;
        },
        set: function (a) {
            if (this.xl != a) {
                var b = this.xl;
                this.xl = a;
                if (!this.xo) {
                    this.raisePropertyChanged("ValueColumn", b, this.xl);
                }
            }
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.prototype.getDataLegendSeriesContextAt = function (a, b) {
        var c = new DataLegendSeriesValueInfo();
        c.a = 0;
        c.l = this.h9({ $type: Point_$type, x: a, y: b }, false, false);
        c.q = this.x5 != null ? this.x5 : "Value";
        c.p = "Value";
        c.r = this.x1 != null ? this.x1 : "V:";
        c.s = this.x3 != null ? this.x3 : "";
        var d = new DataLegendSeriesContext();
        d.f = ((function () {
            var $ret = new List$1(DataLegendSeriesValueInfo.$, 0);
            $ret.add(c);
            return $ret;
        })());
        d.b = this.aw();
        return d;
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "ys", {
        get: function () {
            return this.c(AnchoredCategorySeries.ye);
        },
        set: function (a) {
            this.h(AnchoredCategorySeries.ye, a);
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.prototype.fo = function (a) {
        var b = new Rect(0, 0, 0, 1, 1);
        var c = this.fetchXAxis();
        var d = this.fetchYAxis();
        var e = this.tq(this.cj);
        var f = c != null ? this.vr.r(typeCast(ICategoryScaler_$type, c), b, b, e) : 0;
        return this.xk.c$a(this, this.valueColumn, c, d, f, a);
    };
    AnchoredCategorySeries.prototype.xc = function (a, b, c) {
        if (b < a || a < 0 || a > this.valueColumn.count || b < 0 || b > this.valueColumn.count || c == null) {
            return null;
        }
        var d = new Array((b - a) + 1);
        var e = c.cn;
        var f = null;
        if (e) {
            f = c.i$b;
        }
        for (var g = a; g <= b; g++) {
            var h = g;
            if (e) {
                h = f._inner[h];
            }
            d[g - a] = this.c6.item(g);
        }
        return d;
    };
    AnchoredCategorySeries.prototype.o8 = function (a, b, c, d) {
        _super.prototype.o8.call(this, a, b, c, d);
        if (this.xf.c6 && this.xf.c5.g$b(a, b, c, d)) {
            var e = false;
            if (b == "FastItemsSource") {
                e = this.fq && c != null;
            }
            this.pp(e);
            this.ol();
        }
        switch (b) {
            case "FastItemsSource":
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.valueColumn);
                    this.valueColumn = null;
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.valueColumn = this.c3(this.x5);
                }
                var f = typeCast(NumericAxisBase.$, this.fetchYAxis());
                if (f != null && !f.c1()) {
                    this.xf.cu.g(this.hj);
                    this.pp(this.fq && c != null);
                }
                break;
            case AnchoredCategorySeries.$$p[5]:
                if (this.c6 != null) {
                    this.c6.deregisterColumn(this.valueColumn);
                    this.valueColumn = this.c3(this.x5);
                }
                this.xv = this.x5;
                break;
            case AnchoredCategorySeries.$$p[1]:
                this.xu = this.xx;
                this.pp(true);
                break;
            case "ValueColumn":
                if (this.xf.c6) {
                    this.xf.c5.g$i();
                }
                var g = typeCast(NumericAxisBase.$, this.fetchYAxis());
                if (g != null && !g.c1()) {
                    this.xf.cu.g(this.hj);
                    this.pp(this.fq && this.dn);
                }
                this.yd();
                this.qj();
                break;
            case "TrendLineBrush":
                this.pe(b);
                break;
            case "ErrorBarSettings":
                this.pp(false);
                break;
            case "TrendLineType":
                this.ol();
                break;
            case AnchoredCategorySeries.$$p[2]:
                this.pp(false);
                break;
        }
    };
    AnchoredCategorySeries.prototype.aq = function (a) {
        if (this.valueColumn == null || this.valueColumn.count == 0) {
            return null;
        }
        if (a == this.fetchXAxis()) {
            return new AxisRange(0, this.valueColumn.count - 1);
        }
        if (a == this.fetchYAxis()) {
            return new AxisRange(this.valueColumn.minimum, this.valueColumn.maximum);
        }
        return null;
    };
    AnchoredCategorySeries.prototype.no = function (a, b, c, d) {
        switch (a) {
            case 4:
            case 1:
            case 0:
                this.xf.cu.g(this.hj);
                break;
        }
        if (this.xf.c6) {
            this.xf.c5.g$e(a, b, c, d);
        }
        this.yd();
        this.qj();
        if (a == 0 || a == 2 || a == 3 || a == 4) {
            this.xn = true;
        }
        else if (a == 1) {
            for (var e = b; e < b + c; e++) {
                this.xp += this.valueColumn.item(e);
            }
            this.xq = this.xp / this.valueColumn.count;
        }
    };
    AnchoredCategorySeries.prototype.wm = function () {
        return this.xr(this.vv);
    };
    AnchoredCategorySeries.prototype.xr = function (a) {
        var b = 0;
        var c = a.by;
        var d = a.bx;
        var e = this.getEffectiveViewport1(a);
        var f = typeCast(NumericYAxis.$, this.fetchYAxis());
        if (!c.isEmpty && !d.isEmpty && f != null) {
            var g = new ScalerParams(0, c, d, f.ch, e);
            if (f.cp) {
                g.b = this.h2();
            }
            b = f.ej(f.l7, g);
        }
        return b;
    };
    AnchoredCategorySeries.prototype.yb = function (a, b, c) {
        var d = this.xr(c);
        if (a.count > 0) {
            var e = d;
            a.add({ $type: Point_$type, x: a._inner[a.count - 1].x, y: e });
            a.add({ $type: Point_$type, x: a._inner[0].x, y: e });
        }
    };
    AnchoredCategorySeries.prototype.xd = function (a, b, c, d) {
        return this.xe(a, b, c, d, false);
    };
    AnchoredCategorySeries.prototype.xe = function (a, b, c, d, e) {
        return CategorySeries.vg(a, b, c, d, e);
    };
    AnchoredCategorySeries.prototype.fn = function () {
        return this.highlightedItemsSource != null || this.xx != null;
    };
    AnchoredCategorySeries.prototype.g0 = function () {
        var a = _super.prototype.g0.call(this);
        {
            var b = ((function () {
                var $ret = new SeriesLayerPropertyOverlay();
                $ret.ad = "ValueMemberPath";
                $ret.p = true;
                $ret.y = "HighlightedValueMemberPath";
                $ret.q = true;
                return $ret;
            })());
            b.valueResolving = delegateCombine(b.valueResolving, runOn(this, this.x7));
            a.add(b);
        }
        return a;
    };
    AnchoredCategorySeries.prototype.x7 = function (a, b) {
        if (this.xx != null) {
            b.value = this.xx;
            return;
        }
        b.value = this.x5;
    };
    AnchoredCategorySeries.prototype.gl = function (a, b, c) {
        var d = _super.prototype.gl.call(this, a, b, c);
        var e = c;
        if (this.valueColumn == null || this.valueColumn.count == 0 || e.cu.d < 1) {
            d = false;
        }
        return d;
    };
    AnchoredCategorySeries.prototype.nj = function (a, b) {
        _super.prototype.nj.call(this, a, b);
        var c = b;
        c.c0();
        if (c.c6) {
            c.c5.g$d();
        }
    };
    AnchoredCategorySeries.prototype.w2 = function (a, b) {
        _super.prototype.w2.call(this, a, b);
        this.vs(b).d(a, b);
    };
    AnchoredCategorySeries.prototype.w5 = function (a, b) {
        _super.prototype.w5.call(this, a, b);
        var c = typeCast(AnchoredCategorySeriesView.$, b);
        c.b6 = true;
        if (c.c6) {
            c.c5.g$g(a.p);
        }
        if (this.uc()) {
            CategoryMarkerManager.e(this, a.m, b.cx, this.ue);
            this.wz(b, a);
            b.cp();
        }
        this.x8(a, b);
    };
    AnchoredCategorySeries.prototype.po = function (a, b, c, d, e) {
        _super.prototype.po.call(this, a, b, c, d, e);
        var f = this.a7.a$h.item(d);
        var g = f;
        g.cu.g(this.hj);
        f.a3(c);
        if (this.dl(g)) {
            return;
        }
        if (this.xg == null) {
            this.xg = new CategoryFrame(3);
        }
        this.xg.u();
        this.w2(this.xg, g);
        this.w5(this.xg, g);
    };
    AnchoredCategorySeries.prototype.x8 = function (a, b) {
    };
    AnchoredCategorySeries.prototype.qd = function () {
        _super.prototype.qd.call(this);
        if (this.index < 0) {
            return;
        }
        this.xf.da();
        if (this.trendLineBrush != null) {
            this.xf.c8();
        }
        else {
            this.xf.c7();
        }
    };
    AnchoredCategorySeries.prototype.jy = function (a, b) {
        if (this.xf.c6 && a == this.xf.c5.g$j) {
            return null;
        }
        return _super.prototype.jy.call(this, a, b);
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "currentCategoryMode", {
        get: function () {
            return this.preferredCategoryMode(typeCast(CategoryAxisBase.$, this.vl()));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "scaler", {
        get: function () {
            return typeCast(ICategoryScaler_$type, this.vl());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "yScaler", {
        get: function () {
            return typeCast(IScaler_$type, this.v6());
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "bucketizer", {
        get: function () {
            return this.xf.cu;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeries.prototype, "currentMode2Index", {
        get: function () {
            return this.wq();
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.prototype.provideCollisionDetector = function () {
        if (this.xh == 1) {
            return new CollisionAvoider();
        }
        return NonCollisionAvoider.b;
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "trendlinePreparer", {
        get: function () {
            return this.xf.c6 ? this.xf.c5 : null;
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.prototype.n1 = function (a) {
        _super.prototype.n1.call(this, a);
        if (this.xf.c6) {
            this.a9.exportTrendlineData(this, a, this.xf.c5.g$j);
        }
    };
    AnchoredCategorySeries.prototype.jr = function (a) {
        var _this = this;
        var b = this.fetchXAxis();
        var c = this.fetchYAxis();
        return this.xk.c$b(this, a, this.wn(this.cj), this.valueColumn, b, c, this.xi == 1, function (d) { return _super.prototype.jr.call(_this, d); });
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "mayContainUnknowns", {
        get: function () {
            return this.valueColumn == null || this.valueColumn.mayContainUnknowns;
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.prototype.h2 = function () {
        return Series.h3(this.valueColumn, typeCast(ISortingAxis_$type, this.fetchXAxis()));
    };
    AnchoredCategorySeries.prototype.get_xt = function () {
        return 0;
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "xt", {
        get: function () {
            return this.get_xt();
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.prototype.ar = function (a) {
        if (a.isEmpty && this.cy != null) {
            a = this.cy.tn;
        }
        if (this.valueColumn == null) {
            return null;
        }
        var b = this.to(this.cj);
        var c = this.vl();
        var d = new ScalerParams(0, a, this.cy.t2, c.ch, this.getEffectiveViewport());
        var e = (c.em(b.left, d));
        var f = (c.em(b.right, d));
        if (c.ch) {
            var g = e;
            e = f;
            f = g;
        }
        e -= this.xt;
        f += this.xt;
        var 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));
        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.ap(n, this.v6(), a);
        return n;
    };
    AnchoredCategorySeries.prototype.yd = function () {
        this.hr = this.valueColumn == null || this.valueColumn.count == 0 ? NaN : this.valueColumn.item(this.valueColumn.count - 1);
    };
    AnchoredCategorySeries.prototype.yc = function () {
        if (this.xn) {
            this.xp = 0;
            for (var a = 0; a < this.valueColumn.count; a++) {
                this.xp += this.valueColumn.item(a);
            }
            this.xq = this.xp / this.valueColumn.count;
            this.xn = false;
        }
    };
    AnchoredCategorySeries.prototype.ic = function (a, b) {
        if (b == null || !b.cj) {
            return NaN;
        }
        var c = this.v6();
        if (b != c) {
            return NaN;
        }
        var d = this.am(a);
        if (c.cp) {
            return d[1];
        }
        else {
            return d[0];
        }
    };
    AnchoredCategorySeries.prototype.am = function (a) {
        var b = NaN;
        switch (a) {
            case 5:
            case 2:
                b = this.valueColumn.maximum;
                break;
            case 4:
            case 1:
                b = this.valueColumn.minimum;
                break;
            case 6:
            case 3:
                if (this.xn) {
                    this.yc();
                }
                b = this.xq;
                break;
        }
        var c = this.v6();
        if (c.cp) {
            return [NaN, b];
        }
        else {
            return [b, NaN];
        }
    };
    AnchoredCategorySeries.prototype.tk = function (a) {
        var b = NaN;
        switch (a) {
            case 5:
            case 2:
                b = this.valueColumn.maximum;
                break;
            case 4:
            case 1:
                b = this.valueColumn.minimum;
                break;
            case 6:
            case 3:
                if (this.xn) {
                    this.yc();
                }
                b = this.xq;
                break;
        }
        if (isNaN_(b)) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var c = this.v6();
        var d = this.getEffectiveViewport1(this.cj);
        var e = new ScalerParams(0, this.cj.by, this.cj.bx, c.ch, d);
        if (c.cp) {
            e.b = this.h2();
        }
        e.c = d;
        if (c.cp) {
            return { $type: Point_$type, x: NaN, y: c.ej(b, e) };
        }
        else {
            return { $type: Point_$type, x: c.ej(b, e), y: NaN };
        }
    };
    AnchoredCategorySeries.prototype.tl = function (a) {
        var b = this.v6();
        var c = this.getEffectiveViewport1(this.cj);
        var d = new ScalerParams(0, this.cj.by, this.cj.bx, b.ch, c);
        if (b.cp) {
            d.b = this.h2();
        }
        d.c = c;
        if (b.cp) {
            return { $type: Point_$type, x: NaN, y: b.ej(a[1], d) };
        }
        else {
            return { $type: Point_$type, x: b.ej(a[0], d), y: NaN };
        }
    };
    Object.defineProperty(AnchoredCategorySeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.wi;
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeries.$t = markType(AnchoredCategorySeries, 'AnchoredCategorySeries', CategorySeries.$, [IIsCategoryBased_$type, IHasSingleValueCategory_$type, IHasCategoryTrendline_$type, ITrendLineSeries_$type]);
    AnchoredCategorySeries.ye = DependencyProperty.i("ActualTrendLineBrush", Brush.$, AnchoredCategorySeries.$, new PropertyMetadata(2, null, function (a, b) { return a.raisePropertyChanged("ActualTrendLineBrush", b.oldValue, b.newValue); }));
    AnchoredCategorySeries.$$p = markDep(DependencyProperty, PropertyMetadata, AnchoredCategorySeries, 'raisePropertyChanged', ['ConsolidatedItemHitTestBehavior:xi:yf', [ConsolidatedItemHitTestBehavior_$type, enumGetBox(ConsolidatedItemHitTestBehavior_$type, 0)], 'HighlightedValueMemberPath:xx:yg', [2, null], 'MarkerCollisionAvoidance:xh:yh', [CategorySeriesMarkerCollisionAvoidance_$type, enumGetBox(CategorySeriesMarkerCollisionAvoidance_$type, 1)], 'ValueMemberAsLegendLabel:x1:yp', [2, null], 'ValueMemberAsLegendUnit:x3:yq', [2, null], 'ValueMemberPath:x5:yr', [2, null], 'TrendLineType::yn', [TrendLineType_$type, enumGetBox(TrendLineType_$type, 0)], 'TrendLineThickness::ym', [1, 1.5], 'TrendLinePeriod::yl', [1, 7], 'TrendLineBrush::yi', [Brush.$, null], 'TrendLineZIndex:xs:yo', [1, 1001], 'TrendLineDashArray:yt:yj', [DoubleCollection.$], 'TrendLineDashCap:yu:yk', [PenLineCap_$type, enumGetBox(PenLineCap_$type, 0)]]);
    return AnchoredCategorySeries;
}(CategorySeries));
export { AnchoredCategorySeries };
/**
 * @hidden
 */
var AnchoredCategoryBucketCalculator = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnchoredCategoryBucketCalculator, _super);
    function AnchoredCategoryBucketCalculator(a) {
        var _this = _super.call(this, a) || this;
        _this.i = null;
        _this.h = null;
        _this.j = 0;
        _this.i = a;
        return _this;
    }
    AnchoredCategoryBucketCalculator.prototype.getBucketWithoutUnknowns = function (a) {
        var b = this.h;
        var c = this.j;
        var d = a * this.d;
        var e = d + this.d - 1;
        var f = c - 1;
        d = d < f ? d : f;
        e = e < f ? e : f;
        var g = 1.7976931348623157E+308;
        var h = -1.7976931348623157E+308;
        var i = true;
        for (var j = d; j <= e; ++j) {
            var k = b[j];
            g = g < k ? g : k;
            h = h > k ? h : k;
            i = false;
        }
        if (!i) {
            return [0.5 * (d + e), g, h];
        }
        return [0.5 * (d + e), NaN, NaN];
    };
    AnchoredCategoryBucketCalculator.prototype.getBucket = function (a) {
        var b = this.h;
        var c = this.j;
        var d = a * this.d;
        var e = d + this.d - 1;
        var f = c - 1;
        d = d < f ? d : f;
        e = e < f ? e : f;
        var g = 0;
        var h = 0;
        var i = true;
        for (var j = d; j <= e; ++j) {
            var k = b[j];
            if (!i) {
                if (!isNaN_(k)) {
                    g = g < k ? g : k;
                    h = h > k ? h : k;
                }
            }
            else {
                if (!isNaN_(k)) {
                    g = k;
                    h = k;
                    i = false;
                }
            }
        }
        if (!i) {
            return [0.5 * (d + e), g, h];
        }
        return [0.5 * (d + e), NaN, NaN];
    };
    AnchoredCategoryBucketCalculator.prototype.cacheValues = function () {
        this.j = this.i.c3.valueColumn.count;
        this.h = this.i.c3.valueColumn.asArray();
    };
    AnchoredCategoryBucketCalculator.prototype.unCacheValues = function () {
        this.h = null;
    };
    AnchoredCategoryBucketCalculator.$t = markType(AnchoredCategoryBucketCalculator, 'AnchoredCategoryBucketCalculator', CategoryBucketCalculator.$);
    return AnchoredCategoryBucketCalculator;
}(CategoryBucketCalculator));
export { AnchoredCategoryBucketCalculator };
/**
 * @hidden
 */
var AnchoredCategorySeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnchoredCategorySeriesView, _super);
    function AnchoredCategorySeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c3 = null;
        _this.c4 = null;
        _this.c3 = a;
        return _this;
    }
    Object.defineProperty(AnchoredCategorySeriesView.prototype, "c5", {
        get: function () {
            if (this.c4 == null) {
                this.c4 = CategoryTrendLineManagerFactory.a(this.c4, this.e.as(), this.e.qr, this.e, this.e.c9);
            }
            return this.c4;
        },
        set: function (a) {
            this.c4 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(AnchoredCategorySeriesView.prototype, "c6", {
        get: function () {
            return this.c4 != null;
        },
        enumerable: false,
        configurable: true
    });
    AnchoredCategorySeriesView.prototype.da = function () {
        this.c3.ys = null;
    };
    AnchoredCategorySeriesView.prototype.c8 = function () {
        this.c3.ys = this.c3.trendLineBrush;
    };
    AnchoredCategorySeriesView.prototype.c7 = function () {
        this.c3.ys = this.c3.ss;
    };
    AnchoredCategorySeriesView.prototype.cv = function () {
        return new AnchoredCategoryBucketCalculator(this);
    };
    AnchoredCategorySeriesView.prototype.c9 = function () {
        this.cu.cacheValues();
    };
    AnchoredCategorySeriesView.prototype.db = function () {
        this.cu.unCacheValues();
    };
    AnchoredCategorySeriesView.prototype.dc = function (a) {
        var b = this.cx.item(a);
        return this.cs(b);
    };
    AnchoredCategorySeriesView.prototype.a7 = function (a, b) {
        if (a.d) {
            if (this.c3.trendLineType != 0 && !b) {
                var c = this.c5.g$j;
                c.ad = this.c3.trendLineThickness;
                c._stroke = this.c3.ys;
                c.ai = this.c3.yt;
                c.aj = this.c3.yu;
                a.v(c);
            }
        }
        _super.prototype.a7.call(this, a, b);
    };
    AnchoredCategorySeriesView.prototype.getDefaultTooltipTemplate = function () {
        return this.c3.xk.c$c(this.e, this.c3.x5);
    };
    AnchoredCategorySeriesView.$t = markType(AnchoredCategorySeriesView, 'AnchoredCategorySeriesView', CategorySeriesView.$);
    return AnchoredCategorySeriesView;
}(CategorySeriesView));
export { AnchoredCategorySeriesView };
