/*
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 { HorizontalAnchoredCategorySeries } from "./HorizontalAnchoredCategorySeries";
import { Brush } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { runOn, markType, markDep, fromEnum } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { ArrayExtension } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
export let WaterfallSeries = /*@__PURE__*/ (() => {
    class WaterfallSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.ab = WaterfallSeries.$;
        }
        bf() {
            return new WaterfallSeriesView(this);
        }
        i2(a) {
            super.i2(a);
            this.qu = a;
        }
        preferredCategoryMode(a) {
            return 2;
        }
        get_cz() {
            return true;
        }
        jq(a, b) {
            super.jq(a, b);
            this.q5 = a;
            this.q6 = b;
        }
        lj() {
            return this.q5;
        }
        get_n8() {
            return true;
        }
        i7(a, b, c, d) {
            super.i7(a, b, c, d);
            switch (b) {
                case WaterfallSeries.$$p[3]:
                case WaterfallSeries.$$p[2]:
                case WaterfallSeries.$$p[0]:
                case WaterfallSeries.$$p[1]:
                    this.jl(false);
                    break;
            }
        }
        dh(a, b) {
            if (this.dk(a, b)) {
                return true;
            }
            if (this.me(a, b)) {
                return true;
            }
            return false;
        }
        l4(a) {
            if (this.qu == null || this.qu.c7 == null || this.qu.c7.count == 0 || this.xAxis == null) {
                return Rect.empty;
            }
            let b = this.qu.c7;
            let c = this.lq(a);
            let d = -1;
            let e = this.xAxis.ca;
            let f = this.l8.right * 2;
            if (e) {
                d = ArrayExtension.binarySearch$1(Rectangle.$, b, (g) => {
                    let h = this.qu.de(g);
                    return (f - c.x) < (f - (h.left + h.width / 2)) ? -1 : ((f - c.x) > (f - (h.left + h.width / 2)) ? 1 : 0);
                });
            }
            else {
                d = ArrayExtension.binarySearch$1(Rectangle.$, b, (g) => {
                    let h = this.qu.de(g);
                    return c.x < (h.left + h.width / 2) ? -1 : (c.x > (h.left + h.width / 2) ? 1 : 0);
                });
            }
            if (d < 0) {
                d = ~d;
                d--;
            }
            if (d < 0) {
                d = 0;
            }
            if (d > b.count - 1) {
                d = b.count - 1;
            }
            let g = d;
            let h = d;
            if (g < 0) {
                g--;
            }
            if (h < b.count - 1) {
                h++;
            }
            let i = this.q7(g);
            let j = this.q7(d);
            let k = this.q7(h);
            let l = i.left + i.width / 2;
            let m = j.left + j.width / 2;
            let n = k.left + k.width / 2;
            let o = Math.abs(l - c.x);
            let p = Math.abs(m - c.x);
            let q = Math.abs(n - c.x);
            let r = i.containsPoint(c);
            let s = j.containsPoint(c);
            let t = k.containsPoint(c);
            if (p <= o && p <= q) {
                if (!e && t) {
                    return k;
                }
                if (e && r) {
                    return i;
                }
                return j;
            }
            if (o <= p && o <= q) {
                if (!e && s) {
                    return j;
                }
                return i;
            }
            if (q <= p && q <= o) {
                if (e && s) {
                    return j;
                }
                return k;
            }
            return Rect.empty;
        }
        q7(a) {
            return this.qu.dd(a);
        }
        nt() {
            return 1;
        }
        h3(a, b) {
            super.h3(a, b);
            this.qu.c7.count = 0;
        }
        eg() {
            return this.qb.jz(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
        }
        o1(a, b) {
            let c = b;
            super.o1(a, b);
            let d = b.bs;
            let e = b.br;
            let f = this.getEffectiveViewport1(b);
            let g = this.qb.jz(d, e, f);
            let h = this.qv;
            let i = this.qw;
            let j;
            let k = this.pk(b);
            let l = NaN;
            let m = c.c7;
            let n;
            let o = 0;
            this.nr.x(this, this.oc(), this.qb, runOn(this, this.nd), this.ok(b), this.ol(b));
            this.nr.p = this.qv;
            this.nr.q = this.qw;
            this.nr.j = this.qv;
            this.nr.k = this.qw;
            let p = false;
            let q = this.nr.c;
            if (q != null) {
                p = true;
            }
            let r = this.qb.cf;
            let s = this.valueColumn.count;
            let t = a.f;
            let u = this.qb;
            let v = new ScalerParams(0, d, e, this.qb.ca, f);
            let w = this.lb;
            let x = this.q5;
            let y = this.lc;
            let z = this.q6 || y;
            if (a.f.count > 0) {
                j = a.f._inner[0][0] - 0.5 * g;
                let aa = a.f._inner[0][1];
                if (!isNaN_(aa)) {
                    if (aa > k) {
                        n = m.item(o);
                        o++;
                        c.dc(n, j, k);
                        n.width = g;
                        n.height = Math.abs(k - aa);
                        this.nr.al = x;
                        this.nr.ah = x;
                        this.nr.am = z;
                        this.nr.ai = z;
                        this.nr.f = true;
                        if (p) {
                            this.ox(t, 0, s, u, v, b.n);
                        }
                        this.nr.ae(n, false, false, false, false);
                        n.am = this.nr.j;
                        n.an = this.nr.k;
                    }
                    else {
                        n = m.item(o);
                        o++;
                        c.dc(n, j, aa);
                        n.width = g;
                        n.height = Math.abs(aa - k);
                        this.nr.al = w;
                        this.nr.ah = w;
                        this.nr.am = y;
                        this.nr.ai = y;
                        this.nr.f = false;
                        if (p) {
                            this.ox(t, 0, s, u, v, b.n);
                        }
                        this.nr.ae(n, false, false, false, false);
                        n.am = this.nr.j;
                        n.an = this.nr.k;
                    }
                    l = aa;
                }
                else {
                    l = k;
                }
            }
            for (let ab = 1; ab < a.f.count; ++ab) {
                let ac = a.f._inner[ab];
                j = a.f._inner[ab][0] - 0.5 * g;
                let ad = ac[1];
                if (!isNaN_(ad)) {
                    n = m.item(o);
                    o++;
                    c.dc(n, j, Math.min(l, ad));
                    n.width = g;
                    n.height = Math.abs(l - ad);
                    this.nr.al = w;
                    this.nr.ah = w;
                    this.nr.am = y;
                    this.nr.ai = y;
                    this.nr.f = false;
                    if (l > ad) {
                        if (p) {
                            this.ox(t, ab, s, u, v, b.n);
                        }
                    }
                    else {
                        this.nr.al = x;
                        this.nr.ah = x;
                        this.nr.am = z;
                        this.nr.ai = z;
                        this.nr.f = true;
                        if (p) {
                            this.ox(t, ab, s, u, v, b.n);
                        }
                    }
                    this.nr.ae(n, false, false, false, false);
                    n.am = this.nr.j;
                    n.an = this.nr.k;
                    l = ad;
                }
            }
            m.count = o;
            b.cu(a);
        }
        get useHighMarkerFidelity() {
            return this.of;
        }
    }
    WaterfallSeries.$t = /*@__PURE__*/ markType(WaterfallSeries, 'WaterfallSeries', HorizontalAnchoredCategorySeries.$);
    WaterfallSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, WaterfallSeries, 'raisePropertyChanged', ['NegativeBrush:q5:q1', [Brush.$, null], 'NegativeOutline:q6:q2', [Brush.$, null], 'RadiusX:qv:q3', [1, 2], 'RadiusY:qw:q4', [1, 2]]);
    return WaterfallSeries;
})();
/**
 * @hidden
 */
