/*
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 { Base, typeCast, markType, Array_$type, Number_$type, Point_$type, enumGetBox, runOn, delegateCombine, fromEnum, markDep } from "igniteui-react-core";
import { IBucketizer_$type } from "./IBucketizer";
import { ArgumentNullException } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { ISortingAxis_$type } from "./ISortingAxis";
import { ScalerParams } from "./ScalerParams";
import { Series } from "./Series";
import { truncate, intDivide, isNaN_, isInfinity } from "igniteui-react-core";
import { FramePreparer } from "./FramePreparer";
import { IIsCategoryBased_$type } from "./IIsCategoryBased";
import { List$1 } from "igniteui-react-core";
import { ISupportsMarkers_$type } from "./ISupportsMarkers";
import { IProvidesViewport_$type } from "./IProvidesViewport";
import { ISupportsErrorBars_$type } from "./ISupportsErrorBars";
import { CategoryFrame } from "./CategoryFrame";
import { PreparationParams } from "./PreparationParams";
import { IDateTimeAxis_$type } from "./IDateTimeAxis";
import { NumericAxisBase } from "./NumericAxisBase";
import { IHasCategoryTrendline_$type } from "./IHasCategoryTrendline";
import { IHasSingleValueCategory_$type } from "./IHasSingleValueCategory";
import { DefaultCategoryTrendlineHost } from "./DefaultCategoryTrendlineHost";
import { DefaultSingleValueProvider } from "./DefaultSingleValueProvider";
import { SingleValuesHolder } from "./SingleValuesHolder";
import { MarkerSeries } from "./MarkerSeries";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { ICategorySeriesInteractionManager_$type } from "./ICategorySeriesInteractionManager";
import { DVContainer } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { CategoryTransitionInMode_$type } from "./CategoryTransitionInMode";
import { HighlightingInfo } from "igniteui-react-core";
import { CategoryTransitionSourceFramePreparer } from "./CategoryTransitionSourceFramePreparer";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { Marker } from "./Marker";
import { MarkerSeriesView } from "./MarkerSeriesView";
import { CategorySeriesRenderManager } from "./CategorySeriesRenderManager";
import { Pool$1 } from "igniteui-react-core";
import { SeriesLayerPropertyOverlay } from "./SeriesLayerPropertyOverlay";
import { DoubleCollection } from "igniteui-react-core";
import { Clipper } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { round10N } from "igniteui-react-core";
/**
 * @hidden
 */
export let CategoryBucketCalculator = /*@__PURE__*/ (() => {
    class CategoryBucketCalculator extends Base {
        constructor(a) {
            super();
            this.c = null;
            this.e = 0;
            this.f = 0;
            this.d = 0;
            if (a == null) {
                throw new ArgumentNullException(0, "view");
            }
            this.c = a;
            this.e = -1;
            this.d = 0;
        }
        getBucket(a) {
            return null;
        }
        getBucketWithoutUnknowns(a) {
            return this.getBucket(a);
        }
        getErrorBucket(a, b) {
            return NaN;
        }
        g(a) {
            let b = this.c.by;
            let c = this.c.bx;
            let d = this.c.cy;
            let e = typeCast(CategoryAxisBase.$, d.fetchXAxis());
            let f = d.dl;
            if (b.isEmpty || c.isEmpty || e == null || f == null || f.count == 0) {
                this.d = 0;
                return;
            }
            let g = d.getEffectiveViewport1(this.c);
            let h = d.wd(this.c);
            let i = typeCast(ISortingAxis_$type, e);
            if (i == null || i.i$b == null) {
                let j = new ScalerParams(0, b, c, e.ch, g);
                let k = Math.floor(e.en(h.left, j));
                let l = Math.ceil(e.en(h.right, j));
                if (e.ch) {
                    l = Math.ceil(e.en(h.left, j));
                    k = Math.floor(e.en(h.right, j));
                }
                l = Math.min(l, e.lh - 1);
                let m = Math.floor((l - k + 1) * a / h.width);
                this.d = truncate(Math.max(1, m));
                this.e = truncate(Math.max(0, Math.floor(k / this.d) - 1));
                this.f = truncate(Math.ceil(l / this.d));
            }
            else {
                this.e = i.i$e(b, c, g, h);
                this.f = i.i$g(b, c, g, h);
                this.d = 1;
            }
        }
        getBucketInfo(a, b, c, d) {
            a = this.e;
            b = this.f;
            c = this.d;
            d = this.c.cy.ib;
            return {
                p0: a,
                p1: b,
                p2: c,
                p3: d
            };
        }
        cacheValues() {
        }
        unCacheValues() {
        }
    }
    CategoryBucketCalculator.$t = /*@__PURE__*/ markType(CategoryBucketCalculator, 'CategoryBucketCalculator', Base.$, [IBucketizer_$type]);
    return CategoryBucketCalculator;
})();
/**
 * @hidden
 */
