/*
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-angular-core";
import { Defaults } from "./Defaults";
import { typeCast, runOn, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
import { ChartSelection } from "./ChartSelection";
import { PropertyMetadata } from "igniteui-angular-core";
import { truncate, isNaN_, isInfinity } from "igniteui-angular-core";
import { RangeCategorySeriesView } from "./RangeCategorySeriesView";
/**
 * @hidden
 */
export let RangeColumnSeries = /*@__PURE__*/ (() => {
    class RangeColumnSeries extends HorizontalRangeCategorySeries {
        constructor() {
            super();
            this.ab = RangeColumnSeries.$;
        }
        bk() {
            return new RangeColumnSeries();
        }
        get_e1() {
            return true;
        }
        get_fm() {
            return true;
        }
        jn() {
            if (!isNaN_(this.jm)) {
                return super.jn();
            }
            return Defaults.h;
        }
        ct() {
            return new RangeColumnSeriesView(this);
        }
        q7(a) {
            super.q7(a);
            this.acc = a;
        }
        get_ef() {
            return true;
        }
        preferredCategoryMode(a) {
            return 2;
        }
        wx(a) {
            if (this.xAxis == null || this.yAxis == null) {
                return Rect.empty;
            }
            let b = this.wh(a);
            let c = this.cw.ca;
            let d = this.cw.b9;
            let e = this.getEffectiveViewport1(this.cw);
            let f = new ScalerParams(0, c, d, this.yAxis.df, e);
            f.b = this.i0();
            let g = this.an(this.y2(), this.y4.h, this.z5(this.cw), this.z6(this.cw), 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.ou(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));
            }
        }
        gx(a, b) {
            if (this.g0(a, b)) {
                return true;
            }
            if (this.xr(a, b)) {
                return true;
            }
            return false;
        }
        pb(a, b) {
            super.pb(a, b);
            let c = b;
            if (a && c.dl != null) {
                c.dl.count = 0;
            }
        }
        iy() {
            return this.xAxis.ou(this.cw.ca, this.cw.b9, this.getEffectiveViewport1(this.cw));
        }
        aax(a, b) {
            super.aax(a, b);
            let c = typeCast(RangeColumnSeriesView.$, b);
            let d = a.h;
            let e = b.ca;
            let f = b.b9;
            let g = this.getEffectiveViewport1(b);
            let h = this.xAxis.ou(e, f, g);
            if (isNaN_(h) || isInfinity(h)) {
                c.dl.count = 0;
                return;
            }
            this.zc.a2(this, this.zw(), runOn(this, this.yw), this.z5(b), this.z6(b));
            this.zc.r = this.acd;
            this.zc.s = this.ace;
            this.zc.k = this.acd;
            this.zc.l = this.ace;
            let i = false;
            let j = this.zc.b;
            if (j != null) {
                i = true;
            }
            let k = this.xAxis.dm;
            let l = this.lowColumn.count;
            let m = this.xAxis;
            let n = new ScalerParams(0, e, f, this.xAxis.df, 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.dl.item(o);
                o++;
                u.width = h;
                u.height = t;
                let v = this.zc.aw(l, p)[0];
                if (k && a.o != null && p >= 0 && p < a.o.count) {
                    v = truncate(Math.round(a.o._inner[p]));
                }
                if (i) {
                    this.aat(d, p, l, m, n, b.t, v);
                }
                this.zc.ad(u, false, false, false, false);
                u.ap = this.zc.k;
                u.aq = this.zc.l;
                c.dr(u, q, r);
            }
            c.dl.count = o;
            b.dg(a);
        }
        qa(a, b, c) {
            this.aap(a, b, c, this.y3, 1);
        }
        ak(a, b) {
            let c = new List$1(ChartSelection.$, 0);
            this.qa(a, c, b);
            return c.toArray();
        }
        get useHighMarkerFidelity() {
            return this.z0;
        }
    }
    RangeColumnSeries.$t = markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
    RangeColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:acd:ach', [1, 0], 'RadiusY:ace:aci', [1, 0]]);
    return RangeColumnSeries;
})();
/**
 * @hidden
 */
export let RangeColumnSeriesView = /*@__PURE__*/ (() => {
    class RangeColumnSeriesView extends RangeCategorySeriesView {
        constructor(a) {
            super(a);
            this.dk = null;
            this.dl = null;
            this.dm = null;
            this.ds = new Rectangle();
            this.dk = a;
            this.dl = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.dt);
                $ret.activate = runOn(this, this.dn);
                $ret.disactivate = runOn(this, this.dq);
                $ret.destroy = runOn(this, this.dp);
                return $ret;
            })());
        }
        a4() {
            super.a4();
            this.dm = new List$1(Rectangle.$, 0);
            if (!this.t) {
                this.dk.xk = Defaults.c;
                this.dk.jt = Defaults.i;
            }
        }
        dt() {
            let a = new Rectangle();
            this.dm.add(a);
            a._visibility = 1;
            return a;
        }
        dn(a) {
            a._visibility = 0;
        }
        dq(a) {
            a._visibility = 1;
        }
        dp(a) {
            this.dm.remove(a);
        }
        dr(a, b, c) {
            if (!this.isDirty) {
                this.a2();
            }
            a.o = c;
            a.n = b;
        }
        ak(a) {
            return this.dm._inner[a];
        }
        aj(a) {
            let b = this.dm._inner[a];
            this.ds._visibility = b._visibility;
            this.ds.n = b.n;
            this.ds.o = b.o;
            this.ds.width = b.width;
            this.ds.height = b.height;
            let c = this.b4(a);
            this.ds._fill = c;
            this.ds._stroke = c;
            this.ds.ad = this.f.ig + 3;
            return this.ds;
        }
        bj(a, b) {
            super.bj(a, b);
            if (a.d) {
                for (let c = 0; c < this.dm.count; c++) {
                    let d = this.ai(c, b);
                    this.br(d, c, b);
                    a.w(d);
                }
            }
        }
        ax(a) {
            super.ax(a);
            let b = 0;
            let c = new List$1(Rectangle.$, 0);
            for (let d of fromEnum(this.dl.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.f.bc.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    RangeColumnSeriesView.$t = markType(RangeColumnSeriesView, 'RangeColumnSeriesView', RangeCategorySeriesView.$);
    return RangeColumnSeriesView;
})();
