/*
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 { __extends, __values } from "tslib";
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
 */
var FinalValueLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinalValueLayer, _super);
    function FinalValueLayer() {
        var _this = _super.call(this) || this;
        _this.axisAnnotationFormatLabel = null;
        _this.aal = null;
        _this.aak = null;
        var a = new FinalValueLayerFrame();
        var b = new FinalValueLayerFrame();
        var c = new FinalValueLayerFrame();
        var d = _this.kh / 1000;
        _this.xm = a;
        _this.xl = b;
        _this.xn = c;
        _this.ab = FinalValueLayer.$;
        return _this;
    }
    FinalValueLayer.prototype.bk = function () {
        return new FinalValueLayer();
    };
    FinalValueLayer.prototype.get_es = function () {
        return true;
    };
    FinalValueLayer.prototype.ct = function () {
        return new FinalValueLayerView(this);
    };
    FinalValueLayer.prototype.q7 = function (a) {
        _super.prototype.q7.call(this, a);
        this.aag = a;
    };
    Object.defineProperty(FinalValueLayer.prototype, "abq", {
        get: function () {
            return new Thickness(1, this.aao, this.aaq, this.aap, this.aan);
        },
        enumerable: false,
        configurable: true
    });
    FinalValueLayer.prototype.aaj = function () {
        return this.axisAnnotationFormatLabel != null;
    };
    FinalValueLayer.prototype.y1 = function (a, b) {
        if (this.aai == null || this.aai == a) {
            if (!this.a1.c) {
                this.ry(b);
            }
        }
    };
    FinalValueLayer.prototype.y3 = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.y3.call(this, a, b);
        var 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.xs(this.aai)) {
            this.aa7(this.aai, c);
        }
        else {
            try {
                for (var _b = __values(fromEnum(this.dc.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (this.xs(d)) {
                        this.aa7(d, c);
                    }
                    if (d.isStacked) {
                        d.p9(function (e) {
                            if (_this.xs(e)) {
                                _this.aa7(e, c);
                            }
                            if (e.ei) {
                                e.p7(function (f) {
                                    if (_this.xs(f)) {
                                        _this.aa7(f, c);
                                    }
                                    return true;
                                });
                            }
                            return true;
                        });
                    }
                    if (d.ei) {
                        d.p7(function (e) {
                            if (_this.xs(e)) {
                                _this.aa7(e, c);
                            }
                            return true;
                        });
                    }
                }
            }
            catch (e_1_1) {
                e_1 = { error: e_1_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_1)
                        throw e_1.error;
                }
            }
        }
    };
    FinalValueLayer.prototype.xs = function (a) {
        if (!_super.prototype.xs.call(this, a)) {
            return false;
        }
        if (this.aa4 != null) {
            if (a.isFragment) {
                var b = a.nh();
                if (!Base.equalsStatic(this.aa4, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.aa4, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    FinalValueLayer.prototype.qv = function () {
        _super.prototype.qv.call(this);
        if (!this.a1.c && !this.d4()) {
            return;
        }
        if (this.d4()) {
            this.aa8(this.xn, false);
        }
        else {
            this.aa8(this.xl, false);
        }
    };
    FinalValueLayer.prototype.abp = function (a) {
        var b = NaN;
        var c = NaN;
        var d = this.aah;
        if (d == 0) {
            d = 1;
        }
        var e = false;
        if (d == 2) {
            e = true;
        }
        if (a.isVertical) {
            var f = a.a0();
            if (f != null) {
                if (d == 1 || d == 2) {
                    var g = this.wt(this.cw);
                    if (f.df) {
                        c = a.wr({ $type: Point_$type, x: g.right, y: g.bottom }).y;
                    }
                    else {
                        c = a.wr({ $type: Point_$type, x: g.right, y: g.top }).y;
                    }
                }
                else {
                    if (f.df) {
                        c = 1;
                    }
                    else {
                        c = 0;
                    }
                }
            }
            return a.wm({ $type: Point_$type, x: 0, y: c }, e, true);
        }
        else {
            var h = a.a0();
            if (h != null) {
                if (d == 1 || d == 2) {
                    var i = this.wt(this.cw);
                    if (h.df) {
                        b = a.wr({ $type: Point_$type, x: i.left, y: i.top }).x;
                    }
                    else {
                        b = a.wr({ $type: Point_$type, x: i.right, y: i.top }).x;
                    }
                }
                else {
                    if (h.df) {
                        b = 0;
                    }
                    else {
                        b = 1;
                    }
                }
            }
            if (a.e8) {
                return a.wm({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
            else {
                return a.wm({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
        }
    };
    FinalValueLayer.prototype.aa7 = function (a, b) {
        var c = this.abp(a);
        var d = this.wr(c);
        var e = this.vj;
        if (e == null) {
            e = this.vp;
        }
        if (e == null) {
            e = a.vj;
            if (e != null) {
                e = this.aag.co(e);
            }
        }
        AxisAnnotationFrameManager.c(b, c, a, this.dc, this.getEffectiveViewport(), e, this.abm, this.aam, this.abo, this.abn, this.abq, this.aar, this.abm, this.aam, this.abo, this.abn, this.abq, this.aar, this._visibility == 0 && a.isVertical, this._visibility == 0 && !a.isVertical);
    };
    FinalValueLayer.prototype.aa8 = function (a, b) {
        var c = false;
        if (this.aak == null) {
            c = true;
            this.aal = new List$1(Axis.$, 0);
            this.aak = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.aak, this.aal, b, this.aas, this.aas, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
    };
    FinalValueLayer.prototype.y6 = function (a, b) {
        _super.prototype.y6.call(this, a, b);
        if (this.d4()) {
            this.aa8(this.xn, true);
        }
        else {
            this.aa8(this.xl, false);
        }
    };
    FinalValueLayer.prototype.gb = function () {
        return true;
    };
    FinalValueLayer.prototype.rg = function (a, b, c, d) {
        var e_2, _a;
        _super.prototype.rg.call(this, a, b, c, d);
        switch (b) {
            case FinalValueLayer.$$p[11]:
            case FinalValueLayer.$$p[12]:
                this.ry(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.ry(true);
                break;
            case "SeriesViewer":
                var e = this.aal;
                var f = this.aak;
                if (f != null) {
                    var _loop_1 = function (g) {
                        var h = g.value;
                        h.c(function (i) { return g.key.ar.remove(i); });
                        h.clear();
                    };
                    try {
                        for (var _b = __values(fromEnum(f)), _c = _b.next(); !_c.done; _c = _b.next()) {
                            var g = _c.value;
                            _loop_1(g);
                        }
                    }
                    catch (e_2_1) {
                        e_2 = { error: e_2_1 };
                    }
                    finally {
                        try {
                            if (_c && !_c.done && (_a = _b.return))
                                _a.call(_b);
                        }
                        finally {
                            if (e_2)
                                throw e_2.error;
                        }
                    }
                    e.clear();
                    f.clear();
                }
                break;
        }
    };
    FinalValueLayer.prototype.pb = function (a, b) {
        _super.prototype.pb.call(this, a, b);
        if (a) {
            AxisAnnotationFrameManager.b(this.xl);
            this.aa8(this.xl, false);
        }
    };
    FinalValueLayer.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
    FinalValueLayer.$$p = markDep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:aam:aa9', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:abm:aba', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:aas:abb', [1, -1], 'AxisAnnotationOutline:abn:abc', [Brush.$, null], 'AxisAnnotationPaddingBottom:aan:abd', [1, NaN], 'AxisAnnotationPaddingLeft:aao:abe', [1, NaN], 'AxisAnnotationPaddingRight:aap:abf', [1, NaN], 'AxisAnnotationPaddingTop:aaq:abg', [1, NaN], 'AxisAnnotationStrokeThickness:aar:abh', [1, NaN], 'AxisAnnotationTextColor:abo:abi', [Brush.$, null], 'FinalValueSelectionMode:aah:abj', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeriesName:aa4:abk', [2, null], 'TargetSeries:aai:abl', [Series.$, null]]);
    return FinalValueLayer;
}(AnnotationLayer));
export { FinalValueLayer };
/**
 * @hidden
 */
var FinalValueLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinalValueLayerView, _super);
    function FinalValueLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.cn = null;
        _this.cn = a;
        return _this;
    }
    FinalValueLayerView.prototype.a4 = function () {
        _super.prototype.a4.call(this);
    };
    FinalValueLayerView.prototype.co = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.o(a, 0.1);
    };
    FinalValueLayerView.prototype.ax = function (a) {
        _super.prototype.ax.call(this, a);
    };
    FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
    return FinalValueLayerView;
}(AnnotationLayerView));
export { FinalValueLayerView };
