/*
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-react-core";
import { CategoryHighlightLayerFrame } from "./CategoryHighlightLayerFrame";
import { Base, Number_$type, typeCast, fromEnum, Point_$type, markType, markDep, runOn } from "igniteui-react-core";
import { XamDataChart } from "./XamDataChart";
import { CategoryHighlightFrameRect } from "./CategoryHighlightFrameRect";
import { List$1 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, truncate } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
/**
 * @hidden
 */
export let CategoryHighlightLayer = /*@__PURE__*/ (() => {
    class CategoryHighlightLayer extends AnnotationLayer {
        constructor() {
            super();
            let a = new CategoryHighlightLayerFrame();
            let b = new CategoryHighlightLayerFrame();
            let c = new CategoryHighlightLayerFrame();
            let d = this.fi / 1000;
            this.mc = a;
            this.mb = b;
            this.md = c;
            this.ab = CategoryHighlightLayer.$;
        }
        bf() {
            return new CategoryHighlightLayerView(this);
        }
        i2(a) {
            super.i2(a);
            this.nf = a;
        }
        get ni() {
            return this.c(CategoryHighlightLayer.np);
        }
        set ni(a) {
            this.h(CategoryHighlightLayer.np, a);
        }
        mu(a, b) {
            if (this.ne == null || this.ne == a) {
                if (!this.aq.c) {
                    this.jl(b);
                }
            }
        }
        ng(a) {
            return a != null && a.cg();
        }
        mx(a, b) {
            super.mx(a, b);
            let c = a;
            c.g.clear();
            let d = this.nh;
            if (isNaN_(this.nb.x) && isNaN_(this.nb.y)) {
                return;
            }
            if (this.ne != null) {
                if (this.ng(this.ne)) {
                    this.nn(this.ne, 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.ng(f)) {
                            this.nn(f, c, d);
                        }
                    }
                }
            }
        }
        nn(a, b, c) {
            if (this.bi == null || this.bi.bs.isEmpty || this.bi.br.isEmpty) {
                return;
            }
            let d = this.nb.x;
            if (a.ch && 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.nb.y;
            if (!a.ch && 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.k2({ $type: Point_$type, x: d, y: e }, c, this.ni);
            this.nm(f, b, a);
        }
        nm(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.m9();
            d.h = this.na();
            if (d.g == null) {
                d.g = this.nf.b9(c.ir);
            }
            if (d.h == null) {
                d.h = this.nf.b9(c.ir);
            }
            d.d = this.ey;
            d.f = Base.getHashCodeStatic(c);
            if (!a.isEmpty) {
                b.g.addItem(d.f, d);
            }
        }
        m0(a, b) {
            super.m0(a, b);
            let c = this.nf.b2;
            let d = a;
            let e = 0;
            for (let f of fromEnum(d.g.values)) {
                let g = c.item(e);
                this.no(f, g);
                e++;
            }
            c.count = e;
        }
        c8() {
            return true;
        }
        no(a, b) {
            if (isNaN_(a.b) || isNaN_(a.e) || isNaN_(a.a) || isNaN_(a.c) || isNaN_(a.d)) {
                b._visibility = 1;
                return;
            }
            this.nf.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.ll != null) {
                b.ai = this.ll;
            }
            else {
                b.ai = null;
            }
            b.ad = this.lm;
        }
        i7(a, b, c, d) {
            super.i7(a, b, c, d);
            switch (b) {
                case CategoryHighlightLayer.$$p[0]:
                    this.jl(true);
                    break;
                case CategoryHighlightLayer.$$p[1]:
                    this.jl(true);
                    break;
            }
        }
    }
    CategoryHighlightLayer.$t = /*@__PURE__*/ markType(CategoryHighlightLayer, 'CategoryHighlightLayer', AnnotationLayer.$);
    CategoryHighlightLayer.np = /*@__PURE__*/ DependencyProperty.i("BAndHighlightWidth", Number_$type, CategoryHighlightLayer.$, /*@__PURE__*/ new PropertyMetadata(2, 10, (a, b) => a.raisePropertyChanged("BAndHighlightWidth", b.oldValue, b.newValue)));
    CategoryHighlightLayer.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, CategoryHighlightLayer, 'raisePropertyChanged', ['TargetAxis:ne:nq', [CategoryAxisBase.$, null], 'UseInterpolation:nh:nr', [0, false]]);
    return CategoryHighlightLayer;
})();
/**
 * @hidden
 */
export let CategoryHighlightLayerView = /*@__PURE__*/ (() => {
    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.l(a, 0.1);
        }
        b9(a) {
            if (a != null) {
                let b = BrushUtil.l(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 = /*@__PURE__*/ markType(CategoryHighlightLayerView, 'CategoryHighlightLayerView', AnnotationLayerView.$);
    return CategoryHighlightLayerView;
})();
//# sourceMappingURL=CategoryHighlightLayer_combined.js.map
