/*
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 { __extends } from "tslib";
import { Base, Point_$type, markType } from "igniteui-angular-core";
import { ViewportUtils } from "./ViewportUtils";
import { NumericScaler } from "./NumericScaler";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var PolarAxes = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(PolarAxes, _super);
    function PolarAxes(a, b) {
        var _this = _super.call(this) || this;
        _this.b = null;
        _this.a = null;
        _this.g = { $type: Point_$type, x: 0.5, y: 0.5 };
        _this.b = a;
        _this.a = b;
        return _this;
    }
    PolarAxes.prototype.c = function (a, b, c, d, e, f) {
        var g = this.g.x + (b * f(a));
        return ViewportUtils.e(g, c, d, e);
    };
    PolarAxes.prototype.h = function (a, b, c, d, e, f, g, h, i, j, k) {
        var l = this.a.getScaledAngle1(a, f, g);
        var m = this.b.oe(b, h, i, j, k);
        var n = this.g.x;
        var o = this.g.y;
        var p = n + (m * Math.cos(l));
        var q = o + (m * Math.sin(l));
        p = ViewportUtils.e(p, c, d, e);
        q = ViewportUtils.i(q, c, d, e);
        return { $type: Point_$type, x: p, y: q };
    };
    PolarAxes.prototype.e = function (a, b, c, d, e, f, g, h, i) {
        var j = Math.min(b != null ? b.count : 0, c != null ? c.count : 0);
        a.clear();
        var k;
        var l;
        var m = this.g.x;
        var n = this.g.y;
        var o;
        var p;
        var q = Math.min(this.a.l4, this.a.l3);
        var r = Math.max(this.a.l4, this.a.l3);
        var s = Math.min(this.b.l3, this.b.l4);
        var t = Math.max(this.b.l3, this.b.l4);
        var u = this.a.lp;
        var v = this.a.ch;
        var w = this.b.lp;
        var x = this.b.ch;
        var y = this.b.n7;
        var z = this.b.n6;
        var aa = NumericScaler.ac;
        for (var ab = 0; ab < j; ab++) {
            if ((b.item(ab) <= r && b.item(ab) >= q && c.item(ab) <= t && c.item(ab) >= s) || (isNaN_(b.item(ab)) || isNaN_(c.item(ab)))) {
                k = this.a.getScaledAngle1(b.item(ab), u, v);
                l = this.b.oe(c.item(ab), w, x, y, z);
                o = m + (l * g(ab, k));
                p = n + (l * h(ab, k));
                if (!f.isEmpty) {
                    var ac = f.left + f.width * (o - aa.left) / aa.width;
                    ac = (ac - e.left) / e.width;
                    o = e.left + e.width * (ac - d.left) / d.width;
                }
                else {
                    o = e.left + e.width * (o - d.left) / d.width;
                }
                if (!f.isEmpty) {
                    var ad = f.top + f.height * (p - aa.top) / aa.height;
                    ad = (ad - e.top) / e.height;
                    p = e.top + e.height * (ad - d.top) / d.height;
                }
                else {
                    p = e.top + e.height * (p - d.top) / d.height;
                }
                a.add({ $type: Point_$type, x: o, y: p });
            }
            else {
                a.add({ $type: Point_$type, x: NaN, y: NaN });
            }
        }
    };
    PolarAxes.prototype.f = function (a, b, c, d, e, f, g) {
        var h = ViewportUtils.b(a, c, d, e);
        var i = ViewportUtils.g(b, c, d, e);
        var j = Math.sqrt(Math.pow(h - this.g.x, 2) + Math.pow(i - this.g.y, 2));
        var k = Math.acos((h - this.g.x) / j);
        if ((i - this.g.y) < 0) {
            k = (2 * Math.PI) - k;
        }
        f = this.a.getUnscaledAngle(k);
        g = this.b.of(j);
        return {
            p5: f,
            p6: g
        };
    };
    PolarAxes.prototype.d = function (a, b, c, d, e, f) {
        var g = this.g.y + (b * f(a));
        return ViewportUtils.i(g, c, d, e);
    };
    PolarAxes.$t = markType(PolarAxes, 'PolarAxes');
    return PolarAxes;
}(Base));
export { PolarAxes };
