/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { DependencyProperty } from "igniteui-angular-core";
import { Series } from "./Series";
import { FinalValueSelectionMode_$type } from "./FinalValueSelectionMode";
import { Brush } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { FinalValueLayerFrame } from "./FinalValueLayerFrame";
import { List$1 } from "igniteui-angular-core";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { Base, enumGetBox, fromEnum, Point_$type, markType, markDep } from "igniteui-angular-core";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-angular-core";
/**
 * @hidden
 */
export let FinalValueLayer = /*@__PURE__*/ (() => {
    class FinalValueLayer extends AnnotationLayer {
        constructor() {
            super();
            this.axisAnnotationFormatLabel = null;
            this.z1 = null;
            this.z0 = null;
            let a = new FinalValueLayerFrame();
            let b = new FinalValueLayerFrame();
            let c = new FinalValueLayerFrame();
            let d = this.kd / 1000;
            this.xa = a;
            this.w9 = b;
            this.xb = c;
            this.ab = FinalValueLayer.$;
        }
        bj() {
            return new FinalValueLayer();
        }
        get_eq() {
            return true;
        }
        cs() {
            return new FinalValueLayerView(this);
        }
        qz(a) {
            super.qz(a);
            this.zw = a;
        }
        get aa6() {
            return new Thickness(1, this.z4, this.z6, this.z5, this.z3);
        }
        zz() {
            return this.axisAnnotationFormatLabel != null;
        }
        yn(a, b) {
            if (this.zy == null || this.zy == a) {
                if (!this.a1.c) {
                    this.rp(b);
                }
            }
        }
        yp(a, b) {
            super.yp(a, b);
            let c = a;
            c.f.clear();
            c.r.clear();
            c.q.clear();
            c.ac.clear();
            c.p.clear();
            c.ab.clear();
            c.h.clear();
            c.g.clear();
            c.i.clear();
            c.k.clear();
            c.m.clear();
            c.l.clear();
            c.j.clear();
            c.n.clear();
            c.o.clear();
            c.t.clear();
            c.s.clear();
            c.u.clear();
            c.w.clear();
            c.y.clear();
            c.x.clear();
            c.v.clear();
            c.z.clear();
            c.aa.clear();
            if (this.xg(this.zy)) {
                this.aan(this.zy, c);
            }
            else {
                for (let d of fromEnum(this.db.series)) {
                    if (this.xg(d)) {
                        this.aan(d, c);
                    }
                    if (d.isStacked) {
                        d.p1((e) => {
                            if (this.xg(e)) {
                                this.aan(e, c);
                            }
                            if (e.eg) {
                                e.pz((f) => {
                                    if (this.xg(f)) {
                                        this.aan(f, c);
                                    }
                                    return true;
                                });
                            }
                            return true;
                        });
                    }
                    if (d.eg) {
                        d.pz((e) => {
                            if (this.xg(e)) {
                                this.aan(e, c);
                            }
                            return true;
                        });
                    }
                }
            }
        }
        xg(a) {
            if (!super.xg(a)) {
                return false;
            }
            if (this.aak != null) {
                if (a.fb) {
                    let b = a.nc();
                    if (!Base.equalsStatic(this.aak, b)) {
                        return false;
                    }
                }
                else {
                    if (!Base.equalsStatic(this.aak, a.name)) {
                        return false;
                    }
                }
            }
            return true;
        }
        qn() {
            super.qn();
            if (!this.a1.c && !this.d3()) {
                return;
            }
            if (this.d3()) {
                this.aao(this.xb, false);
            }
            else {
                this.aao(this.w9, false);
            }
        }
        aa5(a) {
            let b = NaN;
            let c = NaN;
            let d = this.zx;
            if (d == 0) {
                d = 1;
            }
            let e = false;
            if (d == 2) {
                e = true;
            }
            if (a.isVertical) {
                let f = a.a0();
                if (f != null) {
                    if (d == 1 || d == 2) {
                        let g = this.wh(this.cv);
                        if (f.ch) {
                            c = a.wf({ $type: Point_$type, x: g.right, y: g.bottom }).y;
                        }
                        else {
                            c = a.wf({ $type: Point_$type, x: g.right, y: g.top }).y;
                        }
                    }
                    else {
                        if (f.ch) {
                            c = 1;
                        }
                        else {
                            c = 0;
                        }
                    }
                }
                return a.wa({ $type: Point_$type, x: 0, y: c }, e, true);
            }
            else {
                let h = a.a0();
                if (h != null) {
                    if (d == 1 || d == 2) {
                        let i = this.wh(this.cv);
                        if (h.ch) {
                            b = a.wf({ $type: Point_$type, x: i.left, y: i.top }).x;
                        }
                        else {
                            b = a.wf({ $type: Point_$type, x: i.right, y: i.top }).x;
                        }
                    }
                    else {
                        if (h.ch) {
                            b = 0;
                        }
                        else {
                            b = 1;
                        }
                    }
                }
                if (a.e6) {
                    return a.wa({ $type: Point_$type, x: b, y: 0 }, e, true);
                }
                else {
                    return a.wa({ $type: Point_$type, x: b, y: 0 }, e, true);
                }
            }
        }
        aan(a, b) {
            let c = this.aa5(a);
            let d = this.wf(c);
            let e = this.u7;
            if (e == null) {
                e = this.vd;
            }
            if (e == null) {
                e = a.u7;
                if (e != null) {
                    e = this.zw.b8(e);
                }
            }
            AxisAnnotationFrameManager.c(b, c, a, this.db, this.getEffectiveViewport(), e, this.aa2, this.z2, this.aa4, this.aa3, this.aa6, this.z7, this.aa2, this.z2, this.aa4, this.aa3, this.aa6, this.z7, this._visibility == 0 && a.isVertical, this._visibility == 0 && !a.isVertical);
        }
        aao(a, b) {
            let c = false;
            if (this.z0 == null) {
                c = true;
                this.z1 = new List$1(Axis.$, 0);
                this.z0 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            AxisAnnotationFrameManager.d(this, a, c, this.z0, this.z1, b, this.z8, this.z8, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
        }
        ys(a, b) {
            super.ys(a, b);
            if (this.d3()) {
                this.aao(this.xb, true);
            }
            else {
                this.aao(this.w9, false);
            }
        }
        ga() {
            return true;
        }
        q7(a, b, c, d) {
            super.q7(a, b, c, d);
            switch (b) {
                case FinalValueLayer.$$p[11]:
                case FinalValueLayer.$$p[12]:
                    this.rp(true);
                    break;
                case FinalValueLayer.$$p[1]:
                case FinalValueLayer.$$p[0]:
                case FinalValueLayer.$$p[3]:
                case FinalValueLayer.$$p[5]:
                case FinalValueLayer.$$p[7]:
                case FinalValueLayer.$$p[6]:
                case FinalValueLayer.$$p[4]:
                case "Visibility":
                case FinalValueLayer.$$p[8]:
                case FinalValueLayer.$$p[9]:
                case FinalValueLayer.$$p[10]:
                    this.rp(true);
                    break;
                case "SeriesViewer":
                    let e = this.z1;
                    let f = this.z0;
                    if (f != null) {
                        for (let g of fromEnum(f)) {
                            let h = g.value;
                            h.c((i) => g.key.an.remove(i));
                            h.clear();
                        }
                        e.clear();
                        f.clear();
                    }
                    break;
            }
        }
        o5(a, b) {
            super.o5(a, b);
            if (a) {
                AxisAnnotationFrameManager.b(this.w9);
                this.aao(this.w9, false);
            }
        }
    }
    FinalValueLayer.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
    FinalValueLayer.$$p = markDep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:z2:aap', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:aa2:aaq', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:z8:aar', [1, -1], 'AxisAnnotationOutline:aa3:aas', [Brush.$, null], 'AxisAnnotationPaddingBottom:z3:aat', [1, NaN], 'AxisAnnotationPaddingLeft:z4:aau', [1, NaN], 'AxisAnnotationPaddingRight:z5:aav', [1, NaN], 'AxisAnnotationPaddingTop:z6:aaw', [1, NaN], 'AxisAnnotationStrokeThickness:z7:aax', [1, NaN], 'AxisAnnotationTextColor:aa4:aay', [Brush.$, null], 'FinalValueSelectionMode:zx:aaz', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeriesName:aak:aa0', [2, null], 'TargetSeries:zy:aa1', [Series.$, null]]);
    return FinalValueLayer;
})();
/**
 * @hidden
 */
export let FinalValueLayerView = /*@__PURE__*/ (() => {
    class FinalValueLayerView extends AnnotationLayerView {
        constructor(a) {
            super(a);
            this.b7 = null;
            this.b7 = a;
        }
        au() {
            super.au();
        }
        b8(a) {
            if (a == null) {
                return a;
            }
            return BrushUtil.m(a, 0.1);
        }
        an(a) {
            super.an(a);
        }
    }
    FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
    return FinalValueLayerView;
})();