export let CategoryFramePreparerBase = /*@__PURE__*/ (() => {
    class CategoryFramePreparerBase extends FramePreparer {
        constructor(a, ..._rest) {
            a = (a == void 0) ? 0 : a;
            switch (a) {
                case 0:
                    {
                        let c = _rest[0];
                        let d = [c, typeCast(ISupportsMarkers_$type, c), typeCast(IProvidesViewport_$type, c), typeCast(ISupportsErrorBars_$type, c), typeCast(IBucketizer_$type, c)];
                        {
                            let f = d[0];
                            let g = d[1];
                            let h = d[2];
                            let i = d[3];
                            let j = d[4];
                            super(1, g, h, i);
                            this.g = null;
                            this.h = null;
                            this.m = false;
                            this.o = new List$1(Array_$type, 0);
                            this.p = new List$1(Number_$type, 0);
                            this.n = new List$1(Number_$type, 0);
                            this.h = f;
                            this.g = j;
                        }
                    }
                    break;
                case 1:
                    {
                        let c = _rest[0];
                        let d = _rest[1];
                        let e = _rest[2];
                        let f = _rest[3];
                        let g = _rest[4];
                        super(1, d, e, f);
                        this.g = null;
                        this.h = null;
                        this.m = false;
                        this.o = new List$1(Array_$type, 0);
                        this.p = new List$1(Number_$type, 0);
                        this.n = new List$1(Number_$type, 0);
                        this.h = c;
                        this.g = g;
                    }
                    break;
            }
        }
        i(a) {
            let b = new PreparationParams();
            b.f = this.h.useHighMarkerFidelity;
            b.b = this.h.scaler;
            b.c = this.h.yScaler;
            b.d = typeCast(ISortingAxis_$type, b.b);
            b.a = typeCast(CategoryFrame.$, a);
            if (b.a == null || b.b == null || b.c == null) {
                return null;
            }
            let c;
            let d;
            let e;
            let f;
            let g = this.g.getBucketInfo(c, d, e, f);
            c = g.p0;
            d = g.p1;
            e = g.p2;
            f = g.p3;
            b.k = c;
            b.l = d;
            b.j = e;
            b.i = f;
            if (b.l < b.k) {
                return null;
            }
            let h;
            let i;
            let j;
            let k = this.a.getViewInfo(i, h);
            i = k.p0;
            h = k.p1;
            j = this.a.getEffectiveViewport();
            let l = this.a.getMainContentViewport();
            b.p = h;
            b.o = i;
            b.n = j;
            b.m = l;
            if (Rect.l_op_Equality(b.p, Rect.empty) || Rect.l_op_Equality(b.o, Rect.empty)) {
                return null;
            }
            if (this.h != null && (typeCast(Series.$, this.h) !== null && this.h.e9) && this.g != null) {
                b.e = true;
            }
            return b;
        }
        r(a, b, c, d) {
            return a.getSeriesOffset(b, c, d, this.h.currentMode2Index, this.h.currentCategoryMode);
        }
        s(a) {
            return this.r(a.b, a.p, a.o, a.n);
        }
        d(a, b) {
            let c = this.i(a);
            if (c == null || this.g == null) {
                return;
            }
            c.a.f.clear();
            c.a.k.clear();
            c.a.n.clear();
            c.a.q.clear();
            c.a.i.clear();
            c.a.h.clear();
            c.a.g.clear();
            if (c.a.m != null) {
                c.a.m.clear();
            }
            let d = this.c.shouldDisplayMarkers;
            let e = false;
            let f = this.s(c);
            let g = this.j(c);
            if (c.d != null && c.d.i$b != null && c.d.i$b.count != g.e) {
                return;
            }
            if (c.d != null && c.d.i$a) {
                c.d.i$h();
            }
            this.g.cacheValues();
            if (this.m && c.d != null && c.d.i$b.count > 0) {
                let h = c.d.i$b._inner[c.k];
                this.z(g, h, true, c.e);
                while ((isNaN_(g.c) || isNaN_(g.d)) && c.k > 0) {
                    c.k = c.k - 1;
                    h = c.d.i$b._inner[c.k];
                    this.z(g, h, true, c.e);
                }
                let i = c.d.i$b._inner[c.l];
                this.z(g, i, true, c.e);
                while ((isNaN_(g.c) || isNaN_(g.d)) && c.l < g.e - 1) {
                    c.l = c.l + 1;
                    i = c.d.i$b._inner[c.l];
                    this.z(g, i, true, c.e);
                }
            }
            if (this.m && c.d == null) {
                let j = c.k;
                let k = this.g.getBucket(j);
                while ((isNaN_(k[1]) || isNaN_(k[2])) && c.k > 0) {
                    c.k = c.k - 1;
                    j = c.k;
                    k = this.g.getBucket(j);
                }
                let l = c.l;
                k = this.g.getBucket(l);
                while ((isNaN_(k[1]) || isNaN_(k[2])) && c.l < (intDivide(g.e, c.j))) {
                    c.l = c.l + 1;
                    l = c.l;
                    k = this.g.getBucket(l);
                }
            }
            this.w(c, g, f);
            let m = this.t(c, g, f, d, e);
            this.c.updateMarkerCount(m);
            this.v(typeCast(CategoryFrame.$, a), b);
            this.g.unCacheValues();
            return;
        }
        v(a, b) {
        }
        get q() {
            return this.o;
        }
        t(a, b, c, d, e) {
            let f = 0;
            let g = false;
            let h = null;
            let i = false;
            let j = a.d != null;
            let k = a.p;
            let l = a.o;
            let m = typeCast(NumericAxisBase.$, a.c) !== null && a.c.lk;
            let n = a.f;
            let o = this.h.mayContainUnknowns;
            let p = this.o;
            let q = this.n;
            let r = this.p;
            p.clear();
            q.clear();
            r.clear();
            let s = this.g;
            let t = this.h.provideCollisionDetector();
            let u = 0;
            let v = a.n;
            let w = new ScalerParams(0, k, l, a.b.j$b, v);
            let x = ((() => {
                let $ret = new ScalerParams(0, k, l, a.c.j$b, v);
                $ret.b = typeCast(Series.$, this.h) !== null ? this.h.iw() : NaN;
                return $ret;
            })());
            if (j) {
                u = a.b.j$d(2, w) - a.b.j$d(1, w);
                i = this.k();
            }
            let y = a.k;
            let z = a.l;
            let aa = a.a.f;
            let ab = typeCast(IDateTimeAxis_$type, a.b);
            if (ab != null) {
                ab.StartTimeCursor();
            }
            for (let ac = y; ac <= z; ++ac) {
                let ad;
                if (!j) {
                    if (!o) {
                        ad = s.getBucketWithoutUnknowns(ac);
                    }
                    else {
                        ad = s.getBucket(ac);
                    }
                }
                else {
                    ad = ((() => { let ae = this.f(a, ac, b, u, g, h, c); ac = ae.p1; g = ae.p4; h = ae.p5; return ae.ret; })());
                }
                let ae = !m || (m && ad[1] > 0);
                let af = ad[0];
                if (!j || !isNaN_(ad[0])) {
                    aa.add(ad);
                    if (j) {
                        if (a.a.m == null) {
                            a.a.m = new List$1(Number_$type, 0);
                        }
                        a.a.m.add(ac * a.j);
                    }
                    if (g && i) {
                        if (h != null) {
                            aa.add(h);
                            if (j) {
                                if (a.a.m == null) {
                                    a.a.m = new List$1(Number_$type, 0);
                                }
                                a.a.m.add(ac * a.j);
                            }
                        }
                    }
                    if (d && ae) {
                        let ag = ac * a.j;
                        let ah = ag;
                        if (j && a.d.i$b != null && ag >= 0 && ag < a.d.i$b.count) {
                            ag = a.d.i$b._inner[ag];
                        }
                        let ai = new Array(ad.length);
                        ai[0] = ad[0];
                        ai[1] = ad[1];
                        ai[2] = ad[2];
                        if (n && ag < b.e) {
                            ai = new Array(ad.length);
                            ai[0] = af;
                            this.z(b, ag, true, a.e);
                            ai[1] = b.c;
                            ai[2] = b.d;
                        }
                        p.add(ai);
                        q.add(a.a.f.count - 1);
                        r.add(ag);
                    }
                }
            }
            if (ab != null) {
                ab.ResetTimeCursor();
            }
            this.y(a, c, j, w, x, e, d);
            if (d) {
                let aj = p.count;
                let ak;
                for (let al = 0; al < aj; al++) {
                    ak = p._inner[al];
                    if (this.l(a.a, ak, t, Math.min(r._inner[al], b.e - 1), f, q._inner[al])) {
                        ++f;
                    }
                }
            }
            return f;
        }
        k() {
            if (typeCast(Series.$, this.h) !== null) {
                return this.h.et;
            }
            return false;
        }
        f(a, b, c, d, e, f, g) {
            let h;
            f = null;
            e = false;
            let i = typeCast(CategorySeries.$, this.h);
            let j = a.o;
            let k = a.p;
            let l = a.n;
            let m = new ScalerParams(0, k, j, a.b.j$b, l);
            let n = new ScalerParams(0, k, j, a.c.j$b, l);
            let o = a.e;
            if (a.d == null || a.d.i$b == null || a.d.i$b.count == 0) {
                return {
                    ret: [NaN, NaN, NaN],
                    p1: b,
                    p4: e,
                    p5: f
                };
            }
            if (i != null && i.dl != null && i.dl.count < a.d.i$b.count) {
                return {
                    ret: [NaN, NaN, NaN],
                    p1: b,
                    p4: e,
                    p5: f
                };
            }
            let p = a.d.i$b._inner[b];
            let q = a.d.i$d(p);
            let r = q;
            this.z(c, p, false, o);
            while (b < a.l) {
                p = a.d.i$b._inner[b + 1];
                r = a.d.i$d(p);
                this.z(c, p, true, o);
                if (r - q >= d || isNaN_(c.c) || isNaN_(c.d)) {
                    if (e) {
                        let s = a.d.i$b._inner[b];
                        this.z(c, s, true, o);
                        f = [a.b.j$c(q, m), c.c, c.d];
                    }
                    break;
                }
                if (!e && this.k()) {
                    let t = a.d.i$b._inner[b];
                    this.z(c, t, true, o);
                    let u = [a.b.j$c(q, m), c.c, c.d];
                    if (!isNaN_(u[0])) {
                        if (!isNaN_(u[1]) && !isNaN_(u[2])) {
                            if (a.d != null) {
                                u[0] = u[0] + g;
                            }
                            a.a.f.add(u);
                            if (a.d != null) {
                                if (a.a.m == null) {
                                    a.a.m = new List$1(Number_$type, 0);
                                }
                                a.a.m.add(b);
                            }
                            e = true;
                        }
                        else {
                            break;
                        }
                    }
                }
                b++;
                this.u(c, p, o);
            }
            let v = NaN;
            if (!isNaN_(q)) {
                v = a.b.j$c(q, m);
            }
            h = this.e(v, c);
            return {
                ret: h,
                p1: b,
                p4: e,
                p5: f
            };
        }
        y(a, b, c, d, e, f, g) {
            let h = a.j;
            let i = a.a.f.count;
            let j = a.a.f;
            let k = this.o;
            let l = k.count;
            if (f) {
                let m = a.c.j$c(a.c.l8, e);
                a.c.j$f(a.a.k, 0, a.a.k.count, e);
                let n = a.a.k;
                let o = n.count;
                for (let p = 0; p < n.count; p++) {
                    n._inner[p] = Math.abs(n._inner[p] - m);
                }
            }
        }
        w(a, b, c) {
        }
    }
    CategoryFramePreparerBase.$t = /*@__PURE__*/ markType(CategoryFramePreparerBase, 'CategoryFramePreparerBase', FramePreparer.$);
    return CategoryFramePreparerBase;
})();
/**
 * @hidden
 */