export let WaterfallSeriesView = /*@__PURE__*/ (() => {
    class WaterfallSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.c6 = null;
            this.c8 = null;
            this.df = new Rectangle();
            this.c7 = null;
            this.c6 = a;
            this.c7 = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.dg);
                $ret.activate = runOn(this, this.c9);
                $ret.disactivate = runOn(this, this.db);
                $ret.destroy = runOn(this, this.da);
                return $ret;
            })());
        }
        ap() {
            super.ap();
            this.c8 = new List$1(Rectangle.$, 0);
            if (!this.n) {
                this.e.eu = 4;
                this.c6.q5 = ((() => {
                    let $ret = new Brush();
                    $ret.fill = "#C62828";
                    return $ret;
                })());
                this.c6.q6 = ((() => {
                    let $ret = new Brush();
                    $ret.fill = "#C62828";
                    return $ret;
                })());
                this.e.bj = 5;
            }
        }
        dg() {
            let a = new Rectangle();
            this.c8.add(a);
            a._visibility = 1;
            return a;
        }
        c9(a) {
            a._visibility = 0;
        }
        db(a) {
            a._visibility = 1;
        }
        da(a) {
            this.c8.remove(a);
        }
        dc(a, b, c) {
            let d = false;
            if (a.o != c) {
                d = true;
                a.o = c;
            }
            if (a.n != b) {
                d = true;
                a.n = b;
            }
            if (d) {
                this.an();
            }
        }
        z(a) {
            return this.c8._inner[a];
        }
        y(a) {
            let b = this.c8._inner[a];
            this.df._visibility = b._visibility;
            this.df.n = b.n;
            this.df.o = b.o;
            this.df.width = b.width;
            this.df.height = b.height;
            let c = this.bm(a);
            this.df._fill = c;
            this.df._stroke = c;
            this.df.ac = this.e.ey + 3;
            return this.df;
        }
        a3(a, b) {
            super.a3(a, b);
            if (a.d) {
                for (let c = 0; c < this.c8.count; c++) {
                    let d = this.x(c, b);
                    this.ba(d, c, b);
                    a.v(d);
                }
            }
        }
        ai(a) {
            super.ai(a);
            let b = 0;
            let c = new List$1(Rectangle.$, 0);
            for (let d of fromEnum(this.c7.a)) {
                c.add(d);
            }
            c.aa((e, f) => {
                if (e.n < f.n) {
                    return -1;
                }
                else if (e.n > f.n) {
                    return 1;
                }
                else {
                    return 0;
                }
            });
            for (let e of fromEnum(c)) {
                let f = "Negative";
                if (e._fill == this.e.lb) {
                    f = "Positive";
                }
                this.e.a2.exportRectangleData(a, e, "column" + b, ["Main", f]);
            }
            b++;
        }
        dd(a) {
            let b = this.c7.item(a);
            return new Rect(0, b.n, b.o, b.width, b.height);
        }
        de(a) {
            return new Rect(0, a.n, a.o, a.width, a.height);
        }
    }
    WaterfallSeriesView.$t = /*@__PURE__*/ markType(WaterfallSeriesView, 'WaterfallSeriesView', AnchoredCategorySeriesView.$);
    return WaterfallSeriesView;
})();
//# sourceMappingURL=WaterfallSeries_combined.js.map
