/*
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 { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-angular-core";
import { Point_$type, typeCast, runOn, markType, markDep } from "igniteui-angular-core";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Defaults } from "./Defaults";
import { Clipper } from "igniteui-angular-core";
import { ScalerParams } from "./ScalerParams";
import { OwnedPoint } from "./OwnedPoint";
import { PathGeometry } from "igniteui-angular-core";
import { Numeric } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
export let ScatterSplineSeries = /*@__PURE__*/ (() => {
    class ScatterSplineSeries extends ScatterBase {
        constructor() {
            super();
            this.ab = ScatterSplineSeries.$;
            this.r7 = new ScatterFrame();
            this.r9 = new ScatterFrame();
            this.r5 = new ScatterFrame();
        }
        get_eh() {
            return true;
        }
        bx() {
            return new ScatterSplineSeriesView(this);
        }
        gw() {
            if (!isNaN_(this.gv)) {
                return super.gw();
            }
            return Defaults.x;
        }
        l7(a, b, c, d) {
            super.l7(a, b, c, d);
            switch (b) {
                case ScatterSplineSeries.$$p[0]:
                    this.ml(false);
                    this.ls();
                    break;
            }
        }
        bp() {
            if (this.bq == 0) {
                return 2;
            }
            else {
                return super.bp();
            }
        }
        t1(a, b) {
            super.t1(a, b);
            a.m.clear();
            a.u.clear();
            let c = b.bv;
            let d = b.bu;
            let e = this.getEffectiveViewport1(b);
            let f = this.fv * this.fv;
            let g = Math.min(this.sh != null ? this.sh.count : 0, this.si != null ? this.si.count : 0);
            let h = new ScalerParams(0, c, d, this.r1.d, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, this.r1.e, e);
                $ret.b = this.ge();
                return $ret;
            })());
            let j = (k) => this.r1.a.ei(this.sh.item(k), h);
            let k = (l) => this.r1.b.ei(this.si.item(l), i);
            let l = ((() => {
                let $ret = new Clipper(0, d, false);
                $ret.i = a.m;
                return $ret;
            })());
            for (let m = 0; m < g;) {
                let n = m;
                ++m;
                while (m < g && this.u6(j, k, n, m) < f) {
                    ++m;
                }
                if (g > this.s2) {
                    l.j(this.va(j, k, n, m - 1));
                }
                else {
                    let o = new OwnedPoint();
                    o.c = { $type: Point_$type, x: j(n), y: k(n) };
                    o.a = this.ck.item(n);
                    if (!a.u.containsKey(o.a)) {
                        a.u.addItem(o.a, o);
                    }
                }
            }
            if (g > this.s2) {
                l.i = null;
            }
        }
        va(a, b, c, d) {
            if (c == d) {
                return { $type: Point_$type, x: a(c), y: b(c) };
            }
            let e = 0;
            let f = 0;
            let g = (d - c + 1);
            for (let h = c; h <= d; ++h) {
                e += a(h);
                f += b(h);
            }
            return { $type: Point_$type, x: e / g, y: f / g };
        }
        u6(a, b, c, d) {
            let e = a(d) - a(c);
            let f = b(d) - b(c);
            return e * e + f * f;
        }
        get_sp() {
            return true;
        }
        k0(a, b) {
            super.k0(a, b);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            c.c4(false);
        }
        uc(a, b) {
            this.k0(false, b);
            super.uc(a, b);
            this.t4(a);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            let d = c.dg;
            this.se.ax(this, this.su(), runOn(this, this.rp));
            let e = false;
            let f = this.se.b;
            if (f != null) {
                e = true;
            }
            if (e) {
                this.tx(-1, this.sh.count, b.q);
            }
            this.se.ad(d, true, false, true, false);
            c.dg.ak = new PathGeometry();
            c.dg.ak.c = Numeric.h(a.m.count, (g) => a.m._inner[g].x, (g) => a.m._inner[g].y, this.u7);
        }
    }
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:u7:u9', [1, 0.5]]);
    return ScatterSplineSeries;
})();
