/*
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, __values } from "tslib";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-angular-core";
import { Point_$type, Boolean_$type, enumGetBox, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType, markDep } from "igniteui-angular-core";
import { AnnotationAppearanceMode_$type } from "./AnnotationAppearanceMode";
import { DoubleCollection } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Tuple$2 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var AnnotationLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnnotationLayer, _super);
    function AnnotationLayer() {
        var _this = _super.call(this) || this;
        _this.ta = null;
        _this.qq = null;
        _this.qp = null;
        _this.qr = null;
        _this.s8 = { $type: Point_$type, x: NaN, y: NaN };
        _this.qs = false;
        _this.ta = { $type: Point_$type, x: NaN, y: NaN };
        _this.sd();
        return _this;
    }
    AnnotationLayer.prototype.by = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.l4 = function (a) {
        _super.prototype.l4.call(this, a);
        this.qo = a;
    };
    AnnotationLayer.prototype.qw = function (a) {
        if (a == null) {
            return false;
        }
        if (a.dd) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.fd(a.b1.bu, a.b1.bv, a.b1);
    };
    AnnotationLayer.prototype.get_dm = function () {
        return this.qt;
    };
    AnnotationLayer.prototype.bq = function () {
        if (this.br == 0) {
            return 1;
        }
        else {
            return _super.prototype.bq.call(this);
        }
    };
    AnnotationLayer.prototype.get_d1 = function () {
        return this.qy || this.qz;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.qz;
    };
    AnnotationLayer.prototype.l9 = function (a, b, c, d) {
        _super.prototype.l9.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.sc(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.r9));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.sb(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.rz));
                    }
                }
                if (f != null) {
                    this.r7(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.r9));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.r6(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.rz));
                    }
                }
                break;
            case AnnotationLayer.$$p[16]:
            case AnnotationLayer.$$p[15]:
                if (this.d1) {
                    if (this.index == -1) {
                        this.index = XamDataChart.vw(this);
                    }
                }
                else {
                    this.index = -1;
                    this.o5 = null;
                    this.o8 = null;
                }
                if (this.ce != null) {
                    this.ce.m8();
                }
                this.mn(true);
                break;
            case "TransitionProgress":
                this.qr.c(this.g5, this.qq, this.qp);
                if (this.cy(this.b1)) {
                    return;
                }
                if (this.g5 == 1) {
                    this.r8(this.qp, this.b1);
                }
                else {
                    this.r8(this.qr, this.b1);
                }
                if (this.ce != null) {
                    this.ce.ob(this);
                }
                break;
            case AnnotationLayer.$$p[13]:
                if (this.ce != null) {
                    this.ce.m6();
                }
                break;
            case AnnotationLayer.$$p[9]:
                this.ta = this.s9;
                this.ly(this.s9);
                break;
            case "ShouldRenderAsOverlay":
                if (this.ce != null) {
                    this.b1.ak(this.ce);
                    this.b1.ag(this.ce);
                }
                break;
            case AnnotationLayer.$$p[8]:
            case AnnotationLayer.$$p[14]:
            case "DashArray":
            case AnnotationLayer.$$p[10]:
            case AnnotationLayer.$$p[17]:
            case AnnotationLayer.$$p[12]:
            case AnnotationLayer.$$p[19]:
            case AnnotationLayer.$$p[11]:
            case AnnotationLayer.$$p[18]:
                this.sd();
                break;
            case AnnotationLayer.$$p[0]:
            case AnnotationLayer.$$p[4]:
            case AnnotationLayer.$$p[1]:
            case AnnotationLayer.$$p[5]:
            case AnnotationLayer.$$p[3]:
            case AnnotationLayer.$$p[7]:
            case AnnotationLayer.$$p[2]:
            case AnnotationLayer.$$p[6]:
                this.mn(true);
                break;
        }
    };
    AnnotationLayer.prototype.sc = function (a) {
        var e_1, _a;
        try {
            for (var _b = __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.sa));
                }
            }
        }
        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.mn(true);
    };
    AnnotationLayer.prototype.sb = function (a) {
        var e_2, _a;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.r0));
            }
        }
        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.mn(true);
    };
    AnnotationLayer.prototype.r7 = function (a) {
        var e_3, _a;
        try {
            for (var _b = __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.sa));
                }
            }
        }
        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.mn(true);
    };
    AnnotationLayer.prototype.r6 = function (a) {
        var e_4, _a;
        try {
            for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.r0));
            }
        }
        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.mn(true);
    };
    AnnotationLayer.prototype.qu = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.r0 = function (a, b) {
        if (this.qu(a)) {
            this.r2(a, b.animate);
        }
    };
    AnnotationLayer.prototype.qv = function (a) {
        if (a == null) {
            return false;
        }
        if (a.dd) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.sa = function (a, b) {
        if (this.qv(a)) {
            this.r3(a, b.animate);
        }
    };
    AnnotationLayer.prototype.r2 = function (a, b) {
    };
    AnnotationLayer.prototype.r3 = function (a, b) {
    };
    AnnotationLayer.prototype.r9 = function (a, b) {
        this.r4(b);
    };
    AnnotationLayer.prototype.rz = function (a, b) {
        this.r1(b);
    };
    AnnotationLayer.prototype.sy = function () {
        if (this.o5 != null) {
            return this.o5;
        }
        return this.o9;
    };
    AnnotationLayer.prototype.sz = function () {
        if (this.o8 != null) {
            return this.o8;
        }
        return this.pe;
    };
    AnnotationLayer.prototype.r1 = function (a) {
        var e_5, _a, e_6, _b;
        if (a.oldItems != null) {
            try {
                for (var _c = __values(fromEn(a.oldItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var b = _d.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.r0));
                }
            }
            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 = __values(fromEn(a.newItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var c = _f.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.r0));
                }
            }
            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.mn(true);
    };
    AnnotationLayer.prototype.r4 = function (a) {
        var e_7, _a, e_8, _b;
        if (a.oldItems != null) {
            try {
                for (var _c = __values(fromEn(a.oldItems)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var b = _d.value;
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.sa));
                }
            }
            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 = __values(fromEn(a.newItems)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var c = _f.value;
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.sa));
                }
            }
            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.mn(true);
    };
    AnnotationLayer.prototype.nb = function (a, b) {
        this.mn(false);
    };
    AnnotationLayer.prototype.na = function (a, b) {
        this.mn(true);
    };
    AnnotationLayer.prototype.mo = function (a) {
        _super.prototype.mo.call(this, a);
        if (this.cy(this.b1)) {
            return;
        }
        if (this.er(a) && !this.ew) {
            var b = this.qq;
            if (this.cw()) {
                if (this.cf.g) {
                    this.cf.t();
                }
                this.qq = this.qr;
                this.qr = b;
            }
            else {
                this.qq = this.qp;
                this.qp = b;
            }
            this.r5(this.qp, this.b1);
            this.mw();
        }
        else {
            if (!this.ew) {
                this.r5(this.qp, this.b1);
            }
            this.r8(this.qp, this.b1);
        }
    };
    AnnotationLayer.prototype.get_dd = function () {
        return true;
    };
    AnnotationLayer.prototype.r5 = function (a, b) {
    };
    AnnotationLayer.prototype.r8 = function (a, b) {
        this.qo.b1();
    };
    AnnotationLayer.prototype.ry = function (a) {
        var b = { $type: Point_$type, x: this.s8.x, y: this.s8.y };
        if (a.isVertical) {
            if (isNaN_(this.s8.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.s8.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.s8.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.s8.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.ly = function (a) {
        _super.prototype.ly.call(this, a);
        if (isNaN_(this.ta.x) && isNaN_(this.ta.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.qo.b0();
                return;
            }
            else {
                this.qo.b2();
                this.s8 = a;
            }
        }
        else {
            this.qo.b2();
            this.s8 = this.ta;
        }
        this.mn(true);
    };
    AnnotationLayer.prototype.fd = function (a, b, c) {
        var d = _super.prototype.fd.call(this, a, b, c);
        if (!this.b1.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.q9 = function () {
        if (isNaN_(this.rc)) {
            switch (this.qc) {
                case 1: return this.q3();
                case 2: return this.q6();
                case 4: return this.q5();
            }
        }
        return this.rc;
    };
    AnnotationLayer.prototype.q8 = function () {
        if (isNaN_(this.rb)) {
            return this.q1;
        }
        return this.rb;
    };
    AnnotationLayer.prototype.ra = function () {
        if (isNaN_(this.rd)) {
            return this.q1;
        }
        return this.rd;
    };
    AnnotationLayer.prototype.qj = function () {
        switch (this.qf) {
            case 0: return this.qg();
        }
        return this.qf;
    };
    AnnotationLayer.prototype.qk = function () {
        switch (this.qm) {
            case 0: return this.qc;
        }
        return this.qm;
    };
    AnnotationLayer.prototype.ql = function () {
        switch (this.qn) {
            case 0: return this.qc;
        }
        return this.qn;
    };
    AnnotationLayer.prototype.s4 = function () {
        if (this.s6 == null) {
            if (this.pi == null) {
                return this.s2();
            }
            return this.pi;
        }
        return this.s6;
    };
    AnnotationLayer.prototype.s5 = function () {
        if (this.s7 == null) {
            if (this.pi == null) {
                return this.s3();
            }
            return this.pi;
        }
        return this.s7;
    };
    AnnotationLayer.prototype.qg = function () {
        return 0;
    };
    AnnotationLayer.prototype.qh = function () {
        return this.qg();
    };
    AnnotationLayer.prototype.qi = function () {
        return this.qg();
    };
    AnnotationLayer.prototype.q3 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.q6 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.q5 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.q4 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.q7 = function () {
        return NaN;
    };
    AnnotationLayer.prototype.s2 = function () {
        return null;
    };
    AnnotationLayer.prototype.s3 = function () {
        return null;
    };
    AnnotationLayer.prototype.sd = function () {
        this.qc = this.qj();
        this.q1 = this.q9();
        this.qd = this.qk();
        this.q0 = this.q8();
        this.qe = this.ql();
        this.q2 = this.ra();
        this.s0 = this.s4();
        this.s1 = this.s5();
    };
    AnnotationLayer.prototype.get_e9 = function () {
        return this.qx;
    };
    Object.defineProperty(AnnotationLayer.prototype, "qx", {
        get: function () {
            return this.qs;
        },
        set: function (a) {
            var b = this.qs;
            this.qs = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.qs);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:qc:se', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalAppearanceMode:qd:sf', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:s0:sg', [DoubleCollection.$], 'ActualHorizontalShiftAmount:q0:sh', [1, NaN], 'ActualShiftAmount:q1:si', [1, NaN], 'ActualVerticalAppearanceMode:qe:sj', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:s1:sk', [DoubleCollection.$], 'ActualVerticalShiftAmount:q2:sl', [1, NaN], 'AppearanceMode:qf:sm', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:s9:sn', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:qm:so', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:s6:sp', [DoubleCollection.$], 'HorizontalShiftAmount:rb:sq', [1, NaN], 'IsDefaultCrosshairDisabled:qt:sr', [0, true], 'ShiftAmount:rc:ss', [1, NaN], 'UseIndex:qy:st', [0, false], 'UseLegend:qz:su', [0, false], 'VerticalAppearanceMode:qn:sv', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:s7:sw', [DoubleCollection.$], 'VerticalShiftAmount:rd:sx', [1, NaN]]);
    return AnnotationLayer;
}(Series));
export { AnnotationLayer };
/**
 * @hidden
 */
var AnnotationLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(AnnotationLayerView, _super);
    function AnnotationLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.bx = null;
        _this.by = false;
        _this.bz = -1;
        _this.bx = a;
        return _this;
    }
    AnnotationLayerView.prototype.b3 = function () {
        if (this.by) {
            this.by = false;
            this.bz = -1;
            this.bx.s8 = { $type: Point_$type, x: NaN, y: NaN };
            this.bx.mn(true);
        }
    };
    AnnotationLayerView.prototype.b0 = function () {
        this.by = true;
        if (this.e.he != null) {
            this.e.he.setTimeout(runOn(this, this.b3), 300);
        }
        else {
            this.bz = window.setTimeout(runOn(this, this.b3), 300);
        }
    };
    AnnotationLayerView.prototype.b2 = function () {
        if (this.by == true) {
            this.by = false;
            if (this.bz != -1) {
                window.clearTimeout(this.bz);
                this.bz = -1;
            }
        }
    };
    AnnotationLayerView.prototype.b1 = function () {
        this.aq();
    };
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
}(SeriesView));
export { AnnotationLayerView };