export let CategoryFramePreparer = /*@__PURE__*/ (() => {
    class CategoryFramePreparer extends CategoryFramePreparerBase {
        constructor(a, ..._rest) {
            a = (a == void 0) ? 0 : a;
            switch (a) {
                case 0:
                    {
                        let c = _rest[0];
                        let d = [c, typeCast(ISupportsMarkers_$type, c), typeCast(IProvidesViewport_$type, c), typeCast(ISupportsErrorBars_$type, c), typeCast(IBucketizer_$type, c)];
                        {
                            let f = d[0];
                            let g = d[1];
                            let h = d[2];
                            let i = d[3];
                            let j = d[4];
                            super(1, f, g, h, i, j);
                            this.aa = new DefaultCategoryTrendlineHost();
                            this.ab = new DefaultSingleValueProvider();
                            this.ac = null;
                            this.ad = null;
                            this.ac = this.aa;
                            if (typeCast(IHasCategoryTrendline_$type, f) !== null) {
                                this.ac = typeCast(IHasCategoryTrendline_$type, f);
                            }
                            this.ad = this.ab;
                            if (typeCast(IHasSingleValueCategory_$type, f) !== null) {
                                this.ad = typeCast(IHasSingleValueCategory_$type, f);
                            }
                        }
                    }
                    break;
                case 1:
                    {
                        let c = _rest[0];
                        let d = _rest[1];
                        let e = _rest[2];
                        let f = _rest[3];
                        let g = _rest[4];
                        super(1, c, d, e, f, g);
                        this.aa = new DefaultCategoryTrendlineHost();
                        this.ab = new DefaultSingleValueProvider();
                        this.ac = null;
                        this.ad = null;
                        this.ac = this.aa;
                        if (typeCast(IHasCategoryTrendline_$type, c) !== null) {
                            this.ac = typeCast(IHasCategoryTrendline_$type, c);
                        }
                        this.ad = this.ab;
                        if (typeCast(IHasSingleValueCategory_$type, c) !== null) {
                            this.ad = typeCast(IHasSingleValueCategory_$type, c);
                        }
                    }
                    break;
            }
        }
        l(a, b, c, d, e, f) {
            let g = b[0];
            let h = b[1];
            let i = new Rect(0, g - 5, h - 5, 11, 11);
            if (!isNaN_(g) && !isNaN_(h) && !isInfinity(g) && !isInfinity(h) && c.tryAdd(i)) {
                a.n.add({ $type: Point_$type, x: g, y: h });
                this.c.updateMarkerTemplate(e, d, f);
                return true;
            }
            return false;
        }
        j(a) {
            let b = new SingleValuesHolder();
            let c = this.ad.valueColumn;
            b.f = c;
            return b;
        }
        x(a, b, c, d, e, f) {
            if (d) {
                b[0] = b[0] + c;
            }
            else {
                b[0] = a.b.j$c(b[0], e) + c;
            }
            b[1] = a.c.j$c(b[1], f);
            if (a.j > 1 || d) {
                b[2] = a.c.j$c(b[2], f);
            }
            else {
                b[2] = b[1];
            }
        }
        y(a, b, c, d, e, f, g) {
            super.y(a, b, c, d, e, f, g);
            let h = a.j;
            let i = a.a.f.count;
            let j = a.a.f;
            let k = this.q;
            let l = k.count;
            let m = new List$1(Number_$type, 0);
            if (!c) {
                m.add(0);
            }
            let n = new List$1(Number_$type, 0);
            n.add(1);
            if (c || h > 1) {
                n.add(2);
            }
            a.b.j$e(j, m, 0, i, d);
            a.c.j$e(j, n, 0, i, e);
            for (let o = 0; o < i; o++) {
                j._inner[o][0] = j._inner[o][0] + b;
            }
            if (h == 1 && !c) {
                for (let p = 0; p < i; p++) {
                    j._inner[p][2] = j._inner[p][1];
                }
            }
            if (g) {
                a.b.j$e(k, m, 0, l, d);
                a.c.j$e(k, n, 0, l, e);
                for (let q = 0; q < l; q++) {
                    k._inner[q][0] = k._inner[q][0] + b;
                }
                if (h == 1 && !c) {
                    for (let r = 0; r < l; r++) {
                        k._inner[r][2] = k._inner[r][1];
                    }
                }
            }
        }
        w(a, b, c) {
            if (this.ac.trendLineType == 0 || this.ac.trendlinePreparer == null || this.ac.trendLinePeriod < 1) {
                return;
            }
            this.ac.trendlinePreparer.prepareLine(this.ac, a, b, c);
        }
        z(a, b, c, d) {
            let e = a;
            let f = e.f;
            let g = f.item(b);
            let h = g;
            if (d) {
                let i = this.g.getBucket(b);
                g = i[1];
                h = i[1];
            }
            if (c) {
                e.c = g;
                e.d = h;
            }
            else {
                e.a = g;
                e.b = h;
            }
        }
        u(a, b, c) {
            let d = a;
            let e = d.f;
            if (b < e.count) {
                let f;
                if (c) {
                    let g = this.g.getBucket(b);
                    f = g[1];
                }
                else {
                    f = e.item(b);
                }
                d.a = Math.min(d.a, f);
                d.b = Math.max(d.b, f);
            }
        }
        e(a, b) {
            let c = b;
            return [a, c.a, c.b];
        }
    }
    CategoryFramePreparer.$t = /*@__PURE__*/ markType(CategoryFramePreparer, 'CategoryFramePreparer', CategoryFramePreparerBase.$);
    return CategoryFramePreparer;
})();
/**
 * @hidden
 */
