/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { Brush } from "igniteui-angular-core/ES5/Brush";
import { DependencyProperty } from "igniteui-angular-core/ES5/DependencyProperty";
import { Series } from "./Series";
import { Thickness } from "igniteui-angular-core/ES5/Thickness";
import { Visibility_$type } from "igniteui-angular-core/ES5/Visibility";
import { CrosshairLayerFrame } from "./CrosshairLayerFrame";
import { List$1 } from "igniteui-angular-core/ES5/List$1";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-angular-core/ES5/Dictionary$2";
import { Pool$1 } from "igniteui-angular-core/ES5/Pool$1";
import { AxisAnnotation } from "./AxisAnnotation";
import { Type, Number_$type, enumGetBox, fromEnum, Point_$type, markType, runOn } from "igniteui-angular-core/ES5/type";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { Tuple$2 } from "igniteui-angular-core/ES5/Tuple$2";
import { Path } from "igniteui-angular-core/ES5/Path";
import { PathGeometry } from "igniteui-angular-core/ES5/PathGeometry";
import { PathFigure } from "igniteui-angular-core/ES5/PathFigure";
import { LineSegment } from "igniteui-angular-core/ES5/LineSegment";
import { PropertyMetadata } from "igniteui-angular-core/ES5/PropertyMetadata";
import { isNaN_ } from "igniteui-angular-core/ES5/number";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { TranslateTransform } from "igniteui-angular-core/ES5/TranslateTransform";
import { LineGeometry } from "igniteui-angular-core/ES5/LineGeometry";
import { BrushUtil } from "igniteui-angular-core/ES5/BrushUtil";
/**
 * @hidden
 */
