/*
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, markType } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { isInfinity } from "igniteui-angular-core";
/**
 * @hidden
 */
var CalloutViewHelper = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutViewHelper, _super);
    function CalloutViewHelper() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    CalloutViewHelper.a = function (a, b, c, d, e, f, g, h) {
        var i = Math.sqrt((c - a) * (c - a) + (d - b) * (d - b));
        var j = (c - a) / i;
        var k = (d - b) / i;
        var l = a - e;
        var m = b - f;
        var n = g - e;
        var o = h - f;
        var p = -k;
        var q = j;
        var r = n * p + o * q;
        var s = n * m - o * l;
        var t = l * p + m * q;
        var u = s / r;
        var v = t / r;
        if (u >= 0 && v >= 0 && v <= 1) {
            return u;
        }
        return Number.POSITIVE_INFINITY;
    };
    CalloutViewHelper.b = function (a, b, c, d) {
        var e = a.x;
        var f = a.y;
        var g = 0;
        var h = 0;
        var i = 0;
        var j = 0;
        var k = 0;
        var l = 0;
        if (e < 0) {
            g = -e;
            k = g;
            e = 0;
        }
        if (f < 0) {
            h = -f;
            l = h;
            f = 0;
        }
        if (e > b) {
            i = e - b;
        }
        if (f > c) {
            j = f - c;
        }
        var m = new Thickness(1, g, h, i, j);
        var n = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k, l, k, l + c);
        var o = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k, l, k + b, l);
        var p = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k, l + c, k + b, l + c);
        var q = CalloutViewHelper.a(e, f, k + b / 2, l + c / 2, k + b, l, k + b, l + c);
        var r = Math.min(n, Math.min(o, Math.min(p, q)));
        var s = 0;
        var t = 0;
        if (isInfinity(r)) {
            s = e;
            t = f;
        }
        else {
            var u = k + b / 2;
            var v = l + c / 2;
            var w = e;
            var x = f;
            var y = Math.sqrt((u - w) * (u - w) + (v - x) * (v - x));
            var z = (u - w) / y;
            var aa = (v - x) / y;
            s = w + z * r;
            t = x + aa * r;
        }
        d.ak = e;
        d.am = f;
        d.al = s;
        d.an = t;
        return m;
    };
    CalloutViewHelper.$t = markType(CalloutViewHelper, 'CalloutViewHelper');
    return CalloutViewHelper;
}(Base));
export { CalloutViewHelper };
