/*
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-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { Series } from "./Series";
import { Thickness } from "igniteui-react-core";
import { Visibility_$type } from "igniteui-react-core";
import { CrosshairLayerFrame } from "./CrosshairLayerFrame";
import { List$1 } from "igniteui-react-core";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { Base, Number_$type, enumGetBox, fromEnum, Point_$type, markType, markDep, runOn } from "igniteui-react-core";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { Tuple$2 } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
import { PathGeometry } from "igniteui-react-core";
import { PathFigure } from "igniteui-react-core";
import { LineSegment } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { TranslateTransform } from "igniteui-react-core";
import { LineGeometry } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
/**
 * @hidden
 */
var CrosshairLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(CrosshairLayer, _super);
    function CrosshairLayer() {
        var _this = _super.call(this) || this;
        _this.xAxisAnnotationFormatLabel = null;
        _this.yAxisAnnotationFormatLabel = null;
        _this.pn = null;
        _this.pm = null;
        var a = new CrosshairLayerFrame();
        var b = new CrosshairLayerFrame();
        var c = new CrosshairLayerFrame();
        var d = _this.gj / 1000;
        _this.ob = a;
        _this.oa = b;
        _this.oc = c;
        _this.ab = CrosshairLayer.$;
        return _this;
    }
    CrosshairLayer.prototype.bp = function () {
        return new CrosshairLayerView(this);
    };
    CrosshairLayer.prototype.kk = function (a) {
        _super.prototype.kk.call(this, a);
        this.pf = a;
    };
    CrosshairLayer.prototype.ph = function () {
        return this.xAxisAnnotationFormatLabel != null;
    };
    CrosshairLayer.prototype.pi = function () {
        return this.yAxisAnnotationFormatLabel != null;
    };
    Object.defineProperty(CrosshairLayer.prototype, "ru", {
        get: function () {
            return new Thickness(1, this.pp, this.pr, this.pq, this.po);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(CrosshairLayer.prototype, "rv", {
        get: function () {
            return new Thickness(1, this.pu, this.pw, this.pv, this.pt);
        },
        enumerable: true,
        configurable: true
    });
    CrosshairLayer.prototype.ou = function (a, b) {
        if (this.pg == null || this.pg == a) {
            if (!this.ar.c) {
                this.k3(b);
            }
        }
    };
    CrosshairLayer.prototype.ow = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.ow.call(this, a, b);
        var c = a;
        var d = this.pl;
        var e = this.pk;
        c.ad.clear();
        c.ae.clear();
        c.ac.clear();
        c.af.clear();
        AxisAnnotationFrameManager.b(c);
        if (this.oh(this.pg)) {
            this.qt(this.pg, c, d, e);
        }
        else {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.b6.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var f = _c.value;
                    if (this.oh(f)) {
                        this.qt(f, c, d, e);
                    }
                    if (f.isStacked) {
                        f.jy(function (g) {
                            if (_this.oh(g)) {
                                _this.qt(g, c, d, e);
                            }
                            return true;
                        });
                    }
                }
            }
            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.oh = function (a) {
        if (!_super.prototype.oh.call(this, a)) {
            return false;
        }
        if (this.p4 != null) {
            if (a.c7) {
                var b = a.ib();
                if (!Base.equalsStatic(this.p4, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.p4, a.name)) {
                    return false;
                }
            }
        }
        var c = this.op(a);
        if (!c.c) {
            return false;
        }
        return true;
    };
    CrosshairLayer.prototype.kd = function () {
        _super.prototype.kd.call(this);
        if (!this.ar.c && !this.cn()) {
            return;
        }
        if (this.cn()) {
            this.qu(this.oc, false);
        }
        else {
            this.qu(this.oa, false);
        }
    };
    CrosshairLayer.prototype.qt = function (a, b, c, d) {
        var e = this.op(a);
        if (!e.c) {
            return;
        }
        var f = e.d;
        f = a.nt(f, c, d);
        var g = this.m9;
        if (g == null) {
            g = this.nb;
        }
        if (g == null) {
            g = a.m9;
            if (g != null) {
                g = this.pf.cb(g);
            }
        }
        var h = g;
        var i = g;
        if (this.rm != null) {
            h = this.rm;
        }
        if (this.rn != null) {
            i = this.rn;
        }
        b.ac.add(h);
        b.af.add(i);
        b.ad.add(f.y);
        b.ae.add(f.x);
        if (this.pj && !isNaN_(f.y)) {
            AxisAnnotationFrameManager.c(b, f, a, this.b6, this.getEffectiveViewport(), g, this.ro, this.rq, this.rp, this.ru, this.ps, this.rr, this.rt, this.rs, this.rv, this.px, this.rx == 0, this.rw == 0);
        }
    };
    CrosshairLayer.prototype.qu = function (a, b) {
        var c = false;
        if (this.pm == null) {
            c = true;
            this.pn = new List$1(Axis.$, 0);
            this.pm = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.pm, this.pn, b, this.py, this.pz, this.xAxisAnnotationFormatLabel, this.yAxisAnnotationFormatLabel);
    };
    CrosshairLayer.prototype.qs = 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.eu;
        f.ai = this.nj;
        f.ad = this.nk;
        return new Tuple$2(Path.$, Number_$type, f, b);
    };
    CrosshairLayer.prototype.oz = function (a, b) {
        _super.prototype.oz.call(this, a, b);
        var c = this.pf.b5;
        var d = a;
        var e = d.ad.count;
        var f = 0;
        var g = b.bu.left;
        var h = b.bu.right;
        var i = b.bu.top;
        var j = b.bu.bottom;
        var k = this.rx == 0;
        var l = this.rw == 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.qs(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.c.add(s);
                p.ak = r;
            }
            if (l) {
                if (isNaN_(n)) {
                    continue;
                }
                var u = this.qs(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.c.add(w);
                p.ak = v;
            }
        }
        c.count = f;
        if (this.cn()) {
            this.qu(this.oc, true);
        }
        else {
            this.qu(this.oa, false);
        }
    };
    CrosshairLayer.prototype.dp = function () {
        return true;
    };
    CrosshairLayer.prototype.kp = function (a, b, c, d) {
        _super.prototype.kp.call(this, a, b, c, d);
        switch (b) {
            case CrosshairLayer.$$p[1]:
                this.k3(true);
                break;
            case CrosshairLayer.$$p[8]:
                this.k3(true);
                break;
            case CrosshairLayer.$$p[4]:
            case CrosshairLayer.$$p[5]:
                this.k3(true);
                break;
            case CrosshairLayer.$$p[2]:
            case CrosshairLayer.$$p[9]:
            case CrosshairLayer.$$p[11]:
            case CrosshairLayer.$$p[13]:
            case CrosshairLayer.$$p[15]:
            case CrosshairLayer.$$p[14]:
            case CrosshairLayer.$$p[12]:
            case CrosshairLayer.$$p[16]:
            case CrosshairLayer.$$p[17]:
            case CrosshairLayer.$$p[18]:
            case CrosshairLayer.$$p[20]:
            case CrosshairLayer.$$p[22]:
            case CrosshairLayer.$$p[24]:
            case CrosshairLayer.$$p[23]:
            case CrosshairLayer.$$p[21]:
            case CrosshairLayer.$$p[25]:
            case CrosshairLayer.$$p[26]:
            case CrosshairLayer.$$p[0]:
            case CrosshairLayer.$$p[7]:
            case CrosshairLayer.$$p[6]:
                this.k3(true);
                break;
        }
    };
    CrosshairLayer.$t = markType(CrosshairLayer, 'CrosshairLayer', AnnotationLayer.$);
    CrosshairLayer.$$p = markDep(DependencyProperty, PropertyMetadata, CrosshairLayer, 'raisePropertyChanged', ['HorizontalLineStroke:rm:qv', [Brush.$, null], 'HorizontalLineVisibility:rw:qw', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'IsAxisAnnotationEnabled:pj:qx', [0, false], 'SkipUnknownValues:pk:qy', [0, true], 'TargetSeriesName:p4:qz', [2, null], 'TargetSeries:pg:q0', [Series.$, null], 'UseInterpolation:pl:q1', [0, true], 'VerticalLineStroke:rn:q2', [Brush.$, null], 'VerticalLineVisibility:rx:q3', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'XAxisAnnotationBackground:ro:q4', [Brush.$, null], 'XAxisAnnotationInterpolatedValuePrecision:py:q5', [1, -1], 'XAxisAnnotationOutline:rp:q6', [Brush.$, null], 'XAxisAnnotationPaddingBottom:po:q7', [1, NaN], 'XAxisAnnotationPaddingLeft:pp:q8', [1, NaN], 'XAxisAnnotationPaddingRight:pq:q9', [1, NaN], 'XAxisAnnotationPaddingTop:pr:ra', [1, NaN], 'XAxisAnnotationStrokeThickness:ps:rb', [1, NaN], 'XAxisAnnotationTextColor:rq:rc', [Brush.$, null], 'YAxisAnnotationBackground:rr:rd', [Brush.$, null], 'YAxisAnnotationInterpolatedValuePrecision:pz:re', [1, -1], 'YAxisAnnotationOutline:rs:rf', [Brush.$, null], 'YAxisAnnotationPaddingBottom:pt:rg', [1, NaN], 'YAxisAnnotationPaddingLeft:pu:rh', [1, NaN], 'YAxisAnnotationPaddingRight:pv:ri', [1, NaN], 'YAxisAnnotationPaddingTop:pw:rj', [1, NaN], 'YAxisAnnotationStrokeThickness:px:rk', [1, NaN], 'YAxisAnnotationTextColor:rt:rl', [Brush.$, null]]);
    return CrosshairLayer;
}(AnnotationLayer));
export { CrosshairLayer };
/**
 * @hidden
 */
var CrosshairLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(CrosshairLayerView, _super);
    function CrosshairLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b4 = null;
        _this.b5 = null;
        _this.b6 = null;
        _this.b4 = a;
        _this.b6 = new List$1(Path.$, 0);
        return _this;
    }
    CrosshairLayerView.prototype.as = function () {
        var _this = this;
        _super.prototype.as.call(this);
        this.b5 = ((function () {
            var $ret = new Pool$1(Path.$);
            $ret.create = runOn(_this, _this.cc);
            $ret.activate = runOn(_this, _this.b7);
            $ret.disactivate = runOn(_this, _this.b9);
            $ret.destroy = runOn(_this, _this.b8);
            return $ret;
        })());
    };
    CrosshairLayerView.prototype.cc = function () {
        var a = new Path();
        a.j = new TranslateTransform();
        this.b6.add(a);
        return a;
    };
    CrosshairLayerView.prototype.b7 = function (a) {
        a._visibility = 0;
    };
    CrosshairLayerView.prototype.b9 = function (a) {
        a._visibility = 1;
    };
    CrosshairLayerView.prototype.b8 = function (a) {
        this.b6.remove(a);
    };
    CrosshairLayerView.prototype.ca = function (a, b, c, d) {
        if (a.ak == null || a.ak.c.x != d || a.ak.d.x != c) {
            var e = ((function () {
                var $ret = new LineGeometry();
                $ret.d = { $type: Point_$type, x: c, y: b };
                $ret.c = { $type: Point_$type, x: d, y: b };
                return $ret;
            })());
            a.ak = e;
        }
    };
    CrosshairLayerView.prototype.cb = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.l(a, 0.1);
    };
    CrosshairLayerView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d && !b) {
            for (var c = 0; c < this.b6.count; c++) {
                var d = this.b6._inner[c];
                if (d._visibility == 0) {
                    a.s(d);
                }
            }
        }
    };
    CrosshairLayerView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        for (var b = 0; b < this.b6.count; b++) {
            this.e.a5.exportPathData(a, this.b6._inner[b], "crosshairLine", ["Main", "Crosshair"]);
        }
    };
    CrosshairLayerView.$t = markType(CrosshairLayerView, 'CrosshairLayerView', AnnotationLayerView.$);
    return CrosshairLayerView;
}(AnnotationLayerView));
export { CrosshairLayerView };
//# sourceMappingURL=CrosshairLayer_combined.js.map
