/*
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 { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES2015/DependencyProperty";
import { FinalValueSelectionMode_$type } from "./FinalValueSelectionMode";
import { Brush } from "igniteui-react-core/ES2015/Brush";
import { Thickness } from "igniteui-react-core/ES2015/Thickness";
import { FinalValueLayerFrame } from "./FinalValueLayerFrame";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-react-core/ES2015/Dictionary$2";
import { Pool$1 } from "igniteui-react-core/ES2015/Pool$1";
import { AxisAnnotation } from "./AxisAnnotation";
import { Type, enumGetBox, fromEnum, Point_$type, markType } from "igniteui-react-core/ES2015/type";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-react-core/ES2015/PropertyMetadata";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core/ES2015/BrushUtil";
/**
 * @hidden
 */
export class FinalValueLayer extends AnnotationLayer {
    constructor() {
        super();
        this.axisAnnotationFormatLabel = null;
        this.m1 = null;
        this.m0 = null;
        let a = new FinalValueLayerFrame();
        let b = new FinalValueLayerFrame();
        let c = new FinalValueLayerFrame();
        let d = this.ff / 1000;
        this.lv = a;
        this.lu = b;
        this.lw = c;
        this.ab = FinalValueLayer.$;
    }
    bf() {
        return new FinalValueLayerView(this);
    }
    im(a) {
        super.im(a);
        this.mw = a;
    }
    get n0() {
        return new Thickness(1, this.m3, this.m5, this.m4, this.m2);
    }
    mz() {
        return this.axisAnnotationFormatLabel != null;
    }
    mc(a, b) {
        if (this.my == null || this.my == a) {
            if (!this.aq.c) {
                this.i6(b);
            }
        }
    }
    me(a, b) {
        super.me(a, b);
        let c = a;
        c.f.clear();
        c.q.clear();
        c.p.clear();
        c.aa.clear();
        c.o.clear();
        c.z.clear();
        c.g.clear();
        c.h.clear();
        c.j.clear();
        c.l.clear();
        c.k.clear();
        c.i.clear();
        c.m.clear();
        c.n.clear();
        c.r.clear();
        c.s.clear();
        c.u.clear();
        c.w.clear();
        c.v.clear();
        c.t.clear();
        c.x.clear();
        c.y.clear();
        if (this.lz(this.my)) {
            this.nj(this.my, c);
        }
        else {
            for (let d of fromEnum(this.bs.series)) {
                if (this.lz(d)) {
                    this.nj(d, c);
                }
            }
        }
    }
    lz(a) {
        if (!super.lz(a)) {
            return false;
        }
        return true;
    }
    ig() {
        super.ig();
        if (!this.aq.c && !this.ca()) {
            return;
        }
        if (this.ca()) {
            this.nk(this.lw, false);
        }
        else {
            this.nk(this.lu, false);
        }
    }
    nz(a) {
        let b = NaN;
        let c = NaN;
        let d = this.mx;
        if (d == 0) {
            d = 1;
        }
        let e = false;
        if (d == 2) {
            e = true;
        }
        if (a.isVertical) {
            let f = a.ap();
            if (f != null) {
                if (d == 1 || d == 2) {
                    if (f.b8) {
                        c = a.lh({ $type: Point_$type, x: this.lr.right, y: this.lr.bottom }).y;
                    }
                    else {
                        c = a.lh({ $type: Point_$type, x: this.lr.right, y: this.lr.top }).y;
                    }
                }
                else {
                    if (f.b8) {
                        c = 1;
                    }
                    else {
                        c = 0;
                    }
                }
            }
            return a.le({ $type: Point_$type, x: 0, y: c }, e, true);
        }
        else {
            let g = a.ap();
            if (g != null) {
                if (d == 1 || d == 2) {
                    if (g.b8) {
                        b = a.lh({ $type: Point_$type, x: this.lr.left, y: this.lr.top }).x;
                    }
                    else {
                        b = a.lh({ $type: Point_$type, x: this.lr.right, y: this.lr.top }).x;
                    }
                }
                else {
                    if (g.b8) {
                        b = 0;
                    }
                    else {
                        b = 1;
                    }
                }
            }
            if (a.cr) {
                return a.le({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
            else {
                return a.le({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
        }
    }
    nj(a, b) {
        let c = this.nz(a);
        let d = this.lh(c);
        let e = this.kw;
        if (e == null) {
            e = this.ky;
        }
        if (e == null) {
            e = a.kw;
            if (e != null) {
                e = this.mw.b2(e);
            }
        }
        AxisAnnotationFrameManager.c(b, c, a, this.bs, this.getEffectiveViewport(), e, this.nw, this.ny, this.nx, this.n0, this.m6, this.nw, this.ny, this.nx, this.n0, this.m6, a.isVertical, !a.isVertical);
    }
    nk(a, b) {
        let c = false;
        if (this.m0 == null) {
            c = true;
            this.m1 = new List$1(Axis.$, 0);
            this.m0 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.m0, this.m1, b, this.m7, this.m7, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
    }
    mh(a, b) {
        super.mh(a, b);
        if (this.ca()) {
            this.nk(this.lw, true);
        }
        else {
            this.nk(this.lu, false);
        }
    }
    c7() {
        return true;
    }
    is(a, b, c, d) {
        super.is(a, b, c, d);
        switch (b) {
            case FinalValueLayer.$$p[10]:
                this.i6(true);
                break;
            case FinalValueLayer.$$p[0]:
            case FinalValueLayer.$$p[2]:
            case FinalValueLayer.$$p[4]:
            case FinalValueLayer.$$p[6]:
            case FinalValueLayer.$$p[5]:
            case FinalValueLayer.$$p[3]:
            case FinalValueLayer.$$p[7]:
            case FinalValueLayer.$$p[8]:
            case FinalValueLayer.$$p[9]:
                this.i6(true);
                break;
            case "SeriesViewer":
                let e = this.m1;
                let f = this.m0;
                if (f != null) {
                    for (let g of fromEnum(f)) {
                        let h = g.value;
                        h.c((i) => g.key.ak.remove(i));
                        h.clear();
                    }
                    e.clear();
                    f.clear();
                }
                break;
        }
    }
}
FinalValueLayer.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
Type.dep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackground:nw:nl', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:m7:nm', [1, -1], 'AxisAnnotationOutline:nx:nn', [Brush.$, null], 'AxisAnnotationPaddingBottom:m2:no', [1, NaN], 'AxisAnnotationPaddingLeft:m3:np', [1, NaN], 'AxisAnnotationPaddingRight:m4:nq', [1, NaN], 'AxisAnnotationPaddingTop:m5:nr', [1, NaN], 'AxisAnnotationStrokeThickness:m6:ns', [1, NaN], 'AxisAnnotationTextColor:ny:nt', [Brush.$, null], 'FinalValueSelectionMode:mx:nu', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeries:my:nv', [Series.$, null]]);
/**
 * @hidden
 */
export class FinalValueLayerView extends AnnotationLayerView {
    constructor(a) {
        super(a);
        this.b1 = null;
        this.b1 = a;
    }
    ap() {
        super.ap();
    }
    b2(a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, 0.1);
    }
    ai(a) {
        super.ai(a);
    }
}
FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
