/*
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.zw = null;
        _this.xc = null;
        _this.xb = null;
        _this.xd = null;
        _this.zu = { $type: Point_$type, x: NaN, y: NaN };
        _this.xe = false;
        _this.zw = { $type: Point_$type, x: NaN, y: NaN };
        _this.yz();
        return _this;
    }
    AnnotationLayer.prototype.cs = function () {
        return new AnnotationLayerView(this);
    };
    AnnotationLayer.prototype.q1 = function (a) {
        _super.prototype.q1.call(this, a);
        this.xa = a;
    };
    AnnotationLayer.prototype.xi = function (a) {
        if (a == null) {
            return false;
        }
        if (a.es) {
            return false;
        }
        if (a.isValueOverlay) {
            return false;
        }
        if (a == this) {
            return false;
        }
        return a.he(a.cv.bx, a.cv.by, a.cv);
    };
    AnnotationLayer.prototype.get_e1 = function () {
        return this.xf;
    };
    AnnotationLayer.prototype.b2 = function () {
        if (this.b3 == 0) {
            return 1;
        }
        else {
            return _super.prototype.b2.call(this);
        }
    };
    AnnotationLayer.prototype.get_fg = function () {
        return this.xk || this.xl;
    };
    AnnotationLayer.prototype.get_isUsableInLegend = function () {
        return this.xl;
    };
    AnnotationLayer.prototype.q9 = function (a, b, c, d) {
        _super.prototype.q9.call(this, a, b, c, d);
        switch (b) {
            case "SeriesViewer":
                var e = c;
                var f = d;
                if (e != null) {
                    this.yy(e.series);
                    var g = e.series;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.yv));
                    if (typeCast(XamDataChart.$, e) !== null) {
                        var h = e;
                        this.yx(h.axes);
                        var i = h.axes;
                        i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.yl));
                    }
                }
                if (f != null) {
                    this.yt(f.series);
                    var j = f.series;
                    j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.yv));
                    if (typeCast(XamDataChart.$, f) !== null) {
                        var k = f;
                        this.ys(k.axes);
                        var l = k.axes;
                        l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.yl));
                    }
                }
                break;
            case AnnotationLayer.$$p[16]:
            case AnnotationLayer.$$p[15]:
                if (this.fg) {
                    if (this.index == -1) {
                        this.index = XamDataChart.yr(this);
                    }
                }
                else {
                    this.index = -1;
                    this.u9 = null;
                    this.vd = null;
                }
                if (this.db != null) {
                    this.db.pe();
                }
                this.rr(true);
                break;
            case "TransitionProgress":
                this.xd.c(this.jq, this.xc, this.xb);
                if (this.d5(this.cv)) {
                    return;
                }
                if (this.jq == 1) {
                    this.yu(this.xb, this.cv);
                    this.qo();
                }
                else {
                    this.yu(this.xd, this.cv);
                }
                if (this.db != null) {
                    this.db.qo(this);
                }
                break;
            case AnnotationLayer.$$p[13]:
                if (this.db != null) {
                    this.db.o8();
                }
                break;
            case AnnotationLayer.$$p[9]:
                this.zw = this.zv;
                this.qr(this.zv);
                break;
            case "ShouldRenderAsOverlay":
                if (this.db != null) {
                    this.cv.al(this.db);
                    this.cv.ag(this.db);
                }
                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.yz();
                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.rr(true);
                break;
        }
    };
    AnnotationLayer.prototype.yy = 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.yw));
                }
            }
        }
        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.rr(true);
    };
    AnnotationLayer.prototype.yx = 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.ym));
            }
        }
        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.rr(true);
    };
    AnnotationLayer.prototype.yt = 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.yw));
                }
            }
        }
        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.rr(true);
    };
    AnnotationLayer.prototype.ys = 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.ym));
            }
        }
        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.rr(true);
    };
    AnnotationLayer.prototype.xg = function (a) {
        if (a == null) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.ym = function (a, b) {
        if (this.xg(a)) {
            this.yo(a, b.animate);
        }
    };
    AnnotationLayer.prototype.xh = function (a) {
        if (a == null) {
            return false;
        }
        if (a.es) {
            return false;
        }
        return true;
    };
    AnnotationLayer.prototype.yw = function (a, b) {
        if (this.xh(a)) {
            this.yp(a, b.animate);
        }
    };
    AnnotationLayer.prototype.yo = function (a, b) {
    };
    AnnotationLayer.prototype.yp = function (a, b) {
    };
    AnnotationLayer.prototype.yv = function (a, b) {
        this.yq(b);
    };
    AnnotationLayer.prototype.yl = function (a, b) {
        this.yn(b);
    };
    AnnotationLayer.prototype.zk = function () {
        if (this.u9 != null) {
            return this.u9;
        }
        return this.vf;
    };
    AnnotationLayer.prototype.zl = function () {
        if (this.vd != null) {
            return this.vd;
        }
        return this.vv;
    };
    AnnotationLayer.prototype.yn = 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.ym));
                }
            }
            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.ym));
                }
            }
            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.rr(true);
    };
    AnnotationLayer.prototype.yq = 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.yw));
                }
            }
            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.yw));
                }
            }
            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.rr(true);
    };
    AnnotationLayer.prototype.sr = function (a, b) {
        this.rr(false);
    };
    AnnotationLayer.prototype.sq = function (a, b) {
        this.rr(true);
    };
    AnnotationLayer.prototype.rs = function (a) {
        _super.prototype.rs.call(this, a);
        if (this.d5(this.cv)) {
            return;
        }
        if (this.gf(a) && !this.gr) {
            var b = this.xc;
            if (this.d3()) {
                if (this.dc.g) {
                    this.dc.t();
                }
                this.xc = this.xd;
                this.xd = b;
            }
            else {
                this.xc = this.xb;
                this.xb = b;
            }
            this.yr(this.xb, this.cv);
            this.r7();
        }
        else {
            if (!this.gr) {
                this.yr(this.xb, this.cv);
            }
            this.yu(this.xb, this.cv);
        }
    };
    AnnotationLayer.prototype.get_es = function () {
        return true;
    };
    AnnotationLayer.prototype.yr = function (a, b) {
    };
    AnnotationLayer.prototype.yu = function (a, b) {
        this.qx();
        this.xa.b4();
    };
    AnnotationLayer.prototype.yk = function (a) {
        var b = { $type: Point_$type, x: this.zu.x, y: this.zu.y };
        if (a.isVertical) {
            if (isNaN_(this.zu.y)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.zu.x)) {
                b.x = 0;
                return new Tuple$2(Boolean_$type, Point_$type, true, b);
            }
        }
        else {
            if (isNaN_(this.zu.x)) {
                return new Tuple$2(Boolean_$type, Point_$type, false, b);
            }
            if (isNaN_(this.zu.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.qr = function (a) {
        _super.prototype.qr.call(this, a);
        if (isNaN_(this.zw.x) && isNaN_(this.zw.y)) {
            if (isNaN_(a.x) && isNaN_(a.y)) {
                this.xa.b3();
                return;
            }
            else {
                this.xa.b5();
                this.zu = a;
            }
        }
        else {
            this.xa.b5();
            this.zu = this.zw;
        }
        this.rr(true);
    };
    AnnotationLayer.prototype.he = function (a, b, c) {
        var d = _super.prototype.he.call(this, a, b, c);
        if (this.db == null) {
            return false;
        }
        if (!this.cv.t()) {
            d = false;
            return d;
        }
        return d;
    };
    AnnotationLayer.prototype.xv = function () {
        if (isNaN_(this.xy)) {
            switch (this.wy) {
                case 1: return this.xp();
                case 2: return this.xs();
                case 4: return this.xr();
            }
        }
        return this.xy;
    };
    AnnotationLayer.prototype.xu = function () {
        if (isNaN_(this.xx)) {
            return this.xn;
        }
        return this.xx;
    };
    AnnotationLayer.prototype.xw = function () {
        if (isNaN_(this.xz)) {
            return this.xn;
        }
        return this.xz;
    };
    AnnotationLayer.prototype.w5 = function () {
        switch (this.w1) {
            case 0: return this.w2();
        }
        return this.w1;
    };
    AnnotationLayer.prototype.w6 = function () {
        switch (this.w8) {
            case 0: return this.wy;
        }
        return this.w8;
    };
    AnnotationLayer.prototype.w7 = function () {
        switch (this.w9) {
            case 0: return this.wy;
        }
        return this.w9;
    };
    AnnotationLayer.prototype.zq = function () {
        if (this.zs == null) {
            if (this.v2 == null) {
                return this.zo();
            }
            return this.v2;
        }
        return this.zs;
    };
    AnnotationLayer.prototype.zr = function () {
        if (this.zt == null) {
            if (this.v2 == null) {
                return this.zp();
            }
            return this.v2;
        }
        return this.zt;
    };
    AnnotationLayer.prototype.w2 = function () {
        return 0;
    };
    AnnotationLayer.prototype.w3 = function () {
        return this.w2();
    };
    AnnotationLayer.prototype.w4 = function () {
        return this.w2();
    };
    AnnotationLayer.prototype.xp = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xs = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xr = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xq = function () {
        return NaN;
    };
    AnnotationLayer.prototype.xt = function () {
        return NaN;
    };
    AnnotationLayer.prototype.zo = function () {
        return null;
    };
    AnnotationLayer.prototype.zp = function () {
        return null;
    };
    AnnotationLayer.prototype.yz = function () {
        this.wy = this.w5();
        this.xn = this.xv();
        this.wz = this.w6();
        this.xm = this.xu();
        this.w0 = this.w7();
        this.xo = this.xw();
        this.zm = this.zq();
        this.zn = this.zr();
    };
    AnnotationLayer.prototype.get_ha = function () {
        return this.xj;
    };
    Object.defineProperty(AnnotationLayer.prototype, "xj", {
        get: function () {
            return this.xe;
        },
        set: function (a) {
            var b = this.xe;
            this.xe = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.xe);
        },
        enumerable: false,
        configurable: true
    });
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:wy:y0', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalAppearanceMode:wz:y1', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:zm:y2', [DoubleCollection.$], 'ActualHorizontalShiftAmount:xm:y3', [1, NaN], 'ActualShiftAmount:xn:y4', [1, NaN], 'ActualVerticalAppearanceMode:w0:y5', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:zn:y6', [DoubleCollection.$], 'ActualVerticalShiftAmount:xo:y7', [1, NaN], 'AppearanceMode:w1:y8', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:zv:y9', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:w8:za', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:zs:zb', [DoubleCollection.$], 'HorizontalShiftAmount:xx:zc', [1, NaN], 'IsDefaultCrosshairDisabled:xf:zd', [0, true], 'ShiftAmount:xy:ze', [1, NaN], 'UseIndex:xk:zf', [0, false], 'UseLegend:xl:zg', [0, false], 'VerticalAppearanceMode:w9:zh', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:zt:zi', [DoubleCollection.$], 'VerticalShiftAmount:xz:zj', [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.b0 = null;
        _this.b1 = false;
        _this.b2 = -1;
        _this.b0 = a;
        return _this;
    }
    AnnotationLayerView.prototype.b6 = function () {
        if (this.b1) {
            this.b1 = false;
            this.b2 = -1;
            this.b0.zu = { $type: Point_$type, x: NaN, y: NaN };
            this.b0.rr(true);
        }
    };
    AnnotationLayerView.prototype.b3 = function () {
        this.b1 = true;
        if (this.e.jz != null) {
            this.e.jz.setTimeout(runOn(this, this.b6), 300);
        }
        else {
            this.b2 = window.setTimeout(runOn(this, this.b6), 300);
        }
    };
    AnnotationLayerView.prototype.b5 = function () {
        if (this.b1 == true) {
            this.b1 = false;
            if (this.b2 != -1) {
                window.clearTimeout(this.b2);
                this.b2 = -1;
            }
        }
    };
    AnnotationLayerView.prototype.b4 = function () {
        this.as();
    };
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
}(SeriesView));
export { AnnotationLayerView };
