/*
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 * as tslib_1 from "tslib";
import { AnnotationLayer } from "./AnnotationLayer";
import { Series } from "./Series";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { FinalValueSelectionMode_$type } from "./FinalValueSelectionMode";
import { Brush } from "igniteui-react-core/ES5/Brush";
import { Thickness } from "igniteui-react-core/ES5/Thickness";
import { FinalValueLayerFrame } from "./FinalValueLayerFrame";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Axis } from "./Axis";
import { Dictionary$2 } from "igniteui-react-core/ES5/Dictionary$2";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { AxisAnnotation } from "./AxisAnnotation";
import { Type, enumGetBox, fromEnum, Point_$type, markType } from "igniteui-react-core/ES5/type";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core/ES5/BrushUtil";
/**
 * @hidden
 */
var FinalValueLayer = /** @class */ (function (_super) {
    tslib_1.__extends(FinalValueLayer, _super);
    function FinalValueLayer() {
        var _this = _super.call(this) || this;
        _this.axisAnnotationFormatLabel = null;
        _this.m1 = null;
        _this.m0 = null;
        var a = new FinalValueLayerFrame();
        var b = new FinalValueLayerFrame();
        var c = new FinalValueLayerFrame();
        var d = _this.ff / 1000;
        _this.lv = a;
        _this.lu = b;
        _this.lw = c;
        _this.ab = FinalValueLayer.$;
        return _this;
    }
    FinalValueLayer.prototype.bf = function () {
        return new FinalValueLayerView(this);
    };
    FinalValueLayer.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.mw = a;
    };
    Object.defineProperty(FinalValueLayer.prototype, "n0", {
        get: function () {
            return new Thickness(1, this.m3, this.m5, this.m4, this.m2);
        },
        enumerable: true,
        configurable: true
    });
    FinalValueLayer.prototype.mz = function () {
        return this.axisAnnotationFormatLabel != null;
    };
    FinalValueLayer.prototype.mc = function (a, b) {
        if (this.my == null || this.my == a) {
            if (!this.aq.c) {
                this.i6(b);
            }
        }
    };
    FinalValueLayer.prototype.me = function (a, b) {
        var e_1, _a;
        _super.prototype.me.call(this, a, b);
        var 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 {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.bs.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (this.lz(d)) {
                        this.nj(d, c);
                    }
                }
            }
            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.lz = function (a) {
        if (!_super.prototype.lz.call(this, a)) {
            return false;
        }
        return true;
    };
    FinalValueLayer.prototype.ig = function () {
        _super.prototype.ig.call(this);
        if (!this.aq.c && !this.ca()) {
            return;
        }
        if (this.ca()) {
            this.nk(this.lw, false);
        }
        else {
            this.nk(this.lu, false);
        }
    };
    FinalValueLayer.prototype.nz = function (a) {
        var b = NaN;
        var c = NaN;
        var d = this.mx;
        if (d == 0) {
            d = 1;
        }
        var e = false;
        if (d == 2) {
            e = true;
        }
        if (a.isVertical) {
            var 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 {
            var 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);
            }
        }
    };
    FinalValueLayer.prototype.nj = function (a, b) {
        var c = this.nz(a);
        var d = this.lh(c);
        var 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);
    };
    FinalValueLayer.prototype.nk = function (a, b) {
        var 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);
    };
    FinalValueLayer.prototype.mh = function (a, b) {
        _super.prototype.mh.call(this, a, b);
        if (this.ca()) {
            this.nk(this.lw, true);
        }
        else {
            this.nk(this.lu, false);
        }
    };
    FinalValueLayer.prototype.c7 = function () {
        return true;
    };
    FinalValueLayer.prototype.is = function (a, b, c, d) {
        var e_2, _a;
        _super.prototype.is.call(this, 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":
                var e = this.m1;
                var f = this.m0;
                if (f != null) {
                    var _loop_1 = function (g) {
                        var h = g.value;
                        h.c(function (i) { return g.key.ak.remove(i); });
                        h.clear();
                    };
                    try {
                        for (var _b = tslib_1.__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.$);
    return FinalValueLayer;
}(AnnotationLayer));
export { FinalValueLayer };
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
 */
var FinalValueLayerView = /** @class */ (function (_super) {
    tslib_1.__extends(FinalValueLayerView, _super);
    function FinalValueLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b1 = null;
        _this.b1 = a;
        return _this;
    }
    FinalValueLayerView.prototype.ap = function () {
        _super.prototype.ap.call(this);
    };
    FinalValueLayerView.prototype.b2 = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, 0.1);
    };
    FinalValueLayerView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
    };
    FinalValueLayerView.$t = markType(FinalValueLayerView, 'FinalValueLayerView', AnnotationLayerView.$);
    return FinalValueLayerView;
}(AnnotationLayerView));
export { FinalValueLayerView };
