/*
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.th = null;
            this.tg = null;
            let a = new FinalValueLayerFrame();
            let b = new FinalValueLayerFrame();
            let c = new FinalValueLayerFrame();
            let d = this.hr / 1000;
            this.qq = a;
            this.qp = b;
            this.qr = c;
            this.ab = FinalValueLayer.$;
        }
        get_db() {
            return true;
        }
        by() {
            return new FinalValueLayerView(this);
        }
        l4(a) {
            super.l4(a);
            this.tc = a;
        }
        get um() {
            return new Thickness(1, this.tk, this.tm, this.tl, this.tj);
        }
        tf() {
            return this.axisAnnotationFormatLabel != null;
        }
        r3(a, b) {
            if (this.te == null || this.te == a) {
                if (!this.at.c) {
                    this.mn(b);
                }
            }
        }
        r5(a, b) {
            super.r5(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.qw(this.te)) {
                this.t3(this.te, c);
            }
            else {
                for (let d of fromEnum(this.ce.series)) {
                    if (this.qw(d)) {
                        this.t3(d, c);
                    }
                    if (d.isStacked) {
                        d.lf((e) => {
                            if (this.qw(e)) {
                                this.t3(e, c);
                            }
                            return true;
                        });
                    }
                }
            }
        }
        qw(a) {
            if (!super.qw(a)) {
                return false;
            }
            if (this.t0 != null) {
                if (a.dx) {
                    let b = a.ju();
                    if (!Base.equalsStatic(this.t0, b)) {
                        return false;
                    }
                }
                else {
                    if (!Base.equalsStatic(this.t0, a.name)) {
                        return false;
                    }
                }
            }
            return true;
        }
        lx() {
            super.lx();
            if (!this.at.c && !this.cw()) {
                return;
            }
            if (this.cw()) {
                this.t4(this.qr, false);
            }
            else {
                this.t4(this.qp, false);
            }
        }
        ul(a) {
            let b = NaN;
            let c = NaN;
            let d = this.td;
            if (d == 0) {
                d = 1;
            }
            let e = false;
            if (d == 2) {
                e = true;
            }
            if (a.isVertical) {
                let f = a.as();
                if (f != null) {
                    if (d == 1 || d == 2) {
                        if (f.cg) {
                            c = a.px({ $type: Point_$type, x: this.p7.right, y: this.p7.bottom }).y;
                        }
                        else {
                            c = a.px({ $type: Point_$type, x: this.p7.right, y: this.p7.top }).y;
                        }
                    }
                    else {
                        if (f.cg) {
                            c = 1;
                        }
                        else {
                            c = 0;
                        }
                    }
                }
                return a.ps({ $type: Point_$type, x: 0, y: c }, e, true);
            }
            else {
                let g = a.as();
                if (g != null) {
                    if (d == 1 || d == 2) {
                        if (g.cg) {
                            b = a.px({ $type: Point_$type, x: this.p7.left, y: this.p7.top }).x;
                        }
                        else {
                            b = a.px({ $type: Point_$type, x: this.p7.right, y: this.p7.top }).x;
                        }
                    }
                    else {
                        if (g.cg) {
                            b = 0;
                        }
                        else {
                            b = 1;
                        }
                    }
                }
                if (a.ds) {
                    return a.ps({ $type: Point_$type, x: b, y: 0 }, e, true);
                }
                else {
                    return a.ps({ $type: Point_$type, x: b, y: 0 }, e, true);
                }
            }
        }
        t3(a, b) {
            let c = this.ul(a);
            let d = this.px(c);
            let e = this.o5;
            if (e == null) {
                e = this.o9;
            }
            if (e == null) {
                e = a.o5;
                if (e != null) {
                    e = this.tc.b5(e);
                }
            }
            AxisAnnotationFrameManager.c(b, c, a, this.ce, this.getEffectiveViewport(), e, this.ui, this.ti, this.uk, this.uj, this.um, this.tn, this.ui, this.ti, this.uk, this.uj, this.um, this.tn, a.isVertical, !a.isVertical);
        }
        t4(a, b) {
            let c = false;
            if (this.tg == null) {
                c = true;
                this.th = new List$1(Axis.$, 0);
                this.tg = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            AxisAnnotationFrameManager.d(this, a, c, this.tg, this.th, b, this.to, this.to, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
        }
        r8(a, b) {
            super.r8(a, b);
            if (this.cw()) {
                this.t4(this.qr, true);
            }
            else {
                this.t4(this.qp, false);
            }
        }
        ep() {
            return true;
        }
        l9(a, b, c, d) {
            super.l9(a, b, c, d);
            switch (b) {
                case FinalValueLayer.$$p[11]:
                case FinalValueLayer.$$p[12]:
                    this.mn(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 FinalValueLayer.$$p[8]:
                case FinalValueLayer.$$p[9]:
                case FinalValueLayer.$$p[10]:
                    this.mn(true);
                    break;
                case "SeriesViewer":
                    let e = this.th;
                    let f = this.tg;
                    if (f != null) {
                        for (let g of fromEnum(f)) {
                            let h = g.value;
                            h.c((i) => g.key.am.remove(i));
                            h.clear();
                        }
                        e.clear();
                        f.clear();
                    }
                    break;
            }
        }
    }
    FinalValueLayer.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
    FinalValueLayer.$$p = markDep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:ti:t5', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:ui:t6', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:to:t7', [1, -1], 'AxisAnnotationOutline:uj:t8', [Brush.$, null], 'AxisAnnotationPaddingBottom:tj:t9', [1, NaN], 'AxisAnnotationPaddingLeft:tk:ua', [1, NaN], 'AxisAnnotationPaddingRight:tl:ub', [1, NaN], 'AxisAnnotationPaddingTop:tm:uc', [1, NaN], 'AxisAnnotationStrokeThickness:tn:ud', [1, NaN], 'AxisAnnotationTextColor:uk:ue', [Brush.$, null], 'FinalValueSelectionMode:td:uf', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeriesName:t0:ug', [2, null], 'TargetSeries:te:uh', [Series.$, null]]);
    return FinalValueLayer;
})();
/**
 * @hidden
 */
export let FinalValueLayerView = /*@__PURE__*/ (() => {
    class FinalValueLayerView extends AnnotationLayerView {
        constructor(a) {
            super(a);
            this.b4 = null;
            this.b4 = a;
        }
        as() {
            super.as();
        }
        b5(a) {
            if (a == null) {
                return a;
            }
            return BrushUtil.l(a, 0.1);
        }
        al(a) {
            super.al(a);
        }
    }
    FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
    return FinalValueLayerView;
})();
