/*
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 { PenLineCap_$type } from "igniteui-angular-core";
import { SeriesView } from "./SeriesView";
import { XamDataChart } from "./XamDataChart";
import { Brush } from "igniteui-angular-core";
import { Tuple$2 } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, truncate } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { Color } from "igniteui-angular-core";
/**
 * @hidden
 */
export let AnnotationLayer = /*@__PURE__*/ (() => {
    class AnnotationLayer extends Series {
        constructor() {
            super();
            this.aae = null;
            this.xm = null;
            this.xl = null;
            this.xn = null;
            this.aac = { $type: Point_$type, x: NaN, y: NaN };
            this.xo = false;
            this.aae = { $type: Point_$type, x: NaN, y: NaN };
            this.zb();
        }
        ct() {
            return new AnnotationLayerView(this);
        }
        q7(a) {
            super.q7(a);
            this.xk = a;
        }
        xs(a) {
            if (a == null) {
                return false;
            }
            if (a.eu) {
                return false;
            }
            if (a.isValueOverlay) {
                return false;
            }
            if (a == this) {
                return false;
            }
            return a.hf(a.cw.b9, a.cw.ca, a.cw);
        }
        get_e3() {
            return this.xp;
        }
        b3() {
            if (this.b4 == 0) {
                return 1;
            }
            else {
                return super.b3();
            }
        }
        get_fh() {
            return this.xu || this.xv;
        }
        get_isUsableInLegend() {
            return this.xv;
        }
        rg(a, b, c, d) {
            super.rg(a, b, c, d);
            switch (b) {
                case "SeriesViewer":
                    let e = c;
                    let f = d;
                    if (e != null) {
                        this.za(e.series);
                        let g = e.series;
                        g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.y7));
                        if (typeCast(XamDataChart.$, e) !== null) {
                            let h = e;
                            this.y9(h.axes);
                            let i = h.axes;
                            i.collectionChanged = delegateRemove(i.collectionChanged, runOn(this, this.yx));
                        }
                    }
                    if (f != null) {
                        this.y5(f.series);
                        let j = f.series;
                        j.collectionChanged = delegateCombine(j.collectionChanged, runOn(this, this.y7));
                        if (typeCast(XamDataChart.$, f) !== null) {
                            let k = f;
                            this.y4(k.axes);
                            let l = k.axes;
                            l.collectionChanged = delegateCombine(l.collectionChanged, runOn(this, this.yx));
                        }
                    }
                    break;
                case AnnotationLayer.$$p[18]:
                case AnnotationLayer.$$p[17]:
                    if (this.fh) {
                        if (this.index == -1) {
                            this.index = XamDataChart.aad(this);
                        }
                    }
                    else {
                        this.index = -1;
                        this.vj = null;
                        this.vn = null;
                    }
                    if (this.dc != null) {
                        this.dc.qd();
                    }
                    this.ry(true);
                    break;
                case "TransitionProgress":
                    this.xn.c(this.ju, this.xm, this.xl);
                    if (this.d7(this.cw)) {
                        return;
                    }
                    if (this.ju == 1) {
                        this.y6(this.xl, this.cw);
                        this.qu();
                    }
                    else {
                        this.y6(this.xn, this.cw);
                    }
                    if (this.dc != null) {
                        this.dc.rz(this);
                    }
                    break;
                case AnnotationLayer.$$p[15]:
                    if (this.dc != null) {
                        this.dc.p7();
                    }
                    break;
                case AnnotationLayer.$$p[11]:
                    this.aae = this.aad;
                    this.qx(this.aad);
                    break;
                case "ShouldRenderAsOverlay":
                    if (this.dc != null) {
                        this.cw.at(this.dc);
                        this.cw.ao(this.dc);
                    }
                    break;
                case AnnotationLayer.$$p[10]:
                case AnnotationLayer.$$p[16]:
                case "DashArray":
                case AnnotationLayer.$$p[12]:
                case AnnotationLayer.$$p[19]:
                case AnnotationLayer.$$p[14]:
                case AnnotationLayer.$$p[21]:
                case AnnotationLayer.$$p[13]:
                case AnnotationLayer.$$p[20]:
                    this.zb();
                    break;
                case AnnotationLayer.$$p[0]:
                case AnnotationLayer.$$p[6]:
                case AnnotationLayer.$$p[3]:
                case AnnotationLayer.$$p[7]:
                case AnnotationLayer.$$p[5]:
                case AnnotationLayer.$$p[9]:
                case AnnotationLayer.$$p[4]:
                case AnnotationLayer.$$p[8]:
                    this.ry(true);
                    break;
            }
        }
        za(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.y8));
                }
            }
            this.ry(true);
        }
        y9(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.yy));
            }
            this.ry(true);
        }
        y5(a) {
            for (let b of fromEnum(a)) {
                if (!(b == this)) {
                    b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.y8));
                }
            }
            this.ry(true);
        }
        y4(a) {
            for (let b of fromEnum(a)) {
                b.renderRequested = delegateCombine(b.renderRequested, runOn(this, this.yy));
            }
            this.ry(true);
        }
        xq(a) {
            if (a == null) {
                return false;
            }
            return true;
        }
        yy(a, b) {
            if (this.xq(a)) {
                this.y0(a, b.animate);
            }
        }
        xr(a) {
            if (a == null) {
                return false;
            }
            if (a.eu) {
                return false;
            }
            return true;
        }
        y8(a, b) {
            if (this.xr(a)) {
                this.y1(a, b.animate);
            }
        }
        y0(a, b) {
        }
        y1(a, b) {
        }
        y7(a, b) {
            this.y2(b);
        }
        yx(a, b) {
            this.yz(b);
        }
        zy() {
            if (this.vj != null) {
                return this.vj;
            }
            return this.vp;
        }
        zz() {
            if (this.vn != null) {
                return this.vn;
            }
            return this.v5;
        }
        yz(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.yy));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.yy));
                }
            }
            this.ry(true);
        }
        y2(a) {
            if (a.oldItems != null) {
                for (let b of fromEn(a.oldItems)) {
                    b.renderRequested = delegateRemove(b.renderRequested, runOn(this, this.y8));
                }
            }
            if (a.newItems != null) {
                for (let c of fromEn(a.newItems)) {
                    c.renderRequested = delegateCombine(c.renderRequested, runOn(this, this.y8));
                }
            }
            this.ry(true);
        }
        sz(a, b) {
            this.ry(false);
        }
        sy(a, b) {
            this.ry(true);
        }
        rz(a) {
            super.rz(a);
            if (this.d7(this.cw)) {
                return;
            }
            if (this.gg(a) && !this.gs) {
                let b = this.xm;
                if (this.d4()) {
                    if (this.dd.g) {
                        this.dd.t();
                    }
                    this.xm = this.xn;
                    this.xn = b;
                }
                else {
                    this.xm = this.xl;
                    this.xl = b;
                }
                this.y3(this.xl, this.cw);
                this.sf();
            }
            else {
                if (!this.gs) {
                    this.y3(this.xl, this.cw);
                }
                this.y6(this.xl, this.cw);
            }
        }
        get_eu() {
            return true;
        }
        y3(a, b) {
        }
        y6(a, b) {
            this.q3();
            this.xk.ch();
        }
        yw(a) {
            let b = { $type: Point_$type, x: this.aac.x, y: this.aac.y };
            if (a.isVertical) {
                if (isNaN_(this.aac.y)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.aac.x)) {
                    b.x = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            else {
                if (isNaN_(this.aac.x)) {
                    return new Tuple$2(Boolean_$type, Point_$type, false, b);
                }
                if (isNaN_(this.aac.y)) {
                    b.y = 0;
                    return new Tuple$2(Boolean_$type, Point_$type, true, b);
                }
            }
            return new Tuple$2(Boolean_$type, Point_$type, true, b);
        }
        qx(a) {
            super.qx(a);
            if (isNaN_(this.aae.x) && isNaN_(this.aae.y)) {
                if (isNaN_(a.x) && isNaN_(a.y)) {
                    this.xk.cg();
                    return;
                }
                else {
                    this.xk.ci();
                    this.aac = a;
                }
            }
            else {
                this.xk.ci();
                this.aac = this.aae;
            }
            this.ry(true);
        }
        hf(a, b, c) {
            let d = super.hf(a, b, c);
            if (this.dc == null) {
                return false;
            }
            if (!this.cw.w()) {
                d = false;
                return d;
            }
            return d;
        }
        x5() {
            if (isNaN_(this.x8)) {
                switch (this.w8) {
                    case 1: return this.xz();
                    case 2: return this.x2();
                    case 4: return this.x1();
                }
            }
            return this.x8;
        }
        x4() {
            if (isNaN_(this.x7)) {
                return this.xx;
            }
            return this.x7;
        }
        x6() {
            if (isNaN_(this.x9)) {
                return this.xx;
            }
            return this.x9;
        }
        xf() {
            switch (this.xb) {
                case 0: return this.xc();
            }
            return this.xb;
        }
        xg() {
            switch (this.xi) {
                case 0: return this.w8;
            }
            return this.xi;
        }
        xh() {
            switch (this.xj) {
                case 0: return this.w8;
            }
            return this.xj;
        }
        z7() {
            if (this.z9 == null) {
                if (this.wc == null) {
                    return this.z4();
                }
                return this.wc;
            }
            return this.z9;
        }
        z8() {
            if (this.aaa == null) {
                if (this.wc == null) {
                    return this.z5();
                }
                return this.wc;
            }
            return this.aaa;
        }
        z6() {
            if (this.wc == null) {
                return this.z3();
            }
            return this.wc;
        }
        xc() {
            return 0;
        }
        xd() {
            return this.xc();
        }
        xe() {
            return this.xc();
        }
        xz() {
            return NaN;
        }
        x2() {
            return NaN;
        }
        x1() {
            return NaN;
        }
        x0() {
            return NaN;
        }
        x3() {
            return NaN;
        }
        z4() {
            return null;
        }
        z5() {
            return null;
        }
        z3() {
            return null;
        }
        zb() {
            this.w8 = this.xf();
            this.xx = this.x5();
            this.w9 = this.xg();
            this.xw = this.x4();
            this.xa = this.xh();
            this.xy = this.x6();
            this.z1 = this.z7();
            this.z2 = this.z8();
            this.z0 = this.z6();
        }
        get_hb() {
            return this.xt;
        }
        get xt() {
            return this.xo;
        }
        set xt(a) {
            let b = this.xo;
            this.xo = a;
            this.raisePropertyChanged("ShouldRenderAsOverlay", b, this.xo);
        }
    }
    AnnotationLayer.$t = markType(AnnotationLayer, 'AnnotationLayer', Series.$);
    AnnotationLayer.$$p = markDep(DependencyProperty, PropertyMetadata, AnnotationLayer, 'raisePropertyChanged', ['ActualAppearanceMode:w8:zc', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualDashArray:z0:zd', [DoubleCollection.$], 'ActualDashCap:aab:ze', [PenLineCap_$type], 'ActualHorizontalAppearanceMode:w9:zf', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualHorizontalDashArray:z1:zg', [DoubleCollection.$], 'ActualHorizontalShiftAmount:xw:zh', [1, NaN], 'ActualShiftAmount:xx:zi', [1, NaN], 'ActualVerticalAppearanceMode:xa:zj', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'ActualVerticalDashArray:z2:zk', [DoubleCollection.$], 'ActualVerticalShiftAmount:xy:zl', [1, NaN], 'AppearanceMode:xb:zm', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'CursorPosition:aad:zn', [Point_$type, { $type: Point_$type, x: NaN, y: NaN }], 'HorizontalAppearanceMode:xi:zo', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'HorizontalDashArray:z9:zp', [DoubleCollection.$], 'HorizontalShiftAmount:x7:zq', [1, NaN], 'IsDefaultCrosshairDisabled:xp:zr', [0, true], 'ShiftAmount:x8:zs', [1, NaN], 'UseIndex:xu:zt', [0, false], 'UseLegend:xv:zu', [0, false], 'VerticalAppearanceMode:xj:zv', [AnnotationAppearanceMode_$type, enumGetBox(AnnotationAppearanceMode_$type, 0)], 'VerticalDashArray:aaa:zw', [DoubleCollection.$], 'VerticalShiftAmount:x9:zx', [1, NaN]]);
    return AnnotationLayer;
})();
/**
 * @hidden
 */
