/*
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";
import { Defaults } from "./Defaults";
import { typeCast, runOn, markType, markDep, fromEnum } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, isInfinity } from "igniteui-react-core";
import { RangeCategorySeriesView } from "./RangeCategorySeriesView";
/**
 * @hidden
 */
export let RangeColumnSeries = /*@__PURE__*/ (() => {
    class RangeColumnSeries extends HorizontalRangeCategorySeries {
        get_ed() {
            return true;
        }
        get_ey() {
            return true;
        }
        ip() {
            if (!isNaN_(this.io)) {
                return super.ip();
            }
            return Defaults.h;
        }
        cg() {
            return new RangeColumnSeriesView(this);
        }
        o0(a) {
            super.o0(a);
            this.yk = a;
        }
        constructor() {
            super();
            this.ab = RangeColumnSeries.$;
        }
        get_du() {
            return true;
        }
        preferredCategoryMode(a) {
            return 2;
        }
        ts(a) {
            if (this.xAxis == null || this.yAxis == null) {
                return Rect.empty;
            }
            let b = this.tc(a);
            let c = this.cj.by;
            let d = this.cj.bx;
            let e = this.getEffectiveViewport1(this.cj);
            let f = new ScalerParams(0, c, d, this.yAxis.ch, e);
            f.b = this.h2();
            let g = this.aj(this.vl(), this.vm.f, this.wn(this.cj), this.wo(this.cj), 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.k4(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));
            }
        }
        f4(a, b) {
            if (this.f7(a, b)) {
                return true;
            }
            if (this.ud(a, b)) {
                return true;
            }
            return false;
        }
        nj(a, b) {
            super.nj(a, b);
            let c = b;
            if (a && c.c6 != null) {
                c.c6.count = 0;
            }
        }
        h0() {
            return this.xAxis.k4(this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj));
        }
        w5(a, b) {
            super.w5(a, b);
            let c = typeCast(RangeColumnSeriesView.$, b);
            let d = a.f;
            let e = b.by;
            let f = b.bx;
            let g = this.getEffectiveViewport1(b);
            let h = this.xAxis.k4(e, f, g);
            if (isNaN_(h) || isInfinity(h)) {
                c.c6.count = 0;
                return;
            }
            this.vu.a2(this, this.we(), runOn(this, this.vf), this.wn(b), this.wo(b));
            this.vu.r = this.yl;
            this.vu.s = this.ym;
            this.vu.k = this.yl;
            this.vu.l = this.ym;
            let i = false;
            let j = this.vu.b;
            if (j != null) {
                i = true;
            }
            let k = this.xAxis.cn;
            let l = this.lowColumn.count;
            let m = this.xAxis;
            let n = new ScalerParams(0, e, f, this.xAxis.ch, 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) || isNaN_(t)) {
                    continue;
                }
                let u = c.c6.item(o);
                o++;
                u.width = h;
                u.height = t;
                if (i) {
                    this.w1(d, p, l, m, n, b.q);
                }
                this.vu.ad(u, false, false, false, false);
                u.ap = this.vu.k;
                u.aq = this.vu.l;
                c.db(u, q, r);
            }
            c.c6.count = o;
            b.c1(a);
        }
        get useHighMarkerFidelity() {
            return this.wi;
        }
    }
    RangeColumnSeries.$t = /*@__PURE__*/ markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
    RangeColumnSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:yl:yp', [1, 0], 'RadiusY:ym:yq', [1, 0]]);
    return RangeColumnSeries;
})();
/**
 * @hidden
 */
export let RangeColumnSeriesView = /*@__PURE__*/ (() => {
    class RangeColumnSeriesView extends RangeCategorySeriesView {
        constructor(a) {
            super(a);
            this.c5 = null;
            this.c6 = null;
            this.c7 = null;
            this.dc = new Rectangle();
            this.c5 = a;
            this.c6 = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.dd);
                $ret.activate = runOn(this, this.c8);
                $ret.disactivate = runOn(this, this.da);
                $ret.destroy = runOn(this, this.c9);
                return $ret;
            })());
        }
        au() {
            super.au();
            this.c7 = new List$1(Rectangle.$, 0);
            if (!this.q) {
                this.c5.ua = Defaults.c;
                this.c5.iu = Defaults.i;
            }
        }
        dd() {
            let a = new Rectangle();
            this.c7.add(a);
            a._visibility = 1;
            return a;
        }
        c8(a) {
            a._visibility = 0;
        }
        da(a) {
            a._visibility = 1;
        }
        c9(a) {
            this.c7.remove(a);
        }
        db(a, b, c) {
            if (!this.isDirty) {
                this.as();
            }
            a.o = c;
            a.n = b;
        }
        ac(a) {
            return this.c7._inner[a];
        }
        ab(a) {
            let b = this.c7._inner[a];
            this.dc._visibility = b._visibility;
            this.dc.n = b.n;
            this.dc.o = b.o;
            this.dc.width = b.width;
            this.dc.height = b.height;
            let c = this.bs(a);
            this.dc._fill = c;
            this.dc._stroke = c;
            this.dc.ad = this.e.hk + 3;
            return this.dc;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                for (let c = 0; c < this.c7.count; c++) {
                    let d = this.aa(c, b);
                    this.bf(d, c, b);
                    a.w(d);
                }
            }
        }
        an(a) {
            super.an(a);
            let b = 0;
            let c = new List$1(Rectangle.$, 0);
            for (let d of fromEnum(this.c6.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.a9.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    RangeColumnSeriesView.$t = /*@__PURE__*/ markType(RangeColumnSeriesView, 'RangeColumnSeriesView', RangeCategorySeriesView.$);
    return RangeColumnSeriesView;
})();
