/*
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-angular-core";
import { ConsolidatedItemsPosition_$type } from "./ConsolidatedItemsPosition";
import { Defaults } from "./Defaults";
import { runOn, enumGetBox, markType, markDep, fromEnum } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { Rectangle } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
/**
 * @hidden
 */
export let ColumnSeries = /*@__PURE__*/ (() => {
    class ColumnSeries extends HorizontalAnchoredCategorySeries {
        constructor() {
            super();
            this.vc = null;
            this.u7 = 0;
            this.ab = ColumnSeries.$;
            this.uq = 2;
        }
        get_dh() {
            return true;
        }
        get_d2() {
            return true;
        }
        gu() {
            if (!isNaN_(this.gt)) {
                return super.gu();
            }
            return Defaults.h;
        }
        bx() {
            return new ColumnSeriesView(this);
        }
        ly(a) {
            super.ly(a);
            this.u6 = a;
        }
        b3() {
            if (this.b4 == 0) {
                return 2;
            }
            return super.b3();
        }
        ry() {
            return 1;
        }
        get_c2() {
            return true;
        }
        preferredCategoryMode(a) {
            return this.uq;
        }
        pu(a) {
            if (this.vc == null) {
                this.vc = runOn(this, this.u9);
            }
            let b = this.ut != null ? this.ut : this.yAxis;
            let c = this.un;
            return this.tl.c$d(this, a, c, b, this.ro, this.so(this.b0), this.sp(this.b0), this.vc);
        }
        ev(a, b) {
            if (this.ey(a, b)) {
                return true;
            }
            if (this.qf(a, b)) {
                return true;
            }
            return false;
        }
        kx(a, b) {
            super.kx(a, b);
            let c = b;
            if (a && c.db != null) {
                c.db.count = 0;
            }
        }
        ga() {
            return this.un.k3(this.b0.bv, this.b0.bu, this.getEffectiveViewport1(this.b0));
        }
        s6(a, b) {
            super.s6(a, b);
            let c = a.f;
            if (!b.t()) {
                return;
            }
            let d = b.bv;
            let e = b.bu;
            let f = this.getEffectiveViewport1(b);
            let g = new ScalerParams(0, d, e, this.ut.cg, f);
            g.b = this.gc();
            let h = new ScalerParams(0, d, e, this.un.cg, f);
            let i = this.ut;
            let j = i.ei(i.l5, g);
            let k = this.un.k3(d, e, f);
            let l = this.un;
            let m = b;
            if (isNaN_(k) || isInfinity(k)) {
                m.db.count = 0;
                return;
            }
            this.rw.a0(this, this.sg(), runOn(this, this.rh), this.so(b), this.sp(b));
            this.rw.r = this.va;
            this.rw.s = this.vb;
            this.rw.k = this.va;
            this.rw.l = this.vb;
            let n = false;
            let o = this.rw.b;
            if (o != null) {
                n = true;
            }
            let p = this.un.cm;
            let q = p ? this.un : null;
            let r = this.valueColumn.count;
            let s = this.so(b);
            let t = 0;
            for (let u = 0; u < c.count; ++u) {
                let v = c._inner[u][0] - 0.5 * k;
                let w = this.u9(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.db.item(t);
                t++;
                z.width = k;
                z.height = y;
                if (n) {
                    this.s2(c, u, r, l, h, b.q);
                }
                if (z.dataContext != null) {
                    let aa = z.dataContext;
                    if (s == 1) {
                        let ab = this.rw.au(r, u)[0];
                        if (ab >= 0 && ab < this.ck.count) {
                            if (q != null && q.i$b != null && q.i$b.count > ab) {
                                ab = q.i$b._inner[ab];
                            }
                            aa.item = this.ck.item(ab);
                        }
                    }
                    else {
                        aa.item = null;
                    }
                }
                this.rw.ad(z, false, false, false, false);
                z.am = this.rw.k;
                z.an = this.rw.l;
                m.dg(z, v, Math.min(x, w));
            }
            m.db.count = t;
            b.cy(a);
        }
        get u8() {
            return this.u7;
        }
        set u8(a) {
            if (this.u8 != a) {
                let b = this.u8;
                this.u7 = a;
                this.raisePropertyChanged("ConsolidatedColumnVerticalPosition", enumGetBox(ConsolidatedItemsPosition_$type, b), enumGetBox(ConsolidatedItemsPosition_$type, this.u8));
            }
        }
        u9(a) {
            if (a == null || a.length < 3) {
                return NaN;
            }
            switch (this.u8) {
                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.el(b, new ScalerParams(1, this.cd.sv, this.cd.su, this.yAxis.cg));
                    if (c < this.yAxis.l5) {
                        return a[2];
                    }
                    else {
                        return a[1];
                    }
                case 4:
                    let d = (a[1] + a[2]) / 2;
                    let e = this.yAxis.el(d, new ScalerParams(1, this.cd.sv, this.cd.su, this.yAxis.cg));
                    if (this.yAxis == null) {
                        return d;
                    }
                    if (e < this.yAxis.l5) {
                        return a[1];
                    }
                    else {
                        return a[2];
                    }
                default: return (a[1] + a[2]) / 2;
            }
        }
        get useHighMarkerFidelity() {
            return this.sj;
        }
    }
    ColumnSeries.$t = markType(ColumnSeries, 'ColumnSeries', HorizontalAnchoredCategorySeries.$);
    ColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ColumnSeries, 'raisePropertyChanged', ['RadiusX:va:vg', [1, 0], 'RadiusY:vb:vh', [1, 0]]);
    return ColumnSeries;
})();
/**
 * @hidden
 */