var CrosshairLayer = /** @class */ (function (_super) {
    tslib_1.__extends(CrosshairLayer, _super);
    function CrosshairLayer() {
        var _this = _super.call(this) || this;
        _this.xAxisAnnotationFormatLabel = null;
        _this.yAxisAnnotationFormatLabel = null;
        _this.nd = null;
        _this.nc = null;
        var a = new CrosshairLayerFrame();
        var b = new CrosshairLayerFrame();
        var c = new CrosshairLayerFrame();
        var d = _this.fi / 1000;
        _this.l1 = a;
        _this.l0 = b;
        _this.l2 = c;
        _this.ab = CrosshairLayer.$;
        return _this;
    }
    CrosshairLayer.prototype.bf = function () {
        return new CrosshairLayerView(this);
    };
    CrosshairLayer.prototype.it = function (a) {
        _super.prototype.it.call(this, a);
        this.m5 = a;
    };
    CrosshairLayer.prototype.m7 = function () {
        return this.xAxisAnnotationFormatLabel != null;
    };
    CrosshairLayer.prototype.m8 = function () {
        return this.yAxisAnnotationFormatLabel != null;
    };
    Object.defineProperty(CrosshairLayer.prototype, "ph", {
        get: function () {
            return new Thickness(1, this.nf, this.nh, this.ng, this.ne);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CrosshairLayer.prototype, "pi", {
        get: function () {
            return new Thickness(1, this.nk, this.nm, this.nl, this.nj);
        },
        enumerable: true,
        configurable: true
    });
    CrosshairLayer.prototype.mk = function (a, b) {
        if (this.m6 == null || this.m6 == a) {
            if (!this.aq.c) {
                this.jc(b);
            }
        }
    };
    CrosshairLayer.prototype.mm = function (a, b) {
        var e_1, _a;
        _super.prototype.mm.call(this, a, b);
        var c = a;
        var d = this.nb;
        var e = this.na;
        c.ad.clear();
        c.ae.clear();
        c.ac.clear();
        c.af.clear();
        AxisAnnotationFrameManager.b(c);
        if (this.l7(this.m6)) {
            this.oh(this.m6, c, d, e);
        }
        else {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.bs.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var f = _c.value;
                    if (this.l7(f)) {
                        this.oh(f, c, d, e);
                    }
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_1) throw e_1.error; }
            }
        }
    };
    CrosshairLayer.prototype.l7 = function (a) {
        if (!_super.prototype.l7.call(this, a)) {
            return false;
        }
        var b = this.mf(a);
        if (!b.c) {
            return false;
        }
        return true;
    };
    CrosshairLayer.prototype.im = function () {
        _super.prototype.im.call(this);
        if (!this.aq.c && !this.ca()) {
            return;
        }
        if (this.ca()) {
            this.oi(this.l2, false);
        }
        else {
            this.oi(this.l0, false);
        }
    };
    CrosshairLayer.prototype.oh = function (a, b, c, d) {
        var e = this.mf(a);
        if (!e.c) {
            return;
        }
        var f = e.d;
        f = a.lk(f, c, d);
        var g = this.k2;
        if (g == null) {
            g = this.k4;
        }
        if (g == null) {
            g = a.k2;
            if (g != null) {
                g = this.m5.b8(g);
            }
        }
        var h = g;
        var i = g;
        if (this.o9 != null) {
            h = this.o9;
        }
        if (this.pa != null) {
            i = this.pa;
        }
        b.ac.add(h);
        b.af.add(i);
        b.ad.add(f.y);
        b.ae.add(f.x);
        if (this.m9) {
            AxisAnnotationFrameManager.c(b, f, a, this.bs, this.getEffectiveViewport(), g, this.pb, this.pd, this.pc, this.ph, this.ni, this.pe, this.pg, this.pf, this.pi, this.nn, this.pk == 0, this.pj == 0);
        }
    };
    CrosshairLayer.prototype.oi = function (a, b) {
        var c = false;
        if (this.nc == null) {
            c = true;
            this.nd = new List$1(Axis.$, 0);
            this.nc = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.nc, this.nd, b, this.no, this.np, this.xAxisAnnotationFormatLabel, this.yAxisAnnotationFormatLabel);
    };
    CrosshairLayer.prototype.og = function (a, b, c, d, e) {
        var f = a.item(b);
        b++;
        if (e) {
            f._stroke = d.af._inner[c];
            f._fill = d.af._inner[c];
        }
        else {
            f._stroke = d.ac._inner[c];
            f._fill = d.ac._inner[c];
        }
        f.ac = this.ey;
        f.ai = this.la;
        f.ad = this.lb;
        return new Tuple$2(Path.$, Number_$type, f, b);
    };
    CrosshairLayer.prototype.mp = function (a, b) {
        _super.prototype.mp.call(this, a, b);
        var c = this.m5.b2;
        var d = a;
        var e = d.ad.count;
        var f = 0;
        var g = b.br.left;
        var h = b.br.right;
        var i = b.br.top;
        var j = b.br.bottom;
        var k = this.pk == 0;
        var l = this.pj == 0;
        for (var m = 0; m < e; m++) {
            var n = Math.floor(d.ad._inner[m]);
            var o = Math.floor(d.ae._inner[m]);
            var p = null;
            if (k) {
                if (isNaN_(n)) {
                    continue;
                }
                var q = this.og(c, f, m, d, true);
                p = q.c;
                f = q.d;
                var r = new PathGeometry();
                var s = new PathFigure();
                s._startPoint = { $type: Point_$type, x: o, y: i };
                var t = new LineSegment(1);
                t.c = { $type: Point_$type, x: o, y: j };
                s._segments.add(t);
                r.b.add(s);
                p.aj = r;
            }
            if (l) {
                if (isNaN_(n)) {
                    continue;
                }
                var u = this.og(c, f, m, d, false);
                p = u.c;
                f = u.d;
                var v = new PathGeometry();
                var w = new PathFigure();
                w._startPoint = { $type: Point_$type, x: g, y: n };
                var x = new LineSegment(1);
                x.c = { $type: Point_$type, x: h, y: n };
                w._segments.add(x);
                v.b.add(w);
                p.aj = v;
            }
        }
        c.count = f;
        if (this.ca()) {
            this.oi(this.l2, true);
        }
        else {
            this.oi(this.l0, false);
        }
    };
    CrosshairLayer.prototype.c8 = function () {
        return true;
    };
    CrosshairLayer.prototype.iy = function (a, b, c, d) {
        _super.prototype.iy.call(this, a, b, c, d);
        switch (b) {
            case CrosshairLayer.$$p[1]:
                this.jc(true);
                break;
            case CrosshairLayer.$$p[7]:
                this.jc(true);
                break;
            case CrosshairLayer.$$p[4]:
                this.jc(true);
                break;
            case CrosshairLayer.$$p[2]:
            case CrosshairLayer.$$p[8]:
            case CrosshairLayer.$$p[10]:
            case CrosshairLayer.$$p[12]:
            case CrosshairLayer.$$p[14]:
            case CrosshairLayer.$$p[13]:
            case CrosshairLayer.$$p[11]:
            case CrosshairLayer.$$p[15]:
            case CrosshairLayer.$$p[16]:
            case CrosshairLayer.$$p[17]:
            case CrosshairLayer.$$p[19]:
            case CrosshairLayer.$$p[21]:
            case CrosshairLayer.$$p[23]:
            case CrosshairLayer.$$p[22]:
            case CrosshairLayer.$$p[20]:
            case CrosshairLayer.$$p[24]:
            case CrosshairLayer.$$p[25]:
            case CrosshairLayer.$$p[0]:
            case CrosshairLayer.$$p[6]:
            case CrosshairLayer.$$p[5]:
                this.jc(true);
                break;
        }
    };
    CrosshairLayer.$t = markType(CrosshairLayer, 'CrosshairLayer', AnnotationLayer.$);
    return CrosshairLayer;
}(AnnotationLayer));
export { CrosshairLayer };
Type.dep(DependencyProperty, PropertyMetadata, CrosshairLayer, 'raisePropertyChanged', ['HorizontalLineStroke:o9:oj', [Brush.$, null], 'HorizontalLineVisibility:pj:ok', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'IsAxisAnnotationEnabled:m9:ol', [0, false], 'SkipUnknownValues:na:om', [0, true], 'TargetSeries:m6:on', [Series.$, null], 'UseInterpolation:nb:oo', [0, true], 'VerticalLineStroke:pa:op', [Brush.$, null], 'VerticalLineVisibility:pk:oq', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'XAxisAnnotationBackground:pb:or', [Brush.$, null], 'XAxisAnnotationInterpolatedValuePrecision:no:os', [1, -1], 'XAxisAnnotationOutline:pc:ot', [Brush.$, null], 'XAxisAnnotationPaddingBottom:ne:ou', [1, NaN], 'XAxisAnnotationPaddingLeft:nf:ov', [1, NaN], 'XAxisAnnotationPaddingRight:ng:ow', [1, NaN], 'XAxisAnnotationPaddingTop:nh:ox', [1, NaN], 'XAxisAnnotationStrokeThickness:ni:oy', [1, NaN], 'XAxisAnnotationTextColor:pd:oz', [Brush.$, null], 'YAxisAnnotationBackground:pe:o0', [Brush.$, null], 'YAxisAnnotationInterpolatedValuePrecision:np:o1', [1, -1], 'YAxisAnnotationOutline:pf:o2', [Brush.$, null], 'YAxisAnnotationPaddingBottom:nj:o3', [1, NaN], 'YAxisAnnotationPaddingLeft:nk:o4', [1, NaN], 'YAxisAnnotationPaddingRight:nl:o5', [1, NaN], 'YAxisAnnotationPaddingTop:nm:o6', [1, NaN], 'YAxisAnnotationStrokeThickness:nn:o7', [1, NaN], 'YAxisAnnotationTextColor:pg:o8', [Brush.$, null]]);
/**
 * @hidden
 */
