/*
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 { HorizontalRangeCategorySeries } from "./HorizontalRangeCategorySeries";
import { DependencyProperty } from "igniteui-react-core/ES2015/DependencyProperty";
import { Type, typeCast, runOn, markType, fromEnum } from "igniteui-react-core/ES2015/type";
import { Rect } from "igniteui-react-core/ES2015/Rect";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Pool$1 } from "igniteui-react-core/ES2015/Pool$1";
import { Rectangle } from "igniteui-react-core/ES2015/Rectangle";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-react-core/ES2015/number";
import { RangeCategorySeriesView } from "./RangeCategorySeriesView";
export class RangeColumnSeries extends HorizontalRangeCategorySeries {
    constructor() {
        super();
        this.ab = RangeColumnSeries.$;
    }
    bf() {
        return new RangeColumnSeriesView(this);
    }
    ii(a) {
        super.ii(a);
        this.o8 = a;
    }
    get_nj() {
        return true;
    }
    get nj() {
        return this.get_nj();
    }
    preferredCategoryMode(a) {
        return 2;
    }
    li(a) {
        if (this.xAxis == null || this.yAxis == null) {
            return Rect.empty;
        }
        let b = this.k4(a);
        let c = this.bi.bq;
        let d = this.bi.bp;
        let e = this.getEffectiveViewport1(this.bi);
        let f = new ScalerParams(0, c, d, this.yAxis.b8, e);
        let g = this.aj(this.mu(), this.mv.f, this.nv(this.bi), this.nw(this.bi), a, true);
        if (g == null) {
            return Rect.empty;
        }
        let h = g[0];
        let i = g[1];
        let j = Math.abs(b.x - h[0]);
        let k = Math.abs(b.x - i[0]);
        let l = this.xAxis.jj(c, d, e);
        if (j < k) {
            let m = h[0] - 0.5 * l;
            let n = h[1];
            let o = h[2];
            return new Rect(0, m, Math.min(n, o), l, Math.max(n, o) - Math.min(n, o));
        }
        else {
            let p = i[0] - 0.5 * l;
            let q = i[1];
            let r = i[2];
            return new Rect(0, p, Math.min(q, r), l, Math.max(q, r) - Math.min(q, r));
        }
    }
    de(a, b) {
        if (this.dh(a, b)) {
            return true;
        }
        if (this.ls(a, b)) {
            return true;
        }
        return false;
    }
    hl(a, b) {
        super.hl(a, b);
        let c = b;
        if (a && c.cx != null) {
            c.cx.count = 0;
        }
    }
    eb() {
        return this.xAxis.jj(this.bi.bq, this.bi.bp, this.getEffectiveViewport1(this.bi));
    }
    ob(a, b) {
        super.ob(a, b);
        let c = typeCast(RangeColumnSeriesView.$, b);
        let d = a.f;
        let e = b.bq;
        let f = b.bp;
        let g = this.getEffectiveViewport1(b);
        let h = this.xAxis.jj(e, f, g);
        if (isNaN_(h) || isInfinity(h)) {
            c.cx.count = 0;
            return;
        }
        this.m2.x(this, this.nn(), this.xAxis, runOn(this, this.mo), this.nv(b), this.nw(b));
        this.m2.p = this.o9;
        this.m2.q = this.pa;
        this.m2.j = this.o9;
        this.m2.k = this.pa;
        let i = false;
        let j = this.m2.c;
        if (j != null) {
            i = true;
        }
        let k = this.xAxis.cc;
        let l = this.lowColumn.count;
        let m = this.xAxis;
        let n = new ScalerParams(0, e, f, this.xAxis.b8, g);
        let o = 0;
        for (let p = 0; p < d.count; ++p) {
            let q = d._inner[p][0] - 0.5 * h;
            let r = Math.min(d._inner[p][1], d._inner[p][2]);
            let s = Math.max(d._inner[p][1], d._inner[p][2]);
            let t = Math.abs(s - r);
            if (isInfinity(t)) {
                continue;
            }
            let u = c.cx.item(o);
            o++;
            u.width = h;
            u.height = t;
            if (i) {
                this.n7(d, p, l, m, n, b.n);
            }
            this.m2.ae(u, false, false, false, false);
            u.al = this.m2.j;
            u.am = this.m2.k;
            c.c2(u, q, r);
        }
        c.cx.count = o;
        b.cs(a);
    }
    get useHighMarkerFidelity() {
        return this.nq;
    }
}
RangeColumnSeries.$t = markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
Type.dep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:o9:pd', [1, 2], 'RadiusY:pa:pe', [1, 2]]);
export class RangeColumnSeriesView extends RangeCategorySeriesView {
    constructor(a) {
        super(a);
        this.cw = null;
        this.cx = null;
        this.cy = null;
        this.c3 = new Rectangle();
        this.cw = a;
        this.cx = ((() => {
            let $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(this, this.c4);
            $ret.activate = runOn(this, this.cz);
            $ret.disactivate = runOn(this, this.c1);
            $ret.destroy = runOn(this, this.c0);
            return $ret;
        })());
    }
    ap() {
        super.ap();
        this.cy = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.eo = 4;
            this.e.bj = 1;
        }
    }
    c4() {
        let a = new Rectangle();
        this.cy.add(a);
        a._visibility = 1;
        return a;
    }
    cz(a) {
        a._visibility = 0;
    }
    c1(a) {
        a._visibility = 1;
    }
    c0(a) {
        this.cy.remove(a);
    }
    c2(a, b, c) {
        if (!this.isDirty) {
            this.an();
        }
        a.o = c;
        a.n = b;
    }
    z(a) {
        return this.cy._inner[a];
    }
    y(a) {
        let b = this.cy._inner[a];
        this.c3._visibility = b._visibility;
        this.c3.n = b.n;
        this.c3.o = b.o;
        this.c3.width = b.width;
        this.c3.height = b.height;
        let c = this.bl(a);
        this.c3._fill = c;
        this.c3._stroke = c;
        this.c3.ac = this.e.es + 3;
        return this.c3;
    }
    a3(a, b) {
        super.a3(a, b);
        if (a.d) {
            for (let c = 0; c < this.cy.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.cx.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)) {
            this.e.a2.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
        }
        b++;
    }
}
RangeColumnSeriesView.$t = markType(RangeColumnSeriesView, 'RangeColumnSeriesView', RangeCategorySeriesView.$);
/*<BeginStatics Name="Infragistics.Controls.Charts.RangeColumnSeries" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.RangeColumnSeries" />*/
