/*
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 { CategoryAxisBase } from "./CategoryAxisBase";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { CategoryHighlightLayerFrame } from "./CategoryHighlightLayerFrame";
import { Type, Base, Number_$type, typeCast, fromEnum, Point_$type, markType, runOn } from "igniteui-react-core/ES5/type";
import { XamDataChart } from "./XamDataChart";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { CategoryHighlightFrameRect } from "./CategoryHighlightFrameRect";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { Rectangle } from "igniteui-react-core/ES5/Rectangle";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { isNaN_, truncate } from "igniteui-react-core/ES5/number";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core/ES5/BrushUtil";
import { Color } from "igniteui-react-core/ES5/Color";
var CategoryHighlightLayer = /** @class */ (function (_super) {
    tslib_1.__extends(CategoryHighlightLayer, _super);
    function CategoryHighlightLayer() {
        var _this = _super.call(this) || this;
        var a = new CategoryHighlightLayerFrame();
        var b = new CategoryHighlightLayerFrame();
        var c = new CategoryHighlightLayerFrame();
        var d = _this.fc / 1000;
        _this.lq = a;
        _this.lp = b;
        _this.lr = c;
        _this.ab = CategoryHighlightLayer.$;
        return _this;
    }
    CategoryHighlightLayer.prototype.bf = function () {
        return new CategoryHighlightLayerView(this);
    };
    CategoryHighlightLayer.prototype.ii = function (a) {
        _super.prototype.ii.call(this, a);
        this.mr = a;
    };
    Object.defineProperty(CategoryHighlightLayer.prototype, "mu", {
        get: function () {
            return this.c(CategoryHighlightLayer.m1);
        },
        set: function (a) {
            this.h(CategoryHighlightLayer.m1, a);
        },
        enumerable: true,
        configurable: true
    });
    CategoryHighlightLayer.prototype.l6 = function (a, b) {
        if (this.mq == null || this.mq == a) {
            if (!this.aq.c) {
                this.i1(b);
            }
        }
    };
    CategoryHighlightLayer.prototype.ms = function (a) {
        return a != null && a.cd();
    };
    CategoryHighlightLayer.prototype.l9 = function (a, b) {
        _super.prototype.l9.call(this, a, b);
        var c = a;
        c.g.clear();
        var d = this.mt;
        if (isNaN_(this.mn.x) && isNaN_(this.mn.y)) {
            return;
        }
        if (this.mq != null) {
            if (this.ms(this.mq)) {
                this.mz(this.mq, c, d);
            }
        }
        else {
            if (typeCast(XamDataChart.$, this.bs) !== null) {
                var e = this.bs;
                try {
                    for (var _a = tslib_1.__values(fromEnum(e.axes)), _b = _a.next(); !_b.done; _b = _a.next()) {
                        var f = _b.value;
                        if (typeCast(CategoryAxisBase.$, f) !== null && this.ms(f)) {
                            this.mz(f, c, d);
                        }
                    }
                }
                catch (e_1_1) { e_1 = { error: e_1_1 }; }
                finally {
                    try {
                        if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                    }
                    finally { if (e_1) throw e_1.error; }
                }
            }
        }
        var e_1, _c;
    };
    CategoryHighlightLayer.prototype.mz = function (a, b, c) {
        if (this.bi == null || this.bi.bq.isEmpty || this.bi.bp.isEmpty) {
            return;
        }
        var d = this.mn.x;
        if (a.ce && isNaN_(d)) {
            d = 0;
        }
        d = this.bi.bp.left + this.bi.bp.width * (d - this.bi.bq.left) / this.bi.bq.width;
        var e = this.mn.y;
        if (!a.ce && isNaN_(e)) {
            e = 0;
        }
        e = this.bi.bp.top + this.bi.bp.height * (e - this.bi.bq.top) / this.bi.bq.height;
        var f = a.km({ $type: Point_$type, x: d, y: e }, c, this.mu);
        this.my(f, b, a);
    };
    CategoryHighlightLayer.prototype.my = function (a, b, c) {
        var d = new CategoryHighlightFrameRect();
        d.b = a.left;
        d.e = a.top;
        d.c = a.right;
        d.a = a.bottom;
        d.g = this.ml();
        d.h = this.mm();
        if (d.g == null) {
            d.g = this.mr.b7(c.ia);
        }
        if (d.h == null) {
            d.h = this.mr.b7(c.ia);
        }
        d.d = this.es;
        d.f = Base.getHashCodeStatic(c);
        if (!a.isEmpty) {
            b.g.addItem(d.f, d);
        }
    };
    CategoryHighlightLayer.prototype.mc = function (a, b) {
        _super.prototype.mc.call(this, a, b);
        var c = this.mr.b0;
        var d = a;
        var e = 0;
        try {
            for (var _a = tslib_1.__values(fromEnum(d.g.values)), _b = _a.next(); !_b.done; _b = _a.next()) {
                var f = _b.value;
                var g = c.item(e);
                this.m0(f, g);
                e++;
            }
        }
        catch (e_2_1) { e_2 = { error: e_2_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
            }
            finally { if (e_2) throw e_2.error; }
        }
        c.count = e;
        var e_2, _c;
    };
    CategoryHighlightLayer.prototype.c5 = function () {
        return true;
    };
    CategoryHighlightLayer.prototype.m0 = function (a, b) {
        if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
            b._visibility = 1;
            return;
        }
        this.mr.b2(b, a.b, a.e, a.c - a.b, a.a - a.e);
        b._fill = a.g;
        b._stroke = a.h;
        b.ac = a.d;
        if (this.kz != null) {
            b.ai = this.kz;
        }
        else {
            b.ai = null;
        }
        b.ad = this.k0;
    };
    CategoryHighlightLayer.prototype.io = function (a, b, c, d) {
        _super.prototype.io.call(this, a, b, c, d);
        switch (b) {
            case CategoryHighlightLayer.$$p[0]:
                this.i1(true);
                break;
            case CategoryHighlightLayer.$$p[1]:
                this.i1(true);
                break;
        }
    };
    CategoryHighlightLayer.m1 = DependencyProperty.i("BAndHighlightWidth", Number_$type, CategoryHighlightLayer.$, new PropertyMetadata(2, 10, function (a, b) { return a.raisePropertyChanged("BAndHighlightWidth", b.oldValue, b.newValue); }));
    CategoryHighlightLayer.$t = markType(CategoryHighlightLayer, 'CategoryHighlightLayer', AnnotationLayer.$);
    return CategoryHighlightLayer;
}(AnnotationLayer));
export { CategoryHighlightLayer };
Type.dep(DependencyProperty, PropertyMetadata, CategoryHighlightLayer, 'raisePropertyChanged', ['TargetAxis:mq:m2', [CategoryAxisBase.$, null], 'UseInterpolation:mt:m3', [0, false]]);
var CategoryHighlightLayerView = /** @class */ (function (_super) {
    tslib_1.__extends(CategoryHighlightLayerView, _super);
    function CategoryHighlightLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.bz = null;
        _this.b0 = null;
        _this.b1 = null;
        _this.bz = a;
        _this.b1 = new List$1(Rectangle.$, 0);
        return _this;
    }
    CategoryHighlightLayerView.prototype.ap = function () {
        var _this = this;
        _super.prototype.ap.call(this);
        this.b0 = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.b8);
            $ret.activate = runOn(_this, _this.b3);
            $ret.disactivate = runOn(_this, _this.b5);
            $ret.destroy = runOn(_this, _this.b4);
            return $ret;
        })());
    };
    CategoryHighlightLayerView.prototype.b8 = function () {
        var a = new Rectangle();
        a.ab = false;
        this.b1.add(a);
        return a;
    };
    CategoryHighlightLayerView.prototype.b3 = function (a) {
        a._visibility = 0;
    };
    CategoryHighlightLayerView.prototype.b5 = function (a) {
        a._visibility = 1;
    };
    CategoryHighlightLayerView.prototype.b4 = function (a) {
        this.b1.remove(a);
    };
    CategoryHighlightLayerView.prototype.b6 = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, 0.1);
    };
    CategoryHighlightLayerView.prototype.b7 = function (a) {
        if (a != null) {
            var b = BrushUtil.h(a, 0.3);
            if (b.isGradient) {
                var c = b;
                if (c.gradientStops != null) {
                    for (var d = 0; d < c.gradientStops.length; d++) {
                        var e = c.gradientStops[d];
                        e.color = Color.u(truncate(Math.round((e.color.l) * 0.2)), e.color.o, e.color.n, e.color.m);
                        e.color = e.color;
                    }
                }
            }
            else {
                b.color = Color.u(truncate(Math.round((b.color.l) * 0.2)), b.color.o, b.color.n, b.color.m);
                b.color = b.color;
            }
            return b;
        }
        else {
            return null;
        }
    };
    CategoryHighlightLayerView.prototype.b2 = function (a, b, c, d, e) {
        a._visibility = 0;
        a.n = b;
        a.o = c;
        a.width = d;
        a.height = e;
    };
    CategoryHighlightLayerView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d && !b) {
            for (var c = 0; c < this.b1.count; c++) {
                var d = this.b1._inner[c];
                if (d._visibility == 0) {
                    a.v(d);
                }
            }
        }
    };
    CategoryHighlightLayerView.prototype.ai = function (a) {
        _super.prototype.ai.call(this, a);
        for (var b = 0; b < this.b1.count; b++) {
            this.e.a2.exportRectangleData(a, this.b1._inner[b], "cihRect", ["Main", "CategoryItem"]);
        }
    };
    CategoryHighlightLayerView.$t = markType(CategoryHighlightLayerView, 'CategoryHighlightLayerView', AnnotationLayerView.$);
    return CategoryHighlightLayerView;
}(AnnotationLayerView));
export { CategoryHighlightLayerView };
/*<BeginStatics Name="Infragistics.Controls.Charts.CategoryHighlightLayer" />*/
/*<EndStatics Name="Infragistics.Controls.Charts.CategoryHighlightLayer" />*/