var CrosshairLayerView = /** @class */ (function (_super) {
    tslib_1.__extends(CrosshairLayerView, _super);
    function CrosshairLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b1 = null;
        _this.b2 = null;
        _this.b3 = null;
        _this.b1 = a;
        _this.b3 = new List$1(Path.$, 0);
        return _this;
    }
    CrosshairLayerView.prototype.ap = function () {
        var _this = this;
        _super.prototype.ap.call(this);
        this.b2 = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.b9);
            $ret.activate = runOn(_this, _this.b4);
            $ret.disactivate = runOn(_this, _this.b6);
            $ret.destroy = runOn(_this, _this.b5);
            return $ret;
        })());
    };
    CrosshairLayerView.prototype.b9 = function () {
        var a = new Path();
        a.j = new TranslateTransform();
        this.b3.add(a);
        return a;
    };
    CrosshairLayerView.prototype.b4 = function (a) {
        a._visibility = 0;
    };
    CrosshairLayerView.prototype.b6 = function (a) {
        a._visibility = 1;
    };
    CrosshairLayerView.prototype.b5 = function (a) {
        this.b3.remove(a);
    };
    CrosshairLayerView.prototype.b7 = function (a, b, c, d) {
        if (a.aj == null || a.aj.b.x != d || a.aj.c.x != c) {
            var e = ((function () {
                var $ret = new LineGeometry();
                $ret.c = { $type: Point_$type, x: c, y: b };
                $ret.b = { $type: Point_$type, x: d, y: b };
                return $ret;
            })());
            a.aj = e;
        }
    };
    CrosshairLayerView.prototype.b8 = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, 0.1);
    };
    CrosshairLayerView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d && !b) {
            for (var c = 0; c < this.b3.count; c++) {
                var d = this.b3._inner[c];
                if (d._visibility == 0) {
                    a.s(d);
                }
            }
        }
    };
    CrosshairLayerView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        for (var b = 0; b < this.b3.count; b++) {
            this.e.a2.exportPathData(a, this.b3._inner[b], "crosshairLine", ["Main", "Crosshair"]);
        }
    };
    CrosshairLayerView.$t = markType(CrosshairLayerView, 'CrosshairLayerView', AnnotationLayerView.$);
    return CrosshairLayerView;
}(AnnotationLayerView));
export { CrosshairLayerView };
//# sourceMappingURL=CrosshairLayer_combined.js.map