/*
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 { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Type, Point_$type, Boolean_$type, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType } from "igniteui-react-core/ES5/type";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Tuple$2 } from "igniteui-react-core/ES5/Tuple$2";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { isNaN_ } from "igniteui-react-core/ES5/number";
var AnnotationLayer = /** @class */ (function (_super) {
    tslib_1.__extends(AnnotationLayer, _super);
    function AnnotationLayer() {
        var _this = _super.call(this) || this;
        _this.ms = null;
        _this.lt = null;
        _this.ls = null;
        _this.lu = null;
        _this.mq = { $type: Point_$type, x: NaN, y: NaN };
        _this.lv = false;
        _this.ms = { $type: Point_$type, x: NaN, y: NaN };
        return _this;
    }
    AnnotationLayer.prototype.bf = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.il = function (a) {
        _super.prototype.il.call(this, a);
        this.lr = a;
    };
    AnnotationLayer.prototype.lx = function (a) {
        if (a == null) {
            return false;
        }
        if (a.cj) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.du(a.bi.br, a.bi.bs, a.bi);
    };
    AnnotationLayer.prototype.get_cm = function () {
        return this.lw;
    };
    AnnotationLayer.prototype.bd = function () {
        if (this.be == 0) {
            return 1;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    AnnotationLayer.prototype.get_cw = function () {
        return this.lz || this.l0;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.l0;
    };
    AnnotationLayer.prototype.ir = function (a, b, c, d) {
        _super.prototype.ir.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.mj(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.mg));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.mi(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.l6));
                    }
                }
                if (f != null) {
                    this.me(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.mg));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.md(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.l6));
                    }
                }
                break;
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[2]:
                if (this.cw) {
                    if (this.fd == -1) {
                        this.fd = XamDataChart.oa(this);
                    }
                }
                else {
                    this.fd = -1;
                    this.ku = null;
                    this.kv = null;
                }
                if (this.bs != null) {
                    this.bs.ig();
                }
                this.i4(true);
                break;
            case "TransitionProgress":
                this.lu.c(this.ev, this.lt, this.ls);
                if (this.cc(this.bi)) {
                    return;
                }
                if (this.ev == 1) {
                    this.mf(this.ls, this.bi);
                }
                else {
                    this.mf(this.lu, this.bi);
                }
                if (this.bs != null) {
                    this.bs.jh(this);
                }
                break;
            case AnnotationLayer.$$p[1]:
                if (this.bs != null) {
                    this.bs.id();
                }
                break;
            case AnnotationLayer.$$p[0]:
                this.ms = this.mr;
                this.ig(this.mr);
                break;
            case "ShouldRenderAsOverlay":
                if (this.bs != null) {
                    this.bi.ah(this.bs);
                    this.bi.ad(this.bs);
                }
                break;
        }
    };
    AnnotationLayer.prototype.mj = function (a) {
        var e_1, _a;
        try {
            for (var _b = tslib_1.__values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.mh));
                }
            }
        }
        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; }
        }
        this.i4(true);
    };
    AnnotationLayer.prototype.mi = function (a) {
        var e_2, _a;
        try {
            for (var _b = tslib_1.__values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l7));
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_2) throw e_2.error; }
        }
        this.i4(true);
    };
    AnnotationLayer.prototype.me = function (a) {
        var e_3, _a;
        try {
            for (var _b = tslib_1.__values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.mh));
                }
            }
        }
        catch (e_3_1) { e_3 = { error: e_3_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_3) throw e_3.error; }
        }
        this.i4(true);
    };
    AnnotationLayer.prototype.md = function (a) {
        var e_4, _a;
        try {
            for (var _b = tslib_1.__values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.l7));
            }
        }
        catch (e_4_1) { e_4 = { error: e_4_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_4) throw e_4.error; }
        }
        this.i4(true);
    };
    AnnotationLayer.prototype.l7 = function (a, b) {
        this.l9(a, b.animate);
    };
    AnnotationLayer.prototype.mh = function (a, b) {
        this.ma(a, b.animate);
    };
    AnnotationLayer.prototype.l9 = function (a, b) {
    };
    AnnotationLayer.prototype.ma = function (a, b) {
    };
    AnnotationLayer.prototype.mg = function (a, b) {
        this.mb(b);
    };
    AnnotationLayer.prototype.l6 = function (a, b) {
        this.l8(b);
    };
    AnnotationLayer.prototype.mo = function () {
        if (this.ku != null) {
            return this.ku;
        }
        return this.kw;
    };
    AnnotationLayer.prototype.mp = function () {
        if (this.kv != null) {
            return this.kv;
        }
        return this.kz;
    };
    AnnotationLayer.prototype.l8 = function (a) {
        var e_5, _a, e_6, _b;
        if (a.oldItems != null) {
            try {
                for (var _c = tslib_1.__values(fromEn(a.oldItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var b = _d.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.l7));
                }
            }
            catch (e_5_1) { e_5 = { error: e_5_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                }
                finally { if (e_5) throw e_5.error; }
            }
        }
        if (a.newItems != null) {
            try {
                for (var _e = tslib_1.__values(fromEn(a.newItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var c = _f.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.l7));
                }
            }
            catch (e_6_1) { e_6 = { error: e_6_1 }; }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                }
                finally { if (e_6) throw e_6.error; }
            }
        }
        this.i4(true);
    };
    AnnotationLayer.prototype.mb = function (a) {
        var e_7, _a, e_8, _b;
        if (a.oldItems != null) {
            try {
                for (var _c = tslib_1.__values(fromEn(a.oldItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var b = _d.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.mh));
                }
            }
            catch (e_7_1) { e_7 = { error: e_7_1 }; }
            finally {
                try {
                    if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
                }
                finally { if (e_7) throw e_7.error; }
            }
        }
        if (a.newItems != null) {
            try {
                for (var _e = tslib_1.__values(fromEn(a.newItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var c = _f.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.mh));
                }
            }
            catch (e_8_1) { e_8 = { error: e_8_1 }; }
            finally {
                try {
                    if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
                }
                finally { if (e_8) throw e_8.error; }
            }
        }
        this.i4(true);
    };
    AnnotationLayer.prototype.jk = function (a, b) {
        this.i4(false);
    };
    AnnotationLayer.prototype.jj = function (a, b) {
        this.i4(true);
    };
    AnnotationLayer.prototype.i5 = function (a) {
        _super.prototype.i5.call(this, a);
        if (this.cc(this.bi)) {
            return;
        }
        if (this.c8(a) && !this.dc) {
            var b = this.lt;
            if (this.ca()) {
                if (this.bt.g) {
                    this.bt.t();
                }
                this.lt = this.lu;
                this.lu = b;
            }
            else {
                this.lt = this.ls;
                this.ls = b;
            }
            this.mc(this.ls, this.bi);
            this.jc();
        }
        else {
            if (!this.dc) {
                this.mc(this.ls, this.bi);
            }
            this.mf(this.ls, this.bi);
        }
    };
    AnnotationLayer.prototype.get_cj = function () {
        return true;
    };
    AnnotationLayer.prototype.mc = function (a, b) {
    };
    AnnotationLayer.prototype.mf = function (a, b) {
        this.lr.by();
    };
    AnnotationLayer.prototype.l5 = function (a) {
        var b = { $type: Point_$type, x: this.mq.x, y: this.mq.y };
        if (a.isVertical) {
            if (isNaN_(this.mq.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mq.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.mq.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.mq.y)) {
                b.y = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        return new Tuple$2(Boolean_$type, Point_$type, true, b);
    };
    AnnotationLayer.prototype.ig = function (a) {
        _super.prototype.ig.call(this, a);
        if (isNaN_(this.ms.x) && isNaN_(this.ms.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.lr.bx();
                return;
            }
            else {
                this.lr.bz();
                this.mq = a;
            }
        }
        else {
            this.lr.bz();
            this.mq = this.ms;
        }
        this.i4(true);
    };
    AnnotationLayer.prototype.du = function (a, b, c) {
        var d = _super.prototype.du.call(this, a, b, c);
        if (!this.bi.q()) {
            return d = false;
        }
        return d;
    };
    AnnotationLayer.prototype.get_dq = function () {
        return this.ly;
    };
    Object.defineProperty(AnnotationLayer.prototype, "ly", {
        get: function () {
            return this.lv;
        },
        set: function (a) {
            var b = this.lv;
            this.lv = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.lv);
        },
        enumerable: true,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    return AnnotationLayer;
}(Series));
export { AnnotationLayer };
Type.dep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:mr:mk', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:lw:ml', [0, true], 'UseIndex:lz:mm', [0, false], 'UseLegend:l0:mn', [0, false]]);
var AnnotationLayerView = /** @class */ (function (_super) {
    tslib_1.__extends(AnnotationLayerView, _super);
    function AnnotationLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.bu = null;
        _this.bv = false;
        _this.bw = -1;
        _this.bu = a;
        return _this;
    }
    AnnotationLayerView.prototype.b0 = function () {
        if (this.bv) {
            this.bv = false;
            this.bw = -1;
            this.bu.mq = { $type: Point_$type, x: NaN, y: NaN };
            this.bu.i4(true);
        }
    };
    AnnotationLayerView.prototype.bx = function () {
        this.bv = true;
        if (this.e.e0 != null) {
            this.e.e0.setTimeout(runOn(this, this.b0), 300);
        }
        else {
            this.bw = window.setTimeout(runOn(this, this.b0), 300);
        }
    };
    AnnotationLayerView.prototype.bz = function () {
        if (this.bv == true) {
            this.bv = false;
            if (this.bw != -1) {
                window.clearTimeout(this.bw);
                this.bw = -1;
            }
        }
    };
    AnnotationLayerView.prototype.by = function () {
        this.an();
    };
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
}(SeriesView));
export { AnnotationLayerView };
