/*
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";
/**
 * @hidden
 */
export class RangeColumnSeries extends HorizontalRangeCategorySeries {
    constructor() {
        super();
        this.ab = RangeColumnSeries.$;
    }
    bf() {
        return new RangeColumnSeriesView(this);
    }
    im(a) {
        super.im(a);
        this.pc = a;
    }
    get_no() {
        return true;
    }
    preferredCategoryMode(a) {
        return 2;
    }
    ln(a) {
        if (this.xAxis == null || this.yAxis == null) {
            return Rect.empty;
        }
        let b = this.k9(a);
        let c = this.bi.bs;
        let d = this.bi.br;
        let e = this.getEffectiveViewport1(this.bi);
        let f = new ScalerParams(0, c, d, this.yAxis.b8, e);
        f.b = this.ee();
        let g = this.aj(this.mz(), this.m0.f, this.n0(this.bi), this.n1(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.jk(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));
        }
    }
    dg(a, b) {
        if (this.dj(a, b)) {
            return true;
        }
        if (this.lx(a, b)) {
            return true;
        }
        return false;
    }
    hp(a, b) {
        super.hp(a, b);
        let c = b;
        if (a && c.cz != null) {
            c.cz.count = 0;
        }
    }
    ed() {
        return this.xAxis.jk(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    }
    oh(a, b) {
        super.oh(a, b);
        let c = typeCast(RangeColumnSeriesView.$, b);
        let d = a.f;
        let e = b.bs;
        let f = b.br;
        let g = this.getEffectiveViewport1(b);
        let h = this.xAxis.jk(e, f, g);
        if (isNaN_(h) || isInfinity(h)) {
            c.cz.count = 0;
            return;
        }
        this.m7.x(this, this.ns(), this.xAxis, runOn(this, this.mt), this.n0(b), this.n1(b));
        this.m7.p = this.pd;
        this.m7.q = this.pe;
        this.m7.j = this.pd;
        this.m7.k = this.pe;
        let i = false;
        let j = this.m7.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.cz.item(o);
            o++;
            u.width = h;
            u.height = t;
            if (i) {
                this.od(d, p, l, m, n, b.n);
            }
            this.m7.ae(u, false, false, false, false);
            u.al = this.m7.j;
            u.am = this.m7.k;
            c.c4(u, q, r);
        }
        c.cz.count = o;
        b.cu(a);
    }
    get useHighMarkerFidelity() {
        return this.nv;
    }
}
RangeColumnSeries.$t = markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
Type.dep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:pd:ph', [1, 2], 'RadiusY:pe:pi', [1, 2]]);
/**
 * @hidden
 */
export class RangeColumnSeriesView extends RangeCategorySeriesView {
    constructor(a) {
        super(a);
        this.cy = null;
        this.cz = null;
        this.c0 = null;
        this.c5 = new Rectangle();
        this.cy = a;
        this.cz = ((() => {
            let $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(this, this.c6);
            $ret.activate = runOn(this, this.c1);
            $ret.disactivate = runOn(this, this.c3);
            $ret.destroy = runOn(this, this.c2);
            return $ret;
        })());
    }
    ap() {
        super.ap();
        this.c0 = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.er = 4;
            this.e.bj = 1;
        }
    }
    c6() {
        let a = new Rectangle();
        this.c0.add(a);
        a._visibility = 1;
        return a;
    }
    c1(a) {
        a._visibility = 0;
    }
    c3(a) {
        a._visibility = 1;
    }
    c2(a) {
        this.c0.remove(a);
    }
    c4(a, b, c) {
        if (!this.isDirty) {
            this.an();
        }
        a.o = c;
        a.n = b;
    }
    z(a) {
        return this.c0._inner[a];
    }
    y(a) {
        let b = this.c0._inner[a];
        this.c5._visibility = b._visibility;
        this.c5.n = b.n;
        this.c5.o = b.o;
        this.c5.width = b.width;
        this.c5.height = b.height;
        let c = this.bm(a);
        this.c5._fill = c;
        this.c5._stroke = c;
        this.c5.ac = this.e.ev + 3;
        return this.c5;
    }
    a3(a, b) {
        super.a3(a, b);
        if (a.d) {
            for (let c = 0; c < this.c0.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.cz.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.$);