export let ColumnSeriesView = /*@__PURE__*/ (() => {
    class ColumnSeriesView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.da = null;
            this.dc = null;
            this.dh = new Rectangle();
            this.db = null;
            this.da = a;
            this.db = ((() => {
                let $ret = new Pool$1(Rectangle.$);
                $ret.create = runOn(this, this.di);
                $ret.activate = runOn(this, this.dd);
                $ret.disactivate = runOn(this, this.df);
                $ret.destroy = runOn(this, this.de);
                return $ret;
            })());
        }
        as() {
            super.as();
            this.dc = new List$1(Rectangle.$, 0);
            if (!this.q) {
                this.da.gz = Defaults.i;
                this.da.qc = Defaults.c;
            }
        }
        di() {
            let a = new Rectangle();
            this.dc.add(a);
            a._visibility = 1;
            return a;
        }
        dd(a) {
            a._visibility = 0;
        }
        df(a) {
            a._visibility = 1;
        }
        de(a) {
            this.dc.remove(a);
        }
        dg(a, b, c) {
            if (!this.isDirty) {
                this.aq();
            }
            a.o = c;
            a.n = b;
        }
        ac(a) {
            return this.dc._inner[a];
        }
        ab(a) {
            let b = this.dc._inner[a];
            this.dh._visibility = b._visibility;
            this.dh.n = b.n;
            this.dh.o = b.o;
            this.dh.width = b.width;
            this.dh.height = b.height;
            let c = this.bp(a);
            this.dh._fill = c;
            this.dh._stroke = c;
            this.dh.ac = this.e.fu + 3;
            return this.dh;
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                for (let c = 0; c < this.dc.count; c++) {
                    let d = this.aa(c, b);
                    this.bd(d, c, b);
                    a.v(d);
                }
            }
        }
        al(a) {
            super.al(a);
            let b = 0;
            let c = new List$1(Rectangle.$, 0);
            for (let d of fromEnum(this.db.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.a8.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
            b++;
        }
    }
    ColumnSeriesView.$t = markType(ColumnSeriesView, 'ColumnSeriesView', AnchoredCategorySeriesView.$);
    return ColumnSeriesView;
})();
