/*
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 { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
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.zc = new ScatterFrame();
            this.ze = new ScatterFrame();
            this.za = new ScatterFrame();
        }
        bk() {
            return new ScatterSplineSeries();
        }
        get_f1() {
            return true;
        }
        ct() {
            return new ScatterSplineSeriesView(this);
        }
        z6() {
            return true;
        }
        jn() {
            if (!isNaN_(this.jm)) {
                return super.jn();
            }
            return Defaults.ak;
        }
        rg(a, b, c, d) {
            super.rg(a, b, c, d);
            switch (b) {
                case ScatterSplineSeries.$$p[0]:
                    this.ry(false);
                    this.qr();
                    break;
            }
        }
        b3() {
            if (this.b4 == 0) {
                return 2;
            }
            else {
                return super.b3();
            }
        }
        abp(a, b) {
            super.abp(a, b);
            a.n.clear();
            a.v.clear();
            let c = b.ca;
            let d = b.b9;
            let e = this.getEffectiveViewport1(b);
            let f = this.ie * this.ie;
            let g = Math.min(this.zr != null ? this.zr.count : 0, this.zs != null ? this.zs.count : 0);
            let h = new ScalerParams(0, c, d, this.y6.d, e);
            let i = ((() => {
                let $ret = new ScalerParams(0, c, d, this.y6.e, e);
                $ret.b = this.i0();
                return $ret;
            })());
            let j = (k) => this.y6.a.ft(this.zr.item(k), h);
            let k = (l) => this.y6.b.ft(this.zs.item(l), i);
            let l = ((() => {
                let $ret = new Clipper(0, d, false);
                $ret.i = a.n;
                return $ret;
            })());
            for (let m = 0; m < g;) {
                let n = m;
                ++m;
                while (m < g && this.acx(j, k, n, m) < f) {
                    ++m;
                }
                if (g > this.aaj) {
                    l.j(this.ac1(j, k, n, m - 1));
                }
                else {
                    let o = new OwnedPoint();
                    o.c = { $type: Point_$type, x: j(n), y: k(n) };
                    o.a = this.dp.item(n);
                    if (!a.v.containsKey(o.a)) {
                        a.v.addItem(o.a, o);
                    }
                }
            }
            if (g > this.aaj) {
                l.i = null;
            }
        }
        ac1(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 };
        }
        acx(a, b, c, d) {
            let e = a(d) - a(c);
            let f = b(d) - b(c);
            return e * e + f * f;
        }
        get_z0() {
            return true;
        }
        pb(a, b) {
            super.pb(a, b);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            c.dm(false);
        }
        ab0(a, b) {
            this.pb(false, b);
            super.ab0(a, b);
            this.abs(a);
            let c = typeCast(ScatterSplineSeriesView.$, b);
            let d = c.dz;
            this.zj.az(this, this.z5(), runOn(this, this.yz));
            let e = false;
            let f = this.zj.b;
            if (f != null) {
                e = true;
            }
            if (e) {
                this.abl(-1, this.zr.count, b.t);
            }
            this.zj.ad(d, true, false, true, false);
            c.dz.an = new PathGeometry();
            c.dz.an.c = Numeric.h(a.n.count, (g) => a.n._inner[g].x, (g) => a.n._inner[g].y, this.acy);
        }
    }
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:acy:ac0', [1, 0.5]]);
    return ScatterSplineSeries;
})();
