/*
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";
import { DeviceUtils } from "igniteui-react-core";
/**
 * @hidden
 */
export let WaterfallSeries = /*@__PURE__*/ (() => {
    class WaterfallSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.ab = WaterfallSeries.$;
        }
        bp() {
            return new WaterfallSeriesView(this);
        }
        kk(a) {
            super.kk(a);
            this.s6 = a;
        }
        preferredCategoryMode(a) {
            return 2;
        }
        get_de() {
            return true;
        }
        k8(a, b) {
            super.k8(a, b);
            this.th = a;
            this.ti = b;
        }
        nh() {
            return this.th;
        }
        bv() {
            if (this.bw == 0) {
                return 2;
            }
            return super.bv();
        }
        get_cu() {
            return true;
        }
        kp(a, b, c, d) {
            super.kp(a, b, c, d);
            switch (b) {
                case WaterfallSeries.$$p[3]:
                case WaterfallSeries.$$p[2]:
                case WaterfallSeries.$$p[0]:
                case WaterfallSeries.$$p[1]:
                    this.k3(false);
                    break;
            }
        }
        dy(a, b) {
            if (this.d1(a, b)) {
                return true;
            }
            if (this.ol(a, b)) {
                return true;
            }
            return false;
        }
        n2(a) {
            if (this.s6 == null || this.s6.db == null || this.s6.db.count == 0 || this.xAxis == null) {
                return Rect.empty;
            }
            let b = this.s6.db;
            let c = this.no(a);
            let d = -1;
            let e = this.xAxis.ca;
            let f = this.n6.right * 2;
            if (e) {
                d = ArrayExtension.binarySearch$1(Rectangle.$, b, (g) => {
                    let h = this.s6.di(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.s6.di(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.tj(g);
            let j = this.tj(d);
            let k = this.tj(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;
        }
        tj(a) {
            return this.s6.dh(a);
        }
        p4() {
            return 1;
        }
        jl(a, b) {
            super.jl(a, b);
            this.s6.db.count = 0;
        }
        get_rx() {
            return 1;
        }
        e9() {
            return this.sn.j0(this.bs.bv, this.bs.bu, this.getEffectiveViewport1(this.bs));
        }
        rc(a, b) {
            let c = b;
            super.rc(a, b);
            let d = b.bv;
            let e = b.bu;
            let f = this.getEffectiveViewport1(b);
            let g = this.sn.j0(d, e, f);
            let h = this.s7;
            let i = this.s8;
            let j;
            let k = this.rv(b);
            let l = NaN;
            let m = c.db;
            let n;
            let o = 0;
            this.p2.a0(this, this.qm(), runOn(this, this.po), this.qu(b), this.qv(b));
            this.p2.r = this.s7;
            this.p2.s = this.s8;
            this.p2.k = this.s7;
            this.p2.l = this.s8;
            let p = false;
            let q = this.p2.b;
            if (q != null) {
                p = true;
            }
            let r = this.sn.cf;
            let s = this.valueColumn.count;
            let t = a.f;
            let u = this.sn;
            let v = new ScalerParams(0, d, e, this.sn.ca, f);
            let w = this.m9;
            let x = this.th;
            let y = this.na;
            let z = this.ti || 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.dg(n, j, k);
                        n.width = g;
                        n.height = Math.abs(k - aa);
                        this.p2.ak = x;
                        this.p2.ag = x;
                        this.p2.al = z;
                        this.p2.ah = z;
                        this.p2.f = true;
                        if (p) {
                            this.q8(t, 0, s, u, v, b.q);
                        }
                        this.p2.ad(n, false, false, false, false);
                        n.am = this.p2.k;
                        n.an = this.p2.l;
                    }
                    else {
                        n = m.item(o);
                        o++;
                        c.dg(n, j, aa);
                        n.width = g;
                        n.height = Math.abs(aa - k);
                        this.p2.ak = w;
                        this.p2.ag = w;
                        this.p2.al = y;
                        this.p2.ah = y;
                        this.p2.f = false;
                        if (p) {
                            this.q8(t, 0, s, u, v, b.q);
                        }
                        this.p2.ad(n, false, false, false, false);
                        n.am = this.p2.k;
                        n.an = this.p2.l;
                    }
                    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.dg(n, j, Math.min(l, ad));
                    n.width = g;
                    n.height = Math.abs(l - ad);
                    this.p2.ak = w;
                    this.p2.ag = w;
                    this.p2.al = y;
                    this.p2.ah = y;
                    this.p2.f = false;
                    if (l > ad) {
                        if (p) {
                            this.q8(t, ab, s, u, v, b.q);
                        }
                    }
                    else {
                        this.p2.ak = x;
                        this.p2.ag = x;
                        this.p2.al = z;
                        this.p2.ah = z;
                        this.p2.f = true;
                        if (p) {
                            this.q8(t, ab, s, u, v, b.q);
                        }
                    }
                    this.p2.ad(n, false, false, false, false);
                    n.am = this.p2.k;
                    n.an = this.p2.l;
                    l = ad;
                }
            }
            m.count = o;
            b.cy(a);
        }
        get useHighMarkerFidelity() {
            return this.qp;
        }
    }
    WaterfallSeries.$t = /*@__PURE__*/ markType(WaterfallSeries, 'WaterfallSeries', HorizontalAnchoredCategorySeries.$);
    WaterfallSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, WaterfallSeries, 'raisePropertyChanged', ['NegativeBrush:th:td', [Brush.$, null], 'NegativeOutline:ti:te', [Brush.$, null], 'RadiusX:s7:tf', [1, 0], 'RadiusY:s8:tg', [1, 0]]);
    return WaterfallSeries;
})();
/**
 * @hidden
 */
