/*
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 { 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
 */
export let AnnotationLayer = /*@__PURE__*/ (() => {
    class AnnotationLayer extends Series {
        constructor() {
            super();
            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();
        }
        cs() {
            return new AnnotationLayerView(this);
        }
        q1(a) {
            super.q1(a);
            this.xa = a;
        }
        xi(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);
        }
        get_e1() {
            return this.xf;
        }
        b2() {
            if (this.b3 == 0) {
                return 1;
            }
            else {
                return super.b2();
            }
        }
        get_fg() {
            return this.xk || this.xl;
        }
        get_isUsableInLegend() {
            return this.xl;
        }
        q9(a, b, c, d) {
            super.q9(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    let e = c;
                    let f = d;
                    if (e != null) {
                        this.yy(e.series);
                        let g = e.series;
                        g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.yv));
                        if (typeCast(XamDataChart.$, e) !== null) {
                            let h = e;
                            this.yx(h.axes);
                            let i = h.axes;
                            i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.yl));
                        }
                    }
                    if (f != null) {
                        this.yt(f.series);
                        let j = f.series;
                        j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.yv));
                        if (typeCast(XamDataChart.$, f) !== null) {
                            let k = f;
                            this.ys(k.axes);
                            let 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;
            }
        }
        yy(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.yw));
                }
            }
            this.rr(true);
        }
        yx(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.ym));
            }
            this.rr(true);
        }
        yt(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.yw));
                }
            }
            this.rr(true);
        }
        ys(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.ym));
            }
            this.rr(true);
        }
        xg(a) {
            if (a == null) {
                return false;
            }
            return true;
        }
        ym(a, b) {
            if (this.xg(a)) {
                this.yo(a, b.animate);
            }
        }
        xh(a) {
            if (a == null) {
                return false;
            }
            if (a.es) {
                return false;
            }
            return true;
        }
        yw(a, b) {
            if (this.xh(a)) {
                this.yp(a, b.animate);
            }
        }
        yo(a, b) {
        }
        yp(a, b) {
        }
        yv(a, b) {
            this.yq(b);
        }
        yl(a, b) {
            this.yn(b);
        }
        zk() {
            if (this.u9 != null) {
                return this.u9;
            }
            return this.vf;
        }
        zl() {
            if (this.vd != null) {
                return this.vd;
            }
            return this.vv;
        }
        yn(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.ym));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.ym));
                }
            }
            this.rr(true);
        }
        yq(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.yw));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.yw));
                }
            }
            this.rr(true);
        }
        sr(a, b) {
            this.rr(false);
        }
        sq(a, b) {
            this.rr(true);
        }
        rs(a) {
            super.rs(a);
            if (this.d5(this.cv)) {
                return;
            }
            if (this.gf(a) && !this.gr) {
                let 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);
            }
        }
        get_es() {
            return true;
        }
        yr(a, b) {
        }
        yu(a, b) {
            this.qx();
            this.xa.b4();
        }
        yk(a) {
            let 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);
        }
        qr(a) {
            super.qr(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);
        }
        he(a, b, c) {
            let d = super.he(a, b, c);
            if (this.db == null) {
                return false;
            }
            if (!this.cv.t()) {
                d = false;
                return d;
            }
            return d;
        }
        xv() {
            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;
        }
        xu() {
            if (isNaN_(this.xx)) {
                return this.xn;
            }
            return this.xx;
        }
        xw() {
            if (isNaN_(this.xz)) {
                return this.xn;
            }
            return this.xz;
        }
        w5() {
            switch (this.w1) {
                case 0: return this.w2();
            }
            return this.w1;
        }
        w6() {
            switch (this.w8) {
                case 0: return this.wy;
            }
            return this.w8;
        }
        w7() {
            switch (this.w9) {
                case 0: return this.wy;
            }
            return this.w9;
        }
        zq() {
            if (this.zs == null) {
                if (this.v2 == null) {
                    return this.zo();
                }
                return this.v2;
            }
            return this.zs;
        }
        zr() {
            if (this.zt == null) {
                if (this.v2 == null) {
                    return this.zp();
                }
                return this.v2;
            }
            return this.zt;
        }
        w2() {
            return 0;
        }
        w3() {
            return this.w2();
        }
        w4() {
            return this.w2();
        }
        xp() {
            return NaN;
        }
        xs() {
            return NaN;
        }
        xr() {
            return NaN;
        }
        xq() {
            return NaN;
        }
        xt() {
            return NaN;
        }
        zo() {
            return null;
        }
        zp() {
            return null;
        }
        yz() {
            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();
        }
        get_ha() {
            return this.xj;
        }
        get xj() {
            return this.xe;
        }
        set xj(a) {
            let b = this.xe;
            this.xe = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.xe);
        }
    }
    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;
})();
/**
 * @hidden
 */
export let AnnotationLayerView = /*@__PURE__*/ (() => {
    class AnnotationLayerView extends SeriesView {
        constructor(a) {
            super(a);
            this.b0 = null;
            this.b1 = false;
            this.b2 = -1;
            this.b0 = a;
        }
        b6() {
            if (this.b1) {
                this.b1 = false;
                this.b2 = -1;
                this.b0.zu = { $type: Point_$type, x: NaN, y: NaN };
                this.b0.rr(true);
            }
        }
        b3() {
            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);
            }
        }
        b5() {
            if (this.b1 == true) {
                this.b1 = false;
                if (this.b2 != -1) {
                    window.clearTimeout(this.b2);
                    this.b2 = -1;
                }
            }
        }
        b4() {
            this.as();
        }
    }
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
})();
