/*
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.ri = null;
        _this.rh = null;
        var a = new FinalValueLayerFrame();
        var b = new FinalValueLayerFrame();
        var c = new FinalValueLayerFrame();
        var d = _this.ho / 1000;
        _this.qa = a;
        _this.p9 = b;
        _this.qb = c;
        _this.ab = FinalValueLayer.$;
        return _this;
    }
    FinalValueLayer.prototype.get_da = function () {
        return true;
    };
    FinalValueLayer.prototype.bx = function () {
        return new FinalValueLayerView(this);
    };
    FinalValueLayer.prototype.l2 = function (a) {
        _super.prototype.l2.call(this, a);
        this.rd = a;
    };
    Object.defineProperty(FinalValueLayer.prototype, "sn", {
        get: function () {
            return new Thickness(1, this.rl, this.rn, this.rm, this.rk);
        },
        enumerable: false,
        configurable: true
    });
    FinalValueLayer.prototype.rg = function () {
        return this.axisAnnotationFormatLabel != null;
    };
    FinalValueLayer.prototype.qt = function (a, b) {
        if (this.rf == null || this.rf == a) {
            if (!this.as.c) {
                this.ml(b);
            }
        }
    };
    FinalValueLayer.prototype.qv = function (a, b) {
        var e_1, _a;
        var _this = this;
        _super.prototype.qv.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.qg(this.rf)) {
            this.r4(this.rf, c);
        }
        else {
            try {
                for (var _b = __values(fromEnum(this.cd.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (this.qg(d)) {
                        this.r4(d, c);
                    }
                    if (d.isStacked) {
                        d.ld(function (e) {
                            if (_this.qg(e)) {
                                _this.r4(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.qg = function (a) {
        if (!_super.prototype.qg.call(this, a)) {
            return false;
        }
        if (this.r1 != null) {
            if (a.dv) {
                var b = a.jr();
                if (!Base.equalsStatic(this.r1, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.r1, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    FinalValueLayer.prototype.lv = function () {
        _super.prototype.lv.call(this);
        if (!this.as.c && !this.cv()) {
            return;
        }
        if (this.cv()) {
            this.r5(this.qb, false);
        }
        else {
            this.r5(this.p9, false);
        }
    };
    FinalValueLayer.prototype.sm = function (a) {
        var b = NaN;
        var c = NaN;
        var d = this.re;
        if (d == 0) {
            d = 1;
        }
        var e = false;
        if (d == 2) {
            e = true;
        }
        if (a.isVertical) {
            var f = a.ar();
            if (f != null) {
                if (d == 1 || d == 2) {
                    if (f.cg) {
                        c = a.pt({ $type: Point_$type, x: this.p3.right, y: this.p3.bottom }).y;
                    }
                    else {
                        c = a.pt({ $type: Point_$type, x: this.p3.right, y: this.p3.top }).y;
                    }
                }
                else {
                    if (f.cg) {
                        c = 1;
                    }
                    else {
                        c = 0;
                    }
                }
            }
            return a.pq({ $type: Point_$type, x: 0, y: c }, e, true);
        }
        else {
            var g = a.ar();
            if (g != null) {
                if (d == 1 || d == 2) {
                    if (g.cg) {
                        b = a.pt({ $type: Point_$type, x: this.p3.left, y: this.p3.top }).x;
                    }
                    else {
                        b = a.pt({ $type: Point_$type, x: this.p3.right, y: this.p3.top }).x;
                    }
                }
                else {
                    if (g.cg) {
                        b = 0;
                    }
                    else {
                        b = 1;
                    }
                }
            }
            if (a.dq) {
                return a.pq({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
            else {
                return a.pq({ $type: Point_$type, x: b, y: 0 }, e, true);
            }
        }
    };
    FinalValueLayer.prototype.r4 = function (a, b) {
        var c = this.sm(a);
        var d = this.pt(c);
        var e = this.o3;
        if (e == null) {
            e = this.o7;
        }
        if (e == null) {
            e = a.o3;
            if (e != null) {
                e = this.rd.b5(e);
            }
        }
        AxisAnnotationFrameManager.c(b, c, a, this.cd, this.getEffectiveViewport(), e, this.sj, this.rj, this.sl, this.sk, this.sn, this.ro, this.sj, this.rj, this.sl, this.sk, this.sn, this.ro, a.isVertical, !a.isVertical);
    };
    FinalValueLayer.prototype.r5 = function (a, b) {
        var c = false;
        if (this.rh == null) {
            c = true;
            this.ri = new List$1(Axis.$, 0);
            this.rh = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        AxisAnnotationFrameManager.d(this, a, c, this.rh, this.ri, b, this.rp, this.rp, this.axisAnnotationFormatLabel, this.axisAnnotationFormatLabel);
    };
    FinalValueLayer.prototype.qy = function (a, b) {
        _super.prototype.qy.call(this, a, b);
        if (this.cv()) {
            this.r5(this.qb, true);
        }
        else {
            this.r5(this.p9, false);
        }
    };
    FinalValueLayer.prototype.en = function () {
        return true;
    };
    FinalValueLayer.prototype.l7 = function (a, b, c, d) {
        var e_2, _a;
        _super.prototype.l7.call(this, a, b, c, d);
        switch (b) {
            case FinalValueLayer.$$p[11]:
            case FinalValueLayer.$$p[12]:
                this.ml(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.ml(true);
                break;
            case "SeriesViewer":
                var e = this.ri;
                var f = this.rh;
                if (f != null) {
                    var _loop_1 = function (g) {
                        var h = g.value;
                        h.c(function (i) { return g.key.am.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.$t = markType(FinalValueLayer, 'FinalValueLayer', AnnotationLayer.$);
    FinalValueLayer.$$p = markDep(DependencyProperty, PropertyMetadata, FinalValueLayer, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:rj:r6', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:sj:r7', [Brush.$, null], 'AxisAnnotationInterpolatedValuePrecision:rp:r8', [1, -1], 'AxisAnnotationOutline:sk:r9', [Brush.$, null], 'AxisAnnotationPaddingBottom:rk:sa', [1, NaN], 'AxisAnnotationPaddingLeft:rl:sb', [1, NaN], 'AxisAnnotationPaddingRight:rm:sc', [1, NaN], 'AxisAnnotationPaddingTop:rn:sd', [1, NaN], 'AxisAnnotationStrokeThickness:ro:se', [1, NaN], 'AxisAnnotationTextColor:sl:sf', [Brush.$, null], 'FinalValueSelectionMode:re:sg', [FinalValueSelectionMode_$type, enumGetBox(FinalValueSelectionMode_$type, 0)], 'TargetSeriesName:r1:sh', [2, null], 'TargetSeries:rf:si', [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.b4 = null;
        _this.b4 = a;
        return _this;
    }
    FinalValueLayerView.prototype.as = function () {
        _super.prototype.as.call(this);
    };
    FinalValueLayerView.prototype.b5 = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.l(a, 0.1);
    };
    FinalValueLayerView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
    };
    FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
    return FinalValueLayerView;
}(AnnotationLayerView));
export { FinalValueLayerView };
