/*
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 { SplineType_$type } from "./SplineType";
import { DependencyProperty } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { typeCast, Point_$type, enumGetBox, markType, markDep } from "igniteui-react-core";
import { CollisionAvoider } from "./CollisionAvoider";
import { ISortingAxis_$type } from "./ISortingAxis";
import { AnchoredCategorySeriesView } from "./AnchoredCategorySeriesView";
import { SafeSortedReadOnlyDoubleCollection } from "./SafeSortedReadOnlyDoubleCollection";
import { Numeric } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { truncate, isNaN_ } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
/**
 * @hidden
 */
export let SplineSeriesBase = /*@__PURE__*/ (() => {
    class SplineSeriesBase extends HorizontalAnchoredCategorySeries {
        constructor() {
            super(...arguments);
            this.s6 = null;
        }
        bp() {
            return new SplineSeriesBaseView(this);
        }
        kk(a) {
            super.kk(a);
            this.s7 = a;
        }
        get_cy() {
            return true;
        }
        td(a, b, c, d, e, f) {
            let g = typeCast(ISortingAxis_$type, d);
            let h = this.getEffectiveViewport1(f);
            if (g == null) {
                return;
            }
            let i = new ScalerParams(0, b, c, d.ca, h);
            let j = new ScalerParams(0, b, c, e.ca, h);
            j.b = this.fa();
            let k = this.ok();
            let l = 0;
            let m = this.tb(d, b, c, h);
            let n = (o) => o;
            let o = (p) => this.valueColumn.item(g.i$b._inner[p]);
            let p = this.p3.cr.f;
            let q = this.p3.cr.e;
            let r = truncate(Math.ceil(c.width / (p - q)));
            let s = new CollisionAvoider();
            let t = this.p3.cr.d;
            if (t <= 0 || (q <= 0 && p <= 0)) {
                this.p3.cu.count = l;
                return;
            }
            let u = 0;
            let v = 0;
            for (let w = q; w < p + 1; ++w) {
                let x = null;
                let y = w * t;
                if (g != null && g.i$b != null && y >= 0 && y < g.i$b.count) {
                    y = g.i$b._inner[y];
                }
                if (w >= (this.valueColumn.count - 1)) {
                    if (k && this.s9(a, a.f._inner[a.f.count - 1], s, Math.min(y, this.cd.count - 1), l, f, u - 1)) {
                        ++l;
                    }
                    break;
                }
                let z = n(w);
                let aa = o(w);
                let ab = n(w + 1);
                let ac = o(w + 1);
                let ad = ab - z;
                let ae = this.s6[w];
                let af = this.s6[w + 1];
                let ag = g.i$d(g.i$b._inner[w]);
                let ah = d.dz(ag, i) + m;
                let ai = e.dz(aa, j);
                a.f.add([ah, ai, ai]);
                u++;
                v = u;
                for (let aj = 1; aj < r; ++aj) {
                    let ak = aj / r;
                    let al = z + ad * ak;
                    let am = (ab - al) / ad;
                    let an = (al - z) / ad;
                    let ao = am * aa + an * ac + ((am * am * am - am) * ae + (an * an * an - an) * af) * (ad * ad) / 6;
                    let ap = g.i$d(g.i$b._inner[w]);
                    let aq = g.i$d(g.i$b._inner[w + 1]);
                    let ar = ap + (aq - ap) * ak;
                    al = d.dz(ar, i) + m;
                    ao = e.dz(ao, j);
                    a.f.add([al, ao, ao]);
                    u++;
                }
                if (k) {
                    x = [ah, ai, ai];
                }
                if (k && this.s9(a, x, s, Math.min(y, this.cd.count - 1), l, f, v - 1)) {
                    ++l;
                }
            }
            f.cu.count = l;
        }
        s9(a, b, c, d, e, f, g) {
            let h = b[0];
            let i = b[1];
            let j = new Rect(0, h - 5, i - 5, 11, 11);
            if (!isNaN_(h) && !isNaN_(i) && c.tryAdd(j)) {
                a.m.add({ $type: Point_$type, x: h, y: i });
                let k = f.cu.item(e);
                k.content.item = this.cd.item(d);
                k.al = g;
                return true;
            }
            return false;
        }
        aj(a, b, c, d, e, f) {
            if (a == null || a.cf || this.qu(this.bs) > 1 || this.qu(this.bs) == 0) {
                return super.aj(this.pu(), this.pv.f, this.qu(this.bs), this.qv(this.bs), e, f);
            }
            if (this.pv.f.count == 0) {
                return null;
            }
            let g = this.s7.cr.f;
            let h = this.bs.bu;
            let i = truncate(Math.ceil(h.width));
            if (g != d) {
                i = truncate(Math.ceil(h.width / (g - d)));
            }
            let j = -1;
            let k = -1;
            let l = this.e4(e);
            let m = this.gf(e, f);
            let n = this.gd(e, f);
            let o = truncate(Math.floor(m / this.qu(this.bs)));
            let p = truncate(Math.floor(n / this.qu(this.bs)));
            j = o - this.qv(this.bs);
            k = p - this.qv(this.bs);
            let q = j * i;
            let r = k * i;
            let s = 0;
            if (m != n) {
                s = (l - m) / (n - m);
            }
            let t = truncate(Math.floor(q + s * (r - q)));
            j = t;
            k = t + 1;
            if (j < 0) {
                j = 0;
            }
            if (j > this.pv.f.count - 1) {
                j = this.pv.f.count - 1;
            }
            if (k < 0) {
                k = 0;
            }
            if (k > this.pv.f.count - 1) {
                k = this.pv.f.count - 1;
            }
            let u = this.pv.f._inner[j];
            let v = this.pv.f._inner[k];
            let w = new Array(2);
            w[0] = u;
            w[1] = v;
            return w;
        }
        q9(a, b) {
            super.q9(a, b);
            if (a.f.count <= 1) {
                return;
            }
            if (b.cr.d == 0) {
                return;
            }
            let c = b.bv;
            let d = b.bu;
            let e = this.getEffectiveViewport1(b);
            let f = this.sn;
            let g = this.st;
            let h = new ScalerParams(0, c, d, f.ca, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, g.ca, e);
                $ret.b = this.fa();
                return $ret;
            })());
            a.f.clear();
            a.m.clear();
            let j = this.ok();
            let k = 0;
            let l = typeCast(ISortingAxis_$type, this.sn);
            if (l != null && l.i$b.count != this.cd.count) {
                return;
            }
            let m = this.tb(f, c, d, e);
            let n = (o) => o;
            let o = (p) => this.valueColumn.item(p);
            let p = b.cr.d;
            if ((this.s6 == null || this.s6.length != this.valueColumn.count) && p == 1) {
                let q = this.s8 == 0 ? NaN : 0;
                if (this.sn != null && typeCast(ISortingAxis_$type, this.sn) !== null && this.sn.i$b != null) {
                    let r = new SafeSortedReadOnlyDoubleCollection(1, this.valueColumn, this.sn.i$b, NaN);
                    o = (s) => r.item(s);
                }
                this.s6 = Numeric.c(this.valueColumn.count, n, o, q, q);
            }
            let s = b.cr.f;
            let t = b.cr.e;
            let u = truncate(Math.ceil(d.width / (s - t)));
            let v = new CollisionAvoider();
            if (l != null) {
                this.td(a, c, d, f, g, b);
                return;
            }
            let w = b;
            w.c6();
            let x = 0;
            let y = 0;
            for (let z = t; z <= s; ++z) {
                let aa = null;
                if (p == 1) {
                    if (z >= (this.valueColumn.count - 1)) {
                        if (j && this.s9(a, a.f._inner[a.f.count - 1], v, Math.min(z * p, this.cd.count - 1), k, b, x - 1)) {
                            ++k;
                        }
                        break;
                    }
                    let ab = n(z);
                    let ac = o(z);
                    let ad = n(z + 1);
                    let ae = o(z + 1);
                    let af = ad - ab;
                    let ag = this.s6[z];
                    let ah = this.s6[z + 1];
                    let ai = f.dz(ab, h) + m;
                    let aj = g.dz(ac, i);
                    a.f.add([ai, aj, aj]);
                    x++;
                    y = x;
                    for (let ak = 1; ak < u; ++ak) {
                        let al = ab + af * ak / u;
                        let am = (ad - al) / af;
                        let an = (al - ab) / af;
                        let ao = am * ac + an * ae + ((am * am * am - am) * ag + (an * an * an - an) * ah) * (af * af) / 6;
                        al = f.dz(al, h) + m;
                        ao = g.dz(ao, i);
                        a.f.add([al, ao, ao]);
                        x++;
                    }
                    if (j) {
                        aa = b.cr.getBucket(z);
                        aa[0] = (f.dz(aa[0], h) + m);
                        aa[1] = g.dz(aa[1], i);
                        aa[2] = g.dz(aa[2], i);
                    }
                }
                else {
                    aa = b.cr.getBucket(z);
                    if (!isNaN_(aa[0])) {
                        aa[0] = (f.dz(aa[0], h) + m);
                        aa[1] = g.dz(aa[1], i);
                        aa[2] = g.dz(aa[2], i);
                        a.f.add(aa);
                        x++;
                    }
                }
                if (j && this.s9(a, aa, v, Math.min(z * p, this.cd.count - 1), k, b, y - 1)) {
                    ++k;
                }
            }
            w.c8();
            b.cu.count = k;
        }
        ta(a, b, c, d, e, f, g) {
            let h = d - b;
            let i = b + h * a;
            let j = (d - i) / h;
            let k = (i - b) / h;
            let l = j * c + k * e + ((j * j * j - j) * f + (k * k * k - k) * g) * (h * h) / 6;
            return l;
        }
        e8(a, b, c, d, e, f, g, h) {
            let i = NaN;
            if (c >= 0 && c < b.count) {
                i = b.item(c);
            }
            let j = NaN;
            if (d >= 0 && d < b.count) {
                j = b.item(d);
            }
            if (f == 0) {
                return j;
            }
            if (e == b.count - 1) {
                return i;
            }
            if (isNaN_(j) && g != 0 && a <= 0.5 && !h) {
                return i;
            }
            if (isNaN_(i) && g != 0 && a >= 0.5 && !h) {
                return j;
            }
            let k = e;
            let l = f;
            let m = i;
            let n = j;
            let o = NaN;
            let p = NaN;
            if (this.s6 != null && e >= 0 && e < this.s6.length) {
                o = this.s6[e];
            }
            if (this.s6 != null && f >= 0 && f < this.s6.length) {
                p = this.s6[f];
            }
            return this.ta(a, k, m, l, n, o, p);
        }
        tb(a, b, c, d) {
            let e = this.preferredCategoryMode(a);
            if (e == 0 && a.categoryMode != 0) {
                e = 1;
            }
            let f = 0;
            switch (e) {
                case 0:
                    f = 0;
                    break;
                case 1:
                    f = 0.5 * a.getCategorySize(b, c, d);
                    break;
                case 2:
                    f = a.getGroupCenter(this.gi, b, c, d);
                    break;
            }
            if (a.ca) {
                f = -f;
            }
            return f;
        }
        te() {
            this.s6 = null;
        }
        kp(a, b, c, d) {
            switch (b) {
                case "ValueColumn":
                case "FastItemsSource":
                    this.te();
                    break;
            }
            super.kp(a, b, c, d);
            switch (b) {
                case SplineSeriesBase.$$p[0]:
                    this.te();
                    this.k3(false);
                    this.ka();
                    break;
            }
        }
        jo(a, b, c, d) {
            this.te();
            super.jo(a, b, c, d);
        }
        get useHighMarkerFidelity() {
            return this.qp;
        }
    }
    SplineSeriesBase.$t = /*@__PURE__*/ markType(SplineSeriesBase, 'SplineSeriesBase', HorizontalAnchoredCategorySeries.$);
    SplineSeriesBase.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, SplineSeriesBase, 'raisePropertyChanged', ['SplineType:s8:tf', [SplineType_$type, /*@__PURE__*/ enumGetBox(SplineType_$type, 0)]]);
    return SplineSeriesBase;
})();
/**
 * @hidden
 */
export let SplineSeriesBaseView = /*@__PURE__*/ (() => {
    class SplineSeriesBaseView extends AnchoredCategorySeriesView {
        constructor(a) {
            super(a);
            this.da = null;
            this.da = a;
        }
        af() {
            let a = new Color();
            a.colorString = "rgba(95,95,95,0.5)";
            this.e.ni = a;
            this.e.fs = 3;
            this.e.ft = 1;
            this.e.fu = 4;
            this.e.ea = false;
        }
    }
    SplineSeriesBaseView.$t = /*@__PURE__*/ markType(SplineSeriesBaseView, 'SplineSeriesBaseView', AnchoredCategorySeriesView.$);
    return SplineSeriesBaseView;
})();
//# sourceMappingURL=SplineSeriesBase_combined.js.map
