/*
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 { AnnotationLayer } from "./AnnotationLayer";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { DependencyProperty } from "igniteui-angular-core/ES2015/DependencyProperty";
import { CategoryHighlightLayerFrame } from "./CategoryHighlightLayerFrame";
import { Type, Base, Number_$type, typeCast, fromEnum, Point_$type, markType, runOn } from "igniteui-angular-core/ES2015/type";
import { XamDataChart } from "./XamDataChart";
import { CategoryHighlightFrameRect } from "./CategoryHighlightFrameRect";
import { List$1 } from "igniteui-angular-core/ES2015/List$1";
import { Pool$1 } from "igniteui-angular-core/ES2015/Pool$1";
import { Rectangle } from "igniteui-angular-core/ES2015/Rectangle";
import { PropertyMetadata } from "igniteui-angular-core/ES2015/PropertyMetadata";
import { isNaN_, truncate } from "igniteui-angular-core/ES2015/number";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-angular-core/ES2015/BrushUtil";
import { Color } from "igniteui-angular-core/ES2015/Color";
/**
 * @hidden
 */
export class CategoryHighlightLayer extends AnnotationLayer {
    constructor() {
        super();
        let a = new CategoryHighlightLayerFrame();
        let b = new CategoryHighlightLayerFrame();
        let c = new CategoryHighlightLayerFrame();
        let d = this.ff / 1000;
        this.lu = a;
        this.lt = b;
        this.lv = c;
        this.ab = CategoryHighlightLayer.$;
    }
    bf() {
        return new CategoryHighlightLayerView(this);
    }
    im(a) {
        super.im(a);
        this.mv = a;
    }
    get my() {
        return this.c(CategoryHighlightLayer.m5);
    }
    set my(a) {
        this.h(CategoryHighlightLayer.m5, a);
    }
    ma(a, b) {
        if (this.mu == null || this.mu == a) {
            if (!this.aq.c) {
                this.i5(b);
            }
        }
    }
    mw(a) {
        return a != null && a.cd();
    }
    md(a, b) {
        super.md(a, b);
        let c = a;
        c.g.clear();
        let d = this.mx;
        if (isNaN_(this.mr.x) && isNaN_(this.mr.y)) {
            return;
        }
        if (this.mu != null) {
            if (this.mw(this.mu)) {
                this.m3(this.mu, c, d);
            }
        }
        else {
            if (typeCast(XamDataChart.$, this.bs) !== null) {
                let e = this.bs;
                for (let f of fromEnum(e.axes)) {
                    if (typeCast(CategoryAxisBase.$, f) !== null && this.mw(f)) {
                        this.m3(f, c, d);
                    }
                }
            }
        }
    }
    m3(a, b, c) {
        if (this.bi == null || this.bi.bs.isEmpty || this.bi.br.isEmpty) {
            return;
        }
        let d = this.mr.x;
        if (a.ce && isNaN_(d)) {
            d = 0;
        }
        d = this.bi.br.left + this.bi.br.width * (d - this.bi.bs.left) / this.bi.bs.width;
        let e = this.mr.y;
        if (!a.ce && isNaN_(e)) {
            e = 0;
        }
        e = this.bi.br.top + this.bi.br.height * (e - this.bi.bs.top) / this.bi.bs.height;
        let f = a.kn({ $type: Point_$type, x: d, y: e }, c, this.my);
        this.m2(f, b, a);
    }
    m2(a, b, c) {
        let d = new CategoryHighlightFrameRect();
        d.b = a.left;
        d.e = a.top;
        d.c = a.right;
        d.a = a.bottom;
        d.g = this.mp();
        d.h = this.mq();
        if (d.g == null) {
            d.g = this.mv.b9(c.ib);
        }
        if (d.h == null) {
            d.h = this.mv.b9(c.ib);
        }
        d.d = this.ev;
        d.f = Base.getHashCodeStatic(c);
        if (!a.isEmpty) {
            b.g.addItem(d.f, d);
        }
    }
    mg(a, b) {
        super.mg(a, b);
        let c = this.mv.b2;
        let d = a;
        let e = 0;
        for (let f of fromEnum(d.g.values)) {
            let g = c.item(e);
            this.m4(f, g);
            e++;
        }
        c.count = e;
    }
    c7() {
        return true;
    }
    m4(a, b) {
        if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
            b._visibility = 1;
            return;
        }
        this.mv.b4(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.k3 != null) {
            b.ai = this.k3;
        }
        else {
            b.ai = null;
        }
        b.ad = this.k4;
    }
    is(a, b, c, d) {
        super.is(a, b, c, d);
        switch (b) {
            case CategoryHighlightLayer.$$p[0]:
                this.i5(true);
                break;
            case CategoryHighlightLayer.$$p[1]:
                this.i5(true);
                break;
        }
    }
}
CategoryHighlightLayer.$t = markType(CategoryHighlightLayer, 'CategoryHighlightLayer', AnnotationLayer.$);
CategoryHighlightLayer.m5 = DependencyProperty.i("BAndHighlightWidth", Number_$type, CategoryHighlightLayer.$, new PropertyMetadata(2, 10, (a, b) => a.raisePropertyChanged("BAndHighlightWidth", b.oldValue, b.newValue)));
Type.dep(DependencyProperty, PropertyMetadata, CategoryHighlightLayer, 'raisePropertyChanged', ['TargetAxis:mu:m6', [CategoryAxisBase.$, null], 'UseInterpolation:mx:m7', [0, false]]);
/**
 * @hidden
 */
export class CategoryHighlightLayerView extends AnnotationLayerView {
    constructor(a) {
        super(a);
        this.b1 = null;
        this.b2 = null;
        this.b3 = null;
        this.b1 = a;
        this.b3 = new List$1(Rectangle.$, 0);
    }
    ap() {
        super.ap();
        this.b2 = ((() => {
            let $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(this, this.ca);
            $ret.activate = runOn(this, this.b5);
            $ret.disactivate = runOn(this, this.b7);
            $ret.destroy = runOn(this, this.b6);
            return $ret;
        })());
    }
    ca() {
        let a = new Rectangle();
        a.ab = false;
        this.b3.add(a);
        return a;
    }
    b5(a) {
        a._visibility = 0;
    }
    b7(a) {
        a._visibility = 1;
    }
    b6(a) {
        this.b3.remove(a);
    }
    b8(a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.h(a, 0.1);
    }
    b9(a) {
        if (a != null) {
            let b = BrushUtil.h(a, 0.3);
            if (b.isGradient) {
                let c = b;
                if (c.gradientStops != null) {
                    for (let d = 0; d < c.gradientStops.length; d++) {
                        let 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;
        }
    }
    b4(a, b, c, d, e) {
        a._visibility = 0;
        a.n = b;
        a.o = c;
        a.width = d;
        a.height = e;
    }
    a3(a, b) {
        super.a3(a, b);
        if (a.d && !b) {
            for (let c = 0; c < this.b3.count; c++) {
                let d = this.b3._inner[c];
                if (d._visibility == 0) {
                    a.v(d);
                }
            }
        }
    }
    ai(a) {
        super.ai(a);
        for (let b = 0; b < this.b3.count; b++) {
            this.e.a2.exportRectangleData(a, this.b3._inner[b], "cihRect", ["Main", "CategoryItem"]);
        }
    }
}
CategoryHighlightLayerView.$t = markType(CategoryHighlightLayerView, 'CategoryHighlightLayerView', AnnotationLayerView.$);
//# sourceMappingURL=CategoryHighlightLayer_combined.js.map