export let CategorySeries = /*@__PURE__*/ (() => {
    class CategorySeries extends MarkerSeries {
        cq() {
            let a = new CategorySeriesView(this);
            return a;
        }
        get yz() {
            if (this.yy == null) {
                this.yy = DVContainer.instance.createInstance(ICategorySeriesInteractionManager_$type, () => this.dp.n);
            }
            return this.yy;
        }
        d9(a, b, c, d) {
            if (!this.hasMarkers) {
                return false;
            }
            let e = this.getEffectiveViewport1(this.ct);
            let f = this.yk();
            let g = new ScalerParams(1, this.c9.vl, this.wl, f.ch);
            g.c = e;
            let h = this.y0();
            let i = new ScalerParams(1, this.c9.vl, this.wl, h.ch);
            i.c = e;
            let j = this.c9.vl;
            let k = this.wl;
            let l = this.currentMode2Index;
            let m = 0;
            if (f.ce && f.cc) {
                m = f.getSeriesOffset(j, k, e, l, f.categoryMode);
            }
            a.clear();
            this.wy.cj((n) => {
                if (n._visibility == 0) {
                    let o = new SeriesPointOfInterest();
                    let p = n.n;
                    let q = n.o;
                    if (p < this.wl.left || p > this.wl.right || q < this.wl.top || q > this.wl.bottom) {
                        return;
                    }
                    if (this.isVertical) {
                        if (f.cb && !f.ce && f.categoryMode != 0) {
                            o.e = n.ak;
                        }
                        else {
                            o.e = f.en(q, g);
                        }
                        o.d = h.en(p, i);
                    }
                    else {
                        if (f.cb && !f.ce && f.categoryMode != 0) {
                            o.d = n.ak;
                        }
                        else {
                            o.d = f.en(p, g);
                        }
                        o.e = h.en(q, i);
                    }
                    o.b = n.content;
                    if (b) {
                        if (this.isVertical) {
                            if (c) {
                                o.f = this.zq(o.d, d);
                            }
                            else {
                                let r = this.jb(n);
                                if (!isNaN_(r)) {
                                    o.f = this.zq(r, d);
                                }
                                else {
                                    o.f = this.zq(o.d, d);
                                }
                            }
                        }
                        else {
                            if (c) {
                                o.f = this.zq(o.e, d);
                            }
                            else {
                                let s = this.jb(n);
                                if (!isNaN_(s)) {
                                    o.f = this.zq(s, d);
                                }
                                else {
                                    o.f = this.zq(o.e, d);
                                }
                            }
                        }
                    }
                    else {
                        let t = this.at(true);
                        if (t != null) {
                            let u = this.kq(n.ak, false);
                            if (u != null) {
                                o.f = t.i(u);
                            }
                            else {
                                o.f = null;
                            }
                        }
                        else {
                            o.f = f.ge(n.ak);
                        }
                    }
                    o.c = n.ak;
                    o.g = this.va;
                    if (this.g7) {
                        o.g = this.vh(n.ak);
                    }
                    a.add(o);
                }
            });
            return true;
        }
        zq(a, b) {
            let c;
            if (b >= 0) {
                c = round10N(a, b);
            }
            else {
                c = a;
            }
            let d = this.at(false);
            if (d != null) {
                let e = d;
                return e.i(c);
            }
            else {
                return c.toString();
            }
        }
        qx(a) {
            super.qx(a);
            this.yu = a;
        }
        preferredCategoryMode(a) {
            return 0;
        }
        get categoryAxis() {
            return this.yk();
        }
        yk() {
            return this.fetchXAxis();
        }
        y0() {
            return this.fetchYAxis();
        }
        get_ei() {
            return true;
        }
        get_f3() {
            return this.y0() != null && this.y0().ch;
        }
        get_ew() {
            return true;
        }
        constructor() {
            super();
            this.yq = null;
            this.yy = null;
            this.y7 = false;
            this.y6 = false;
            this.assigningCategoryStyle = null;
            this.assigningCategoryMarkerStyle = null;
            this.y4 = null;
            this.y5 = null;
            this.yn = new CategoryFrame(3);
            this.yp = new CategoryFrame(3);
            this.yl = new CategoryFrame(3);
            this.yo = new CategoryFrame(3);
            this.yt = null;
            this.yx = null;
            this.yt = new CategorySeriesRenderManager();
            this.yx = new CategoryTransitionSourceFramePreparer();
            this.y7 = false;
            this.d0 = false;
            this.y6 = false;
            this.ab = CategorySeries.$;
        }
        ac() {
            super.ac();
            this.yu.cw.g(this.ib);
        }
        zd() {
            return (this.assigningCategoryStyle != null && this.y7) || (this.bv != 1) || this.d0 || (this.cn != 1) || (this.cm != 1);
        }
        ze() {
            return (this.assigningCategoryMarkerStyle != null && this.y6) || (this.bv != 1) || this.d0 || (this.cn != 1) || (this.cm != 1);
        }
        z3(a) {
            if (this.assigningCategoryStyle != null && this.y7) {
                this.assigningCategoryStyle(this, a);
            }
        }
        z2(a) {
            if (this.assigningCategoryMarkerStyle != null && this.y6) {
                this.assigningCategoryMarkerStyle(this, a);
            }
        }
        ye(a, b) {
            return null;
        }
        o3(a, b) {
            super.o3(a, b);
            if (a) {
                this.zx(b);
            }
        }
        bp() {
            let a = super.bp();
            return a;
        }
        p6() {
            super.p6();
            let a = this.fetchXAxis();
            if (a != null) {
                a.h9(false);
            }
            let b = this.fetchYAxis();
            if (b != null) {
                b.h9(false);
            }
        }
        sl(a, b) {
            super.sl(a, b);
            this.yu.cw.g(this.ib);
            this.rn(false);
        }
        sk(a, b) {
            if (this.gz && this.jo < 0.05 && (this.c9 == null || !this.c9.fj())) {
                this.g0 = true;
                this.g3 = false;
                this.gi = false;
            }
            super.sk(a, b);
            this.yu.cw.g(this.ib);
            this.rn(false);
        }
        q5(a, b, c, d) {
            super.q5(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    let e = this.fetchYAxis();
                    let f = this.fetchXAxis();
                    if (c != null && d == null) {
                        this.pa(f);
                        this.pa(e);
                    }
                    if (c == null && d != null) {
                        this.rd(f);
                        this.rd(e);
                    }
                    this.yu.cw.g(this.ib);
                    this.rn(false);
                    break;
                case "SyncLink":
                    if (this.c1 != null && this.c9 != null) {
                        this.yu.cw.g(this.ib);
                    }
                    this.rn(false);
                    break;
                case "TransitionProgress":
                    this.yp.c(this.jo, this.yn, this.yl);
                    if (this.d3(this.ct)) {
                        return;
                    }
                    if (this.jo == 1) {
                        this.yl.w();
                        this.z4(this.yl, this.yu);
                        if (this.gz) {
                            this.gz = false;
                            this.o4();
                            this.da.r = truncate(this.i7());
                            this.da.b = this.db;
                        }
                        if (this.g2) {
                            this.g2 = false;
                            this.o4();
                            this.da.r = truncate(this.i7());
                            this.da.b = this.db;
                            this.qw();
                        }
                        this.qk();
                    }
                    else {
                        this.z4(this.yp, this.yu);
                    }
                    if (this.c9 != null) {
                        this.c9.qa(this);
                    }
                    break;
                case "ErrorBarSettings":
                    this.qh();
                    break;
                case CategorySeries.$$p[4]:
                    this.rn(false);
                    break;
                case CategorySeries.$$p[1]:
                    this.y7 = this.y9();
                    this.rn(false);
                    break;
                case CategorySeries.$$p[0]:
                    this.y6 = this.y8();
                    this.rn(false);
                    break;
            }
        }
        y9() {
            return this.zb;
        }
        y8() {
            return this.za;
        }
        zk(a) {
            return this.ir(a, this.fetchXAxis());
        }
        get_fq() {
            return typeCast(ISortingAxis_$type, this.yk()) !== null;
        }
        az() {
            return this.yk();
        }
        j3(a) {
            return this.yz.b$d(this, a);
        }
        kl(a) {
            return this.yz.b$f(this, a);
        }
        j1(a) {
            let b = truncate(Math.round(this.ip(a)));
            return b;
        }
        ip(a) {
            return this.yz.b$c(this, a);
        }
        df(a, b, c) {
            if (this.fx(this.bv) && !c) {
                let d = this.y3(a, b, this.y5);
                this.y5 = d;
                return d;
            }
            else {
                let e = this.y1(a, b, this.y5);
                e.d = true;
                this.y5 = e;
                return e;
            }
        }
        get_fc() {
            return true;
        }
        o1() {
            super.o1();
            this.y4 = null;
            this.y5 = null;
        }
        de(a, b, c) {
            if (this.eb && this.fx(this.bv) && !c) {
                let d = this.y2(a, b, this.y4);
                this.y4 = d;
                return d;
            }
            else {
                let e = this.y1(a, b, this.y4);
                this.y4 = e;
                return e;
            }
        }
        zj() {
            return this.yu.cz.a;
        }
        y3(a, b, c) {
            if (!this.w8()) {
                return null;
            }
            let d = this.ym();
            let e = this.zj();
            return this.yz.b$b(this, e, this.zn(this.ct), this.zm(this.ct), d.f, a, b, c);
        }
        y2(a, b, c) {
            let d = this.zn(this.ct);
            let e = this.zo(this.ct);
            let f = this.zm(this.ct);
            let g = this.ym();
            return this.yz.b$a(this, g.f, g.m, d, e, f, a, b, c);
        }
        y1(a, b, c) {
            let d = new HighlightingInfo();
            d.i = this;
            d.g = 0;
            d.f = this.dl != null ? this.dl.count - 1 : 0;
            d.c = true;
            if (c != null && c.g == d.g && c.f == d.f) {
                return c;
            }
            return d;
        }
        ym() {
            let a = this.yl;
            if (this.d1()) {
                if (this.da.g) {
                    this.da.t();
                }
                a = this.yp;
            }
            return a;
        }
        zz(a, b, c, d, e, f, g) {
            let h = this.bv != 1;
            let i = this.d0;
            let j = this.cn != 1;
            let k = this.cm != 1;
            this.yt.a3(this.yt.d, d.cn, a, b, c, d, e, f, true, g);
            this.yt.aa(this.h9);
            let l = this.yt.ax;
            let m = null;
            let n = this.dl;
            let o = null;
            let p = null;
            let q = null;
            let r = null;
            let s = null;
            if (i && this.c9 != null && !l.e) {
                let t = this.vi(l.z);
                let u = this.vj(l.z);
                this.yt.ae = t;
                this.yt.af = u;
                l.aa = t;
                l.ab = u;
            }
            if (h && this.c9 != null) {
                m = this.c9.dj.getHighlightingInfo(this, n, l.z, l.y, true);
                if (this.c9.dj.isCrossContextHighlight(this)) {
                    o = this.c9.dj.getHighlightingInfo(this, n, l.z, l.y, true);
                }
                l.c = m;
            }
            if (j && this.c9 != null) {
                p = this.c9.dk.getHighlightingInfo(this, n, l.z, l.y, true);
                if (p == null && this.bl != null) {
                    p = this.c9.dk.getHighlightingInfo(this.bl, this.bl.dl, l.z, l.y, true);
                }
                if (this.c9.dk.isCrossContextHighlight(this)) {
                    r = this.c9.dk.getHighlightingInfo(this, n, l.z, l.y, true);
                }
                l.d = p;
            }
            if (k && this.c9 != null) {
                q = this.c9.di.getHighlightingInfo(this, n, l.z, l.y, true);
                if (this.c9.di.isCrossContextHighlight(this)) {
                    s = this.c9.di.getHighlightingInfo(this, n, l.z, l.y, true);
                }
                l.b = q;
            }
            l.h = f;
            this.z2(l);
            this.yt.y(this, m, p, q, f, h, j, k, l.v, this.c9.dj.totalHighWaterMark, l.x, this.c9.dk.totalHighWaterMark, l.t, this.c9.di.totalHighWaterMark);
        }
        z0(a, b, c, d, e, f, g) {
            let h = this.bv != 1;
            let i = this.cn != 1;
            let j = this.cm != 1;
            let k = this.d0;
            this.yt.a3(this.yt.b, d.cn, a, b, c, d, e, f, false, g);
            this.yt.ab(this.h9);
            let l = this.yt.ay;
            let m = null;
            let n = null;
            let o = null;
            let p = this.dl;
            if (k && this.c9 != null && !l.e) {
                let q = this.vh(l.z);
                let r = this.vk(l.z);
                this.yt.ag = q;
                this.yt.ah = r;
                l.aa = q;
                l.ab = r;
            }
            if (h && this.c9 != null) {
                m = this.c9.dj.getHighlightingInfo(this, p, l.z, l.y, false);
                l.c = m;
            }
            if (i && this.c9 != null) {
                n = this.c9.dk.getHighlightingInfo(this, p, l.z, l.y, false);
                if (n == null && this.bl != null) {
                    n = this.c9.dk.getHighlightingInfo(this.bl, this.bl.dl, l.z, l.y, false);
                }
                l.d = n;
            }
            if (j && this.c9 != null) {
                o = this.c9.di.getHighlightingInfo(this, p, l.z, l.y, false);
                if (o == null && this.bl != null) {
                    o = this.c9.di.getHighlightingInfo(this.bl, this.bl.dl, l.z, l.y, false);
                }
                l.b = o;
            }
            l.h = f;
            this.z3(l);
            this.yt.z(this, m, n, o, f, h, i, j, b < 0);
        }
        hc(a, b, c) {
            let d = super.hc(a, b, c);
            d = d && this.zi(this.fetchXAxis());
            d = d && this.zi(this.fetchYAxis());
            let e = c;
            if (!c.o() || b.isEmpty || a.isEmpty || this.dl == null) {
                d = false;
            }
            if (!d) {
                e.cw.d = 0;
            }
            return d;
        }
        zi(a) {
            if (a == null || a.bi == null) {
                return false;
            }
            let b = typeCast(CategoryAxisBase.$, a);
            if (b != null) {
                if (b.itemsSource == null) {
                    return false;
                }
                if (b.lg < 1) {
                    return false;
                }
            }
            else {
                let c = typeCast(NumericAxisBase.$, a);
                if (c != null) {
                    return c.ly != c.lx;
                }
            }
            return true;
        }
        gl() {
            return this.zc;
        }
        gm() {
            return true;
        }
        yv() {
            return 12;
        }
        o4() {
            super.o4();
            this.yn.w();
            this.yl.w();
            this.yp.w();
        }
        ro(a) {
            super.ro(a);
            this.yu.cw.g(this.ib);
            if (this.d3(this.ct)) {
                this.yl.z();
                this.yp.z();
                this.yn.z();
                return;
            }
            if (this.gp) {
                if (this.d1()) {
                    if (this.da.g) {
                        this.da.t();
                    }
                    this.z4(this.yp, this.yu);
                }
                else {
                    this.z4(this.yl, this.yu);
                }
                return;
            }
            if (this.gd(a)) {
                let b = this.yn;
                if (this.d1()) {
                    if (this.da.g) {
                        this.da.t();
                    }
                    this.yn = this.yp;
                    this.yp = b;
                }
                else {
                    this.yn = this.yl;
                    this.yl = b;
                }
                let c = false;
                this.z1(this.yl, this.yu);
                if (this.g1) {
                    this.da.w();
                    this.da.r = truncate(this.i8());
                    this.da.b = this.dc != null ? this.dc : this.db;
                    if (this.g2) {
                        let d = this.yp;
                        this.yp = this.yn;
                        this.yn = d;
                        c = true;
                    }
                    this.yx.s(this, this.yn, this.yl, this.isVertical, this.fetchXAxis(), this.fetchYAxis(), this.yw, this.yv(), this.c3, this.c2(), runOn(this, this.zl), this.yu.bx);
                    if (this.g2) {
                        let e = this.yp;
                        this.yp = this.yn;
                        this.yn = e;
                    }
                    this.g2 = false;
                }
                if (this.g4) {
                    this.da.w();
                    this.da.r = truncate(this.i9());
                    this.da.b = this.dd != null ? this.dd : this.db;
                    if (this.gz) {
                        let f = this.yp;
                        this.yp = this.yn;
                        this.yn = f;
                        c = true;
                    }
                    this.yx.s(this, this.yn, this.yl, this.isVertical, this.fetchXAxis(), this.fetchYAxis(), this.yw, this.yv(), this.c3, this.c2(), runOn(this, this.zl), this.yu.bx);
                    let g = this.yl;
                    this.yl = this.yn;
                    this.yn = g;
                    if (this.gz) {
                        let h = this.yp;
                        this.yp = this.yn;
                        this.yn = h;
                    }
                    this.gz = false;
                }
                this.d7 = false;
                if (!c) {
                    this.oz();
                }
                this.r1();
                if (this.g1) {
                    this.g0 = false;
                    this.gz = true;
                }
                if (this.g4) {
                    this.g3 = false;
                    this.g2 = true;
                }
            }
            else {
                this.z1(this.yl, this.yu);
                this.z4(this.yl, this.yu);
            }
        }
        c2() {
            return 3;
        }
        c5() {
            let a = this.c2();
            switch (a) {
                case 0: return 0;
                case 1: return 1;
                case 4: return 4;
                case 2: return 2;
                case 3: return 3;
            }
            return 3;
        }
        zl() {
            if (this.isVertical) {
                return this.wl.left;
            }
            return this.wl.bottom;
        }
        zf() {
            return false;
        }
        hr() {
            let a = super.hr();
            if (this.zf()) {
                let b = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "DashArray";
                    $ret.p = true;
                    $ret.x = ((() => {
                        let $ret = new DoubleCollection();
                        $ret.add(5);
                        $ret.add(5);
                        return $ret;
                    })());
                    $ret.q = true;
                    return $ret;
                })());
                a.add(b);
            }
            if (!this.zf()) {
                let c = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "Brush";
                    $ret.p = true;
                    $ret.y = "ActualBrush";
                    $ret.q = true;
                    return $ret;
                })());
                c.valueResolving = delegateCombine(c.valueResolving, runOn(this, this.rv));
                a.add(c);
            }
            if (!this.zf()) {
                let d = ((() => {
                    let $ret = new SeriesLayerPropertyOverlay();
                    $ret.r = true;
                    $ret.ad = "Outline";
                    $ret.p = true;
                    $ret.y = "ActualOutline";
                    $ret.q = true;
                    return $ret;
                })());
                d.valueResolving = delegateCombine(d.valueResolving, runOn(this, this.rv));
                a.add(d);
            }
            let e = ((() => {
                let $ret = new SeriesLayerPropertyOverlay();
                $ret.p = true;
                $ret.ad = "IsTransitionInEnabled";
                $ret.x = true;
                $ret.q = true;
                return $ret;
            })());
            a.add(e);
            let f = ((() => {
                let $ret = new SeriesLayerPropertyOverlay();
                $ret.p = true;
                $ret.ad = "TransitionInMode";
                $ret.x = enumGetBox(CategoryTransitionInMode_$type, 20);
                $ret.q = true;
                return $ret;
            })());
            a.add(f);
            return a;
        }
        kt() {
            if (this.d1()) {
                return this.bl.yp;
            }
            else {
                return this.bl.yl;
            }
        }
        zp() {
            if (this.bl != null) {
                let a = this.bl;
                return a.zp();
            }
            let b = 0;
            let c = this.fetchXAxis();
            for (let d of fromEnum(this.c9.series)) {
                if (d == this) {
                    return b;
                }
                let e = typeCast(CategorySeries.$, d);
                if (e != null) {
                    let f = typeCast(CategoryAxisBase.$, e.fetchXAxis());
                    if (f == c && e.preferredCategoryMode(f) == 2) {
                        b++;
                    }
                }
            }
            return -1;
        }
        get GetErrorBarsXAxis() {
            return this.fetchXAxis();
        }
        get GetErrorBarsYAxis() {
            return this.fetchYAxis();
        }
        zy(a, b) {
            this.yt.a1(this, this.ze(), runOn(this, this.ye), this.zm(a), this.zn(a));
            let c = this.yt.d;
            let d = c != null;
            let e = this.yk();
            if (e == null) {
                return;
            }
            let f = this.getEffectiveViewport1(a);
            let g = new ScalerParams(0, a.by, a.bx, e.ch, f);
            let h = this.dl == null ? 0 : this.dl.count;
            let i = a;
            let j = b.f;
            let k = i.cw.e;
            let l = i.cw.f;
            let m = i.cw.d;
            let n = k * m;
            for (let o = 0; o < a.cz.count; o++) {
                let p = a.cz.item(o);
                let q = p.content;
                if (d) {
                    let r = p.al;
                    this.zz(j, r, h, e, g, a.q, p.ak);
                }
                this.yt.ac(p, q);
            }
        }
        z4(a, b) {
            this.qt();
            this.wc = a.ab;
            b.aw();
        }
        z1(a, b) {
            a.v();
        }
        zm(a) {
            return a.cw.d;
        }
        zn(a) {
            return a.cw.e;
        }
        zo(a) {
            return a.cw.f;
        }
        zx(a) {
            let b = a;
            b.cz.count = 0;
        }
        rp(a, b) {
            super.rp(a, b);
            if (!this.gy) {
                this.ct.a4(b);
                return;
            }
            let c = typeCast(CategorySeriesView.$, this.cs);
            c.cw.g(this.ib);
            this.ct.a4(b);
            if (this.d3(this.cs)) {
                return;
            }
            this.z5();
            this.gy = false;
        }
        z5() {
            let a = typeCast(CategorySeriesView.$, this.cs);
            if (!this.gq) {
                this.z1(this.yo, a);
            }
            this.gq = false;
            this.z4(this.yo, a);
        }
        yr(a) {
            let b = typeCast(CategorySeriesView.$, a);
            if (b != null && b.q) {
                if (b.p) {
                    return new CategoryFramePreparer(1, typeCast(IIsCategoryBased_$type, this), typeCast(ISupportsMarkers_$type, b), b, this, b.cw);
                }
                else {
                    return new CategoryFramePreparer(1, typeCast(IIsCategoryBased_$type, this), typeCast(ISupportsMarkers_$type, b), this.c9.c8.o, this, b.cw);
                }
            }
            else {
                return this.yq;
            }
        }
        av(a) {
            if (this.fetchXAxis() == a) {
                return this.fetchYAxis();
            }
            if (this.fetchYAxis() == a) {
                return this.fetchXAxis();
            }
            return null;
        }
        ai() {
            return [this.fetchXAxis(), this.fetchYAxis()];
        }
        static yf(a, b, c, d, e) {
            let f = null;
            if (b > -1 && !d.isEmpty && !c.isEmpty) {
                let g = a._inner[0][0] < c.left - 2000 ? c.left - 10 : NaN;
                let h = c.bottom + 10;
                let i = a._inner[b][0] > c.right + 2000 ? c.right + 10 : NaN;
                let j = c.top - 10;
                f = new Clipper(1, g, h, i, j, e);
            }
            return f;
        }
    }
    CategorySeries.$t = /*@__PURE__*/ markType(CategorySeries, 'CategorySeries', MarkerSeries.$, [IHasCategoryModePreference_$type, ISupportsErrorBars_$type]);
    CategorySeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategorySeries, 'raisePropertyChanged', ['IsCustomCategoryMarkerStyleAllowed:za:z6', [0, false], 'IsCustomCategoryStyleAllowed:zb:z7', [0, false], 'IsTransitionInEnabled:zc:z8', [0, false], 'TransitionInMode:yw:z9', [CategoryTransitionInMode_$type, /*@__PURE__*/ enumGetBox(CategoryTransitionInMode_$type, 0)], 'UseHighMarkerFidelity:zh:aaa', [0, false]]);
    return CategorySeries;
})();
/**
 * @hidden
 */
