/*
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 { Base, Point_$type, markType } from "igniteui-angular-core/ES5/type";
import { IVerticalAnchoredCategorySeriesInteractionManager_$type } from "./IVerticalAnchoredCategorySeriesInteractionManager";
import { Rect } from "igniteui-angular-core/ES5/Rect";
import { ScalerParams } from "./ScalerParams";
import { ArrayExtension } from "igniteui-angular-core/ES5/ArrayExtension";
/**
 * @hidden
 */
var VerticalAnchoredCategorySeriesInteractionManager = /** @class */ (function (_super) {
    tslib_1.__extends(VerticalAnchoredCategorySeriesInteractionManager, _super);
    function VerticalAnchoredCategorySeriesInteractionManager() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    VerticalAnchoredCategorySeriesInteractionManager.prototype.e$a = function (a, b) {
        var c = a.bs != null ? a.bs.mq : Rect.empty;
        var d = a.bi.br;
        var e = a.li(a.bi);
        var f = a.getEffectiveViewport1(a.bi);
        var g = a.ap();
        var h = -1;
        if (g != null && !c.isEmpty && !d.isEmpty) {
            var i = new ScalerParams(0, c, d, g.b8, f);
            var j = g.dw(e.top, i);
            var k = g.dw(e.bottom, i);
            var l = (b.y - c.top) / c.height;
            var m = j + (l * (k - j));
            if (g.categoryMode != 0) {
                m -= 0.5;
            }
            h = m;
        }
        return h;
    };
    VerticalAnchoredCategorySeriesInteractionManager.prototype.e$b = function (a, b, c, d) {
        var e = a.k8(c);
        var f = -1;
        var g = a.ap().b8;
        var h = a.bi.br.bottom * 2;
        if (g) {
            f = ArrayExtension.binarySearch$11(Point_$type, b, function (i) { return (h - e.y) < (h - i.y) ? -1 : ((h - e.y) > (h - i.y) ? 1 : 0); });
        }
        else {
            f = ArrayExtension.binarySearch$11(Point_$type, b, function (i) { return e.y < i.y ? -1 : (e.y > i.y ? 1 : 0); });
        }
        if (f < 0) {
            f = ~f;
        }
        if (f < 0) {
            f = 0;
        }
        if (f > b.count - 1) {
            f = b.count - 1;
        }
        var i = f;
        var j = f;
        if (i > 0) {
            i--;
        }
        if (j < b.count - 1) {
            j++;
        }
        var k = b._inner[i].y;
        var l = b._inner[f].y;
        var m = b._inner[j].y;
        var n = Math.abs(k - e.y);
        var o = Math.abs(l - e.y);
        var p = Math.abs(m - e.y);
        var q = d(i);
        var r = d(f);
        var s = d(j);
        var t = q.containsPoint(e);
        var u = r.containsPoint(e);
        var v = s.containsPoint(e);
        if (o <= n && o <= p) {
            if (!g && v) {
                return s;
            }
            if (g && t) {
                return q;
            }
            return r;
        }
        if (n <= o && n <= p) {
            if (!g && u) {
                return r;
            }
            return d(i);
        }
        if (p <= o && p <= n) {
            if (g && u) {
                return r;
            }
            return d(j);
        }
        return Rect.empty;
    };
    VerticalAnchoredCategorySeriesInteractionManager.$t = markType(VerticalAnchoredCategorySeriesInteractionManager, 'VerticalAnchoredCategorySeriesInteractionManager', Base.$, [IVerticalAnchoredCategorySeriesInteractionManager_$type]);
    return VerticalAnchoredCategorySeriesInteractionManager;
}(Base));
export { VerticalAnchoredCategorySeriesInteractionManager };
//# sourceMappingURL=VerticalAnchoredCategorySeriesInteractionManager.js.map