/*
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-react-core";
import { ViewportUtils } from "./ViewportUtils";
import { isNaN_ } from "igniteui-react-core";
/**
 * @hidden
 */
var RadialAxes = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RadialAxes, _super);
    function RadialAxes(a, b) {
        var _this = _super.call(this) || this;
        _this.b = null;
        _this.a = null;
        _this.h = { $type: Point_$type, x: 0.5, y: 0.5 };
        _this.b = a;
        _this.a = b;
        return _this;
    }
    RadialAxes.prototype.d = function (a, b, c, d, e) {
        var f = this.h.x + (b * Math.cos(a));
        return ViewportUtils.e(f, c, d, e);
    };
    RadialAxes.prototype.f = function (a, b, c, d, e, f, g) {
        var h = Math.min(b != null ? b.count : 0, c != null ? c.count : 0);
        var i = false;
        if (a.count == h) {
            i = true;
        }
        var j;
        var k;
        var l = this.h.x;
        var m = this.h.y;
        var n;
        var o;
        for (var p = 0; p < h; p++) {
            j = this.a.getScaledAngle(b.item(p));
            k = this.b.nv(c.item(p));
            n = l + (k * f(p, j));
            o = m + (k * g(p, j));
            n = e.left + e.width * (n - d.left) / d.width;
            o = e.top + e.height * (o - d.top) / d.height;
            if (!i) {
                a.add({ $type: Point_$type, x: n, y: o });
            }
            else {
                a.item(p, { $type: Point_$type, x: n, y: o });
            }
        }
    };
    RadialAxes.prototype.g = 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.h.x, 2) + Math.pow(i - this.h.y, 2));
        var k = Math.acos((h - this.h.x) / j);
        if (j == 0 && isNaN_(k)) {
            k = 0;
        }
        if ((i - this.h.y) < 0) {
            k = (2 * Math.PI) - k;
        }
        f = this.a.getUnscaledAngle(k);
        g = this.b.nx(j);
        return {
            p5: f,
            p6: g
        };
    };
    RadialAxes.prototype.e = function (a, b, c, d, e) {
        var f = this.h.y + (b * Math.sin(a));
        return ViewportUtils.i(f, c, d, e);
    };
    RadialAxes.prototype.c = function (a, b, c, d) {
        var e = { $type: Point_$type, x: ViewportUtils.e(this.h.x, b, c, d), y: ViewportUtils.i(this.h.y, b, c, d) };
        var f = { $type: Point_$type, x: ViewportUtils.e(a.x, b, c, d), y: ViewportUtils.i(a.y, b, c, d) };
        var g = Math.sqrt(Math.pow(f.x - e.x, 2) + Math.pow(f.y - e.y, 2));
        var h = Math.acos((f.x - e.x) / g);
        if ((f.y - e.y) < 0) {
            h = (2 * Math.PI) - h;
        }
        return h;
    };
    RadialAxes.$t = markType(RadialAxes, 'RadialAxes');
    return RadialAxes;
}(Base));
export { RadialAxes };