export let CategorySeriesView = /*@__PURE__*/ (() => {
    class CategorySeriesView extends MarkerSeriesView {
        c0(a) {
            if (this.c1 != a.u) {
                return true;
            }
            return false;
        }
        c3(a) {
            this.c1 = a.u;
        }
        constructor(a) {
            super(a);
            this.cy = null;
            this.c1 = 0;
            this.cw = null;
            this.cz = null;
            this.c1 = -1;
            this.cy = a;
            this.cw = this.cx();
            this.cz = ((() => {
                let $ret = new Pool$1(Marker.$);
                $ret.create = runOn(this, this.b3);
                $ret.activate = runOn(this, this.co);
                $ret.disactivate = runOn(this, this.cq);
                $ret.destroy = runOn(this, this.cp);
                return $ret;
            })());
        }
        updateMarkerTemplate(a, b, c) {
            if (!this.b4.xa) {
                let d = this.cz.item(a);
                let e = d.content;
                e.item = this.e.dl.item(b);
                d.ak = b;
                d.al = c;
            }
        }
        cx() {
            return new CategoryBucketCalculator(this);
        }
        get shouldDisplayMarkers() {
            return this.cy.w8();
        }
        updateMarkerCount(a) {
            this.cz.count = a;
        }
        cj(a) {
            this.cz.c(a);
        }
        c2() {
        }
    }
    CategorySeriesView.$t = /*@__PURE__*/ markType(CategorySeriesView, 'CategorySeriesView', MarkerSeriesView.$, [ISupportsMarkers_$type]);
    return CategorySeriesView;
})();
