/*
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 {
        get_ed() {
            return true;
        }
        get_ey() {
            return true;
        }
        ip() {
            if (!isNaN_(this.io)) {
                return super.ip();
            }
            return Defaults.h;
        }
        cg() {
            return new ColumnSeriesView(this);
        }
        o0(a) {
            super.o0(a);
            this.ze = a;
        }
        cm() {
            if (this.cn == 0) {
                return 2;
            }
            return super.cm();
        }
        vw() {
            return 1;
        }
        constructor() {
            super();
            this.zk = null;
            this.zf = 0;
            this.ab = ColumnSeries.$;
            this.yy = 2;
        }
        get_du() {
            return true;
        }
        preferredCategoryMode(a) {
            return this.yy;
        }
        ts(a) {
            if (this.zk == null) {
                this.zk = runOn(this, this.zh);
            }
            let b = this.y1 != null ? this.y1 : this.yAxis;
            let c = this.yv;
            return this.xk.c$d(this, a, c, b, this.vm, this.wn(this.cj), this.wo(this.cj), this.zk);
        }
        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.de != null) {
                c.de.count = 0;
            }
        }
        h0() {
            return this.yv.k4(this.cj.by, this.cj.bx, this.getEffectiveViewport1(this.cj));
        }
        w5(a, b) {
            super.w5(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.y1.ch, f);
            g.b = this.h2();
            let h = new ScalerParams(0, d, e, this.yv.ch, f);
            let i = this.y1;
            let j = i.ej(i.l7, g);
            let k = this.yv.k4(d, e, f);
            let l = this.yv;
            let m = b;
            if (isNaN_(k) || isInfinity(k)) {
                m.de.count = 0;
                return;
            }
            this.vu.a2(this, this.we(), runOn(this, this.vf), this.wn(b), this.wo(b));
            this.vu.r = this.zi;
            this.vu.s = this.zj;
            this.vu.k = this.zi;
            this.vu.l = this.zj;
            let n = false;
            let o = this.vu.b;
            if (o != null) {
                n = true;
            }
            let p = this.yv.cn;
            let q = p ? this.yv : null;
            let r = this.valueColumn.count;
            let s = this.wn(b);
            let t = 0;
            for (let u = 0; u < c.count; ++u) {
                let v = c._inner[u][0] - 0.5 * k;
                let w = this.zh(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.w1(c, u, r, l, h, b.q);
                }
                if (z.dataContext != null) {
                    let aa = z.dataContext;
                    if (s == 1) {
                        let ab = this.vu.aw(r, u)[0];
                        if (ab >= 0 && ab < this.c6.count) {
                            if (q != null && q.i$b != null && q.i$b.count > ab) {
                                ab = q.i$b._inner[ab];
                            }
                            aa.item = this.c6.item(ab);
                        }
                    }
                    else {
                        aa.item = null;
                    }
                }
                this.vu.ad(z, false, false, false, false);
                z.ap = this.vu.k;
                z.aq = this.vu.l;
                m.dj(z, v, Math.min(x, w));
            }
            m.de.count = t;
            b.c1(a);
        }
        get zg() {
            return this.zf;
        }
        set zg(a) {
            if (this.zg != a) {
                let b = this.zg;
                this.zf = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.zg));
            }
        }
        zh(a) {
            if (a == null || a.length < 3) {
                return NaN;
            }
            switch (this.zg) {
                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.cy.t3, this.cy.t2, 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.cy.t3, this.cy.t2, 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.wi;
        }
    }
    ColumnSeries.$t = /*@__PURE__*/ markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    ColumnSeries.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:zi:zo', [1, 0], 'RadiusY:zj:zp', [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.iu = Defaults.i;
                this.dd.ua = 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.hk + 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.a9.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    ColumnSeriesView.$t = /*@__PURE__*/ markType(ColumnSeriesView, 'ColumnSeriesView', AnchoredCategorySeriesView.$);
    return ColumnSeriesView;
})();
