/*
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 { DependencyProperty } from "igniteui-react-core";
import { ConsolidatedItemsPosition_$type } from "./ConsolidatedItemsPosition";
import { Defaults } from "./Defaults";
import { runOn, enumGetBox, markType, markDep, fromEnum } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { List$1 } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, isInfinity } from "igniteui-react-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
export let ColumnSeries = /*@__PURE__*/ (() => {
    class ColumnSeries extends HorizontalAnchoredCategorySeries {
        bc() {
            return new ColumnSeries();
        }
        get_ee() {
            return true;
        }
        get_ez() {
            return true;
        }
        iq() {
            if (!isNaN_(this.ip)) {
                return super.iq();
            }
            return Defaults.h;
        }
        cd() {
            return new ColumnSeriesView(this);
        }
        o2(a) {
            super.o2(a);
            this.zg = a;
        }
        cj() {
            if (this.ck == 0) {
                return 2;
            }
            return super.cj();
        }
        vy() {
            return 1;
        }
        constructor() {
            super();
            this.zm = null;
            this.zh = 0;
            this.ab = ColumnSeries.$;
            this.y0 = 2;
        }
        get_dv() {
            return true;
        }
        preferredCategoryMode(a) {
            return this.y0;
        }
        tu(a) {
            if (this.zm == null) {
                this.zm = runOn(this, this.zj);
            }
            let b = this.y3 != null ? this.y3 : this.yAxis;
            let c = this.yx;
            return this.xm.c$d(this, a, c, b, this.vo, this.wp(this.cg), this.wq(this.cg), this.zm);
        }
        f5(a, b) {
            if (this.f8(a, b)) {
                return true;
            }
            if (this.uf(a, b)) {
                return true;
            }
            return false;
        }
        nk(a, b) {
            super.nk(a, b);
            let c = b;
            if (a && c.de != null) {
                c.de.count = 0;
            }
        }
        h1() {
            return this.yx.k4(this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg));
        }
        w7(a, b) {
            super.w7(a, b);
            let c = a.f;
            if (!b.t()) {
                return;
            }
            let d = b.by;
            let e = b.bx;
            let f = this.getEffectiveViewport1(b);
            let g = new ScalerParams(0, d, e, this.y3.ch, f);
            g.b = this.h3();
            let h = new ScalerParams(0, d, e, this.yx.ch, f);
            let i = this.y3;
            let j = i.ej(i.l7, g);
            let k = this.yx.k4(d, e, f);
            let l = this.yx;
            let m = b;
            if (isNaN_(k) || isInfinity(k)) {
                m.de.count = 0;
                return;
            }
            this.vw.a2(this, this.wg(), runOn(this, this.vh), this.wp(b), this.wq(b));
            this.vw.r = this.zk;
            this.vw.s = this.zl;
            this.vw.k = this.zk;
            this.vw.l = this.zl;
            let n = false;
            let o = this.vw.b;
            if (o != null) {
                n = true;
            }
            let p = this.yx.cn;
            let q = p ? this.yx : null;
            let r = this.valueColumn.count;
            let s = this.wp(b);
            let t = 0;
            for (let u = 0; u < c.count; ++u) {
                let v = c._inner[u][0] - 0.5 * k;
                let w = this.zj(c._inner[u]);
                let x = j;
                w = Math.max(w, -100);
                x = Math.min(x, e.bottom + 100);
                let y = Math.abs(x - w);
                if (isInfinity(y) || isNaN_(y)) {
                    continue;
                }
                let z = m.de.item(t);
                t++;
                z.width = k;
                z.height = y;
                if (n) {
                    this.w3(c, u, r, l, h, b.q);
                }
                if (z.dataContext != null) {
                    let aa = z.dataContext;
                    if (s == 1) {
                        let ab = this.vw.aw(r, u)[0];
                        if (ab >= 0 && ab < this.c7.count) {
                            if (q != null && q.i$b != null && q.i$b.count > ab) {
                                ab = q.i$b._inner[ab];
                            }
                            aa.item = this.c7.item(ab);
                        }
                    }
                    else {
                        aa.item = null;
                    }
                }
                this.vw.ad(z, false, false, false, false);
                z.ap = this.vw.k;
                z.aq = this.vw.l;
                m.dj(z, v, Math.min(x, w));
            }
            m.de.count = t;
            b.c1(a);
        }
        get zi() {
            return this.zh;
        }
        set zi(a) {
            if (this.zi != a) {
                let b = this.zi;
                this.zh = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.zi));
            }
        }
        zj(a) {
            if (a == null || a.length < 3) {
                return NaN;
            }
            switch (this.zi) {
                case 0: return a[1];
                case 1: return a[2];
                case 2: return (a[1] + a[2]) / 2;
                case 3:
                    let b = (a[1] + a[2]) / 2;
                    if (this.yAxis == null) {
                        return b;
                    }
                    let c = this.yAxis.em(b, new ScalerParams(1, this.cv.t7, this.cv.t6, this.yAxis.ch));
                    if (c < this.yAxis.l7) {
                        return a[2];
                    }
                    else {
                        return a[1];
                    }
                case 4:
                    let d = (a[1] + a[2]) / 2;
                    let e = this.yAxis.em(d, new ScalerParams(1, this.cv.t7, this.cv.t6, this.yAxis.ch));
                    if (this.yAxis == null) {
                        return d;
                    }
                    if (e < this.yAxis.l7) {
                        return a[1];
                    }
                    else {
                        return a[2];
                    }
                default: return (a[1] + a[2]) / 2;
            }
        }
        get useHighMarkerFidelity() {
            return this.wk;
        }
    }
    ColumnSeries.$t = /*@__PURE__*/ markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    ColumnSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:zk:zq', [1, 0], 'RadiusY:zl:zr', [1, 0]]);
    return ColumnSeries;
})();
/**
 * @hidden
 */