export let WaterfallSeriesView = /*@__PURE__*/ (() => {
    class WaterfallSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.da = null;
            this.dc = null;
            this.dj = new Rectangle();
            this.db = null;
            this.da = a;
            this.db = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.dk);
                $ret.activate = runOn(this, this.dd);
                $ret.disactivate = runOn(this, this.df);
                $ret.destroy = runOn(this, this.de);
                return $ret;
            })());
        }
        as() {
            super.as();
            this.dc = new List$1(Rectangle.$, 0);
            if (!this.q) {
                this.e.fq = 4;
                this.da.th = ((() => {
                    let $ret = new Brush();
                    $ret.fill = "#ee5879";
                    return $ret;
                })());
                this.da.ti = ((() => {
                    let $ret = new Brush();
                    $ret.fill = "#ee5879";
                    return $ret;
                })());
                this.e.fv = DeviceUtils.g(1);
                this.e.bx = 5;
            }
        }
        dk() {
            let a = new Rectangle();
            this.dc.add(a);
            a._visibility = 1;
            return a;
        }
        dd(a) {
            a._visibility = 0;
        }
        df(a) {
            a._visibility = 1;
        }
        de(a) {
            this.dc.remove(a);
        }
        dg(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.aq();
            }
        }
        ac(a) {
            return this.dc._inner[a];
        }
        ab(a) {
            let b = this.dc._inner[a];
            this.dj._visibility = b._visibility;
            this.dj.n = b.n;
            this.dj.o = b.o;
            this.dj.width = b.width;
            this.dj.height = b.height;
            let c = this.bp(a);
            this.dj._fill = c;
            this.dj._stroke = c;
            this.dj.ac = this.e.eu + 3;
            return this.dj;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                for (let c = 0; c < this.dc.count; c++) {
                    let d = this.aa(c, b);
                    this.bd(d, c, b);
                    a.v(d);
                }
            }
        }
        al(a) {
            super.al(a);
            let b = 0;
            let c = new List$1(Rectangle.$, 0);
            for (let d of fromEnum(this.db.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.m9) {
                    f = "Positive";
                }
                this.e.a5.exportRectangleData(a, e, "column" + b, ["Main", f]);
            }
            b++;
        }
        dh(a) {
            let b = this.db.item(a);
            return new Rect(0, b.n, b.o, b.width, b.height);
        }
        di(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
