/*
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-react-core";
import { Series } from "./Series";
import { FinalValueSelectionMode_$type } from "./FinalValueSelectionMode";
import { Brush } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { FinalValueLayerFrame } from "./FinalValueLayerFrame";
import { List$1 } from "igniteui-react-core";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { Base, enumGetBox, fromEnum, Point_$type, markType, markDep } from "igniteui-react-core";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-react-core";
import { DeviceUtils } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core";
/**
 * @hidden
 */
var FinalValueLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(FinalValueLayer, _super);
    function FinalValueLayer() {
        var _this = _super.call(this) || this;
        _this.axisAnnotationFormatLabel = null;
        _this.zv = null;
        _this.zu = null;
        var a = new FinalValueLayerFrame();
        var b = new FinalValueLayerFrame();
        var c = new FinalValueLayerFrame();
        var d = _this.kb / 1000;
        _this.w4 = a;
        _this.w3 = b;
        _this.w5 = c;
        _this.ab = FinalValueLayer.$;
        return _this;
    }
    FinalValueLayer.prototype.bi = function () {
        return new FinalValueLayer();
    };
    FinalValueLayer.prototype.get_eo = function () {
        return true;
    };
    FinalValueLayer.prototype.cq = function () {
        return new FinalValueLayerView(this);
    };
    FinalValueLayer.prototype.qx = function (a) {
        _super.prototype.qx.call(this, a);
        this.zq = a;
    };
    Object.defineProperty(FinalValueLayer.prototype, "aa0", {
        get: function () {
            return new Thickness(1, this.zy, this.z0, this.zz, this.zx);
        },
        enumerable: false,
        configurable: true
    });
    FinalValueLayer.prototype.zt = function () {
        return this.axisAnnotationFormatLabel != null;
    };
    FinalValueLayer.prototype.yh = function (a, b) {
        if (this.zs == null || this.zs == a) {
            if (!this.a0.c) {
                this.rn(b);
            }
        }
    };
    FinalValueLayer.prototype.yj = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.yj.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.xa(this.zs)) {
            this.aah(this.zs, c);
        }
        else {
            try {
                for (var _b = __values(fromEnum(this.c9.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (this.xa(d)) {
                        this.aah(d, c);
                    }
                    if (d.isStacked) {
                        d.pz(function (e) {
                            if (_this.xa(e)) {
                                _this.aah(e, c);
                            }
                            if (e.ee) {
                                e.px(function (f) {
                                    if (_this.xa(f)) {
                                        _this.aah(f, c);
                                    }
                                    return true;
                                });
                            }
                            return true;
                        });
                    }
                    if (d.ee) {
                        d.px(function (e) {
                            if (_this.xa(e)) {
                                _this.aah(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.xa = function (a) {
        if (!_super.prototype.xa.call(this, a)) {
            return false;
        }
        if (this.aae != null) {
            if (a.e9) {
                var b = a.na();
                if (!Base.equalsStatic(this.aae, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.aae, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    FinalValueLayer.prototype.ql = function () {
        _super.prototype.ql.call(this);
        if (!this.a0.c && !this.d1()) {
            return;
        }
        if (this.d1()) {
            this.aai(this.w5, false);
        }
        else {
            this.aai(this.w3, false);
        }
    };
    FinalValueLayer.prototype.aaz = function (a) {
        var b = NaN;
        var c = NaN;
        var d = this.zr;
        if (d == 0) {
            d = 1;
        }
        var e = false;
        if (d == 2) {
            e = true;
        }
        if (a.isVertical) {
            var f = a.az();
            if (f != null) {
                if (d == 1 || d == 2) {
                    var g = this.wd(this.ct);
                    if (f.ch) {
                        c = a.wb({ $type: Point_$type, x: g.right, y: g.bottom }).y;
                    }
                    else {
                        c = a.wb({ $type: Point_$type, x: g.right, y: g.top }).y;
                    }
                }
                else {
                    if (f.ch) {
                        c = 1;
                    }
                    else {
                        c = 0;
                    }
                }
            }
            return a.v6({ $type: Point_$type, x: 0, y: c }, e, true);
        }
        else {
            var h = a.az();
            if (h != null) {
                if (d == 1 || d == 2) {
                    var i = this.wd(this.ct);
                    if (h.ch) {
                        b = a.wb({ $type: Point_$type, x: i.left, y: i.top }).x;
                    }
                    else {
                        b = a.wb({ $type: Point_$type, x: i.right, y: i.top }).x;
                    }
                }
                else {
                    if (h.ch) {
                        b = 0;
                    }
                    else {
                        b = 1;
                    }
                }
            }
            if (a.e4) {
                return a.v6({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
            else {
                return a.v6({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
        }
    };
    FinalValueLayer.prototype.aah = function (a, b) {
        var c = this.aaz(a);
        var d = this.wb(c);
        var e = this.u3;
        if (e == null) {
            e = this.u9;
        }
        if (e == null) {
            e = a.u3;
            if (e != null) {
                e = this.zq.b8(e);
            }
        }
        AxisAnnotationFrameManager.c(b, c, a, this.c9, this.getEffectiveViewport(), e, this.aaw, this.zw, this.aay, this.aax, this.aa0, this.z1, this.aaw, this.zw, this.aay, this.aax, this.aa0, this.z1, this._visibility == 0 && a.isVertical, this._visibility == 0 && !a.isVertical);
    };
    FinalValueLayer.prototype.aai = function (a, b) {
        var c = false;
        if (this.zu == null) {
            c = true;
            this.zv = new List$1(Axis.$, 0);
            this.zu = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.zu, this.zv, b, this.z2, this.z2, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
    };
    FinalValueLayer.prototype.ym = function (a, b) {
        _super.prototype.ym.call(this, a, b);
        if (this.d1()) {
            this.aai(this.w5, true);
        }
        else {
            this.aai(this.w3, false);
        }
    };
    FinalValueLayer.prototype.f8 = function () {
        return true;
    };
    FinalValueLayer.prototype.q5 = function (a, b, c, d) {
        var e_2, _a;
        _super.prototype.q5.call(this, a, b, c, d);
        switch (b) {
            case FinalValueLayer.$$p[11]:
            case FinalValueLayer.$$p[12]:
                this.rn(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.rn(true);
                break;
            case "SeriesViewer":
                var e = this.zv;
                var f = this.zu;
                if (f != null) {
                    var _loop_1 = function (g) {
                        var h = g.value;
                        h.c(function (i) { return g.key.an.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.o3 = function (a, b) {
        _super.prototype.o3.call(this, a, b);
        if (a) {
            AxisAnnotationFrameManager.b(this.w3);
            this.aai(this.w3, false);
        }
    };
    FinalValueLayer.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
    FinalValueLayer.$$p = markDep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:zw:aaj', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:aaw:aak', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:z2:aal', [1, -1], 'AxisAnnotationOutline:aax:aam', [Brush.$, null], 'AxisAnnotationPaddingBottom:zx:aan', [1, NaN], 'AxisAnnotationPaddingLeft:zy:aao', [1, NaN], 'AxisAnnotationPaddingRight:zz:aap', [1, NaN], 'AxisAnnotationPaddingTop:z0:aaq', [1, NaN], 'AxisAnnotationStrokeThickness:z1:aar', [1, NaN], 'AxisAnnotationTextColor:aay:aas', [Brush.$, null], 'FinalValueSelectionMode:zr:aat', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeriesName:aae:aau', [2, null], 'TargetSeries:zs:aav', [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.b7 = null;
        _this.b7 = a;
        return _this;
    }
    FinalValueLayerView.prototype.au = function () {
        _super.prototype.au.call(this);
    };
    FinalValueLayerView.prototype.b8 = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.m(a, 0.1);
    };
    FinalValueLayerView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
    };
    FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
    return FinalValueLayerView;
}(AnnotationLayerView));
export { FinalValueLayerView };