export let ColumnSeriesView = /*@__PURE__*/ (() => {
    class ColumnSeriesView extends AnchoredCategorySeriesView {
        au() {
            super.au();
            this.df = new List$1(Rectangle.$, 0);
            if (!this.q) {
                this.dd.iv = Defaults.i;
                this.dd.uc = Defaults.c;
            }
        }
        constructor(a) {
            super(a);
            this.dd = null;
            this.df = null;
            this.dk = new Rectangle();
            this.de = null;
            this.dd = a;
            this.de = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.dl);
                $ret.activate = runOn(this, this.dg);
                $ret.disactivate = runOn(this, this.di);
                $ret.destroy = runOn(this, this.dh);
                return $ret;
            })());
        }
        dl() {
            let a = new Rectangle();
            this.df.add(a);
            a._visibility = 1;
            return a;
        }
        dg(a) {
            a._visibility = 0;
        }
        di(a) {
            a._visibility = 1;
        }
        dh(a) {
            this.df.remove(a);
        }
        dj(a, b, c) {
            if (!this.isDirty) {
                this.as();
            }
            a.o = c;
            a.n = b;
        }
        ac(a) {
            return this.df._inner[a];
        }
        ab(a) {
            let b = this.df._inner[a];
            this.dk._visibility = b._visibility;
            this.dk.n = b.n;
            this.dk.o = b.o;
            this.dk.width = b.width;
            this.dk.height = b.height;
            let c = this.bs(a);
            this.dk._fill = c;
            this.dk._stroke = c;
            this.dk.ad = this.e.hl + 3;
            return this.dk;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                for (let c = 0; c < this.df.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.de.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.a5.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    ColumnSeriesView.$t = /*@__PURE__*/ markType(ColumnSeriesView, 'ColumnSeriesView', AnchoredCategorySeriesView.$);
    return ColumnSeriesView;
})();
