/*
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 { Size } from "igniteui-angular-core";
import { ViewportUtils } from "./ViewportUtils";
/**
 * @hidden
 */
var SliceCoords = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SliceCoords, _super);
    function SliceCoords() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.d = null;
        _this.f = null;
        _this.h = null;
        _this.j = null;
        _this.e = null;
        _this.g = null;
        _this.i = null;
        _this.k = null;
        _this.c = false;
        _this.n = new Size();
        _this.m = new Size();
        _this.l = new Size();
        return _this;
    }
    SliceCoords.b = function (a, b, c, d, e, f, g) {
        var h = Math.min(c, d);
        var i = Math.max(c, d);
        var j = Math.cos(h);
        var k = Math.sin(h);
        var l = Math.max(0, e);
        var m = f;
        var n = g.x + j * l;
        var o = g.y + k * l;
        var p = g.x + j * m;
        var q = g.y + k * m;
        var r = Math.cos(i);
        var s = Math.sin(i);
        var t = g.x + r * l;
        var u = g.y + s * l;
        var v = g.x + r * m;
        var w = g.y + s * m;
        n = ViewportUtils.c(n, a, b);
        o = ViewportUtils.f(o, a, b);
        p = ViewportUtils.c(p, a, b);
        q = ViewportUtils.f(q, a, b);
        t = ViewportUtils.c(t, a, b);
        u = ViewportUtils.f(u, a, b);
        v = ViewportUtils.c(v, a, b);
        w = ViewportUtils.f(w, a, b);
        var x = { $type: Point_$type, x: n, y: o };
        var y = { $type: Point_$type, x: p, y: q };
        var z = { $type: Point_$type, x: v, y: w };
        var aa = { $type: Point_$type, x: t, y: u };
        var ab = ViewportUtils.d(m, a, b);
        var ac = ViewportUtils.g(m, a, b);
        var ad = ViewportUtils.d(l, a, b);
        var ae = ViewportUtils.g(l, a, b);
        return ((function () {
            var $ret = new SliceCoords();
            $ret.d = x;
            $ret.f = y;
            $ret.h = z;
            $ret.j = aa;
            $ret.c = ((i - h) > Math.PI);
            $ret.n = new Size(1, ab, ac);
            $ret.m = new Size(1, ad, ae);
            return $ret;
        })());
    };
    SliceCoords.a = function (a, b, c, d, e, f, g, h, i) {
        var j = ViewportUtils.b(i, a, b);
        var k = f - e;
        if (k < 0) {
            return null;
        }
        if (ViewportUtils.d(k, a, b) < 2) {
            return null;
        }
        if (j * 2 > k) {
            j = k / 2;
            i = ViewportUtils.d(j, a, b);
        }
        var l = ViewportUtils.b(h, a, b);
        var m = l / (f - j);
        var n = Math.atan(m);
        if (n * 2 > Math.abs(d - c)) {
            n = Math.abs(d - c) / 2;
            h = ViewportUtils.d(Math.tan(n) * (f - j), a, b);
        }
        var o = SliceCoords.b(a, b, c + n, d - n, e, f, g);
        var p = SliceCoords.b(a, b, c, d, e + (j * (e / f)), f - j, g);
        o.g = o.f;
        o.k = o.j;
        o.e = p.d;
        o.f = p.f;
        o.i = p.h;
        o.j = p.j;
        o.l = new Size(1, h, i);
        return o;
    };
    SliceCoords.$t = markType(SliceCoords, 'SliceCoords');
    return SliceCoords;
}(Base));
export { SliceCoords };
