/*
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 * as tslib_1 from "tslib";
import { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Type, Point_$type, typeCast, markType } from "igniteui-react-core/ES5/type";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Clipper } from "igniteui-react-core/ES5/Clipper";
import { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-react-core/ES5/PathGeometry";
import { Numeric } from "igniteui-react-core/ES5/Numeric";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
/**
 * @hidden
 */
var ScatterSplineSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterSplineSeries, _super);
    function ScatterSplineSeries() {
        var _this = _super.call(this) || this;
        _this.ab = ScatterSplineSeries.$;
        _this.m2 = new ScatterFrame();
        _this.m4 = new ScatterFrame();
        _this.m1 = new ScatterFrame();
        return _this;
    }
    ScatterSplineSeries.prototype.bf = function () {
        return new ScatterSplineSeriesView(this);
    };
    ScatterSplineSeries.prototype.is = function (a, b, c, d) {
        _super.prototype.is.call(this, a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.i6(false);
                this.ic();
                break;
        }
    };
    ScatterSplineSeries.prototype.bd = function () {
        if (this.be == 0) {
            return 2;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    ScatterSplineSeries.prototype.nv = function (a, b) {
        var _this = this;
        _super.prototype.nv.call(this, a, b);
        a.m.clear();
        a.u.clear();
        var c = b.bs;
        var d = b.br;
        var e = this.getEffectiveViewport1(b);
        var f = this.er * this.er;
        var g = Math.min(this.m6 != null ? this.m6.count : 0, this.m8 != null ? this.m8.count : 0);
        var h = new ScalerParams(0, c, d, this.mx.d, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, _this.mx.e, e);
            $ret.b = _this.ee();
            return $ret;
        })());
        var j = function (k) { return _this.mx.a.dt(_this.m6.item(k), h); };
        var k = function (l) { return _this.mx.b.dt(_this.m8.item(l), i); };
        var l = ((function () {
            var $ret = new Clipper(0, d, false);
            $ret.i = a.m;
            return $ret;
        })());
        for (var m = 0; m < g;) {
            var n = m;
            ++m;
            while (m < g && this.oq(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.nd) {
                l.j(this.ou(j, k, n, m - 1));
            }
            else {
                var o = new OwnedPoint();
                o.c = { $type: Point_$type, x: j(n), y: k(n) };
                o.a = this.bz.item(n);
                if (!a.u.containsKey(o.a)) {
                    a.u.addItem(o.a, o);
                }
            }
        }
        if (g > this.nd) {
            l.i = null;
        }
    };
    ScatterSplineSeries.prototype.ou = function (a, b, c, d) {
        if (c == d) {
            return { $type: Point_$type, x: a(c), y: b(c) };
        }
        var e = 0;
        var f = 0;
        var g = (d - c + 1);
        for (var h = c; h <= d; ++h) {
            e += a(h);
            f += b(h);
        }
        return { $type: Point_$type, x: e / g, y: f / g };
    };
    ScatterSplineSeries.prototype.oq = function (a, b, c, d) {
        var e = a(d) - a(c);
        var f = b(d) - b(c);
        return e * e + f * f;
    };
    ScatterSplineSeries.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.c0(false);
    };
    ScatterSplineSeries.prototype.n4 = function (a, b) {
        this.hp(false, b);
        _super.prototype.n4.call(this, a, b);
        this.ny(a);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.da.aj = new PathGeometry();
        c.da.aj.b = Numeric.h(a.m.count, function (d) { return a.m._inner[d].x; }, function (d) { return a.m._inner[d].y; }, this.or);
    };
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    return ScatterSplineSeries;
}(ScatterBase));
export { ScatterSplineSeries };
Type.dep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:or:ot', [1, 0.5]]);