export let AnnotationLayerView = /*@__PURE__*/ (() => {
    class AnnotationLayerView extends SeriesView {
        constructor(a) {
            super(a);
            this.cd = null;
            this.ce = false;
            this.cf = -1;
            this.cd = a;
        }
        cj() {
            if (this.ce) {
                this.ce = false;
                this.cf = -1;
                this.cd.aac = { $type: Point_$type, x: NaN, y: NaN };
                this.cd.ry(true);
            }
        }
        cg() {
            this.ce = true;
            if (this.f.j3 != null) {
                this.f.j3.setTimeout(runOn(this, this.cj), 300);
            }
            else {
                this.cf = window.setTimeout(runOn(this, this.cj), 300);
            }
        }
        ci() {
            if (this.ce == true) {
                this.ce = false;
                if (this.cf != -1) {
                    window.clearTimeout(this.cf);
                    this.cf = -1;
                }
            }
        }
        ch() {
            this.a2();
        }
        ck(a, b) {
            if (a == null) {
                return a;
            }
            return BrushUtil.o(a, b);
        }
        cm(a, b) {
            if (a == null) {
                return a;
            }
            return BrushUtil.q(a, b);
        }
        cl(a, b) {
            if (a == null) {
                return a;
            }
            let c = new Brush();
            c.color = Color.u(truncate((a.color.l * b)), a.color.o, a.color.n, a.color.m);
            return c;
        }
    }
    AnnotationLayerView.$t = markType(AnnotationLayerView, 'AnnotationLayerView', SeriesView.$);
    return AnnotationLayerView;
})();
