/*
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 { truncate, isNaN_, isInfinity } from "igniteui-react-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
export let ColumnSeries = /*@__PURE__*/ (() => {
    class ColumnSeries extends HorizontalAnchoredCategorySeries {
        bi() {
            return new ColumnSeries();
        }
        get_ex() {
            return true;
        }
        get_fj() {
            return true;
        }
        ji() {
            if (!isNaN_(this.jh)) {
                return super.ji();
            }
            return Defaults.h;
        }
        cq() {
            return new ColumnSeriesView(this);
        }
        qx(a) {
            super.qx(a);
            this.acd = a;
        }
        cw() {
            if (this.cx == 0) {
                return 2;
            }
            return super.cw();
        }
        yv() {
            return 1;
        }
        constructor() {
            super();
            this.acj = null;
            this.ace = 0;
            this.ab = ColumnSeries.$;
            this.abx = 2;
        }
        get_eb() {
            return true;
        }
        preferredCategoryMode(a) {
            return this.abx;
        }
        wh(a) {
            if (this.acj == null) {
                this.acj = runOn(this, this.acg);
            }
            let b = this.ab0 != null ? this.ab0 : this.yAxis;
            let c = this.abu;
            return this.aaj.c$d(this, a, c, b, this.yl, this.zm(this.ct), this.zn(this.ct), this.acj);
        }
        gu(a, b) {
            if (this.gx(a, b)) {
                return true;
            }
            if (this.w9(a, b)) {
                return true;
            }
            return false;
        }
        o3(a, b) {
            super.o3(a, b);
            let c = b;
            if (a && c.dg != null) {
                c.dg.count = 0;
            }
        }
        iu() {
            return this.abu.k5(this.ct.by, this.ct.bx, this.getEffectiveViewport1(this.ct));
        }
        z4(a, b) {
            super.z4(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.ab0.ch, f);
            g.b = this.iw();
            let h = new ScalerParams(0, d, e, this.abu.ch, f);
            let i = this.ab0;
            let j = i.ek(i.l8, g);
            let k = this.abu.k5(d, e, f);
            let l = this.abu;
            let m = b;
            if (isNaN_(k) || isInfinity(k)) {
                m.dg.count = 0;
                return;
            }
            this.yt.a2(this, this.zd(), runOn(this, this.ye), this.zm(b), this.zn(b));
            this.yt.r = this.ach;
            this.yt.s = this.aci;
            this.yt.k = this.ach;
            this.yt.l = this.aci;
            let n = false;
            let o = this.yt.b;
            if (o != null) {
                n = true;
            }
            let p = this.abu.cn;
            let q = p ? this.abu : null;
            let r = this.valueColumn.count;
            let s = this.zm(b);
            let t = 0;
            for (let u = 0; u < c.count; ++u) {
                let v = c._inner[u][0] - 0.5 * k;
                let w = this.acg(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.dg.item(t);
                t++;
                z.width = k;
                z.height = y;
                let aa = this.yt.aw(r, u)[0];
                if (p && a.m != null && u >= 0 && u < a.m.count) {
                    aa = truncate(Math.round(a.m._inner[u]));
                }
                if (n) {
                    this.z0(c, u, r, l, h, b.q, aa);
                }
                if (z.dataContext != null) {
                    let ab = z.dataContext;
                    if (s == 1) {
                        if (aa >= 0 && aa < this.dl.count) {
                            if (q != null && q.i$b != null && q.i$b.count > aa) {
                                aa = q.i$b._inner[aa];
                            }
                            ab.item = this.dl.item(aa);
                        }
                    }
                    else {
                        ab.item = null;
                    }
                }
                this.yt.ad(z, false, false, false, false);
                z.ap = this.yt.k;
                z.aq = this.yt.l;
                m.dl(z, v, Math.min(x, w));
            }
            m.dg.count = t;
            b.c3(a);
        }
        get acf() {
            return this.ace;
        }
        set acf(a) {
            if (this.acf != a) {
                let b = this.acf;
                this.ace = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.acf));
            }
        }
        acg(a) {
            if (a == null || a.length < 3) {
                return NaN;
            }
            switch (this.acf) {
                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.en(b, new ScalerParams(1, this.c9.v1, this.c9.v0, this.yAxis.ch));
                    if (c < this.yAxis.l8) {
                        return a[2];
                    }
                    else {
                        return a[1];
                    }
                case 4:
                    let d = (a[1] + a[2]) / 2;
                    let e = this.yAxis.en(d, new ScalerParams(1, this.c9.v1, this.c9.v0, this.yAxis.ch));
                    if (this.yAxis == null) {
                        return d;
                    }
                    if (e < this.yAxis.l8) {
                        return a[1];
                    }
                    else {
                        return a[2];
                    }
                default: return (a[1] + a[2]) / 2;
            }
        }
        get useHighMarkerFidelity() {
            return this.zh;
        }
    }
    ColumnSeries.$t = /*@__PURE__*/ markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    ColumnSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:ach:acn', [1, 0], 'RadiusY:aci:aco', [1, 0]]);
    return ColumnSeries;
})();
/**
 * @hidden
 */
export let ColumnSeriesView = /*@__PURE__*/ (() => {
    class ColumnSeriesView extends AnchoredCategorySeriesView {
        au() {
            super.au();
            this.dh = new List$1(Rectangle.$, 0);
            if (!this.q) {
                this.df.jn = Defaults.i;
                this.df.w2 = Defaults.c;
            }
        }
        constructor(a) {
            super(a);
            this.df = null;
            this.dh = null;
            this.dm = new Rectangle();
            this.dg = null;
            this.df = a;
            this.dg = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.dn);
                $ret.activate = runOn(this, this.di);
                $ret.disactivate = runOn(this, this.dk);
                $ret.destroy = runOn(this, this.dj);
                return $ret;
            })());
        }
        dn() {
            let a = new Rectangle();
            this.dh.add(a);
            a._visibility = 1;
            return a;
        }
        di(a) {
            a._visibility = 0;
        }
        dk(a) {
            a._visibility = 1;
        }
        dj(a) {
            this.dh.remove(a);
        }
        dl(a, b, c) {
            if (!this.isDirty) {
                this.as();
            }
            a.o = c;
            a.n = b;
        }
        ac(a) {
            return this.dh._inner[a];
        }
        ab(a) {
            let b = this.dh._inner[a];
            this.dm._visibility = b._visibility;
            this.dm.n = b.n;
            this.dm.o = b.o;
            this.dm.width = b.width;
            this.dm.height = b.height;
            let c = this.bs(a);
            this.dm._fill = c;
            this.dm._stroke = c;
            this.dm.ad = this.e.ic + 3;
            return this.dm;
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                for (let c = 0; c < this.dh.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.dg.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.bb.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    ColumnSeriesView.$t = /*@__PURE__*/ markType(ColumnSeriesView, 'ColumnSeriesView', AnchoredCategorySeriesView.$);
    return ColumnSeriesView;
})();
