/*
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, runOn, delegateRemove, typeCast, delegateCombine, fromEnum, fromEn, markType, markDep } 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.q6 = null;
            this.p5 = null;
            this.p4 = null;
            this.p6 = null;
            this.q4 = { $type: Point_$type, x: NaN, y: NaN };
            this.p7 = false;
            this.q6 = { $type: Point_$type, x: NaN, y: NaN };
        }
        bx() {
            return new AnnotationLayerView(this);
        }
        ly(a) {
            super.ly(a);
            this.p3 = a;
        }
        qb(a) {
            if (a == null) {
                return false;
            }
            if (a.dc) {
                return false;
            }
            if (a.isValueOverlay) {
                return false;
            }
            if (a == this) {
                return false;
            }
            return a.e9(a.b0.bu, a.b0.bv, a.b0);
        }
        get_dj() {
            return this.p8;
        }
        bp() {
            if (this.bq == 0) {
                return 1;
            }
            else {
                return super.bp();
            }
        }
        get_dy() {
            return this.qd || this.qe;
        }
        get_isUsableInLegend() {
            return this.qe;
        }
        l3(a, b, c, d) {
            super.l3(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    let e = c;
                    let f = d;
                    if (e != null) {
                        this.qx(e.series);
                        let g = e.series;
                        g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.qu));
                        if (typeCast(XamDataChart.$, e) !== null) {
                            let h = e;
                            this.qw(h.axes);
                            let i = h.axes;
                            i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.qk));
                        }
                    }
                    if (f != null) {
                        this.qs(f.series);
                        let j = f.series;
                        j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.qu));
                        if (typeCast(XamDataChart.$, f) !== null) {
                            let k = f;
                            this.qr(k.axes);
                            let l = k.axes;
                            l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.qk));
                        }
                    }
                    break;
                case AnnotationLayer.$$p[3]:
                case AnnotationLayer.$$p[2]:
                    if (this.dy) {
                        if (this.index == -1) {
                            this.index = XamDataChart.u1(this);
                        }
                    }
                    else {
                        this.index = -1;
                        this.oy = null;
                        this.o1 = null;
                    }
                    if (this.cd != null) {
                        this.cd.mk();
                    }
                    this.mh(true);
                    break;
                case "TransitionProgress":
                    this.p6.c(this.g0, this.p5, this.p4);
                    if (this.cx(this.b0)) {
                        return;
                    }
                    if (this.g0 == 1) {
                        this.qt(this.p4, this.b0);
                    }
                    else {
                        this.qt(this.p6, this.b0);
                    }
                    if (this.cd != null) {
                        this.cd.nn(this);
                    }
                    break;
                case AnnotationLayer.$$p[1]:
                    if (this.cd != null) {
                        this.cd.mi();
                    }
                    break;
                case AnnotationLayer.$$p[0]:
                    this.q6 = this.q5;
                    this.ls(this.q5);
                    break;
                case "ShouldRenderAsOverlay":
                    if (this.cd != null) {
                        this.b0.ak(this.cd);
                        this.b0.ag(this.cd);
                    }
                    break;
            }
        }
        qx(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.qv));
                }
            }
            this.mh(true);
        }
        qw(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.ql));
            }
            this.mh(true);
        }
        qs(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.qv));
                }
            }
            this.mh(true);
        }
        qr(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.ql));
            }
            this.mh(true);
        }
        p9(a) {
            if (a == null) {
                return false;
            }
            return true;
        }
        ql(a, b) {
            if (this.p9(a)) {
                this.qn(a, b.animate);
            }
        }
        qa(a) {
            if (a == null) {
                return false;
            }
            if (a.dc) {
                return false;
            }
            return true;
        }
        qv(a, b) {
            if (this.qa(a)) {
                this.qo(a, b.animate);
            }
        }
        qn(a, b) {
        }
        qo(a, b) {
        }
        qu(a, b) {
            this.qp(b);
        }
        qk(a, b) {
            this.qm(b);
        }
        q2() {
            if (this.oy != null) {
                return this.oy;
            }
            return this.o2;
        }
        q3() {
            if (this.o1 != null) {
                return this.o1;
            }
            return this.o7;
        }
        qm(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.ql));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.ql));
                }
            }
            this.mh(true);
        }
        qp(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.qv));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.qv));
                }
            }
            this.mh(true);
        }
        m5(a, b) {
            this.mh(false);
        }
        m4(a, b) {
            this.mh(true);
        }
        mi(a) {
            super.mi(a);
            if (this.cx(this.b0)) {
                return;
            }
            if (this.eo(a) && !this.es) {
                let b = this.p5;
                if (this.cv()) {
                    if (this.ce.g) {
                        this.ce.t();
                    }
                    this.p5 = this.p6;
                    this.p6 = b;
                }
                else {
                    this.p5 = this.p4;
                    this.p4 = b;
                }
                this.qq(this.p4, this.b0);
                this.mq();
            }
            else {
                if (!this.es) {
                    this.qq(this.p4, this.b0);
                }
                this.qt(this.p4, this.b0);
            }
        }
        get_dc() {
            return true;
        }
        qq(a, b) {
        }
        qt(a, b) {
            this.p3.b1();
        }
        qj(a) {
            let b = { $type: Point_$type, x: this.q4.x, y: this.q4.y };
            if (a.isVertical) {
                if (isNaN_(this.q4.y)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.q4.x)) {
                    b.x = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            else {
                if (isNaN_(this.q4.x)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.q4.y)) {
                    b.y = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            return new Tuple$2(Boolean_$type, Point_$type, true, b);
        }
        ls(a) {
            super.ls(a);
            if (isNaN_(this.q6.x) && isNaN_(this.q6.y)) {
                if (isNaN_(a.x) && isNaN_(a.y)) {
                    this.p3.b0();
                    return;
                }
                else {
                    this.p3.b2();
                    this.q4 = a;
                }
            }
            else {
                this.p3.b2();
                this.q4 = this.q6;
            }
            this.mh(true);
        }
        e9(a, b, c) {
            let d = super.e9(a, b, c);
            if (!this.b0.t()) {
                d = false;
                return d;
            }
            return d;
        }
        get_e5() {
            return this.qc;
        }
        get qc() {
            return this.p7;
        }
        set qc(a) {
            let b = this.p7;
            this.p7 = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.p7);
        }
    }
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['CursorPosition:q5:qy', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'IsDefaultCrosshairDisabled:p8:qz', [0, true], 'UseIndex:qd:q0', [0, false], 'UseLegend:qe:q1', [0, false]]);
    return AnnotationLayer;
})();
/**
 * @hidden
 */
export let AnnotationLayerView = /*@__PURE__*/ (() => {
    class AnnotationLayerView extends SeriesView {
        constructor(a) {
            super(a);
            this.bx = null;
            this.by = false;
            this.bz = -1;
            this.bx = a;
        }
        b3() {
            if (this.by) {
                this.by = false;
                this.bz = -1;
                this.bx.q4 = { $type: Point_$type, x: NaN, y: NaN };
                this.bx.mh(true);
            }
        }
        b0() {
            this.by = true;
            if (this.e.g9 != null) {
                this.e.g9.setTimeout(runOn(this, this.b3), 300);
            }
            else {
                this.bz = window.setTimeout(runOn(this, this.b3), 300);
            }
        }
        b2() {
            if (this.by == true) {
                this.by = false;
                if (this.bz != -1) {
                    window.clearTimeout(this.bz);
                    this.bz = -1;
                }
            }
        }
        b1() {
            this.aq();
        }
    }
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
})();
